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

Reverse Death Animation

Status
Not open for further replies.
Level 3
Joined
May 15, 2021
Messages
21
Hi. I need to reverse death animation I tried to use
SetUnitTimeScalePercent with negative value but it didn' work. Is there any way to do so. It works with others animations though. I installed blender but I can't open mdl model I installed addon for mdl but I have an error that says AttributeError: 'Object has no attribute 'pivot'
 
Last edited:
Level 3
Joined
May 15, 2021
Messages
21
Have you tried doing it with Special Effects?
Like hide an unit and create at his point a special effect? I want to make an unit to play reverse death animation when they are effected by spell. Like I made my unit sleep and play death animation I want to cast dispell and after buff dissapear they play reversed death animation
 
Last edited:
Level 3
Joined
May 15, 2021
Messages
21
Here what makes them sleep

JASS:
function Trig_sleep_Actions takes nothing returns nothing
local unit u 
set u = GetSpellTargetUnit()
call TriggerSleepAction(0.25)
call PauseUnit(u,false)
call SetUnitTimeScalePercent(u, 75 )
call SetUnitAnimationByIndex(u,9)
endfunction

This makes them play animation when they got dispelled.

JASS:
function Trig_Untitled_Trigger_002_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'Adis' ) ) then
        return false
    endif
    return true
endfunction

function Target_Check takes nothing returns boolean
    return GetUnitTypeId(GetFilterUnit()) == 'hfoo' or GetUnitTypeId(GetFilterUnit()) == 'hcth' 
endfunction

function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
local group g = CreateGroup()
local unit  u
local location l
local boolexpr b = Condition(function Target_Check)

set l = GetSpellTargetLoc()
set g = GetUnitsInRangeOfLocMatching(275,l,b)

loop

set u = FirstOfGroup(g)
call DisplayTextToForce(GetPlayersAll(),GetUnitName(u))
call SetUnitTimeScalePercent(u,-100)
call SetUnitAnimationByIndex(u,9)
call GroupRemoveUnit(g,u)

exitwhen u == null

endloop

endfunction
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,570
Did you convert your trigger to text?
If yes, it'd be easier to read it in it's original GUI form.

Anyway, maybe this will help:

For the Special Effect method, you could set the transparency of the unit to 0.00% and then create a Special Effect of their model and have it mimic their reversed Death animation. Reverse the animation by setting the Special Effect's time scale to -1. Then move the Special Effect offscreen and Destroy it when it's done playing and return the unit back to 100% transparency.
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,024
No, @Uncle, they have some locals in there. Just beginning JASS looks like.

I am 100% certain I have been able to set a negative animation speed to play an animation backwards, but that was years ago. I was specifically interested in the possibility of this and tested on the Blood Mage model to make it look like he was swooping down from the air with his dissipate animation. Guess something changed.

Special effect method can be achieved with this new native:
JASS:
native BlzPlaySpecialEffectWithTimeScale takes effect whichEffect, animtype whichAnim, real timeScale returns nothing

If that ends up looking janky you could edit the model and manually reverse the death animation keyframe-by-keyframe and reimport it as a new model. Then make a second identical unit to the main one except using that model. Morph the unit into the alt version using a passive transformation method (or maybe unit skins in newer versions, but I have not messed with them), play the animation, and then morph back.
 
Level 3
Joined
May 15, 2021
Messages
21
Special effect method can be achieved with this new native:
JASS:
native BlzPlaySpecialEffectWithTimeScale takes effect whichEffect, animtype whichAnim, real timeScale returns nothing
Oh thank you, didn't know about this function, for some reason TESH doesn't recognize it and it's also not in the list. Probably need to update. So it turns out that I will need to create an effect with a model in my case of a footman and make this effect play the animation of death in reverse order? How do I know what I should put on
JASS:
animtype whichAnim
?
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,570
ANIM_TYPE_DEATH

I recommend downloading VS Code if you haven't already and downloading a vJass plugin so you can easily see the entire API. Typing "animtype" for example will bring up a list of every possible option.

Quoting myself (updated my previous post):

For the Special Effect method, you could set the transparency of the unit to 0.00% and then create a Special Effect of their model and have it mimic their reversed Death animation. Reverse the animation by setting the Special Effect's time scale to -1. Then move the Special Effect offscreen and Destroy it when it's done playing and return the unit back to 100% transparency.
 
Level 3
Joined
May 15, 2021
Messages
21
ANIM_TYPE_DEATH

I recommend downloading VS Code if you haven't already and downloading a vJass plugin so you can easily see the entire API. Typing "animtype" for example will bring up a list of every possible option.

Quoting myself (updated my previous post):

For the Special Effect method, you could set the transparency of the unit to 0.00% and then create a Special Effect of their model and have it mimic their reversed Death animation. Reverse the animation by setting the Special Effect's time scale to -1. Then move the Special Effect offscreen and Destroy it when it's done playing and return the unit back to 100% transparency.
Ty I will try
 
