• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Timer Not Working

Status
Not open for further replies.
Level 4
Joined
Sep 29, 2004
Messages
52
Hey, finally starting to get used to using JASS instead of GUI. For a game I'm working on, I decided to try and turn one of my old spells into JASS, but I've ran into problem with the JASS Timer not initiating. If someone would kindly take a look at it, I would be greatful and plus rep to them:
JASS:
//############################################################
//  Spell: Philosopher's Stone
//The Alchemist creates a Philosopher stone above his head,
//channeling it for up to 10 seconds.  While channeling 20
//health is drained from every enemy, allowing the stone to
//grow bigger.  Once the channeling is done the Stone explodes
//dealing damage based upon the total health absorbed/1.50.
//############################################################
function Philosopher_Stone_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A070'
endfunction

function Philosopher_Stone_Conditions_Sub2 takes nothing returns boolean
    return ( IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetTriggerPlayer()) == true )
endfunction

//This function makes everyone within a 1000 radius of the Stone
//loose health.  With each health drawn, the stone grows bigger.
function PhilDamage takes nothing returns nothing
    local unit cast2 = GetTriggerUnit()
    local unit temp2
    local group gx = CreateGroup()
    local real x2 = GetUnitX(cast2)
    local real y2 = GetUnitY(cast2)
    local effect se2
    set se2 = AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DeathPact\\DeathPactTarget.mdl",cast2,"chest")
    call DestroyEffect( se2 )
    set se2 = null
    call GroupEnumUnitsInRange(gx,x2,y2, 1000.00,Condition(function Philosopher_Stone_Conditions_Sub2))
    loop
        set temp2 = FirstOfGroup(gx)
        exitwhen temp2 == null
        set udg_PhilosopherSize = (udg_PhilosopherSize + 20.00)
        call UnitDamageTarget(cast2,temp2, 20.00,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_DIVINE,null)
        set se2 = AddSpecialEffectTarget("VampiricAuraTarget.mdx",temp2,"chest")
        call DestroyEffect( se2 )
        set se2 = null
        call SetUnitScale(udg_PhilosopherStone,(udg_PhilosopherSize + 100.00),(udg_PhilosopherSize + 100.00),(udg_PhilosopherSize + 100.00))
        call GroupRemoveUnit(gx,temp2)
    endloop
    call DestroyGroup(gx)
    set temp2 = null
    set cast2 = null
endfunction
        
        
//Philosopher Action allows the Stone to be channeled for up to 10 seconds.
//Once reaching 10 seconds the Stone explodes dealing massive damage,
//based upon the health drained during channel.    
function Philosopher_Stone_Actions takes nothing returns nothing
//########################################################
    local unit cast = GetTriggerUnit()
    local unit temp
    local timer dt = CreateTimer()
    local real x = GetUnitX(cast)
    local real y = GetUnitY(cast)
    local location l = Location(x,y)
    local real a = 0.00
    local integer i = 0
    local group g = CreateGroup()
    local effect se

//########################################################
    set udg_PhilosopherStone = CreateUnit(GetOwningPlayer(cast), 'h01Q',x,y,a)
//For some reason this timer fails to repeat, or event initialize
    call TimerStart(dt,1.00,true,function PhilDamage)
    loop
        exitwhen i == 10
        set i = i + 1
        call TriggerSleepAction(1.00)
        if not IsUnitInRangeLoc(cast,l,0.00) then
            set i = 10
        endif
    endloop
    call GroupEnumUnitsInRange(g,x,y, 1500.00,Condition(function Philosopher_Stone_Conditions_Sub2))
    loop
        set temp = FirstOfGroup(g)
        exitwhen temp == null
        call UnitDamageTarget(cast,temp,(udg_PhilosopherSize/1.50),true, false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_DIVINE,null)
        set se = AddSpecialEffectTarget("Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl",temp,"origin")
        call DestroyEffect( se )
        set se = null
        call GroupRemoveUnit(g,temp)
    endloop
    call RemoveUnit(udg_PhilosopherStone)
    set udg_PhilosopherStone = null
    set udg_PhilosopherSize = 0.00
    call DestroyTimer(dt)
    call RemoveLocation(l)
endfunction

//===========================================================================
function InitTrig_Philosopher_Stone takes nothing returns nothing
    local trigger P = CreateTrigger( )
    call TriggerRegisterAnyUnitEventBJ( P, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(P, Condition(function Philosopher_Stone_Conditions))
    call TriggerAddAction( P, function Philosopher_Stone_Actions )
endfunction
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
You have to null all locals that are handles.

JASS:
type event              extends     handle
type player             extends     handle
type widget             extends     handle
type unit               extends     widget
type destructable       extends     widget
type item               extends     widget
type ability            extends     handle
type buff               extends     ability
type force              extends     handle
type group              extends     handle
type trigger            extends     handle
type triggercondition   extends     handle
type triggeraction      extends     handle
type timer              extends     handle
type location           extends     handle
type region             extends     handle
type rect               extends     handle
type boolexpr           extends     handle
type sound              extends     handle
type conditionfunc      extends     boolexpr
type filterfunc         extends     boolexpr
type unitpool           extends     handle
type itempool           extends     handle
type race               extends     handle
type alliancetype       extends     handle
type racepreference     extends     handle
type gamestate          extends     handle
type igamestate         extends     gamestate
type fgamestate         extends     gamestate
type playerstate        extends     handle
type playerscore        extends     handle
type playergameresult   extends     handle
type unitstate          extends     handle
type aidifficulty       extends     handle

type eventid            extends     handle
type gameevent          extends     eventid
type playerevent        extends     eventid
type playerunitevent    extends     eventid
type unitevent          extends     eventid
type limitop            extends     eventid
type widgetevent        extends     eventid
type dialogevent        extends     eventid
type unittype           extends     handle

type gamespeed          extends     handle
type gamedifficulty     extends     handle
type gametype           extends     handle
type mapflag            extends     handle
type mapvisibility      extends     handle
type mapsetting         extends     handle
type mapdensity         extends     handle
type mapcontrol         extends     handle
type playerslotstate    extends     handle
type volumegroup        extends     handle
type camerafield        extends     handle
type camerasetup        extends     handle
type playercolor        extends     handle
type placement          extends     handle
type startlocprio       extends     handle
type raritycontrol      extends     handle
type blendmode          extends     handle
type texmapflags        extends     handle
type effect             extends     handle
type effecttype         extends     handle
type weathereffect      extends     handle
type terraindeformation extends     handle
type fogstate           extends     handle
type fogmodifier        extends     handle
type dialog             extends     handle
type button             extends     handle
type quest              extends     handle
type questitem          extends     handle
type defeatcondition    extends     handle
type timerdialog        extends     handle
type leaderboard        extends     handle
type multiboard         extends     handle
type multiboarditem     extends     handle
type trackable          extends     handle
type gamecache          extends     handle
type version            extends     handle
type itemtype           extends     handle
type texttag            extends     handle
type attacktype         extends     handle
type damagetype         extends     handle
type weapontype         extends     handle
type soundtype          extends     handle
type lightning          extends     handle
type pathingtype        extends     handle
type image              extends     handle
type ubersplat          extends     handle
 
Status
Not open for further replies.
Top