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

Playing Specified Animation?

Status
Not open for further replies.
Level 7
Joined
Nov 4, 2006
Messages
153
So I'm trying to make a Druid of the Claw unit do a specific animation...but it doesn't play the correct one sometimes (WC3 glitch?).

Anyways, it's like this:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • StrongArm_motion[i] Equal to 3
    • Then - Actions
      • Animation - Play StrongArm_caster[i]'s Attack animation
    • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • StrongArm_motion[i] Equal to 2
        • Then - Actions
          • Animation - Play StrongArm_caster[i]'s Attack - 2 animation
        • Else - Actions
          • Animation - Play StrongArm_caster[i]'s Spell animation
When it needs to play the Attack animation, sometimes it does the Attack - 2. Is there a way to make him do the one specified?...everytime perfectly
 
Level 7
Joined
Jul 20, 2009
Messages
295
Try setting the unit's animation by index instead. I am not sure which value you'd input for that unit's attack animation though. Just test with numbers from 1-15 or so until you find the right animation. (Some units don't even have 15 animations, so usually you'll probably use around 1-10 or 11 or so)

What do you mean, "by using index". What is index? I always hear, see about it but I do not understand it.
 
What do you mean, "by using index". What is index? I always hear, see about it but I do not understand it.

Sorry, I forgot that there is no GUI function for it. =(

I'll try to explain it a bit more. =D Animations are weird since when you use the string value, it might not always do what you want it to do, especially for things like "Attack - 2". The best way is to do it something like this:
  • Animation
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Custom script: call SetUnitAnimationByIndex(GetTriggerUnit(),1)
SetUnitAnimationByIndex():
JASS:
native          SetUnitAnimationByIndex     takes unit whichUnit, integer whichAnimation returns nothing

Ok, in GUI you'll mostly use two values for whichUnit. Either:
- GetTriggerUnit()
- udg_<Name of your unit variable>

So just use those based on whichever you want to use, example:
JASS:
    call SetUnitAnimationByIndex(GetTriggerUnit(),3) 
//Sets the triggering unit's animation to the 3rd indexed animation
    call SetUnitAnimationByIndex(udg_TempUnit,2)
//TempUnit is my unit variable, this sets his animation to the 2nd indexed animation

The indexes will be a whole number (not sure if animations are indexed at 0, I forget)

Anyway, how do you find out the appropriate animation? Well, you can either open it with Magos' model editor (I think it might tell you the indexes), or you can use this code:
  • Animation
    • Events
      • Player - Player 1 (Red) types a chat message containing -Anim as A substring
    • Conditions
    • Actions
      • Set Sub = (Substring((Entered chat string), 7, 8))
      • Set TempUnit = Footman 0003 <gen>
      • Custom script: call SetUnitAnimationByIndex(udg_TempUnit,S2I(udg_Sub))
Select your unit to test it on. (Just place a unit on the map and select it for TempUnit) and then the rest will do it for you. Simply type
- Anim #
Where # is the index you want to test. Example:
testx.jpg

^The footman's eighth animation index is the defend walking animation.

Good luck! =D
 
Status
Not open for further replies.
Top