In my map, units fight on a grid, and use dummy abilities to move. However it used to be that you could only move one unit at a time, which was slow, and looked rather stupid. I changed it to do all units selected by the player, and that worked, kind of. There were random bugs, like units getting more mana, or not moving, or units that weren't selected moving, etc. Here's my trigger.
The units currently selected by triggering player seems to be causing all kinda of problems, including making random bugs without a pattern I can see. Some units will move but not have any mana subtracted, some unselected units will move and lose all their mana.
Is there a better way to do this?
-
Move North
-
Events
- Unit - A unit Begins casting an ability
-
Conditions
- (Ability being cast) Equal to Move North waterelemental
-
Actions
- Set TEMP_UGROUP = (Units currently selected by (Triggering player))
-
Unit Group - Pick every unit in TEMP_UGROUP and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked unit) is A structure) Equal to False
-
Or - Any (Conditions) are true
-
Conditions
- (Mana of (Picked unit)) Greater than or equal to 1.00
- (Picked unit) Equal to (Casting unit)
-
Conditions
-
Then - Actions
- Set TEMP_POINT = (Position of (Picked unit))
- Set TEMP_POINT = (TEMP_POINT offset by (0.00, 128.00))
- Set TEMP_UGROUP2 = (Units within 50.00 of TEMP_POINT)
- Set TEMP_INT = (Number of units in TEMP_UGROUP2)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- TEMP_INT Equal to 0
-
Then - Actions
- Unit - Pause (Picked unit)
- If ((Picked unit) Not equal to (Casting unit)) then do (Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - 1.00)) else do (Do nothing)
- Unit - Make (Picked unit) face TEMP_POINT over 0.00 seconds
- Animation - Play (Picked unit)'s walk animation
- Unit - Set the custom value of (Picked unit) to 0
- Unit Group - Add (Picked unit) to MOVE_GROUP_NORTH
-
Else - Actions
- Unit - Set mana of (Picked unit) to ((Mana of (Casting unit)) + 1.00)
- Set TEMP_POINT = (Position of (Picked unit))
- Floating Text - Create floating text that reads Cannot move there. at TEMP_POINT with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
-
If - Conditions
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
- Game - Enable selection and deselection functionality (Enable selection circles)
-
Events
The units currently selected by triggering player seems to be causing all kinda of problems, including making random bugs without a pattern I can see. Some units will move but not have any mana subtracted, some unselected units will move and lose all their mana.
Is there a better way to do this?