HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Trigger Help

04-15-2011, 03:30 AM#1
Blindman
Hello everyone. I would like to ask some help related with triggers. I'm trying to make a trigger which does this: When the dialog button Attack is clicked the unit will attack the enemy unit. The attack basically goes like this: Move to target, wait until the target reaches the point, stop, attack, wait .5 seconds, stop, go back then face forward. Here are the triggers:

Hidden information:
Trigger:
Button Click Attack Target
Collapse Events
Dialog - A dialog button is clicked for AttackDialog
Conditions
Collapse Actions
Set ForestWarpLoc[1] = (Center of Unit1Forest <gen>)
Set ForestWarpLoc[2] = (Center of Unit2Forest <gen>)
Set ForestWarpLoc[3] = (Center of Unit3Forest <gen>)
Set ForestWarpLoc[4] = (Center of Unit4Forest <gen>)
Set ForestWarpLoc[5] = (Center of Unit5Forest <gen>)
Set ForestWarpLoc[6] = (Center of BossForest <gen>)
Set ForestWarpLoc[7] = (Center of ForestSpawn <gen>)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to DialogButton[1]
Collapse Then - Actions
Set DistanceAttack = (Distance between ForestWarpLoc[7] and ForestWarpLoc[1])
Unit - Order Mountain King 0009 <gen> to Move To ForestWarpLoc[1]
Wait until (DistanceAttack Less than or equal to 100.00), checking every 1.00 seconds
Unit - Order Mountain King 0009 <gen> to Stop
Unit - Order Mountain King 0009 <gen> to Attack BattleTarget[1]
Wait 0.50 seconds
Unit - Order Mountain King 0009 <gen> to Stop
Unit - Order Mountain King 0009 <gen> to Move To ForestWarpLoc[7]
Unit - Make Mountain King 0009 <gen> face ForestWarpLoc[6] over 0.00 seconds
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to DialogButton[2]
Collapse Then - Actions
Set DistanceAttack = (Distance between ForestWarpLoc[7] and ForestWarpLoc[2])
Unit - Order Mountain King 0009 <gen> to Move To ForestWarpLoc[2]
Wait until (DistanceAttack Less than or equal to 100.00), checking every 1.00 seconds
Unit - Order Mountain King 0009 <gen> to Stop
Unit - Order Mountain King 0009 <gen> to Attack BattleTarget[2]
Wait 0.50 seconds
Unit - Order Mountain King 0009 <gen> to Stop
Unit - Order Mountain King 0009 <gen> to Move To ForestWarpLoc[7]
Unit - Make Mountain King 0009 <gen> face ForestWarpLoc[6] over 0.00 seconds
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to DialogButton[3]
Collapse Then - Actions
Set DistanceAttack = (Distance between ForestWarpLoc[7] and ForestWarpLoc[3])
Unit - Order Mountain King 0009 <gen> to Move To ForestWarpLoc[3]
Wait until (DistanceAttack Less than or equal to 100.00), checking every 1.00 seconds
Unit - Order Mountain King 0009 <gen> to Stop
Unit - Order Mountain King 0009 <gen> to Attack BattleTarget[3]
Wait 0.50 seconds
Unit - Order Mountain King 0009 <gen> to Stop
Unit - Order Mountain King 0009 <gen> to Move To ForestWarpLoc[7]
Unit - Make Mountain King 0009 <gen> face ForestWarpLoc[6] over 0.00 seconds
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to DialogButton[4]
Collapse Then - Actions
Set DistanceAttack = (Distance between ForestWarpLoc[7] and ForestWarpLoc[4])
Unit - Order Mountain King 0009 <gen> to Move To ForestWarpLoc[4]
Wait until (DistanceAttack Less than or equal to 100.00), checking every 1.00 seconds
Unit - Order Mountain King 0009 <gen> to Stop
Unit - Order Mountain King 0009 <gen> to Attack BattleTarget[4]
Wait 0.50 seconds
Unit - Order Mountain King 0009 <gen> to Stop
Unit - Order Mountain King 0009 <gen> to Move To ForestWarpLoc[7]
Unit - Make Mountain King 0009 <gen> face ForestWarpLoc[6] over 0.00 seconds
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to DialogButton[5]
Collapse Then - Actions
Set DistanceAttack = (Distance between ForestWarpLoc[7] and ForestWarpLoc[5])
Unit - Order Mountain King 0009 <gen> to Move To ForestWarpLoc[5]
Wait until (DistanceAttack Less than or equal to 100.00), checking every 1.00 seconds
Unit - Order Mountain King 0009 <gen> to Stop
Unit - Order Mountain King 0009 <gen> to Attack BattleTarget[5]
Wait 0.50 seconds
Unit - Order Mountain King 0009 <gen> to Stop
Unit - Order Mountain King 0009 <gen> to Move To ForestWarpLoc[7]
Unit - Make Mountain King 0009 <gen> face ForestWarpLoc[6] over 0.00 seconds
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to DialogButton[6]
Collapse Then - Actions
Set DistanceAttack = (Distance between ForestWarpLoc[7] and ForestWarpLoc[6])
Unit - Order Mountain King 0009 <gen> to Move To ForestWarpLoc[6]
Wait until (DistanceAttack Less than or equal to 100.00), checking every 1.00 seconds
Unit - Order Mountain King 0009 <gen> to Stop
Unit - Order Mountain King 0009 <gen> to Attack BattleTarget[6]
Wait 0.50 seconds
Unit - Order Mountain King 0009 <gen> to Stop
Unit - Order Mountain King 0009 <gen> to Move To ForestWarpLoc[7]
Unit - Make Mountain King 0009 <gen> face ForestWarpLoc[6] over 0.00 seconds
Else - Actions
Custom script: call RemoveLocation (udg_ForestWarpLoc[1])
Custom script: call RemoveLocation (udg_ForestWarpLoc[2])
Custom script: call RemoveLocation (udg_ForestWarpLoc[3])
Custom script: call RemoveLocation (udg_ForestWarpLoc[4])
Custom script: call RemoveLocation (udg_ForestWarpLoc[5])
Custom script: call RemoveLocation (udg_ForestWarpLoc[6])
Custom script: call RemoveLocation (udg_ForestWarpLoc[7])

