Play specific unit attack animation

Solu9

You can change this now in User CP.
Reaction score
216
For a spell I need the unit to use a specific attack animation.
The unit has 3.
attack - 1
attack - 2
attack - 3

I want attack - 2.
Trigger:
  • Animation - Play Temp_Unit's attack - 2 animation


This doesn't work.
If I use attack it does, but plays a random attack animation.

How do I differ between animations with the same prefix?
 

vypur85

Hibernate
Reaction score
803
The 'Animation - Play unit animation' is kinda buggy most of the time.

Try this:
Code:
Set Unit = Whatever unit...
Custom script:   call SetUnitAnimationByIndex ( udg_Unit , 1 )

Change the '1' to whatever value and test until you get your desired animation. Then use the same code to play the animation when the spell is casted.
 

Solu9

You can change this now in User CP.
Reaction score
216
Fantastic!

It's a shame the animation number is kinda random but the custom script indeed does the trick.
Thanks :)
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
The animation number is not random at all. It plays the animations in the same order as they are defined in the model-file.
 

Solu9

You can change this now in User CP.
Reaction score
216
The animation number is not random at all. It plays the animations in the same order as they are defined in the model-file.


Really?
I take you don't mean the sequence they show inside the editor because that's not correct.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Nope. The editor sorts them by the animation names. The animation index, as used by that jass function, is the exact index in the files animation list.
Or so I was told by forum members who know more about this stuff. I never checked that information.
 

Solu9

You can change this now in User CP.
Reaction score
216
Nope. The editor sorts them by the animation names. The animation index, as used by that jass function, is the exact index in the files animation list.
Or so I was told by forum members who know more about this stuff. I never checked that information.


And is there a way to show this index?
 

DrEvil

FCRI Associate!
Reaction score
111
Trigger:
  • Animation - Play Unit's attack - 2 animation

translates to
Code:
call SetUnitAnimation( null, "attack - 2" )
which only plays the attack animation (it just plays "attack", the " - 2" is forgotten)
as accname and vyper said, you have to play it by index to get specific animations.

if you view the unit in the main editor screen, and press the left and right arrows on the mini object viewer, you can manually count the index for each animation. (Stand is normally the first, so that would be 1, if "attack" is next, 2, "attack - 2" 3, e.t.c)

EDIT: *points*
 

Solu9

You can change this now in User CP.
Reaction score
216
Open the model file with a model editor. Obviously.


Obviously.
Did that already. Still not correct. I had to use number 12, but in the model editor it shows as 2.
I have added and deleted animations from this model though. Obviously.
If it was obvious I obviously wouldn't have asked.
Obviously.
 

Solu9

You can change this now in User CP.
Reaction score
216
Trigger:
  • Animation - Play Unit's attack - 2 animation

translates to
Code:
call SetUnitAnimation( null, "attack - 2" )
which only plays the attack animation (it just plays "attack", the " - 2" is forgotten)
as accname and vyper said, you have to play it by index to get specific animations.

if you view the unit in the main editor screen, and press the left and right arrows on the mini object viewer, you can manually count the index for each animation. (Stand is normally the first, so that would be 1, if "attack" is next, 2, "attack - 2" 3, e.t.c)


As just stated. The animations "number" in the editor viewer does not represent the correct number in the index.

Edit:
Anyway. The problem is solved.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Well, then that information seems to be incorrect.
As I said, I have been informed by other members that this is the case; I never checked that information, never opened even a single model file from wc3.
But it got to follow some convention. Have you tried it with different model-editors? Maybe some of them sort the animations by other aspects. Maybe try to open a model-file with a standard text-editor. Depending on the format this should be possible.
 

DrEvil

FCRI Associate!
Reaction score
111
I just tried it with a seige tank, the right animation played...
Is it a custom model?

Maybe try to open a model-file with a standard text-editor.
... o_O

EDIT: Ok... I lied.. I changed it to another animation index. And well. It didn't work. How about we just blame blizzard for being noobs?
 

Solu9

You can change this now in User CP.
Reaction score
216
I just tried it with a seige tank, the right animation played...
Is it a custom model?


Again as already stated. I have added and deleted animations, so that might be the reason why the numbers are messed up.
Oh yeah and the model is a custom model which might screw it up even more. Although I would have thought even a custom model would have the correct index to begin with.
So my best guess is still that it's because of the adding and deleting.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Magos sorts animations, geosets, etc. differently than the way they are defined (in the case of animations, it sorts it alphabetically). If you use something like MDLVis, it'll show the order of the sequences properly and you can just count which index the particular animation is (starting from 0).

