- genDudePrepare

This commit is contained in:
Christoph Oelckers 2021-05-06 10:51:39 +02:00
parent fb5916a3dd
commit 013eadfd9f
5 changed files with 22 additions and 22 deletions

View file

@ -2482,7 +2482,7 @@ static void actInitDudes()
case kDudeModernCustom: case kDudeModernCustom:
case kDudeModernCustomBurning: case kDudeModernCustomBurning:
pSprite->cstat |= 4096 + CSTAT_SPRITE_BLOCK_HITSCAN + CSTAT_SPRITE_BLOCK; pSprite->cstat |= 4096 + CSTAT_SPRITE_BLOCK_HITSCAN + CSTAT_SPRITE_BLOCK;
seqStartId = genDudeSeqStartId(pXSprite); // Custom Dude stores its SEQ in data2 seqStartId = genDudeSeqStartId(act); // Custom Dude stores its SEQ in data2
pXSprite->sysData1 = pXSprite->data3; // move sndStartId to sysData1, because data3 used by the game; pXSprite->sysData1 = pXSprite->data3; // move sndStartId to sysData1, because data3 used by the game;
pXSprite->data3 = 0; pXSprite->data3 = 0;
break; break;

View file

@ -1901,7 +1901,7 @@ void aiInitSprite(DBloodActor* actor)
case kDudeModernCustomBurning: case kDudeModernCustomBurning:
if (!gModernMap) break; if (!gModernMap) break;
aiGenDudeInitSprite(pSprite, pXSprite); aiGenDudeInitSprite(pSprite, pXSprite);
genDudePrepare(pSprite, kGenDudePropertyAll); genDudePrepare(actor, kGenDudePropertyAll);
break; break;
#endif #endif
default: default:

View file

@ -188,7 +188,7 @@ void genDudeUpdate(DBloodActor* actor)
{ {
GENDUDEEXTRA* pExtra = &actor->genDudeExtra(); GENDUDEEXTRA* pExtra = &actor->genDudeExtra();
for (int i = 0; i < kGenDudePropertyMax; i++) { for (int i = 0; i < kGenDudePropertyMax; i++) {
if (pExtra->updReq[i]) genDudePrepare(&actor->s(), i); if (pExtra->updReq[i]) genDudePrepare(actor, i);
} }
} }
@ -1987,7 +1987,7 @@ DBloodActor* genDudeSpawn(DBloodActor* source, DBloodActor* actor, int nDist)
pXDude->data3 = 0; pXDude->data3 = 0;
// spawn seq // spawn seq
seqSpawn(genDudeSeqStartId(pXDude), 3, pDude->extra, -1); seqSpawn(genDudeSeqStartId(spawned), 3, pDude->extra, -1);
// inherit movement speed. // inherit movement speed.
pXDude->busyTime = pXSource->busyTime; pXDude->busyTime = pXSource->busyTime;
@ -2132,8 +2132,8 @@ void genDudeTransform(DBloodActor* actor)
break; break;
case kDudeModernCustom: case kDudeModernCustom:
case kDudeModernCustomBurning: case kDudeModernCustomBurning:
seqId = genDudeSeqStartId(pXSprite); seqId = genDudeSeqStartId(actor);
genDudePrepare(pSprite, kGenDudePropertyMass); genDudePrepare(actor, kGenDudePropertyMass);
[[fallthrough]]; // go below [[fallthrough]]; // go below
default: default:
seqSpawn(seqId, 3, pSprite->extra, -1); seqSpawn(seqId, 3, pSprite->extra, -1);
@ -2343,19 +2343,20 @@ bool canWalk(DBloodActor* actor)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
int genDudeSeqStartId(XSPRITE* pXSprite) { int genDudeSeqStartId(DBloodActor* actor)
if (genDudePrepare(&sprite[pXSprite->reference], kGenDudePropertyStates)) return pXSprite->data2; {
if (genDudePrepare(actor, kGenDudePropertyStates)) return actor->x().data2;
else return kGenDudeDefaultSeq; else return kGenDudeDefaultSeq;
} }
bool genDudePrepare(spritetype* pSprite, int propId) { bool genDudePrepare(DBloodActor* actor, int propId)
if (!spriRangeIsFine(pSprite->index)) { {
Printf(PRINT_HIGH, "!spriRangeIsFine(pSprite->index)"); if (!actor || !actor->hasX()) return false;
return false;
} else if (!xspriRangeIsFine(pSprite->extra)) { auto const pSprite = &actor->s();
Printf(PRINT_HIGH, "!xspriRangeIsFine(pSprite->extra)"); auto const pXSprite = &actor->x();
return false;
} else if (pSprite->type != kDudeModernCustom) { if (pSprite->type != kDudeModernCustom) {
Printf(PRINT_HIGH, "pSprite->type != kDudeModernCustom"); Printf(PRINT_HIGH, "pSprite->type != kDudeModernCustom");
return false; return false;
} else if (propId < kGenDudePropertyAll || propId >= kGenDudePropertyMax) { } else if (propId < kGenDudePropertyAll || propId >= kGenDudePropertyMax) {
@ -2363,9 +2364,8 @@ bool genDudePrepare(spritetype* pSprite, int propId) {
return false; return false;
} }
auto actor = &bloodActors[pSprite->index]; GENDUDEEXTRA* pExtra = &actor->genDudeExtra();
XSPRITE* pXSprite = &xsprite[pSprite->extra]; pExtra->updReq[propId] = false;
GENDUDEEXTRA* pExtra = &gGenDudeExtra[pSprite->index]; pExtra->updReq[propId] = false;
switch (propId) { switch (propId) {
case kGenDudePropertyAll: case kGenDudePropertyAll:

View file

@ -225,8 +225,8 @@ short inRecoil(AISTATE* aiState);
short inSearch(AISTATE* aiState); short inSearch(AISTATE* aiState);
short inChase(AISTATE* aiState); short inChase(AISTATE* aiState);
short inDuck(AISTATE* aiState); short inDuck(AISTATE* aiState);
int genDudeSeqStartId(XSPRITE* pXSprite); int genDudeSeqStartId(DBloodActor* pXSprite);
bool genDudePrepare(spritetype* pSprite, int propId); bool genDudePrepare(DBloodActor* pSprite, int propId);
void genDudeUpdate(DBloodActor* pSprite); void genDudeUpdate(DBloodActor* pSprite);
void genDudePostDeath(spritetype* pSprite, DAMAGE_TYPE damageType, int damage); void genDudePostDeath(spritetype* pSprite, DAMAGE_TYPE damageType, int damage);
void aiGenDudeInitSprite(spritetype* pSprite, XSPRITE* pXSprite); void aiGenDudeInitSprite(spritetype* pSprite, XSPRITE* pXSprite);

View file

@ -262,7 +262,7 @@ void Respawn(int nSprite) // 9
seqSpawn(getDudeInfo(nType + kDudeBase)->seqStartID, 3, pSprite->extra, -1); seqSpawn(getDudeInfo(nType + kDudeBase)->seqStartID, 3, pSprite->extra, -1);
break; break;
case kDudeModernCustom: case kDudeModernCustom:
seqSpawn(genDudeSeqStartId(pXSprite), 3, pSprite->extra, -1); seqSpawn(genDudeSeqStartId(actor), 3, pSprite->extra, -1);
break; break;
} }