• Check out the results of the Techtree Contest #19!
  • 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 void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] HandleVars Coding Problem

Status
Not open for further replies.

SpikyThunderX

S

SpikyThunderX

JASS:
//*************************************************************
//* Constant Functions (Only edit things under this section.) *
//*************************************************************
constant function FW_Raw_Code takes nothing returns integer
  return 'A003'
endfunction

//**************
//* Conditions *
//**************

function FW_Spell_Check takes nothing returns boolean
  return GetSpellAbilityId() == FW_Raw_Code()
endfunction

//*************
//* Functions *
//*************

function FW_Dash takes nothing returns nothing
  //Local Varibles and Handles
    local timer dashtimer = GetExpiredTimer()
    local unit caster = GetHandleUnit(dashtimer, "caster")
    local location casterpos = GetUnitLoc(caster)
    local real xtarget = GetHandleReal(dashtimer, "xtarget")
    local real ytarget = GetHandleReal(dashtimer, "ytarget")
    local location targetpoint = Location(xtarget, ytarget)
    local real angle = AngleBetweenPoints(casterpos,targetpoint)
    
  //Functions
    if DistanceBetweenPoints(casterpos,targetpoint) != 0 then
      call SetUnitPositionLoc(caster, PolarProjectionBJ(casterpos, 50.00, angle))
    else
      call PauseUnit(caster, false)
      call ResetUnitAnimation(caster)
    endif
    
  //Null Variables
    set caster = null
    call RemoveLocation(casterpos)
    call RemoveLocation(targetpoint)
    set casterpos = null
    set targetpoint = null   
endfunction

function FW_Spell takes nothing returns nothing
  //Local Variables
    local unit caster = GetTriggerUnit()
    local timer dashtimer = CreateTimer()
    local location targetpoint = GetSpellTargetLoc()
    local real xtarget = GetLocationX(targetpoint)
    local real ytarget = GetLocationY(targetpoint)
  
  //Handles
    call SetHandleHandle(dashtimer, "caster", caster)
    call SetHandleReal(dashtimer, "xtarget", xtarget)
    call SetHandleHandle(dashtimer, "ytarget", ytarget)
    
  //Functions
    call PauseUnit(caster, true)
    call SetUnitAnimation(caster, "attack")
    call TimerStart(dashtimer, 0.035, true, function FW_Dash)
    
  //Null Variables
    call DestroyTimer(dashtimer)
    set dashtimer = null
    call FlushLocalHandles(dashtimer)
    set caster = null
    call RemoveLocation(targetpoint)
endfunction

//===========================================================================
function InitTrig_Flame_Walk takes nothing returns nothing
local integer i
    set i = 0
    set gg_trg_Flame_Walk = CreateTrigger(  )
    loop
      exitwhen i>12
      call TriggerRegisterPlayerUnitEventSimple( gg_trg_Flame_Walk, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT)
      set i = i + 1
    endloop
    call TriggerAddCondition( gg_trg_Flame_Walk, Condition(function FW_Spell_Check))    
    call TriggerAddAction( gg_trg_Flame_Walk, function FW_Spell )  
endfunction

I am using the HandleVars system and it's imported correctly. But when I try to save the map, it gives me these errors (two pictures):

error1jw9.png


error2kf8.png


Does anyone have any clue what's happening? And will this script work? Please help me correct my mistakes, I'm quite new to JASS.

Thanks in advanced.

~Spiky
 
You have to understand that most of the times stupid WE sintax checker shows the line below of the actual error line. So the real line is:

JASS:
call SetHandleHandle(dashtimer, "ytarget", ytarget)

When it should be:

JASS:
call SetHandleReal(dashtimer, "ytarget", ytarget)

Second one is that you named the function wrong, not FlushLocalHandles, but FlushHandleLocals.

Now, few corrections:

JASS:
call DestroyTimer(dashtimer)
set dashtimer = null
call FlushLocalHandles(dashtimer)
set caster = null
call RemoveLocation(targetpoint)

What did you do here? Why did you destroy the timer? This timer will do nothing because you destroyed it instantly. Also don't forget to null targetpoint as well. One more tip: always null on the end of the function.

EDIT: Well you could at least say something, I hate when I help someone and he never says anything
 
Last edited by a moderator:
Status
Not open for further replies.
Back
Top