HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Allied Units controlled by abilities

02-23-2008, 10:54 PM#1
refl3ction
okay,
for a single player map im currently working on,
i want to have units supporting/following the Hero, but are not owned by the player.
these helper units are owned by a computer controlled player
but listen to orders through abilities that the main hero has on start-up

i dont fully understand JASS to utilize it

i have 5 triggers devoted to the 'Hero followers'
Trigger:
Check for Units
Collapse Events
Time - Every 2.00 seconds of game time
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Hero_Followers_TF Equal to True
Collapse Then - Actions
Trigger - Turn on On Me <gen>
Trigger - Turn on Attack <gen>
Trigger - Turn on Defend <gen>
Trigger - Turn on Follow <gen>
Collapse Else - Actions
Trigger - Turn off On Me <gen>
Trigger - Turn off Attack <gen>
Trigger - Turn off Defend <gen>
Trigger - Turn off Follow <gen>
Hero_followers_TF is a boolean variable, that is set to true if units have been added to the unit group Hero_Followers.
Units can only be added to the group variable when the hero takes a quest where units are put under his control.
this trigger is ment to turn on/off the following triggers if the hero has no supporting units.
Trigger:
Collapse Follow
Collapse Events
Time - Every 5.00 seconds of game time
Collapse Conditions
Hero_Followers_TF Equal to True
Collapse Actions
Collapse Unit Group - Pick every unit in Hero_Followers and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Current order of (Picked unit)) Equal to (Order(stop))
Collapse Then - Actions
Unit - Order (Picked unit) to Follow TheHero
Collapse
Else - Actions
problems here: when units have stopped, after 5 seconds, they do not follow TheHero
Trigger:
On Me
Collapse Events
Unit - A unit owned by Player 1 (Red) Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to "On Me!" (Command)
Collapse Actions
Collapse Unit Group - Pick every unit in Hero_Followers and do (Actions)
Collapse Loop - Actions
Unit - Order (Picked unit) to Follow TheHero
the problem here is that if the Hero uses the 'Defensive Positions' ability, the units in Hero_Followers will move to the position, then stop. requiring the player to use the 'On Me!' ability
Trigger:
Attack
Collapse Events
Unit - A unit owned by Player 1 (Red) Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to "Attack!" (Command)
Collapse Actions
Collapse Unit Group - Pick every unit in Hero_Followers and do (Actions)
Collapse Loop - Actions
Unit - Order (Picked unit) to Attack (Target unit of ability being cast)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Target unit of ability being cast) is dead) Equal to True
Collapse Then - Actions
Collapse Unit Group - Pick every unit in Hero_Followers and do (Actions)
Collapse Loop - Actions
Unit - Order (Picked unit) to Stop
Else - Actions
the problem with this trigger is that when the target unit is killed, the units in Hero_Followers will move back to their locations when the map started, before they were added to the group
Trigger:
Defend
Collapse Events
Unit - A unit owned by Player 1 (Red) Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to "Defensive Positions!" (Neutral Hostile 1)
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Defend_yes Equal to False
Collapse Then - Actions
Collapse Unit Group - Pick every unit in Hero_Followers and do (Actions)
Collapse Loop - Actions
Unit - Order (Picked unit) to Human Footman - Defend
Set Defend_yes = True
Collapse Else - Actions
Collapse Unit Group - Pick every unit in Hero_Followers and do (Actions)
Collapse Loop - Actions
Unit - Order (Picked unit) to Human Footman - Stop Defend
Set Defend_yes = False
This trigger performs perfectly, units in Hero_Followers activate and deactivate Defend as they should. just that the problem occurs that ive stated above with the On Me trigger.

any help is appreciated, thanks
02-24-2008, 09:27 AM#2
tamisrah
To the problem that your units won't follow after the 5secs: I had a simliar problem and I think I solved it by replacing the
Trigger:
If - Conditions
(Current order of (Picked unit)) Equal to (Order(stop))
with this
Trigger:
And - All (Conditions) are true
Collapse Conditions
(Current order of (Picked unit)) Unequal to (Order(smart))
(Current order of (Picked unit)) Unequal to (Order(patrol))
(Current order of (Picked unit)) Unequal to (Order(hold))
(Current order of (Picked unit)) Unequal to (Order(null))

Referring to your other problems I'd say as a temporary solve you could just order them to follow the hero after each of your triggers.
02-24-2008, 03:49 PM#3
refl3ction
im about to try that out,
if it works
thanks a bunch :]