Return Bug Fix Request :P

INCINERATE

New Member
Reaction score
12
hi , i was wondering if anybody can fix these 2 spells i found on warcraft3campaigns.com .

i have tried my hand at them , i continuously get struct errors .. and all sorts weird errors .. i don't know if to remove all the else ifs .. basically its a complete mess with this return bug tutorial im using from sevion

the first spell is

-Tremor from Tim http://www.wc3c.net/showthread.php?t=84022 (jesp)

the 2nd spell is

-RollingBoulder from Vexorian http://www.wc3c.net/showthread.php?t=82894


anyone? credits and rep of course , thats really all i can offer :rolleyes:
 

INCINERATE

New Member
Reaction score
12
this is the tremor code.can somebody work their magic here, cause im retarded with jass :p



JASS:
//Spell Contest 4 Entry
//Spell: Tremor
//Created by: Tim.
//www.Wc3Campaigns.net


//Below are all the settings you can customize.
function TremorTim_Dummy takes integer i returns integer
    if i == 1 then
        set i = 'h002' //Normal dummy
    elseif i == 2 then
        set i = 'h003' //Special hand dummy
    endif
    return i
endfunction

function TremorTim_SpellID takes integer i returns integer
    if i == 1 then
        set i = 'A000' //Your dummy spell
    elseif i == 2 then
        set i = 'A000' //Reserved
    elseif i == 3 then
        set i = 'A002' //Your stun ability (Impale based)
    elseif i == 4 then
        set i = 'B001' //Your stunned buff (Impale based)
    endif
    return i
endfunction

function TremorTim_Real takes integer i returns real
    if i == 1 then
        return 50.00 //Damage on the charge (10xSpell's Level will be added to this value)
    elseif i == 2 then
        return 100.00 //AoE Slam Damage below the palm (10xSpell's Level will be added to this value)
    elseif i == 3 then
        return 25.00 //Damage in the area of the final ripple (10xSpell's Level will be added to this value)
    elseif i == 4 then
        return 4.00 //Time in seconds for the stuns (1 second per level is added to this value)
    endif
    return 0.00 //Nothing goes here, just leave it
endfunction

function TremorTim_String takes integer i returns string
    if i == 1 then
        return "Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl" //Effect played as bump moves through the ground
    elseif i == 2 then
        return "origin" //This is the attachment point of your dummy unit
    elseif i == 3 then
        return "war3mapImported\\SanExplosion2.mdx" //Effect played on impact of the hand
    elseif i == 4 then
        return "war3mapImported\\ImpaleHitTarget.mdx" //Effect used by the Variable Stun's buff
    endif
    return null
endfunction

function TremorTim_Gamecache takes nothing returns gamecache
    return udg_AbilityCache //This is your global cache you are using
endfunction

//End customization functions

function TremorTim_Blood takes unit u returns string
    local race r = GetUnitRace(u)
    local string s
    local integer i
    if r == RACE_HUMAN then
        set s = "Objects\\spawnmodels\\Human\\HumanLargeDeathExplode\\HumanLargeDeathExplode.mdl"
    elseif r == RACE_NIGHTELF then
        set s = "Objects\\Spawnmodels\\NightElf\\NightElfLargeDeathExplode\\NightElfLargeDeathExplode.mdl"
    elseif r == RACE_ORC then
        set s = "Objects\\Spawnmodels\\Orc\\OrcLargeDeathExplode\\OrcLargeDeathExplode.mdl"
    elseif r == RACE_UNDEAD then
        set s = "Objects\\Spawnmodels\\Undead\\UndeadLargeDeathExplode\\UndeadLargeDeathExplode.mdl"
    elseif r == RACE_DEMON then
        set s = "Objects\\Spawnmodels\\Demon\\DemonLargeDeathExplode\\DemonLargeDeathExplode.mdl"
    elseif r == RACE_OTHER then
        set i = GetRandomInt(1,3)
        if i == 1 then
            set s = "Objects\\spawnmodels\\Human\\HumanLargeDeathExplode\\HumanLargeDeathExplode.mdl"
        elseif i == 2 then
            set s = "Objects\\Spawnmodels\\NightElf\\NightElfLargeDeathExplode\\NightElfLargeDeathExplode.mdl"
        elseif i == 3 then
            set s = "Objects\\Spawnmodels\\Orc\\OrcLargeDeathExplode\\OrcLargeDeathExplode.mdl"
        endif
    else
        set s = "Objects\\spawnmodels\\Human\\HumanLargeDeathExplode\\HumanLargeDeathExplode.mdl"   
    endif
    return s
