• 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

Commit MetaInfo

Revisiónc363af79fb90d1d7b9f79bc82289ff0e71708fc1 (tree)
Tiempo2021-11-28 23:38:45
AutorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

The result value of GAMEEVENT_ACTOR_DAMAGED event scripts can now be used to change the final damage that the target will take.

Cambiar Resumen

Diferencia incremental

diff -r a9f4423847ec -r c363af79fb90 src/gamemode.cpp
--- a/src/gamemode.cpp Sun Nov 28 09:34:13 2021 -0500
+++ b/src/gamemode.cpp Sun Nov 28 09:38:45 2021 -0500
@@ -1110,16 +1110,16 @@
11101110
11111111 //*****************************************************************************
11121112 //
1113-void GAMEMODE_HandleDamageEvent ( AActor *target, AActor *inflictor, AActor *source, int damage, FName mod )
1113+bool GAMEMODE_HandleDamageEvent ( AActor *target, AActor *inflictor, AActor *source, int &damage, FName mod )
11141114 {
11151115 // [AK] Don't run any scripts if the target doesn't allow executing GAMEEVENT_ACTOR_DAMAGED.
11161116 if ( target->STFlags & STFL_NODAMAGEEVENTSCRIPT )
1117- return;
1117+ return true;
11181118
11191119 // [AK] Don't run any scripts if the target can't execute GAMEEVENT_ACTOR_DAMAGED unless
11201120 // all actors are forced to execute it.
11211121 if ((( target->STFlags & STFL_USEDAMAGEEVENTSCRIPT ) == false ) && ( gameinfo.bForceDamageEventScripts == false ))
1122- return;
1122+ return true;
11231123
11241124 // [AK] We somehow need to pass all the actor pointers into the script itself. A simple way
11251125 // to do this is temporarily spawn a temporary actor and change its actor pointers to the target,
@@ -1131,10 +1131,14 @@
11311131 temp->master = source;
11321132 temp->tracer = inflictor;
11331133
1134- GAMEMODE_HandleEvent( GAMEEVENT_ACTOR_DAMAGED, temp, damage, GlobalACSStrings.AddString( mod ));
1134+ GAMEMODE_SetEventResult( damage );
1135+ damage = GAMEMODE_HandleEvent( GAMEEVENT_ACTOR_DAMAGED, temp, damage, GlobalACSStrings.AddString( mod ));
11351136
11361137 // [AK] Destroy the temporary actor after executing all event scripts.
11371138 temp->Destroy( );
1139+
1140+ // [AK] If the new damage is zero, that means the target shouldn't take damage in P_DamageMobj.
1141+ return ( damage != 0 );
11381142 }
11391143
11401144 //*****************************************************************************
diff -r a9f4423847ec -r c363af79fb90 src/gamemode.h
--- a/src/gamemode.h Sun Nov 28 09:34:13 2021 -0500
+++ b/src/gamemode.h Sun Nov 28 09:38:45 2021 -0500
@@ -213,7 +213,7 @@
213213 GAMESTATE_e GAMEMODE_GetState ( void );
214214 void GAMEMODE_SetState ( GAMESTATE_e GameState );
215215 LONG GAMEMODE_HandleEvent ( const GAMEEVENT_e Event, AActor *pActivator = NULL, const int DataOne = 0, const int DataTwo = 0 );
216-void GAMEMODE_HandleDamageEvent ( AActor *target, AActor *inflictor, AActor *source, int damage, FName mod );
216+bool GAMEMODE_HandleDamageEvent ( AActor *target, AActor *inflictor, AActor *source, int &damage, FName mod );
217217 LONG GAMEMODE_GetEventResult ( void );
218218 void GAMEMODE_SetEventResult ( LONG lResult );
219219
diff -r a9f4423847ec -r c363af79fb90 src/p_interaction.cpp
--- a/src/p_interaction.cpp Sun Nov 28 09:34:13 2021 -0500
+++ b/src/p_interaction.cpp Sun Nov 28 09:38:45 2021 -0500
@@ -1573,7 +1573,10 @@
15731573 }
15741574
15751575 // [AK] Trigger an event script indicating that the player has taken damage, if we can.
1576- GAMEMODE_HandleDamageEvent( target, inflictor, source, damage, mod );
1576+ // If the event returns 0, then the target doesn't take damage and we do nothing.
1577+ if ( GAMEMODE_HandleDamageEvent( target, inflictor, source, damage, mod ) == false )
1578+ return -1;
1579+
15771580 bDamageEventHandled = true;
15781581
15791582 if (damage >= player->health
@@ -1585,8 +1588,9 @@
15851588 }
15861589
15871590 // [AK] If we haven't done so already, trigger an event script indicating that the player has taken damage.
1588- if ( bDamageEventHandled == false )
1589- GAMEMODE_HandleDamageEvent( target, inflictor, source, damage, mod );
1591+ // If the event returns 0, then the target doesn't take damage and we do nothing.
1592+ if (( bDamageEventHandled == false ) && ( GAMEMODE_HandleDamageEvent( target, inflictor, source, damage, mod ) == false ))
1593+ return -1;
15901594
15911595 player->health -= damage; // mirror mobj health here for Dave
15921596 // [RH] Make voodoo dolls and real players record the same health
@@ -1653,7 +1657,9 @@
16531657 }
16541658
16551659 // [AK] Trigger an event script indicating that the target actor has taken damage, if we can.
1656- GAMEMODE_HandleDamageEvent( target, inflictor, source, damage, mod );
1660+ // If the event returns 0, then the target doesn't take damage and we do nothing.
1661+ if ( GAMEMODE_HandleDamageEvent( target, inflictor, source, damage, mod ) == false )
1662+ return -1;
16571663
16581664 target->health -= damage;
16591665 }