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 havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Dismiss Notice
  5. The Highway to Hell has been laid open. Come along and participate in the 5th Special Effect Contest.
    Dismiss Notice
  6. 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.

Hi help me check my trigger , I wan unit every unit that life lower than 500 then mov

Discussion in 'Triggers & Scripts' started by o2bryan, Jan 27, 2012.

  1. o2bryan

    o2bryan

    Joined:
    Mar 9, 2009
    Messages:
    173
    Resources:
    0
    Resources:
    0
    Hi my problem is , I wan every unit that life lower than 500 then move backward but my triggers seem VERY BIG PROBLEM please help me =__=:grin:


    • Unit Life Fall Back
      • Events
        • Time - Every 0.01 seconds of game time
      • Conditions
      • Actions
        • Unit Group - Pick every unit in (Units in (Entire map)) and do (Actions)
          • Loop - Actions
            • Trigger - Add to Unit Fall back <gen> the event (Unit - (Picked unit)'s life becomes Less than 500.00)


    Next
    • Unit Fall back
      • Events
      • Conditions
      • Actions
        • Unit - Order (Picked unit) to Move To ((Position of (Picked unit)) offset by 256.00 towards 10.00 degrees)


    Lets solve my problem together ^^:grin::grin:
     
  2. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    What is the problem exactly?

    Right now I see you order the unit to move, but you order him to move towards 10.00 degrees which is pretty much due East, regardless of where the unit is facing. It is possible for you to get the unit's facing (search through the GUI, it's a real value) and by subtracting 180.0 from that you can get the angle that is in the opposite direction the unit is facing.
     
  3. o2bryan

    o2bryan

    Joined:
    Mar 9, 2009
    Messages:
    173
    Resources:
    0
    Resources:
    0
    but this trigger cause hang and lag >.<
     
  4. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    Probably because every 0.01 seconds you're enumerating every single unit in the entire map. If you've got enough units on your map that is going to cause terrible lag.

    Oh, actually, there are a number of things wrong here. First of all, you should not be registering the same event to the unit twice, because then it will execute the actions twice (even on only one instance of the event occurring). Since you do this every 0.01 seconds, you're going to be generating 99 unnecessary actions in only one second, for one unit (in addition to enumerating all units 100 times a second).

    Instead of enumerating all units every 0.01 seconds, allocate the work to different triggers. Have one trigger that adds all existing units on the map (same way you are doing now) to the event that the unit's life goes below a certain amount. Then have a trigger that detects when units enter the map, and add them to the event when that happens. This takes care of units that existed on map initialization, and units that may be added to the map afterwards.

    You'll still have to fix your issue with adding the events to units multiple times, though in this case it won't matter. If you had an action that was additive (such as subtracting X amount of life) then you would definitely notice this.