Level 3
Joined
May 15, 2021
Messages
21
Quoting myself (updated my previous post):

For the Special Effect method, you could set the transparency of the unit to 0.00% and then create a Special Effect of their model and have it mimic their reversed Death animation. Reverse the animation by setting the Special Effect's time scale to -1. Then move the Special Effect offscreen and Destroy it when it's done playing and return the unit back to 100% transparency.
I tried to do so -1 doesn't work. I put -0,1 and it plays the very ending of animation.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,570
All of the info is in that first link I sent you.

If the animation does not loop, you need to set its time as well:
  • Actions
    • Special Effect - Create a special effect at (Center of (Playable map area)) using Abilities\Spells\NightElf\FanOfKnives\FanOfKnivesCaster.mdl
    • Special Effect - Set Time of (Last created special effect) to 5000.00
    • Special Effect - Set Time Scale of (Last created special effect) to -1.00
 
Level 3
Joined
May 15, 2021
Messages
21
All of the info is in that first link I sent you.
JASS:
call AddSpecialEffectLocBJ (effectLocation,"units\\human\\Footman\\Footman.mdl" )
call BlzSetSpecialEffectTime (GetLastCreatedEffectBJ(), 5000.00)
call BlzSetSpecialEffectTimeScale(GetLastCreatedEffectBJ(),-1)
call BlzPlaySpecialEffect (GetLastCreatedEffectBJ(),ANIM_TYPE_DEATH)

what did i do wrong?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,570
Looks like the old method doesn't play nice on the latest patch.

I got it working by shifting the order of the Actions so that the animation plays first:
  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Special Effect - Create a special effect at (Center of (Playable map area)) using units\human\Footman\Footman.mdl
      • Special Effect - Play Special Effect: (Last created special effect), Animation: Death
      • Special Effect - Set Time of (Last created special effect) to 5000.00
      • Special Effect - Set Time Scale of (Last created special effect) to -1.00
 
Level 3
Joined
May 15, 2021
Messages
21
I got it working by shifting the order of the Actions so that the animation plays first:
  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Special Effect - Create a special effect at (Center of (Playable map area)) using units\human\Footman\Footman.mdl
      • Special Effect - Play Special Effect: (Last created special effect), Animation: Death
      • Special Effect - Set Time of (Last created special effect) to 5000.00
      • Special Effect - Set Time Scale of (Last created special effect) to -1.00

It worked thanks! Blizzard loves to break what worked well
 
Level 3
Joined
May 15, 2021
Messages
21
Maybe that would work for just the unit directly, then? Play animation then set timescale? I realize you can't start at the 'end' of the animation like you can with an effect but it's worth trying.
I tried but it didn't work. I noticed if you just wait and then kill an effect It will still play reversed animation on effect. I'm wondering if I can set the animation in a local variable and wait a while before destroying it. Will it play it for unit?
 
Last edited:
Level 3
Joined
May 15, 2021
Messages
21
I have no idea what you mean by this. I think you don't understand what local variable is or why you would need/want one?
I meant that if it was possible to recognize the animations being played, then I could try to destroy it. But that type of variable doesn't exist, so it was just a guess.
 
Level 3
Joined
May 15, 2021
Messages
21
Ah. No it's not possible to read a unit's current animation, but animtype and subanimtype are valid variable types you could declare in a custom script line. There are various constant globals defined already.
What it gives to me? Like I can just set global variable as
JASS:
 set udg_AnimationType = ANIM_TYPE_DEATH

And I get this error:(
1676637318989.png
1676637335712.png


upd: I understood what was wrong. I used GUI to set variable but need to visit the site u linked and edit numbers. will try to do something with it
upd Still don't understand how to use that I thought I could make unit play this variable. But
JASS:
SetUnitAnimation
requires string not integer what function should I use with this variable?
Or I can still use ?
JASS:
SetUnitAnimationByIndex
upd: In general, it is somehow difficult to understand how to set this variable, I entered 328 as indicated on the site, then I tried to insert 1 and both options did not work ... And which function should I use with this variable. I am sorry for such many upds. I have problems with try first then write:D
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,024
Those animtype and subanimtype variables are only used as inputs to a few functions; you can see them all here. Most of them are for the new BlzSpecialEffect... stuff, which is why they exist. The two functions you cited (SetUnitAnimation/ByIndex) are older and do not use animtype or subanimtype variables as inputs; they take strings like "death" (instead of ANIM_TYPE_DEATH) or integers. The only potentially relevant function for you to use is this one:
JASS:
native BlzGetAnimName takes animtype whichAnim returns string
but it won't really provide you with anything you couldn't already guess beforehand: BlzGetAnimName(ANIM_TYPE_DEATH) returns "death". For more obscure animation types maybe it's relevant to use this function to learn how they're written as strings.

To use ByIndex animation functions, you need to open the model up and inspect its animations to learn which ones are which number... or just keep trying them all until you find it. These allow you to play specific variations of animations that have multiple variations.
 
Status
Not open for further replies.
Top