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!
You are using an out of date browser. It may not display this or other websites correctly. You should upgrade or use an alternative browser.
Triggers
Attack Detection 1.0.w3x
Variables
Attack Detection
README!
Detection Add
AD Initialization
Attack
Cancel
Detection
Enter map-specific custom script code below. This text will be included in the map script after variables are declared and before any trigger code.
Name
Type
is_array
initial_value
ADHashtables
hashtable
Yes
AttackedGroup
group
No
AttackersNumber
integer
No
AttackingGroup
group
No
Handle
handle
No
HDUnit
unit
No
The triggers needed are below. This trigger isn't needed but marks the folder.
How do I import this system?
1. Highlight the "Attack Detection" folder
2. Press Control(Ctrl) + C or right-click it and press copy
3. Go to your map and press Control(Ctrl) + V when in the trigger editor or you can paste it with right-click and pressing paste
Credits
If you wish to give me credit, you can do so. You dont have to give me credit for my works, but its nice and provides me with some reputation.
To find more awsome resources like spells and models, visit one of the following 2 sites
www.hiveworkshop.com <--- This site was also known as WC Search in the past. It provides resources that are fine and work. The community is pretty great as well that consists of much personality
www.wc3c.net <--- This site's full name is Warcraft 3 Campaigns.net. It provides top notch resources that are the best of the best. The community isn't as big as the hive's but have some really cool people and most are great resource creators
You need this for the detection trigger to initiate.
Detection Add
Events
Unit - A unit enters (Entire map)
Conditions
Actions
-------- This trigger is for adding other units to the detection trigger later on. Like the 4 main triggers, it is also needed --------
Trigger - Add to Detection <gen> the event ((Entering unit) Takes damage)
The starting trigger. You need this.
AD Initialization
Events
Map initialization
Conditions
Actions
-------- These are the starting point of the hashtables. They are created here --------
For each (Integer A) from 1 to 2 , do (Actions)
Loop - Actions
Hashtable - Create a hashtable
Set Variable Set ADHashtables[(Integer A)] = (Last created hashtable)
-------- This detects units and adds them to the detection trigger --------
Unit Group - Pick every unit in (Units in (Entire map)) and do (Actions)
Loop - Actions
Trigger - Add to Detection <gen> the event ((Picked unit) Takes damage)
The attacked trigger. You also need this as it detects when a unit is attacked.
Attack
Events
Unit - A unit Is attacked
Conditions
Actions
-------- These triggers are for detecting the attack --------
Set Variable Set AttackersNumber = (Load 2 of (Key (Attacked unit).) from ADHashtables[2].)
Unit Group - Add (Attacked unit) to AttackedGroup
Unit Group - Add (Attacking unit) to AttackingGroup
-------- These are where the hashtables record the amount of attackers and the attacker --------
Hashtable - Save Handle Of (Attacked unit) as 1 of (Key (Attacking unit).) in ADHashtables[1] .
Hashtable - Save Handle Of (Attacking unit) as 1 of (Key (Attacked unit).) in ADHashtables[2] .
Hashtable - Save (AttackersNumber + 1) as 2 of (Key (Attacked unit).) in ADHashtables[2] .
This is a fail-safe trigger that tells if a unit stops attacking.
Cancel
Events
Unit - A unit Begins casting an ability
Unit - A unit Dies
Unit - A unit Is issued an order with no target
Unit - A unit Is issued an order targeting a point
Unit - A unit Is issued an order targeting an object
Conditions
((Triggering unit) is in AttackingGroup.) Equal to True
Actions
-------- Here, we remove the attacker from the group if the attack is cancelled --------
Set Variable Set Handle = (Load 1 of (Key (Triggering unit).) in ADHashtables[1].)
Set Variable Set AttackersNumber = (Load 2 of (Key Handle.) from ADHashtables[2].)
Unit Group - Remove (Triggering unit) from AttackingGroup .
Hashtable - Clear all child hashtables of child (Key (Triggering unit).) in ADHashtables[1] .
-------- This tells whether the unit is still being attacked by other units or not. It will not move untill all attackers are gone --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
AttackersNumber Greater than 1
Then - Actions
Hashtable - Save (AttackersNumber - 1) as 2 of (Key Handle.) in ADHashtables[2] .
Else - Actions
Hashtable - Clear all child hashtables of child (Key Handle.) in ADHashtables[1] .
Detection
Events
Conditions
((Triggering unit) is in AttackedGroup.) Equal to True
Actions
-------- You may say "WTF NO EVENTS??!!" like a noob. The events are created at the Initialization trigger --------
Set Variable Set HDUnit = (Load 1 of (Key (Triggering unit).) in ADHashtables[2].)
Set Variable Set Handle = (Load 1 of (Key (Triggering unit).) in ADHashtables[2].)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Damage source) Equal to HDUnit
Then - Actions
Set Variable Set AttackersNumber = (Load 2 of (Key (Triggering unit).) from ADHashtables[2].)
Hashtable - Save (AttackersNumber - 1) as 2 of (Key (Triggering unit).) in ADHashtables[2] .
Unit Group - Remove HDUnit from AttackingGroup .
Hashtable - Clear all child hashtables of child (Key Handle.) in ADHashtables[1] .
-------- This is where you may insert your actions. The floating text acts as an example --------
Floating Text - Create floating text that reads Hit! above (Triggering unit) with Z offset 50.00 , using font size 10 , color ( 100 %, 0.00 %, 0.00 %), and 0 % transparency
Floating Text - Change (Last created floating text) : Disable permanence
Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
Floating Text - Change the fading age of (Last created floating text) to 0.50 seconds
-------- Below determines if the unit is still being attacked and can clear it out if not --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
AttackersNumber Less than or equal to 0
Then - Actions
Unit Group - Remove (Triggering unit) from AttackedGroup .
Hashtable - Clear all child hashtables of child (Key (Triggering unit).) in ADHashtables[2] .
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.