Sooda
Diversity enchants
- Reaction score
- 318
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:
'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:
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 execution count is reset after 50 by default. Maximum is 8190 (Thanks AceHart). For example:
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.
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
- If - Conditions
- Loop - Actions
- Special Effect - Destroy hammer_sfx[trigExecCount]
- Events
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.