- 3 smaller functions.

This commit is contained in:
Christoph Oelckers 2021-08-28 09:50:01 +02:00
parent 733d9b2e2b
commit bb094fd003
4 changed files with 47 additions and 28 deletions

View file

@ -2985,7 +2985,7 @@ static bool actKillModernDude(DBloodActor* actor, DAMAGE_TYPE damageType)
{
pXSprite->locked = 1; // lock while transforming
aiSetGenIdleState(pSprite, pXSprite); // set idle state
aiSetGenIdleState(actor); // set idle state
if (pXSprite->key > 0) // drop keys
actDropObject(actor, kItemKeyBase + pXSprite->key - 1);

View file

@ -1922,11 +1922,9 @@ void debrisMove(int listIndex)
}
else
{
actor->hit().florhit.setNone();
if (pXSprite->physAttr & kPhysGravity)
pXSprite->physAttr |= kPhysFalling;
}
if (top <= ceilZ)
@ -1976,26 +1974,36 @@ void debrisMove(int listIndex)
actor->xvel() = actor->yvel() = 0;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
bool ceilIsTooLow(spritetype* pSprite) {
if (pSprite != NULL) {
sectortype* pSector = &sector[pSprite->sectnum];
bool ceilIsTooLow(DBloodActor* actor)
{
if (actor != nullptr)
{
sectortype* pSector = &sector[actor->s().sectnum];
int a = pSector->ceilingz - pSector->floorz;
int top, bottom;
GetSpriteExtents(pSprite, &top, &bottom);
GetActorExtents(actor, &top, &bottom);
int b = top - bottom;
if (a > b) return true;
}
return false;
}
void aiSetGenIdleState(spritetype* pSprite, XSPRITE* pXSprite)
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void aiSetGenIdleState(DBloodActor* actor)
{
auto actor = &bloodActors[pXSprite->reference];
switch (pSprite->type) {
switch (actor->s().type)
{
case kDudeModernCustom:
case kDudeModernCustomBurning:
aiGenDudeNewState(actor, &genIdle);
@ -2006,27 +2014,39 @@ void aiSetGenIdleState(spritetype* pSprite, XSPRITE* pXSprite)
}
}
//---------------------------------------------------------------------------
//
// this function stops wind on all TX sectors affected by WindGen after it goes off state.
void windGenStopWindOnSectors(XSPRITE* pXSource) {
spritetype* pSource = &sprite[pXSource->reference];
if (pXSource->txID <= 0 && xsectRangeIsFine(sector[pSource->sectnum].extra)) {
//
//---------------------------------------------------------------------------
void windGenStopWindOnSectors(DBloodActor* sourceactor)
{
spritetype* pSource = &sourceactor->s();
auto pXSource = &sourceactor->x();
if (pXSource->txID <= 0 && xsectRangeIsFine(sector[pSource->sectnum].extra))
{
xsector[sector[pSource->sectnum].extra].windVel = 0;
return;
}
for (int i = bucketHead[pXSource->txID]; i < bucketHead[pXSource->txID + 1]; i++) {
for (int i = bucketHead[pXSource->txID]; i < bucketHead[pXSource->txID + 1]; i++)
{
if (rxBucket[i].type != OBJ_SECTOR) continue;
XSECTOR* pXSector = &xsector[sector[rxBucket[i].rxindex].extra];
if ((pXSector->state == 1 && !pXSector->windAlways)
|| ((pSource->flags & kModernTypeFlag1) && !(pSource->flags & kModernTypeFlag2))) {
|| ((pSource->flags & kModernTypeFlag1) && !(pSource->flags & kModernTypeFlag2)))
{
pXSector->windVel = 0;
}
}
// check redirected TX buckets
int rx = -1; XSPRITE* pXRedir = NULL;
while ((pXRedir = evrListRedirectors(OBJ_SPRITE, sprite[pXSource->reference].extra, pXRedir, &rx)) != NULL) {
for (int i = bucketHead[rx]; i < bucketHead[rx + 1]; i++) {
int rx = -1; XSPRITE* pXRedir = nullptr;
while ((pXRedir = evrListRedirectors(OBJ_SPRITE, sprite[pXSource->reference].extra, pXRedir, &rx)) != nullptr)
{
for (int i = bucketHead[rx]; i < bucketHead[rx + 1]; i++)
{
if (rxBucket[i].type != OBJ_SECTOR) continue;
XSECTOR* pXSector = &xsector[sector[rxBucket[i].rxindex].extra];
if ((pXSector->state == 1 && !pXSector->windAlways) || (pSource->flags & kModernTypeFlag2))
@ -5203,7 +5223,7 @@ bool modernTypeOperateSprite(int nSprite, spritetype* pSprite, XSPRITE* pXSprite
case kModernWindGenerator:
switch (event.cmd) {
case kCmdOff:
windGenStopWindOnSectors(pXSprite);
windGenStopWindOnSectors(actor);
if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0);
break;
case kCmdOn:
@ -6173,7 +6193,7 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) {
auto actLeech = leechIsDropped(actor);
if (pXSource->data4 == 3) {
aiSetTarget_(pXSprite, pSprite->x, pSprite->y, pSprite->z);
aiSetGenIdleState(pSprite, pXSprite);
aiSetGenIdleState(&bloodActors[pSprite->index]);
if (pSprite->type == kDudeModernCustom && actLeech)
removeLeech(actLeech);
} else if (pXSource->data4 == 4) {

View file

@ -308,7 +308,7 @@ void debrisBubble(DBloodActor* nSprite);
void debrisMove(int listIndex);
void debrisConcuss(DBloodActor* nOwner, int listIndex, int x, int y, int z, int dmg);
// ------------------------------------------------------------------------- //
void aiSetGenIdleState(spritetype* pSprite, XSPRITE* pXSprite);
void aiSetGenIdleState(DBloodActor*);
// triggers related
// ------------------------------------------------------------------------- //
@ -396,9 +396,8 @@ bool isActive(int nSprite);
int getDataFieldOfObject(int objType, int objIndex, DBloodActor* objActor, int dataIndex);
bool setDataValueOfObject(int objType, int objIndex, int dataIndex, int value);
bool incDecGoalValueIsReached(XSPRITE* pXSprite);
void windGenStopWindOnSectors(XSPRITE* pXSource);
int getSpriteMassBySize(DBloodActor* pSprite);
bool ceilIsTooLow(spritetype* pSprite);
bool ceilIsTooLow(DBloodActor* pSprite);
void levelEndLevelCustom(int nLevel);
int useCondition(spritetype* pSource, XSPRITE* pXSource, EVENT event);
bool condPush(XSPRITE* pXSprite, int objType, int objIndex);

View file

@ -267,7 +267,7 @@ char powerupActivate(PLAYER *pPlayer, int nPowerUp)
pPlayer->pwUpTime[kPwUpShadowCloak] = 0;
}
if (ceilIsTooLow(pPlayer->pSprite))
if (ceilIsTooLow(pPlayer->actor()))
actDamageSprite(pPlayer->actor(), pPlayer->actor(), kDamageExplode, 65535);
}
break;
@ -315,7 +315,7 @@ void powerupDeactivate(PLAYER *pPlayer, int nPowerUp)
case kItemShroomShrink:
if (gModernMap) {
playerSizeReset(pPlayer);
if (ceilIsTooLow(pPlayer->pSprite))
if (ceilIsTooLow(pPlayer->actor()))
actDamageSprite(pPlayer->actor(), pPlayer->actor(), kDamageExplode, 65535);
}
break;