From 477cf23fd2c0b8e50c8d0d0def89794ae834aa55 Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Wed, 11 Apr 2018 16:49:42 +0200 Subject: [PATCH] Adds "OnGiveSecret" virtual function on Actor for customizing behavior of secret finding. --- src/p_spec.cpp | 11 ++++++++++- wadsrc/static/zscript/actor.txt | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 5b32b410ad..e8dbe8d2f8 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -589,7 +589,15 @@ void P_GiveSecret(AActor *actor, bool printmessage, bool playsound, int sectornu { actor->player->secretcount++; } - if (cl_showsecretmessage && actor->CheckLocalView(consoleplayer)) + int retval = 1; + IFVIRTUALPTR(actor, AActor, OnGiveSecret) + { + VMValue params[] = { actor, printmessage, playsound }; + VMReturn ret; + ret.IntAt(&retval); + VMCall(func, params, countof(params), &ret, 1); + } + if (retval && cl_showsecretmessage && actor->CheckLocalView(consoleplayer)) { if (printmessage) { @@ -616,6 +624,7 @@ DEFINE_ACTION_FUNCTION(AActor, GiveSecret) return 0; } + DEFINE_ACTION_FUNCTION(FLevelLocals, GiveSecret) { PARAM_PROLOGUE; diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 61afdef0d5..5eb3a16adf 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -539,6 +539,9 @@ class Actor : Thinker native { return damage; } + + // called on getting a secret, return false to disable default "secret found" message/sound + virtual bool OnGiveSecret(bool printmsg, bool playsound); native virtual bool OkayToSwitchTarget(Actor other); native static class GetReplacement(class cls);