detecting units in range

Ticer

New Member
Reaction score
2
I've been working on this trigger for awhile and have been able to come up with some so-so solutions that really don't create the results I'm looking for. :banghead: Anyways, I am trying to make a trigger so for a unit that is moving along a set path and when it comes in range of enemy units, it stops, waits until they are dead, then moves again to a set location.

Events
Time - Every 1.00 seconds of game time
Conditions
Actions
Unit Group - Pick every unit in (Units in (Playable map area) matching (((Owner of (Matching unit)) Equal to Player 4 (Purple)) and (((Matching unit) is A structure) Equal to False))) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) is in (Units within 800.00 of (Position of Wagon 0007 <gen>))) Equal to True
Then - Actions
Unit - Order Wagon 0007 <gen> to Stop
Else - Actions
Unit - Order Wagon 0007 <gen> to Move To (Center of Region 017 <gen>)

The wagon doesn't move at all, no matter whether the condition is true or false and I need help on what to do at this point or even if my trigger is completely off base.
 

Weegee

Go Weegee!
Reaction score
102
cant you change it so its an integer variable for the if then else statement and you can check if they are matching your conditions?
 

vypur85

Hibernate
Reaction score
803
Something like this?:

Code:
Test
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        Set SomeGroup = (Units within 800.00 of (Position of ([B]YourUnit[/B])) matching (((Owner of (Matching unit)) Equal to Player 4 (Purple)) and ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is alive) Equal to True))))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in SomeGroup) Greater than 0
            Then - Actions
                ...stop
            Else - Actions
                ...move
 

istar

New Member
Reaction score
31
get mpqmaster and extract the tft human campaign secret mission and copy the map, easy
you could use a unit in range event instead
you could scan units around the wagon instead

i think unit in range event works better
 

vypur85

Hibernate
Reaction score
803
> use a unit in range event instead

I think it's not such a good idea though. Because the event only fires when a unit enters the range. Which orders the wagon to 'stop'. What about 'move'? Periodic wouldn't hurt much.


Edit:
> Periodic wouldn't hurt much.

Unless someone start mentioning the 'L' word again... :p
 

lbebusiness

New Member
Reaction score
3
I have a trigger "system" where if any enemy players can see you, you will get a text stating " playernamehere can see you" then when no enemy players can see you, you get a text "your safe".
Its to late for you to use it thought. (could modify it to what you wanted).

It leaks in three different spots right now. Forgive me.

It IS a periodic though.
Right now it wont spawn the warning text EVERY time the enemy can see you if your already in ANY enemy players sight. (prevents lots of player x can see you spam) And ONLY says your safe when ALL enemy players can not see you. (also prevents alot of spam)

Funny enough this code went through SO MUCH **** just to put in the conditions so it wouldn't spam. lol.

I think I could take out the periodic and replace it with the ranged event. Save everyone some lag.
I'll post it for the sake of variety:
JASS:
Icanseeyou
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        Player Group - Pick every player in (All players) and do (Actions)
            Loop - Actions
                Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                Who_can_see_me[(Player number of (Picked player))] Equal to No unit
                                ((Picked unit) is visible to (Picked player)) Equal to True
                                ((Picked unit) belongs to an enemy of (Picked player)) Equal to True
                            Then - Actions
                                Set Who_can_see_me[(Player number of (Picked player))] = (Picked unit)
                                Game - Display to (Player group((Picked player))) the text: ((Name of (Owner of (Picked unit))) +  can see you...)
                            Else - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Who_can_see_me[(Player number of (Picked player))] Not equal to No unit
                                    Then - Actions
                                        Wait until ((Who_can_see_me[(Player number of (Picked player))] is visible to (Picked player)) Equal to False), checking every 1.00 seconds
                                        Game - Display to (Player group((Picked player))) the text: Your safe
                                        Set Who_can_see_me[(Player number of (Picked player))] = No unit
                                    Else - Actions
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top