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

[General] Trigger an animation

Status
Not open for further replies.

sentrywiz

S

sentrywiz

I want to trigger a specific animation for "crit, bash" effects.

I have a dds in place, so I have both the freedom of before attack and on dealing damage. I intend to use the "unit is attacked" event, since this happens when a unit comes into range and will just initiate an attack, but i don't know how exactly to do it.

Simple trigger examples would help. Also, different units have different "special" animations, so take that into account. ty
 
Level 10
Joined
Feb 22, 2008
Messages
619
Have you tried this?:
  • Actions
    • Animation - Play (Picked unit)'s attack animation
The field where I typed "attack" is for strings, so you can type the name of the animation you want.

To detect Critical hits and Bashes, you could try giving the abilities Buffs and using this condition to check if the attacked unit has the buff after being attacked:
  • Conditions
    • ((Picked unit) has buff Your_Buff) Equal to True
 

sentrywiz

S

sentrywiz

Have you tried this?:
  • Actions
    • Animation - Play (Picked unit)'s attack animation
The field where I typed "attack" is for strings, so you can type the name of the animation you want.

To detect Critical hits and Bashes, you could try giving the abilities Buffs and using this condition to check if the attacked unit has the buff after being attacked:
  • Conditions
    • ((Picked unit) has buff Your_Buff) Equal to True

I did, but it didn't work. Because the animation for the attack i want is something like "stand channel" or "attack 4" and none of them worked for me.
 
Level 14
Joined
Nov 17, 2010
Messages
1,265
There is a line of custom script for playing specific animations.

call SetUnitAnimationByIndex(udg_YourUnitVariable, NumberVariable)

YourUnitVariable = the variable your unit is set to that you want to play the animation
NumberVariable = the number of the animation you want to play.

The hard part is figuring out which number goes with the animation you want

Example: your hero's variable is HeroUnit and his attack 4 animation is number 6

call SetUnitAnimationByIndex(udg_HeroUnit, 6)
 

sentrywiz

S

sentrywiz

There is a line of custom script for playing specific animations.

call SetUnitAnimationByIndex(udg_YourUnitVariable, NumberVariable)

YourUnitVariable = the variable your unit is set to that you want to play the animation
NumberVariable = the number of the animation you want to play.

The hard part is figuring out which number goes with the animation you want

Example: your hero's variable is HeroUnit and his attack 4 animation is number 6

call SetUnitAnimationByIndex(udg_HeroUnit, 6)

This sounds good on paper, but can you show me an example?
Like lets say the attack animation is called "attack slam" that I want to cast
before the unit attacks. How do I do it? You don't need to show me events and conditions, just the actoins.
 
Level 14
Joined
Nov 17, 2010
Messages
1,265
You basically just use this in place of the default GUI action "animation - play unit animation"

Your best bet would be to test it out because some animations will loop and some will not so you may need to reset their animation after it plays. (I'm not sure if queue animation would work I'll need to do some testing)
 

sentrywiz

S

sentrywiz

Awesome, I got it to work. Took a little bit of modification with the dds and "finding out" the animation numbers.

Its a little clunky, and some of the animations have sort of "empty space" after they end and the unit stays that way a little longer than usual.
Also, it sometimes doesn't work - or maybe I made a mistake. But I think sometimes animations bug out and the unit doesn't do the animation

But it works in most cases!

+rep

EDIT: I opened another thread in order to see if I did the triggers right and if they can be improved. Please go there so that we don't clutter this forum with triggers
 
Last edited by a moderator:
Level 33
Joined
Mar 27, 2008
Messages
8,035
But do keep this in mind, SetUnitAnimationByIndex is a function that plays your unit animation speed according to normal speed animation of the unit has in the Model Editor.

Let's say its default animation speed is 1.34 seconds to complete a certain animation.
When you have an a Attack Speed that is higher than 1.34 seconds, let's say you can attack per 0.5 second, the speed won't be in sync and it would look weird.

I myself haven't tested this yet, but this is my theory, can someone test this to assure it but by logically, it should be the case.
 

sentrywiz

S

sentrywiz

But do keep this in mind, SetUnitAnimationByIndex is a function that plays your unit animation speed according to normal speed animation of the unit has in the Model Editor.

Let's say its default animation speed is 1.34 seconds to complete a certain animation.
When you have an a Attack Speed that is higher than 1.34 seconds, let's say you can attack per 0.5 second, the speed won't be in sync and it would look weird.

I myself haven't tested this yet, but this is my theory, can someone test this to assure it but by logically, it should be the case.

In my case its the opposite. some units have high attackspeed (when i have the items) and they still attack slower. but maybe its because i haven't optimised the art animations in the object data.

But back to your logic, I don't think it does. Because most animations I use for critical strike have 1.5 sec time and all units start with 2.1 - 1.9 attackspeed, depending on class spec and agility. In any case, by the time the bots and myself have the critical strike passive, its animations are faster than the unit's attackspeed.

Maybe i'm wrong. I'll definitely check it next time i open world editor
 
Status
Not open for further replies.
Top