diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index aff2629e4..6c44fa79e 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -5007,13 +5007,67 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageSelf) ACTION_PARAM_INT(amount, 0); ACTION_PARAM_NAME(DamageType, 1); - if (amount > 0) + if (amount > 0) + { + P_DamageMobj(self, self, self, amount, DamageType, DMG_NO_ARMOR); + } + else if (amount < 0) + { + amount = -amount; + P_GiveBody(self, amount); + } +} + +//=========================================================================== +// +// A_DamageTarget (int amount, str damagetype) +// Damages the target of the actor by the specified amount. Negative values heal. +// +//=========================================================================== +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageTarget) +{ + ACTION_PARAM_START(2); + ACTION_PARAM_INT(amount, 0); + ACTION_PARAM_NAME(DamageType, 1); + + if (self->target != NULL) { - P_DamageMobj(self, self, self, amount, DamageType, DMG_NO_ARMOR); + + if (amount > 0) + { + P_DamageMobj(self->target, self, self, amount, DamageType, DMG_NO_ARMOR); + } + else if (amount < 0) + { + amount = -amount; + P_GiveBody(self->target, amount); + } } - else if (amount < 0) +} + +//=========================================================================== +// +// A_DamageTracer (int amount, str damagetype) +// Damages the tracer of the actor by the specified amount. Negative values heal. +// +//=========================================================================== +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageTracer) +{ + ACTION_PARAM_START(2); + ACTION_PARAM_INT(amount, 0); + ACTION_PARAM_NAME(DamageType, 1); + + if (self->target != NULL) { - amount = -amount; - P_GiveBody(self, amount); + + if (amount > 0) + { + P_DamageMobj(self->tracer, self, self, amount, DamageType, DMG_NO_ARMOR); + } + else if (amount < 0) + { + amount = -amount; + P_GiveBody(self->tracer, amount); + } } } \ No newline at end of file diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 95d055afb..448d83f09 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -305,6 +305,8 @@ ACTOR Actor native //: Thinker action native A_DropItem(class item, int dropamount = -1, int chance = 256); action native A_SetSpeed(float speed); action native A_DamageSelf(int amount, name damagetype = "none"); + action native A_DamageTarget(int amount, name damagetype = "none"); + action native A_DamageTracer(int amount, name damagetype = "none"); action native A_CheckSightOrRange(float distance, state label); action native A_CheckRange(float distance, state label);