HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Time Stop

06-19-2006, 08:20 PM#1
Kam
I downloaded this spell from here or wc3sear, but it didn't come with any credit and I don't remember the author. So, I come to you guys again. I noticed that even though this spell has a timer field, it does not employ it. The spell is supposed to stop even if you have mana left after 10/20/30 seconds, but it just goes until the unit runs out of mana. I can't find a problem, so here you go.

Collapse JASS:
//************************************************************************************************************************************
//*
//* Time Stop
//* ¯¯¯¯¯¯¯¯¯
//* Requires:
//*          - The Time Stop Ability (should use the time stop buff)
//*          - The Time Stop Dead Fixer Ability
//*          - The Time Stop Buff 
//*          - The Caster System ( [url]http://vexorian.wc3campaigns.com[/url] )
//*          - This Trigger ( make sure it points to the right rawcodes)
//*
//* Notes:
//*       - The ability's area effect art is scaled according to the configuration section of the
//*         trigger and followes the unit that casts time stop. (recomended the glow model included)
//*       - The ability's target effect is added to the units that get affected by time stop.
//*
//************************************************************************************************************************************

//===================================================================================================
// Time stop configuration:
//
constant function TimeStop_SpellId takes nothing returns integer
    return 'A00F' // TimeStop's ability rawcode
endfunction

constant function TimeStop_BuffId takes nothing returns integer
    return 'B00C' // TimeStop's buff rawcode
endfunction

constant function TimeStop_DeadFixerSpellId takes nothing returns integer
    return 'A00O' // Dead Fixer Ability's Rawcode
endfunction

constant function TimeStop_Duration takes real level returns real
    return 10*level // Duration formula
endfunction

constant function TimeStop_Area takes integer level returns integer
    return 250+75*level // Area formula
endfunction

constant function TimeStop_ScalePerArea takes nothing returns real
    return 0.03 //Scale for the model per area point
endfunction

function TimeStop_Options takes nothing returns integer
    return DontDamageSelf() + DamageFactorAbility1(TimeStop_BuffId(),0)
//
// Don't affect self, and the Time Stop Buff gives immunity against other people using time stop.
// Other options can be used, read the caster system's readme for more info.
//
endfunction

//===================================================================================================
function TimeStop_RemoveFixer takes nothing returns nothing
 local timer t=GetExpiredTimer()
 local unit u=GetAttachedUnit(t,"u")
    call SetWidgetLife(u,1)
    call UnitRemoveAbility(u,TimeStop_DeadFixerSpellId())

    call CleanAttachedVars(t)
    call DestroyTimer(t)
 set t=null
 set u=null
endfunction

function TimeStop_PreventDead takes nothing returns nothing
 local unit u=GetTriggerUnit()
 local timer t
    if (GetWidgetLife(u)-GetEventDamage()<1) then
        set t=CreateTimer()
        if (GetAttachedUnit(u,"TimeStop_Killer")==null) then
            call AttachObject(u,"TimeStop_Killer",GetEventDamageSource())
        endif
        call UnitAddAbility(u,TimeStop_DeadFixerSpellId())
        call SetWidgetLife(u,100000)
        call AttachObject(t,"u",u)
        call TimerStart(t,0,false,function TimeStop_RemoveFixer)
    endif
 set t=null
 set u=null
endfunction

function TimeStop_SetupUnit takes unit u returns nothing
 local trigger t=CreateTrigger()
 local integer s=TimeStop_SpellId()
    call SetUnitTimeScale(u,0)
    call PauseUnit(u,true)
    call TriggerRegisterUnitEvent(t,u,EVENT_UNIT_DAMAGED)
    
    call AttachObject(u,"TimeStop_Trig",t)
    call AttachObject(t,"ac",TriggerAddAction(t,function TimeStop_PreventDead))
    call AttachObject(u,"TimeStop_FX",AddSpellEffectTargetById(s,EFFECT_TYPE_TARGET,u,GetAbilityEffectById(s,EFFECT_TYPE_TARGET,1)))
 set t=null
