Sometimes simple is better..?

This commit is contained in:
Arthur 2024-02-17 10:04:34 -05:00
parent dc625496d8
commit 9a75ef18c3
3 changed files with 1 additions and 65 deletions

View file

@ -3279,69 +3279,6 @@ static boolean P_TagDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, IN
return true;
}
//
// P_CanPlayerHurtPlayer
//
// Is it permissible for a player to hurt another player?
// This should be the definitive global function to determine if pain is allowed. :)
//
boolean P_CanPlayerHurtPlayer(player_t *target, mobj_t *inflictor, player_t *source, UINT8 damagetype)
{
I_Assert(target != NULL);
I_Assert(source != NULL);
I_Assert(inflictor != NULL);
// MT_LHRT should return true here, because we want it to go through the 'damage' process
if (inflictor->type == MT_LHRT)
return true;
if (!(damagetype & DMG_CANHURTSELF))
{
// You can't kill yourself, idiot...
if (source == target)
return false;
// In COOP/RACE, you can't hurt other players unless cv_friendlyfire is on
if (!(cv_friendlyfire.value || (gametyperules & GTR_FRIENDLYFIRE)) && (gametyperules & GTR_FRIENDLY))
return false;
}
// Tag handling
if (G_TagGametype())
{
// If flashing or invulnerable, ignore the tag,
if (target->powers[pw_flashing] || target->powers[pw_invulnerability])
return false;
// Don't allow any damage before the round starts.
if (leveltime <= hidetime * TICRATE)
return false;
// Ignore IT players shooting each other, unless friendlyfire is on.
if ((target->pflags & PF_TAGIT && !((cv_friendlyfire.value || (gametyperules & GTR_FRIENDLYFIRE) || (damagetype & DMG_CANHURTSELF))
&& source->pflags & PF_TAGIT)))
return false;
// Don't allow players on the same team to hurt one another,
// unless cv_friendlyfire is on.
if (!(cv_friendlyfire.value || (gametyperules & GTR_FRIENDLYFIRE) || (damagetype & DMG_CANHURTSELF)) && (target->pflags & PF_TAGIT) == (source->pflags & PF_TAGIT))
return false;
return true;
}
else if (damagetype & DMG_CANHURTSELF)
return true;
else if (G_GametypeHasTeams()) // CTF + Team Match
{
// Don't allow players on the same team to hurt one another,
// unless cv_friendlyfire is on.
if (!(cv_friendlyfire.value || (gametyperules & GTR_FRIENDLYFIRE)) && target->ctfteam == source->ctfteam)
return false;
}
return true;
}
static boolean P_PlayerHitsPlayer(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype)
{
player_t *player = target->player;

View file

@ -506,7 +506,6 @@ void P_RemoveShield(player_t *player);
void P_SpecialStageDamage(player_t *player, mobj_t *inflictor, mobj_t *source);
boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype);
void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype);
boolean P_CanPlayerHurtPlayer(player_t *target, mobj_t *inflictor, player_t *source, UINT8 damagetype);
void P_PlayerRingBurst(player_t *player, INT32 num_rings); /// \todo better fit in p_user.c
void P_PlayerWeaponPanelBurst(player_t *player);
void P_PlayerWeaponAmmoBurst(player_t *player);

View file

@ -1280,7 +1280,7 @@ static unsigned PIT_DoCheckThing(mobj_t *thing)
{
// Don't hit yourself, and if a player, don't hit bots
if (thing == tmthing->target
|| (thing->player && tmthing->target->player && !P_CanPlayerHurtPlayer(thing->player, tmthing, tmthing->target->player, 0)))
|| (thing->player && tmthing->target->player && (thing->player->bot == BOT_2PAI || thing->player->bot == BOT_2PHUMAN)))
return CHECKTHING_IGNORE;
if (thing->type != MT_PLAYER)