endfunction

function TremorTim_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

/////////////////////////////////////////////////////////////////
//Modified Variable Stun System with permission from blu_da_noob/
//Created by blu_da_noob modoified by Tim.///////////////////////
//http://www.wc3campaigns.net/showthread.php?t=83383/////////////
/////////////////////////////////////////////////////////////////

function TremorTim_Cache takes nothing returns gamecache
    return TremorTim_Gamecache()
endfunction

function TremorTim_MinimumStunDuration takes nothing returns real
    return 0.2 //Do not modify
endfunction

function TremorTim_GetUnit takes string mission, string key returns unit
    return GetStoredInteger(TremorTim_Cache(),mission,key)
    return null
endfunction

function TremorTim_GetTimer takes string mission, string key returns timer
    return GetStoredInteger(TremorTim_Cache(),mission,key)
    return null
endfunction

function TremorTim_GetGroup takes string mission, string key returns group
    return GetStoredInteger(TremorTim_Cache(),mission,key)
    return null
endfunction

function TremorTim_GetStunDummy takes unit target returns unit
    local gamecache gc = TremorTim_Cache()
    local group g
    local unit dummy
    local integer temp
    
    set g = TremorTim_GetGroup("CustomStunSystem","StunDummyGroup")
    if g == null then
        set g = CreateGroup()
        call StoreInteger(gc,"CustomStunSystem","StunDummyGroup",H2I(g))    
    endif
    set dummy = FirstOfGroup(g)
    if dummy == null then
        set dummy = CreateUnit(GetOwningPlayer(target),TremorTim_Dummy(1),GetUnitX(target),GetUnitY(target),0)
    else
        call SetUnitX(dummy,GetUnitX(target))
        call SetUnitY(dummy,GetUnitY(target))
        call SetUnitOwner(dummy,GetOwningPlayer(target),false)
        call GroupRemoveUnit(g,dummy)
    endif
    call UnitAddAbility(dummy,'Aloc')
    call UnitAddAbility(dummy,TremorTim_SpellID(3))
    
    set temp = H2I(dummy)
    set gc = null
    set g = null
    set dummy = null
    return temp
    return null
endfunction

function TremorTim_ReturnStunDummy takes nothing returns nothing
    local unit dummy = bj_groupRandomCurrentPick
    call TriggerSleepAction(10)
    call GroupAddUnit(TremorTim_GetGroup("CustomStunSystem","StunDummyGroup"),dummy)
    set dummy = null
endfunction

function TremorTim_RemoveUnitStun takes unit u returns boolean
    return UnitRemoveAbility(u,TremorTim_SpellID(4))
endfunction

function TremorTim_TimedRemoveStun takes nothing returns nothing
    local string timertable
    local unit target
    local string targettable
    local gamecache gc = TremorTim_Cache()
    
    set bj_crippledTimer[21] = GetExpiredTimer()
    set timertable = I2S(H2I(bj_crippledTimer[21]))
    set target = TremorTim_GetUnit(timertable,"stuntarget")
    set targettable = I2S(H2I(target))
    
    call UnitRemoveAbility(target,TremorTim_SpellID(4))
    
    call FlushStoredMission(gc,timertable)
    call DestroyTimer(bj_crippledTimer[21])
    call FlushStoredInteger(gc,targettable,"stuntimer")
     
    set target = null
    set gc = null
endfunction

function TremorTim_StunUnit takes unit target, real duration, boolean ignoremagicimmunity returns boolean
    local boolean immune = IsUnitType(target,UNIT_TYPE_MAGIC_IMMUNE)
    local boolean stun = (not immune) or ignoremagicimmunity
    local unit dummy
    local string targettable
    local string timertable
    local gamecache gc 
    
    if stun then
        set dummy = TremorTim_GetStunDummy(target)
        set stun = IssueTargetOrder(dummy,"impale",target)
        if stun then
            set gc = TremorTim_Cache()
            set duration = RMaxBJ(duration,TremorTim_MinimumStunDuration())
            set targettable = I2S(H2I(target))
            set bj_crippledTimer[21] = TremorTim_GetTimer(targettable,"stuntimer")
            if bj_crippledTimer[21] == null then
                set bj_crippledTimer[21] = CreateTimer()
                call StoreInteger(gc,targettable,"stuntimer",H2I(bj_crippledTimer[21]))
            endif
            set timertable = I2S(H2I(bj_crippledTimer[21]))
            call StoreInteger(gc,timertable,"stuntarget",H2I(target))
            call TimerStart(bj_crippledTimer[21],RMaxBJ(duration,TimerGetRemaining(bj_crippledTimer[21])),false,function TremorTim_TimedRemoveStun) 
        endif
        set bj_groupRandomCurrentPick = dummy
        call ExecuteFunc("TremorTim_ReturnStunDummy")    
    endif
    
    set dummy = null
    set gc = null
    return stun
