- 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();
GENDUDEEXTRA* pExtra = &actor->genDudeExtra();
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)
{

View file

@ -1056,7 +1056,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
if (nDmgType == kDamageBurn)
{
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);

View file

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

View file

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