- targets in weapon.cpp, plus removal of the now redundant spritetype variants of IsTargetTeammate.

This commit is contained in:
Christoph Oelckers 2021-12-23 13:15:19 +01:00
parent bf25428225
commit 582b83601d
4 changed files with 36 additions and 50 deletions

View file

@ -184,11 +184,6 @@ inline bool CheckSector(const BitArray& bits, DBloodActor* act)
return bits[act->spr.sectno()];
}
inline bool IsTargetTeammate(PLAYER* pSourcePlayer, DBloodActor* pTarget)
{
return IsTargetTeammate(pSourcePlayer, &pTarget->spr);
}
inline bool IsTargetTeammate(DBloodActor* pSource, DBloodActor* pTarget)
{
if (!pSource->IsPlayerActor())

View file

@ -225,6 +225,28 @@ DAMAGEINFO damageInfo[7] = {
{ 0, 0, 0, 0, 0, 0, 0 }
};
inline bool IsTargetTeammate(PLAYER* pSourcePlayer, DBloodActor* target)
{
if (pSourcePlayer == nullptr)
return false;
if (!target->IsPlayerActor())
return false;
if (gGameOptions.nGameType == 1 || gGameOptions.nGameType == 3)
{
PLAYER* pTargetPlayer = &gPlayer[target->spr.type - kDudePlayer1];
if (pSourcePlayer != pTargetPlayer)
{
if (gGameOptions.nGameType == 1)
return true;
if (gGameOptions.nGameType == 3 && (pSourcePlayer->teamId & 3) == (pTargetPlayer->teamId & 3))
return true;
}
}
return false;
}
int powerupCheck(PLAYER *pPlayer, int nPowerUp)
{
assert(pPlayer != NULL);

View file

@ -206,35 +206,7 @@ extern int team_ticker[kMaxPlayers];
extern AMMOINFO gAmmoInfo[];
extern POWERUPINFO gPowerUpInfo[kMaxPowerUps];
inline bool IsTargetTeammate(PLAYER *pSourcePlayer, spritetype *pTargetSprite)
{
if (pSourcePlayer == NULL)
return false;
if (!IsPlayerSprite(pTargetSprite))
return false;
if (gGameOptions.nGameType == 1 || gGameOptions.nGameType == 3)
{
PLAYER *pTargetPlayer = &gPlayer[pTargetSprite->type - kDudePlayer1];
if (pSourcePlayer != pTargetPlayer)
{
if (gGameOptions.nGameType == 1)
return true;
if (gGameOptions.nGameType == 3 && (pSourcePlayer->teamId & 3) == (pTargetPlayer->teamId & 3))
return true;
}
}
return false;
}
inline bool IsTargetTeammate(spritetype *pSourceSprite, spritetype *pTargetSprite)
{
if (!IsPlayerSprite(pSourceSprite))
return false;
PLAYER *pSourcePlayer = &gPlayer[pSourceSprite->type - kDudePlayer1];
return IsTargetTeammate(pSourcePlayer, pTargetSprite);
}
bool IsTargetTeammate(PLAYER* pSourcePlayer, DBloodActor* target);
int powerupCheck(PLAYER *pPlayer, int nPowerUp);
bool powerupActivate(PLAYER *pPlayer, int nPowerUp);
void powerupDeactivate(PLAYER *pPlayer, int nPowerUp);

View file

@ -1453,8 +1453,7 @@ void FireVoodoo(int nTrigger, PLAYER *pPlayer)
}
DBloodActor* targetactor = pPlayer->voodooTarget;
if (!targetactor) return;
spritetype *pTarget = &targetactor->s();
if (!gGameOptions.bFriendlyFire && IsTargetTeammate(pPlayer, pTarget))
if (!gGameOptions.bFriendlyFire && IsTargetTeammate(pPlayer, targetactor))
return;
switch (nTrigger)
{
@ -1471,8 +1470,8 @@ void FireVoodoo(int nTrigger, PLAYER *pPlayer)
sfxPlay3DSound(actor, 460, 2, 0);
fxSpawnBlood(targetactor, 17<<4);
int nDamage = actDamageSprite(actor, targetactor, kDamageSpirit, 9<<4);
if (IsPlayerSprite(pTarget))
WeaponLower(&gPlayer[pTarget->type-kDudePlayer1]);
if (targetactor->IsPlayerActor())
WeaponLower(&gPlayer[targetactor->spr.type-kDudePlayer1]);
UseAmmo(pPlayer, 9, nDamage/4);
break;
}
@ -1489,9 +1488,9 @@ void FireVoodoo(int nTrigger, PLAYER *pPlayer)
sfxPlay3DSound(actor, 460, 2, 0);
fxSpawnBlood(targetactor, 17<<4);
int nDamage = actDamageSprite(actor, targetactor, kDamageSpirit, 11<<4);
if (IsPlayerSprite(pTarget))
if (targetactor->IsPlayerActor())
{
PLAYER *pOtherPlayer = &gPlayer[pTarget->type - kDudePlayer1];
PLAYER *pOtherPlayer = &gPlayer[targetactor->spr.type - kDudePlayer1];
pOtherPlayer->blindEffect = 128;
}
UseAmmo(pPlayer, 9, nDamage/4);
@ -1515,10 +1514,9 @@ void AltFireVoodoo(int nTrigger, PLAYER *pPlayer)
{
DBloodActor* targetactor = pPlayer->aimTargets[i];
if (!targetactor) continue;
spritetype* pTarget = &targetactor->s();
if (!gGameOptions.bFriendlyFire && IsTargetTeammate(pPlayer, pTarget))
if (!gGameOptions.bFriendlyFire && IsTargetTeammate(pPlayer, targetactor))
continue;
int nDist = approxDist(pTarget->pos.X - pPlayer->actor->spr.pos.X, pTarget->pos.Y - pPlayer->actor->spr.pos.Y);
int nDist = approxDist(targetactor->spr.pos.X - pPlayer->actor->spr.pos.X, targetactor->spr.pos.Y - pPlayer->actor->spr.pos.Y);
if (nDist > 0 && nDist < 51200)
{
int vc = pPlayer->ammoCount[9] >> 3;
@ -1527,9 +1525,9 @@ void AltFireVoodoo(int nTrigger, PLAYER *pPlayer)
nDamage = (nDamage * ((51200 - nDist) + 1)) / 51200;
nDamage = actDamageSprite(actor, targetactor, kDamageSpirit, nDamage);
if (IsPlayerSprite(pTarget))
if (targetactor->IsPlayerActor())
{
PLAYER* pOtherPlayer = &gPlayer[pTarget->type - kDudePlayer1];
PLAYER* pOtherPlayer = &gPlayer[targetactor->spr.type - kDudePlayer1];
if (!pOtherPlayer->godMode || !powerupCheck(pOtherPlayer, kPwUpDeathMask))
powerupActivate(pOtherPlayer, kPwUpDeliriumShroom);
}
@ -1552,12 +1550,11 @@ void AltFireVoodoo(int nTrigger, PLAYER *pPlayer)
{
DBloodActor* targetactor = pPlayer->aimTargets[i];
if (!targetactor) continue;
spritetype* pTarget = &targetactor->s();
if (!gGameOptions.bFriendlyFire && IsTargetTeammate(pPlayer, pTarget))
if (!gGameOptions.bFriendlyFire && IsTargetTeammate(pPlayer, targetactor))
continue;
if (v4 > 0)
v4--;
int nDist = approxDist(pTarget->pos.X - pPlayer->actor->spr.pos.X, pTarget->pos.Y - pPlayer->actor->spr.pos.Y);
int nDist = approxDist(targetactor->spr.pos.X - pPlayer->actor->spr.pos.X, targetactor->spr.pos.Y - pPlayer->actor->spr.pos.Y);
if (nDist > 0 && nDist < 51200)
{
int vc = pPlayer->ammoCount[9] >> 3;
@ -1566,9 +1563,9 @@ void AltFireVoodoo(int nTrigger, PLAYER *pPlayer)
nDamage = (nDamage * ((51200 - nDist) + 1)) / 51200;
nDamage = actDamageSprite(actor, targetactor, kDamageSpirit, nDamage);
UseAmmo(pPlayer, 9, nDamage);
if (IsPlayerSprite(pTarget))
if (targetactor->IsPlayerActor())
{
PLAYER* pOtherPlayer = &gPlayer[pTarget->type - kDudePlayer1];
PLAYER* pOtherPlayer = &gPlayer[targetactor->spr.type - kDudePlayer1];
if (!pOtherPlayer->godMode || !powerupCheck(pOtherPlayer, kPwUpDeathMask))
powerupActivate(pOtherPlayer, kPwUpDeliriumShroom);
}