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

Need Some Trigger Help

Status
Not open for further replies.
Level 8
Joined
Sep 2, 2012
Messages
308
Hi Guys :goblin_yeah:

I Want To Know The Triggers of These :

When Map Loaded In Case Of Hero Been Level 1 Changes To Level 10 .?
How To Improve More Than Level 10 .?
I Want To Know When A Hero or A Unit Dies .Drop Item From That Hero Or Unit.?

And When Map Loaded I Want A Hero Have Items In His Inventory .
And My Last Question . How To Improve My Spell Triggering :ogre_hurrhurr:

Thanks Anyone Who Anwser Me . If Anyone Knows All Of Them Send Me Private Message In My Profile . Thanks :ogre_love:
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • Untitled Trigger 081
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Hero - Drop the item from slot (Integer A) of (Triggering unit)
Advanced - Gameplay constants -> Hero Maximum Level
 
Level 7
Joined
May 11, 2010
Messages
278
  • Set Hero Level
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • -------- First, we pick all units on the map --------
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • -------- Now, if the picked unit is a hero... --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A Hero) Equal to True
            • Then - Actions
              • -------- ...we set his level to 10. --------
              • Hero - Set (Picked unit) Hero-level to 10, Hide level-up graphics
            • Else - Actions
But, this trigger leaks a Unit Group.
We fix that by adding a unit group variable.

  • Set Hero Level
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • -------- First, we set the unitGroup variable to all units in the map --------
      • Set unitGroup = (Units in (Playable map area))
      • -------- next, we pick all units in unitGroup --------
      • Unit Group - Pick every unit in unitGroup and do (Actions)
        • Loop - Actions
          • -------- Now, if the picked unit is a hero... --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A Hero) Equal to True
            • Then - Actions
              • -------- ...we set his level to 10. --------
              • Hero - Set (Picked unit) Hero-level to 10, Hide level-up graphics
            • Else - Actions
      • -------- And we finish by removing the unit group as it's not needed anymore. --------
      • Custom script: call DestroyGroup(udg_unitGroup)
Basically, if you have a lot of leaks in your map, it will start to lag after a while.

(though, the set unitGroup function might leak a region? I'm not sure about that)
 
Setting variables don't create leaks, I think. Instead of putting up a unit group variable, use "set bj_wantDestroyGroup = true" before picking the units.

To improve your triggering, view any spells in the spells section or tutorials.

To have items in hero's inventory, select the hero and click the Inventory tab in the dialog box that will appear. Then add items.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
If you only do a simple Unit Group pick, just add set bj_wantDestroyGroup = true above Unit Group function, you don't need any Unit Group for that.

By default, that boolean is set to false, meaning that the Unit Group never got destroyed - this will leak.
That is why we change the boolean to true, so that the Unit Group is destroyed right after it ends the loop
 
Status
Not open for further replies.
Top