1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Ride into the sunset with the 32nd Modeling Contest. The contest is optionally paired. Best of luck, people!
    Dismiss Notice
  4. This adventure has come to an end. Congratulate our heroes in the 16th Mini Mapping Contest Results.
    Dismiss Notice
  5. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  6. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Distance Between Points

Discussion in 'Triggers & Scripts' started by Lee_Go, Feb 21, 2010.

  1. Lee_Go

    Lee_Go

    Joined:
    May 1, 2009
    Messages:
    156
    Resources:
    0
    Resources:
    0
    Hi, I'm trying to make it so when my character comes in 500 range of any of the neutral passive animals in the Forest region the animals basically run to a random point in the forest region.
    • Spook
      • Events
        • Time - Every 0.20 seconds of game time
      • Conditions
        • (Distance between (Position of Villager (Male 2) 0011 <gen>) and (Position of (Picked unit))) Less than or equal to 500.00
      • Actions
        • Unit Group - Pick every unit in (Units owned by Neutral Passive) and do (Actions)
          • Loop - Actions
            • Unit - Order (Picked unit) to Move To (Random point in (Playable map area))


    The Unit group action is just me messin around with it but I dont know how to have it so any units in that 500 range will do the action of moving to random point in the Forest Region (Playable Map area is wrong)
     
  2. overload119

    overload119

    Joined:
    May 28, 2007
    Messages:
    362
    Resources:
    3
    Skins:
    1
    Tools:
    1
    Maps:
    1
    Resources:
    3
    Yeah, that's a bad way to do it.

    I'm not sure the best way to do it, but here is a suggestion.

    Pick every unit in (Units Owned By Neatural Passive) and do...
    Event - Register Event (unit comes within 500 range of picked unit) for the trigger (ANOTHER TRIGGER)

    Then in ANOTHER TRIGGER
    Action - Issue Point Order( thetriggerunit(), randomarea )

    Really rough, hope you get it.
     
  3. Pharaoh_

    Pharaoh_

    Joined:
    Nov 6, 2008
    Messages:
    8,128
    Resources:
    11
    Icons:
    3
    Skins:
    1
    Spells:
    6
    Tutorials:
    1
    Resources:
    11
    • Trigger
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Set Points[1] = (Position of (Villager (Male 2) 0011 <gen>)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (your forest region) matching ((Owner of (Matching unit)) Equal to Neutral Passive) and do (Actions)
        • Loop - Actions
          • Set Points[2] = (Position of (Picked unit))
          • If (All conditions are true) then do (Actions) else do (Actions)
            • If - Conditions
              • (Distance between Points[1] and Points[2]) Less than or Equal to 500.00
            • Then - Actions
              • Set Points[3] = (Random point in (your forest region))
              • Unit - Order (Picked unit) to Move To (Points[3])
              • Custom script: call RemoveLocation (udg_Points[3])
            • Else - Actions
          • Custom script: call RemoveLocation (udg_Points[2])
      • Custom script: call RemoveLocation (udg_Points[1])


    Picked unit cannot be used in the main condition, since you do not do any pick of units. Try the one I gave you.
    References:
    [•] http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/variables-5896/

    I wouldn't do the trigger this way, but I just edited your trigger, so that it actually works.
     
  4. Lee_Go

    Lee_Go

    Joined:
    May 1, 2009
    Messages:
    156
    Resources:
    0
    Resources:
    0
    THaNk yOu both...

    And the picked unit thing was just me clicking around because i had no idea how to do it.

    Thank you again