wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 01-04-2009, 09:11 AM   #1
fX_
User
 
fX_'s Avatar
 
Join Date: Jan 2007
Posts: 528

Submissions (2)

fX_ will become famous soon enough (38)fX_ will become famous soon enough (38)

Default Reverse Animation

**Updated:**
fixed some leaks and removed redundant stuff. dunno why they were missed...
Added a feature for running follow-up stuff to be ran after animation is played. See "C" trigger in script for example implementation.
Also fixed an error in calculation of run time of the reverse naimation, I think.

A function that runs animations in reverse for units.
See http://www.wc3campaigns.net/showpost...1&postcount=88 for information on which this system is dependent.

Requires TimerUtils (Source: http://wc3campaigns.net/showthread.php?t=101322).

SCRIPT:
Collapse JASS:
library ReverseAnimation requires TimerUtils

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //  ReverseAnimation
    //====================================================================================================================
    //  Firstly, this script requires TimerUtils (by Vexorian @ [url]www.wc3campaigns.net):[/url]
    //          [url]http://wc3campaigns.net/showthread.php?t=101322[/url]
    //
    //  Background Info:
    //   [url]http://www.wc3campaigns.net/showpost.php?p=1017121&postcount=88[/url]
    //
    //  function SetUnitAnimationReverse takes:
    //
    //      unit u - animation of which reverse animation is played;
    //      integer index - animation index of the animation to be played;
    //      real animTime - the natural duration of the animation to be played. This can be referred to in the preview
    //                      window in the bottom-left part of the World Editor interface (it is the real value enclosed
    //                      in parenthesis);
    //      real runSpeed - the speed at which the animation to be played in reverse will be ran.
    //      boolean resetAnim - indicates to the system if it should set the unit's animation to "stand" after playing the
    //                          reverse animation.
    //
    //  function SetUnitAnimationReverseFollowed takes all of the above and:
    //      FollowUpFunc func - function to be ran after the animation is played. Expressed as a function interface
    //                          (see below). Takes an data object arguement pertaining to relevant stuff that must be
    //                          passed.
    //      integer data - a struct that is the above data object.
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII//
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII//
//  -- Configuration --

    globals
        private constant real PREP_INTERVAL_DURATION = 0.03
    endglobals

//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII//
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII//
//  -- User Functions --

    private keyword ReverseAnimation

    function SetUnitAnimationReverse takes unit u, integer index, real animTime, real runSpeed, boolean resetAnim returns boolean
        return ReverseAnimation.Prepare(u, index, animTime, runSpeed, resetAnim, 0, 0)
    endfunction

    function SetUnitAnimationReverseFollowed takes unit u, integer index, real animTime, real runSpeed, boolean resetAnim, FollowUpFunc func, integer data returns boolean
        return ReverseAnimation.Prepare(u, index, animTime, runSpeed, resetAnim, func, data)
    endfunction

//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII//
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII//
//  -- Script Operation Functions --

    function interface FollowUpFunc takes integer data returns nothing

    private struct ReverseAnimation

        private unit u
        private integer intAnimIndex
        private real rAnimTime
        private real rRunSpeed
        private boolean boolResetAnim
        private FollowUpFunc func
        private integer data

        public static method Prepare takes unit u, integer index, real animTime, real runSpeed, boolean resetAnim, FollowUpFunc func, integer data returns boolean
            local ReverseAnimation new = 0
            local timer TIM = null

            if u != null and index > 0 and runSpeed > 0.00 then
                set new = .allocate()
                set new.u = u
                set new.intAnimIndex = index
                set new.rAnimTime = animTime
                set new.rRunSpeed = -runSpeed
                set new.boolResetAnim = resetAnim
                set new.func = func
                set new.data = data

                call SetUnitTimeScale(u, animTime/PREP_INTERVAL_DURATION)
                call SetUnitAnimationByIndex(u, index)
                set TIM = NewTimer()
                call SetTimerData(TIM, integer(new))
                call TimerStart(TIM, PREP_INTERVAL_DURATION, false, function ReverseAnimation.Play)

                set TIM = null
                return true
            endif

            return false
        endmethod

        public static method Play takes nothing returns nothing
            local timer TIM = GetExpiredTimer()
            local ReverseAnimation INST = GetTimerData(TIM)

            call SetUnitTimeScale(INST.u, INST.rRunSpeed)
            call TimerStart(TIM, INST.rAnimTime/-INST.rRunSpeed, false, function ReverseAnimation.End)

            set TIM = null
        endmethod

        public static method End takes nothing returns nothing
            local timer TIM = GetExpiredTimer()
            local ReverseAnimation INST = GetTimerData(TIM)

            call SetUnitTimeScale(INST.u, 1.00)
            if INST.boolResetAnim then
                call SetUnitAnimation(INST.u, "stand")
            endif
            if INST.func != 0 then
                call INST.func.execute(INST.data)
            endif

            set INST.u = null
            call INST.destroy()
            call ReleaseTimer(TIM)
            set TIM = null
        endmethod

    endstruct

endlibrary
Attached Files
File Type: w3x ReverseAnimation.w3x (22.0 KB, 148 views)

Last edited by fX_ : 11-11-2009 at 05:18 PM.
fX_ is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 01-04-2009, 05:20 PM   #2
Ammorth
I blink, therefore I am.
 
Ammorth's Avatar
 
Join Date: Sep 2006
Posts: 1,812

Submissions (10)

Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)

