HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Somewhat sticky trigger problem

01-08-2003, 07:45 PM#1
Guest
Hi all,

I've got a map with the Felwood tileset which has areas of poison (the terrain). I would like to have it so that when a unit is standing on the poison, they take damage every two seconds.

The thing is, to keep the map looking pretty the poison areas are odd shapes, so each one uses several regions to define the area.

I have tried:
Events : Time - Every 2 seconds
Conditions : (Region 000 <gen> contains [triggering unit]) Equal to True
(Region 001 ...
...
Actions : Unit - Set life of [triggering unit] to (life of [triggering unit] - 2)

Unfortunately, of course, no unit ever triggers this event. Further, I cannot replace the 'triggering unit' occurances with 'any unit' (couldn't find it)... besides I don't think the rule written this way will lower the health of more than one unit.

If there is a way I can get a trigger like this to work I'd love to know! Failing that, I have to try the following:

Maybe something like these (pseudo-code):
(1)
Events : Unit enters region group
Actions : Set some-array[max-index] = [triggering unit]

(2)
Events : Unit leaves region group
Actions : Somehow find [triggering unit] in array and splice it

(3)
Events : Every 2 seconds
and then somehow remove 2 health from each unit in the array

I basically need help doing this. I need to know, at the very least;

1 How do I write a trigger whose event is "Unit enters a region group", as opposed to just unit enters a region?

2 How do I do its compliment (unit leaves a region group)?

c How do I do the action in (2)? For each integer A from 0 to (what -- I have no idea how to reference the index of my array)?

quatro How do I iterate through the array and deduct their health


Thanks for your time!
01-08-2003, 09:29 PM#2
SuperIKI
Easy:
Every 2 secs is a cool event. Take it.
Condition: NONE!!!
Action:
Loop through every unit in poison1 and do (damage it)
[Pick every unit in (units in poison1)]
The damaging should be done by using the life of "Picked unit".
Use this for all your poison regions. You can also use a poison region array. Depends on how many poison regions you have.

Note: If a unit stands in 2 regions at the same time, somewhat on the borderline between two regions, it will take twice the damage. To avoid this, you can make a unit group and clear it at the beginning of the trigger. Before damaging the unit, check if it's in the unit group. If not: Deal the damage and add it to the unit group.
This avoids double damaging.
01-08-2003, 09:39 PM#3
Guest
Quote:
Originally posted by SuperIKI
Easy:
Every 2 secs is a cool event. Take it.
Condition: NONE!!!
Action:
Loop through every unit in poison1 and do (damage it)
[Pick every unit in (units in poison1)]
The damaging should be done by using the life of "Picked unit".
Use this for all your poison regions. You can also use a poison region array. Depends on how many poison regions you have.

Note: If a unit stands in 2 regions at the same time, somewhat on the borderline between two regions, it will take twice the damage. To avoid this, you can make a unit group and clear it at the beginning of the trigger. Before damaging the unit, check if it's in the unit group. If not: Deal the damage and add it to the unit group.
This avoids double damaging.


Yep, exactly! I also answered hte question at http://www.wc3campaigns.com/forums/s...&threadid=7140 then I came here and relized osmeone already got it, but oh well.
01-08-2003, 09:52 PM#4
dataangel
I'm not sure what SuperIKI means by "loop through." Just unit group every unit in the region every two seconds and lower their health.
01-08-2003, 10:07 PM#5
Guest
Once again:

Zoom (requires log in)
01-08-2003, 10:18 PM#6
SuperIKI
@dataangel: With "Loop through all units" I mean: "Pick every unit and do".

@random157: You may damage units twice every 3 seconds when they stand in two regions at a time.

Solution:
Don't set the life of the units directly. Instead add them to a unit group called "Poor units that will be damaged".
Then as a last action pick every unit from that unit group and damage them.