• 🏆 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] requires return ?

Status
Not open for further replies.
Level 29
Joined
Oct 24, 2012
Messages
6,543
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:
Level 16
Joined
Mar 3, 2006
Messages
1,564
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
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
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)
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
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.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
lol i couldnt find anything different between the 2 triggers either but i need to get the units into the group the other units add fine to the other group in the trigger which is also a global group lol


oops found a typo lol i created group 10 in the other trigger instead of group 11 lol
the return thing is still stumping me tho lol
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
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