• 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!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Attack2 animation (Reforged)

Attack 2 or Attack Two?

1730746707222.png

Only the selected animation is shown for some reason (ranged).
Attack 2 is not shown when Unit does Attack 2 - melee
 
Last edited:

Remixer

Map Reviewer
Level 33
Joined
Feb 19, 2011
Messages
2,112
Sure. Attached is a test map with a Troll Headhunter that alternates between standard and alternate animations depending on whether he is targeting Peon or not.
Here's the trigger (also included in the test map).
  • Attack Animation Alteration
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Unit-type of (Ordered unit)) Equal to Headhunter
      • (Issued order) Equal to (Order(attack))
    • Actions
      • Game - Display to (All players) the text: Trigger
      • Trigger - Turn off (This trigger)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Target unit of issued order)) Equal to Peon
        • Then - Actions
          • Animation - Add the alternate animation tag to (Ordered unit)
          • Wait until ((Current order of (Ordered unit)) Not equal to (Order(attack))), checking every 0.10 seconds
          • Animation - Remove the alternate animation tag to (Ordered unit)
        • Else - Actions
          • Animation - Remove the alternate animation tag to (Ordered unit)
      • Trigger - Turn on (This trigger)
Edit:
Also note that this is scrambled in just a few minutes so it is not the polished or fine-tuned example, but shows the logic that you can use. Using the animation tag adding and removing it when the conditions are no longer met (I just simply used a conditional wait).
 

Attachments

  • AlternateAttackExample.w3m
    17.3 KB · Views: 4
call AddUnitAnimationProperties(whichUnit, animProperties, add)
you use this function.

call AddUnitAnimationProperties(myUnit, "alternate", true)

what it does? i dont rly understand.
Play animation one time?

or it will understand according to event fired that this is attack. and if it is an attack it should play another attack variation?

and what false flag means?

call AddUnitAnimationProperties(myUnit, "alternate", false)
 
Code:
function PlayAttackAnimation takes nothing returns nothing
    local unit attacker = GetTriggerUnit()
   
    if GetUnitTypeId(attacker) == 'earc' then
        //call SetUnitAnimationByIndex(attacker, 1)
        call AddUnitAnimationProperties(attacker, "alternate", true)
        //call SetUnitAnimation(attacker, "rdy")
        //call QueueUnitAnimation(attacker, "Stand Ready Melee")
    endif
endfunction


function InitAttackEvent takes nothing returns nothing
    local trigger trig = CreateTrigger()
    local integer i = 0
   
    loop
        exitwhen i >= bj_MAX_PLAYERS
        call TriggerRegisterPlayerUnitEvent(trig, Player(i), EVENT_PLAYER_UNIT_ATTACKED, null)
        set i = i + 1
    endloop
   
    call TriggerAddAction(trig, function PlayAttackAnimation)
endfunction
 

Remixer

Map Reviewer
Level 33
Joined
Feb 19, 2011
Messages
2,112
JASS:
call AddUnitAnimationProperties(whichUnit, animProperties, add)
The meaning of this native is better explained in the graphical interpretation triggers, where it is is called Add Animation Tag.
In Warcraft 3 unit actions are associated with animations and sometimes with additional tags to differentiate two similar animations. Good example is the Human Scout Tower. When you build a Scout Tower you'll get a Scout Tower that is constantly playing its "stand" animation. When you upgrade the tower into a Guard Tower the model of the tower does not actually change but the Guard Tower instead plays the animation "Stand Upgrade First", where the "Upgade" and "First" are additional animation tags to imply that the stand animation it should play is the First Updated one.

Other examples of animation tags include wording such as "swim" - most Naga units have all animations in without the "Swim" tag, and those animations they play while on ground, while the game automatically tries to use any animation with the addition of the tag "Swim" whenever a unit enters deep water.

So, back to the original question:
JASS:
call AddUnitAnimationProperties(whichUnit, animProperties, add)
Attaches an animation tag to a unit until the said tag is removed. The true value adds it, the false value removes it. animProperties dictate which tag you wish to add ("Swim", "Alternate", "Upgrade", "First", "Gold", "Lumber"... the list goes on).

While the unit has said animation tag attached, it tries to play all animations with that said animation tag included. For example, if you would add "Swim" animation to a Naga Myrmidon, it will play the swim animation, even if it is on land. However, not all models have all animations covered by animation tags, meaning that if you for example add "Swim" tag to a Peasant, it will do nothing, as Peasant doesn't have animations for "Swim" tag. Thus, if a unit does not have animations associated with a tag, it will simply play the regular animation (without the tag) for said animations.
 

Remixer

Map Reviewer
Level 33
Joined
Feb 19, 2011
Messages
2,112
But how it understands that this is the attack animation that will be switched to alternate and not other animation?
It doesn't. Like I said earlier, the game will display the normal animation if there is no defined alternative. Meaning, you can use a model with only the attack animation having the specified tag (let's say "alternate"), so then the unit only uses the tag upon attack animations, as it doesn't have any other animation with the tag "alternate".
 

Remixer

Map Reviewer
Level 33
Joined
Feb 19, 2011
Messages
2,112
will it loop show attack animation indefinetly until i stop it?
It will play whichever animation the game tells it - as usual. The only difference is that the animation will include the tag "alternate" if it has one. The game has its internal logic on which animations to play when: The game plays the Death animation when a unit dies, it plays the "Walk" animation when a unit is ordered to move, and so forth.
or how it understand that it needs to change attack animation and not idle animation?
It changes all animations, but if your model only has the alternate -tag for attack animations, it will only affect attack animations. Note that in the example I provided I also remove the tag whenever the unit is not attacking a Peon, so you can also make a custom logic for it and remove/add the tag whenever you want.
 
Top