• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] How do I make this MUI?

Status
Not open for further replies.
Level 7
Joined
Jul 9, 2012
Messages
158
How do I make this MUI? (Turns out unsolved again)

Hey guys!
I'm having trouble with this trigger. It is supposed to greate 5 "lights" around the caster where each light will absorb 20% damage and then will be removed. But it is not working when 2 units are casting it on the same time.


I can't find the problem myself :razz:
Thank you!

EDIT:
The trigger I posted in the first place has been replaced by a trigger in the comments, which still isn't working either.
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,378
Do you use unit indexer system? Since you use custom value, I wonder if you use indexing system, else it will return 0.

Either index those units into array or use a specific unit group.
E.g.
MaxIndex variable represents maximum (last) index. It should be initialized with value 0.
Caster[] array saves all casters into itself.
When spell is fired, you increase value of MaxIndex by 1 and then save the latest caster into Caster[MaxIndex].
In the loop trigger you use integer loop from 1 to MaxIndex and iterate through each layer of Caster[] and check their data.

You can use multiple arrays to hold multiple types of data.

Other way is that when unit casts an ability, you add that unit into specific group (e.g. DivineProtection_Group). Then in loop trigger you pick every unit in that group and check their data.
Do note that you don't destroy that group! You just add and remove units from it!

Last note:
Never create unit groups that quickly. Creating unit group is a costly process, more so if you create 1 every 0,04 second. The cost of the process increases with amount of units in the map. This can lead to serious fps drops.
 
Level 7
Joined
Jul 9, 2012
Messages
158
Thank for the answer! Yes, I am using an indexing system.
I will look into it, and I didn't knew about the unit groups too...! :eekani:

EDIT:
I have tried to follow your tip regarding to the indexing, but I haven't found the solution yet!

It only works in GUI; when two units are using it the same time the unit, which used the spell first, will share the lights with the second one. But the damage reduction and calculations works perfect.

Here is the new trigger:

  • Divine Protection Init
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Divine Protection
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DP_Boolean[(Custom value of (Triggering unit))] Equal to False
        • Then - Actions
          • Set DP_MaxIndex = (DP_MaxIndex + 1)
          • Set DP_Boolean[(Custom value of (Triggering unit))] = True
        • Else - Actions
      • Set DP_Caster[DP_MaxIndex] = (Triggering unit)
      • Set DP_Angle[DP_MaxIndex] = 0.00
      • Set DP_Integer[DP_MaxIndex] = (Level of Divine Protection for DP_Caster[DP_MaxIndex])
      • Set DP_Absorb[DP_MaxIndex] = (20.00 x (Real(DP_Integer[DP_MaxIndex])))
      • Set DP_Point[DP_MaxIndex] = (Position of DP_Caster[DP_MaxIndex])
      • Unit - Create 1 Dummy Unit for (Owner of DP_Caster[DP_MaxIndex]) at DP_Point[DP_MaxIndex] facing Default building facing degrees
      • Set DummyUnit = (Last created unit)
      • Unit - Add a 3.00 second Generic expiration timer to DummyUnit
      • Unit - Add Divine Protection to DummyUnit
      • Unit - Order DummyUnit to Night Elf Druid Of The Claw - Rejuvenation DP_Caster[DP_MaxIndex]
      • For each (Integer DP_Index[DP_MaxIndex]) from 1 to DP_Integer[DP_MaxIndex], do (Actions)
        • Loop - Actions
          • Unit - Remove DP_Light[DP_Index[DP_MaxIndex]] from the game
          • Set DP_Point2[DP_Index[DP_MaxIndex]] = (DP_Point[DP_Index[DP_MaxIndex]] offset by 25.00 towards ((360.00 / (Real(DP_Integer[DP_MaxIndex]))) x (Real(DP_Index[DP_MaxIndex]))) degrees)
          • Unit - Create 1 Light for (Owner of DP_Caster[DP_MaxIndex]) at DP_Point2[DP_Index[DP_MaxIndex]] facing Default building facing degrees
          • Set DP_Light[DP_Index[DP_MaxIndex]] = (Last created unit)
          • Custom script: call RemoveLocation(udg_DP_Point2[udg_DP_Index[udg_DP_MaxIndex]])
      • Custom script: call RemoveLocation(udg_DP_Point[udg_DP_MaxIndex])
  • Divine Protection Loop
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (DP_Caster[DP_HeroIndex] has buff Divine Protection ) Equal to True
        • Then - Actions
          • For each (Integer DP_HeroIndex) from 1 to DP_MaxIndex, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • DP_Integer[DP_HeroIndex] Greater than 0
                • Then - Actions
                  • Set DP_Angle[DP_HeroIndex] = (DP_Angle[DP_HeroIndex] + 5.00)
                  • Set DP_Point[DP_HeroIndex] = (Position of DP_Caster[DP_HeroIndex])
                  • For each (Integer DP_Index[DP_HeroIndex]) from 1 to DP_Integer[DP_HeroIndex], do (Actions)
                    • Loop - Actions
                      • Set DP_Point2[DP_Index[DP_HeroIndex]] = (DP_Point[DP_HeroIndex] offset by 50.00 towards (((360.00 / (Real(DP_Integer[DP_HeroIndex]))) x (Real(DP_Index[DP_HeroIndex]))) + DP_Angle[DP_HeroIndex]) degrees)
                      • Custom script: call SetUnitX(udg_DP_Light[udg_DP_Index[udg_DP_HeroIndex]],GetLocationX(udg_DP_Point2[udg_DP_Index[udg_DP_HeroIndex]]))
                      • Custom script: call SetUnitY(udg_DP_Light[udg_DP_Index[udg_DP_HeroIndex]],GetLocationY(udg_DP_Point2[udg_DP_Index[udg_DP_HeroIndex]]))
                      • Custom script: call RemoveLocation(udg_DP_Point2[udg_DP_Index[udg_DP_HeroIndex]])
                  • Custom script: call RemoveLocation(udg_DP_Point[udg_DP_HeroIndex])
                • Else - Actions
                  • Unit - Remove Divine Protection buff from DP_Caster[DP_HeroIndex]
        • Else - Actions
  • Divine Protection Absorb
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventTarget has buff Divine Protection ) Equal to True
    • Actions
      • For each (Integer DP_HeroIndex) from 1 to DP_MaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DamageEventTarget Equal to DP_Caster[DP_HeroIndex]
            • Then - Actions
              • Set DamageEventAmount = (DamageEventAmount - ((DamageEventAmount / 100.00) x DP_Absorb[DP_HeroIndex]))
              • Set DP_Absorb[DP_HeroIndex] = (DP_Absorb[DP_HeroIndex] - 20.00)
              • Unit - Remove DP_Light[DP_Integer[DP_HeroIndex]] from the game
              • Set DP_Integer[DP_HeroIndex] = (DP_Integer[DP_HeroIndex] - 1)
            • Else - Actions


I hope you can help me, because i'm totally lost.. :) Thank you.
 
Last edited:
Status
Not open for further replies.
Top