Default

I think he means to rename the file name to something more convenient.
__________________
Ammorth is offline   Reply With Quote
Old 01-04-2009, 08:24 PM   #3
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

This is actually an interesting script. The biggest problem I see with it is that a unit must actually play the animation and be caught before it ends, which can be a real pain to manage. I will toy with your testmap and see what you have come up with, though.

EDIT:
In the future, make sure your testmaps are actually compiled properly and playable. Also, please, for the love of God, name them something relevant. asdasfd is not suitable at all.

EDIT:
Okay, that was kind of neat, it worked sufficiently and in all cases that SetUnitAnimation() would. Good job there. However, my biggest concern is that you're playing with and destroying timers. You should incorporate TimerUtils into your library so as to avert that. This is important.
__________________

Last edited by Rising_Dusk : 01-04-2009 at 08:30 PM.
Rising_Dusk is offline   Reply With Quote
Old 01-05-2009, 12:26 AM   #4
fX_
User
 
fX_'s Avatar
 
Join Date: Jan 2007
Posts: 528

Submissions (2)

fX_ will become famous soon enough (38)fX_ will become famous soon enough (38)

Default

So it is ok but I need to rework how the waiting works?

Can I use something CSSafety-ish instead of TimerUtils? - 'coz I know how it works and I do not how TimerUtils does...

EDIT: I was able to compile it...

Last edited by fX_ : 01-05-2009 at 12:56 AM.
fX_ is offline   Reply With Quote
Old 01-05-2009, 02:37 AM   #5
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Quote:
Originally Posted by fX_
EDIT: I was able to compile it...
Your testmap as you originally had it would not start because the map was improperly compiled. That is to what I refer.
Quote:
Originally Posted by fX_
Can I use something CSSafety-ish instead of TimerUtils? - 'coz I know how it works and I do not how TimerUtils does...
CSSafety is deprecated. We use TimerUtils now. There are likely other fixes necessary as well, but the resident Development Director will elaborate when he finds the time.
__________________
Rising_Dusk is offline   Reply With Quote
Old 01-06-2009, 09:51 AM   #6
Pyrogasm
Lackadaisically Absent.
 
Pyrogasm's Avatar


Respected User
 
Join Date: Sep 2006
Posts: 4,523

Submissions (9)

Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)

Hero Contest - Fourth place

Send a message via ICQ to Pyrogasm Send a message via AIM to Pyrogasm Send a message via MSN to Pyrogasm Send a message via Yahoo to Pyrogasm
Default

Sweet. Nice to know my results got used for something :D
__________________
Quote:
Originally posted by Rising_Dusk
Your spells are mostly ignored because they are not very cool so we aren't very excited to review/approve them, but you are incredibly persistent and won't give us an excuse to graveyard it. That is generally what results in a resource being ignored for a long time.

The Spell Request Thread Done for, unless someone else wants to revive it...
It lasted a damn long time.

Please; Ask for Help Appropriately














