• 🏆 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!

Autocasting Rejuvenation

Status
Not open for further replies.
Level 13
Joined
Oct 16, 2010
Messages
731
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

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)
 
Level 39
Joined
Feb 27, 2007
Messages
4,992
The tags are literally just [trigger][/trigger]. Probably don’t use the Unit is Attacked event, because it fires when an attack is initiated, not when it connects. A damage detection system that can detect attacks is going to be much more reliable.

What do you mean by “works”? How much of the trigger runs? Are you certain there is a valid target in range? It will only find a target that has < 80% hp and has taken more than 200 damage. You may also want to store the caster’s previous order before casting so it goes back to whatever it was doing beforehand.
 
Level 13
Joined
Oct 16, 2010
Messages
731
Ahh, I will note that tag for future reference

I've got debug text in the trigger that tell me how many units are in the group and what unit it picks as the target, if this unit is not the caster then the caster doesn't actually use the spell but instead just stands there doing nothing. In regards to the DDS idea, I don't need it to try casting the spell when damage is dealt, having the attacked option is just so I can detect the unit is in combat rather than doing a periodic check or something similar.

But back to the trigger, if it picks someone other than the caster the caster will stand there until the target dies, or the caster dies. The trigger does not fire afterwards as the caster doesn't attack or anything
 
Status
Not open for further replies.
Top