- 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)
{
actor->xvel() = actor->yvel() = 0;
if (seqGetStatus(actor) < 0) genDudeTransform(pSprite);
if (seqGetStatus(actor) < 0) genDudeTransform(actor);
}
#endif
if (pSprite->type == kDudeCerberusTwoHead)

View file

@ -1670,7 +1670,7 @@ void aiProcessDudes(void)
case kDudeModernCustomBurning: {
GENDUDEEXTRA* pExtra = &actor->genDudeExtra();
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
&& (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* pSource = &sprite[pXSource->reference];
spritetype* pSprite = &actor->s();
spritetype* pSource = &source->s();
auto pXSource = &source->x();
auto spawned = actSpawnSprite(actor, kStatDude);
spritetype* pDude = &spawned->s();
XSPRITE* pXDude = &spawned->x();
@ -2036,7 +2039,7 @@ spritetype* genDudeSpawn(XSPRITE* pXSource, spritetype* pSprite, int nDist)
gKillMgr.AddNewKill(1);
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)) {
Printf(PRINT_HIGH, "pSprite->extra >= 0 && pSprite->extra < kMaxXSprites");
return;
}
XSPRITE* pXSprite = &xsprite[pSprite->extra];
auto actor = &bloodActors[pXSprite->reference];
auto const pSprite = &actor->s();
auto const pXSprite = &actor->x();
auto actIncarnation = getNextIncarnation(actor);
if (actIncarnation == NULL) {
if (actIncarnation == NULL)
{
if (pXSprite->sysData1 == kGenDudeTransformStatus) pXSprite->sysData1 = 0;
trTriggerSprite(pSprite->index, pXSprite, kCmdOff);
return;
@ -2171,13 +2173,11 @@ void genDudeTransform(spritetype* pSprite) {
//
//---------------------------------------------------------------------------
void updateTargetOfLeech(spritetype* pSprite) {
if (!(pSprite->extra >= 0 && pSprite->extra < kMaxXSprites)) {
Printf(PRINT_HIGH, "pSprite->extra >= 0 && pSprite->extra < kMaxXSprites");
return;
}
auto actor = &bloodActors[pSprite->index];
void updateTargetOfLeech(DBloodActor* actor)
{
if (!actor->hasX()) return;
auto const pSprite = &actor->s();
auto actLeech = leechIsDropped(actor);
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);
int checkAttackState(DBloodActor* actor);
bool doExplosion(DBloodActor* pSprite, int nType);
spritetype* genDudeSpawn(XSPRITE* pXSource, spritetype* pSprite, int nDist);
void genDudeTransform(spritetype* pSprite);
DBloodActor* genDudeSpawn(DBloodActor* source, DBloodActor* pSprite, int nDist);
void genDudeTransform(DBloodActor* pSprite);
void dudeLeechOperate(DBloodActor* actor, const EVENT& a3);
int getDodgeChance(DBloodActor* pSprite);
int getRecoilChance(DBloodActor* pSprite);
bool dudeIsMelee(DBloodActor* pXSprite);
void updateTargetOfSlaves(spritetype* pSprite);
void updateTargetOfLeech(spritetype* pSprite);
void updateTargetOfLeech(DBloodActor* pSprite);
bool canSwim(spritetype* pSprite);
bool canDuck(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
case kModernCustomDudeSpawn:
if (destObjType != OBJ_SPRITE) break;
useCustomDudeSpawn(pXSource, &sprite[destObjIndex]);
useCustomDudeSpawn(&bloodActors[pXSource->reference], &bloodActors[destObjIndex]);
break;
}
}
@ -4740,10 +4740,9 @@ bool modernTypeOperateSector(int nSector, sectortype* pSector, XSECTOR* pXSector
}
void useCustomDudeSpawn(XSPRITE* pXSource, spritetype* pSprite) {
genDudeSpawn(pXSource, pSprite, pSprite->clipdist << 1);
void useCustomDudeSpawn(DBloodActor* pSource, DBloodActor* pSprite)
{
genDudeSpawn(pSource, pSprite, pSprite->s().clipdist << 1);
}
void useDudeSpawn(XSPRITE* pXSource, spritetype* pSprite) {
@ -4851,7 +4850,7 @@ bool modernTypeOperateSprite(int nSprite, spritetype* pSprite, XSPRITE* pXSprite
return true;
case kModernCustomDudeSpawn:
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);
return true;
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 useRandomTx(XSPRITE* pXSource, COMMAND_ID cmd, bool setState);
void useDudeSpawn(XSPRITE* pXSource, spritetype* pSprite);
void useCustomDudeSpawn(XSPRITE* pXSource, spritetype* pSprite);
void useCustomDudeSpawn(DBloodActor* pXSource, DBloodActor* pSprite);
bool txIsRanged(XSPRITE* pXSource);
void seqTxSendCmdAll(XSPRITE* pXSource, int nIndex, COMMAND_ID cmd, bool modernSend);
// ------------------------------------------------------------------------- //