• 🏆 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] Unexpected "("

Status
Not open for further replies.
Level 11
Joined
Sep 14, 2009
Messages
284
I need some help to find an unexpected "(". I can't for the god of me find where the error is.

According to JassHelper the "(" is in the line where the Timer is created.
The error disappears when I remove the () from the call of CreateCombatSpawnUnit function, but I need it to take that argument and it should work I think?

Here is the code:


JASS:
globals
    rect array combatSpawnRectGreenwood
    region array combatSpawnRegionGreenwood
endglobals
//===========================================================================
function CombatSpawnRectGreenwood_Conditions takes nothing returns boolean
    return GetUnitAbilityLevel(GetTriggerUnit(), abilPartyManager) >= 1
endfunction
function CombatSpawnRectGreenwood_Actions takes nothing returns nothing
    local integer i = 0
    local region r = GetTriggeringRegion()
    loop
        exitwhen i >= 1 // Number of combatSpawnRects in zone.
        if combatSpawnRegionGreenwood[i] == r then
            call TimerStart(CreateTimer(), GetRandomReal(2, 5), false, function CreateCombatSpawnUnit(combatSpawnRectGreenwood[i]))
        endif
        set i = i + 1
    endloop
    set r = null
endfunction
//===========================================================================
function InitTrig_CombatSpawnRectGreenwood takes nothing returns nothing
    set gg_trg_CombatSpawnRectGreenwood = CreateTrigger()
    call TriggerRegisterEnterRectSimple(gg_trg_CombatSpawnRectGreenwood, gg_rct_CombatSpawnGreenwood00)
    call TriggerAddCondition(gg_trg_CombatSpawnRectGreenwood, Condition(function CombatSpawnRectGreenwood_Conditions))
    call TriggerAddAction(gg_trg_CombatSpawnRectGreenwood, function CombatSpawnRectGreenwood_Actions)
endfunction


JASS:
function CreateCombatSpawnUnit takes rect r returns nothing
    local location l = GetRandomLocInRect(r)
    call DestroyTimer(GetExpiredTimer())
    call CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), combatSpawnType[GetRandomInt(0, 1)], GetLocationX(l), GetLocationY(l), GetRandomReal(0, 360))
    call RemoveLocation(l)
    set l = null
endfunction


EDIT: Solved. Thanks Jampion, totally forgot that.
 
Last edited:

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
call TimerStart(CreateTimer(), GetRandomReal(2, 5), false, function CreateCombatSpawnUnit(combatSpawnRectGreenwood))

you can't use functions with parameters in timers. Use a hashtable instead to attach the necessary data to the timer.
 
Status
Not open for further replies.
Top