Adds "OnGiveSecret" virtual function on Actor for customizing behavior of secret finding.

This commit is contained in:
Marisa Kirisame 2018-04-11 16:49:42 +02:00 committed by Rachael Alexanderson
parent 674b6ee85c
commit 477cf23fd2
2 changed files with 13 additions and 1 deletions

View File

@ -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;

View File

@ -540,6 +540,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<Actor> GetReplacement(class<Actor> cls);
native static class<Actor> GetReplacee(class<Actor> cls);