mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 17:01:28 +00:00
- refactored aiSetTarget
This commit is contained in:
parent
e6e9bac04b
commit
c8501f8ea6
4 changed files with 43 additions and 27 deletions
|
@ -7403,6 +7403,7 @@ void SerializeActor(FSerializer& arc)
|
|||
}
|
||||
}
|
||||
|
||||
// dumping ground for temporary wrappers.
|
||||
int actDamageSprite(int nSource, spritetype* pSprite, DAMAGE_TYPE damageType, int damage)
|
||||
{
|
||||
return actDamageSprite(nSource == -1 ? nullptr : &bloodActors[nSource], &bloodActors[pSprite->index], damageType, damage);
|
||||
|
@ -7423,5 +7424,16 @@ void aiPlay3DSound(spritetype* pSprite, int a2, AI_SFX_PRIORITY a3, int a4)
|
|||
return aiPlay3DSound(&bloodActors[pSprite->index], a2, a3, a4);
|
||||
}
|
||||
|
||||
void aiSetTarget_(XSPRITE* pXSprite, int nTarget)
|
||||
{
|
||||
aiSetTarget(&bloodActors[pXSprite->reference], &bloodActors[nTarget]);
|
||||
}
|
||||
|
||||
void aiSetTarget_(XSPRITE* pXSprite, int x, int y, int z)
|
||||
{
|
||||
aiSetTarget(&bloodActors[pXSprite->reference], x, y, z);
|
||||
}
|
||||
|
||||
|
||||
|
||||
END_BLD_NS
|
||||
|
|
|
@ -930,23 +930,29 @@ void aiActivateDude(DBloodActor* actor)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void aiSetTarget_(XSPRITE *pXSprite, int x, int y, int z)
|
||||
void aiSetTarget(DBloodActor*actor, int x, int y, int z)
|
||||
{
|
||||
pXSprite->target_i = -1;
|
||||
auto pXSprite = &actor->x();
|
||||
actor->SetTarget(nullptr);
|
||||
pXSprite->targetX = x;
|
||||
pXSprite->targetY = y;
|
||||
pXSprite->targetZ = z;
|
||||
}
|
||||
|
||||
void aiSetTarget_(XSPRITE *pXSprite, int nTarget)
|
||||
void aiSetTarget(DBloodActor* actor, DBloodActor* target)
|
||||
{
|
||||
assert(nTarget >= 0 && nTarget < kMaxSprites);
|
||||
spritetype *pTarget = &sprite[nTarget];
|
||||
if (target == nullptr)
|
||||
{
|
||||
actor->SetTarget(nullptr);
|
||||
return;
|
||||
}
|
||||
auto pXSprite = &actor->x();
|
||||
spritetype* pTarget = &target->s();
|
||||
if (pTarget->type >= kDudeBase && pTarget->type < kDudeMax)
|
||||
{
|
||||
if (sprite[pXSprite->reference].owner != nTarget)
|
||||
if (actor->GetOwner() != target)
|
||||
{
|
||||
pXSprite->target_i = nTarget;
|
||||
actor->SetTarget(target);
|
||||
DUDEINFO* pDudeInfo = getDudeInfo(pTarget->type);
|
||||
pXSprite->targetX = pTarget->x;
|
||||
pXSprite->targetY = pTarget->y;
|
||||
|
@ -955,12 +961,6 @@ void aiSetTarget_(XSPRITE *pXSprite, int nTarget)
|
|||
}
|
||||
}
|
||||
|
||||
void aiSetTarget(DBloodActor* actor, DBloodActor* target)
|
||||
{
|
||||
aiSetTarget_(&actor->x(), target ? target->x().reference : -1);
|
||||
}
|
||||
|
||||
|
||||
int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType, int nDamage)
|
||||
{
|
||||
auto pSprite = &actor->s();
|
||||
|
@ -991,7 +991,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
|
|||
nThresh *= pDudeInfo->changeTarget;
|
||||
if (Chance(nThresh))
|
||||
{
|
||||
aiSetTarget_(pXSprite, nSource);
|
||||
aiSetTarget(actor, source);
|
||||
aiActivateDude(&bloodActors[pXSprite->reference]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,8 +86,7 @@ void aiMoveForward(DBloodActor*pXSprite);
|
|||
void aiMoveTurn(DBloodActor*pXSprite);
|
||||
void aiMoveDodge(DBloodActor *actor);
|
||||
void aiActivateDude(DBloodActor *actor);
|
||||
void aiSetTarget_(XSPRITE *pXSprite, int x, int y, int z);
|
||||
void aiSetTarget_(XSPRITE *pXSprite, int nTarget);
|
||||
void aiSetTarget(DBloodActor* pXSprite, int x, int y, int z);
|
||||
void aiSetTarget(DBloodActor* actor, DBloodActor* target);
|
||||
int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType, int nDamage);
|
||||
void aiThinkTarget(DBloodActor* actor);
|
||||
|
@ -99,5 +98,7 @@ bool CanMove(DBloodActor* pSprite, int a2, int nAngle, int nRange);
|
|||
|
||||
bool dudeIsPlayingSeq(spritetype* pSprite, int nSeq); // deprecated
|
||||
void aiPlay3DSound(spritetype* pSprite, int a2, AI_SFX_PRIORITY a3, int a4);
|
||||
void aiSetTarget_(XSPRITE* pXSprite, int x, int y, int z);
|
||||
void aiSetTarget_(XSPRITE* pXSprite, int nTarget);
|
||||
|
||||
END_BLD_NS
|
||||
|
|
|
@ -6948,6 +6948,7 @@ void aiPatrolAlarmLite(spritetype* pSprite, XSPRITE* pXTarget) {
|
|||
if (!xsprIsFine(pSprite) || !IsDudeSprite(pSprite))
|
||||
return;
|
||||
|
||||
auto targetactor = &bloodActors[pXTarget->reference];
|
||||
XSPRITE* pXSprite = &xsprite[pSprite->extra];
|
||||
if (pXSprite->health <= 0)
|
||||
return;
|
||||
|
@ -6960,11 +6961,12 @@ void aiPatrolAlarmLite(spritetype* pSprite, XSPRITE* pXTarget) {
|
|||
|
||||
for (int nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite]) {
|
||||
|
||||
pDude = &sprite[nSprite];
|
||||
auto dudeactor = &bloodActors[nSprite];
|
||||
pDude = &dudeactor->s();
|
||||
if (pDude->index == pSprite->index || !IsDudeSprite(pDude) || IsPlayerSprite(pDude) || pDude->extra < 0)
|
||||
continue;
|
||||
|
||||
pXDude = &xsprite[pDude->extra];
|
||||
pXDude = &dudeactor->x();
|
||||
if (pXDude->health <= 0)
|
||||
continue;
|
||||
|
||||
|
@ -6982,8 +6984,8 @@ void aiPatrolAlarmLite(spritetype* pSprite, XSPRITE* pXTarget) {
|
|||
if (pXDude->target_i >= 0 || pXDude->target_i == pXSprite->target_i)
|
||||
continue;
|
||||
|
||||
aiSetTarget_(pXDude, pXTarget->reference);
|
||||
aiActivateDude(&bloodActors[pXDude->reference]);
|
||||
aiSetTarget(dudeactor, targetactor);
|
||||
aiActivateDude(dudeactor);
|
||||
|
||||
}
|
||||
|
||||
|
@ -7010,11 +7012,12 @@ void aiPatrolAlarmFull(spritetype* pSprite, XSPRITE* pXTarget, bool chain) {
|
|||
|
||||
for (int nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite]) {
|
||||
|
||||
pDude = &sprite[nSprite];
|
||||
auto dudeactor = &bloodActors[nSprite];
|
||||
pDude = &dudeactor->s();
|
||||
if (pDude->index == pSprite->index || !IsDudeSprite(pDude) || IsPlayerSprite(pDude) || pDude->extra < 0)
|
||||
continue;
|
||||
|
||||
pXDude = &xsprite[pDude->extra];
|
||||
pXDude = &dudeactor->x();
|
||||
if (pXDude->health <= 0)
|
||||
continue;
|
||||
|
||||
|
@ -7033,9 +7036,9 @@ void aiPatrolAlarmFull(spritetype* pSprite, XSPRITE* pXTarget, bool chain) {
|
|||
if (pXDude->target_i >= 0 || pXDude->target_i == pXSprite->target_i)
|
||||
continue;
|
||||
|
||||
if (spriRangeIsFine(pXSprite->target_i)) aiSetTarget_(pXDude, pXSprite->target_i);
|
||||
else aiSetTarget_(pXDude, pSprite->x, pSprite->y, pSprite->z);
|
||||
aiActivateDude(&bloodActors[pXDude->reference]);
|
||||
if (spriRangeIsFine(pXSprite->target_i)) aiSetTarget(dudeactor, &bloodActors[pXSprite->target_i]);
|
||||
else aiSetTarget(dudeactor, pSprite->x, pSprite->y, pSprite->z);
|
||||
aiActivateDude(dudeactor);
|
||||
|
||||
if (chain)
|
||||
aiPatrolAlarmFull(pDude, pXTarget, Chance(0x0010));
|
||||
|
|
Loading…
Reference in a new issue