1. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  2. The Melee Mapping Contest #4: 2v2 - Results are out! Step by to congratulate the winners!
    Dismiss Notice
  3. We're hosting the 15th Mini-Mapping Contest with YouTuber Abelhawk! The contestants are to create a custom map that uses the hidden content within Warcraft 3 or is inspired by any of the many secrets within the game.
    Dismiss Notice
  4. The 20th iteration of the Terraining Contest is upon us! Join and create exquisite Water Structures for it.
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice

Forcing unit animation

Discussion in 'Triggers & Scripts' started by Woodenplank, Jan 20, 2019.

  1. Woodenplank

    Woodenplank

    Joined:
    Feb 8, 2015
    Messages:
    89
    Resources:
    0
    Resources:
    0
    Hi Hive

    I'm making a sort of "motion blur" movement speed ability, and it almost works perfectly.

    The trigger gives some movement speed abilities and such to the caster, but it also does a loop every 0.20 seconds which creates a transparent clone of the Hero.
    The clone starts with 60% transparency, and steadily becomes more transparent until it reaches 100% and is removed from the game.

    This all works perfectly, but I want the blur images to play their walking animation - however, they refuse to do so. Right now they just do idle stand animations
    Putting a "Play Unit's walk animation" in the For Every Unit in Group... loop made them stutter awkwardly, because of how fast the looping runs.

    Any advice? Is there a way to force units to just permanently play walk animations, regardless of other changes?

    P.s. The casting trigger is just here for the full picture. The problem is entirely with the loop trigger
    • Windstalk Activate
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Ash: Windstalk (Channel)
      • Actions
        • Set WinSta_index = (WinSta_index + 1)
        • Set WinSta_Caster[WinSta_index] = (Triggering unit)
        • Set WinSta_Dur = 9999.00
        • Set WinSta_lvl = (Level of (Ability being cast) for WinSta_Caster[WinSta_index])
        • -------- Adds and levels abilities- then hides the icons --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Level of WinSta_Abil1 for WinSta_Caster[WinSta_index]) Less than 1
          • Then - Actions
            • Unit - Add WinSta_Abil1 to WinSta_Caster[WinSta_index]
            • Unit - Set level of WinSta_Abil1 for WinSta_Caster[WinSta_index] to WinSta_lvl
            • Unit - For WinSta_Caster[WinSta_index], Ability WinSta_Abil1, Hide ability: True
          • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Level of WinSta_Abil2 for WinSta_Caster[WinSta_index]) Less than 1
          • Then - Actions
            • Unit - Add WinSta_Abil2 to WinSta_Caster[WinSta_index]
            • Unit - Set level of WinSta_Abil2 for WinSta_Caster[WinSta_index] to WinSta_lvl
            • Unit - For WinSta_Caster[WinSta_index], Ability WinSta_Abil2, Hide ability: True
          • Else - Actions
        • -------- Loop trigger on/off --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • WinSta_index Greater than 0
          • Then - Actions
            • Trigger - Turn on Windstalk Loop <gen>
          • Else - Actions
    • Windstalk Loop
      • Events
        • Time - Every 0.20 seconds of game time
      • Conditions
      • Actions
        • For each (Integer WinSta_Loopi) from 1 to WinSta_index, do (Actions)
          • Loop - Actions
            • -------- Visual Effect --------
            • Set WinSta_Tempp = (Position of WinSta_Caster[WinSta_Loopi])
            • Unit - Create 1 Ashprowler Image (Dummy) for Neutral Passive at WinSta_Tempp facing (Facing of WinSta_Caster[WinSta_Loopi]) degrees
            • Custom script: call RemoveLocation(udg_WinSta_Tempp)
            • Set WinSta_Tempu = (Last created unit)
            • Animation - Play WinSta_Tempu's walk animation
            • Set WinSta_transparency = 60.00
            • Animation - Change WinSta_Tempu's vertex coloring to (100.00%, 100.00%, 100.00%) with WinSta_transparency% transparency
            • Hashtable - Save WinSta_transparency as 0 of (Key (Last created unit)) in WinSta_hash
            • -------- Increasing transparency and removal --------
            • Set WinSta_r = (((100.00 - WinSta_transparency) / 2.00) / 5.00)
            • Unit Group - Add WinSta_Tempu to WinSta_Ug
            • Unit Group - Pick every unit in WinSta_Ug and do (Actions)
              • Loop - Actions
                • Set WinSta_picked = (Picked unit)
                • Set WinSta_transparency = ((Load 0 of (Key (Picked unit)) from WinSta_hash) + WinSta_r)
                • Animation - Change WinSta_picked's vertex coloring to (100.00%, 100.00%, 100.00%) with WinSta_transparency% transparency
                • Animation - Queue WinSta_picked's walk animation
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • WinSta_transparency Greater than or equal to 100.00
                  • Then - Actions
                    • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in WinSta_hash
                    • Unit Group - Remove WinSta_picked from WinSta_Ug
                    • Unit - Remove WinSta_picked from the game
                  • Else - Actions
                    • Hashtable - Save WinSta_transparency as 0 of (Key (Picked unit)) in WinSta_hash
            • -------- Updates duration --------
            • Set WinSta_Time[WinSta_Loopi] = (WinSta_Time[WinSta_Loopi] + 0.20)
            • -------- Checks if Duration Expired --------
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • WinSta_Time[WinSta_Loopi] Greater than or equal to WinSta_Dur
              • Then - Actions
                • -------- Removes ability bonuses --------
                • Unit - Remove WinSta_Abil1 from WinSta_Caster[WinSta_Loopi]
                • Unit - Remove WinSta_Abil2 from WinSta_Caster[WinSta_Loopi]
                • -------- Updates index --------
                • Set WinSta_Caster[WinSta_Loopi] = WinSta_Caster[WinSta_index]
                • Set WinSta_index = (WinSta_index - 1)
                • Set WinSta_Loopi = (WinSta_Loopi - 1)
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • WinSta_index Equal to 0
                  • Then - Actions
                    • Trigger - Turn off (This trigger)
                  • Else - Actions
              • Else - Actions

    P.p.s. The insanely high duration is just for testing purposes...
     
  2. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,420
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    Try using
    SetUnitAnimationByIndex
    , like so:
    • Custom script: call SetUnitAnimationByIndex(udg_WinSta_Tempu, 3)


    edited: Replace "3" with the animation index for your unit's walk. To find this out, convert your model from MDX to MDL, open it in a text editor, go to the animations portion, and the animations will be listed in order (first animation listed has index 0, second animation has index 1, etc.). Or you can just test your spell with different #'s until you get the right one.

    Note: the animation index depends on your model. So if you want this spell to support different models, I would store the walk indices in a hashtable on map init for all the models that may cast that spell, and then look it up for your spell's triggers.

    For more reading, see this post:
    how to play units walk animation
     
    Last edited: Jan 21, 2019
  3. Hermit

    Hermit

    Joined:
    May 29, 2013
    Messages:
    1,099
    Resources:
    2
    Models:
    1
    Icons:
    1
    Resources:
    2
    Animations are always listed alphabetically in War3 Model Editor. I think you need to convert the model to mdl and open it in Notepad to see the correct order.
     
    Last edited: Jan 20, 2019
  4. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,420
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    nice catch, didn't remember that. I'll update my post.
     
  5. Woodenplank

    Woodenplank

    Joined:
    Feb 8, 2015
    Messages:
    89
    Resources:
    0
    Resources:
    0
    Thanks a lot to the both of you! I used the custom script (after finding that the index was 2, for the given model), and it works perfectly!