| 01-15-2004, 12:08 AM | #1 |
Hi, how would i do this.. if unit comes within range of a unit2, change unit2 speed to 200, but when unit is out of range of unit2 change unit2 speed to 1. How do i do that? plz help a nob *noob |
| 01-15-2004, 09:12 PM | #2 |
Using triggers, If <unit1> enters range of <unit2> Then set speed of <unit2> to 200 Else set speed of <unit2> to 1 |
| 01-16-2004, 01:45 AM | #3 |
i cant find that range thing, in if/then/else ... :( |
| 01-16-2004, 03:44 PM | #4 |
Sorry, I was working from memory when I typed that up last night. Here is the actual trigger. Modify Unit Speed Code:
Events
Unit - A unit comes within 600 of <unit1>
Conditions
Actions
If ((Unit-type of (Triggering unit)) Equal to <unit2>) then do (Unit - <unit1> movement speed to 200.00) else do (Unit - <unit1> movement speed to 1.00)Just replace the 600 with the range you want, for example the <unit1>'s attack range, and replace <unit1> and <unit2> with the proper units. |
| 01-17-2004, 09:44 AM | #5 |
I am not sure this trigger would work properly.... because when unit2 come into range of unit1 then unit1 will get 200 speed but when unit2 will get out of range unit1 will still have 200 speed. even more... when unit2 come into range of unit1 and then another unit come into range of unit1 while unit2 is still in range the speed of unit1 will become 1 . conclusion your trigger doesn't work at all EnetheruAnuon . the only problem with what you want sov_marksman is that there is no unit become out of range trigger event. there is only trigger come into range. so what you need to do is use a periodic check that look if unit2 is still in range of unit1. *(unitenterrange) event: unit- a unit come within 600 of <unit1> condition: (Unit-type of (triggering unit)) Equal to <unit2> ) action: turn on <checkrange> trigger turn off this trigger. *(checkrange) event: every 2 sec of game time condition: action: Group unit- pick every units in (Units within 600 of (Unit1))) and do (if (Unit-type (of picked unit)) egal a unit2) then do (unit - set (unit1) movement speed to 200) else do run <notinrange> trigger. *(notinrange) event: condition: action: unit - set <unit1> movement speed to 1. turn off (checkrange) trigger. turn on (unit enterrange) trigger. the only problem with this trigger is that it need to work that <unit1> is a specific unit and not a unit type, so that it work only for one specified unit that is allready into game. (of course the default speed of unit1 is 1) if not at map initialisation or game elapsed time 2sec u need to put: *(set speed) event: game time elapsed 2 sec. condition: action: unit - set <unit1> movement speed to 1. destroy this trigger with this trigger you will need the unit1 not to die, because if it die the speed will return to default when raised. i hope i could help....if you want to work for non-specific unit tell me i can modify this trigger. |
| 01-17-2004, 03:37 PM | #6 | |
Quote:
You're right...oops. However, my trigger could be fixed like this: Events Unit - A unit comes within 600 of <unit1> Conditions (Triggering Unit) is <unit2> = true Actions If ((Unit-type of (Triggering unit)) Equal to <unit2> ) then do (Unit - <unit1> movement speed to 200.00) else do (Unit - <unit1> movement speed to 1.00) In that case, It would fire when unit 2 entered range, but If you set this up as well, Code:
Events
Unit - A unit comes within 600.00 of Footman 0000 <gen>
Conditions
(Unit-type of (Triggering unit)) Equal to No unit-type
Actions
Unit - Set Footman 0000 <gen> movement speed to (Default movement speed of (Triggering unit))it should trigger when no unit was nearby, and set the speed to the default. Otherwise, perhaps you could have a rect chase <unit1> and have triggers for units entering and leaving the rect. |
| 01-17-2004, 05:14 PM | #7 |
Well, there is a problem if the units aren't preplaced but thaen you'll just have to put them ina variable when they are created. |
| 01-17-2004, 05:19 PM | #8 |
I coulda sworn you couldn't use unit vars when selecting a 'unit comes within range' event. You would have to count units within 500 and have some kind of if/then/else statement that chose the unit type and compared it with (unit within range) |
| 01-17-2004, 05:42 PM | #9 |
Checking it right now, i haves used it so it isnät imposiible just dont remeber exactly... Yea thats right, i used a region that checked when centered on the unit, but that was for a turnbased map so i dint have to use a periodic time event. You could preplace a unit with 0 collision and make it follow the unit once it's created. Of course you would have to give it aloc, but im not condifent that you can detect if a unit comes with range of a unit with aloc, and since u cant use vars.... |
| 01-17-2004, 06:04 PM | #10 |
Wouldn't a modified Endurance Aura be a LOT easier then doing this with triggers? Just allow the modified aura to only effect units of type 1, so that when type 2 comes into range, the type 1 unit can suddenly move (change the move speed to something insane, like 2000%). |
| 01-17-2004, 07:32 PM | #11 |
Yep, thats probably the best solution of the problem. Unit comes within range is actually very limited since you cant use a variable to define what unit comes in range of which unit. Usually units isn't preplaced as long as it isn't a rpg or something like that. |