Or you can open the .mdl file in notepad and count it. Here is a sample:
Code:
Sequences 17 {
        Anim "Stand" {
                Interval { 3333, 6000 },
                MinimumExtent { -85.5541, -85.1761, -0.735934 },
                MaximumExtent { 83.1785, 74.1028, 209.012 },
                BoundsRadius 137.455,
        }
        Anim "Stand - 2" {
                Interval { 6667, 10000 },
                MinimumExtent { -85.5577, -85.1907, -0.736055 },
                MaximumExtent { 83.1785, 74.1128, 209.012 },
                BoundsRadius 137.48,
        }
        Anim "Walk" {
                Interval { 13667, 15667 },
                MoveSpeed 200,
                MinimumExtent { -138.788, -48.8426, -1.26554 },
                MaximumExtent { 89.8302, 113.422, 210.922 },
                BoundsRadius 165.949,
        }
        Anim "Stand Ready" {
                Interval { 16667, 18667 },
                MinimumExtent { -82.4281, -86.6628, -0.76509 },
                MaximumExtent { 71.7419, 130.536, 209.012 },
                BoundsRadius 154.89,
        }
        Anim "Attack - 1" {
                Interval { 20000, 21000 },
                NonLooping,
                MinimumExtent { -152.138, -100.333, -7.18807 },
                MaximumExtent { 233.286, 130.536, 209.012 },
                BoundsRadius 214.324,
        }
        Anim "Death" {
                Interval { 23200, 25533 },
                NonLooping,
                MinimumExtent { -304.427, -168.207, -16.8208 },
                MaximumExtent { 102.035, 130.536, 209.012 },
                BoundsRadius 252.853,
        }
        Anim "Spell" {
                Interval { 26533, 27700 },
                NonLooping,
                MinimumExtent { -139.589, -82.4189, -3.83338 },
                MaximumExtent { 169.714, 74.455, 209.958 },
                BoundsRadius 188.489,
        }
        Anim "Walk Gold" {
                Interval { 28667, 29667 },
                MoveSpeed 200,
                MinimumExtent { -261.506, -92.2042, -38.2161 },
                MaximumExtent { 22.908, 113.609, 108.192 },
                BoundsRadius 172.889,
        }
        Anim "Stand Gold" {
                Interval { 30000, 32667 },
                MinimumExtent { -146.659, -93.1261, -80.3994 },
                MaximumExtent { 114.435, 63.8673, 92.2605 },
                BoundsRadius 162.667,
        }
        Anim "Stand Gold - 2" {
                Interval { 33333, 36667 },
                MinimumExtent { -146.659, -93.1261, -80.4255 },
                MaximumExtent { 114.435, 63.8673, 92.2604 },
                BoundsRadius 162.671,
        }
        Anim "Attack Gold" {
                Interval { 40733, 41733 },
                NonLooping,
                MinimumExtent { -176.809, -82.4581, -75.264 },
                MaximumExtent { 175.16, 135.003, 127.975 },
                BoundsRadius 186.277,
        }
        Anim "Stand Ready Gold" {
                Interval { 42400, 46400 },
                MinimumExtent { -146.659, -82.4581, -80.5297 },
                MaximumExtent { 141.41, 54.396, 92.2604 },
                BoundsRadius 165.266,
        }
        Anim "Death Gold" {
                Interval { 48767, 50200 },
                NonLooping,
                MinimumExtent { -146.659, -82.4581, -147.86 },
                MaximumExtent { 141.41, 124.346, 111.415 },
                BoundsRadius 162.775,
        }
        Anim "Spell Gold" {
                Interval { 54733, 55900 },
                NonLooping,
                MinimumExtent { -202.141, -82.4581, -97.4892 },
                MaximumExtent { 141.41, 155.386, 114.138 },
                BoundsRadius 205.516,
        }
        Anim "Decay Gold" {
                Interval { 57067, 117067 },
                NonLooping,
                MinimumExtent { 3.40282e+038, 3.40282e+038, 3.40282e+038 },
                MaximumExtent { -3.40282e+038, -3.40282e+038, -3.40282e+038 },
        }
        Anim "Decay Flesh" {
                Interval { 173267, 233267 },
                NonLooping,
                MinimumExtent { -295.367, -172.12, -138.53 },
                MaximumExtent { 48.0356, 44.8795, 36.6764 },
                BoundsRadius 213.262,
        }
        Anim "Decay Bone" {
                Interval { 239933, 299933 },
                NonLooping,
                MinimumExtent { -106.698, -103.051, 2.00656 },
                MaximumExtent { 46.6459, 34.7261, 19.1762 },
                BoundsRadius 89.9866,
        }
}

"Sequences" is followed by a number displaying the animation count (in this case, 17). The way the animations are ordered defines its animation index. Thus, "stand" is 0, "stand - 2" is 1, "walk" is 2, etc. This is a bit tedious though. Perhaps it would be neat to add a plug-in in JNGP to get the animation indexes of a model. :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top