From d36f656caf78f6bc8a4d4c043aec7038b9efc2d7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 29 Mar 2017 20:25:54 +0200 Subject: [PATCH] - added a callback for when damage is drained from a target. --- src/p_interaction.cpp | 6 ++++++ wadsrc/static/zscript/actor.txt | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index eb1fb46fe..431c637de 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1415,6 +1415,12 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da } } + IFVIRTUALPTR(source, AActor, OnDrain) + { + VMValue params[] = { source, target, draindamage, mod.GetIndex() }; + VMReturn ret(&draindamage); + GlobalVMStack.Call(func, params, countof(params), &ret, 1); + } if ( P_GiveBody( source, int(draindamage * damage))) { S_Sound(source, CHAN_ITEM, "*drainhealth", 1, ATTN_NORM ); diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index daac2f23d..fb883f846 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -489,6 +489,11 @@ class Actor : Thinker native return Obituary; } + virtual int OnDrain(Actor victim, int damage, Name dmgtype) + { + return damage; + } + native virtual bool OkayToSwitchTarget(Actor other); native static class GetReplacement(class cls); native static class GetReplacee(class cls);