mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- trigger WorldThingDamaged event before WorldThingDied
https://forum.zdoom.org/viewtopic.php?t=60597
This commit is contained in:
parent
e9050a38b3
commit
fc91827900
1 changed files with 20 additions and 9 deletions
|
@ -909,7 +909,7 @@ static inline bool isFakePain(AActor *target, AActor *inflictor, int damage)
|
||||||
|
|
||||||
// Returns the amount of damage actually inflicted upon the target, or -1 if
|
// Returns the amount of damage actually inflicted upon the target, or -1 if
|
||||||
// the damage was cancelled.
|
// the damage was cancelled.
|
||||||
static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, FName mod, int flags, DAngle angle)
|
static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, FName mod, int flags, DAngle angle, bool& needevent)
|
||||||
{
|
{
|
||||||
DAngle ang;
|
DAngle ang;
|
||||||
player_t *player = NULL;
|
player_t *player = NULL;
|
||||||
|
@ -1503,8 +1503,13 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da
|
||||||
source = source->tracer;
|
source = source->tracer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int realdamage = MAX(0, damage);
|
||||||
|
E_WorldThingDamaged(target, inflictor, source, realdamage, mod, flags, angle);
|
||||||
|
needevent = false;
|
||||||
|
|
||||||
target->CallDie (source, inflictor, flags);
|
target->CallDie (source, inflictor, flags);
|
||||||
return MAX(0, damage);
|
return realdamage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1630,9 +1635,12 @@ DEFINE_ACTION_FUNCTION(AActor, DamageMobj)
|
||||||
PARAM_FLOAT_DEF(angle);
|
PARAM_FLOAT_DEF(angle);
|
||||||
|
|
||||||
// [ZZ] event handlers need the result.
|
// [ZZ] event handlers need the result.
|
||||||
int realdamage = DamageMobj(self, inflictor, source, damage, mod, flags, angle);
|
bool needevent = true;
|
||||||
if (!realdamage) ACTION_RETURN_INT(0);
|
int realdamage = DamageMobj(self, inflictor, source, damage, mod, flags, angle, needevent);
|
||||||
E_WorldThingDamaged(self, inflictor, source, realdamage, mod, flags, angle);
|
if (realdamage && needevent)
|
||||||
|
{
|
||||||
|
E_WorldThingDamaged(self, inflictor, source, realdamage, mod, flags, angle);
|
||||||
|
}
|
||||||
ACTION_RETURN_INT(realdamage);
|
ACTION_RETURN_INT(realdamage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1649,10 +1657,13 @@ int P_DamageMobj(AActor *target, AActor *inflictor, AActor *source, int damage,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int realdamage = DamageMobj(target, inflictor, source, damage, mod, flags, angle);
|
bool needevent = true;
|
||||||
if (!realdamage) return 0;
|
int realdamage = DamageMobj(target, inflictor, source, damage, mod, flags, angle, needevent);
|
||||||
// [ZZ] event handlers only need the resultant damage (they can't do anything about it anyway)
|
if (realdamage && needevent)
|
||||||
E_WorldThingDamaged(target, inflictor, source, realdamage, mod, flags, angle);
|
{
|
||||||
|
// [ZZ] event handlers only need the resultant damage (they can't do anything about it anyway)
|
||||||
|
E_WorldThingDamaged(target, inflictor, source, realdamage, mod, flags, angle);
|
||||||
|
}
|
||||||
return realdamage;
|
return realdamage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue