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

Timers and hashtables

Status
Not open for further replies.
Level 7
Joined
Jul 4, 2007
Messages
249
Hi, I've been struggling with making a simple (single target) taunt spell and now I've got something that is working but I don't think this is an optimal solution. Does anyone else have any better suggestion to how I could do this?

  • Illi Taunt start
    • Events
    • Conditions
    • Actions
      • Set target = (Target unit of ability being cast)
      • Unit - Order target to Right-Click Lord of the Seven 0141 <gen>
      • Special Effect - Create a special effect attached to the overhead of target using Abilities\Spells\Undead\Possession\PossessionCaster.mdl
      • Hashtable - Save 100 as 0 of (Key (Target unit of ability being cast)) in Illi_tauntHash
      • Hashtable - Save Handle Of(Last created special effect) as 1 of (Key (Target unit of ability being cast)) in Illi_tauntHash
      • Unit Group - Add target to Illi_tauntGrp
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Illi Taunt periodic <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Illi Taunt periodic <gen>
        • Else - Actions
  • Illi Taunt periodic
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Illi_tauntGrp) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in Illi_tauntGrp and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is alive) Equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Load 0 of (Key (Picked unit)) from Illi_tauntHash) Greater than 0
                    • Then - Actions
                      • Hashtable - Save ((Load 0 of (Key (Picked unit)) from Illi_tauntHash) - 1) as 0 of (Key (Picked unit)) in Illi_tauntHash
                    • Else - Actions
                      • Set tempLoc = (Position of (Picked unit))
                      • Unit - Order (Picked unit) to Right-Click tempLoc
                      • Special Effect - Destroy (Load 1 of (Key (Picked unit)) in Illi_tauntHash)
                      • Custom script: call RemoveLocation(udg_tempLoc)
                      • Unit Group - Remove (Picked unit) from Illi_tauntGrp
                      • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Illi_tauntHash
                • Else - Actions
                  • Special Effect - Destroy (Load 1 of (Key (Picked unit)) in Illi_tauntHash)
                  • Unit Group - Remove (Picked unit) from Illi_tauntGrp
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Illi_tauntHash
        • Else - Actions
          • Trigger - Turn off (This trigger)
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,562
I don't think there's really much you can do that would make a noticeable difference in performance, this looks about as good as it gets. That being said, I am curious as to why you order the unit to Right-Click tempLoc instead of ordering the taunted unit to Attack the taunt source. I'm not sure if you did that intentionally but you could get rid of a Point variable if you stored the Taunt Source in the Hashtable and ordered the Taunted unit to Attack it.

Another thing to note is that if the Taunt Source dies the Taunted Unit will remain taunted for the remaining duration and potentially attack a new unit that wanders near the corpse.
 
Level 7
Joined
Jul 4, 2007
Messages
249
I don't think there's really much you can do that would make a noticeable difference in performance, this looks about as good as it gets.
Alright thanks for your answer.
That being said, I am curious as to why you order the unit to Right-Click tempLoc instead of ordering the taunted unit to Attack the taunt source.
  • Unit - Order target to Right-Click Lord of the Seven 0141 <gen>
This is when the target is ordered to attack taunting unit, the periodic trigger is just a timer for when to stop attacking, and that's why it is ordered to right click tempLoc (which is the position of the unit itself). I tried ordering Stop before but it didn't work for some reason. Stop would actually be a whole lot better because it looks kinda weird sometimes with right click, making the unit turn around.

I changed it to "attack-move to" now and it works nicely, so thanks for bringing that up :D
 
Level 7
Joined
Jul 4, 2007
Messages
249
Ah, I completely misread it... Forget what I said, lol.

And maybe try this when you order the unit to Stop:
Pause Unit
Order Unit to Stop
Unpause Unit

That's the method to interrupt orders.
Oh, cool, thanks!

Ordering a unit to do something every 0.03 seconds might cause them to be unable to perform the action as they repeatedly interrupt themselves.
It is not, it's just a timer. It orders once when timer is expired
 
Status
Not open for further replies.
Top