Quote:
Originally posted by Kyrbi0
Huh. Almost makes me wish I had a girlfriend, to take advantage of today (wait, no, that's not what I meant... I mean, take advantage of the fact that it is international women's day... gah, never mind).
Quote:
Originally posted by Pyrogasm
Rome may not have been built in a day, but the Romans sure as hell didn't say "look at this great city we built guys!" when they had nothing more than a bit of stone and some cottages.
Pyrogasm is offline   Reply With Quote
Old 01-06-2009, 04:31 PM   #7
Tide-Arc Ephemera
Overdoses result in death
 
Tide-Arc Ephemera's Avatar
 
Join Date: Jan 2007
Posts: 2,365

Submissions (3)

Tide-Arc Ephemera is a jewel in the rough (206)Tide-Arc Ephemera is a jewel in the rough (206)Tide-Arc Ephemera is a jewel in the rough (206)

Default

Had this been in plain Jass, I'd be using this... EVERYWHERE.
__________________
Before asking for help with triggers... read this and check your trigger!

If you're having troubles getting help on WC3C or anywhere at all, please have a look at...
The WRONG way to ask for help and The CORRECT way to ask for help.

Quote:
Originally Posted by Alevice
You may never stop our bioweapon! We mexicans shall rule the third world! Mwahahahahahahaha!
Please acknowledge that I use Mac and avoid suggesting vJass and other tools that don't work on it. Thank you.
Tide-Arc Ephemera is offline   Reply With Quote
Old 01-07-2009, 12:09 AM   #8
Pyrogasm
Lackadaisically Absent.
 
Pyrogasm's Avatar


Respected User
 
Join Date: Sep 2006
Posts: 4,523

Submissions (9)

Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)

Hero Contest - Fourth place

Send a message via ICQ to Pyrogasm Send a message via AIM to Pyrogasm Send a message via MSN to Pyrogasm Send a message via Yahoo to Pyrogasm
Default

It's able to be converted. Want me to do it for you?
__________________
Quote:
Originally posted by Rising_Dusk
Your spells are mostly ignored because they are not very cool so we aren't very excited to review/approve them, but you are incredibly persistent and won't give us an excuse to graveyard it. That is generally what results in a resource being ignored for a long time.

The Spell Request Thread Done for, unless someone else wants to revive it...
It lasted a damn long time.

Please; Ask for Help Appropriately














Quote:
Originally posted by Kyrbi0
Huh. Almost makes me wish I had a girlfriend, to take advantage of today (wait, no, that's not what I meant... I mean, take advantage of the fact that it is international women's day... gah, never mind).
Quote:
Originally posted by Pyrogasm
Rome may not have been built in a day, but the Romans sure as hell didn't say "look at this great city we built guys!" when they had nothing more than a bit of stone and some cottages.
Pyrogasm is offline   Reply With Quote
Old 01-07-2009, 05:59 AM   #9
Tide-Arc Ephemera
Overdoses result in death
 
Tide-Arc Ephemera's Avatar
 
Join Date: Jan 2007
Posts: 2,365

Submissions (3)

Tide-Arc Ephemera is a jewel in the rough (206)Tide-Arc Ephemera is a jewel in the rough (206)Tide-Arc Ephemera is a jewel in the rough (206)

Default

That would be super special awesome, please.
__________________
Before asking for help with triggers... read this and check your trigger!

If you're having troubles getting help on WC3C or anywhere at all, please have a look at...
The WRONG way to ask for help and The CORRECT way to ask for help.

Quote:
Originally Posted by Alevice
You may never stop our bioweapon! We mexicans shall rule the third world! Mwahahahahahahaha!
Please acknowledge that I use Mac and avoid suggesting vJass and other tools that don't work on it. Thank you.
Tide-Arc Ephemera is offline   Reply With Quote
Old 01-07-2009, 06:10 AM   #10
Pyrogasm
Lackadaisically Absent.
 
Pyrogasm's Avatar


Respected User
 
Join Date: Sep 2006
Posts: 4,523

Submissions (9)

Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)

Hero Contest - Fourth place

Send a message via ICQ to Pyrogasm Send a message via AIM to Pyrogasm Send a message via MSN to Pyrogasm Send a message via Yahoo to Pyrogasm
Default

