I asked about this in the data section and they pointed me to the triggers section:
Basically I'm trying to make an ability that when casted on an enemy unit create a link between the units so that if the caster is killed by any unit it kills the targeted unit. I was informed that this can only be accomplished through triggers.
Create two global unit variable arrays called "Link Unit Caster[n]" and "Link Unit Target[n]" where n is the maximum number of links that can occur at any given time. Create a new trigger. When the ability is used (unit uses ability event), run an integer loop to check if Link Unit Target[integer] = No Unit. If true, set Link Unit Caster[integer] = triggering unit and Link Unit Target[integer] = triggering ability target unit. Then immediately Break the loop . This will establish the link.
Create a new trigger with event Unit Any Unit Dies. Under actions, create another integer loop from 1 to n. Create an if/then/else statement within the loop. Under conditions, use (triggering unit) = Link Unit Caster[integer], followed by Link Unit Target[integer] != No Unit, followed by Link Unit Target[integer] is Alive = true. Under actions, you can either kill Link Unit Target[integer] instantly or apply a damage effect (to attribute the kill to the caster.) Then set Link Unit Target[integer] = No Unit and Link Unit Caster[integer] = No Unit (it's a preset I think.)
That's basically how it would be done. Obviously you'll need to tweak it a bit to do exactly what you want. And you'll need to set Link Unit Target[n] to No Unit if that unit dies beforehand, same with the caster. Good luck!
The question would be: Do you need 100% accurate tracking of the death time? If not, you could do a periodic check like every 1 second and you could do the same thing with 1 trigger and 2 local variables.
Ok so I'm not super great at trigger but I tried to figure it out and this is what I got and I think I'm on the right track but so far it's not working...
You're off to a good start, however there is a fatal flaw. I'm not sure why you wanted your variables to be unit groups. Do you want a link to be between two units or two groups of units? If you want it to be between just two units, then they should be unit arrays, not unit group arrays.
I put an OR condition there because, theoretically, if either the caster or target variable is empty the link should be broken and a new one can be established in its place.
I asked about this in the data section and they pointed me to the triggers section:
Basically I'm trying to make an ability that when casted on an enemy unit create a link between the units so that if the caster is killed by any unit it kills the targeted unit. I was informed that this can only be accomplished through triggers.
Any help is appreciated :) ty
Create two global unit variable arrays called "Link Unit Caster[n]" and "Link Unit Target[n]" where n is the maximum number of links that can occur at any given time. Create a new trigger. When the ability is used (unit uses ability event), run an integer loop to check if Link Unit Target[integer] = No Unit. If true, set Link Unit Caster[integer] = triggering unit and Link Unit Target[integer] = triggering ability target unit. Then immediately Break the loop . This will establish the link.
Create a new trigger with event Unit Any Unit Dies. Under actions, create another integer loop from 1 to n. Create an if/then/else statement within the loop. Under conditions, use (triggering unit) = Link Unit Caster[integer], followed by Link Unit Target[integer] != No Unit, followed by Link Unit Target[integer] is Alive = true. Under actions, you can either kill Link Unit Target[integer] instantly or apply a damage effect (to attribute the kill to the caster.) Then set Link Unit Target[integer] = No Unit and Link Unit Caster[integer] = No Unit (it's a preset I think.)
That's basically how it would be done. Obviously you'll need to tweak it a bit to do exactly what you want. And you'll need to set Link Unit Target[n] to No Unit if that unit dies beforehand, same with the caster. Good luck!
The question would be: Do you need 100% accurate tracking of the death time? If not, you could do a periodic check like every 1 second and you could do the same thing with 1 trigger and 2 local variables.
Ok so I'm not super great at trigger but I tried to figure it out and this is what I got and I think I'm on the right track but so far it's not working...
(See Attachments)
Can anyone tell me what exactly is wrong here?
You're off to a good start, however there is a fatal flaw. I'm not sure why you wanted your variables to be unit groups. Do you want a link to be between two units or two groups of units? If you want it to be between just two units, then they should be unit arrays, not unit group arrays.
Here is a revised "Execute" trigger:
I put an OR condition there because, theoretically, if either the caster or target variable is empty the link should be broken and a new one can be established in its place.
I corrected that section but I still can't get it to work :( Is my other trigger (Any Unit Dies) right?
Well now that you've fixed up the execute trigger you have to fix up the death trigger.
The easiest thing to do is set up a loop to see which linked unit died.
Here's a basic revision:
By the way, make sure you set the default for "Maximum Number of Links" to 2 for each trigger or it won't work.