Demo Map Triggers - Multi-Unit Instanceability (MUI)

Sooda

Diversity enchants
Index:
1.0 - What is Multi-Unit Instanceability (MUI)?
1.1 - Trigger overlapping
1.2 - How to prevent it (achieving MUI)?
1.3 - Demo map with MUI knockback, damage over time abilities and tutorial example in action.

1.0 - What is Multi-Unit Instanceability (MUI)?
When triggered ability can be cast by multiple units at same time without ability malfunctioning. As a note MPI means Multi-Player Instanceability.

1.1 - Trigger overlapping
Happens when currently waiting trigger new instance fires and starts to overwrite previously set variable values. Trigger without waits never overlaps.

1.2 - How to prevent it (achieving MUI)?
Each trigger has execution count, that number is unique to every instance. Using that number as array indexes which trigger instance uses we achieve MUI.

When using custom scripts all your defined variables get prefix "udg_" (without ""). Local variable declaration must be first thing in trigger actions. Safest way to get started is always paste this section to your trigger start:
Trigger:
  • Actions
    • Custom script: local integer locExecCount = GetTriggerExecCount(GetTriggeringTrigger())
    • Custom script: if locExecCount == 50 then
    • Custom script: call ResetTrigger(GetTriggeringTrigger())
    • Custom script: endif
    • Custom script: set udg_trigExecCount = locExecCount

'trigExecCount' is integer variable with default starting values.

You can name variable differently, for example 'myTriggerIndex' (without ''). Then you would change variable name in custom script also:
Trigger:
  • Custom script: set udg_myTriggerIndex = locExecCount

I will use in my example still name 'trigExecCount' (without '').

Lastly MUI trigger with wait. After using wait in trigger you have to use custom script to set trigger execution variable again!
'triggerUnit' is unit variable array with default starting value.
Trigger:
  • Golden Hammer
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Golden Hammer (T)
    • Actions
      • Custom script: local integer locExecCount = GetTriggerExecCount(GetTriggeringTrigger())
      • Custom script: if locExecCount == 50 then
      • Custom script: call ResetTrigger(GetTriggeringTrigger())
      • Custom script: endif
      • Custom script: set udg_trigExecCount = locExecCount
      • Set hammer_target[trigExecCount] = (Target unit of ability being cast)
      • Set hammer_caster[trigExecCount] = (Triggering unit)
      • Special Effect - Create a special effect attached to the overhead of hammer_target[trigExecCount] using Objects\InventoryItems\PotofGold\PotofGold.mdl
      • Set hammer_sfx[trigExecCount] = (Last created special effect)
      • For each (Integer hammer_loop[trigExecCount]) from 1 to 3, do (Actions)
        • Loop - Actions
          • Unit - Cause hammer_caster[trigExecCount] to damage hammer_target[trigExecCount], dealing 50.00 damage of attack type Spells and damage type Normal
          • Player - Add 10 to (Owner of hammer_caster[trigExecCount]) Current gold
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (hammer_target[trigExecCount] is dead) Equal to True
            • Then - Actions
              • Special Effect - Destroy hammer_sfx[trigExecCount]
              • Player - Add 50 to (Owner of hammer_caster[trigExecCount]) Current gold
              • Skip remaining actions
            • Else - Actions
              • Wait 5.00 game-time seconds
              • Custom script: set udg_trigExecCount = locExecCount
      • Special Effect - Destroy hammer_sfx[trigExecCount]


Trigger execution count is reset after 50 by default. Maximum is 8190 (Thanks AceHart). For example:
Trigger:
  • Custom script: if locExecCount == 8190 then

When triggered ability requires 20 unit array indexes reserved then max simultaneous casts of ability would be 8190/ 20. Best would be to store instance reserved array index start to one integer variable and end to another integer variable.
1.3 - Demo map with MUI knockback, damage over time abilities and tutorial example in action.
It is attached below my post.

Version history:
1.3 - added Dash ability (works on area knock back trigger)
1.2 - fixed area knock back angle and added location check
1.1 - trigger execution count reset set to 50.
1.0 - Initial release.
 

Attachments

vypur85

Hibernate
Actually, I've done this before. Fusing Flare's MUI-GUI and then localise an integer so that all arrays are made MUI regardless of whether there's wait or not. Also, to make timer 'MUI', a dummy unit can be used to reference its custom value. Anyway, I've decided to scrape the idea because when the array becomes too big, it will either lags the game or may not function at all (this will happen if many large arrayed variables are created).

Anyway, I might be wrong, though.
 

AceHart

Your Friendly Neighborhood Admin
> if locExecCount == 8191 then

You should stop at 8190...

> set udg_trigExecCount = locExecCount

What's the point of using two variables here?

And, those (pseudo-)locals have a couple features, like not working inside "pick every"s, conditions, ...