endfunction

/////////////////////////////////////////////////////////////////
//End of the Variable Stun System////////////////////////////////
/////////////////////////////////////////////////////////////////

function TremorTim_Finale takes nothing returns nothing
    local gamecache gc = TremorTim_Gamecache()
    local timer t = GetExpiredTimer()
    local string s = I2S(H2I(t))
    local unit c = I2U(GetStoredInteger(gc, s, "c"))
    call SelectUnitAddForPlayer(c, GetOwningPlayer(c))
    call SetUnitTimeScale(c, -1)
    call TriggerSleepAction (3.2)
    call SetUnitTimeScale(c, 1)
    call SetUnitAnimation(c, "stand")
    call PauseUnit(c, false)
    call SetUnitInvulnerable(c, false)
    set gc = null
    set c = null
    call PauseTimer(t)
    call DestroyTimer(t)
    set t = null
endfunction

function TremorTim_Timer takes nothing returns nothing
    local gamecache gc = TremorTim_Gamecache()
    local string s = I2S(H2I(GetExpiredTimer()))
    local unit c = I2U(GetStoredInteger(gc, s, "c"))
    local player pc = GetOwningPlayer(c)
    local unit t = I2U(GetStoredInteger(gc, s, "t"))
    local integer l = GetStoredInteger(gc, s, "l")
    local integer hide = GetStoredInteger(gc, s, "h")
    local integer stg = GetStoredInteger(gc, s, "s")
    local real a = GetStoredReal(gc, s, "a")
    local real x = GetStoredReal(gc, s, "bx")
    local real y = GetStoredReal(gc, s, "by")
    local real dx
    local real dy
    local integer z = GetStoredInteger(gc, s, "z")
    local integer s2 = GetStoredInteger(gc, s, "s2")
    local integer en = GetStoredInteger(gc, s, "en")
    local group g = CreateGroup()
    local group g2 = I2G(GetStoredInteger(gc, s, "g2"))
    local unit f
    local integer dn = GetStoredInteger(gc, s, "dn")
    local real r = GetStoredReal(gc, s, "r")
    if stg == 1 then //Stage 1:1
        if s2 == 0 then
            set dx = GetUnitX(t) - x
            set dy = GetUnitY(t) - y
            if dx*dx + dy*dy > 2500 then
                //Move mound to unit
                call StoreInteger(gc, s, "d" + I2S(dn), H2I(TerrainDeformCrater(x, y, 70, -40, 600, false)))
                call StoreInteger(gc, s, "dn", dn + 1)
                call GroupEnumUnitsInRange(g, x, y, 80, null)
                loop
                    set f = FirstOfGroup(g)
                    exitwhen f == null
                    if GetUnitState(f, UNIT_STATE_LIFE) > 0.405 and IsUnitEnemy( f, pc) and not IsUnitType(f, UNIT_TYPE_FLYING) and not IsUnitInGroup(f, g2) then
                        call UnitDamageTarget(c, f, TremorTim_Real(1) + 10*l, true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)
                        call TremorTim_RemoveUnitStun(f)
                        call TremorTim_StunUnit(f, TremorTim_Real(4) + l, true)
                        call GroupAddUnit(g2, f)
                    endif
                    call GroupRemoveUnit(g, f)
                endloop
                set a = Atan2(dy, dx)
                call StoreReal(gc, s, "a", a)
                call StoreReal(gc, s, "bx", x + 40 * Cos(a))
                call StoreReal(gc, s, "by", y + 40 * Sin(a))
                call StoreInteger(gc, s, "e" + I2S(en), H2I(AddSpecialEffect(TremorTim_String(1), x, y)))
                call StoreInteger(gc, s, "en", en + 1)
            else
                //Stun the target and go to Stage 1:2
                call TremorTim_RemoveUnitStun(t)
                call TremorTim_StunUnit(t, 4.00, true)
                call StoreReal(gc, s, "x2",  GetUnitX(t) + Cos(a) * 700)
                call StoreReal(gc, s, "y2",  GetUnitY(t) + Sin(a) * 700)
                call StoreReal(gc, s, "ca", Cos(a))
                call StoreReal(gc, s, "sa", Sin(a))
                call StoreInteger(gc, s, "s2", 1)
            endif
            elseif s2 == 1 then //Stage 1:2
            //Move 500 past target
            set dx = GetStoredReal(gc, s, "x2") - x
            set dy = GetStoredReal(gc, s, "y2") - y
            if dx*dx + dy*dy > 2500 then   
                call StoreInteger(gc, s, "d" + I2S(dn), H2I(TerrainDeformCrater(x, y, 70, -40, 600, false)))
                call StoreInteger(gc, s, "dn", dn + 1)
                call GroupEnumUnitsInRange(g, x, y, 80, null)
                loop
                    set f = FirstOfGroup(g)
                    exitwhen f == null
                    if GetUnitState(f, UNIT_STATE_LIFE) > 0.405 and IsUnitEnemy( f, pc) and not IsUnitType(f, UNIT_TYPE_FLYING) and not IsUnitInGroup(f, g2) then
                        call UnitDamageTarget(c, f, TremorTim_Real(1) + 10*l, true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)
                        call TremorTim_RemoveUnitStun(f)
                        call TremorTim_StunUnit(f, TremorTim_Real(4) + l, true)
                        call GroupAddUnit(g2, f)
                    endif
                    call GroupRemoveUnit(g, f)
                endloop
                call StoreReal(gc, s, "bx", x + 40 * GetStoredReal(gc, s, "ca"))
                call StoreReal(gc, s, "by", y + 40 * GetStoredReal(gc, s, "sa"))
                call StoreInteger(gc, s, "e" + I2S(en), H2I(AddSpecialEffect(TremorTim_String(1), x, y)))
                call StoreInteger(gc, s, "en", en + 1)
            else
                //500 offset reached, on to Stage 2
                set x = GetUnitX(t)
                set y = GetUnitY(t)
                set dx = GetUnitX(c) - x
                set dy = GetUnitY(c) - y
                set a = Atan2(dy, dx)
                call StoreInteger(gc, s, "dh", H2I(CreateUnit(pc, TremorTim_Dummy(2), x, y, a * 57.2958)))
                call StoreReal(gc, s, "bx", x)
                call StoreReal(gc, s, "by", y)
                call StoreReal(gc, s, "a", 30)
                call StoreInteger(gc, s, "s", 2)
                call GroupClear(g2)
            endif
        endif        
    elseif stg == 2 then    
        if a <= 0 then
            //We have hand impact!
            call DestroyEffect(AddSpecialEffect(TremorTim_String(3), x, y))
            call DestroyEffect(AddSpecialEffect(TremorTim_String(3), x, y))
            call StoreInteger(gc, s, "d" + I2S(dn), H2I(TerrainDeformRipple(GetUnitX(t), GetUnitY(t), 512, 128, 2000, 1, 1.00, 1.50, 3.125, false)))
            call StoreInteger(gc, s, "dn", dn + 1)
            call StoreInteger(gc, s, "s", 3)
            call StoreReal(gc, s, "a", 30)
            call GroupEnumUnitsInRange(g, x, y, 128, null)
            //Smash units under palm
            loop
                set f = FirstOfGroup(g)
                exitwhen f == null
                if GetUnitState(f, UNIT_STATE_LIFE) > 0.405 and IsUnitEnemy( f, pc) and not IsUnitType(f, UNIT_TYPE_FLYING) then
                    call UnitDamageTarget(c, f, TremorTim_Real(2) + 10*l, true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)
                    call DestroyEffect(AddSpecialEffectTarget(TremorTim_Blood(f), f, TremorTim_String(2))) 
                endif
                call GroupRemoveUnit(g, f)
            endloop
        else
            //Subtract 1
            call StoreReal(gc, s, "a", a - 1)
        endif
    elseif stg == 3 then    
        if a <= 0 then
            //End of the ripple!
            call StoreInteger(gc, s, "s", 4)
        else
            //Knock units in an expanding ring
            call GroupEnumUnitsInRange(g, x, y, r, null)
            loop
                set f = FirstOfGroup(g)
                exitwhen f == null
                if GetUnitState(f, UNIT_STATE_LIFE) > 0.405 and IsUnitEnemy( f, pc) and not IsUnitType(f, UNIT_TYPE_FLYING) and not IsUnitInGroup(f, g2) then
                    call UnitDamageTarget(c, f, TremorTim_Real(3) + 10*l, true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)
                    call TremorTim_RemoveUnitStun(f)
                    call TremorTim_StunUnit(f, TremorTim_Real(4) + l, true)
                    call GroupAddUnit(g2, f)
                endif
                call GroupRemoveUnit(g, f)
            endloop
            //Subtract 1
            call StoreReal(gc, s, "r", r + 10)
            call StoreReal(gc, s, "a", a - 1)
        endif
    elseif stg == 4 then
        //Being hero back and clean up
        call ExecuteFunc("TremorTim_Finale")
        call RemoveUnit(I2U(GetStoredInteger(gc, s, "dh")))
        set en = en - 1
        loop
            exitwhen en <= 0
            call DestroyEffect(I2E(GetStoredInteger(gc, s, "e" + I2S(en))))
            set en = en - 1
        endloop
        set dn = dn - 1
        loop
            exitwhen dn <= 0
            call TerrainDeformStop(I2TD(GetStoredInteger(gc, s, "d" + I2S(dn))), 5000)
            set dn = dn - 1
        endloop
        call DestroyGroup(g2)
        call FlushStoredMission(gc, s)
        call DestroyTimer(GetExpiredTimer())
    endif
    set gc = null
    set c = null
    set t = null
    call DestroyGroup(g)
    set g = null
    set g2 = null
    set f = null
