PDA

View Full Version : [Trigger] Passive variables to triggers w/o Wait MUI?


SupremeGrandRuler
07-25-2012, 12:36 AM
If I have a trigger like this:

Trigger 1
Event - Unit Casts Spell
Actions - Pick all units of type Footman
- Set MyVar = Picked Unit
- Damage picked unit

Trigger 2
Event - Unit takes Damage
Actions - Kill MyVar

Basically, I'm just reusing a variable that was set in one trigger and passing it on to another, but there are no waits within any of the triggers, would this still be MUI?

Dr Super Good
07-25-2012, 01:52 AM
What you are asking makes no sense...

In Trigger 1, add the picked unit to a unit group. Then in Trigger 2 you kill all units by iterating through that group when a unit takes damage.

Be aware that event objects only get destroyed when the trigger they were created for is. This means that a unit takes damage event attached to a trigger will still exist even if the unit it was bound for was removed. Unless the trigger is destroyed at some stage this becomes and event leak.

SupremeGrandRuler
07-25-2012, 02:15 AM
What you are asking makes no sense...

In Trigger 1, add the picked unit to a unit group. Then in Trigger 2 you kill all units by iterating through that group when a unit takes damage.

Be aware that event objects only get destroyed when the trigger they were created for is. This means that a unit takes damage event attached to a trigger will still exist even if the unit it was bound for was removed. Unless the trigger is destroyed at some stage this becomes and event leak.

OK let me try to rephrase:

It's for a spell: it throws a fireball at a unit, and if the unit has Buff X, then it runs a certain trigger. In my fireball trigger, it picks all units around the fireball, and if that picked unit has Buff X, then it runs a trigger B that will do some actions. Trigger B needs to know the location of the picked unit & who the picked unit is (that information is set in the Fireball trigger). I just use 2 simple variables with no arrays. Will this cause MUI problems?

Keep in mind it's for a spell and no waits are used.

I can post the entire triggers if needed but they are kinda long.

defskull
07-25-2012, 02:34 AM
Short Answer: Yes, it's MUI.
Because Warcraft III is a single-thread where triggers run one after another, it would be MUI IF there is no wait involve.

But I maybe wrong, because what you're doing now is not direct actions.

This is an example of "direct actions" which is MUI no matter what;
Untitled Trigger 001
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Animate Dead
Actions
Unit - Kill (Triggering unit)


No matter how much unit cast this spell at a time, it will still be MUI.

mckill2009
07-25-2012, 04:10 AM
The first post isnt MUI, coz you are using MyVar in a global way, what if somebody outside the picked group takes damage?, so it will kill the MyVar?...so better to use TriggerintyUnit as defskull showed you...

SupremeGrandRuler
07-26-2012, 12:06 AM
Short Answer: Yes, it's MUI.
Because Warcraft III is a single-thread where triggers run one after another, it would be MUI IF there is no wait involve.

But I maybe wrong, because what you're doing now is not direct actions.


Yes this is what I'm looking for. It's not a problem for me anyway, just something I am wondering about but I need to make sure. I hope someone can confirm this.

Also @ mckill, i can't do that because my Trigger B has no events, therefore no triggering units so I need to set that variable in a trigger in which there is a triggering unit.

But like I said above, it's not a problem for me, just something I am wondering about.

mckill2009
07-26-2012, 01:06 AM
i can't do that because my Trigger B has no events


Im reffering to the first post...

Trigger 2
Event - Unit takes Damage
Actions - Kill MyVar

SupremeGrandRuler
07-26-2012, 01:47 AM
Im reffering to the first post...

Yea sorry ignore that. Just an example off the top of my head.

SupremeGrandRuler
07-27-2012, 07:43 PM
Any comfirmation on what defskull said?

defskull
07-28-2012, 05:40 AM
Which ?
Oh, if you don't believe me, you should run a test ?
Create a 3 triggers that has separate event (3 trigger detects 3 casting ability) like this;
Ability 1
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Ability 1
Actions
Set Caster = (Triggering unit)
Unit - Set life of Caster to ((Life of Caster) + 100.00)


Ability 2
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Ability 2
Actions
Set Caster = (Triggering unit)
Unit - Kill Caster


Ability 3
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Ability 3
Actions
Set Caster = (Triggering unit)
Unit - Remove Caster from the game


To order those units to cast those spells at the same time, simply pick them in Unit Group and order them to cast each spell order string.

You will notice in those 3 triggers, they shared the same variable but since Warcraft III is single-threaded, it will run one after another (it can never run at the same time), making the spell MUI (no Wait/Delay is involved, just direct actions)

mckill2009
07-28-2012, 06:09 AM
def while 'Triggering unit' can be MUI in direct actions, but if you store it into a global variable it will change it's value...
you cant use Unit groups as testing coz the first unit will cast first, so Ability 1 as PickedUnit will cast first, then 2-3...

defskull
07-28-2012, 06:18 AM
I used Timer as prepare duration and when Timer expires, order those units to simultaneously cast the spell (each with 3 separate events)
Each cast I set Caster = (Triggering unit)

Prove is, all 3 units died.

mckill2009
07-28-2012, 07:08 AM
I cant view your sample map yet coz I dont have WE now, but if you did like this;

Event
Timer - Expires
Conditions
Unit - Issue With No Target(abil 1)
Unit - Issue With No Target(abil 2)
Unit - Issue With No Target(abil 3)

its still the same as looping through unit groups, but if you do it in multiplayer, it can cause desyncs,
although it's very very rare that 2 players can cast it at the same time as 99.99% of the time, the upper thread casts first...

defskull
07-28-2012, 07:21 AM
Melee Initialization
Events
Time - Elapsed game time is 0.00 seconds
Conditions
Actions
Countdown Timer - Start Timer as a One-shot timer that will expire in 5.00 seconds
Set Timer = (Last started timer)


Untitled Trigger 001
Events
Time - Timer expires
Conditions
Actions
Unit - Order Blood Mage 0000 <gen> to Night Elf Druid Of The Claw - Roar


Untitled Trigger 001 Copy
Events
Time - Timer expires
Conditions
Actions
Unit - Order Blood Mage 0001 <gen> to Night Elf Druid Of The Claw - Roar


Untitled Trigger 001 Copy 2
Events
Time - Timer expires
Conditions
Actions
Unit - Order Blood Mage 0002 <gen> to Night Elf Druid Of The Claw - Roar


Untitled Trigger 002
Events
Unit - A unit Starts the effect of an ability
Conditions
Actions
Set Caster = (Triggering unit)
Unit - Kill Caster


although it's very very rare that 2 players can cast it at the same time as 99.99% of the time, the upper thread casts first...
Believe me, Warcraft III uses single-threaded mechanics, it can never runs at the same time.

SupremeGrandRuler
07-28-2012, 09:42 PM
Believe me, Warcraft III uses single-threaded mechanics, it can never runs at the same time.

Yes, I understand that, what I meant is what if halfway through a trigger you use the action "Run (Another Trigger)"?

defskull
07-28-2012, 10:16 PM
Yes, I understand that, what I meant is what if halfway through a trigger you use the action "Run (Another Trigger)"?
It is safe too.
You know what, you should make this experiment all by yourselves.
After all, it's an easy experiment I guess.