Also, the example given is not very useful as "Dying unit" already has no problems.
(Other than waiting for ages and the unit is removed from the game of course)


> Instansable

is not a word.
 

Psiblade94122

In need of sleep
instead of telling my to copy and paste the scripts, can you please tell me the exact effects of each script and their purpose?

like call ResetTrigger(GetTriggeringTrigger()) is easy to understand, i get that much because its straight forward

but then you have stuff like
local integer locExecCount = GetTriggerExecCount(GetTriggeringTrigger())
where i see its an integer but i have no idea how its counting, thus i have no idea how this script works as a whole and that just makes my head hurt like crazy =_=

also, i understand that locals isolate the trigger so it wont be overlaped by another instance but i dont see how a local integer would make DOTS and Slides mui

and no i cannot see the demo map for another 4 or so hours, im reading this at school at the moment,perhaps ill understand it a bit better if i look at it though, but since your tut is so gung ho about copy paste this local and youll be fine, i dont think ill be able to understand how exactly dose this work outside of that
 

Sooda

Diversity enchants
I just updated demo map with minor fixes, it should now be down loadable.

> What's the point of using two variables here?

After wait I load from local variable trigger execution count to global variable. Execution count is unique index which used with arrays makes trigger MUI.


> I don't get custom script part.


is in GUI this:
Code:
Actions
    Set trigExecCount = (Execution count of (This trigger))
Convert it to custom script and you will see that same thing. I restore execution count from local integer variable which is glued to trigger and does not get lost with waits. Thanks for comments. I hope your head does not hurt so much anymore :)

EDIT:

I will add next Dash ability which shows how to slide caster while keeping MUI. It works same way as Gold Hammer ability.
 

Trollvottel

never aging title
Its a nice idea, i didnt even know that there was something like a execution count ^^. Will be useful for some GUIlers.
 

Leazy

You can change this now in User CP.
This is awesome :)

One question, lets say I got a variable called ''Kill_Point''. Can I now have three triggers using the same variable using that custom value way or do I need to create a new variable for each single MUI trigger? For example:

One trigger kills a unit, then waits and revives it at Kill_Point
One trigger creates 10 footmens at Kill_Point after 20 seconds that someone casted an ability
and one trigger creates two special effects 10 seconds after a unit moves at that point (at Kill_Point).

Will this work? (It's just an example)
 

emjlr3

Change can be a good thing
Staff member
if the only way to make GUI MUI is to use JASS....whats the point?
 

Romek

Super Moderator
Staff member
if the only way to make GUI MUI is to use JASS....whats the point?
It's only a few lines of Jass.
GUIers could learn those lines, or simply copy and paste.
Then they could continue the trigger in GUI, without having to fully learn Jass.
 

emjlr3

Change can be a good thing
Staff member
they could just as easily learn some simple JASS, and their triggering would be much better for it

spending a few hours learning it more then pays for itself in the long run, when you consider how much easier and faster it is to make trigger using JASS as compare dto GUI
 

Sooda

Diversity enchants
> One question, lets say I got a variable called ''Kill_Point''

'Kill_Point' needs to be variable array. Then you use trigger execution count as array index and it will be MUI when you restore from local variable execution count after wait in trigger. Without using array it is not possible.

Oh comments, I like feedback :)They could remember such trick to create MUI triggers. It' s similar to learning removing memory leaks.

EDIT:

Just for the record,

'triggerz' is trigger variable array with default starting value.
'triggerIndex' is integer variable with default starting value.
'thisTriggerIndex' is integer variable with default starting value.

Code:
Idea
    Events
    Conditions
    Actions
        -------- Set it up --------
        Set triggerz[triggerIndex] = (This trigger)
        Set triggerIndex = (triggerIndex + 1)
        -------- Get current trigger index --------
        For each (Integer A) from 0 to triggerIndex, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        triggerz[(Integer A)] Equal to (This trigger)
                    Then - Actions
                        Set thisTriggerIndex = (Integer A)
                    Else - Actions
        -------- Remove trigger from list --------
        For each (Integer A) from 0 to triggerIndex, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        triggerz[(Integer A)] Equal to (This trigger)
                    Then - Actions
                        Set triggerz[(Integer A)] = triggerz[triggerIndex]
                        Set triggerIndex = (triggerIndex - 1)
                    Else - Actions
Can be used to create MUI triggers with loop check, it is correct until 'This Trigger' points to fired trigger (maybe 60 seconds).
 

lindenkron

You can change this now in User CP
Now I've read this tutorial twice, and I might just be dumb, but I still don't get it...

