• 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.

[JASS] requires return ?

Status
Not open for further replies.
requires return it also doesnt add unit u to group ?

umm i have this problem im not sure y this requires a return can anyone tell me y does this require a return ? also i have another problem w it y does it not add unit u to the group ?

JASS:
function Trig_Unit_Spawn_Red_all_Lvls_Actions takes nothing returns boolean
    local integer LoopA = 1
    local integer Unit_Runner
    local real rx = GetRectCenterX(gg_rct_red_start)
    local real ry = GetRectCenterY(gg_rct_red_start)
    local real bx = GetRectCenterX(gg_rct_P11_Battleground_Spawn)
    local real by = GetRectCenterY(gg_rct_P11_Battleground_Spawn)
    local integer us
    local integer ub
    local unit u 
    call DisableTrigger( trg_Unit_Spawn_Red_all_Lvls )
    set udg_Damage_Boss_Round_Count_Player[0] = udg_Damage_Boss_Round_Count_Player[0] + 1
    set udg_EnemiesAlive_Counter_Player[0] = udg_Number_Of_Unit_Spawns_Player[0]//#of unit spawns is a selected number of spawns in the game
    set udg_Boss_Bonus_Counter[0] = udg_Boss_Bonus_Counter[0] + 1//used for giving players mana to summon a boss
    set Round_Player[0] = ( Round_Player[0] + 1 )
    call MultiboardSetItemValueBJ( udg_MultiBoard_Game_Scores, 2, 2, I2S(Round_Player[0]) )
    if ( udg_Round_Player[0] <= 31) then
        set us = Unit_Runner_Spawn[Round_Player[0]]
        set ub = Battlegrounds_Spawn[Round_Player[0]]
    elseif ( udg_Round_Player[0] > 31) then
        set us = Unit_Runner_Spawn[31]
        set ub = Battlegrounds_Spawn[31]
    endif
    if ( udg_Boss_Bonus_Counter[0] == 5 ) then
        set udg_Boss_Add_Mana_Boolean_Player[0] = true
        set udg_Boss_Bonus_Counter[0] = 0
    endif
    
    loop //loops for spawning units into map for player 1 ( i do not use 0 for players gets annoying ) 
        exitwhen LoopA > udg_Number_Of_Unit_Spawns_Player[0] // variable tht allows player to pick # of enemy units per round 
        set udg_Unit_Spawns_Red[LoopA] = CreateUnit(Player(11), us, rx, ry, 0)
        call GroupAddUnit(Unit_Spawns_Group_Player[0], udg_Unit_Spawns_Red[LoopA])
        call SetHeroLevel( udg_Unit_Spawns_Red[LoopA], ( Round_Player[0] - 30 ), false )
        set EnemiesAlive_Player[0] = ( EnemiesAlive_Player[0] + 1 ) //multiboard variable enemies alive
        call MultiboardSetItemValueBJ( udg_MultiBoard_Game_Scores, 2, 6, I2S(EnemiesAlive_Player[0]) )
        call PolledWait( udg_Spawn_Speed_Player[0] )//set the speed between enemy spawns
        set u = CreateUnit(Player(11), ub, bx, by, 0)
        call GroupAddUnit(Battlegrounds_Group_Player[11], u)
        set LoopA = LoopA + 1
    endloop
    set u = null
    return false
endfunction

//===========================================================================
function InitTrig_Unit_Spawn_Red_all_Lvls takes nothing returns nothing
    set trg_Unit_Spawn_Red_all_Lvls = CreateTrigger()
    call TriggerRegisterPlayerEvent(trg_Unit_Spawn_Red_all_Lvls, Player(0), EVENT_PLAYER_END_CINEMATIC)
    call TriggerRegisterPlayerChatEvent( trg_Unit_Spawn_Red_all_Lvls, Player(0), ( "-go" ), true )
    call TriggerAddAction( trg_Unit_Spawn_Red_all_Lvls, function Trig_Unit_Spawn_Red_all_Lvls_Actions )
endfunction

