• 🏆 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!

[Solved] Simple MUI spell

Status
Not open for further replies.
Level 28
Joined
Nov 12, 2007
Messages
2,340
I was trying to make this very simple MUI spell but it isn't working consistently (sometimes it does, sometimes it doesn't):

  • SL Start
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Healing Liquor (test)
    • Actions
      • Set SL_MaxIndex = (SL_MaxIndex + 1)
      • Set SL_Caster[SL_MaxIndex] = (Triggering unit)
      • Set SL_TargetUnit[SL_MaxIndex] = (Target unit of ability being cast)
      • Set SL_TargetPosition[SL_MaxIndex] = (Position of SL_TargetUnit[SL_MaxIndex])
      • -------- -------------------------------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SL_MaxIndex Equal to 1
        • Then - Actions
          • Trigger - Turn on SL Loop <gen>
        • Else - Actions

  • SL Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer SL_CurrentIndex) from 1 to SL_MaxIndex, do (Actions)
        • Loop - Actions
          • -------- Healing --------
          • Unit - Create 1 Dummy for (Owner of SL_Caster[SL_CurrentIndex]) at SL_TargetPosition[SL_CurrentIndex] facing Default building facing degrees
          • Unit - Add Healing Liquor (DUMMY) to (Last created unit)
          • Unit - Order (Last created unit) to Human Priest - Inner Fire SL_TargetUnit[SL_CurrentIndex]
          • Unit - Remove (Last created unit) from the game
          • -------- Recycling --------
          • Custom script: call RemoveLocation(udg_SL_TargetPosition[udg_SL_CurrentIndex])
          • Set SL_Caster[SL_CurrentIndex] = SL_Caster[SL_MaxIndex]
          • Set SL_TargetPosition[SL_CurrentIndex] = SL_TargetPosition[SL_MaxIndex]
          • Set SL_TargetUnit[SL_CurrentIndex] = SL_TargetUnit[SL_MaxIndex]
          • Set SL_MaxIndex = (SL_MaxIndex - 1)
          • Set SL_CurrentIndex = (SL_CurrentIndex - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SL_MaxIndex Equal to 0
            • Then - Actions
              • Trigger - Turn off (This trigger)
            • Else - Actions

Is the problem some failure in my MUI logic? Thanks in advance!
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Instead of "remove unit from the game" use "add expiration timer" with a longer duration than the cast time of the spell. In your case the cast time is probably 0, so a expiration timer of 0.1 seconds should be fine. You cannot be sure that the spell can be used within 0 seconds.

MUI logic is correct.
 
Level 28
Joined
Nov 12, 2007
Messages
2,340
It's not completed, or can you maybe even move the dummy actions just to the onCast trigger?

Oh that spell isn't complete yet! I planned to add a counter so the dummy will only cast after 5 seconds - but this depends on map balance.

But did you mean that if I'm leaving the spell "instant" (like they way I posted) I'm supposed to throw the whole thing in the cast trigger and remove the indexing? I thought that could affect the game if two units cast it at the same time.
 
planned to add a counter so the dummy will only cast after 5 seconds
ah, yes, then it's good.

I'm leaving the spell "instant" (like they way I posted) I'm supposed to throw the whole thing in the cast trigger and remove the indexing?
Yes, now the it waits only until the periodic trigger runs the next time, so 0 - 0.03 seconds of timeout, but it would also work just fine to order a dummy unit just instantly in the cast trigger.
And even units cast spells at same time, the triggers will firtsly execute for one unit, do all actions, and then start firing the trigger for the other unit - it can never be 2 events/triggers run at the very same time.
 
Level 28
Joined
Nov 12, 2007
Messages
2,340
Yes, now the it waits only until the periodic trigger runs the next time, so 0 - 0.03 seconds of timeout, but it would also work just fine to order a dummy unit just instantly in the cast trigger.
And even units cast spells at same time, the triggers will firtsly execute for one unit, do all actions, and then start firing the trigger for the other unit - it can never be 2 events/triggers run at the very same time.

Oh I see now. Thank you for making it clear!
 
Status
Not open for further replies.
Top