- getNextIncarnation

Event queue handling not refactored yet.
This commit is contained in:
Christoph Oelckers 2021-05-06 08:39:33 +02:00
parent d892efb78a
commit eb478ba580
4 changed files with 22 additions and 12 deletions

View file

@ -2947,7 +2947,7 @@ static bool actKillModernDude(DBloodActor* actor, DAMAGE_TYPE damageType)
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
GENDUDEEXTRA* pExtra = &actor->genDudeExtra(); GENDUDEEXTRA* pExtra = &actor->genDudeExtra();
removeDudeStuff(actor); removeDudeStuff(actor);
if (pXSprite->txID <= 0 || getNextIncarnation(pXSprite) == nullptr) if (pXSprite->txID <= 0 || getNextIncarnation(actor) == nullptr)
{ {
if (pExtra->weaponType == kGenDudeWeaponKamikaze && Chance(0x4000) && damageType != kDamageSpirit && damageType != kDamageDrown) if (pExtra->weaponType == kGenDudeWeaponKamikaze && Chance(0x4000) && damageType != kDamageSpirit && damageType != kDamageDrown)
{ {

View file

@ -1056,7 +1056,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
if (nDmgType == kDamageBurn) if (nDmgType == kDamageBurn)
{ {
if (pXSprite->health > (uint32_t)pDudeInfo->fleeHealth) return nDamage; if (pXSprite->health > (uint32_t)pDudeInfo->fleeHealth) return nDamage;
else if (pXSprite->txID <= 0 || getNextIncarnation(pXSprite) == nullptr) else if (pXSprite->txID <= 0 || getNextIncarnation(actor) == nullptr)
{ {
removeDudeStuff(actor); removeDudeStuff(actor);

View file

@ -1506,17 +1506,26 @@ void killDudeLeech(DBloodActor* actLeech)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
XSPRITE* getNextIncarnation(XSPRITE* pXSprite) { DBloodActor* getNextIncarnation(DBloodActor* actor)
for (int i = bucketHead[pXSprite->txID]; i < bucketHead[pXSprite->txID + 1]; i++) { {
if (rxBucket[i].type != 3 || rxBucket[i].index == pXSprite->reference) XSPRITE* pXSprite = &actor->x();
for (int i = bucketHead[pXSprite->txID]; i < bucketHead[pXSprite->txID + 1]; i++)
{
if (rxBucket[i].type != OBJ_SPRITE || rxBucket[i].index == pXSprite->reference)
continue; continue;
if (sprite[rxBucket[i].index].statnum == kStatInactive) if (sprite[rxBucket[i].index].statnum == kStatInactive)
return &xsprite[sprite[rxBucket[i].index].extra]; return &bloodActors[sprite[rxBucket[i].index].index];
} }
return NULL; return NULL;
} }
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
bool dudeIsMelee(XSPRITE* pXSprite) { bool dudeIsMelee(XSPRITE* pXSprite) {
return gGenDudeExtra[sprite[pXSprite->reference].index].isMelee; return gGenDudeExtra[sprite[pXSprite->reference].index].isMelee;
} }
@ -1967,14 +1976,15 @@ void genDudeTransform(spritetype* pSprite) {
XSPRITE* pXSprite = &xsprite[pSprite->extra]; XSPRITE* pXSprite = &xsprite[pSprite->extra];
auto actor = &bloodActors[pXSprite->reference]; auto actor = &bloodActors[pXSprite->reference];
XSPRITE* pXIncarnation = getNextIncarnation(pXSprite); auto actIncarnation = getNextIncarnation(actor);
if (pXIncarnation == NULL) { if (actIncarnation == NULL) {
if (pXSprite->sysData1 == kGenDudeTransformStatus) pXSprite->sysData1 = 0; if (pXSprite->sysData1 == kGenDudeTransformStatus) pXSprite->sysData1 = 0;
trTriggerSprite(pSprite->index, pXSprite, kCmdOff); trTriggerSprite(pSprite->index, pXSprite, kCmdOff);
return; return;
} }
spritetype* pIncarnation = &sprite[pXIncarnation->reference]; auto pXIncarnation = &actIncarnation->x();
spritetype* pIncarnation = &actIncarnation->s();
pXSprite->key = pXSprite->dropMsg = pXSprite->locked = 0; pXSprite->key = pXSprite->dropMsg = pXSprite->locked = 0;
// save incarnation's going on and off options // save incarnation's going on and off options

View file

@ -195,7 +195,7 @@ struct GENDUDEEXTRA
extern GENDUDEEXTRA gGenDudeExtra[kMaxSprites]; extern GENDUDEEXTRA gGenDudeExtra[kMaxSprites];
XSPRITE* getNextIncarnation(XSPRITE* pXSprite); DBloodActor* getNextIncarnation(DBloodActor* actor);
void killDudeLeech(DBloodActor* pLeech); void killDudeLeech(DBloodActor* pLeech);
void removeLeech(DBloodActor* pLeech, bool delSprite = true); void removeLeech(DBloodActor* pLeech, bool delSprite = true);
void removeDudeStuff(DBloodActor* pSprite); void removeDudeStuff(DBloodActor* pSprite);