endfunction

function TremorTim_Begin takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local gamecache gc = TremorTim_Gamecache()
    local string s = I2S(H2I(t))
    local unit c = I2U(GetStoredInteger(gc, s, "c"))
    call SetUnitTimeScale(c, 0)
    call TimerStart(t, 0.04, true, function TremorTim_Timer)
    set gc = null
    set c = null
    set t = null
endfunction

function TremorTim_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local gamecache gc = TremorTim_Gamecache()
    local string s = I2S(H2I(t))
    local unit c = GetTriggerUnit()
    call StoreInteger(gc, s, "l", GetUnitAbilityLevel(c, TremorTim_SpellID(1)))
    call StoreInteger(gc, s, "g2", H2I(CreateGroup()))
    call StoreInteger(gc, s, "c", H2I(c))
    call StoreInteger(gc, s, "t", H2I(GetSpellTargetUnit()))
    call StoreInteger(gc, s, "s", 1)
    call StoreReal(gc, s, "bx", GetUnitX(c))
    call StoreReal(gc, s, "by", GetUnitY(c))
    call StoreInteger(gc, s, "z", 40)
    call StoreInteger(gc, s, "h", 255)
    call PauseUnit(c, true)
    call SetUnitInvulnerable(c, true)
    call TriggerSleepAction (0.00)
    call SetUnitTimeScale(c, 2 )
    call SetUnitAnimation(c, "death")
    call TimerStart(t, 1.7, false, function TremorTim_Begin)
    set c = null
    set gc = null
    set t = null