Most of them are just the same. You could just look at the first If/Then/Else/. The BattleTarget[#] are just variables which store the enemy units in different triggers. Thanks in advance.
04-15-2011, 08:04 AM#2
Bribe
Trigger:
Set DistanceAttack = (Distance between ForestWarpLoc[7] and ForestWarpLoc[1])
Unit - Order Mountain King 0009 <gen> to Move To ForestWarpLoc[1]
Wait until (DistanceAttack Less than or equal to 100.00), checking every 1.00 seconds

It will basically keep waiting forever. DistanceAttack is only set once, unless some other unit is also ordered to attack (re-setting the variable and well that should key you in that it's not MUI nor MPI). You can use custom script to design your own loop that periodically resets DistanceAttack, but there are better ways. A periodic timer, combined with a decent indexing technique, can detect when the two units get within 100 distance of each other.
04-16-2011, 08:11 AM#3
Themerion
The trigger will become a lot easier to debug if you use a loop instead of a bunch of IF- THEN - ELSE.

(Integer A) is an integer value called "For Loop Integer A" in the list.

Trigger:
For each (Integer A) from 1 to 6, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to DialogButton[(Integer A)]
Collapse Then - Actions
Set Target = (Integer A)

Now you have Target set up as a number between 1 and 6; and you can use Target instead of 1,2,3,4...
  • DialogButton[Target]
  • ForestWarpLoc[Target]
  • BattleTarget[Target]

Thus, you don't need to repeat your trigger/code 6 times... (and it will become much more pleasant to work with / debug)

Trigger:
Unit - Order Mountain King 0009 <gen> to Move To ForestWarpLoc[Target]
Wait until ((Distance between ForestWarpLoc[7] and ForestWarpLoc[Target]) Less than or equal to 100.00), checking every 1.00 seconds
Unit - Order Mountain King 0009 <gen> to Stop
Unit - Order Mountain King 0009 <gen> to Attack BattleTarget[Target]
Wait 0.50 seconds
Unit - Order Mountain King 0009 <gen> to Stop
Unit - Order Mountain King 0009 <gen> to Move To ForestWarpLoc[7]
Unit - Make Mountain King 0009 <gen> face ForestWarpLoc[6] over 0.00 seconds

Notice how this is all the trigger code needed. No unecessary repetitions of trigger-actions.

Also notice what Bribe said. My example trigger doesn't use DistanceAttack as a variable at all, solving your problem. You might also need to set the limit value higher than 100; depending on attack range and collision size.
04-26-2011, 05:15 PM#4
[VDM]Amn

why do you even use that system to hit the unit ?
use the order "attack once"

goes like this:
Code:
1. order unit a to attack once unit b
2. wait (distance / 100) seconds // (if your unit moves fast, change 100 to 150 or more, you'll find the correct number)
3. order unit a to move point your_point_away

that's the idea, you solve the rest

c ya