SetActivatorToTarget not behaving correctly

Discuss all aspects related to modding Zandronum here.
Post Reply
User avatar
jdagenet
Forum Regular
Posts: 191
Joined: Tue Jun 05, 2012 8:08 am
Clan: Cube
Clan Tag: A3
Contact:

SetActivatorToTarget not behaving correctly

#1

Post by jdagenet » Tue Dec 13, 2016 4:13 am

I'm using this method of triggering actions when projectiles hit players on the enemy team.
[spoiler]

Code: Select all

Actor TriggerProj
{
	...
	
	+SEEKERMISSILE
	
	...
	States
	{
		Death:
			TNT1 A 0
			TNT1 A 0 A_SeekerMissile(0, 0, SMF_LOOK, 256, 0) //Look for a target
			TNT1 A 0 ACS_ExecuteAlways(614, 0, 2) //Execute the script
			TNT1 A 0 A_Stop
			Stop
	}
}
[/spoiler]
In this particular situation, I'm wanting to give health to the attacker if the projectile he fires makes contact with a player on the opposite team. Here is the script:
[spoiler]

Code: Select all

Script 614 (int x)
{
	if (SetActivator(0, AAPTR_TRACER)) //If it has a target
	{
		Switch (x)
		{
			Case 2:
				SetActivatorToTarget(0); //Make the attacker the original activator again
				//Give health stuff down below
				Break;
		}
	}
}
[/spoiler]
Now this setup does work, but there's a very specific situation in which it doesn't work as it should be: If the attackee is looking anywhere but directly at the attacker it doesn't work. After quite a bit of online testing, I've concluded that the SetActivatorToTarget(0); line doesn't work as it should because the attackee still remains the activator of script 614. As I mentioned, if the attackee is directly looking at the attacker the script works as intended.
I've made sure that there's nothing breaking in the seekermissile actor pointer storing because the script passes the if statement everytime, it's the SetActivatorToTarget(0) that breaks. Unless there's some undocumented credentials involving the tracer pointer and seekermissiles being used on players, I'm really not convinced that my code is breaking.

Why would the actor's angle have anything to do with SetActivatorToTarget(0)?

Catastrophe
Retired Staff / Community Team Member
Posts: 2559
Joined: Sat Jun 02, 2012 2:44 am

Re: SetActivatorToTarget not behaving correctly

#2

Post by Catastrophe » Tue Dec 13, 2016 5:48 am

As the wiki states,
If the tid being referenced is a living player, the new activator is first thing the player is aiming at.
This means that the game thinks either the attackee is still alive or there's something wrong with your ACS. The line that strikes me as odd is "SetActivator(0, AAPTR_TRACER)". Why would you need this? It should be enough to just have setactivatortotarget only. If the script gets ran on the attackee's death, it should be healing the attacker to full.

User avatar
Ivan
Addicted to Zandronum
Posts: 2219
Joined: Mon Jun 04, 2012 5:38 pm
Location: Omnipresent

Re: SetActivatorToTarget not behaving correctly

#3

Post by Ivan » Tue Dec 13, 2016 12:03 pm

Oh so you are finally realizing your "mistake"?

Give players, through pain states of the respective damage type, the cooldown item, and have them run an ACS script. In this script, check if the cooldown item is already on the player. If so, terminate. If not, have this:

Code: Select all

SetActivator(0, AAPTR_TARGET);
GiveInventory("ChokeHealer", 1);
Through many tests and debugging I have found that targets are not reliable unless you're directly using actor pointers themselves as in above.
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===

Post Reply