Give me a day or so and I can probably do it. Gamecache for-the-win.
__________________
Quote:
Originally posted by Rising_Dusk
Your spells are mostly ignored because they are not very cool so we aren't very excited to review/approve them, but you are incredibly persistent and won't give us an excuse to graveyard it. That is generally what results in a resource being ignored for a long time.

The Spell Request Thread Done for, unless someone else wants to revive it...
It lasted a damn long time.

Please; Ask for Help Appropriately














Quote:
Originally posted by Kyrbi0
Huh. Almost makes me wish I had a girlfriend, to take advantage of today (wait, no, that's not what I meant... I mean, take advantage of the fact that it is international women's day... gah, never mind).
Quote:
Originally posted by Pyrogasm
Rome may not have been built in a day, but the Romans sure as hell didn't say "look at this great city we built guys!" when they had nothing more than a bit of stone and some cottages.
Pyrogasm is offline   Reply With Quote
Old 01-07-2009, 06:41 AM   #11
Ammorth
I blink, therefore I am.
 
Ammorth's Avatar
 
Join Date: Sep 2006
Posts: 1,812

Submissions (10)

Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)

Default

Quote:
Originally Posted by Pyrogasm
Give me a day or so and I can probably do it. Gamecache for-the-win.
no need, just use the same style of coding that vJass parses to (look at my multibars system for an example of how I did it).
__________________
Ammorth is offline   Reply With Quote
Old 01-07-2009, 06:59 AM   #12
Pyrogasm
Lackadaisically Absent.
 
Pyrogasm's Avatar


Respected User
 
Join Date: Sep 2006
Posts: 4,523

Submissions (9)

Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)

Hero Contest - Fourth place

Send a message via ICQ to Pyrogasm Send a message via AIM to Pyrogasm Send a message via MSN to Pyrogasm Send a message via Yahoo to Pyrogasm
Default

Ah, arrays. Right.
__________________
Quote:
Originally posted by Rising_Dusk
Your spells are mostly ignored because they are not very cool so we aren't very excited to review/approve them, but you are incredibly persistent and won't give us an excuse to graveyard it. That is generally what results in a resource being ignored for a long time.

The Spell Request Thread Done for, unless someone else wants to revive it...
It lasted a damn long time.

Please; Ask for Help Appropriately














Quote:
Originally posted by Kyrbi0
Huh. Almost makes me wish I had a girlfriend, to take advantage of today (wait, no, that's not what I meant... I mean, take advantage of the fact that it is international women's day... gah, never mind).
Quote:
Originally posted by Pyrogasm
Rome may not have been built in a day, but the Romans sure as hell didn't say "look at this great city we built guys!" when they had nothing more than a bit of stone and some cottages.
Pyrogasm is offline   Reply With Quote
Old 01-07-2009, 08:02 AM   #13
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Quote:
Originally Posted by Tide-Arc-Ephemera
Had this been in plain Jass, I'd be using this... EVERYWHERE.
Had you been up to date with WC3 modding, this would be a nonissue.
__________________
Rising_Dusk is offline   Reply With Quote
Old 01-07-2009, 03:43 PM   #14
Tide-Arc Ephemera
Overdoses result in death
 
Tide-Arc Ephemera's Avatar
 
Join Date: Jan 2007
Posts: 2,365

Submissions (3)

Tide-Arc Ephemera is a jewel in the rough (206)Tide-Arc Ephemera is a jewel in the rough (206)Tide-Arc Ephemera is a jewel in the rough (206)

Default

Had I had a job or other source of income and the ability to get my own computer which is suitable for what I need, being 1.2-3 thousand AUD, you'd be right.
__________________
Before asking for help with triggers... read this and check your trigger!

If you're having troubles getting help on WC3C or anywhere at all, please have a look at...
The WRONG way to ask for help and The CORRECT way to ask for help.

Quote:
Originally Posted by Alevice
You may never stop our bioweapon! We mexicans shall rule the third world! Mwahahahahahahaha!
Please acknowledge that I use Mac and avoid suggesting vJass and other tools that don't work on it. Thank you.
Tide-Arc Ephemera is offline   Reply With Quote
Old 01-07-2009, 06:15 PM   #15
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

...Or you could, you know, just compile vJass externally like Pyro does... What a novel idea. Oo
__________________
Rising_Dusk is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 05:43 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services