• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Triggers

Status
Not open for further replies.
Level 5
Joined
Jan 27, 2014
Messages
164
Multi unit instanceability.
However, that's spelt...

Basically means your spell you created can cast on several units on an instance without causing errors. In the normal triggers, using waits will create some problem in making spells MUI.

For example:
Code:
Event
-- A unit starts the effect of an ability
Condition
-- Ability being cast Equal to Heal
Actions
-- Unit - Set (Target unit of ability being cast) to 50%
-- Wait 2 seconds
-- Unit - Set (Target unit of ability being cast) to 100%

The above trigger will bug because 'Target unit of ability being cast' will be forgotten after the wait. A way to fix this is to use variable.

For example:
Code:
Event
-- A unit starts the effect of an ability
Condition
-- Ability being cast Equal to Heal
Actions
-- Set unitvariable = (Target unit of ability being cast)
-- Unit - Set unitvariable to 50%
-- Wait 2 seconds
-- Unit - Set unitvariable to 100%

But the above is not MUI. If the spell is casted more than once on multiple units within 2 seconds, it will bug.
 
Level 17
Joined
Mar 21, 2011
Messages
1,611
For most situations you can use locals to obtain MUI
this will help alot if he doesnt even know what MUI is..

I will try to explain it as easy as possible:

Spell: A "target unit" ability that damages the targeted enemy after 3 seconds based on the level of the caster

Non - MUI trigger:
  • Trigger
    • Events
      • Unit - A unit starts the effect of an ability
    • Conditions
      • (Ability being cast) equal to YOUR_ABILITY
    • Actions
      • Wait 3.00 game-time seconds
      • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing (Real((Level of (Triggering unit)))) damage of attack type Spell and damage type Normal
(NOTE: triggering unit is the unit that triggers the event)
why is this not MUI?
example: A unit casts this spell, and 1 second later, another unit casts it
what happens now?
When the first unit casts the ability, the trigger will run and would work, because after the 3 seconds, the "triggering unit" is still the same. but if the second unit casts it 1 second after (the first usage of the trigger has to wait for another 2 seconds before the damage) the "triggering unit" will be overwritten with the new unit, which results into lots of unwanted things.

The solution:
use arrays to save the different units into different variables. Also try to avoid waits.

  • Init
    • Events
      • Unit - A unit starts the effect of an ability
    • Conditions
      • (Ability being cast) equal to YOUR_ABILITY
    • Actions
      • Set Counter = (Counter + 1)
      • Set Unit[Counter] = (Triggering unit)
      • Set Enemy[Counter] = (Target unit of ability being cast)
      • Set Time[Counter] = 3
  • Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer i) from 1 to Counter, do (Actions)
        • Loop - Actions
          • Set Time[i] = (Time[i] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Conditions
              • Time[i] equal to 0
            • 'THEN'-Actions
              • Unit - Cause Unit[i] to damage Enemy[i], dealing (Real((Level of Unit[i]))) damage of attack type Spells and damage type Normal
            • 'ELSE'-Actions
What happens here?
you trigger the event with a unit and save the triggering unit into a variable.
counter = counter + 1 (counter = 0 + 1)
set Unit[1] = triggering unit

...
after you cast it a second time

counter = counter + 1 (counter = 1 + 1)
set Unit[2] = triggering unit
..

and so on. the variables cannot collide with each other this way.
use that also for the time and the target enemy

now, in the second trigger we pick every integer number between 1 and the current counter value (that includes every caster) and reduce the time by 1. after that we check if the time is equal to 0. if this is the case, we will damage the enemy. just fill in the fields with the variables and fill the arrays with the current loop integer i

NOTE: this is just an example trigger and its very unefficient

i hope you understood a little bit :)
 
Status
Not open for further replies.
Top