- Added source and inflictor parameters to all A_Damage/Kill functions.

- Source is the actor to blame for the cause of damage (monster infighting for example). For missiles, modders should consider setting to AAPTR_TARGET.
- Inflictor is the actor doing the damage itself. Note that by changing this, it will take into account the flags on the pointed actor.
This commit is contained in:
MajorCooke 2016-05-17 11:22:29 -05:00 committed by Christoph Oelckers
parent 33ddbe8ab3
commit 2719905ade
2 changed files with 81 additions and 26 deletions

View file

@ -5848,7 +5848,7 @@ enum DMSS
DMSS_EITHER = 256, //Allow either type or species to be affected.
};
static void DoDamage(AActor *dmgtarget, AActor *self, int amount, FName DamageType, int flags, PClassActor *filter, FName species)
static void DoDamage(AActor *dmgtarget, AActor *inflictor, AActor *source, int amount, FName DamageType, int flags, PClassActor *filter, FName species)
{
bool filterpass = DoCheckClass(dmgtarget, filter, !!(flags & DMSS_EXFILTER)),
speciespass = DoCheckSpecies(dmgtarget, species, !!(flags & DMSS_EXSPECIES));
@ -5870,7 +5870,7 @@ static void DoDamage(AActor *dmgtarget, AActor *self, int amount, FName DamageTy
if (amount > 0)
{ //Should wind up passing them through just fine.
P_DamageMobj(dmgtarget, self, self, amount, DamageType, dmgFlags);
P_DamageMobj(dmgtarget, inflictor, source, amount, DamageType, dmgFlags);
}
else if (amount < 0)
{
@ -5893,8 +5893,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageSelf)
PARAM_INT_OPT (flags) { flags = 0; }
PARAM_CLASS_OPT (filter, AActor){ filter = NULL; }
PARAM_NAME_OPT (species) { species = NAME_None; }
PARAM_INT_OPT (src) { src = AAPTR_DEFAULT; }
PARAM_INT_OPT (inflict) { inflict = AAPTR_DEFAULT; }
DoDamage(self, self, amount, damagetype, flags, filter, species);
AActor *source = COPY_AAPTR(self, src);
AActor *inflictor = COPY_AAPTR(self, inflict);
DoDamage(self, inflictor, source, amount, damagetype, flags, filter, species);
return 0;
}
@ -5911,9 +5916,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageTarget)
PARAM_INT_OPT (flags) { flags = 0; }
PARAM_CLASS_OPT (filter, AActor){ filter = NULL; }
PARAM_NAME_OPT (species) { species = NAME_None; }
PARAM_INT_OPT (src) { src = AAPTR_DEFAULT; }
PARAM_INT_OPT (inflict) { inflict = AAPTR_DEFAULT; }
AActor *source = COPY_AAPTR(self, src);
AActor *inflictor = COPY_AAPTR(self, inflict);
if (self->target != NULL)
DoDamage(self->target, self, amount, damagetype, flags, filter, species);
DoDamage(self->target, inflictor, source, amount, damagetype, flags, filter, species);
return 0;
}
@ -5930,9 +5940,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageTracer)
PARAM_INT_OPT (flags) { flags = 0; }
PARAM_CLASS_OPT (filter, AActor){ filter = NULL; }
PARAM_NAME_OPT (species) { species = NAME_None; }
PARAM_INT_OPT (src) { src = AAPTR_DEFAULT; }
PARAM_INT_OPT (inflict) { inflict = AAPTR_DEFAULT; }
AActor *source = COPY_AAPTR(self, src);
AActor *inflictor = COPY_AAPTR(self, inflict);
if (self->tracer != NULL)
DoDamage(self->tracer, self, amount, damagetype, flags, filter, species);
DoDamage(self->tracer, inflictor, source, amount, damagetype, flags, filter, species);
return 0;
}
@ -5949,9 +5964,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageMaster)
PARAM_INT_OPT (flags) { flags = 0; }
PARAM_CLASS_OPT (filter, AActor){ filter = NULL; }
PARAM_NAME_OPT (species) { species = NAME_None; }
PARAM_INT_OPT (src) { src = AAPTR_DEFAULT; }
PARAM_INT_OPT (inflict) { inflict = AAPTR_DEFAULT; }
AActor *source = COPY_AAPTR(self, src);
AActor *inflictor = COPY_AAPTR(self, inflict);
if (self->master != NULL)
DoDamage(self->master, self, amount, damagetype, flags, filter, species);
DoDamage(self->master, inflictor, source, amount, damagetype, flags, filter, species);
return 0;
}
@ -5968,6 +5988,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageChildren)
PARAM_INT_OPT (flags) { flags = 0; }
PARAM_CLASS_OPT (filter, AActor){ filter = NULL; }
PARAM_NAME_OPT (species) { species = NAME_None; }
PARAM_INT_OPT (src) { src = AAPTR_DEFAULT; }
PARAM_INT_OPT (inflict) { inflict = AAPTR_DEFAULT; }
AActor *source = COPY_AAPTR(self, src);
AActor *inflictor = COPY_AAPTR(self, inflict);
TThinkerIterator<AActor> it;
AActor *mo;
@ -5975,7 +6000,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageChildren)
while ( (mo = it.Next()) )
{
if (mo->master == self)
DoDamage(mo, self, amount, damagetype, flags, filter, species);
DoDamage(mo, inflictor, source, amount, damagetype, flags, filter, species);
}
return 0;
}
@ -5993,6 +6018,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageSiblings)
PARAM_INT_OPT (flags) { flags = 0; }
PARAM_CLASS_OPT (filter, AActor){ filter = NULL; }
PARAM_NAME_OPT (species) { species = NAME_None; }
PARAM_INT_OPT (src) { src = AAPTR_DEFAULT; }
PARAM_INT_OPT (inflict) { inflict = AAPTR_DEFAULT; }
AActor *source = COPY_AAPTR(self, src);
AActor *inflictor = COPY_AAPTR(self, inflict);
TThinkerIterator<AActor> it;
AActor *mo;
@ -6002,7 +6032,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageSiblings)
while ((mo = it.Next()))
{
if (mo->master == self->master && mo != self)
DoDamage(mo, self, amount, damagetype, flags, filter, species);
DoDamage(mo, inflictor, source, amount, damagetype, flags, filter, species);
}
}
return 0;
@ -6025,7 +6055,7 @@ enum KILS
KILS_EITHER = 1 << 6,
};
static void DoKill(AActor *killtarget, AActor *self, FName damagetype, int flags, PClassActor *filter, FName species)
static void DoKill(AActor *killtarget, AActor *inflictor, AActor *source, FName damagetype, int flags, PClassActor *filter, FName species)
{
bool filterpass = DoCheckClass(killtarget, filter, !!(flags & KILS_EXFILTER)),
speciespass = DoCheckSpecies(killtarget, species, !!(flags & KILS_EXSPECIES));
@ -6052,7 +6082,7 @@ static void DoKill(AActor *killtarget, AActor *self, FName damagetype, int flags
}
if (!(flags & KILS_NOMONSTERS))
{
P_DamageMobj(killtarget, self, self, killtarget->health, damagetype, dmgFlags);
P_DamageMobj(killtarget, inflictor, source, killtarget->health, damagetype, dmgFlags);
}
}
}
@ -6070,9 +6100,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_KillTarget)
PARAM_INT_OPT (flags) { flags = 0; }
PARAM_CLASS_OPT (filter, AActor){ filter = NULL; }
PARAM_NAME_OPT (species) { species = NAME_None; }
PARAM_INT_OPT (src) { src = AAPTR_DEFAULT; }
PARAM_INT_OPT (inflict) { inflict = AAPTR_DEFAULT; }
AActor *source = COPY_AAPTR(self, src);
AActor *inflictor = COPY_AAPTR(self, inflict);
if (self->target != NULL)
DoKill(self->target, self, damagetype, flags, filter, species);
DoKill(self->target, inflictor, source, damagetype, flags, filter, species);
return 0;
}
@ -6088,9 +6123,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_KillTracer)
PARAM_INT_OPT (flags) { flags = 0; }
PARAM_CLASS_OPT (filter, AActor){ filter = NULL; }
PARAM_NAME_OPT (species) { species = NAME_None; }
PARAM_INT_OPT (src) { src = AAPTR_DEFAULT; }
PARAM_INT_OPT (inflict) { inflict = AAPTR_DEFAULT; }
AActor *source = COPY_AAPTR(self, src);
AActor *inflictor = COPY_AAPTR(self, inflict);
if (self->tracer != NULL)
DoKill(self->tracer, self, damagetype, flags, filter, species);
DoKill(self->tracer, inflictor, source, damagetype, flags, filter, species);
return 0;
}
@ -6106,9 +6146,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_KillMaster)
PARAM_INT_OPT (flags) { flags = 0; }
PARAM_CLASS_OPT (filter, AActor){ filter = NULL; }
PARAM_NAME_OPT (species) { species = NAME_None; }
PARAM_INT_OPT (src) { src = AAPTR_DEFAULT; }
PARAM_INT_OPT (inflict) { inflict = AAPTR_DEFAULT; }
AActor *source = COPY_AAPTR(self, src);
AActor *inflictor = COPY_AAPTR(self, inflict);
if (self->master != NULL)
DoKill(self->master, self, damagetype, flags, filter, species);
DoKill(self->master, inflictor, source, damagetype, flags, filter, species);
return 0;
}
@ -6124,6 +6169,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_KillChildren)
PARAM_INT_OPT (flags) { flags = 0; }
PARAM_CLASS_OPT (filter, AActor){ filter = NULL; }
PARAM_NAME_OPT (species) { species = NAME_None; }
PARAM_INT_OPT (src) { src = AAPTR_DEFAULT; }
PARAM_INT_OPT (inflict) { inflict = AAPTR_DEFAULT; }
AActor *source = COPY_AAPTR(self, src);
AActor *inflictor = COPY_AAPTR(self, inflict);
TThinkerIterator<AActor> it;
AActor *mo;
@ -6132,7 +6182,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_KillChildren)
{
if (mo->master == self)
{
DoKill(mo, self, damagetype, flags, filter, species);
DoKill(mo, inflictor, source, damagetype, flags, filter, species);
}
}
return 0;
@ -6150,6 +6200,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_KillSiblings)
PARAM_INT_OPT (flags) { flags = 0; }
PARAM_CLASS_OPT (filter, AActor){ filter = NULL; }
PARAM_NAME_OPT (species) { species = NAME_None; }
PARAM_INT_OPT (src) { src = AAPTR_DEFAULT; }
PARAM_INT_OPT (inflict) { inflict = AAPTR_DEFAULT; }
AActor *source = COPY_AAPTR(self, src);
AActor *inflictor = COPY_AAPTR(self, inflict);
TThinkerIterator<AActor> it;
AActor *mo;
@ -6160,7 +6215,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_KillSiblings)
{
if (mo->master == self->master && mo != self)
{
DoKill(mo, self, damagetype, flags, filter, species);
DoKill(mo, inflictor, source, damagetype, flags, filter, species);
}
}
}