endfunction

//===========================================================================
function InitTrig_TremorTim takes nothing returns nothing
    set gg_trg_TremorTim = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_TremorTim, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_TremorTim, Condition( function TremorTim_Conditions ) )
    call TriggerAddAction( gg_trg_TremorTim, function TremorTim_Actions )
    call RemoveUnit(CreateUnit(Player(15), TremorTim_Dummy(1), 0, 0, 0))
    call RemoveUnit(CreateUnit(Player(15), TremorTim_Dummy(2), 0, 0, 0))
    call Preload(TremorTim_String(1))
    call Preload(TremorTim_String(3))
    call Preload(TremorTim_String(4))
    call Preload("Objects\\spawnmodels\\Human\\HumanLargeDeathExplode\\HumanLargeDeathExplode.mdl")
    call Preload("Objects\\Spawnmodels\\NightElf\\NightElfLargeDeathExplode\\NightElfLargeDeathExplode.mdl")
    call Preload("Objects\\Spawnmodels\\Orc\\OrcLargeDeathExplode\\OrcLargeDeathExplode.mdl")
    call Preload("Objects\\Spawnmodels\\Undead\\UndeadLargeDeathExplode\\UndeadLargeDeathExplode.mdl")
    call Preload("Objects\\Spawnmodels\\Demon\\DemonLargeDeathExplode\\DemonLargeDeathExplode.mdl")
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top