• 🏆 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] Need help converting a spell in MUI

Status
Not open for further replies.
Level 1
Joined
Nov 17, 2016
Messages
4
I've read a few guides about making MUI spells using hashtables, index, array, etc. but it seems i just can't understand how this thing works. I kinda understood that I should store PoundCount in a hashtable to avoid conflicts between different units casting the same spell. Any help would be greatly appreciated.

  • Ground Pound Cast
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Ground Pound
    • Actions
      • Set Hero = (Triggering unit)
      • Trigger - Turn on Ground Pound Effect <gen>

  • Ground Pound Effect
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PoundCount Less than or equal to 3
        • Then - Actions
          • Set PoundCount = (PoundCount + 1)
          • Set Pound = (Units within 300.00 of (Position of Hero))
          • Special Effect - Create a special effect attached to the origin of Hero using Abilities\Spells\Human\Thunderclap\ThunderClapCaster.mdl
          • Camera - Shake the camera for (Owner of Hero) with magnitude 1.00
          • Animation - Play Hero's spell animation
          • Unit Group - Pick every unit in Pound and do (Actions)
            • Loop - Actions
              • If (((Picked unit) belongs to an enemy of (Owner of Hero)) Equal to True) then do (Unit - Cause Hero to damage (Picked unit), dealing 20.00 damage of attack type Spells and damage type Normal) else do (Do nothing)
        • Else - Actions
          • Trigger - Turn off (This trigger)
          • Camera - Stop swaying/shaking the camera for (Owner of Hero)
          • Set PoundCount = 0
          • Custom script: call DestroyGroup (udg_Pound)
 
Level 10
Joined
Oct 5, 2008
Messages
355
Well, the point is that you use a hashtable to save variables you would otherwise need to add into globals. They work, simplified speaking, like 2D arrays. You got a parent table, which is in most triggered spells the Unit ID. The child tables are the section under the parent. This helps clearing the variables quite simple.
Another point is that you don't need to iterate through a array to find the one of a special unit. You can just use the Id and get to the point to work on.
For this, you must stop using globals to store single heros for example. You can use unit groups to place all your casters into.

On the other hand, you leak groups, locations and spell effects. I have rewritten the triggers to make it MUI and to remove the leaks (If i found all while looking at it), I commended most changes so you could try to see what i did:


  • Ground Pound Cast
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Ground Pound
    • Actions
      • Unitgroup - Add (Triggering unit) to Poundcasters
      • -------- // Instead of setting your variable to the unit, you just throw it into a unit group. It should handle it from then on// --------
      • Trigger - Turn on Ground Pound Effect <gen>

  • Ground Pound Effect
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unitgroup - Pick every unit in Poundcasters and do (Actions)
        • Loop - Actions
          • Set Pounder = (Picked unit)
          • Custom script: set udg_PoundInteger = GetHandleId(udg_Pounder)
          • -------- // Here you get the Id of the unit, this is becomming the child of this unit within the hashtable// --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load 1 of (Key (Picked unit)) from Poundhashtable Less than or equal 3
              • -------- // this is your poundercounter// --------
            • Then - Actions
              • Hashtabelle - Save ((Load 1 of PoundInteger from Poundhashtable) + 1) as 1 of PoundInteger in Poundhashtable
              • -------- // its like: Save (Variable) as (Array within Child) of (Child) in (Parent Hashtable)// --------
              • Set PoundLocation = (Position of Pounder)
              • Set Pound = (Units within 300.00 of PoundLocation)
              • Custom script: call RemoveLocation(udg_Poundlocation)
              • -------- // (Units within 300.00 of (Position of Hero)) Leaks a Location (Position of Hero), so you need to remove it after use// --------
              • Special Effect - Create a special effect attached to the origin of Hero using Abilities\Spells\Human\Thunderclap\ThunderClapCaster.mdl
              • Special Effect - Destroy (Last created special effect)
              • -------- // You were leaking a Special effect here. They always needs to be destroyed// --------
              • Camera - Shake the camera for (Owner of Pounder) with magnitude 1.00
              • -------- // this gets quite akward if multiple units of the same player use Pound, but i suppose you want to keep it// --------
              • Animation - Play Pounders's spell animation
              • Unit Group - Pick every unit in Pound and do (Actions)
                • Loop - Actions
                  • If (((Picked unit) belongs to an enemy of (Owner of Pounder)) Equal to True) then do (Unit - Cause Pounder to damage (Picked unit), dealing 20.00 damage of attack type Spells and damage type Normal) else do (Do nothing)
                • -------- // You always need to destroy the unit group, because (Units within 300.00 of PoundLocation) always creates a new unit group // --------
              • Custom script: call DestroyGroup (udg_Pound)
            • Else - Actions
              • Unitgroup - Remove Pounder from Poundgroup
              • -------- // We added the unit, we need to remove it// --------
              • If - Conditions
                • (Number of units in Poundcaster) Equals 0
                • -------- // now we check if other units are pounding before we turn off the trigger ^^// --------
              • Then - Actions
                • Trigger - Turn off (This trigger)
              • Camera - Stop swaying/shaking the camera for (Owner of Pounder)
              • -------- // this now gets akward, because if two units of the same hero cast this, the spell could stop shaking the camera, this would require some workaround if you want to keep it// --------
              • Hashtabelle - Clear all child hashtables of child PoundInteger in Poundhashtable
              • -------- // instead of setting a variable to 0, we can now clear the whole child. Well, for this spell its kinda pointless, you could use one line of code and set it to zero, but if you want to expand it with max duration, damage per second values and so on, then go for it.// --------
Edit: Not the whole trigger was in "trigger" tags. Changed that
Edit 2: Clarified some comments
 
Level 1
Joined
Nov 17, 2016
Messages
4
Sorry, but this isn't working as intended. Is any of the variables you made an array?

Edit: just to be more clear. The first unit that uses the spell starts it and never stops, while the second one doesn't even start it. This leads me to believe that maybe there's something wrong in the way the trigger counts PoundInteger...
 
Last edited:
Level 10
Joined
Oct 5, 2008
Messages
355
I just have quickly triggered it and for me its working fine. I could tell you what the prioblem is when i could see how you made it. Also i made a trigger which stops the ability when the unit stops channeling the skill (dont know actually if it is a channeled ability, it surely looked like one).
 

Attachments

  • Pound Testing.w3x
    19.4 KB · Views: 28
Level 1
Joined
Nov 17, 2016
Messages
4
I don't know what I've done wrong, but your version works perfectly. I just needed to change begins casting an ability with begins channeling an ability. Thank you very much.
 
Status
Not open for further replies.
Top