View file

@ -289,17 +289,17 @@ ACTOR Actor native //: Thinker
native void A_SetSpeed(float speed, int ptr = AAPTR_DEFAULT);
native void A_SetFloatSpeed(float speed, int ptr = AAPTR_DEFAULT);
native void A_SetPainThreshold(int threshold, int ptr = AAPTR_DEFAULT);
native void A_DamageSelf(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None");
native void A_DamageTarget(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None");
native void A_DamageMaster(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None");
native void A_DamageTracer(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None");
native void A_DamageChildren(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None");
native void A_DamageSiblings(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None");
action native A_KillTarget(name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None");
action native A_KillMaster(name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None");
action native A_KillTracer(name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None");
action native A_KillChildren(name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None");
action native A_KillSiblings(name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None");
native void A_DamageSelf(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT);
native void A_DamageTarget(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT);
native void A_DamageMaster(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT);
native void A_DamageTracer(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT);
native void A_DamageChildren(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT);
native void A_DamageSiblings(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT);
action native A_KillTarget(name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT);
action native A_KillMaster(name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT);
action native A_KillTracer(name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT);
action native A_KillChildren(name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT);
action native A_KillSiblings(name damagetype = "none", int flags = 0, class<Actor> filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT);
action native A_RemoveTarget(int flags = 0, class<Actor> filter = "None", name species = "None");
action native A_RemoveMaster(int flags = 0, class<Actor> filter = "None", name species = "None");
action native A_RemoveTracer(int flags = 0, class<Actor> filter = "None", name species = "None");