JASS:
function Trig_Unit_Spawn_Blue_all_Lvls_Actions takes nothing returns nothing
    local integer LoopB = 1
    local integer Unit_Runner
    local real rx = GetRectCenterX(gg_rct_blue_start)
    local real ry = GetRectCenterY(gg_rct_blue_start)
    local real bx = GetRectCenterX(gg_rct_P11_Battleground_Spawn)
    local real by = GetRectCenterY(gg_rct_P11_Battleground_Spawn)
    local integer us
    local integer ub
    local unit u
    call DisableTrigger( trg_Unit_Spawn_Blue_all_Lvls )
    set udg_Damage_Boss_Round_Count_Player[1] = ( udg_Damage_Boss_Round_Count_Player[1] + 1 )
    set udg_EnemiesAlive_Counter_Player[1] = udg_Number_Of_Unit_Spawns_Player[1]
    set udg_Boss_Bonus_Counter[1] = ( udg_Boss_Bonus_Counter[1] + 1 )
    set Round_Player[1] = ( Round_Player[1] + 1 )
    call MultiboardSetItemValueBJ( udg_MultiBoard_Game_Scores, 3, 2, I2S(udg_Round_Player[1]) )
    if ( udg_Round_Player[0] <= 31) then
        set us = Unit_Runner_Spawn[Round_Player[1]]
        set ub = Battlegrounds_Spawn[Round_Player[1]]
    elseif ( udg_Round_Player[1] > 31) then
        set us = Unit_Runner_Spawn[31]
        set ub = Battlegrounds_Spawn[31]
    endif
    if ( udg_Boss_Bonus_Counter[1] == 5 ) then
        set udg_Boss_Add_Mana_Boolean_Player[1] = true
        set udg_Boss_Bonus_Counter[1] = 0
    endif

    loop
        exitwhen LoopB > udg_Number_Of_Unit_Spawns_Player[1]
        set udg_Unit_Spawns_Blue[LoopB] = CreateUnit(Player(11), us, rx, ry, 0)
        call GroupAddUnit(Unit_Spawns_Group_Player[1], udg_Unit_Spawns_Blue[LoopB])
        call SetHeroLevel( udg_Unit_Spawns_Blue[LoopB], ( Round_Player[1] - 30 ), false )
        set EnemiesAlive_Player[1] = ( EnemiesAlive_Player[1] + 1 )
        call MultiboardSetItemValueBJ( udg_MultiBoard_Game_Scores, 3, 6, I2S(EnemiesAlive_Player[1]) )
        call PolledWait( udg_Spawn_Speed_Player[1] )
        set u = CreateUnit(Player(11), ub, bx, by, 0)
        call GroupAddUnit(Battlegrounds_Group_Player[11], u)
        set LoopB = LoopB + 1
    endloop
    set u = null
endfunction

//===========================================================================
function InitTrig_Unit_Spawn_Blue_all_Lvls takes nothing returns nothing
    set trg_Unit_Spawn_Blue_all_Lvls = CreateTrigger(  )
    call TriggerRegisterPlayerEventEndCinematic( trg_Unit_Spawn_Blue_all_Lvls, Player(1) )
    call TriggerRegisterPlayerChatEvent( trg_Unit_Spawn_Blue_all_Lvls, Player(1), ( "-go" ), true )
    call TriggerAddAction( trg_Unit_Spawn_Blue_all_Lvls, function Trig_Unit_Spawn_Blue_all_Lvls_Actions )
endfunction

notes: this is only for player 0 i have another for player 1 tht is the exact same thing except it doesnt require a return ?
 
Last edited:
JASS:
    if ( udg_Round_Player[0] <= 31) then
        set us = Unit_Runner_Spawn[Round_Player[0]]
        set ub = Battlegrounds_Spawn[Round_Player[0]]
    elseif
        set us = Unit_Runner_Spawn[31]
        set ub = Battlegrounds_Spawn[31]
    endif
    if ( udg_Boss_Bonus_Counter[0] == 5 ) then
        set udg_Boss_Add_Mana_Boolean_Player[0] = true
        set udg_Boss_Bonus_Counter[0] = 0
    endif

This is wrong, elseif is written like that:

JASS:
if CONDITION_1 then
elseif CONDITION_2 then
else
endif
 
ive never had a problem without the else after elseif and ya i forgot condition 2 its on the post now i noticed shortly after i pasted it

I just put else in my post to show that it doesn't need a condition for explanation only, sometimes the error telling you something is missing and it can't find exactly where the problem is.

But I think the problem is that you don't need a return at all. (EDIT: you don't need a return but it is not causing the problem)
 
i figured tht i dont need a return since the other trigger is exactly the same w steup and doesnt require it but y when i save does it keep telling me missing return lol when i put it in there it saves fine

also i have another problem w it y does it not add unit u to the group ?

1. I will check the triggers again but remember that sometimes the error that you see isn't accurate.

2. Make sure that you created the group.
 
126172-albums1967-picture64715.png


Take a look at the error, the problem is that I am typing:

takes nothing return nothing

instead of

takes nothing returns nothing

an 's' letter is missing.
 
Status
Not open for further replies.
Top