From b1f87295b86487686b789f9cd730be525bc6fbe6 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 25 Sep 2014 16:47:41 -0500 Subject: [PATCH] - Added A_DamageSelf. - A_DamageSelf(int amount, name damagetype) --- src/thingdef/thingdef_codeptr.cpp | 31 +++++++++++++++++++++++++++---- wadsrc/static/actors/actor.txt | 1 + 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index f80e89aad..aff2629e4 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -3532,7 +3532,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS) //=========================================================================== // -// A_DamageMaster (int amount) +// A_DamageMaster (int amount, str damagetype) // Damages the master of this child by the specified amount. Negative values heal. // //=========================================================================== @@ -3558,7 +3558,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageMaster) //=========================================================================== // -// A_DamageChildren (amount) +// A_DamageChildren (amount, str damagetype) // Damages the children of this master by the specified amount. Negative values heal. // //=========================================================================== @@ -3592,7 +3592,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageChildren) //=========================================================================== // -// A_DamageSiblings (amount) +// A_DamageSiblings (int amount, str damagetype) // Damages the siblings of this master by the specified amount. Negative values heal. // //=========================================================================== @@ -4993,4 +4993,27 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetSpeed) ACTION_PARAM_FIXED(speed, 0); self->Speed = speed; -} +} + +//=========================================================================== +// +// A_DamageSelf (int amount, str damagetype) +// Damages the calling actor by the specified amount. Negative values heal. +// +//=========================================================================== +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageSelf) +{ + ACTION_PARAM_START(2); + ACTION_PARAM_INT(amount, 0); + ACTION_PARAM_NAME(DamageType, 1); + + if (amount > 0) + { + P_DamageMobj(self, self, self, amount, DamageType, DMG_NO_ARMOR); + } + else if (amount < 0) + { + amount = -amount; + P_GiveBody(self, amount); + } +} \ No newline at end of file diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index e66226c1e..95d055afb 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -304,6 +304,7 @@ ACTOR Actor native //: Thinker action native A_SetDamageType(name damagetype); 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_CheckSightOrRange(float distance, state label); action native A_CheckRange(float distance, state label);