Skip to content

Commit

Permalink
- getNextIncarnation
Browse files Browse the repository at this point in the history
Event queue handling not refactored yet.
  • Loading branch information
coelckers committed Oct 12, 2021
1 parent d892efb commit eb478ba
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion source/games/blood/src/actor.cpp
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/ai.cpp
Expand Up @@ -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);

Expand Down
28 changes: 19 additions & 9 deletions source/games/blood/src/aiunicult.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/aiunicult.h
Expand Up @@ -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);
Expand Down

0 comments on commit eb478ba

Please sign in to comment.