mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- took out the part of PIT_CheckThing that determines whether a missile should hurt its target and moved it to a separate function.
- fixed: MF7_HARMFRIENDS was checked on the victim of an attack, but needs to be checked on the shooter.
This commit is contained in:
parent
b6a5515ad7
commit
123da68735
1 changed files with 78 additions and 66 deletions
144
src/p_map.cpp
144
src/p_map.cpp
|
@ -903,6 +903,82 @@ static bool CheckRipLevel(AActor *victim, AActor *projectile)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// Isolated to keep the code readable and allow reuse in other attacks
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
static bool CanAttackHurt(AActor *victim, AActor *shooter)
|
||||||
|
{
|
||||||
|
// players are never subject to infighting settings and are always allowed
|
||||||
|
// to harm / be harmed by anything.
|
||||||
|
if (!victim->player && !shooter->player)
|
||||||
|
{
|
||||||
|
int infight;
|
||||||
|
if (level.flags2 & LEVEL2_TOTALINFIGHTING) infight = 1;
|
||||||
|
else if (level.flags2 & LEVEL2_NOINFIGHTING) infight = -1;
|
||||||
|
else infight = infighting;
|
||||||
|
|
||||||
|
if (infight < 0)
|
||||||
|
{
|
||||||
|
// -1: Monsters cannot hurt each other, but make exceptions for
|
||||||
|
// friendliness and hate status.
|
||||||
|
if (shooter->flags & MF_SHOOTABLE)
|
||||||
|
{
|
||||||
|
// Question: Should monsters be allowed to shoot barrels in this mode?
|
||||||
|
// The old code does not.
|
||||||
|
if (victim->flags3 & MF3_ISMONSTER)
|
||||||
|
{
|
||||||
|
// Monsters that are clearly hostile can always hurt each other
|
||||||
|
if (!victim->IsHostile(shooter))
|
||||||
|
{
|
||||||
|
// The same if the shooter hates the target
|
||||||
|
if (victim->tid == 0 || shooter->TIDtoHate != victim->tid)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (infight == 0)
|
||||||
|
{
|
||||||
|
// 0: Monsters cannot hurt same species except
|
||||||
|
// cases where they are clearly supposed to do that
|
||||||
|
if (victim->IsFriend(shooter))
|
||||||
|
{
|
||||||
|
// Friends never harm each other, unless the shooter has the HARMFRIENDS set.
|
||||||
|
if (!(shooter->flags7 & MF7_HARMFRIENDS)) return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (victim->TIDtoHate != 0 && victim->TIDtoHate == shooter->TIDtoHate)
|
||||||
|
{
|
||||||
|
// [RH] Don't hurt monsters that hate the same victim as you do
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (victim->GetSpecies() == shooter->GetSpecies() && !(victim->flags6 & MF6_DOHARMSPECIES))
|
||||||
|
{
|
||||||
|
// Don't hurt same species or any relative -
|
||||||
|
// but only if the target isn't one's hostile.
|
||||||
|
if (!victim->IsHostile(shooter))
|
||||||
|
{
|
||||||
|
// Allow hurting monsters the shooter hates.
|
||||||
|
if (victim->tid == 0 || shooter->TIDtoHate != victim->tid)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// else if (infight==1) every shot hurts anything - no further tests needed
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// PIT_CheckThing
|
// PIT_CheckThing
|
||||||
|
@ -1139,10 +1215,6 @@ bool PIT_CheckThing(AActor *thing, FCheckPosition &tm)
|
||||||
// [RH] Extend DeHacked infighting to allow for monsters
|
// [RH] Extend DeHacked infighting to allow for monsters
|
||||||
// to never fight each other
|
// to never fight each other
|
||||||
|
|
||||||
// [Graf Zahl] Why do I have the feeling that this didn't really work anymore now
|
|
||||||
// that ZDoom supports friendly monsters?
|
|
||||||
|
|
||||||
|
|
||||||
if (tm.thing->target != NULL)
|
if (tm.thing->target != NULL)
|
||||||
{
|
{
|
||||||
if (thing == tm.thing->target)
|
if (thing == tm.thing->target)
|
||||||
|
@ -1150,69 +1222,9 @@ bool PIT_CheckThing(AActor *thing, FCheckPosition &tm)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// players are never subject to infighting settings and are always allowed
|
if (!CanAttackHurt(thing, tm.thing->target))
|
||||||
// to harm / be harmed by anything.
|
|
||||||
if (!thing->player && !tm.thing->target->player)
|
|
||||||
{
|
{
|
||||||
int infight;
|
return false;
|
||||||
if (level.flags2 & LEVEL2_TOTALINFIGHTING) infight = 1;
|
|
||||||
else if (level.flags2 & LEVEL2_NOINFIGHTING) infight = -1;
|
|
||||||
else infight = infighting;
|
|
||||||
|
|
||||||
if (infight < 0)
|
|
||||||
{
|
|
||||||
// -1: Monsters cannot hurt each other, but make exceptions for
|
|
||||||
// friendliness and hate status.
|
|
||||||
if (tm.thing->target->flags & MF_SHOOTABLE)
|
|
||||||
{
|
|
||||||
// Question: Should monsters be allowed to shoot barrels in this mode?
|
|
||||||
// The old code does not.
|
|
||||||
if (thing->flags3 & MF3_ISMONSTER)
|
|
||||||
{
|
|
||||||
// Monsters that are clearly hostile can always hurt each other
|
|
||||||
if (!thing->IsHostile(tm.thing->target))
|
|
||||||
{
|
|
||||||
// The same if the shooter hates the target
|
|
||||||
if (thing->tid == 0 || tm.thing->target->TIDtoHate != thing->tid)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (infight == 0)
|
|
||||||
{
|
|
||||||
// 0: Monsters cannot hurt same species except
|
|
||||||
// cases where they are clearly supposed to do that
|
|
||||||
if (thing->IsFriend(tm.thing->target))
|
|
||||||
{
|
|
||||||
// Friends never harm each other, unless the shooter has the HARMFRIENDS set.
|
|
||||||
if (!(thing->flags7 & MF7_HARMFRIENDS)) return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (thing->TIDtoHate != 0 && thing->TIDtoHate == tm.thing->target->TIDtoHate)
|
|
||||||
{
|
|
||||||
// [RH] Don't hurt monsters that hate the same thing as you do
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (thing->GetSpecies() == tm.thing->target->GetSpecies() && !(thing->flags6 & MF6_DOHARMSPECIES))
|
|
||||||
{
|
|
||||||
// Don't hurt same species or any relative -
|
|
||||||
// but only if the target isn't one's hostile.
|
|
||||||
if (!thing->IsHostile(tm.thing->target))
|
|
||||||
{
|
|
||||||
// Allow hurting monsters the shooter hates.
|
|
||||||
if (thing->tid == 0 || tm.thing->target->TIDtoHate != thing->tid)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// else if (infight==1) any shot hurts anything - no further tests
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(thing->flags & MF_SHOOTABLE))
|
if (!(thing->flags & MF_SHOOTABLE))
|
||||||
|
|
Loading…
Reference in a new issue