# HG changeset patch # User Adam Kaminski # Date 1631398229 14400 # Sat Sep 11 18:10:29 2021 -0400 # Node ID deaf05345cb3187676f15cb4ee8b07b8847407df # Parent 7764ba08d5e0cf80040650c4ccb569f47d9ecfc3 Added the EVENT script type GAMEEVENT_ACTOR_SPAWNED, which is triggered just before an actor's first tic. Note that for performance reasons, this event only executes if the actor has the USESPAWNEVENTSCRIPT flag or if the GameInfo option "forcespawneventscripts" is enabled. diff -r 7764ba08d5e0 -r deaf05345cb3 docs/zandronum-history.txt --- a/docs/zandronum-history.txt Thu Sep 09 00:25:47 2021 -0400 +++ b/docs/zandronum-history.txt Sat Sep 11 18:10:29 2021 -0400 @@ -58,6 +58,7 @@ + - Added all of the text colors from "New Text Colors", originally made by FuzzballFox. [Kaminsky] + - Added DMFlags: "sv_shootthroughallies" and "sv_dontpushallies", so a player's attacks can pass through and not push their allies. [Kaminsky] + - Added the EVENT script type: GAMEEVENT_PLAYERCONNECT, indicating when a client or bot joins the server. [Kaminsky] ++ - Added the EVENT script type GAMEEVENT_ACTOR_SPAWNED, which is triggered just before an actor's first tic. Note that for performance reasons, this event only executes if the actor has the USESPAWNEVENTSCRIPT flag or if the GameInfo option "forcespawneventscripts" is enabled. [Kaminsky] - - Fixed: Bots tries to jump to reach item when sv_nojump is true. [sleep] - - Fixed: ACS function SetSkyScrollSpeed didn't work online. [Edward-san] - - Fixed: color codes in callvote reasons weren't terminated properly. [Dusk] diff -r 7764ba08d5e0 -r deaf05345cb3 src/actor.h --- a/src/actor.h Thu Sep 09 00:25:47 2021 -0400 +++ b/src/actor.h Sat Sep 11 18:10:29 2021 -0400 @@ -431,6 +431,10 @@ // [BB] Hidden by HideOrDestroyIfSafe(), will be restored when the map is reset. STFL_HIDDEN_INSTEAD_OF_DESTROYED = 0x00800000, + // [AK] This actor may (not) trigger GAMEEVENT_ACTOR_SPAWNED upon spawning. + STFL_USESPAWNEVENTSCRIPT = 0x01000000, + STFL_NOSPAWNEVENTSCRIPT = 0x02000000, + // More flags for Skulltag... these having to do with the network. // This object does not have a network ID. diff -r 7764ba08d5e0 -r deaf05345cb3 src/gamemode.h --- a/src/gamemode.h Thu Sep 09 00:25:47 2021 -0400 +++ b/src/gamemode.h Sat Sep 11 18:10:29 2021 -0400 @@ -114,6 +114,7 @@ GAMEEVENT_ROUND_ABORTED, GAMEEVENT_CHAT, GAMEEVENT_PLAYERCONNECT, + GAMEEVENT_ACTOR_SPAWNED, } GAMEEVENT_e; //***************************************************************************** diff -r 7764ba08d5e0 -r deaf05345cb3 src/gi.cpp --- a/src/gi.cpp Thu Sep 09 00:25:47 2021 -0400 +++ b/src/gi.cpp Sat Sep 11 18:10:29 2021 -0400 @@ -359,6 +359,9 @@ GAMEINFOKEY_BOOL(norandomplayerclass, "norandomplayerclass") GAMEINFOKEY_BOOL(forcekillscripts, "forcekillscripts") // [JM] Force kill scripts on thing death. (MF7_NOKILLSCRIPTS overrides.) + // [AK] Forces actors to trigger GAMEEVENT_ACTOR_SPAWNED unless they have STFL_NOSPAWNEVENTSCRIPT enabled. + GAMEINFOKEY_BOOL(bForceSpawnEventScripts, "forcespawneventscripts") + else { // ignore unkown keys. diff -r 7764ba08d5e0 -r deaf05345cb3 src/gi.h --- a/src/gi.h Thu Sep 09 00:25:47 2021 -0400 +++ b/src/gi.h Sat Sep 11 18:10:29 2021 -0400 @@ -145,6 +145,9 @@ bool norandomplayerclass; bool forcekillscripts; + // [AK] Forces actors to trigger GAMEEVENT_ACTOR_SPAWNED unless they have STFL_NOSPAWNEVENTSCRIPT enabled. + bool bForceSpawnEventScripts; + const char *GetFinalePage(unsigned int num) const; }; diff -r 7764ba08d5e0 -r deaf05345cb3 src/p_mobj.cpp --- a/src/p_mobj.cpp Thu Sep 09 00:25:47 2021 -0400 +++ b/src/p_mobj.cpp Sat Sep 11 18:10:29 2021 -0400 @@ -5178,6 +5178,19 @@ } PrevAngle = angle; flags7 |= MF7_HANDLENODELAY; + + // [AK] Trigger an event script indicating that the actor has spawned. We + // shouldn't need to execute this for players since we already have special + // script types like ENTER, RETURN, and RESPAWN. + if (( player == NULL ) && (( STFlags & STFL_NOSPAWNEVENTSCRIPT ) == false )) + { + bool bNotImportant = (( flags & ( MF_NOBLOCKMAP|MF_NOSECTOR )) || IsKindOf( RUNTIME_CLASS( AHexenArmor ))); + + // [AK] If we want to force GAMEEVENT_ACTOR_SPAWNED on every actor, then at least ignore + // the less imporant actors unless they have the USESPAWNEVENTSCRIPT flag enabled. + if (( STFlags & STFL_USESPAWNEVENTSCRIPT ) || (( gameinfo.bForceSpawnEventScripts ) && ( bNotImportant == false ))) + GAMEMODE_HandleEvent( GAMEEVENT_ACTOR_SPAWNED, this ); + } } void AActor::MarkPrecacheSounds() const diff -r 7764ba08d5e0 -r deaf05345cb3 src/thingdef/thingdef_data.cpp --- a/src/thingdef/thingdef_data.cpp Thu Sep 09 00:25:47 2021 -0400 +++ b/src/thingdef/thingdef_data.cpp Sat Sep 11 18:10:29 2021 -0400 @@ -265,6 +265,10 @@ DEFINE_FLAG(STFL, USESTBOUNCESOUND, AActor, STFlags), DEFINE_FLAG(STFL, EXPLODEONDEATH, AActor, STFlags), DEFINE_FLAG(STFL, DONTIDENTIFYTARGET, AActor, STFlags), // [CK] + + // [AK] Enables/disables GAMEEVENT_ACTOR_SPAWNED for the actor. + DEFINE_FLAG(STFL, USESPAWNEVENTSCRIPT, AActor, STFlags), + DEFINE_FLAG(STFL, NOSPAWNEVENTSCRIPT, AActor, STFlags), // [BB] New DECORATE network related flag defines here. DEFINE_FLAG(NETFL, NONETID, AActor, NetworkFlags),