# HG changeset patch # User Adam Kaminski # Date 1633290408 14400 # Sun Oct 03 15:46:48 2021 -0400 # Node ID bdfe3ca5dbaa07e242287360fcdd0e0fa0a86f33 # Parent ae74fa3c316bd6828a566d230d22d1d56dc1043f Fixed the activator's target and master pointers in GAMEEVENT_ACTOR_DAMAGED event scripts. diff -r ae74fa3c316b -r bdfe3ca5dbaa src/gamemode.cpp --- a/src/gamemode.cpp Thu Sep 30 20:13:20 2021 -0400 +++ b/src/gamemode.cpp Sun Oct 03 15:46:48 2021 -0400 @@ -1115,21 +1115,20 @@ if ((( target->STFlags & STFL_USEDAMAGEEVENTSCRIPT ) == false ) && ( gameinfo.bForceDamageEventScripts == false )) return; - // [AK] We somehow need to pass the source and inflictor actor pointers into the script - // itself. A simple way to do this is temporarily changing the target's pointers to the - // source and inflictor, which we'll then use to initialize AAPTR_DAMAGE_SOURCE and - // AAPTR_DAMAGE_INFLICTOR for the script. - // The source actor is the activator, which we'll use to initialize AAPTR_DAMAGE_TARGET. - AActor *tempMaster = target->master; - AActor *tempTarget = target->target; - target->master = source; - target->target = inflictor; + // [AK] We somehow need to pass all the actor pointers into the script itself. A simple way + // to do this is temporarily spawn a temporary actor and change its actor pointers to the target, + // source, and inflictor. We can then use these to initialize the AAPTR_DAMAGE_TARGET, + // AAPTR_DAMAGE_SOURCE, and AAPTR_DAMAGE_INFLICTOR pointers of the script. + AActor *temp = Spawn( "MapSpot", target->x, target->y, target->z, NO_REPLACE ); - GAMEMODE_HandleEvent( GAMEEVENT_ACTOR_DAMAGED, target, damage, GlobalACSStrings.AddString( mod )); + temp->target = target; + temp->master = source; + temp->tracer = inflictor; - // [AK] Restore the source actor's old pointers. - target->master = tempMaster; - target->target = tempTarget; + GAMEMODE_HandleEvent( GAMEEVENT_ACTOR_DAMAGED, temp, damage, GlobalACSStrings.AddString( mod )); + + // [AK] Destroy the temporary actor after executing all event scripts. + temp->Destroy( ); } //***************************************************************************** diff -r ae74fa3c316b -r bdfe3ca5dbaa src/p_acs.cpp --- a/src/p_acs.cpp Thu Sep 30 20:13:20 2021 -0400 +++ b/src/p_acs.cpp Sun Oct 03 15:46:48 2021 -0400 @@ -11654,14 +11654,16 @@ // [AK] Check if this is an event script triggered by GAMEEVENT_ACTOR_DAMAGED. This is // where we initialize the script's target, source, and inflictor pointers by using the - // activator as the target, and the activator's own master and target, which are the - // source and inflictor respectively. + // temporary activator's own pointers. if (( NETWORK_InClientMode( ) == false ) && ( who != NULL ) && ( code->Type == SCRIPT_Event ) && ( args[0] == GAMEEVENT_ACTOR_DAMAGED )) { - pDamageTarget = who; + pDamageTarget = who->target; pDamageSource = who->master; - pDamageInflictor = who->target; + pDamageInflictor = who->tracer; + + // [AK] Make the target actor the activator. + activator = pDamageTarget; } else {