JASS:
globals
integer array P[6][4]
integer array G[6][4]
integer array T[6][4]
integer l
integer j
integer k
integer z
integer q
real Level = 1
integer Intervallo = 5
integer Gate = bj_GATEOPERATION_OPEN
integer array ctID
endglobals
function Setting takes nothing returns nothing
//*
//* P è un 2D array che controlla i cancelli ed il tipo di unità 1 = true 0 = false
//* Destra 2 = peone 3 = archer 4 = grunt
if (Level == 1.0) then
set P[1][1] = 0
set P[1][2] = 0
set P[1][3] = 0
set P[1][4] = 0
//* Centro Destra 2 = peone 3 = archer 4 = grunt
set P[2][1] = 1
set P[2][2] = 1
set P[2][3] = 0
set P[2][4] = 0
//* Centro Sinistra 2 = peone 3 = archer 4 = grunt
set P[3][1] = 1
set P[3][2] = 1
set P[3][3] = 0
set P[3][4] = 0
//* Sinistra 2 = peone 3 = archer 4 = grunt
set P[4][1] = 0
set P[4][2] = 0
set P[4][3] = 0
set P[4][4] = 0
//* Laterale Destra 2 = peone 3 = archer 4 = grunt
set P[5][1] = 0
set P[5][2] = 0
set P[5][3] = 0
set P[5][4] = 0
//* Laterale Sinistra 2 = peone 3 = archer 4 = grunt
set P[6][1] = 0
set P[6][2] = 0
set P[6][3] = 0
set P[6][4] = 0
//*
//* G è un 2D array che dice la quantità di unità per tipo di unità
set G[1][1] = 1
set G[1][2] = 0
set G[1][3] = 0
set G[1][4] = 0
set G[2][1] = 1
set G[2][2] = 2
set G[2][3] = 0
set G[2][4] = 0
set G[3][1] = 1
set G[3][2] = 1
set G[3][3] = 0
set G[3][4] = 0
set G[4][1] = 1
set G[4][2] = 0
set G[4][3] = 0
set G[4][4] = 0
set G[5][1] = 1
set G[5][2] = 0
set G[5][3] = 0
set G[5][4] = 0
set G[6][1] = 1
set G[6][2] = 0
set G[6][3] = 0
set G[6][4] = 0
endif
if (Level == 1.5) then
set P[1][1] = 0
set P[1][2] = 0
set P[1][3] = 0
set P[1][4] = 0
//* Centro Destra 2 = peone 3 = archer 4 = grunt
set P[2][1] = 1
set P[2][2] = 1
set P[2][3] = 1
set P[2][4] = 0
//* Centro Sinistra 2 = peone 3 = archer 4 = grunt
set P[3][1] = 0
set P[3][2] = 0
set P[3][3] = 0
set P[3][4] = 0
//* Sinistra 2 = peone 3 = archer 4 = grunt
set P[4][1] = 0
set P[4][2] = 0
set P[4][3] = 0
set P[4][4] = 0
//* Laterale Destra 2 = peone 3 = archer 4 = grunt
set P[5][1] = 0
set P[5][2] = 0
set P[5][3] = 0
set P[5][4] = 0
//* Laterale Sinistra 2 = peone 3 = archer 4 = grunt
set P[6][1] = 0
set P[6][2] = 0
set P[6][3] = 0
set P[6][4] = 0
//*
//* G è un 2D array che dice la quantità di unità per tipo di unità
set G[1][1] = 1
set G[1][2] = 0
set G[1][3] = 0
set G[1][4] = 0
set G[2][1] = 1
set G[2][2] = 1
set G[2][3] = 1
set G[2][4] = 0
set G[3][1] = 1
set G[3][2] = 0
set G[3][3] = 0
set G[3][4] = 0
set G[4][1] = 1
set G[4][2] = 0
set G[4][3] = 0
set G[4][4] = 0
set G[5][1] = 1
set G[5][2] = 0
set G[5][3] = 0
set G[5][4] = 0
set G[6][1] = 1
set G[6][2] = 0
set G[6][3] = 0
set G[6][4] = 0
endif
if (Level == 2.0) then
set P[1][1] = 1
set P[1][2] = 1
set P[1][3] = 1
set P[1][4] = 0
//* Centro Destra 2 = peone 3 = archer 4 = grunt
set P[2][1] = 1
set P[2][2] = 1
set P[2][3] = 0
set P[2][4] = 0
//* Centro Sinistra 2 = peone 3 = archer 4 = grunt
set P[3][1] = 1
set P[3][2] = 1
set P[3][3] = 0
set P[3][4] = 0
//* Sinistra 2 = peone 3 = archer 4 = grunt
set P[4][1] = 1
set P[4][2] = 1
set P[4][3] = 1
set P[4][4] = 0
//* Laterale Destra 2 = peone 3 = archer 4 = grunt
set P[5][1] = 0
set P[5][2] = 0
set P[5][3] = 0
set P[5][4] = 0
//* Laterale Sinistra 2 = peone 3 = archer 4 = grunt
set P[6][1] = 0
set P[6][2] = 0
set P[6][3] = 0
set P[6][4] = 0
//*
//* G è un 2D array che dice la quantità di unità per tipo di unità
set G[1][1] = 1
set G[1][2] = 3
set G[1][3] = 1
set G[1][4] = 0
set G[2][1] = 1
set G[2][2] = 3
set G[2][3] = 0
set G[2][4] = 0
set G[3][1] = 1
set G[3][2] = 1
set G[3][3] = 0
set G[3][4] = 0
set G[4][1] = 1
set G[4][2] = 3
set G[4][3] = 1
set G[4][4] = 0
set G[5][1] = 1
set G[5][2] = 0
set G[5][3] = 0
set G[5][4] = 0
set G[6][1] = 1
set G[6][2] = 0
set G[6][3] = 0
set G[6][4] = 0
endif
if (Level == 2.5) then
set P[1][1] = 1
set P[1][2] = 1
set P[1][3] = 1
set P[1][4] = 0
//* Centro Destra 2 = peone 3 = archer 4 = grunt
set P[2][1] = 1
set P[2][2] = 1
set P[2][3] = 0
set P[2][4] = 0
//* Centro Sinistra 2 = peone 3 = archer 4 = grunt
set P[3][1] = 1
set P[3][2] = 0
set P[3][3] = 1
set P[3][4] = 0
//* Sinistra 2 = peone 3 = archer 4 = grunt
set P[4][1] = 1
set P[4][2] = 1
set P[4][3] = 1
set P[4][4] = 0
//* Laterale Destra 2 = peone 3 = archer 4 = grunt
set P[5][1] = 0
set P[5][2] = 0
set P[5][3] = 0
set P[5][4] = 0
//* Laterale Sinistra 2 = peone 3 = archer 4 = grunt
set P[6][1] = 0
set P[6][2] = 0
set P[6][3] = 0
set P[6][4] = 0
//*
//* G è un 2D array che dice la quantità di unità per tipo di unità
set G[1][1] = 1
set G[1][2] = 3
set G[1][3] = 1
set G[1][4] = 0
set G[2][1] = 1
set G[2][2] = 4
set G[2][3] = 0
set G[2][4] = 0
set G[3][1] = 1
set G[3][2] = 0
set G[3][3] = 3
set G[3][4] = 0
set G[4][1] = 1
set G[4][2] = 3
set G[4][3] = 1
set G[4][4] = 0
set G[5][1] = 1
set G[5][2] = 0
set G[5][3] = 0
set G[5][4] = 0
set G[6][1] = 1
set G[6][2] = 0
set G[6][3] = 0
set G[6][4] = 0
endif
if (Level == 3.0) then
set P[1][1] = 1
set P[1][2] = 1
set P[1][3] = 1
set P[1][4] = 0
//* Centro Destra 2 = peone 3 = archer 4 = grunt
set P[2][1] = 1
set P[2][2] = 1
set P[2][3] = 1
set P[2][4] = 0
//* Centro Sinistra 2 = peone 3 = archer 4 = grunt
set P[3][1] = 1
set P[3][2] = 1
set P[3][3] = 0
set P[3][4] = 0
//* Sinistra 2 = peone 3 = archer 4 = grunt
set P[4][1] = 1
set P[4][2] = 1
set P[4][3] = 1
set P[4][4] = 0
//* Laterale Destra 2 = peone 3 = archer 4 = grunt
set P[5][1] = 0
set P[5][2] = 0
set P[5][3] = 0
set P[5][4] = 0
//* Laterale Sinistra 2 = peone 3 = archer 4 = grunt
set P[6][1] = 0
set P[6][2] = 0
set P[6][3] = 0
set P[6][4] = 0
//*
//* G è un 2D array che dice la quantità di unità per tipo di unità
set G[1][1] = 1
set G[1][2] = 3
set G[1][3] = 1
set G[1][4] = 0
set G[2][1] = 1
set G[2][2] = 3
set G[2][3] = 1
set G[2][4] = 0
set G[3][1] = 1
set G[3][2] = 2
set G[3][3] = 0
set G[3][4] = 0
set G[4][1] = 1
set G[4][2] = 3
set G[4][3] = 1
set G[4][4] = 0
set G[5][1] = 1
set G[5][2] = 0
set G[5][3] = 0
set G[5][4] = 0
set G[6][1] = 1
set G[6][2] = 0
set G[6][3] = 0
set G[6][4] = 0
endif
if (Level == 3.5) then
set P[1][1] = 1
set P[1][2] = 1
set P[1][3] = 1
set P[1][4] = 0
//* Centro Destra 2 = peone 3 = archer 4 = grunt
set P[2][1] = 1
set P[2][2] = 1
set P[2][3] = 1
set P[2][4] = 0
//* Centro Sinistra 2 = peone 3 = archer 4 = grunt
set P[3][1] = 1
set P[3][2] = 1
set P[3][3] = 1
set P[3][4] = 0
//* Sinistra 2 = peone 3 = archer 4 = grunt
set P[4][1] = 1
set P[4][2] = 1
set P[4][3] = 1
set P[4][4] = 0
//* Laterale Destra 2 = peone 3 = archer 4 = grunt
set P[5][1] = 0
set P[5][2] = 0
set P[5][3] = 0
set P[5][4] = 0
//* Laterale Sinistra 2 = peone 3 = archer 4 = grunt
set P[6][1] = 0
set P[6][2] = 0
set P[6][3] = 0
set P[6][4] = 0
//*
//* G è un 2D array che dice la quantità di unità per tipo di unità
set G[1][1] = 1
set G[1][2] = 3
set G[1][3] = 1
set G[1][4] = 0
set G[2][1] = 1
set G[2][2] = 2
set G[2][3] = 2
set G[2][4] = 0
set G[3][1] = 1
set G[3][2] = 4
set G[3][3] = 2
set G[3][4] = 0
set G[4][1] = 1
set G[4][2] = 3
set G[4][3] = 1
set G[4][4] = 0
set G[5][1] = 1
set G[5][2] = 0
set G[5][3] = 0
set G[5][4] = 0
set G[6][1] = 1
set G[6][2] = 0
set G[6][3] = 0
set G[6][4] = 0
endif
if (Level == 4.0) then
set P[1][1] = 1
set P[1][2] = 1
set P[1][3] = 1
set P[1][4] = 0
//* Centro Destra 2 = peone 3 = archer 4 = grunt
set P[2][1] = 1
set P[2][2] = 1
set P[2][3] = 1
set P[2][4] = 0
//* Centro Sinistra 2 = peone 3 = archer 4 = grunt
set P[3][1] = 1
set P[3][2] = 1
set P[3][3] = 0
set P[3][4] = 0
//* Sinistra 2 = peone 3 = archer 4 = grunt
set P[4][1] = 1
set P[4][2] = 1
set P[4][3] = 1
set P[4][4] = 0
//* Laterale Destra 2 = peone 3 = archer 4 = grunt
set P[5][1] = 1
set P[5][2] = 0
set P[5][3] = 0
set P[5][4] = 1
//* Laterale Sinistra 2 = peone 3 = archer 4 = grunt
set P[6][1] = 1
set P[6][2] = 0
set P[6][3] = 0
set P[6][4] = 1
//*
//* G è un 2D array che dice la quantità di unità per tipo di unità
set G[1][1] = 1
set G[1][2] = 8
set G[1][3] = 3
set G[1][4] = 0
set G[2][1] = 1
set G[2][2] = 4
set G[2][3] = 1
set G[2][4] = 0
set G[3][1] = 1
set G[3][2] = 3
set G[3][3] = 0
set G[3][4] = 0
set G[4][1] = 1
set G[4][2] = 8
set G[4][3] = 3
set G[4][4] = 0
set G[5][1] = 1
set G[5][2] = 0
set G[5][3] = 0
set G[5][4] = 1
set G[6][1] = 1
set G[6][2] = 0
set G[6][3] = 0
set G[6][4] = 1
endif
if (Level == 4.5) then
set P[1][1] = 1
set P[1][2] = 1
set P[1][3] = 1
set P[1][4] = 0
//* Centro Destra 2 = peone 3 = archer 4 = grunt
set P[2][1] = 1
set P[2][2] = 1
set P[2][3] = 1
set P[2][4] = 0
//* Centro Sinistra 2 = peone 3 = archer 4 = grunt
set P[3][1] = 1
set P[3][2] = 1
set P[3][3] = 1
set P[3][4] = 0
//* Sinistra 2 = peone 3 = archer 4 = grunt
set P[4][1] = 1
set P[4][2] = 1
set P[4][3] = 1
set P[4][4] = 0
//* Laterale Destra 2 = peone 3 = archer 4 = grunt
set P[5][1] = 1
set P[5][2] = 0
set P[5][3] = 0
set P[5][4] = 1
//* Laterale Sinistra 2 = peone 3 = archer 4 = grunt
set P[6][1] = 1
set P[6][2] = 0
set P[6][3] = 0
set P[6][4] = 1
//*
//* G è un 2D array che dice la quantità di unità per tipo di unità
set G[1][1] = 1
set G[1][2] = 8
set G[1][3] = 3
set G[1][4] = 0
set G[2][1] = 1
set G[2][2] = 4
set G[2][3] = 3
set G[2][4] = 0
set G[3][1] = 1
set G[3][2] = 4
set G[3][3] = 2
set G[3][4] = 0
set G[4][1] = 1
set G[4][2] = 8
set G[4][3] = 3
set G[4][4] = 0
set G[5][1] = 1
set G[5][2] = 0
set G[5][3] = 0
set G[5][4] = 1
set G[6][1] = 1
set G[6][2] = 0
set G[6][3] = 0
set G[6][4] = 1
endif
if (Level == 5.0) then
set P[1][1] = 1
set P[1][2] = 1
set P[1][3] = 1
set P[1][4] = 0
//* Centro Destra 2 = peone 3 = archer 4 = grunt
set P[2][1] = 1
set P[2][2] = 1
set P[2][3] = 1
set P[2][4] = 0
//* Centro Sinistra 2 = peone 3 = archer 4 = grunt
set P[3][1] = 1
set P[3][2] = 1
set P[3][3] = 1
set P[3][4] = 1
//* Sinistra 2 = peone 3 = archer 4 = grunt
set P[4][1] = 1
set P[4][2] = 1
set P[4][3] = 1
set P[4][4] = 0
//* Laterale Destra 2 = peone 3 = archer 4 = grunt
set P[5][1] = 1
set P[5][2] = 0
set P[5][3] = 0
set P[5][4] = 1
//* Laterale Sinistra 2 = peone 3 = archer 4 = grunt
set P[6][1] = 1
set P[6][2] = 0
set P[6][3] = 0
set P[6][4] = 1
//*
//* G è un 2D array che dice la quantità di unità per tipo di unità
set G[1][1] = 1
set G[1][2] = 12
set G[1][3] = 6
set G[1][4] = 0
set G[2][1] = 1
set G[2][2] = 6
set G[2][3] = 1
set G[2][4] = 0
set G[3][1] = 1
set G[3][2] = 4
set G[3][3] = 2
set G[3][4] = 1
set G[4][1] = 1
set G[4][2] = 12
set G[4][3] = 6
set G[4][4] = 0
set G[5][1] = 1
set G[5][2] = 0
set G[5][3] = 0
set G[5][4] = 2
set G[6][1] = 1
set G[6][2] = 0
set G[6][3] = 0
set G[6][4] = 2
endif
if (Level == 5.5) then
set P[1][1] = 1
set P[1][2] = 1
set P[1][3] = 1
set P[1][4] = 0
//* Centro Destra 2 = peone 3 = archer 4 = grunt
set P[2][1] = 1
set P[2][2] = 1
set P[2][3] = 1
set P[2][4] = 1
//* Centro Sinistra 2 = peone 3 = archer 4 = grunt
set P[3][1] = 1
set P[3][2] = 1
set P[3][3] = 1
set P[3][4] = 0
//* Sinistra 2 = peone 3 = archer 4 = grunt
set P[4][1] = 1
set P[4][2] = 1
set P[4][3] = 1
set P[4][4] = 0
//* Laterale Destra 2 = peone 3 = archer 4 = grunt
set P[5][1] = 1
set P[5][2] = 0
set P[5][3] = 0
set P[5][4] = 1
//* Laterale Sinistra 2 = peone 3 = archer 4 = grunt
set P[6][1] = 1
set P[6][2] = 0
set P[6][3] = 0
set P[6][4] = 1
//*
//* G è un 2D array che dice la quantità di unità per tipo di unità
set G[1][1] = 1
set G[1][2] = 12
set G[1][3] = 6
set G[1][4] = 0
set G[2][1] = 1
set G[2][2] = 4
set G[2][3] = 2
set G[2][4] = 1
set G[3][1] = 1
set G[3][2] = 6
set G[3][3] = 1
set G[3][4] = 0
set G[4][1] = 1
set G[4][2] = 12
set G[4][3] = 6
set G[4][4] = 0
set G[5][1] = 1
set G[5][2] = 0
set G[5][3] = 0
set G[5][4] = 2
set G[6][1] = 1
set G[6][2] = 0
set G[6][3] = 0
set G[6][4] = 2
endif
endfunction
function ID takes nothing returns nothing
if (z == 2) then
set ctID[2] = 'h002'
endif
if (z == 3) then
set ctID[3] = 'o000'
endif
if (z == 4) then
set ctID[4] = 'h003'
endif
endfunction
function Spawn takes nothing returns nothing
local WayPoint wp = 0
local Way wy = 0
local unit u
local real array x1
local real array x2
local real array x3
local real array x4
local real array y1
local real array y2
local real array y3
local real array y4
//* Routes
//*
set x1[1] = 1090.7
set x1[2] = 2167.1
set x1[3] = 2168.4
set x1[4] = 1230.2
set x1[5] = -2567.6
set x1[6] = -2562.0
set y1[1] = 2245.2
set y1[2] = 39.0
set y1[3] = -493.3
set y1[4] = -2722.5
set y1[5] = 2959.2
set y1[6] = -3245.4
set x2[1] = 1019.2
set x2[2] = 675.8
set x2[3] = 1134-9
set x2[4] = 1104.5
set x2[5] = -2565.1
set x2[6] = -2605.7
set y2[1] = 1064.9
set y2[2] = 1073.5
set y2[3] = -1712.5
set y2[4] = -1728.3
set y2[5] = 1300.9
set y2[6] = -2006.3
set x3[1] = -919.2
set x3[2] = -923.6
set x3[3] = -1054.8
set x3[4] = -957.0
set x3[5] = -1956.6
set x3[6] = -1921.5
set y3[1] = 1192.4
set y3[2] = 1025.9
set y3[3] = -1773.1
set y3[4] = -1730.0
set y3[5] = 1329.7
set y3[6] = -1958.4
set x4[1] = -1815.5
set x4[2] = -1757.6
set x4[3] = -1673.3
set x4[4] = -1791.2
set x4[5] = -2018.3
set x4[6] = -1993.3
set y4[1] = -321.4
set y4[2] = -373.7
set y4[3] = -377.9
set y4[4] = -386.7
set y4[5] = -200.9
set y4[6] = -574.1
set u = CreateUnit(Player(4), ctID[z], x1[k], y1[k], 270.)
set wy = Way.create()
call wy.addWayPoint(WayPoint.create(x1[k], y1[k], x2[k], y2[k], 192.))
call wy.addWayPoint(WayPoint.create(x2[k], y2[k], x3[k], y3[k], 192.))
call wy.addWayPoint(WayPoint.create(x3[k], y3[k], x4[k], y4[k], 192.))
call wy.addUnit(u, 0)
endfunction
function TerzaMatrice takes nothing returns nothing
set l = 1
loop
exitwhen l>6
set j = 1
loop
exitwhen j>4
set T[l][j] = (P[l][j]*G[l][j])
set j = (j + 1)
endloop
set l = (l + 1)
endloop
endfunction
function Spawner takes nothing returns nothing
set k = 1
loop
exitwhen k>6
if (T[k][1] == 1) then
set z = 2
loop
exitwhen z>4
call ID()
set q = 1
loop
exitwhen q> T[k][z]
call Spawn()
set q = (q + 1)
endloop
set z = (z + 1)
endloop
endif
set k = (k + 1)
endloop
endfunction
function Porte takes nothing returns nothing
local integer p
local destructable array porte
set porte[1] = gg_dest_LTg1_0001
set porte[2] = gg_dest_LTg3_0002
set porte[3] = porte[2]
set porte[4] = gg_dest_LTg1_0000
set porte[5] = gg_dest_DTg5_0003
set porte[6] = gg_dest_DTg5_0004
set p = 1
loop
exitwhen p > 6
if (T[1] == 1) then
call ModifyGateBJ( Gate, porte )
endif
set p = (p + 1)
endloop
endfunction
function PostSpawn takes nothing returns nothing
call TriggerSleepAction( Intervallo )
set Level = (Level + 0.5)
call Setting()
call TerzaMatrice()
call Spawner()
loop
exitwhen ( IsUnitGroupDeadBJ(GetUnitsOfPlayerAll(Player(4))) == true )
call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 1))
endloop
set Gate = bj_GATEOPERATION_CLOSE
call Porte()
set Gate = bj_GATEOPERATION_OPEN
set udg_Checker = 0
set Level = (Level + 0.5)
call DisplayTextToForce( GetPlayersAll(), ( "Wave " + ( R2S((Level - 1.0) ) + " completed!" ) ) )
call Setting()
call TerzaMatrice()
call CheckPlayers()
endfunction
//===========================================================================
function InitTrig_Wave takes nothing returns nothing
set gg_trg_Wave = CreateTrigger( )
call TriggerAddAction( gg_trg_Wave, function Setting )
call TriggerAddAction( gg_trg_Wave, function TerzaMatrice )
call TriggerAddAction( gg_trg_Wave, function Porte )
call TriggerAddAction( gg_trg_Wave, function Spawner )
call TriggerAddAction( gg_trg_Wave, function PostSpawn )
endfunction
Ok this is a spawn system which i've made based on Anachron's movement system (function Spawn)
But there's a bug which occurs on last levels with average amount of units in the map which is : all units move to a point (a point of the route) and stop there
I think that there's a leak somewhere but i can't find it
I've tried putting the coordinates of the different routes in the function Spawn and setting them local but nothing has changed (before they were globals)
I've also tried respawning many times level 1 for example but the bug didn't show. Whereas starting from level 3 which is the level from which the bug starts it goes perfectly but after it , at level 4, the bug occurs. Same on starting at level 5.
In my opinion the problem is : a hidden leak somewhere ; or the movement system doesn't support many units (but that's strange since it's all local).
If there's something you don't understand please tell me because since i'm italian i've called variables with italian terms