• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

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

Status
Not open for further replies.
Level 6
Joined
Mar 9, 2009
Messages
175
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:
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
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.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
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.
 
Status
Not open for further replies.
Top