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

Attack Animations with Items

Status
Not open for further replies.
Level 7
Joined
Sep 8, 2011
Messages
211
Sorry to post another thread so quickly but I really need to know how to change a units attack animations when he has an item equipped. I am now using the Villager 255 animation model, when he doesn't have weapons he attacks using his fists (this is default and it is fine left like this) but when the player picks up a weapon I want him to use different animations he has for the item when he attacks.

Anyone know what to do here?
 
Level 12
Joined
Sep 11, 2011
Messages
1,176
here is a test map, you can play with the 'Integer' variable, until you find the right animations. currently i set it to random number from 20 to 30.

pick the Claw of attack +15
 

Attachments

  • Villager 255 Animations.w3x
    433 KB · Views: 103
Level 5
Joined
Dec 16, 2011
Messages
55
You should use SetUnitAnimationByIndex(GetAttackingUnit(),integer) with the event EVENT_PLAYER_UNIT_ATTACKED

In GUI it would be kinda like this:

  • TempTrigger
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) has an item of type Your Item) Equal to True
    • Actions
      • Set TempInteger = 0
      • -------- TempInteger is the index of the animation you wanna play --------
      • Custom script: call SetUnitAnimationByIndex(GetAttacker(),udg_TempInteger)
And if you wanna do it in more than a single item:

  • TempTrigger
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • ((Attacking unit) has an item of type Sword) Equal to True
          • ((Attacking unit) has an item of type Dagger) Equal to True
          • ((Attacking unit) has an item of type Bow) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Attacking unit) has an item of type Sword) Equal to True
        • Then - Actions
          • Set TempInteger = 1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Attacking unit) has an item of type Dagger) Equal to True
            • Then - Actions
              • Set TempInteger = 2
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Attacking unit) has an item of type Bow) Equal to True
                • Then - Actions
                  • Set TempInteger = 3
                • Else - Actions
      • Custom script: call SetUnitAnimationByIndex(GetAttacker(),udg_TempInteger)
 
Last edited:
Level 7
Joined
Sep 8, 2011
Messages
211
I have all the animations I want written down. I just want to know how to make the villager use specific animations when he picks up an item.

For example: There is a one handed sword in the game he can pick up, when he obtains it, it gives him the model I have added to the sword but he still punches and kicks rather that uses the animations I have set in the option in object editor Art - Animation Names.

I want to know how exactly do I change his animations for auto attacking with different items. :)
 
Level 7
Joined
Sep 8, 2011
Messages
211
I am terrible at custom scripts... It keeps giving me an syntax error with the custom script even though I have modified it. I has set it as:

SetUnitAnimationByIndex(GetAttacker(),udg_Temp_Integer) because the variable I am using is Temp_Integer...

What am I doing wrong? (probably everything :p )

Edit: I wasn't adding in the call at the start...... I haven't done map editing in a long time lmao. Thanks to everyone that has helped me! :)
 
Last edited:
Status
Not open for further replies.
Top