• 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.

Looping Integer / Unit / Destructible help

Status
Not open for further replies.
Level 2
Joined
Nov 24, 2007
Messages
4
  • Events
    • Unit - A unit enters (region)
  • Conditions
    • ((Entering unit) is in (Units owned by Neutral Hostile)) Equal to True
  • Actions
    • For each (Integer A) from 1 to (Number of units in (Units in (region)), do (actions)
      • Loop - Actions
        • Destructible - Set life of (variable) to ((Current life of (variable) - 10.00)
        • Wait 0.50 seconds
I need to know if I need the Wait timer in there.

I also need to know if the loop will keep going with 1 OR no units unit in it. or if I need to enable another trigger somehow and disable it when units leave the region.

I need to know if there's a timer on loops like this already built into the mechanics of the regular up-to-date WE. I also am not sure if this will loop only 1 time, as in, ''per-unit''. I need it to loop the actions for each unit.

can anyone tell me if this is the right setup? (basically I want it to destroy a destructible doodad such as a gate, by reducing its health per second using this trigger, I made it up on my own but I'm not sure if its going to work properly or crash or has leaks.)

again: Here's what I want to happen, I want to destroy a destructible doodad by placing units into a region then having them reduce the DD's life without attacks enabled (using a trigger) and when it's dead move on to the despawn zone (or next region.) I'm just unsure of how to 'trigger' this.

~Mr.TD :confused:

EDIT:

Hehe, this is the WRONG way to do this. Read below for my revised form of killing destructible units using units in a region rather than simply attacking them (this is by slowly draining it's hp as well, not just 'kill' it.)
 
Last edited:
Level 11
Joined
Aug 25, 2006
Messages
971
First of all anytime you call something that uses/returns a unitgroup you want to be using a variable. This is so you can destroy the unit group when your done with it. The way you did it is weird, considering if you looked under unit group you'd see they already built you a loop for that. 'Time on loops'??? Use the interval event. Then just turn it on and off. Your trigger will add additional looping wait everytime a unit enters that location. I'm on vacation so I can't help you anymore then this. If you still have a problem when I'm home (in a few days) I'll help you then.
 
Level 2
Joined
Nov 24, 2007
Messages
4
  • Events
    • Map initialization
  • Conditions
  • Actions
    • Set Destructible Variable = Gate (Horizontal) 0001 <gen>
    • Set Point Variable = (Position of Gate (Horizontal) 0001 <gen>)
  • Events
    • Unit - A unit enters Checkpoint <gen>
  • Conditions
    • ((Entering unit) is in (Units owned by Neutral Hostile)) Equal to True
  • Actions
    • Set Real Variable = (Real((Number of units in (units in Checkpoint <gen> owned by Neutral Hostile))))
    • Trigger - Turn on Next Trigger <gen>
  • Events
    • Time - Every 2.00 seconds of game time
  • Conditions
    • (Number of units in (Units in Checkpoint <gen>)) greater than 0
  • Actions
    • Destructible - Set life of Destructible Variable to ((Current life of Destructible Variable) - (10.00 times Real Variable))
  • Events
    • Unit - A unit leaves Checkpoint <gen>
  • Conditions
    • ((Leaving unit) is in (Units owned by Neutral Hostile)) Equal to True
  • Actions
    • Set Real Variable = (Real((Number of units in (Units in Checkpoint <gen> owned by Neutral Hostile))))
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Number of units in (Units in Checkpoint <gen>)) Less than 1
      • Then - Actions
        • Trigger - Turn off Previous Trigger
      • Else - Actions
        • Do nothing
  • Events
    • Unit - A unit owned by Player 1 (Red) Finishes training a unit
  • Conditions
    • ((Trained unit) is in (Units of type New Gate)) Equal to True
  • Actions
    • If ((Destructible Variable is dead) Equal to True) then do (Destructible - Create a Gate (Horizontal) at (Point Variable offset by (0.00, 0.00)) facing 0.00 with scale 1.00 and variation 0) else do (Do nothing)
    • Set Destructible Variable = (Last created destructible)
    • Unit - Remove (Trained unit) from the game
I think this works all the kinks out, however I am sure there's a memory leak here somewhere. or several, anyone elaborate?

Also, 'Leaving unit' I wanted to ask if anyone knows for sure if this counts as units that die, then use another new trigger-->

  • Events
    • Unit - A unit owned by Neutral Hostile Dies
  • Conditions
  • Actions
    • Unit - Remove (Dying unit) from the game
However this will remove the death animations I'm sure unless I set variables for each unit as they spawn per wave per side, then remove them when they die.

also I'm not sure if the editor counts this as a 'leaving unit' for the triggers to disable the gate's destruction.

finally, the reason I did so many loopholes was to make sure units don't count in (say your builder) as it flies over the region when they're piling up at the gate. And so that the Real number is never 0 when it calculates damage. I know that 0 times anything = 0 but it might cause the game to crash, (it stopped crashing for me after I made a few changes and I think this was it.) so I also made it so leaving units re-set the variable's value, and so that it turns off if there are 0 units in the checkpoint region.

EDIT: Fixed the Triggers I did post, however still having a few issues regarding to units leaving a checkpoint. I need to make it so that they can die in it as well and it would still revert the real variable to 0 and turn off the ''gate'' 2 sec. timer

EDIT2: With these triggers setup this way (after I figure out the last issue regarding units leaving the checkpoint) You can easily set this up so that every few waves or each wave, increases the damage done per second to gates (you can do this with a variable array I think so it increases by 1 per wave, or do it manually every way, by simply taking out 10.00 times the Real variable, and making it an Integer variable x Real number variable and then having the Integer variable be = to a set amount each wave. (requires more coding than an array I would think.)

EDIT3: For some reason, when I tested these triggers using a sample map I made - the first neutral unit that enters the checkpoint region does NOT trigger the drain of the gate's energy... only everyone of them after that (even with the triggers setup to turn on and off).

I fixed the units leaving the area issue, simply make 2 versions of the same trigger, one for leaving units, one for dieing.
 
Last edited:
Status
Not open for further replies.
Top