From 8d7a64bd17d2688ba05e2196f438c3b038cadd10 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 15 Feb 2017 00:43:30 +0100 Subject: [PATCH] - added a virtual 'used' method that gets called when the player presses use on an actor. This method will only be called if the actor does not have the USESPECIAL flag - that one will be handled as before. --- src/p_map.cpp | 8 ++++++++ wadsrc/static/zscript/actor.txt | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index e46c441db2..da84855fde 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -5287,6 +5287,14 @@ bool P_UseTraverse(AActor *usething, const DVector2 &start, const DVector2 &end, if (P_ActivateThingSpecial(in->d.thing, usething)) return true; } + IFVIRTUALPTR(usething, AActor, Used) + { + VMValue params[] = { usething, in->d.thing }; + int ret; + VMReturn vret(&ret); + GlobalVMStack.Call(func, params, 2, &vret, 1); + if (ret) return true; + } continue; } diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index ceda20bd85..5e2454ed25 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -329,7 +329,12 @@ class Actor : Thinker native { return -1; } - + + // Called when the player presses 'use' and an actor is found + virtual bool Used(Actor user) + { + return false; + } native static class GetReplacement(class cls); native static class GetReplacee(class cls);