Trigger:
  • MUI Example
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Custom script: local integer locExecCount = GetTriggerExecCount(GetTriggeringTrigger())
      • Custom script: if locExecCount == 50 then
      • Custom script: call ResetTrigger(GetTriggeringTrigger())
      • Custom script: endif
      • Custom script: set udg_trigExecCount = locExecCount
      • Set triggerUnit[trigExecCount] = (Dying unit)
      • Game - Display to (All players) the text: (Killed unit was: + (Name of (Dying unit)))
      • Game - Display to (All players) the text: (Trigger execution count: + (String(trigExecCount)))
      • Wait 5.00 seconds
      • -------- IMPORTANT: Setting with custom script trigger execution count again! --------
      • Custom script: set udg_trigExecCount = locExecCount
      • Game - Display to (All players) the text: (After wait unit was: + (Name of triggerUnit[trigExecCount]))


The custom scripts used here, are the same as in the abilities.. Right?
All I see that script doing is counting how many creeps have been killed, I fail to see how that helps me with my wait issue.. I see alot of stuff that I don't get, I don't know if this tutorial was made for peopel further in understanding JASS etc. then me, but it's not far enough basic for me atleast to understand.
 

Sooda

Diversity enchants
> I think it'd be easier if you just made them local globals. Less script overall.

Now that suggestion I didn't expected... whole point of this tutorial is to avoid map breaking local globals.

> The custom scripts used here, are the same as in the abilities.. Right?
Yes.

> I fail to see how that helps me with my wait issue..

It stores trigger execution count into local variable and sets global variable after wait again to local variable value (trigger execution count). Trigger execution count is unique to every trigger unless reset, which I do after 50 runs, 50 instances at same time should be fine for GUI-ers.

Here is GUI concept of it:
Trigger:
  • MUI Concept
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (Died unit name is: + (Name of (Dying unit)))
      • Set myUnitVariableArray[(Execution count of (This trigger))] = (Dying unit)
      • Wait 5.00 seconds
      • Game - Display to (All players) the text: (Died unit name after wait is still: + (Name of myUnitVariableArray[(Execution count of (This trigger))]))

Though it keeps MUI until 'This Trigger' is stored in memory (60 seconds maybe). I use local variable at actions start to store trigger. It makes MUI independent from 'This Trigger'.

EDIT: 'This Trigger' isn't safe to use, with new trigger firing execution count is raised.
 

SwedishChef

New Member
Sooda i have to say (and i hope that you see this) that your mui-tutorial is great:thup: i have only question thought: why do you only use " if locExecCount == 50 then" not ==30?? Maby nooby question but i got to know:p.

they could just as easily learn some simple JASS, and their triggering would be much better for it

spending a few hours learning it more then pays for itself in the long run, when you consider how much easier and faster it is to make trigger using JASS as compare dto GUI
I would love to learn jass but i don't understand the guides. I dont know how a jass "trigger" is built up and i don't know how the action, events and conditions should be written :confused:. Anyone have a good guide, maby you emjlr3??
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    The old shoutbox wasn't supported anymore. We updated xenForo, so it had to be replaced.
  • jonas jonas:
    let's see if everyone finds it... the nice thing about the shoutbox was I could check on it even while logged out, but the existence of this one is hidden when you're not logged in
  • Ghan Ghan:
    We can fix that.
  • Ghan Ghan:
    Chat should show on the sidebar when not logged in now.
  • Ghan Ghan:
    (You'll still need to log in to post messages)
  • Ghan Ghan:
    Test!
  • tom_mai78101 tom_mai78101:
    I must be in a test server.
  • tom_mai78101 tom_mai78101:
    Nice, Twitter tweets embedding now works
  • Wizard Wizard:
    Yup.
  • Ghan Ghan:
    Excellent.
  • Ghan Ghan:
    @tom_mai78101 Hello there.
  • Ghan Ghan:
    Tagging works in the chat too.
  • tom_mai78101 tom_mai78101:
    @Ghan Missed it.
  • Wizard Wizard:
    Still fixing things here and there. Added widgets to the portal, will make it match the ones here on the forum index tomorrow.
  • Ghan Ghan:
    The venerable World Editor Tutorials site has been converted to HTTPS at last.
  • jonas jonas:
    cool
  • jonas jonas:
    and I can even edit my messages, nice
  • seph ir oth seph ir oth:
    GENERAL CHIT CHAT, YOU ARE A BOLD ONE
  • Ghan Ghan:
    Hello there
  • The Helper The Helper:
    this new chatbox is great and the forum software update is great too
    +1
  • The Helper The Helper:
    upgrade has fixed forum registration spam problem
  • tom_mai78101 tom_mai78101:
    Something tells me we might be able to customize the chatbox a bit, considering that there's a gap under every message.
  • Wizard Wizard:
    Going to deploy a fix soon, just had to take some time for myself this weekend.
  • Varine Varine:
    Unbelievable. Time for yourself? How dare you!

    Staff online

    Members online

    Affiliates

    Hive Workshop
    Top