This is a fork of Zandronum used on servers hosted by The Sentinels Playground (TSPG).
Revisión | 59f1474300fa889904ba85ce4526a0734db3af08 (tree) |
---|---|
Tiempo | 2021-10-04 04:46:48 |
Autor | Adam Kaminski <kaminskiadam9@gmai...> |
Commiter | Adam Kaminski |
Fixed the activator's target and master pointers in GAMEEVENT_ACTOR_DAMAGED event scripts.
@@ -1115,21 +1115,20 @@ | ||
1115 | 1115 | if ((( target->STFlags & STFL_USEDAMAGEEVENTSCRIPT ) == false ) && ( gameinfo.bForceDamageEventScripts == false )) |
1116 | 1116 | return; |
1117 | 1117 | |
1118 | - // [AK] We somehow need to pass the source and inflictor actor pointers into the script | |
1119 | - // itself. A simple way to do this is temporarily changing the target's pointers to the | |
1120 | - // source and inflictor, which we'll then use to initialize AAPTR_DAMAGE_SOURCE and | |
1121 | - // AAPTR_DAMAGE_INFLICTOR for the script. | |
1122 | - // The source actor is the activator, which we'll use to initialize AAPTR_DAMAGE_TARGET. | |
1123 | - AActor *tempMaster = target->master; | |
1124 | - AActor *tempTarget = target->target; | |
1125 | - target->master = source; | |
1126 | - target->target = inflictor; | |
1118 | + // [AK] We somehow need to pass all the actor pointers into the script itself. A simple way | |
1119 | + // to do this is temporarily spawn a temporary actor and change its actor pointers to the target, | |
1120 | + // source, and inflictor. We can then use these to initialize the AAPTR_DAMAGE_TARGET, | |
1121 | + // AAPTR_DAMAGE_SOURCE, and AAPTR_DAMAGE_INFLICTOR pointers of the script. | |
1122 | + AActor *temp = Spawn( "MapSpot", target->x, target->y, target->z, NO_REPLACE ); | |
1127 | 1123 | |
1128 | - GAMEMODE_HandleEvent( GAMEEVENT_ACTOR_DAMAGED, target, damage, GlobalACSStrings.AddString( mod )); | |
1124 | + temp->target = target; | |
1125 | + temp->master = source; | |
1126 | + temp->tracer = inflictor; | |
1129 | 1127 | |
1130 | - // [AK] Restore the source actor's old pointers. | |
1131 | - target->master = tempMaster; | |
1132 | - target->target = tempTarget; | |
1128 | + GAMEMODE_HandleEvent( GAMEEVENT_ACTOR_DAMAGED, temp, damage, GlobalACSStrings.AddString( mod )); | |
1129 | + | |
1130 | + // [AK] Destroy the temporary actor after executing all event scripts. | |
1131 | + temp->Destroy( ); | |
1133 | 1132 | } |
1134 | 1133 | |
1135 | 1134 | //***************************************************************************** |
@@ -11656,14 +11656,16 @@ | ||
11656 | 11656 | |
11657 | 11657 | // [AK] Check if this is an event script triggered by GAMEEVENT_ACTOR_DAMAGED. This is |
11658 | 11658 | // where we initialize the script's target, source, and inflictor pointers by using the |
11659 | - // activator as the target, and the activator's own master and target, which are the | |
11660 | - // source and inflictor respectively. | |
11659 | + // temporary activator's own pointers. | |
11661 | 11660 | if (( NETWORK_InClientMode( ) == false ) && ( who != NULL ) && |
11662 | 11661 | ( code->Type == SCRIPT_Event ) && ( args[0] == GAMEEVENT_ACTOR_DAMAGED )) |
11663 | 11662 | { |
11664 | - pDamageTarget = who; | |
11663 | + pDamageTarget = who->target; | |
11665 | 11664 | pDamageSource = who->master; |
11666 | - pDamageInflictor = who->target; | |
11665 | + pDamageInflictor = who->tracer; | |
11666 | + | |
11667 | + // [AK] Make the target actor the activator. | |
11668 | + activator = pDamageTarget; | |
11667 | 11669 | } |
11668 | 11670 | else |
11669 | 11671 | { |