From c0eb8f3b9604612240956b75f3fcd9c5c38f5f13 Mon Sep 17 00:00:00 2001 From: Jordon Moss Date: Sat, 23 Jul 2016 05:21:04 -0300 Subject: [PATCH] Added KILL Script type and associated flags and GameInfo keyword. This is different from the original "Death Scripts" idea. This tackles some issues I've found with the original idea (now you can have as many scripts as you want, not just global and actor-defined). Also takes care of other complaints about the original idea and push request. Flags and their use are in code comments. --- src/actor.h | 2 ++ src/gi.cpp | 1 + src/gi.h | 1 + src/p_acs.h | 2 ++ src/p_interaction.cpp | 6 ++++++ src/thingdef/thingdef_data.cpp | 2 ++ 6 files changed, 14 insertions(+) diff --git a/src/actor.h b/src/actor.h index 93d2834a8..a9ce18a57 100644 --- a/src/actor.h +++ b/src/actor.h @@ -380,6 +380,8 @@ enum ActorFlag7 MF7_LAXTELEFRAGDMG = 0x00100000, // [MC] Telefrag damage can be reduced. MF7_ICESHATTER = 0x00200000, // [MC] Shatters ice corpses regardless of damagetype. MF7_ALLOWTHRUFLAGS = 0x00400000, // [MC] Allow THRUACTORS and the likes on puffs to prevent mod breakage. + MF7_USEKILLSCRIPTS = 0x00800000, // [JM] Use "KILL" Script on death if not forced by GameInfo. + MF7_NOKILLSCRIPTS = 0x01000000, // [JM] No "KILL" Script on death whatsoever, even if forced by GameInfo. }; // --- mobj.renderflags --- diff --git a/src/gi.cpp b/src/gi.cpp index 313df4f0b..9d45d2724 100644 --- a/src/gi.cpp +++ b/src/gi.cpp @@ -354,6 +354,7 @@ void FMapInfoParser::ParseGameInfo() GAMEINFOKEY_PATCH(mStatscreenFinishedFont, "statscreen_finishedpatch") GAMEINFOKEY_PATCH(mStatscreenEnteringFont, "statscreen_enteringpatch") GAMEINFOKEY_BOOL(norandomplayerclass, "norandomplayerclass") + GAMEINFOKEY_BOOL(forcekillscripts, "forcekillscripts") // [JM] Force kill scripts on thing death. (MF7_NOKILLSCRIPTS overrides.) else { diff --git a/src/gi.h b/src/gi.h index 2786b3425..c5b8f79cf 100644 --- a/src/gi.h +++ b/src/gi.h @@ -173,6 +173,7 @@ struct gameinfo_t FGIFont mStatscreenFinishedFont; FGIFont mStatscreenEnteringFont; bool norandomplayerclass; + bool forcekillscripts; const char *GetFinalePage(unsigned int num) const; }; diff --git a/src/p_acs.h b/src/p_acs.h index 13dad4651..243e2ccf3 100644 --- a/src/p_acs.h +++ b/src/p_acs.h @@ -270,6 +270,8 @@ enum SCRIPT_Unloading = 13, SCRIPT_Disconnect = 14, SCRIPT_Return = 15, + SCRIPT_Event = 16, // [BB] + SCRIPT_Kill = 17, // [JM] }; // Script flags diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 8890d3592..9f50c9ab5 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -379,6 +379,12 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags) target = source; } + // [JM] Fire KILL type scripts for actor. Not needed for players, since they have the "DEATH" script type. + if (!player && !(flags7 & MF7_NOKILLSCRIPTS) && ((flags7 & MF7_USEKILLSCRIPTS) || gameinfo.forcekillscripts)) + { + FBehavior::StaticStartTypedScripts(SCRIPT_Kill, this, true, 0, true); + } + flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SKULLFLY); if (!(flags4 & MF4_DONTFALL)) flags&=~MF_NOGRAVITY; flags |= MF_DROPOFF; diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index fba032662..0768f80c8 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -257,6 +257,8 @@ static FFlagDef ActorFlagDefs[]= DEFINE_FLAG(MF7, LAXTELEFRAGDMG, AActor, flags7), DEFINE_FLAG(MF7, ICESHATTER, AActor, flags7), DEFINE_FLAG(MF7, ALLOWTHRUFLAGS, AActor, flags7), + DEFINE_FLAG(MF7, USEKILLSCRIPTS, AActor, flags7), + DEFINE_FLAG(MF7, NOKILLSCRIPTS, AActor, flags7), // Effect flags DEFINE_FLAG(FX, VISIBILITYPULSE, AActor, effects),