Revisión | 33f7f8b86568e48eb015e5d4995e36830dfa3dcb (tree) |
---|---|
Tiempo | 2021-11-29 04:28:02 |
Autor | Adam Kaminski <kaminskiadam9@gmai...> |
Commiter | Adam Kaminski |
Added a variant of GAMEEVENT_ACTOR_DAMAGED that is triggered just before an actor's armor can absorb any damage, called GAMEEVENT_ACTOR_ARMORDAMAGED.
@@ -58,6 +58,7 @@ | ||
58 | 58 | + - Added all of the text colors from "New Text Colors", originally made by FuzzballFox. [Kaminsky] |
59 | 59 | + - Added the EVENT script type: GAMEEVENT_PLAYERCONNECT, indicating when a client or bot joins the server. [Kaminsky] |
60 | 60 | + - 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] | |
61 | 62 | + - Added DMFlags: "sv_shootthroughallies" and "sv_dontpushallies", so a player's attacks can pass through and not push their allies. [Kaminsky] |
62 | 63 | + - Added packet loss mitigation, which the client can control using the CVar "cl_backupcommands". [Kaminsky] |
63 | 64 | + - Added the server CVAR "sv_country", which allows servers to present their country to launchers. [Sean] |
@@ -1093,7 +1093,7 @@ | ||
1093 | 1093 | // actor pointers that were responsible for calling the event |
1094 | 1094 | // become NULL after one tic. |
1095 | 1095 | // 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 ); | |
1097 | 1097 | |
1098 | 1098 | // [BB] The activator of the event activates the event script. |
1099 | 1099 | // The first argument is the type, e.g. GAMEEVENT_PLAYERFRAGS, |
@@ -1111,7 +1111,7 @@ | ||
1111 | 1111 | |
1112 | 1112 | //***************************************************************************** |
1113 | 1113 | // |
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 ) | |
1115 | 1115 | { |
1116 | 1116 | // [AK] Don't run any scripts if the target doesn't allow executing GAMEEVENT_ACTOR_DAMAGED. |
1117 | 1117 | if ( target->STFlags & STFL_NODAMAGEEVENTSCRIPT ) |
@@ -1122,6 +1122,8 @@ | ||
1122 | 1122 | if ((( target->STFlags & STFL_USEDAMAGEEVENTSCRIPT ) == false ) && ( gameinfo.bForceDamageEventScripts == false )) |
1123 | 1123 | return true; |
1124 | 1124 | |
1125 | + const GAMEEVENT_e DamageEvent = bBeforeArmor ? GAMEEVENT_ACTOR_ARMORDAMAGED : GAMEEVENT_ACTOR_DAMAGED; | |
1126 | + | |
1125 | 1127 | // [AK] We somehow need to pass all the actor pointers into the script itself. A simple way |
1126 | 1128 | // to do this is temporarily spawn a temporary actor and change its actor pointers to the target, |
1127 | 1129 | // source, and inflictor. We can then use these to initialize the AAPTR_DAMAGE_TARGET, |
@@ -1133,7 +1135,7 @@ | ||
1133 | 1135 | temp->tracer = inflictor; |
1134 | 1136 | |
1135 | 1137 | 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 )); | |
1137 | 1139 | |
1138 | 1140 | // [AK] Destroy the temporary actor after executing all event scripts. |
1139 | 1141 | temp->Destroy( ); |
@@ -132,6 +132,7 @@ | ||
132 | 132 | GAMEEVENT_PLAYERCONNECT, |
133 | 133 | GAMEEVENT_ACTOR_SPAWNED, |
134 | 134 | GAMEEVENT_ACTOR_DAMAGED, |
135 | + GAMEEVENT_ACTOR_ARMORDAMAGED, | |
135 | 136 | } GAMEEVENT_e; |
136 | 137 | |
137 | 138 | //***************************************************************************** |
@@ -213,7 +214,7 @@ | ||
213 | 214 | GAMESTATE_e GAMEMODE_GetState ( void ); |
214 | 215 | void GAMEMODE_SetState ( GAMESTATE_e GameState ); |
215 | 216 | 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 ); | |
217 | 218 | LONG GAMEMODE_GetEventResult ( void ); |
218 | 219 | void GAMEMODE_SetEventResult ( LONG lResult ); |
219 | 220 |
@@ -11721,11 +11721,11 @@ | ||
11721 | 11721 | // [TP] We need to store this as activefontname instead. |
11722 | 11722 | activefontname = "SmallFont"; |
11723 | 11723 | |
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. | |
11727 | 11727 | 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 )) | |
11729 | 11729 | { |
11730 | 11730 | pDamageTarget = who->target; |
11731 | 11731 | pDamageSource = who->master; |
@@ -1074,8 +1074,8 @@ | ||
1074 | 1074 | int InModuleScriptNumber; |
1075 | 1075 | FString activefontname; // [TP] |
1076 | 1076 | |
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. | |
1079 | 1079 | TObjPtr<AActor> pDamageSource; |
1080 | 1080 | TObjPtr<AActor> pDamageInflictor; |
1081 | 1081 | TObjPtr<AActor> pDamageTarget; |
@@ -1121,7 +1121,7 @@ | ||
1121 | 1121 | friend class ServerCommands::ReplaceTextures; |
1122 | 1122 | // [AK] We need to access protected variables from this class when we tell the clients to print a HUD message. |
1123 | 1123 | 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. | |
1125 | 1125 | friend AActor *ACS_GetScriptDamagePointers( unsigned int pointer ); |
1126 | 1126 | }; |
1127 | 1127 |
@@ -1552,6 +1552,11 @@ | ||
1552 | 1552 | |
1553 | 1553 | if (!(flags & DMG_NO_ARMOR) && player->mo->Inventory != NULL) |
1554 | 1554 | { |
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 | + | |
1555 | 1560 | int newdam = damage; |
1556 | 1561 | player->mo->Inventory->AbsorbDamage (damage, mod, newdam); |
1557 | 1562 | damage = newdam; |
@@ -1647,6 +1652,11 @@ | ||
1647 | 1652 | // Armor for monsters. |
1648 | 1653 | if (!(flags & (DMG_NO_ARMOR|DMG_FORCED)) && target->Inventory != NULL && damage > 0) |
1649 | 1654 | { |
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 | + | |
1650 | 1660 | int newdam = damage; |
1651 | 1661 | target->Inventory->AbsorbDamage (damage, mod, newdam); |
1652 | 1662 | damage = newdam; |