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

[JASS] Simple question

Status
Not open for further replies.
Level 9
Joined
Jun 7, 2008
Messages
440
Im experimenting with natives; Can anyone explain what went wrong with this one please?
JASS:
function Trig_Map_Initialization_Resort takes nothing returns nothing
    local location t
    local integer i = 0
    loop
      exitwhen i>11
      set t = GetPlayerStartLocation(Player(i))
      call CreateNUnitsAtLoc( 3, 'h002', Player(i), t, 0.00 )
      call RemoveLocation(t)
    endloop
endfunction
Im new at this. Please bear with me.
 
Level 11
Joined
Sep 30, 2009
Messages
697
You need to increase your loop variable.
JASS:
function Trig_Map_Initialization_Resort takes nothing returns nothing
    local location t
    local integer i = 0
    loop
      set t = GetPlayerStartLocation(Player(i))
      call CreateNUnitsAtLoc( 3, 'h002', Player(i), t, 0.00 )
      call RemoveLocation(t)
      exitwhen i >= 11
      set i = i + 1
    endloop
endfunction

also you should learn to use coordinates instead of locations, because they are faster
 
Level 9
Joined
Jun 7, 2008
Messages
440
I would love to learn how to use coordinates more appropriately. However, when I use the jass script you just gave me it syntaxed on:
JASS:
function Trig_Map_Initialization_Resort takes nothing returns nothing
    local location t
    local integer i = 0
    loop
      set t = GetPlayerStartLocation(Player(i)) //This part
      call CreateNUnitsAtLoc( 3, 'h002', Player(i), t, 0.00 )
      call RemoveLocation(t)
      exitwhen i >= 11
      set i = i + 1
    endloop
endfunction
 
Level 11
Joined
Sep 30, 2009
Messages
697
JASS:
function Trig_Map_Initialization_Resort takes nothing returns nothing
    local location t
    local integer i = 0
    local real x
    local real y
    loop
        set x = GetStartLocationX(GetPlayerStartLocation(Player(i)))
        set y = GetStartLocationY(GetPlayerStartLocation(Player(i)))
        
        call CreateUnit(Player(i), 'h002', x, y, 0)
        call CreateUnit(Player(i), 'h002', x, y, 0)
        call CreateUnit(Player(i), 'h002', x, y, 0)
        
        call RemoveLocation(t)
        exitwhen i >= 11
        set i = i + 1
    endloop
endfunction

Thats it with coordinates. It gave you a syntax because of your own fail.

GetPlayerStartLocation(Player(i)) returns an integer and not a location
 
Level 21
Joined
Mar 19, 2009
Messages
444
JASS:
function Trig_Map_Initialization_Resort takes nothing returns nothing
    local integer i = 0
    local integer j = 0
    local real x = 0.
    local real y = 0.
    loop
      exitwhen i>11
      set x = GetStartLocationX(GetPlayerStartLocation(Player(i)))
      set y = GetStartLocationY(GetPlayerStartLocation(Player(i)))
      set j = 0
      loop
          exitwhen j > 2
          call CreateUnit(Player(i), 'h002', x, y, 0)
          set j = j + 1
      endloop
      set i = i + 1
    endloop
endfunction
 
Status
Not open for further replies.
Top