Hi all,
I'm trying to make an Autocast function to an ability based on Rejuvenation, the standard AI do use the ability but they use it too late so it doesn't really work as intended.
My idea is that I'd start the autocast on when the unit with the spell attacks, pick a unit group of valid targets, then use if applicable. For whatever reason my trigger only seems to work when there is only 1 unit in the group, or if the unit picked is the caster. Otherwise the caster just stands there until it or the target die, any ideas why this is happening?
I've put the trigger below - I can't find the "trigger" tab so I've put it in a "code" one instead
I'm trying to make an Autocast function to an ability based on Rejuvenation, the standard AI do use the ability but they use it too late so it doesn't really work as intended.
My idea is that I'd start the autocast on when the unit with the spell attacks, pick a unit group of valid targets, then use if applicable. For whatever reason my trigger only seems to work when there is only 1 unit in the group, or if the unit picked is the caster. Otherwise the caster just stands there until it or the target die, any ideas why this is happening?
I've put the trigger below - I can't find the "trigger" tab so I've put it in a "code" one instead
Code:
Enlighten Autocast
Events
Unit - A unit Is attacked
Conditions
(Level of Enlighten for (Attacking unit)) Equal to 1
Actions
Set TempUnit = (Attacking unit)
Set TempPoint = (Position of TempUnit)
Set TempUnitGroup = (Units within 500.00 of TempPoint matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is Mechanical) Equal to False) and ((((Matching unit) belongs to an ally of (Owner of TempUnit)) Equal to True) and (((Matching unit) is alive))
Unit Group - Pick every unit in TempUnitGroup and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Percentage life of (Picked unit)) Greater than or equal to 80.00
((Max life of (Picked unit)) - (Life of (Picked unit))) Less than or equal to 200.00
Then - Actions
Unit Group - Remove (Picked unit) from TempUnitGroup
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in TempUnitGroup) Greater than or equal to 1
Then - Actions
Game - Display to (All players) the text: (String((Number of units in TempUnitGroup)))
Set TargetUnit = (Random unit from TempUnitGroup)
Game - Display to (All players) the text: (Name of TargetUnit)
Unit - Order TempUnit to Night Elf Druid Of The Claw - Rejuvenation TargetUnit
Else - Actions
Custom script: call RemoveLocation(udg_TempPoint)
Custom script: call DestroyGroup(udg_TempUnitGroup)