Skip to content

Commit

Permalink
Added KILL Script type and associated flags and GameInfo keyword.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
StrikerMan780 authored and Christoph Oelckers committed Jul 28, 2016
1 parent 1322ef2 commit c0eb8f3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/actor.h
Expand Up @@ -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 ---
Expand Down
1 change: 1 addition & 0 deletions src/gi.cpp
Expand Up @@ -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
{
Expand Down
1 change: 1 addition & 0 deletions src/gi.h
Expand Up @@ -173,6 +173,7 @@ struct gameinfo_t
FGIFont mStatscreenFinishedFont;
FGIFont mStatscreenEnteringFont;
bool norandomplayerclass;
bool forcekillscripts;

const char *GetFinalePage(unsigned int num) const;
};
Expand Down
2 changes: 2 additions & 0 deletions src/p_acs.h
Expand Up @@ -270,6 +270,8 @@ enum
SCRIPT_Unloading = 13,
SCRIPT_Disconnect = 14,
SCRIPT_Return = 15,
SCRIPT_Event = 16, // [BB]
SCRIPT_Kill = 17, // [JM]
};

// Script flags
Expand Down
6 changes: 6 additions & 0 deletions src/p_interaction.cpp
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/thingdef/thingdef_data.cpp
Expand Up @@ -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),
Expand Down

0 comments on commit c0eb8f3

Please sign in to comment.