• 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.

[Trigger] MUI Spell

Status
Not open for further replies.
Level 19
Joined
Apr 21, 2013
Messages
1,194
Hey everyone,
I was working on a spell to help someone, it works fine with one hero but it fails when two caster use the spell within little time gaps.

it's a channeling spell; which the caster targets a point and waits for a few seconds and teleports to the point.



  • SpellExecution
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Blink(channeling)
    • Actions
      • Set castCount = (castCount + 1)
      • Set blinkCaster[castCount] = (Triggering unit)
      • Set targetLoc[castCount] = (Target point of ability being cast)
      • Set firstPos[castCount] = (Position of blinkCaster[castCount])
      • Trigger - Run Effects <gen> (checking conditions)
Okay the reason why i used 'begins channeling ability is; i want to create an effect before the action is done.

  • Blink
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Blink(channeling)
    • Actions
      • -------- Moving Unit --------
      • Unit - Move blinkCaster[castCount] instantly to targetLoc[castCount]
      • -------- The other special effect where it will appear in the taget location --------
      • Special Effect - Create a special effect at targetLoc[castCount] using Abilities\Spells\Other\Drain\ManaDrainCaster.mdl
      • Set specialEffecLastPos[castCount] = (Last created special effect)
      • Wait 0.70 seconds
      • Special Effect - Destroy specialEffecLastPos[castCount]
      • Custom script: call RemoveLocation (udg_targetLoc[udg_castCount])
This is the main spell.

  • Effects
    • Events
    • Conditions
    • Actions
      • Animation - Play blinkCaster[castCount]'s victory animation
      • Special Effect - Create a special effect at firstPos[castCount] using Abilities\Spells\Other\Drain\ManaDrainTarget.mdl
      • Set specialEffectFirstPos[castCount] = (Last created special effect)
      • Wait 2.00 seconds
      • Special Effect - Destroy specialEffectFirstPos[castCount]
And i needed to use another trigger for the animations because it uses "wait"


I tried to make it MUI but i failed :( Can anybody show what i'm doing wrong?

I posted the map too if anyone want to have changes on this one.
 

Attachments

  • Blink(channeling).w3x
    18.6 KB · Views: 38
Level 19
Joined
Mar 18, 2012
Messages
1,716
That's not how MUI works. You should take a look into to the tutorial in my signature "Dynamic Indexing".
It is a very well structured tutorial with pictures and the best, it is short.
Afterwards you should be able to fix the problem by yourself :).
If you still having questions feel free to post them here.

Waits should be avoided in any case, because you are quickly running into the problem that they are not MUI.
Also their timeout is not very precise. While timers are bound to the accuracy of the wc3 itself, wait timeouts can be very wrong.
 
Level 19
Joined
Apr 21, 2013
Messages
1,194
okay what about this i started a new one and the projectile goes nicely but still its not very well when another unit casts the spell right after first unit.

  • Spell2 Execution
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Spell2
    • Actions
      • Set Sp_Index = (Sp_Index + 1)
      • Set Sp_Caster[Sp_Index] = (Triggering unit)
      • Set Sp_Counter[Sp_Index] = 0.00
      • Set tempLoc1 = (Position of Sp_Caster[Sp_Index])
      • Set tempLoc2 = (Target point of ability being cast)
      • Set Sp_Angle[Sp_Index] = (Angle from tempLoc1 to tempLoc2)
      • Unit - Create 1 Dummy for (Owner of Sp_Caster[Sp_Index]) at tempLoc1 facing Sp_Angle[Sp_Index] degrees
      • Set Sp_Dummy[Sp_Index] = (Last created unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Sp_Index Equal to 1
        • Then - Actions
          • Trigger - Turn on Spell2 Loop <gen>
        • Else - Actions

  • Spell2 Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Sp_LoopInteger) from 1 to Sp_Index, do (Actions)
        • Loop - Actions
          • Set tempLoc2 = (Position of Sp_Dummy[Sp_LoopInteger])
          • Set tempLoc1 = (tempLoc2 offset by (1000.00 x 0.03) towards Sp_Angle[Sp_LoopInteger] degrees)
          • Unit - Move Sp_Dummy[Sp_LoopInteger] instantly to tempLoc1
          • Set Sp_Counter[Sp_LoopInteger] = (Sp_Counter[Sp_LoopInteger] + (1000.00 x 0.03))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Sp_Counter[Sp_LoopInteger] Greater than or equal to 1000.00
            • Then - Actions
              • Unit - Kill Sp_Dummy[Sp_LoopInteger]
              • Set Sp_Caster[Sp_LoopInteger] = Sp_Caster[Sp_Index]
              • Set Sp_Counter[Sp_LoopInteger] = Sp_Counter[Sp_Index]
              • Set Sp_Index = (Sp_Index - 1)
              • Set Sp_LoopInteger = (Sp_LoopInteger - 1)
              • Custom script: call RemoveLocation(udg_tempLoc1)
              • Custom script: call RemoveLocation(udg_tempLoc2)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Sp_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
