• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

how do you make a unit auto cast spell?

Status
Not open for further replies.
Level 7
Joined
Dec 17, 2005
Messages
337
this is the trigger:

Chain Tower
Events
Unit - A unit Is attacked
Conditions
(Unit-type of (Attacking unit)) Equal to Lightning Tower
Actions
Unit - Order (Attacking unit) to Orc Far Seer - Chain Lightning (Attacked unit)

or something like this but for different spells you'll have to chain some things. :)
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Here is what I tried with the editor:

Make a custom tower by copy and pasting a guard tower. Make a custom ability by copy and pasting Chain lightning. Set the Chain Lightning property "Hero Ability" to false, "mana cost" to 0. To "targets allowed" you might want to add mechanical to be able to target demolishers for example. Change damage and cooldown to whatever you like. And maybe "levels" to 1 and remove the "tooltip text" level1 -part.

Then change the custom tower "attacks enabled" to none. Add to "normal abilities" the Chain Lightning you just made.

Then use these triggers:

============================
This trigger sets a target for the tower, when a unit becomes inside the towers range(700). If the tower already has a targe, it doesn't change it.

TowerShoot
Events
Unit - A unit comes within 700.00 of Guard Tower 0050 <gen>
Conditions
(Owner of (Triggering unit)) Not equal to Player 3 (Teal)
Actions
Unit Group - Add (Entering unit) to TowerTargets
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
Attacker Equal to No unit
(Attacker is dead) Equal to True
Then - Actions
Set Attacker = (Entering unit)
Else - Actions
Do nothing

====================================================
This trigger makes the tower to constantly shoot the target as long as it is alive or leaves the towers range. If the target leaves the range, the tower no longer tries to shoot it and acquires a new target, if inside range.

ShootUnits
Events
Time - Every 0.10 seconds of game time
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
Attacker Not equal to No unit
(Attacker is dead) Equal to True
And - All (Conditions) are true
Conditions
(Distance between (Position of Attacker) and (Position of Guard Tower 0050 <gen>)) Less than or equal to 700.00
(Attacker is dead) Equal to False
Then - Actions
Unit - Order Guard Tower 0050 <gen> to Orc Far Seer - Chain Lightning Attacker
Else - Actions
Unit Group - Remove Attacker from TowerTargets
Set Attacker = No unit
Set Attacker = (Random unit from TowerTargets)
Unit - Order Guard Tower 0050 <gen> to Orc Far Seer - Chain Lightning Attacker

======================================================

There might be some way you could optimize these triggers, but try it out =)
 
Status
Not open for further replies.
Top