• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

This is a fork of Zandronum Beta for TSPG.


Commit MetaInfo

Revisión2d248057a368c8bfd3fa4a5a6f3205dc6742d325 (tree)
Tiempo2021-11-29 04:28:02
AutorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

Added a variant of GAMEEVENT_ACTOR_DAMAGED that is triggered just before an actor's armor can absorb any damage, called GAMEEVENT_ACTOR_ARMORDAMAGED.

Cambiar Resumen

Diferencia incremental

diff -r 59193cc88f92 -r 2d248057a368 docs/zandronum-history.txt
--- a/docs/zandronum-history.txt Mon Nov 29 08:21:26 2021 +1100
+++ b/docs/zandronum-history.txt Sun Nov 28 14:28:02 2021 -0500
@@ -58,6 +58,7 @@
5858 + - Added all of the text colors from "New Text Colors", originally made by FuzzballFox. [Kaminsky]
5959 + - Added the EVENT script type: GAMEEVENT_PLAYERCONNECT, indicating when a client or bot joins the server. [Kaminsky]
6060 + - Added the EVENT script type GAMEEVENT_ACTOR_SPAWNED and GAMEVENT_ACTOR_DAMAGED, which are triggered just before an actor's first tic and when an actor takes damage. Note that for performance reasons, these events are disabled by default so modders have to enable them by themselves. [Kaminsky]
61++ - Added the EVENT script type GAMEEVENT_ACTOR_ARMORDAMAGED that's triggered just before an actor's armor absorbs any damage inflicted on it. [Kaminsky]
6162 + - Added DMFlags: "sv_shootthroughallies" and "sv_dontpushallies", so a player's attacks can pass through and not push their allies. [Kaminsky]
6263 + - Added packet loss mitigation, which the client can control using the CVar "cl_backupcommands". [Kaminsky]
6364 + - Added the server CVAR "sv_country", which allows servers to present their country to launchers. [Sean]
diff -r 59193cc88f92 -r 2d248057a368 src/gamemode.cpp
--- a/src/gamemode.cpp Mon Nov 29 08:21:26 2021 +1100
+++ b/src/gamemode.cpp Sun Nov 28 14:28:02 2021 -0500
@@ -1093,7 +1093,7 @@
10931093 // actor pointers that were responsible for calling the event
10941094 // become NULL after one tic.
10951095 // Also allow chat events to be executed immediately.
1096- bool bRunNow = ( Event == GAMEEVENT_ACTOR_SPAWNED || Event == GAMEEVENT_ACTOR_DAMAGED || Event == GAMEEVENT_CHAT );
1096+ const bool bRunNow = ( Event == GAMEEVENT_ACTOR_SPAWNED || Event == GAMEEVENT_ACTOR_DAMAGED || Event == GAMEEVENT_ACTOR_ARMORDAMAGED || Event == GAMEEVENT_CHAT );
10971097
10981098 // [BB] The activator of the event activates the event script.
10991099 // The first argument is the type, e.g. GAMEEVENT_PLAYERFRAGS,
@@ -1111,7 +1111,7 @@
11111111
11121112 //*****************************************************************************
11131113 //
1114-bool GAMEMODE_HandleDamageEvent ( AActor *target, AActor *inflictor, AActor *source, int &damage, FName mod )
1114+bool GAMEMODE_HandleDamageEvent ( AActor *target, AActor *inflictor, AActor *source, int &damage, FName mod, bool bBeforeArmor )
11151115 {
11161116 // [AK] Don't run any scripts if the target doesn't allow executing GAMEEVENT_ACTOR_DAMAGED.
11171117 if ( target->STFlags & STFL_NODAMAGEEVENTSCRIPT )
@@ -1122,6 +1122,8 @@
11221122 if ((( target->STFlags & STFL_USEDAMAGEEVENTSCRIPT ) == false ) && ( gameinfo.bForceDamageEventScripts == false ))
11231123 return true;
11241124
1125+ const GAMEEVENT_e DamageEvent = bBeforeArmor ? GAMEEVENT_ACTOR_ARMORDAMAGED : GAMEEVENT_ACTOR_DAMAGED;
1126+
11251127 // [AK] We somehow need to pass all the actor pointers into the script itself. A simple way
11261128 // to do this is temporarily spawn a temporary actor and change its actor pointers to the target,
11271129 // source, and inflictor. We can then use these to initialize the AAPTR_DAMAGE_TARGET,
@@ -1133,7 +1135,7 @@
11331135 temp->tracer = inflictor;
11341136
11351137 GAMEMODE_SetEventResult( damage );
1136- damage = GAMEMODE_HandleEvent( GAMEEVENT_ACTOR_DAMAGED, temp, damage, GlobalACSStrings.AddString( mod ));
1138+ damage = GAMEMODE_HandleEvent( DamageEvent, temp, damage, GlobalACSStrings.AddString( mod ));
11371139
11381140 // [AK] Destroy the temporary actor after executing all event scripts.
11391141 temp->Destroy( );
diff -r 59193cc88f92 -r 2d248057a368 src/gamemode.h
--- a/src/gamemode.h Mon Nov 29 08:21:26 2021 +1100
+++ b/src/gamemode.h Sun Nov 28 14:28:02 2021 -0500
@@ -132,6 +132,7 @@
132132 GAMEEVENT_PLAYERCONNECT,
133133 GAMEEVENT_ACTOR_SPAWNED,
134134 GAMEEVENT_ACTOR_DAMAGED,
135+ GAMEEVENT_ACTOR_ARMORDAMAGED,
135136 } GAMEEVENT_e;
136137
137138 //*****************************************************************************
@@ -213,7 +214,7 @@
213214 GAMESTATE_e GAMEMODE_GetState ( void );
214215 void GAMEMODE_SetState ( GAMESTATE_e GameState );
215216 LONG GAMEMODE_HandleEvent ( const GAMEEVENT_e Event, AActor *pActivator = NULL, const int DataOne = 0, const int DataTwo = 0 );
216-bool GAMEMODE_HandleDamageEvent ( AActor *target, AActor *inflictor, AActor *source, int &damage, FName mod );
217+bool GAMEMODE_HandleDamageEvent ( AActor *target, AActor *inflictor, AActor *source, int &damage, FName mod, bool bBeforeArmor = false );
217218 LONG GAMEMODE_GetEventResult ( void );
218219 void GAMEMODE_SetEventResult ( LONG lResult );
219220
diff -r 59193cc88f92 -r 2d248057a368 src/p_acs.cpp
--- a/src/p_acs.cpp Mon Nov 29 08:21:26 2021 +1100
+++ b/src/p_acs.cpp Sun Nov 28 14:28:02 2021 -0500
@@ -11721,11 +11721,11 @@
1172111721 // [TP] We need to store this as activefontname instead.
1172211722 activefontname = "SmallFont";
1172311723
11724- // [AK] Check if this is an event script triggered by GAMEEVENT_ACTOR_DAMAGED. This is
11725- // where we initialize the script's target, source, and inflictor pointers by using the
11726- // temporary activator's own pointers.
11724+ // [AK] Check if this is an event script triggered by GAMEEVENT_ACTOR_DAMAGED or
11725+ // GAMEEVENT_ACTOR_ARMORDAMAGED. This is where we initialize the script's target,
11726+ // source, and inflictor pointers by using the temporary activator's own pointers.
1172711727 if (( NETWORK_InClientMode( ) == false ) && ( who != NULL ) &&
11728- ( code->Type == SCRIPT_Event ) && ( args[0] == GAMEEVENT_ACTOR_DAMAGED ))
11728+ ( code->Type == SCRIPT_Event ) && ( args[0] == GAMEEVENT_ACTOR_DAMAGED || args[0] == GAMEEVENT_ACTOR_ARMORDAMAGED ))
1172911729 {
1173011730 pDamageTarget = who->target;
1173111731 pDamageSource = who->master;
diff -r 59193cc88f92 -r 2d248057a368 src/p_acs.h
--- a/src/p_acs.h Mon Nov 29 08:21:26 2021 +1100
+++ b/src/p_acs.h Sun Nov 28 14:28:02 2021 -0500
@@ -1074,8 +1074,8 @@
10741074 int InModuleScriptNumber;
10751075 FString activefontname; // [TP]
10761076
1077- // [AK] Pointers to the source, inflictor, and target actors that triggered a GAMEEVENT_ACTOR_DAMAGED event.
1078- // In all other cases, these pointers should be equal to NULL.
1077+ // [AK] Pointers to the source, inflictor, and target actors that triggered a GAMEEVENT_ACTOR_DAMAGED or
1078+ // GAMEEVENT_ACTOR_ARMORDAMAGED event. In all other cases, these pointers should be equal to NULL.
10791079 TObjPtr<AActor> pDamageSource;
10801080 TObjPtr<AActor> pDamageInflictor;
10811081 TObjPtr<AActor> pDamageTarget;
@@ -1121,7 +1121,7 @@
11211121 friend class ServerCommands::ReplaceTextures;
11221122 // [AK] We need to access protected variables from this class when we tell the clients to print a HUD message.
11231123 friend void SERVERCOMMANDS_PrintACSHUDMessage( DLevelScript *pScript, const char *pszString, float fX, float fY, LONG lType, LONG lColor, float fHoldTime, float fInTime, float fOutTime, fixed_t Alpha, LONG lID, ULONG ulPlayerExtra, ServerCommandFlags flags );
1124- // [AK] If the current running script is a GAMEEVENT_ACTOR_DAMAGED event, this will return a pointer to the source, inflictor, or target actor.
1124+ // [AK] If the current running script is a GAMEEVENT_ACTOR_DAMAGED or GAMEEVENT_ACTOR_ARMORDAMAGED event, this returns a pointer to the source, inflictor, or target actor.
11251125 friend AActor *ACS_GetScriptDamagePointers( unsigned int pointer );
11261126 };
11271127
diff -r 59193cc88f92 -r 2d248057a368 src/p_interaction.cpp
--- a/src/p_interaction.cpp Mon Nov 29 08:21:26 2021 +1100
+++ b/src/p_interaction.cpp Sun Nov 28 14:28:02 2021 -0500
@@ -1552,6 +1552,11 @@
15521552
15531553 if (!(flags & DMG_NO_ARMOR) && player->mo->Inventory != NULL)
15541554 {
1555+ // [AK] Trigger an event script indicating that the player has taken damage before any damage
1556+ // can be absorbed by their armor. If the event returns 0, don't do anything else.
1557+ if ( GAMEMODE_HandleDamageEvent( target, inflictor, source, damage, mod, true ) == false )
1558+ return -1;
1559+
15551560 int newdam = damage;
15561561 player->mo->Inventory->AbsorbDamage (damage, mod, newdam);
15571562 damage = newdam;
@@ -1647,6 +1652,11 @@
16471652 // Armor for monsters.
16481653 if (!(flags & (DMG_NO_ARMOR|DMG_FORCED)) && target->Inventory != NULL && damage > 0)
16491654 {
1655+ // [AK] Trigger an event script indicating that the actor has taken damage before any damage
1656+ // can be absorbed by their armor. If the event returns 0, don't do anything else.
1657+ if ( GAMEMODE_HandleDamageEvent( target, inflictor, source, damage, mod, true ) == false )
1658+ return -1;
1659+
16501660 int newdam = damage;
16511661 target->Inventory->AbsorbDamage (damage, mod, newdam);
16521662 damage = newdam;