I don't understand why this doesn't work. When another unit casts this spell right after the first one the second projectile stays on air frozen. But it works fine when cast only once at a moment.

I've not gotten into the damage issues now i just have to solve this movement issue first :)
 
Last edited:
Level 7
Joined
Mar 6, 2006
Messages
282
Remember when de-indexing, check all the variables you indexed in the Casting trigger, and make sure you de-index them.

  • Set Sp_Caster[Sp_LoopInteger] = Sp_Caster[Sp_Index]
  • Set Sp_Counter[Sp_LoopInteger] = Sp_Counter[Sp_Index]
  • Set Sp_Index = (Sp_Index - 1)
  • Set Sp_LoopInteger = (Sp_LoopInteger - 1)
You're missing Sp_Angle and Sp_Dummy.

Also, instead of this line:

  • Unit - Move Sp_Dummy[Sp_LoopInteger] instantly to tempLoc1
It's not completely necessary, but this is much faster and is usually used in loops with such small timers:

  • Custom script: call SetUnitX( udg_Sp_Dummy[udg_Sp_LoopInteger], GetLocationX(udg_tempLoc1) )
  • Custom script: call SetUnitY( udg_Sp_Dummy[udg_Sp_LoopInteger], GetLocationY(udg_tempLoc1) )
 
Level 5
Joined
Jan 27, 2014
Messages
164
You could try using hashtable perhaps?

It isn't too hard to trigger after all:
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set hash_point = (Last created hashtable)
  • Cast
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Channel
    • Actions
      • Hashtable - Save Handle Of(Target point of ability being cast) as (Key (Triggering unit)) of 0 in hash_point
  • Finish Cast
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Channel
    • Actions
      • Set temp_point = (Load (Key (Triggering unit)) of 0 in hash_point)
      • Unit - Move (Triggering unit) instantly to temp_point
  • Stop Cast
    • Events
      • Unit - A unit Stops casting an ability
    • Conditions
      • (Ability being cast) Equal to Channel
    • Actions
      • Set temp_point = (Load (Key (Triggering unit)) of 0 in hash_point)
      • Custom script: call RemoveLocation (udg_temp_point)
      • Hashtable - Clear all child hashtables of child (Key (Triggering unit)) in hash_point
 

Attachments

  • Swimming Pool TD.w3x
    5.5 MB · Views: 61
Last edited:
Level 19
Joined
Apr 21, 2013
Messages
1,194
okay i did everything you said but it's still the same problem :S

i noticed that when the first arrow dies the second stays where it is any more ideas? :S

You could try using hashtable perhaps?

It isn't too hard to trigger after all:
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set hash_point = (Last created hashtable)
  • Cast
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Channel
    • Actions
      • Hashtable - Save Handle Of(Target point of ability being cast) as (Key (Triggering unit)) of 0 in hash_point
  • Finish Cast
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Channel
    • Actions
      • Set temp_point = (Load (Key (Triggering unit)) of 0 in hash_point)
      • Unit - Move (Triggering unit) instantly to temp_point
  • Stop Cast
    • Events
      • Unit - A unit Stops casting an ability
    • Conditions
      • (Ability being cast) Equal to Channel
    • Actions
      • Set temp_point = (Load (Key (Triggering unit)) of 0 in hash_point)
      • Custom script: call RemoveLocation (udg_temp_point)
      • Hashtable - Clear all child hashtables of child (Key (Triggering unit)) in hash_point

this is nice but i should solve my problem i'm stuck in it and it makes me mad why it isnt working everything seems fine :vw_sad:

EDIT: OKAy okay it's WORKING :D I've forgot to enable an action now it's working thank all of you for helping me out :D I added the damage group and a tree cutter peasant now it's fully working with effects and sounds too thank you all :D

Added map if anyone wants to test :D
 

Attachments

  • spell2MUI.w3x
    24.8 KB · Views: 64
Last edited:
Status
Not open for further replies.
Top