| 07-03-2005, 07:51 AM | #1 |
In a map that I'm making, I'm going to have many power generators. When a unit dies in a region centered around one of these power generators I want to change the custom value of that generator. I've been trying to figure out how to do this with just a few triggers, but haven't had any luck with it yet. Could you help me out? Thanks. |
| 07-03-2005, 08:44 AM | #2 |
Guest | If you wanted to, you could assign all the generators to a unit array variable. Then, when u want to check if the dying unit is near a generator you'd have to check all the values, but I think it'd work. Make one of these triggers for every generator in your map. It would be REALLY inefficient but It would work. Sorry this is all i can think of at the moment.. It's late... Code:
Event
Unit - A unit dies.
Condition
Real Condition -> Distance between (Position of dying unit and Position of Generators[1]) less than or equal to 500
Actions
Unit - Set custom value of Generators[1] to <whatever> |
| 07-03-2005, 11:29 AM | #3 |
Ummm... surely you can do better than that? Just make one trigger and use a if-then-else action inside a loop to check all the generators stored in the array, or, just use a "pick every unit in unit group" loop, so you don't even need to have the generators in an array. Something like this: Code:
Events:
A unit dies.
Conditions:
Actions:
Set tempGroup = Units of type (Power generator)
Set tempPoint1 = position of (dying unit)
Pick every unit in tempGroup and do actions
loop - actions:
set tempPoint2 = position of (picked unit)
If (distance between tempPoint1 and tempPoint2 is less than 500) then set the custom value of (picked unit) to (custom value of (picked unit)) + 1 else do nothing
custom script: call RemoveLocation( udg_tempPoint2 )
custom script: call RemoveLocation( udg_tempPoint1 )
custom script: call DestroyGroup( udg_tempGroup ) [i]//just cleaning out the memory leaks with this[/i] |
| 07-04-2005, 10:20 AM | #4 |
Anitarf, that trigger looks like it should work really well. I'll try it out. Thanks. |
