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

Trigger shuts off

Status
Not open for further replies.
Level 8
Joined
Apr 30, 2009
Messages
338
I get all the fucking hashtables for spells usually 100% right the first try and now my simple -ms for movespeed trigger is bugging. It works for awhile but it seems like after using it a few times it stops working.

It is supposed to show the current movespeed, then the current movespeed's percentage of 261. Yeah I know it says 260 so that my boots with +26 and +39 say 110% / 115%.

  • Movespeed
    • Events
      • Player - Player 1 (Red) types a chat message containing -ms as An exact match
      • Player - Player 2 (Blue) types a chat message containing -ms as An exact match
      • Player - Player 3 (Teal) types a chat message containing -ms as An exact match
      • Player - Player 4 (Purple) types a chat message containing -ms as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -ms as An exact match
      • Player - Player 6 (Orange) types a chat message containing -ms as An exact match
      • Player - Player 7 (Green) types a chat message containing -ms as An exact match
      • Player - Player 8 (Pink) types a chat message containing -ms as An exact match
      • Player - Player 9 (Gray) types a chat message containing -ms as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -ms as An exact match
    • Conditions
    • Actions
      • Unit Group - Add all units of (Units currently selected by (Triggering player)) to temp_group
      • For each (Integer A) from 1 to (Number of units in temp_group), do (Actions)
        • Loop - Actions
          • Set temp_unit = (Random unit from temp_group)
          • Game - Display to (All players matching ((Matching player) Equal to (Triggering player))) the text: (Movespeed of + ((Name of temp_unit) + (: + ((String((Integer((Current movement speed of temp_unit))))) + (, ( + ((String((Integer(((100.00 x (Current movement speed of temp_unit)) / 260.00))))) + %)))))))
          • Unit Group - Remove temp_unit from temp_group
          • Custom script: set udg_temp_unit = null
 
Level 15
Joined
Dec 18, 2007
Messages
1,098
I can't really tell what's bugging, but the things I think you should change are:
Units currently selected by (Triggering player) is a unit group. This leaks.
In the first place, it would be easier to just set temp_group to Units currently selected by (Triggering player) and then use a Unit Group loop to do the stuff.

In general, I doubt that your trigger bugs though. It may not be this trigger though. I suspect that you may have used one of the following in another trigger:
  • Custom script: call DestroyGroup(udg_temp_group)
Or
  • Custom script: set bj_wantDestroyGroup = true
The thing is, you need temp_group to refer to an empty unit group for your trigger to work properly. If you wish to skip on checking the other triggers in your map, my suggestion above should work just fine. Setting a variable to a group assures that your variable actually refers to a unit group and not just nothing.

I hope this helped!
 
Level 8
Joined
Apr 30, 2009
Messages
338
Thanks for the leak advice. Does my problem have anything to do with having more than 1 trigger at map initialization?

PS: So I should only destroy the group once all the units are removed?

Does destroying the group make it unusable for later or does it just set it to being empty?
 
Level 15
Joined
Dec 18, 2007
Messages
1,098
It makes the group unusable unless you set the variable to something like:
Units within 500 range of location.

Or something. In the case of the above, a new group is created with the appropriate units inside. When you set the variable to this group, its actually a newly created group.

Therefore, it doesn't matter when you destroy the group, but if you were to use your method (adding units into the group and then doing the actions), I would suggest that you do not destroy the group. Otherwise, you won't have a group to store the information in.

Its fine if you want to use your method, just remember to add
  • Custom script: set udg_temp_group = CreateGroup()
You would have to destroy the group first before you use this script, or it may leak.

Explanation to Unit Groups:
Let's use an analogy: A unit group is a notepad.
When you add a unit to the group, you write down text in your notepad.
When you remove a unit from the group, you erase the text.
When you destroy a unit group, you burn your notepad.
When you apply actions to a unit group, you actually apply them to each unit in your notepad. So if you already burned your notepad, you can't use it.
When you use a variable to refer to a unit group, you search for the correct notepad you put your stuff in. So if you already burned the notepad, you won't have anything to search for.

That's the idea. Just add the lines at the start of your trigger:
  • Custom script: call DestroyGroup(udg_temp_group)
  • Custom script: set udg_temp_group = CreateGroup()
I hope this helps!

PS: Map init doesn't really have much to do with it, but I would suggest that you merge it if possible :D
 
Level 8
Joined
Apr 30, 2009
Messages
338
How about this:

  • Movespeed
    • Events
      • Player - Player 1 (Red) types a chat message containing -ms as An exact match
      • Player - Player 2 (Blue) types a chat message containing -ms as An exact match
      • Player - Player 3 (Teal) types a chat message containing -ms as An exact match
      • Player - Player 4 (Purple) types a chat message containing -ms as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -ms as An exact match
      • Player - Player 6 (Orange) types a chat message containing -ms as An exact match
      • Player - Player 7 (Green) types a chat message containing -ms as An exact match
      • Player - Player 8 (Pink) types a chat message containing -ms as An exact match
      • Player - Player 9 (Gray) types a chat message containing -ms as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -ms as An exact match
    • Conditions
    • Actions
      • Set temp_group_Copy = (Units currently selected by (Triggering player))
      • Unit Group - Pick every unit in temp_group_Copy and do (Actions)
        • Loop - Actions
          • Game - Display to (All players matching ((Matching player) Equal to (Triggering player))) the text: (Movespeed of + ((Name of (Picked unit)) + (: + ((String((Integer((Current movement speed of (Picked unit)))))) + (, ( + ((String((Integer(((100.00 x (Current movement speed of (Picked unit))) / 260.00))))) + %)))))))
          • Unit Group - Remove (Picked unit) from temp_group_Copy
      • Custom script: call DestroyGroup(udg_temp_group_Copy)
I don't know why I used "add unit" in the first trigger.

I still don't really understand destroying groups so let me say how I think it works and you tell me if I'm right:

set bj_wantDestroyGroup = true
Immediately destroys the group referenced in the next line as soon as the next line executes

call DestroyGroup(udg_temp_group)
Destroys the handle of the units assigned to temp_group, but allows the variable temp_group to be used later for other things
 
Level 15
Joined
Dec 18, 2007
Messages
1,098
set bj_wantDestroyGroup = true
Immediately destroys the group referenced in the next line as soon as the next line executes

call DestroyGroup(udg_temp_group)
Destroys the handle of the units assigned to temp_group, but allows the variable temp_group to be used later for other things
Yep. The variable is never destroyed, but the referenced group is.
In both cases, it is necessary to set the variable to a group in order for the trigger to work. Otherwise, you'll be refering to an empty group.
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
Why you remove the unit from the group and then destroy the group?
Destroying only the group will do the job, so all units inside it are removed.

Also, when making the group make it with matching unit == hero, b/c this will get realy messy if the specified player is currently seceleted more than 1 unit.

Also you can do this:
  • Game - Display to (Player group((Triggering player))) for 5.00 seconds the text: <Text>
Instead of putting (Matching Player)

Also, destroying the group with "set bj_wantDestroyGroup = true" and "Custom script: call DestroyGroup(udg_temp_group_Copy)" is the same thng and group is always available to use...
Just for the bj you don't need a group veriable, so for the second you need it.
 
Status
Not open for further replies.
Top