• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Time Lapse v1.4b

What does it do?
This ability allows the caster to return/teleport back to it's condition within several seconds ago which is configurable.

JASS:
//==========================================================================================
//====================================CONFIGURATION=========================================

    // The main ability raw code
    constant function TL_SpellID takes nothing returns integer
        return 'A000'
    endfunction
    
    // Length of rewind time per level
    constant function TL_Time takes integer level returns real
        
        if level == 1 then
            return 6.0          // Level 1
        elseif level == 2 then
            return 6.0          // Level 2
        else
            return 6.0          // Level 3
        endif
        
    endfunction
    
    // Sfx created at the cast point
    constant function TL_CastSfx takes nothing returns string
        return "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl"
    endfunction
    
    // Sfx created at the target point
    constant function TL_TargetSfx takes nothing returns string
        return "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdl"
    endfunction
    
    // How often the Hero's states will be saved
    constant function TL_Accuracy takes nothing returns real
        return 0.25
    endfunction
    
//=====================================END OF CONFIGURATION=================================
//==========================================================================================
 
    function SaveNode takes nothing returns nothing
        
        local unit      u       = GetEnumUnit()
        local integer   dex
        local integer   node
        local integer   i
        local integer   c
        local real      l
        
        if GetUnitTypeId(u) != 0 then
            set l = GetWidgetLife(u)
            if l > 0.405 then
                set dex = GetHandleId(u)
                set node = R2I(TL_Time(LoadInteger(udg_TL_Hashtable, dex, -2)) / TL_Accuracy())
                set i = node
                loop
                    call SaveReal(udg_TL_Hashtable, dex, i, LoadReal(udg_TL_Hashtable, dex, i - 1))
                    call SaveReal(udg_TL_Hashtable, dex, i + node , LoadReal(udg_TL_Hashtable, dex, i + node - 1))
                    call SaveReal(udg_TL_Hashtable, dex, i + node * 2 , LoadReal(udg_TL_Hashtable, dex, i + node * 2 - 1))
                    call SaveReal(udg_TL_Hashtable, dex, i + node * 3 , LoadReal(udg_TL_Hashtable, dex, i + node * 3 - 1))
                    call SaveReal(udg_TL_Hashtable, dex, i + node * 4 , LoadReal(udg_TL_Hashtable, dex, i + node * 4 - 1))
                    set i = i - 1
                    exitwhen i == 1
                endloop
                call SaveReal(udg_TL_Hashtable, dex, 1, l)
                call SaveReal(udg_TL_Hashtable, dex, 1 + node, GetUnitState(u, UNIT_STATE_MANA))
                call SaveReal(udg_TL_Hashtable, dex, 1 + 2 * node, GetUnitFacing(u))
                call SaveReal(udg_TL_Hashtable, dex, 1 + 3 * node, GetUnitX(u))
                call SaveReal(udg_TL_Hashtable, dex, 1 + 4 * node, GetUnitY(u))
                call SaveInteger(udg_TL_Hashtable, dex, -1, LoadInteger(udg_TL_Hashtable, dex, -1) + 1)
            else
                call FlushChildHashtable(udg_TL_Hashtable,dex)
                call SaveInteger(udg_TL_Hashtable, dex, -1, 0)
            endif
        else
            call GroupRemoveUnit(udg_TL_Group, u)
            call FlushChildHashtable(udg_TL_Hashtable,dex)
            set c = LoadInteger(udg_TL_Hashtable, -1, 999) - 1
            call SaveInteger(udg_TL_Hashtable, -1, 999, c)
            if c == 0 then
                call PauseTimer(udg_TL_Timer)
            endif
        endif
        set u = null
        
    endfunction

    function TL_Loop takes nothing returns nothing
        call ForGroup(udg_TL_Group, function SaveNode)
    endfunction

    function learn takes nothing returns boolean

        local integer   i
        local integer   c
        local integer   lv
        local integer   ln = GetLearnedSkill()
        local unit      u
        
        if ln == TL_SpellID() then
            set u = GetTriggerUnit()
            set lv = GetUnitAbilityLevel(u, ln)
            if not IsUnitInGroup(u, udg_TL_Group) then
                set i = GetHandleId(u)
                set c = LoadInteger(udg_TL_Hashtable, -1, 999) + 1
                call SaveInteger(udg_TL_Hashtable, -1, 999, c)
                call SaveInteger(udg_TL_Hashtable, i, -1, 0)
                call SaveInteger(udg_TL_Hashtable, i, -2, lv)
                call GroupAddUnit(udg_TL_Group, u)
                if c == 1 then
                    call TimerStart(udg_TL_Timer, TL_Accuracy(), true, function TL_Loop)
                endif
            endif
            set u = null
        endif
        return false
    endfunction

    function cast takes nothing returns boolean

        local integer   dex
        local integer   node
        local integer   total
        local unit      caster
        local real      x
        local real      y
        
        if GetSpellAbilityId() == TL_SpellID() then
            set caster = GetTriggerUnit()
            if IsUnitInGroup(caster, udg_TL_Group) then
                set dex = GetHandleId(caster)
                set node = R2I(TL_Time(LoadInteger(udg_TL_Hashtable, dex, -2)) / TL_Accuracy())
                set total = LoadInteger(udg_TL_Hashtable, dex, -1)
                if total > 0 then
                    call DestroyEffect(AddSpecialEffect(TL_CastSfx(), GetUnitX(caster), GetUnitY(caster)))
                    if total >= node then
                        call SetWidgetLife(caster,LoadReal(udg_TL_Hashtable, dex, node))
                        call SetUnitState(caster, UNIT_STATE_MANA, LoadReal(udg_TL_Hashtable, dex, 2 * node))
                        call SetUnitFacing(caster, LoadReal(udg_TL_Hashtable, dex, 3 * node))
                        set x = LoadReal(udg_TL_Hashtable, dex, 4 * node)
                        set y = LoadReal(udg_TL_Hashtable, dex, 5 * node)
                        call SetUnitX(caster, x)
                        call SetUnitY(caster, y)
                    else
                        call SetWidgetLife(caster,LoadReal(udg_TL_Hashtable, dex, total))
                        call SetUnitState(caster, UNIT_STATE_MANA, LoadReal(udg_TL_Hashtable, dex, total + node))
                        call SetUnitFacing(caster, LoadReal(udg_TL_Hashtable, dex, total + node * 2))
                        set x = LoadReal(udg_TL_Hashtable, dex, total + node * 3)
                        set y = LoadReal(udg_TL_Hashtable, dex, total + node * 4)
                        call SetUnitX(caster, x)
                        call SetUnitY(caster, y)
                    endif
                    call DestroyEffect(AddSpecialEffect(TL_TargetSfx(), x, y))
                    call FlushChildHashtable(udg_TL_Hashtable, dex)
                    call SaveInteger(udg_TL_Hashtable, dex, -1, 0)
                else
                    call IssueImmediateOrder(caster, "stop")
                endif
            endif
            set caster = null
        endif
        return false
    endfunction

    function InitTrig_Time_Lapse takes nothing returns nothing
        local trigger t1    = CreateTrigger()
        local trigger t2    = CreateTrigger()
        local integer i     = 0
        
        set udg_TL_Hashtable = InitHashtable()
        loop
            call TriggerRegisterPlayerUnitEvent(t1, Player(i), EVENT_PLAYER_HERO_SKILL, null)
            call TriggerRegisterPlayerUnitEvent(t2, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
            set i = i + 1
            exitwhen i == bj_MAX_PLAYER_SLOTS
        endloop
        call SaveInteger(udg_TL_Hashtable, -1, 999, 0)
        call TriggerAddCondition(t1, Condition(function learn))
        call TriggerAddCondition(t2, Condition(function cast))
        set t1 = null
        set t2 = null
    endfunction

Keywords:
time, lapse, dota, anub'seran
Contents

TimeLapse JASS (Map)

Reviews
BPower 19th Feb 2014 Approved. You can find the full review here 14:46, 11th Feb 2014 BPower: Use a hashtable, a queue, anything ... but not substrings.

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
Nothing. This has just revived. I'm going to update it anyway since I have something new to offer (to make it a bit different from Bribe's retro system).

..... said:
Thnks, may i ask you something? Once i saw a spell without any variable, how can i do that? Or i was just misremembered?

Values like mana, life, facing can easily be stored into real arrays, why do you use strings?
it's because each hero need to save 1 value per TL_Accuracy, I guess using hashtable the spell will be so much simpler, and I don't like simple :ogre_hurrhurr:
Uh, I was so cute :3
 
Top