endfunction

function TimeStop_DestroyTrigger takes unit u returns nothing
 local trigger t=GetAttachedTrigger(u,"TimeStop_Trig")
    call DestroyEffect(GetAttachedEffect(u,"TimeStop_FX"))
    call TriggerRemoveAction(t,GetAttachedTriggerAction(t,"ac"))
    call CleanAttachedVars(t)
    call DestroyTrigger(t)
 set t=null
endfunction
function TimeStop_Stop takes unit u returns nothing
 local integer t=GetAttachedInt(u,"TimeStop_T")+1
    if (t==1) then
        call TimeStop_SetupUnit(u)
    endif
    call AttachInt(u,"TimeStop_T",t)

endfunction

function TimeStop_NoLonger takes unit p returns nothing
 local unit k
 local integer t=GetAttachedInt(p,"TimeStop_T")-1
    call AttachInt(p,"TimeStop_T",t)
    if (t<=0) then
        call PauseUnit(p,false)
        call SetUnitTimeScale(p,1)
        call TimeStop_DestroyTrigger(p)
        set k=GetAttachedUnit(p,"TimeStop_Killer")
        if (k!=null) then
            call DamageUnitByTypes(k,p,GetWidgetLife(p),null,null)
            set k=null
        endif
    endif
endfunction



function TimeStop_End takes group g returns nothing
 local unit p
 local integer t
    loop
        set p=FirstOfGroup(g)
        exitwhen (p==null)
        call TimeStop_NoLonger(p)
        call GroupRemoveUnit(g,p)
    endloop
 set p=null
endfunction


function TimeStop_Enter takes nothing returns nothing
 local unit u=GetTriggerUnit()
 local trigger t=GetTriggeringTrigger()
 local timer x
 local group g

    if (u!=null) and (GetTriggerEventId()!=EVENT_UNIT_ISSUED_ORDER) then
        set g=GetAttachedGroup(t,"g")
        if (GetDamageFactorByOptions(GetAttachedUnit(t,"u"),u,TimeStop_Options())!=0) and not(IsUnitInGroup(u,g)) then
            call TimeStop_Stop(u)
            call GroupAddUnit(g,u)
        endif
        set g=null
    else

        set u=GetAttachedUnit(t,"u")
        if (GetUnitAbilityLevel(u,TimeStop_BuffId())<=0) or (IsUnitHidden(u)) then
            call TimeStop_End(GetAttachedGroup(t,"g"))
            set x=GetAttachedTimer(t,"timer")
            call CleanAttachedVars(x)
            call DestroyTimer(x)
            set x=null
            call DestroyEffect(GetAttachedEffect(t,"fx"))
            call RecicleCasterAfterCastEx(GetAttachedUnit(t,"c"),5,0,false)
            call TriggerRemoveAction(t,GetAttachedTriggerAction(t,"ac"))
            call CleanAttachedVars(t)
            call DestroyTrigger(t)
            call IssueImmediateOrder(u,"unimmolation")
        else
            call SetUnitPosition(GetAttachedUnit(t,"c"),GetUnitX(u),GetUnitY(u))
        endif
    endif
 set t=null
 set u=null

endfunction

function TimeStop_Loop takes nothing returns nothing
 local timer x=GetExpiredTimer()
 local unit u=GetAttachedUnit(x,"u")
 local unit p
 local group a=CreateGroup()
 local group g=GetAttachedGroup(x,"g")
 local real d=GetAttachedReal(x,"r")
    call GroupAddGroup(g,a)
    loop
        set p=FirstOfGroup(a)
        exitwhen (p==null)
        if not(IsUnitInRange(p,u,d)) then
            call TimeStop_NoLonger(p)
            call GroupRemoveUnit(g,p)
        endif
        call GroupRemoveUnit(a,p)
    endloop
    call DestroyGroup(a)
 set g=null
 set p=null
 set a=null
 set u=null
 set x=null
