- handled 4 aiFight functions for rxBuckets.

This commit is contained in:
Christoph Oelckers 2021-09-01 20:06:00 +02:00
parent 0ef388538d
commit db9d4efdc9

View file

@ -4448,9 +4448,9 @@ bool aiFightDudeCanSeeTarget(XSPRITE* pXDude, DUDEINFO* pDudeInfo, spritetype* p
void aiFightActivateDudes(int rx) { void aiFightActivateDudes(int rx) {
for (int i = bucketHead[rx]; i < bucketHead[rx + 1]; i++) { for (int i = bucketHead[rx]; i < bucketHead[rx + 1]; i++) {
if (rxBucket[i].type != OBJ_SPRITE) continue; if (rxBucket[i].type != OBJ_SPRITE) continue;
spritetype* pDude = &sprite[rxBucket[i].rxindex]; XSPRITE* pXDude = &xsprite[pDude->extra]; auto dudeactor = rxBucket[i].GetActor();
if (!IsDudeSprite(pDude) || pXDude->aiState->stateType != kAiStateGenIdle) continue; if (!dudeactor || !dudeactor->hasX() || !dudeactor->IsDudeActor() || dudeactor->x().aiState->stateType != kAiStateGenIdle) continue;
aiInitSprite(&bloodActors[pDude->index]); aiInitSprite(dudeactor);
} }
} }
@ -4472,9 +4472,12 @@ void aiFightFreeTargets(int nSprite) {
// this function sets target to -1 for all targets that hunting for dudes affected by selected kModernDudeTargetChanger // this function sets target to -1 for all targets that hunting for dudes affected by selected kModernDudeTargetChanger
void aiFightFreeAllTargets(XSPRITE* pXSource) { void aiFightFreeAllTargets(XSPRITE* pXSource) {
if (pXSource->txID <= 0) return; if (pXSource->txID <= 0) return;
for (int i = bucketHead[pXSource->txID]; i < bucketHead[pXSource->txID + 1]; i++) { for (int i = bucketHead[pXSource->txID]; i < bucketHead[pXSource->txID + 1]; i++)
if (rxBucket[i].type == OBJ_SPRITE && sprite[rxBucket[i].rxindex].extra >= 0) {
aiFightFreeTargets(rxBucket[i].rxindex); if (rxBucket[i].type != OBJ_SPRITE) continue;
auto rxactor = rxBucket[i].GetActor();
if (rxactor && rxactor->hasX())
aiFightFreeTargets(rxactor->s().index);
} }
return; return;
@ -4492,9 +4495,9 @@ bool aiFightDudeIsAffected(XSPRITE* pXDude) {
for (int i = bucketHead[pXSprite->txID]; i < bucketHead[pXSprite->txID + 1]; i++) { for (int i = bucketHead[pXSprite->txID]; i < bucketHead[pXSprite->txID + 1]; i++) {
if (rxBucket[i].type != OBJ_SPRITE) continue; if (rxBucket[i].type != OBJ_SPRITE) continue;
spritetype* pSprite = &sprite[rxBucket[i].rxindex]; auto actor = rxBucket[i].GetActor();
if (pSprite->extra < 0 || !IsDudeSprite(pSprite)) continue; if (!actor || !actor->hasX() || !actor->IsDudeActor()) continue;
else if (pSprite->index == sprite[pXDude->reference].index) return true; else if (actor->s().index == sprite[pXDude->reference].index) return true;
} }
} }
return false; return false;
@ -4509,8 +4512,9 @@ bool aiFightGetDudesForBattle(XSPRITE* pXSprite) {
for (int i = bucketHead[pXSprite->txID]; i < bucketHead[pXSprite->txID + 1]; i++) { for (int i = bucketHead[pXSprite->txID]; i < bucketHead[pXSprite->txID + 1]; i++) {
if (rxBucket[i].type != OBJ_SPRITE) continue; if (rxBucket[i].type != OBJ_SPRITE) continue;
else if (IsDudeSprite(&sprite[rxBucket[i].rxindex]) && auto actor = rxBucket[i].GetActor();
xsprite[sprite[rxBucket[i].rxindex].extra].health > 0) return true; if (!actor || !actor->hasX() || !actor->IsDudeActor()) continue;
if (actor->x().health > 0) return true;
} }
// check redirected TX buckets // check redirected TX buckets
@ -4518,8 +4522,9 @@ bool aiFightGetDudesForBattle(XSPRITE* pXSprite) {
while ((pXRedir = evrListRedirectors(OBJ_SPRITE, sprite[pXSprite->reference].extra, pXRedir, &rx)) != NULL) { while ((pXRedir = evrListRedirectors(OBJ_SPRITE, sprite[pXSprite->reference].extra, pXRedir, &rx)) != NULL) {
for (int i = bucketHead[rx]; i < bucketHead[rx + 1]; i++) { for (int i = bucketHead[rx]; i < bucketHead[rx + 1]; i++) {
if (rxBucket[i].type != OBJ_SPRITE) continue; if (rxBucket[i].type != OBJ_SPRITE) continue;
else if (IsDudeSprite(&sprite[rxBucket[i].rxindex]) && auto actor = rxBucket[i].GetActor();
xsprite[sprite[rxBucket[i].rxindex].extra].health > 0) return true; if (!actor || !actor->hasX() || !actor->IsDudeActor()) continue;
if (actor->x().health > 0) return true;
} }
} }
return false; return false;