• 🏆 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!

[Solved] Parse error !

Status
Not open for further replies.
Level 13
Joined
Mar 29, 2012
Messages
530
I was making a spell named "Knives Attack" (is that cool for you ??)

Here is the codes :
JASS:
constant function KA_Ability takes nothing returns integer
    return 'A00K'
endfunction

constant function KA_Dummy_Type takes nothing returns integer
    return 'u001'
endfunction

constant function KA_Interval takes nothing returns real
    return 0.03
endfunction

constant function KA_Hit_Effect takes nothing returns string
    return "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl"
endfunction

constant function KA_Piercing takes nothing returns boolean
    return true
endfunction

constant function KA_Attack_Type takes nothing returns attacktype
    return ATTACK_TYPE_PIERCE
endfunction

constant function KA_Damage_Type takes nothing returns damagetype
    return DAMAGE_TYPE_NORMAL
endfunction

function KA_Level takes unit u returns integer
    return GetUnitAbilityLevel(u, KA_Ability)
endfunction

function KA_Distance takes nothing returns real
    return 600.00
endfunction

function KA_Speed takes nothing returns real
    return KA_Interval * 1500.00
endfunction

function KA_Damage takes integer i returns real
    return 35.00 + (15.00 * I2R(i))
endfunction

function KA_Collision takes nothing returns real
    return 50.00
endfunction

function KA_Count takes integer i returns integer
    return (i + 1) * 5
endfunction

function KA_Scale_Size takes nothing returns real
    return 100.00
endfunction

function KA_Fly_Height takes nothing returns real
    return 50.00
endfunction

function KA_Cast_Conditions takes nothing returns boolean
    if (GetSpellAbilityId() == KA_Ability) then
        return true
    endif
    return false
endfunction

function KA_Cast_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local player owner = GetTriggerPlayer()
    local integer level = KA_Level(caster)
    local real distance = KA_Distance()
    local integer count = KA_Count(level)
    local real scalesize = KA_Scale_Size()
    local real flyheight = KA_Fly_Height()
    local location l = GetUnitLoc(caster)
    local integer handleid
    local unit dummy
    local real angle = GetRandomDirectionDeg()
    local integer i = 1
    loop
        exitwhen i >= count
        set dummy = CreateUnitAtLoc(owner, KA_Dummy_Type, l, (I2R(i) * angle) + 360.00)
        call SetUnitScalePercent(dummy, scalesize, scalesize, scalesize)
        call SetUnitFlyHeight(dummy, flyheight, 0)
        set handleid = GetHandleId(dummy)
        call SavePlayerHandle(udg_KA_Hashtable, StringHash("owner"), handleid, owner)
        call SaveInteger(udg_KA_Hashtable, StringHash("level"), handleid, level)
        call SaveReal(udg_KA_Hashtable, StringHash("distance"), handleid, distance)
        call GroupAddUnit(udg_KA_Group, dummy)
        set i = i + 1
    endloop
    set caster = null
    set owner = null
    set dummy = null
    call RemoveLocation(l)
    if (IsTriggerEnabled(udg_KA_Loop) == false) then
        call EnableTrigger(udg_KA_Loop)
    endif
endfunction

function KA_Group_Actions takes nothing returns nothing
    local unit pickedunit = GetEnumUnit()
    local integer handleid = GetHandleId(pickedunit)
    local location unitloc
    local real array r
    local real speed = KA_Speed()
    local real angle = GetUnitFacing(pickedunit)
    local real distance = LoadReal(udg_KA_Hashtable, StringHash("distance"), handleid)
    if (distance > 0.00) then
        set r[1] = GetUnitX(pickedunit)
        set r[2] = GetUnitY(pickedunit)
        set r[3] = angle * bj_DEGTORAD
        call SetUnitX(pickedunit, r[1] + speed * Cos(r[3]))
        call SetUnitY(pickedunit, r[2] + speed * Sin(r[3]))
        SaveReal(udg_KA_Hashtable, StringHash("distance"), handleid, distance - speed)
    endif
    set pickedunit = null
    call RemoveLocation(unitloc)
endfunction

function KA_Loop_Actions takes nothing returns nothing
    call ForGroup(udg_KA_Group, function KA_Group_Actions)
endfunction

//===========================================================================
function InitTrig_Knives_Attack takes nothing returns nothing
    set udg_KA_Cast = CreateTrigger()
    set udg_KA_Loop = CreateTrigger()
    set udg_KA_Hashtable = InitHashtable()
    call TriggerRegisterAnyUnitEventBJ(udg_KA_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerRegisterTimerEventPeriodic(udg_KA_Loop, KA_Interval)
    call TriggerAddCondition(udg_KA_Cast, Filter(function KA_Cast_Conditions))
    call TriggerAddAction(udg_KA_Cast, function KA_Cast_Actions)
    call TriggerAddAction(udg_KA_Loop, function KA_Loop_Actions)
    call DisableTrigger(udg_KA_Loop)
endfunction

When i save it says "[highlight]Parse error[/code]"

That error begun after i save the real in here :
JASS:
function KA_Group_Actions takes nothing returns nothing
    local unit pickedunit = GetEnumUnit()
    local integer handleid = GetHandleId(pickedunit)
    local location unitloc
    local real array r
    local real speed = KA_Speed()
    local real angle = GetUnitFacing(pickedunit)
    local real distance = LoadReal(udg_KA_Hashtable, StringHash("distance"), handleid)
    if (distance > 0.00) then
        set r[1] = GetUnitX(pickedunit)
        set r[2] = GetUnitY(pickedunit)
        set r[3] = angle * bj_DEGTORAD
        call SetUnitX(pickedunit, r[1] + speed * Cos(r[3]))
        call SetUnitY(pickedunit, r[2] + speed * Sin(r[3]))
        SaveReal(udg_KA_Hashtable, StringHash("distance"), handleid, distance - speed)
    endif
    set pickedunit = null
    call RemoveLocation(unitloc)
endfunction

And guys this spell isn't don't yet.

+Rep to anyone that helped me....
 
Level 3
Joined
Sep 21, 2005
Messages
33
you forgot add call before savereal, simple but easy to do mistake

*edit* btw whats the reasoning behind the variable values inside their own functions, why use that instead of globals?
 
Level 13
Joined
Mar 29, 2012
Messages
530
Actually, i just want to make this spell in JASS not vJASS but making JASS spell with normal WE makes my eyes hurts, so i make it with JNGP...

BTW thanks for help...i was looked so stupid, right ? I even forgot that call :(
 
Status
Not open for further replies.
Top