mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 11:10:39 +00:00
- aiProcessDudes and aiInitSprite done, completing the main pass over ai.cpp.
This commit is contained in:
parent
29e245dfce
commit
44b0e59127
6 changed files with 44 additions and 47 deletions
|
@ -6519,7 +6519,7 @@ DBloodActor* actSpawnDude(DBloodActor* source, short nType, int a3, int a4)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
aiInitSprite(pSprite2);
|
aiInitSprite(spawned);
|
||||||
return spawned;
|
return spawned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1642,7 +1642,7 @@ void aiLookForTarget(DBloodActor* actor)
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void aiProcessDudes(void)
|
void aiProcessDudes(void)
|
||||||
{
|
{
|
||||||
BloodStatIterator it(kStatDude);
|
BloodStatIterator it(kStatDude);
|
||||||
while (auto actor = it.Next())
|
while (auto actor = it.Next())
|
||||||
|
@ -1650,10 +1650,10 @@ void aiProcessDudes(void)
|
||||||
auto pSprite = &actor->s();
|
auto pSprite = &actor->s();
|
||||||
if (pSprite->flags & 32) continue;
|
if (pSprite->flags & 32) continue;
|
||||||
auto pXSprite = &actor->x();
|
auto pXSprite = &actor->x();
|
||||||
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
|
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
|
||||||
if (IsPlayerSprite(pSprite) || pXSprite->health == 0) continue;
|
if (IsPlayerSprite(pSprite) || pXSprite->health == 0) continue;
|
||||||
|
|
||||||
pXSprite->stateTimer = ClipLow(pXSprite->stateTimer-4, 0);
|
pXSprite->stateTimer = ClipLow(pXSprite->stateTimer - 4, 0);
|
||||||
|
|
||||||
if (pXSprite->aiState && pXSprite->aiState->moveFunc)
|
if (pXSprite->aiState && pXSprite->aiState->moveFunc)
|
||||||
pXSprite->aiState->moveFunc(actor);
|
pXSprite->aiState->moveFunc(actor);
|
||||||
|
@ -1662,14 +1662,14 @@ void aiProcessDudes(void)
|
||||||
pXSprite->aiState->thinkFunc(actor);
|
pXSprite->aiState->thinkFunc(actor);
|
||||||
|
|
||||||
switch (pSprite->type) {
|
switch (pSprite->type) {
|
||||||
#ifdef NOONE_EXTENSIONS
|
#ifdef NOONE_EXTENSIONS
|
||||||
case kDudeModernCustom:
|
case kDudeModernCustom:
|
||||||
case kDudeModernCustomBurning: {
|
case kDudeModernCustomBurning: {
|
||||||
GENDUDEEXTRA* pExtra = &gGenDudeExtra[pSprite->index];
|
GENDUDEEXTRA* pExtra = &gGenDudeExtra[pSprite->index];
|
||||||
if (pExtra->slaveCount > 0) updateTargetOfSlaves(pSprite);
|
if (pExtra->slaveCount > 0) updateTargetOfSlaves(pSprite);
|
||||||
if (pExtra->nLifeLeech >= 0) updateTargetOfLeech(pSprite);
|
if (pExtra->nLifeLeech >= 0) updateTargetOfLeech(pSprite);
|
||||||
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))
|
||||||
{
|
{
|
||||||
aiGenDudeNewState(pSprite, pXSprite->aiState->nextState);
|
aiGenDudeNewState(pSprite, pXSprite->aiState->nextState);
|
||||||
}
|
}
|
||||||
|
@ -1679,7 +1679,7 @@ void aiProcessDudes(void)
|
||||||
RecoilDude(actor);
|
RecoilDude(actor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
if (pXSprite->stateTimer == 0 && pXSprite->aiState && pXSprite->aiState->nextState) {
|
if (pXSprite->stateTimer == 0 && pXSprite->aiState && pXSprite->aiState->nextState) {
|
||||||
if (pXSprite->aiState->stateTicks > 0)
|
if (pXSprite->aiState->stateTicks > 0)
|
||||||
|
@ -1688,7 +1688,7 @@ void aiProcessDudes(void)
|
||||||
aiNewState(actor, pXSprite->aiState->nextState);
|
aiNewState(actor, pXSprite->aiState->nextState);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pXSprite->health > 0 && ((pDudeInfo->hinderDamage << 4) <= actor->cumulDamage))
|
if (pXSprite->health > 0 && ((pDudeInfo->hinderDamage << 4) <= actor->cumulDamage))
|
||||||
{
|
{
|
||||||
pXSprite->data3 = actor->cumulDamage;
|
pXSprite->data3 = actor->cumulDamage;
|
||||||
RecoilDude(actor);
|
RecoilDude(actor);
|
||||||
|
@ -1706,25 +1706,23 @@ void aiProcessDudes(void)
|
||||||
|
|
||||||
void aiInit(void)
|
void aiInit(void)
|
||||||
{
|
{
|
||||||
int nSprite;
|
BloodStatIterator it(kStatDude);
|
||||||
StatIterator it(kStatDude);
|
while (auto actor = it.Next())
|
||||||
while ((nSprite = it.NextIndex()) >= 0)
|
|
||||||
{
|
{
|
||||||
aiInitSprite(&sprite[nSprite]);
|
aiInitSprite(actor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void aiInitSprite(spritetype *pSprite)
|
void aiInitSprite(DBloodActor* actor)
|
||||||
{
|
{
|
||||||
auto actor = &bloodActors[pSprite->index];
|
auto pSprite = &actor->s();
|
||||||
int nXSprite = pSprite->extra;
|
auto pXSprite = &actor->x();
|
||||||
XSPRITE *pXSprite = &xsprite[nXSprite];
|
|
||||||
int nSector = pSprite->sectnum;
|
int nSector = pSprite->sectnum;
|
||||||
int nXSector = sector[nSector].extra;
|
int nXSector = sector[nSector].extra;
|
||||||
XSECTOR *pXSector = NULL;
|
XSECTOR* pXSector = NULL;
|
||||||
if (nXSector > 0)
|
if (nXSector > 0)
|
||||||
pXSector = &xsector[nXSector];
|
pXSector = &xsector[nXSector];
|
||||||
DUDEEXTRA *pDudeExtra = &actor->dudeExtra;
|
DUDEEXTRA* pDudeExtra = &actor->dudeExtra;
|
||||||
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
|
DUDEEXTRA_STATS *pDudeExtraE = &actor->dudeExtra.stats;
|
||||||
pDudeExtra->teslaHit = 0;
|
pDudeExtra->teslaHit = 0;
|
||||||
pDudeExtra->time = 0;
|
pDudeExtra->time = 0;
|
||||||
|
@ -1734,21 +1732,21 @@ void aiInitSprite(spritetype *pSprite)
|
||||||
#ifdef NOONE_EXTENSIONS
|
#ifdef NOONE_EXTENSIONS
|
||||||
int stateTimer = -1, targetMarker = -1;
|
int stateTimer = -1, targetMarker = -1;
|
||||||
int targetX = 0, targetY = 0, targetZ = 0;
|
int targetX = 0, targetY = 0, targetZ = 0;
|
||||||
|
|
||||||
// dude patrol init
|
// dude patrol init
|
||||||
if (gModernMap) {
|
if (gModernMap)
|
||||||
|
{
|
||||||
// must keep it in case of loading save
|
// must keep it in case of loading save
|
||||||
if (pXSprite->dudeFlag4 && spriRangeIsFine(pXSprite->target_i) && sprite[pXSprite->target_i].type == kMarkerPath) {
|
if (pXSprite->dudeFlag4 && spriRangeIsFine(pXSprite->target_i) && sprite[pXSprite->target_i].type == kMarkerPath) {
|
||||||
stateTimer = pXSprite->stateTimer; targetMarker = pXSprite->target_i;
|
stateTimer = pXSprite->stateTimer; targetMarker = pXSprite->target_i;
|
||||||
targetX = pXSprite->targetX; targetY = pXSprite->targetY;
|
targetX = pXSprite->targetX; targetY = pXSprite->targetY;
|
||||||
targetZ = pXSprite->targetZ;
|
targetZ = pXSprite->targetZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (pSprite->type) {
|
switch (pSprite->type)
|
||||||
|
{
|
||||||
case kDudeCultistTommy:
|
case kDudeCultistTommy:
|
||||||
case kDudeCultistShotgun:
|
case kDudeCultistShotgun:
|
||||||
case kDudeCultistTesla:
|
case kDudeCultistTesla:
|
||||||
|
@ -1903,14 +1901,14 @@ void aiInitSprite(spritetype *pSprite)
|
||||||
aiNewState(actor, &genIdle);
|
aiNewState(actor, &genIdle);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
aiSetTarget_(pXSprite, 0, 0, 0);
|
aiSetTarget(actor, 0, 0, 0);
|
||||||
pXSprite->stateTimer = 0;
|
pXSprite->stateTimer = 0;
|
||||||
switch (pSprite->type)
|
switch (pSprite->type)
|
||||||
{
|
{
|
||||||
case kDudeSpiderBrown:
|
case kDudeSpiderBrown:
|
||||||
case kDudeSpiderRed:
|
case kDudeSpiderRed:
|
||||||
case kDudeSpiderBlack:
|
case kDudeSpiderBlack:
|
||||||
if (pSprite->cstat&8) pSprite->flags |= 9;
|
if (pSprite->cstat & 8) pSprite->flags |= 9;
|
||||||
else pSprite->flags = 15;
|
else pSprite->flags = 15;
|
||||||
break;
|
break;
|
||||||
case kDudeGargoyleFlesh:
|
case kDudeGargoyleFlesh:
|
||||||
|
@ -1928,7 +1926,7 @@ void aiInitSprite(spritetype *pSprite)
|
||||||
case kDudeZombieAxeLaying:
|
case kDudeZombieAxeLaying:
|
||||||
pSprite->flags = 7;
|
pSprite->flags = 7;
|
||||||
break;
|
break;
|
||||||
#ifdef NOONE_EXTENSIONS
|
#ifdef NOONE_EXTENSIONS
|
||||||
case kDudePodMother: // FakeDude type
|
case kDudePodMother: // FakeDude type
|
||||||
if (gModernMap) break;
|
if (gModernMap) break;
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
|
@ -1945,19 +1943,20 @@ void aiInitSprite(spritetype *pSprite)
|
||||||
}
|
}
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
// go default
|
// go default
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
pSprite->flags = 15;
|
pSprite->flags = 15;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NOONE_EXTENSIONS
|
#ifdef NOONE_EXTENSIONS
|
||||||
if (gModernMap) {
|
if (gModernMap)
|
||||||
|
{
|
||||||
if (pXSprite->dudeFlag4) {
|
if (pXSprite->dudeFlag4)
|
||||||
|
{
|
||||||
// restore dude's path
|
// restore dude's path
|
||||||
if (spriRangeIsFine(targetMarker)) {
|
if (spriRangeIsFine(targetMarker))
|
||||||
|
{
|
||||||
pXSprite->target_i = targetMarker;
|
pXSprite->target_i = targetMarker;
|
||||||
pXSprite->targetX = targetX;
|
pXSprite->targetX = targetX;
|
||||||
pXSprite->targetY = targetY;
|
pXSprite->targetY = targetY;
|
||||||
|
@ -1982,12 +1981,9 @@ void aiInitSprite(spritetype *pSprite)
|
||||||
else if (uwater) aiPatrolState(pSprite, kAiStatePatrolMoveW);
|
else if (uwater) aiPatrolState(pSprite, kAiStatePatrolMoveW);
|
||||||
else if (pXSprite->unused1 & kDudeFlagCrouch) aiPatrolState(pSprite, kAiStatePatrolMoveC);
|
else if (pXSprite->unused1 & kDudeFlagCrouch) aiPatrolState(pSprite, kAiStatePatrolMoveC);
|
||||||
else aiPatrolState(pSprite, kAiStatePatrolMoveL);
|
else aiPatrolState(pSprite, kAiStatePatrolMoveL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
END_BLD_NS
|
END_BLD_NS
|
||||||
|
|
|
@ -93,7 +93,7 @@ void aiThinkTarget(DBloodActor* actor);
|
||||||
void aiLookForTarget(DBloodActor* actor);
|
void aiLookForTarget(DBloodActor* actor);
|
||||||
void aiProcessDudes(void);
|
void aiProcessDudes(void);
|
||||||
void aiInit(void);
|
void aiInit(void);
|
||||||
void aiInitSprite(spritetype *pSprite);
|
void aiInitSprite(DBloodActor* pSprite);
|
||||||
bool CanMove(DBloodActor* pSprite, int a2, int nAngle, int nRange);
|
bool CanMove(DBloodActor* pSprite, int a2, int nAngle, int nRange);
|
||||||
|
|
||||||
void aiSetTarget_(XSPRITE* pXSprite, int x, int y, int z);
|
void aiSetTarget_(XSPRITE* pXSprite, int x, int y, int z);
|
||||||
|
|
|
@ -1716,7 +1716,7 @@ spritetype* genDudeSpawn(XSPRITE* pXSource, spritetype* pSprite, int nDist) {
|
||||||
}
|
}
|
||||||
|
|
||||||
gKillMgr.AddNewKill(1);
|
gKillMgr.AddNewKill(1);
|
||||||
aiInitSprite(pDude);
|
aiInitSprite(spawned);
|
||||||
return pDude;
|
return pDude;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1814,7 +1814,7 @@ void genDudeTransform(spritetype* pSprite) {
|
||||||
int target = pXSprite->target_i;
|
int target = pXSprite->target_i;
|
||||||
|
|
||||||
// re-init sprite
|
// re-init sprite
|
||||||
aiInitSprite(pSprite);
|
aiInitSprite(actor);
|
||||||
|
|
||||||
// try to restore target
|
// try to restore target
|
||||||
if (target == -1) aiSetTarget(actor, pSprite->x, pSprite->y, pSprite->z);
|
if (target == -1) aiSetTarget(actor, pSprite->x, pSprite->y, pSprite->z);
|
||||||
|
|
|
@ -277,7 +277,7 @@ void Respawn(int nSprite) // 9
|
||||||
if (getSequence(getDudeInfo(nType + kDudeBase)->seqStartID))
|
if (getSequence(getDudeInfo(nType + kDudeBase)->seqStartID))
|
||||||
seqSpawn(getDudeInfo(nType + kDudeBase)->seqStartID, 3, pSprite->extra, -1);
|
seqSpawn(getDudeInfo(nType + kDudeBase)->seqStartID, 3, pSprite->extra, -1);
|
||||||
#endif
|
#endif
|
||||||
aiInitSprite(pSprite);
|
aiInitSprite(actor);
|
||||||
pXSprite->key = 0;
|
pXSprite->key = 0;
|
||||||
} else if (pSprite->type == kThingTNTBarrel) {
|
} else if (pSprite->type == kThingTNTBarrel) {
|
||||||
pSprite->cstat |= CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN;
|
pSprite->cstat |= CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN;
|
||||||
|
|
|
@ -331,7 +331,7 @@ spritetype* nnExtSpawnDude(XSPRITE* pXSource, spritetype* pSprite, short nType,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
aiInitSprite(pDude);
|
aiInitSprite(pDudeActor);
|
||||||
|
|
||||||
gKillMgr.AddNewKill(1);
|
gKillMgr.AddNewKill(1);
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ spritetype* nnExtSpawnDude(XSPRITE* pXSource, spritetype* pSprite, short nType,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((burning || (pSource->flags & kModernTypeFlag3)) && !pXDude->dudeFlag4)
|
if ((burning || (pSource->flags & kModernTypeFlag3)) && !pXDude->dudeFlag4)
|
||||||
aiActivateDude(&bloodActors[pXDude->reference]);
|
aiActivateDude(pDudeActor);
|
||||||
|
|
||||||
return pDude;
|
return pDude;
|
||||||
}
|
}
|
||||||
|
@ -2664,6 +2664,7 @@ void usePropertiesChanger(XSPRITE* pXSource, short objType, int objIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void useTeleportTarget(XSPRITE* pXSource, spritetype* pSprite) {
|
void useTeleportTarget(XSPRITE* pXSource, spritetype* pSprite) {
|
||||||
|
auto actor = &bloodActors[pSprite->index];
|
||||||
spritetype* pSource = &sprite[pXSource->reference]; PLAYER* pPlayer = getPlayerById(pSprite->type);
|
spritetype* pSource = &sprite[pXSource->reference]; PLAYER* pPlayer = getPlayerById(pSprite->type);
|
||||||
XSECTOR* pXSector = (sector[pSource->sectnum].extra >= 0) ? &xsector[sector[pSource->sectnum].extra] : NULL;
|
XSECTOR* pXSector = (sector[pSource->sectnum].extra >= 0) ? &xsector[sector[pSource->sectnum].extra] : NULL;
|
||||||
bool isDude = (!pPlayer && IsDudeSprite(pSprite));
|
bool isDude = (!pPlayer && IsDudeSprite(pSprite));
|
||||||
|
@ -2733,7 +2734,7 @@ void useTeleportTarget(XSPRITE* pXSource, spritetype* pSprite) {
|
||||||
int x = pXDude->targetX; int y = pXDude->targetY; int z = pXDude->targetZ;
|
int x = pXDude->targetX; int y = pXDude->targetY; int z = pXDude->targetZ;
|
||||||
int target = pXDude->target_i;
|
int target = pXDude->target_i;
|
||||||
|
|
||||||
aiInitSprite(pSprite);
|
aiInitSprite(actor);
|
||||||
|
|
||||||
if (target >= 0) {
|
if (target >= 0) {
|
||||||
pXDude->targetX = x; pXDude->targetY = y; pXDude->targetZ = z;
|
pXDude->targetX = x; pXDude->targetY = y; pXDude->targetZ = z;
|
||||||
|
@ -4414,7 +4415,7 @@ void aiFightActivateDudes(int rx) {
|
||||||
if (rxBucket[i].type != OBJ_SPRITE) continue;
|
if (rxBucket[i].type != OBJ_SPRITE) continue;
|
||||||
spritetype* pDude = &sprite[rxBucket[i].index]; XSPRITE* pXDude = &xsprite[pDude->extra];
|
spritetype* pDude = &sprite[rxBucket[i].index]; XSPRITE* pXDude = &xsprite[pDude->extra];
|
||||||
if (!IsDudeSprite(pDude) || pXDude->aiState->stateType != kAiStateGenIdle) continue;
|
if (!IsDudeSprite(pDude) || pXDude->aiState->stateType != kAiStateGenIdle) continue;
|
||||||
aiInitSprite(pDude);
|
aiInitSprite(&bloodActors[pDude->index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6826,7 +6827,7 @@ void aiPatrolStop(spritetype* pSprite, int target, bool alarm)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
aiInitSprite(pSprite);
|
aiInitSprite(actor);
|
||||||
aiSetTarget_(pXSprite, pXSprite->targetX, pXSprite->targetY, pXSprite->targetZ);
|
aiSetTarget_(pXSprite, pXSprite->targetX, pXSprite->targetY, pXSprite->targetZ);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue