HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Detect Attacked and attacking

04-12-2006, 07:01 AM#1
Nevan
Hi peoples
Its possible to detect when a unit is under attack and is in attack?
If yes can give some examples plz?
tnx in advance
04-12-2006, 09:22 AM#2
Blade.dk
Hello, and welcome to Wc3Campaigns! :)

I am not totally sure about what you mean, maybe you could elaborate a bit?
04-12-2006, 10:00 AM#3
Nevan
tnx man
i try to make a stealthfrom rogue
i want to make a trigger type this:

if "unit" is combat have "example ability"
if isnt in combat have " second example ability"
04-12-2006, 01:42 PM#4
Tim.
You mean somthing like this?

If unit is being attacked then give it ability 1
If unit is not being attacked give it ability 2
04-12-2006, 03:43 PM#5
Nevan
Yes and if is possibile, if he attack give it ability 2
04-12-2006, 04:12 PM#6
Tim.
You'll need loops for that, Blade can explain better.
04-12-2006, 07:42 PM#7
Blade.dk
The easiest thing would just be to save the old life in a variable in the start of the loop, and then check a while later if the life has increased or decreased. If it has decreased, the unit is most likely under attack and you can add the ability.
04-12-2006, 08:02 PM#8
Nevan
oky can you give 1 example trigger plz? (for not go in wrong mode :P)
tnx for your help peoples
04-12-2006, 08:28 PM#9
Immoralis
the var at the begin and check at the end doesnt work if the animation damage step is different for each unit that is attacking so you would want to set it all the same or below a certain number you can check after
04-13-2006, 01:19 PM#10
Nevan
(Sorry for noob trigger)

but what is wrong?

Trigger:
Stealth
Collapse Events
Time - Every 0.10 seconds of game time
Unit - A unit Is attacked
Collapse Conditions
(Unit-type of (Attacked unit)) Equal to Rogue Orc
Collapse Actions
Set Rogue_healt[(Player number of (Owner of (Attacked unit)))] = (Life of (Attacked unit))
Wait 0.50 seconds
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Collapse Or - Any (Conditions) are true
Collapse Conditions
(Level of Stealth for (Attacked unit)) Equal to 1
(Level of Stealth for (Attacked unit)) Equal to 2
(Level of Stealth for (Attacked unit)) Equal to 3
(Life of (Attacked unit)) Less than Rogue_healt[(Player number of (Owner of (Attacked unit)))]
Collapse Then - Actions
Set StealthLvL[(Player number of (Owner of (Attacked unit)))] = (Level of Stealth for (Attacked unit))
Unit - Remove Stealth from (Attacked unit)
Unit - Add Stealth Cant Go to (Attacked unit)
Collapse Else - Actions
Do nothing

Trigger:
Stealth 2
Collapse Events
Time - Every 1.00 seconds of game time
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Life of Rogue Orc 0002 <gen>) Greater than or equal to Rogue_healt[(Player number of (Owner of Rogue Orc 0002 <gen>))]
Collapse Then - Actions
Unit - Remove Stealth Cant Go from Rogue Orc 0002 <gen>
Hero - Learn skill for Rogue Orc 0002 <gen>: Stealth
Unit - Set level of Stealth for Rogue Orc 0002 <gen> to StealthLvL[(Player number of (Owner of Rogue Orc 0002 <gen>))]
Collapse Else - Actions
Do nothing
04-13-2006, 04:34 PM#11
ixmike88
You have it run the code every .10 seconds (which could possibly lead to lag), and as far as I know, the events work as an "or" statement meaning: Every .10 seconds -or- If a unit is attacked, try removing the periodic event, because that has no values which could lead to further map errors.