• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Control unit's attack animation

Status
Not open for further replies.
Level 2
Joined
Feb 17, 2017
Messages
26
Hello everyone,

So I've recently downloaded the Summer Tank Pack of General Franck (awesome work btw, if you are interested, check him out : Summer Tank Pack 2019 )

One of his awesome tank models features a tank with 2 canons that I want to integrate to my map. The tank features 2 attack animations (one when the left canon shoot, and the other for the right canon). Problem is, since the attack anitmations come randomly, the canons fire randomly as well (for example first the left canon shoots twice and the right one only once, then the left one shoots three times etc...).

My question is, how can I tweak it with triggers so that the animations loop in such a way that the tank's canons fire one after the other? In other words how can I control what animation will pop up during the attack? I couldn't find a way to figure this out myself.

Thanks in advance for your help.

PS : please be aware I didn't use the warcraft editor for a few years, I still need to refigure everything out, so if you can suppose that I'm an idiot for explanation it would actually be helpful for me.
 
Level 4
Joined
Sep 2, 2016
Messages
48
Make a dummy ability with 2 levels and give it to the unit. Best an iconless item-based one (so you don't have to hide it in a spellbook).
Make a trigger running on an attack.
If level of the ability for the attacking unit equals 1 - play animation "attack 1", set level of ability to 2.
If 2 - play animation "attack 2", set level of ability to 1.
 
Level 2
Joined
Feb 17, 2017
Messages
26
I think I see it. So the trigger should look something like this :

Event : "A unit attacks"

Condition : "Unit equal to [the one I want to tweak the animation]"

Action : "Order unit to use dummy ability on attacked target"
"If Level is = 1, then change it to 2, if level is = 2, change it to one"

And the dummy ability is set so that one level triggers one animation, and the other level triggers the other.

But isn't there a problem? Since the unit is attacking a target, won't the unit trigger its random attack animation BEFORE it executes the order to use the dummy ability? In my logic it appears that the unit will first accomplish a random attack animation before doing the one we want.

But if it does work like you think it should, I don't think a dummy ability will be enough (not certain though, I might be mistaken). The thing is, cast animation is the same for all levels of that dummy ability, shouldn't I use instead 2 dummy abilities combined with an integer that loops between 1 and 2?

PS : I don't intend to play know-it-all, I'm just asking because it somehow doesn't seem right to me. Perhaps I'm overcomplicating things.
PPS : I couldn't find any Event based on a unit attacking, so I think I might have misunderstood your idea. What should I do instead?
 
Last edited:
Level 4
Joined
Sep 2, 2016
Messages
48
I see communication problem. You interpret things that I didn't write.
Do exactly as I said. Step by step. Don't add things I didnt say.
For example "cast animation". I didn't say anything about "casting". The unit doesn't have to cast the dummy ability. It's just a marker.
1. Make a dummy ability with 2 levels.
Use Claws of Attack +damage ability as a base ability. Set it's bonus to 0(obviously). Set its levels to 2.
2. give it to the unit
Open the unit in editor, scroll down to abilities. Add the dummy ability.
3. Make a trigger running on an attack.
Event : "A unit IS ATTACKED" //<- Not "attacks"
Condition : "Unit TYPE of Attacking Unit equals to [the one you want to tweak the animation]"
Action :
If Level of Dummy Ability for Attacking Unit equals 1 then
Set Level of Dummy Ability for Attacking Unit to 2
Set Unit = (Attacking Unit) //<-Make a variable "Unit"
Custom script: call SetUnitAnimationByIndex (udg_Unit, X)
Else
If Level of Dummy Ability for Attacking Unit equals 2 then
Set Level of Dummy Ability for Attacking Unit to 1
Set Unit = (Attacking Unit)
Custom script: call SetUnitAnimationByIndex (udg_Unit, Y)

X and Y should be integer numbers of the proper animations. Test it starting with 0 and 1, then 2 and 3. Untill you find the ones you want.
 
Last edited:
Level 2
Joined
Feb 17, 2017
Messages
26
Hey this actually worked out pretty well ! It works just fine thank you thank you very much for your help

Although just one thing : I think my If/Then/Else is wrong, I couldn't do it the way you described it, so I had to use 2 of them. Here is what I used :

UnitAttack.png


As you can see it's pretty complicated as my If/Then/Else actions spread only on one line. What am I still doing wrong?

Also, just to be sure, shouldn't I also call a custom script to destroy the unit value to make it GUI or something similar? I remember many triggers using such lines.
 
Level 4
Joined
Sep 2, 2016
Messages
48
Bro... Dont use this "if then else". Use the next one. With "multiple actions". The block version. It's much better.

If you needed to destroy the variable "Unit" I would tell you.
 
Level 2
Joined
Feb 17, 2017
Messages
26
Oh ok, got it, that's indeed better. I knew it probably had to be the other If/Then/Else action. Both setups work just fine for what I want, thanks again.

Sorry if I look like a noob, as I said it's been a while since I did Warcraft 3 maps on the editor so I'm remembering all the little details, this is why I was asking for the destroy unit variable because I vaguely remembered some triggers that did that. But if you say that's not necessary I trust you.
 
Status
Not open for further replies.
Top