endfunction

function TimeStop_Spell takes nothing returns nothing
 local unit u=GetTriggerUnit()
 local integer s=GetSpellAbilityId()
 local integer l=GetUnitAbilityLevel(u,s)
 local trigger t=CreateTrigger()
 local timer x=CreateTimer()
 local group g=CreateGroup()
 local unit c=GetACaster()
 local real sc=TimeStop_Area(l)*TimeStop_ScalePerArea()
    call SetUnitPosition(c,GetUnitX(u),GetUnitY(u))
    call SetUnitScale(c,sc,sc,sc)

    call AttachObject(t,"fx",AddSpellEffectTargetById(s,EFFECT_TYPE_AREA_EFFECT,c,"origin"))
    call AttachObject(t,"ac",TriggerAddAction(t,function TimeStop_Enter))        
    call AttachObject(t,"c",u)
    call AttachObject(t,"u",u)
    call AttachObject(t,"g",g)
    call AttachInt(t,"l",l)
    call AttachObject(t,"timer",x)
    call AttachObject(t,"c",c)
    call TriggerRegisterTimerEvent(t,0.04,true)
    call TriggerRegisterUnitInRange(t,u,TimeStop_Area(l),null)
    call TriggerRegisterUnitEvent(t,u,EVENT_UNIT_ISSUED_ORDER)
    call AttachObject(x,"g",g)
    call AttachObject(x,"u",u)
    call AttachReal(x,"r",TimeStop_Area(l))
    call TimerStart(x,1,true,function TimeStop_Loop)

 set c=null
 set g=null
 set x=null
 set u=null
endfunction

function TimeStop_Cond takes nothing returns boolean
    return GetSpellAbilityId()==TimeStop_SpellId()
endfunction

//===================================================================================================
function InitTrig_TimeStop takes nothing returns nothing
    set gg_trg_TimeStop = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_TimeStop, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_TimeStop,function TimeStop_Spell)
    call TriggerAddCondition(gg_trg_TimeStop,Condition(function TimeStop_Cond))
endfunction

And yes, I have all the required items the spell lists.
06-19-2006, 08:54 PM#2
Blade.dk
Collapse JASS:
//*          - The Caster System ( [url]http://vexorian.wc3campaigns.com[/url] )

This makes me believe that the author is Vexorian. And you are not very smart for not writing the author down when you downloaded it, no matter if you plan to use it or not

So believing that Vexorian made it (it is his way of creating spells, configuration functions, comments etc.), I'll move it to his forum so he can help you :).
06-19-2006, 09:07 PM#3
Kam
I know, I know.... I'm sorry. But I didn't save the original map, and since the actual spell didn't have a "created by" line... I just wasn't sure. I've downloaded spells with the caster system line in it that weren't created by Vexorian before too.
06-20-2006, 01:55 AM#4
Vexorian
I forgot to remove that config function. The first try on making this spell was to make just use duration, I eventually made it like immolation, so the whole duration thing was not used at all. I forgot to remove the configuration function after making it about immolation.
06-20-2006, 04:32 AM#5
Kam
So what needs to be changed to make it run from the time set?
06-20-2006, 12:48 PM#6
Vexorian
Such a feature has to be added. You can make another trigger order the hero to stop immolation after 10/20/30 seconds the ability is clicked
06-21-2006, 05:57 AM#7
Punisher_x
Thats dumb. Is there any possible way to add it in?
06-21-2006, 12:57 PM#8
Vexorian
Is there really point to do so? Since it is immolation based, If time stop ends because of duration the player can just activate it again.

Also the code is buff based so you can change the base spell to that ability the quill beast have and it will turn time stop into a duration based spell.

Since the quill beast's ability is autocast , you can also use divine shield. Since time stop is time stop, the invulnerability wouldn't matter