- genDudeSpawn, genDudeTransform and updateTargetOfLeech.

This commit is contained in:
Christoph Oelckers 2021-05-06 09:55:56 +02:00
parent e41fcb92ab
commit c42e26351e
6 changed files with 31 additions and 32 deletions

View file

@ -6186,7 +6186,7 @@ static void actCheckDudes()
if (pSprite->type == kDudeModernCustom && pXSprite->txID > 0 && pXSprite->sysData1 == kGenDudeTransformStatus) if (pSprite->type == kDudeModernCustom && pXSprite->txID > 0 && pXSprite->sysData1 == kGenDudeTransformStatus)
{ {
actor->xvel() = actor->yvel() = 0; actor->xvel() = actor->yvel() = 0;
if (seqGetStatus(actor) < 0) genDudeTransform(pSprite); if (seqGetStatus(actor) < 0) genDudeTransform(actor);
} }
#endif #endif
if (pSprite->type == kDudeCerberusTwoHead) if (pSprite->type == kDudeCerberusTwoHead)

View file

@ -1670,7 +1670,7 @@ void aiProcessDudes(void)
case kDudeModernCustomBurning: { case kDudeModernCustomBurning: {
GENDUDEEXTRA* pExtra = &actor->genDudeExtra(); GENDUDEEXTRA* pExtra = &actor->genDudeExtra();
if (pExtra->slaveCount > 0) updateTargetOfSlaves(pSprite); if (pExtra->slaveCount > 0) updateTargetOfSlaves(pSprite);
if (pExtra->pLifeLeech != nullptr) updateTargetOfLeech(pSprite); if (pExtra->pLifeLeech != nullptr) updateTargetOfLeech(actor);
if (pXSprite->stateTimer == 0 && pXSprite->aiState && pXSprite->aiState->nextState if (pXSprite->stateTimer == 0 && pXSprite->aiState && pXSprite->aiState->nextState
&& (pXSprite->aiState->stateTicks > 0 || seqGetStatus(3, pSprite->extra) < 0)) && (pXSprite->aiState->stateTicks > 0 || seqGetStatus(3, pSprite->extra) < 0))
{ {

View file

@ -1949,10 +1949,13 @@ bool doExplosion(DBloodActor* actor, int nType)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
spritetype* genDudeSpawn(XSPRITE* pXSource, spritetype* pSprite, int nDist) DBloodActor* genDudeSpawn(DBloodActor* source, DBloodActor* actor, int nDist)
{ {
DBloodActor* actor = &bloodActors[pSprite->index]; spritetype* pSprite = &actor->s();
spritetype* pSource = &sprite[pXSource->reference];
spritetype* pSource = &source->s();
auto pXSource = &source->x();
auto spawned = actSpawnSprite(actor, kStatDude); auto spawned = actSpawnSprite(actor, kStatDude);
spritetype* pDude = &spawned->s(); spritetype* pDude = &spawned->s();
XSPRITE* pXDude = &spawned->x(); XSPRITE* pXDude = &spawned->x();
@ -2036,7 +2039,7 @@ spritetype* genDudeSpawn(XSPRITE* pXSource, spritetype* pSprite, int nDist)
gKillMgr.AddNewKill(1); gKillMgr.AddNewKill(1);
aiInitSprite(spawned); aiInitSprite(spawned);
return pDude; return spawned;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -2045,17 +2048,16 @@ spritetype* genDudeSpawn(XSPRITE* pXSource, spritetype* pSprite, int nDist)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void genDudeTransform(spritetype* pSprite) { void genDudeTransform(DBloodActor* actor)
{
if (!actor->hasX()) return;
if (!(pSprite->extra >= 0 && pSprite->extra < kMaxXSprites)) { auto const pSprite = &actor->s();
Printf(PRINT_HIGH, "pSprite->extra >= 0 && pSprite->extra < kMaxXSprites"); auto const pXSprite = &actor->x();
return;
}
XSPRITE* pXSprite = &xsprite[pSprite->extra];
auto actor = &bloodActors[pXSprite->reference];
auto actIncarnation = getNextIncarnation(actor); auto actIncarnation = getNextIncarnation(actor);
if (actIncarnation == 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;
@ -2171,13 +2173,11 @@ void genDudeTransform(spritetype* pSprite) {
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void updateTargetOfLeech(spritetype* pSprite) { void updateTargetOfLeech(DBloodActor* actor)
if (!(pSprite->extra >= 0 && pSprite->extra < kMaxXSprites)) { {
Printf(PRINT_HIGH, "pSprite->extra >= 0 && pSprite->extra < kMaxXSprites"); if (!actor->hasX()) return;
return;
} auto const pSprite = &actor->s();
auto actor = &bloodActors[pSprite->index];
auto actLeech = leechIsDropped(actor); auto actLeech = leechIsDropped(actor);
if (actLeech == NULL || !actLeech->hasX()) actor->genDudeExtra().pLifeLeech = nullptr; if (actLeech == NULL || !actLeech->hasX()) actor->genDudeExtra().pLifeLeech = nullptr;

View file

@ -207,14 +207,14 @@ void aiGenDudeChooseDirection(DBloodActor* actor, int a3, int aXvel = -1, int aY
void aiGenDudeNewState(DBloodActor* actor, AISTATE* pAIState); void aiGenDudeNewState(DBloodActor* actor, AISTATE* pAIState);
int checkAttackState(DBloodActor* actor); int checkAttackState(DBloodActor* actor);
bool doExplosion(DBloodActor* pSprite, int nType); bool doExplosion(DBloodActor* pSprite, int nType);
spritetype* genDudeSpawn(XSPRITE* pXSource, spritetype* pSprite, int nDist); DBloodActor* genDudeSpawn(DBloodActor* source, DBloodActor* pSprite, int nDist);
void genDudeTransform(spritetype* pSprite); void genDudeTransform(DBloodActor* pSprite);
void dudeLeechOperate(DBloodActor* actor, const EVENT& a3); void dudeLeechOperate(DBloodActor* actor, const EVENT& a3);
int getDodgeChance(DBloodActor* pSprite); int getDodgeChance(DBloodActor* pSprite);
int getRecoilChance(DBloodActor* pSprite); int getRecoilChance(DBloodActor* pSprite);
bool dudeIsMelee(DBloodActor* pXSprite); bool dudeIsMelee(DBloodActor* pXSprite);
void updateTargetOfSlaves(spritetype* pSprite); void updateTargetOfSlaves(spritetype* pSprite);
void updateTargetOfLeech(spritetype* pSprite); void updateTargetOfLeech(DBloodActor* pSprite);
bool canSwim(spritetype* pSprite); bool canSwim(spritetype* pSprite);
bool canDuck(spritetype* pSprite); bool canDuck(spritetype* pSprite);
bool canWalk(spritetype* pSprite); bool canWalk(spritetype* pSprite);

View file

@ -4307,7 +4307,7 @@ void modernTypeTrigger(int destObjType, int destObjIndex, EVENT event) {
// spawn custom dude on TX ID sprites // spawn custom dude on TX ID sprites
case kModernCustomDudeSpawn: case kModernCustomDudeSpawn:
if (destObjType != OBJ_SPRITE) break; if (destObjType != OBJ_SPRITE) break;
useCustomDudeSpawn(pXSource, &sprite[destObjIndex]); useCustomDudeSpawn(&bloodActors[pXSource->reference], &bloodActors[destObjIndex]);
break; break;
} }
} }
@ -4740,10 +4740,9 @@ bool modernTypeOperateSector(int nSector, sectortype* pSector, XSECTOR* pXSector
} }
void useCustomDudeSpawn(XSPRITE* pXSource, spritetype* pSprite) { void useCustomDudeSpawn(DBloodActor* pSource, DBloodActor* pSprite)
{
genDudeSpawn(pXSource, pSprite, pSprite->clipdist << 1); genDudeSpawn(pSource, pSprite, pSprite->s().clipdist << 1);
} }
void useDudeSpawn(XSPRITE* pXSource, spritetype* pSprite) { void useDudeSpawn(XSPRITE* pXSource, spritetype* pSprite) {
@ -4851,7 +4850,7 @@ bool modernTypeOperateSprite(int nSprite, spritetype* pSprite, XSPRITE* pXSprite
return true; return true;
case kModernCustomDudeSpawn: case kModernCustomDudeSpawn:
if (!gGameOptions.nMonsterSettings) return true; if (!gGameOptions.nMonsterSettings) return true;
else if (!(pSprite->flags & kModernTypeFlag4)) useCustomDudeSpawn(pXSprite, pSprite); else if (!(pSprite->flags & kModernTypeFlag4)) useCustomDudeSpawn(actor, actor);
else if (pXSprite->txID) evSend(nSprite, OBJ_SPRITE, pXSprite->txID, kCmdModernUse); else if (pXSprite->txID) evSend(nSprite, OBJ_SPRITE, pXSprite->txID, kCmdModernUse);
return true; return true;
case kModernRandomTX: // random Event Switch takes random data field and uses it as TX ID case kModernRandomTX: // random Event Switch takes random data field and uses it as TX ID

View file

@ -353,7 +353,7 @@ void usePropertiesChanger(XSPRITE* pXSource, short objType, int objIndex);
void useSequentialTx(XSPRITE* pXSource, COMMAND_ID cmd, bool setState); void useSequentialTx(XSPRITE* pXSource, COMMAND_ID cmd, bool setState);
void useRandomTx(XSPRITE* pXSource, COMMAND_ID cmd, bool setState); void useRandomTx(XSPRITE* pXSource, COMMAND_ID cmd, bool setState);
void useDudeSpawn(XSPRITE* pXSource, spritetype* pSprite); void useDudeSpawn(XSPRITE* pXSource, spritetype* pSprite);
void useCustomDudeSpawn(XSPRITE* pXSource, spritetype* pSprite); void useCustomDudeSpawn(DBloodActor* pXSource, DBloodActor* pSprite);
bool txIsRanged(XSPRITE* pXSource); bool txIsRanged(XSPRITE* pXSource);
void seqTxSendCmdAll(XSPRITE* pXSource, int nIndex, COMMAND_ID cmd, bool modernSend); void seqTxSendCmdAll(XSPRITE* pXSource, int nIndex, COMMAND_ID cmd, bool modernSend);
// ------------------------------------------------------------------------- // // ------------------------------------------------------------------------- //