# [JASS]Help with this system, makes my jngp crash.

Status
Not open for further replies.

#### Hijax

Level 6
yeah, so i have this system for generating random dungeons.
JASS:
``````//randomdungeons v1.0, by hijax.
//to use this, you need a wall building. its unitid must be h100
//usage: call walls(mapw, maph, wallz, dnsz)
//dnsz is the length of the corridors.
//wallz is the colsize of your wall unit. it is advised to be high.
//mapw is the amount of walls that can fit horizontally on your map
//maph is the vertical version of mapw
//call spawnboss(boss1, boss2, boss3, boss4) to spawn bosses. read the comments on the
//function for instructions on how to expand it
//this is a work in progress.
//the supposed start location is stored in the global variable startloc.
//========================================
struct position
integer i
integer j
endstruct

globals
position array bospla[7]=position.create
location array bosplaloc[7]
integer bosnum=0
location startloc
location array roomloc[500]
endglobals

library paths
function walls takes integer mapw, integer maph, integer wallz, integer dnsz returns nothing
//locals
local integer i=0
// aka x
local integer n=0
//the next direction
local integer l=0
//stores what direction we last moved in
local integer j=0
//aka y
local integer w=0
local integer z=0
//used to determine if we're done 'dungeoning'
local integer array udg_map[mapw][maph]
//first, we fill the array with 1's
loop
exitwhen i>mapw
set j=0
loop
exitwhen j>maph
set udg_map[i][j]=1
set j=j+1
endloop
set i=i+1
endloop
//then, we clear a 'path' of 0's through it
set i=GetRandomInt(0,83)
//i denotes where we start
set udg_startloc=Location((i*144)-(GetRectMinY(GetPlayableMapRect())), 0)
set udg_map[i][j] = 0
set n=GetRandomInt(0, 2)
//lets get moving. n now shows which direction to go in.
// 0 is to the left of what we moved previously, 1 and 2 is straight forward, 3 is to the right
//since we are in the top of the map, there is only three ways to go.
if n==0then
set i=i-1
set udg_map[i][j]=0
set l=0
elseif n==1
set j=j+1
set udg_map[i][j]=0
set l=3
elseif n==2
set i=i+1
set udg_map[i][j]=0
set l=2
endif
loop
exitwhen z>dnsz
set n=GetRandomInt(0,3)
if (l==0 AND n==1) OR (l==0 AND n==2) OR (l==1 AND n==0) OR (l==3 AND n==3)
//check if we should for some reason move left
set i=i-1
set udg_map[i][j]=0
set l=0
elseif (l==1 AND n==1) OR (l==1 AND n==2) OR (l==2 AND n==0) OR (l==0 AND n==3)
//...or up
set j=j-1
set udg_map[i][j]=0
set l=1
elseif (l==2 AND n==1) OR (l==2 AND n==2) OR (l==3 AND n==0) OR (l==1 AND n==3)
//...or right
set i=i+1
set udg_map[i][j]=0
set l=2
elseif (l==3 AND n==1) OR (l==3 AND n==2) OR (l==0 AND n==0) OR (l==2 AND n==3)
//or maybe down?
set j=j+1
set udg_map[i][j]=0
set l=3
endif
set z=z+1
endloop
set i=0
set j=0
set l=0
set n=0
//resetting again. were going to use l for some chance. because now, were going to do BOSSES(well, their rooms)
//n is a counter
loop
exitwhen i>mapw
set j=0
loop
exitwhen j>maph
set l=GetRandomInt(0,50)
if udg_map[i][j]==0 AND l<1 then
set bospla[n].i=i
set bospla[n].j=j
n=n+1
endif
set j=j+1
endloop
set i=i+1
endloop
set l=0
//l is a counter, to check if we've created enough rooms.
set j=0
set i=0
//as usual, these are the y and x of this script
set n=0
//for chance if the room should be a bossroom or just a room.
set w=0
//for chance where we should create the room
loop
exitwhen l>n
set j=udg_bospla[l].j
set i=udg_bospla[l].i
set w=GetRandomInt(0,10)
if w==0 then
set udg_map[i+1][j]=0
set udg_map[i+2][j]=0
set udg_map[i+2][j-1]=0
set udg_map[i+2][j+1]=0
set udg_map[i+3][j-1]=0
set udg_map[i+3][j+1]=0
set udg_map[i+3][j]=0
set udg_map[i+4][j-1]=0
set udg_map[i+4][j+1]=0
set udg_map[i+4][j]=0
set udg_roomloc[l]=Location(((i+3)*wallsize)-(GetRectMinX(GetPlayableMaprect())), (j*wallsize)-(GetRectMinY(GetPlayableMapRect())))
elseif w==1
set udg_map[i-1][j]=0
set udg_map[i-2][j]=0
set udg_map[i-2][j+1]=0
set udg_map[i-2][j-1]=0
set udg_map[i-3][j]=0
set udg_map[i-3][j+1]=0
set udg_map[i-3][j-1]=0
set udg_map[i-4][j]=0
set udg_map[i-4][j+1]=0
set udg_map[i-4][j-1]=0
set udg_roomloc[l]=Location(((i-3)*wallsize)-(GetRectMinX(GetPlayableMaprect())), (j*wallsize)-(GetRectMinY(GetPlayableMapRect())))
elseif w==2
set udg_map[i][j-1]=0
set udg_map[i][j-2]=0
set udg_map[i+1][j-2]=0
set udg_map[i-1][j-2]=0
set udg_map[i][j-3]=0
set udg_map[i+1][j-3]=0
set udg_map[i-1][j-3]=0
set udg_map[i][j-4]=0
set udg_map[i+1][j-4]=0
set udg_map[i-1][j-4]=0
set udg_roomloc[l]=Location(((i)*wallsize)-(GetRectMinX(GetPlayableMaprect())), (j-3*wallsize)-(GetRectMinY(GetPlayableMapRect())))
else
set udg_map[i][j+1]=0
set udg_map[i][j+2]=0
set udg_map[i-1][j+2]=0
set udg_map[i+1][j+2]=0
set udg_map[i][j+3]=0
set udg_map[i-1][j+3]=0
set udg_map[i+1][j+3]=0
set udg_map[i][j+4]=0
set udg_map[i-1][j+4]=0
set udg_map[i+1][j+4]=0
set udg_roomloc[l]=Location(((i)*wallsize)-(GetRectMinX(GetPlayableMaprect())), (j+3*wallsize)-(GetRectMinY(GetPlayableMapRect())))
//clear the room, and store the location in a variable
set n=GetRandomInt(0,124)
if n=0 then
set udg_bosplaloc[l]=Location((udg_bospla.i*144)-(GetRectMinX(GetPlayableMapRect)), (udg_bospla.j*144)-(GetRectMinY(GetPlayableMapRect())))
//store the location so we can spawn bosses there, if the chance rolls low enough.
endif
set l=l+1
endloop
loop
exitwhen i>mapw
set j=0
loop
exitwhen j>maph
//those two loops will go through every slot in the array
if udg_map[i][j]==1 AND (udg_map[i-1][j]==0 OR udg_map[i+1][j]==0 OR udg_map[i][j-1]==0 OR udg_map[i][j+1]==0 udg_map[i-1][j-1]==0 OR udg_map[i+1][j+1]==0 OR udg_map[i+1][j-1]==0 udg_map[i-1][j+1]==0) then
//if the selected slot holds an 1, and any of the adjacent slots holds an 0
call CreateUnit(player(PLAYER_NEUTRAL_AGGRESSIVE), 'h000', (i*144)-(GetRectMinX(GetPlayableMapRect())), (j*144)-(GetRectMinY(GetPlayableMapRect())), 0)
//create a wall at the right location
endif
endloop
set i=i+1
endloop
endfunction

function spawnboss takes integer boss1 integer boss2 integer boss3 integer boss4 returns nothing
//add more unitids if you like, the script chooses them randomly
local integer j=0
local integer w=0
loop
exitwhen j>udg_bosnum
set w=GetRandomInt(0,3)
//modify that 3 to the number of bosses you specified minus 1
if w=0 then
call CreateUnitAtLoc(PLAYER_NEUTRAL_AGGRESSIVE, 'boss1', udg_bosplaloc[j], 0)
elseif w=1 then
call CreateUnitAtLoc(PLAYER_NEUTRAL_AGGRESSIVE, 'boss2', udg_bosplaloc[j], 0)
elseif w=2 then
call CreateUnitAtLoc(PLAYER_NEUTRAL_AGGRESSIVE, 'boss3', udg_bosplaloc[j], 0)
elseif w=3 then
call CreateUnitAtLoc(PLAYER_NEUTRAL_AGGRESSIVE, 'boss4', udg_bosplaloc[j], 0)
endif
//add more elseifs and unit spawns if you addded more bossids to the function
set j=j+1
endloop
endlibrary``````

(that version is intended for the hiveworkshop)
whenever i try and save it in jngp, it becomes unresponsive. could anybody help me locate the error? thanks in advance.

#### Eleandor

Level 21
Sounds like a problem related to jasshelper. Maybe contact vexorian on wc3c.net

#### Child_0f_Bodom

Level 16
position array bospla[7]=position.create

I think you cannot initialize structs in globals declaration and it should be position.create() not position.create

#### Yixx

Level 16
structs could only be placed inside a library or scope right? Or am i being totally wrong here?

#### Mannoroth

Level 4
structs could only be placed inside a library or scope right? Or am i being totally wrong here?

no, structs do not need to be defined inside a library or scope.

Edit: Also, you are only initializing the 8th element of your struct array (when it only has 7). You need to allocate an instance for each array element that you intend to use. For example (somewhere in your init code):

JASS:
``````local integer i = 0
loop
exitwhen i >= 7   // using a constant to define array size would be better
set bospla[i] = position.create()
if ( bospla[i] == 0 ) then
// allocation failure... decide what to do
endif
set i = i + 1
endloop``````

Last edited:

#### Hijax

Level 6
thanks for the help guys. it turned out to be a bug with JNGP. well, there were bugs too, but i fixed them.
but when the PJASS parser starts, it displays CRAPLOADS of errors, which wasnt there when the vJASS compiler looked. i partly suspect this is a bug in compilation.

JASS:
``````//randomdungeons v1.0, by hijax.
//to use this, you need a wall building. its unitid must be h100
//usage: call walls(mapw, maph, wallz)
//wallz is the colsize of your wall unit
//mapw is the amount of walls that can fit horizontally on your map
//maph is the vertical version of mapw
//call spawnboss(boss1, boss2, boss3, boss4) to spawn bosses. read the comments on the
//function for instructions on how to expand it
//this is a work in progress.
//the supposed start location is stored in the global variable startloc.
//========================================
struct position
integer i
integer j
endstruct

globals
constant integer maxmapwh=150
integer array map[maxmapwh][maxmapwh]
location array bosplaloc[100]
integer bosnum=0
location startloc
location array roomloc[500]
endglobals

library paths
function walls takes integer mapw, integer maph, integer wallz returns nothing
//locals
local integer i=0
// aka x
local integer n=0
//the next direction
local integer l=0
//stores what direction we last moved in
local integer j=0
//aka y
local integer w=0
local integer z=0
//used to determine if we're done 'dungeoning'
local integer p=0
local position array bospla
//roomlocs
loop
exitwhen p >= 100
set bospla = position.create()
if ( bospla == 0 ) then
call DisplayTextToForce(GetPlayersAll(), "An error occured while generating dungeon. please restart the game")
endif
set p = p + 1
endloop
//first, we fill the array with 1's
loop
exitwhen i>mapw
set j=0
loop
exitwhen j>maph
set udg_map[i][j]=1
set j=j+1
endloop
set i=i+1
endloop
//then, we clear a 'path' of 0's through it
set i=GetRandomInt(0,83)
//i denotes where we start
set udg_startloc=Location((i*144)-(GetRectMinY(GetPlayableMapRect())), 0)
set udg_map[i][j] = 0
set n=GetRandomInt(0, 2)
//lets get moving. n now shows which direction to go in.
// 0 is to the left of what we moved previously, 1 and 2 is straight forward, 3 is to the right
//since we are in the top of the map, there is only three ways to go.
if n==0 then
set i=i-1
set udg_map[i][j]=0
set l=0
elseif n==1 then
set j=j+1
set udg_map[i][j]=0
set l=3
elseif n==2 then
set i=i+1
set udg_map[i][j]=0
set l=2
endif
loop
exitwhen z>500
set n=GetRandomInt(0,3)
if ((l==0 and n==1) or (l==0 and n==2) or (l==1 and n==0) or (l==3 and n==3)) then
//check if we should for some reason move left
set i=i-1
set udg_map[i][j]=0
set l=0
elseif (l==1 and n==1) or (l==1 and n==2) or (l==2 and n==0) or (l==0 and n==3) then
//...or up
set j=j-1
set udg_map[i][j]=0
set l=1
elseif (l==2 and n==1) or (l==2 and n==2) or (l==3 and n==0) or (l==1 and n==3) then
//...or right
set i=i+1
set udg_map[i][j]=0
set l=2
elseif (l==3 and n==1) or (l==3 and n==2) or (l==0 and n==0) or (l==2 and n==3) then
//or maybe down?
set j=j+1
set udg_map[i][j]=0
set l=3
endif
set z=z+1
endloop
set i=0
set j=0
set l=0
set n=0
//resetting again. were going to use l for some chance. because now, were going to do BOSSES(well, their rooms)
//n is a counter
loop
exitwhen i>mapw
set j=0
loop
exitwhen j>maph
set l=GetRandomInt(0,50)
if udg_map[i][j]==0 and l<1 then
set bospla[n].i=i
set bospla[n].j=j
set n=n+1
endif
set j=j+1
endloop
set i=i+1
endloop
set l=0
//l is a counter, to check if we've created enough rooms.
set j=0
set i=0
//as usual, these are the y and x of this script
set n=0
//for chance if the room should be a bossroom or just a room.
set w=0
//for chance where we should create the room
loop
exitwhen l>n
set j=bospla[l].j
set i=bospla[l].i
set w=GetRandomInt(0,10)
if w==0 then
set udg_map[i+1][j]=0
set udg_map[i+2][j]=0
set udg_map[i+2][j-1]=0
set udg_map[i+2][j+1]=0
set udg_map[i+3][j-1]=0
set udg_map[i+3][j+1]=0
set udg_map[i+3][j]=0
set udg_map[i+4][j-1]=0
set udg_map[i+4][j+1]=0
set udg_map[i+4][j]=0
set udg_roomloc[l]=Location(((i+3)*wallsize)-(GetRectMinX(GetPlayableMaprect())), (j*wallsize)-(GetRectMinY(GetPlayableMapRect())))
elseif w==1 then
set udg_map[i-1][j]=0
set udg_map[i-2][j]=0
set udg_map[i-2][j+1]=0
set udg_map[i-2][j-1]=0
set udg_map[i-3][j]=0
set udg_map[i-3][j+1]=0
set udg_map[i-3][j-1]=0
set udg_map[i-4][j]=0
set udg_map[i-4][j+1]=0
set udg_map[i-4][j-1]=0
set udg_roomloc[l]=Location(((i-3)*wallsize)-(GetRectMinX(GetPlayableMaprect())), (j*wallsize)-(GetRectMinY(GetPlayableMapRect())))
elseif w==2 then
set udg_map[i][j-1]=0
set udg_map[i][j-2]=0
set udg_map[i+1][j-2]=0
set udg_map[i-1][j-2]=0
set udg_map[i][j-3]=0
set udg_map[i+1][j-3]=0
set udg_map[i-1][j-3]=0
set udg_map[i][j-4]=0
set udg_map[i+1][j-4]=0
set udg_map[i-1][j-4]=0
set udg_roomloc[l]=Location(((i)*wallsize)-(GetRectMinX(GetPlayableMaprect())), (j-3*wallsize)-(GetRectMinY(GetPlayableMapRect())))
else
set udg_map[i][j+1]=0
set udg_map[i][j+2]=0
set udg_map[i-1][j+2]=0
set udg_map[i+1][j+2]=0
set udg_map[i][j+3]=0
set udg_map[i-1][j+3]=0
set udg_map[i+1][j+3]=0
set udg_map[i][j+4]=0
set udg_map[i-1][j+4]=0
set udg_map[i+1][j+4]=0
set udg_roomloc[l]=Location(((i)*wallsize)-(GetRectMinX(GetPlayableMaprect())), (j+3*wallsize)-(GetRectMinY(GetPlayableMapRect())))
//clear the room, and store the location in a variable
set n=GetRandomInt(0,124)
if n==0 then
set udg_bosplaloc[l]=Location((bospla[l].i*144)-(GetRectMinX(GetPlayableMapRect)), (bospla[l].j*144)-(GetRectMinY(GetPlayableMapRect())))
//store the location so we can spawn bosses there, if the chance rolls low enough.
endif
set l=l+1
endloop
loop
exitwhen i>mapw
set j=0
loop
exitwhen j>maph
//those two loops will go through every slot in the array
if udg_map[i][j]==1 and (udg_map[i-1][j]==0 or udg_map[i+1][j]==0 or udg_map[i][j-1]==0 or udg_map[i][j+1]==0 or udg_map[i-1][j-1]==0 or udg_map[i+1][j+1]==0 or udg_map[i+1][j-1]==0 or udg_map[i-1][j+1]==0) then
//if the selected slot holds an 1, and any of the adjacent slots holds an 0
call CreateUnit(player(PLAYER_NEUTRAL_AGGRESSIVE), 'h000', (i*144)-(GetRectMinX(GetPlayableMapRect())), (j*144)-(GetRectMinY(GetPlayableMapRect())), 0)
//create a wall at the right location
endif
endloop
set i=i+1
endloop
endfunction
endlibrary``````

thats the only trigger in the whole map.

JASS:
``````globals
// Generated
trigger                 gg_trg_RDbase              = null
constant integer maxmapwh=150
// processed:     integer array map[maxmapwh][maxmapwh]
// processed:     location array bosplaloc[100]
integer bosnum=0
location startloc
// processed:     location array roomloc[500]

//JASSHelper struct globals:
constant integer si__position=2
integer si__position_F=0
integer si__position_I=0
integer array si__position_V
integer array s__position_i
integer array s__position_j
integer array s__map
integer array s__2map
integer array s__3map
location array s__bosplaloc
location array s__roomloc

endglobals

function sg__map_get takes integer i returns integer
if(i<8191) then
return s__map[i]
elseif(i<16382) then
return s__2map[i-8191]
else
return s__3map[i-16382]
endif
endfunction

function sg__map_set takes integer i,integer v returns nothing
if(i<8191) then
set s__map[i]=v
elseif(i<16382) then
set s__2map[i-8191]=v
else
set s__3map[i-16382]=v
endif
endfunction

//Generated allocator of position
function s__position__allocate takes nothing returns integer
local integer this=si__position_F
if (this!=0) then
set si__position_F=si__position_V[this]
else
set si__position_I=si__position_I+1
set this=si__position_I
endif
if (this>8190) then
return 0
endif

set si__position_V[this]=-1
return this
endfunction

//Generated destructor of position
function s__position_destroy takes integer this returns nothing
if this==null then
return
elseif (si__position_V[this]!=-1) then
return
endif
set si__position_V[this]=si__position_F
set si__position_F=this
endfunction

//library paths:
function walls takes integer mapw,integer maph,integer wallz returns nothing
//locals
local integer i=0
// aka x
local integer n=0
//the next direction
local integer l=0
//stores what direction we last moved in
local integer j=0
//aka y
local integer w=0
local integer z=0
//used to determine if we're done 'dungeoning'
local integer p=0
local integer array bospla
//roomlocs
loop
exitwhen p >= 100
set bospla=s__position__allocate()
if ( bospla == 0 ) then
call DisplayTextToForce(GetPlayersAll() , "An error occured while generating dungeon. please restart the game")
endif
set p = p + 1
endloop
//first, we fill the array with 1's
loop
exitwhen i > mapw
set j = 0
loop
exitwhen j > maph
set udg_map[i][j]=1
set j = j + 1
endloop
set i = i + 1
endloop
//then, we clear a 'path' of 0's through it
set i = GetRandomInt(0 , 83)
//i denotes where we start
set udg_startloc = Location(( i * 144 ) - ( GetRectMinY(GetPlayableMapRect()) ) , 0)
set udg_map[i][j]=0
set n = GetRandomInt(0 , 2)
//lets get moving. n now shows which direction to go in.
// 0 is to the left of what we moved previously, 1 and 2 is straight forward, 3 is to the right
//since we are in the top of the map, there is only three ways to go.
if n == 0 then
set i = i - 1
set udg_map[i][j]=0
set l = 0
elseif n == 1 then
set j = j + 1
set udg_map[i][j]=0
set l = 3
elseif n == 2 then
set i = i + 1
set udg_map[i][j]=0
set l = 2
endif
loop
exitwhen z > 500
set n = GetRandomInt(0 , 3)
if ( ( l == 0 and n == 1 ) or ( l == 0 and n == 2 ) or ( l == 1 and n == 0 ) or ( l == 3 and n == 3 ) ) then
//check if we should for some reason move left
set i = i - 1
set udg_map[i][j]=0
set l = 0
elseif ( l == 1 and n == 1 ) or ( l == 1 and n == 2 ) or ( l == 2 and n == 0 ) or ( l == 0 and n == 3 ) then
//...or up
set j = j - 1
set udg_map[i][j]=0
set l = 1
elseif ( l == 2 and n == 1 ) or ( l == 2 and n == 2 ) or ( l == 3 and n == 0 ) or ( l == 1 and n == 3 ) then
//...or right
set i = i + 1
set udg_map[i][j]=0
set l = 2
elseif ( l == 3 and n == 1 ) or ( l == 3 and n == 2 ) or ( l == 0 and n == 0 ) or ( l == 2 and n == 3 ) then
//or maybe down?
set j = j + 1
set udg_map[i][j]=0
set l = 3
endif
set z = z + 1
endloop
set i = 0
set j = 0
set l = 0
set n = 0
//resetting again. were going to use l for some chance. because now, were going to do BOSSES(well, their rooms)
//n is a counter
loop
exitwhen i > mapw
set j = 0
loop
exitwhen j > maph
set l = GetRandomInt(0 , 50)
if udg_map[i][j] == 0 and l < 1 then
set s__position_i[bospla[n]]=i
set s__position_j[bospla[n]]=j
set n = n + 1
endif
set j = j + 1
endloop
set i = i + 1
endloop
set l = 0
//l is a counter, to check if we've created enough rooms.
set j = 0
set i = 0
//as usual, these are the y and x of this script
set n = 0
//for chance if the room should be a bossroom or just a room.
set w = 0
//for chance where we should create the room
loop
exitwhen l > n
set j = s__position_j[bospla[l]]
set i = s__position_i[bospla[l]]
set w = GetRandomInt(0 , 10)
if w == 0 then
set udg_map[i + 1][j]=0
set udg_map[i + 2][j]=0
set udg_map[i + 2][j - 1]=0
set udg_map[i + 2][j + 1]=0
set udg_map[i + 3][j - 1]=0
set udg_map[i + 3][j + 1]=0
set udg_map[i + 3][j]=0
set udg_map[i + 4][j - 1]=0
set udg_map[i + 4][j + 1]=0
set udg_map[i + 4][j]=0
set udg_roomloc[l]=Location(( ( i + 3 ) * wallsize ) - ( GetRectMinX(GetPlayableMaprect()) ) , ( j * wallsize ) - ( GetRectMinY(GetPlayableMapRect()) ))
elseif w == 1 then
set udg_map[i - 1][j]=0
set udg_map[i - 2][j]=0
set udg_map[i - 2][j + 1]=0
set udg_map[i - 2][j - 1]=0
set udg_map[i - 3][j]=0
set udg_map[i - 3][j + 1]=0
set udg_map[i - 3][j - 1]=0
set udg_map[i - 4][j]=0
set udg_map[i - 4][j + 1]=0
set udg_map[i - 4][j - 1]=0
set udg_roomloc[l]=Location(( ( i - 3 ) * wallsize ) - ( GetRectMinX(GetPlayableMaprect()) ) , ( j * wallsize ) - ( GetRectMinY(GetPlayableMapRect()) ))
elseif w == 2 then
set udg_map[i][j - 1]=0
set udg_map[i][j - 2]=0
set udg_map[i + 1][j - 2]=0
set udg_map[i - 1][j - 2]=0
set udg_map[i][j - 3]=0
set udg_map[i + 1][j - 3]=0
set udg_map[i - 1][j - 3]=0
set udg_map[i][j - 4]=0
set udg_map[i + 1][j - 4]=0
set udg_map[i - 1][j - 4]=0
set udg_roomloc[l]=Location(( ( i ) * wallsize ) - ( GetRectMinX(GetPlayableMaprect()) ) , ( j - 3 * wallsize ) - ( GetRectMinY(GetPlayableMapRect()) ))
else
set udg_map[i][j + 1]=0
set udg_map[i][j + 2]=0
set udg_map[i - 1][j + 2]=0
set udg_map[i + 1][j + 2]=0
set udg_map[i][j + 3]=0
set udg_map[i - 1][j + 3]=0
set udg_map[i + 1][j + 3]=0
set udg_map[i][j + 4]=0
set udg_map[i - 1][j + 4]=0
set udg_map[i + 1][j + 4]=0
set udg_roomloc[l]=Location(( ( i ) * wallsize ) - ( GetRectMinX(GetPlayableMaprect()) ) , ( j + 3 * wallsize ) - ( GetRectMinY(GetPlayableMapRect()) ))
//clear the room, and store the location in a variable
set n = GetRandomInt(0 , 124)
if n == 0 then
set udg_bosplaloc[l]=Location(( s__position_i[bospla[l]] * 144 ) - ( GetRectMinX(GetPlayableMapRect) ) , ( s__position_j[bospla[l]] * 144 ) - ( GetRectMinY(GetPlayableMapRect()) ))
//store the location so we can spawn bosses there, if the chance rolls low enough.
endif
set l = l + 1
endloop
loop
exitwhen i > mapw
set j = 0
loop
exitwhen j > maph
//those two loops will go through every slot in the array
if udg_map[i][j] == 1 and ( udg_map[i - 1][j] == 0 or udg_map[i + 1][j] == 0 or udg_map[i][j - 1] == 0 or udg_map[i][j + 1] == 0 or udg_map[i - 1][j - 1] == 0 or udg_map[i + 1][j + 1] == 0 or udg_map[i + 1][j - 1] == 0 or udg_map[i - 1][j + 1] == 0 ) then
//if the selected slot holds an 1, and any of the adjacent slots holds an 0
call CreateUnit(player(PLAYER_NEUTRAL_AGGRESSIVE) , 'h000' , ( i * 144 ) - ( GetRectMinX(GetPlayableMapRect()) ) , ( j * 144 ) - ( GetRectMinY(GetPlayableMapRect()) ) , 0)
//create a wall at the right location
endif
endloop
set i = i + 1
endloop
endfunction

//library paths ends
//===========================================================================
//
// Just another Warcraft III map
//
//   Warcraft III map script
//   Generated by the Warcraft III World Editor
//   Date: Sun Jun 14 21:28:18 2009
//   Map Author: Unknown
//
//===========================================================================

//***************************************************************************
//*
//*  Global Variables
//*
//***************************************************************************

function InitGlobals takes nothing returns nothing
endfunction

//***************************************************************************
//*
//*  Triggers
//*
//***************************************************************************

//===========================================================================
// Trigger: RDbase
//===========================================================================
//TESH.scrollpos=0
//TESH.alwaysfold=0
//randomdungeons v1.0, by hijax.
//to use this, you need a wall building. its unitid must be h100
//usage: call walls(mapw, maph, wallz)
//wallz is the colsize of your wall unit
//mapw is the amount of walls that can fit horizontally on your map
//maph is the vertical version of mapw
//call spawnboss(boss1, boss2, boss3, boss4) to spawn bosses. read the comments on the
//function for instructions on how to expand it
//this is a work in progress.
//the supposed start location is stored in the global variable startloc.
//========================================

function InitCustomTriggers takes nothing returns nothing
endfunction

//***************************************************************************
//*
//*  Players
//*
//***************************************************************************

function InitCustomPlayerSlots takes nothing returns nothing

// Player 0
call SetPlayerStartLocation(Player(0) , 0)
call SetPlayerColor(Player(0) , ConvertPlayerColor(0))
call SetPlayerRacePreference(Player(0) , RACE_PREF_HUMAN)
call SetPlayerRaceSelectable(Player(0) , true)
call SetPlayerController(Player(0) , MAP_CONTROL_USER)

endfunction

function InitCustomTeams takes nothing returns nothing
// Force: TRIGSTR_002
call SetPlayerTeam(Player(0) , 0)

endfunction

//***************************************************************************
//*
//*  Main Initialization
//*
//***************************************************************************

//===========================================================================
function main takes nothing returns nothing
call SetCameraBounds(- 3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT) , - 3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM) , 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT) , 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP) , - 3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT) , 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP) , 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT) , - 3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM))
call SetDayNightModels("Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl" , "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl")
call NewSoundEnvironment("Default")
call SetAmbientDaySound("LordaeronSummerDay")
call SetAmbientNightSound("LordaeronSummerNight")
call SetMapMusic("Music" , true , 0)
call InitBlizzard()

call ExecuteFunc("jasshelper__initstructs13612070")

call InitGlobals()
call InitCustomTriggers()

endfunction

//***************************************************************************
//*
//*  Map Configuration
//*
//***************************************************************************

function config takes nothing returns nothing
call SetMapName("Just another Warcraft III map")
call SetMapDescription("Nondescript")
call SetPlayers(1)
call SetTeams(1)
call SetGamePlacement(MAP_PLACEMENT_USE_MAP_SETTINGS)

call DefineStartLocation(0 , - 2880.0 , - 128.0)

// Player setup
call InitCustomPlayerSlots()
call SetPlayerSlotAvailable(Player(0) , MAP_CONTROL_USER)
call InitGenericPlayerSlots()
endfunction

//Struct method generated initializers/callers:

//Functions for BigArrays:

function jasshelper__initstructs13612070 takes nothing returns nothing

endfunction``````

thats what it displays when pJASS comes up with all its errors. i guess that means thats the compiled version.

could anybody tell me WTH is wrong here?

#### Mannoroth

Level 4
thanks for the help guys. it turned out to be a bug with JNGP. well, there were bugs too, but i fixed them.
What bugs with JNGP and how did you fix them? Please specify.

Or are you referring to jasshelper becoming unresponsive when it encountered the bugs in your code (which you appear to have fixed)?

but when the PJASS parser starts, it displays CRAPLOADS of errors, which wasnt there when the vJASS compiler looked.
vjass takes your vjass code and creates a jass compatible source file. So its primary function is to check for vjass related errors. pjass checks the actual jass code (non-vjass) and reports jass errors. This is why some things will get past the vjass compiler and then caught by pjass.

i partly suspect this is a bug in compilation.
I assume you mean a bug in your code when pjass examines it (as opposed to a bug in the compiler itself).

thats what it displays when pJASS comes up with all its errors. i guess that means thats the compiled version.

could anybody tell me WTH is wrong here?
It might help to know the first few errors that pjass is reporting. Subsequent errors can often be a result of the original error (i.e. it propagates).

Edit: Your error appears to be that you are using udg_map but haven't defined it.

I assume you were meaning to use this var:
integer array map[maxmapwh][maxmapwh]

#### Hijax

Level 6
i have defined map under my globals, which means i should refernce it as udg_map.
[maxmapwh][maxmapwh] are the SIZE of the array. [j] are the index.

#### Yixx

Level 16
No, you are wrong
Globals are 'called' (JASS) as you declare them, with the name you put there.
In GUI you can also make Globals. You give it a name, but that is not the real name. GUI puts the global prefix in front of it 'udg_' , this is a GUI thing, and is not applied in normal JASS. Only if you use a 'GUI' global (one declared in 'trigger Editor's CTRL+B' place) you put the 'udg_' prefix in front of it. For example when killing leaks with GUI globals. But YOU instead should not use the 'udg_' prefix since you made a global yourself, instead of making the trigger editor do it for you.

#### Mannoroth

Level 4
i have defined map under my globals, which means i should refernce it as udg_map.
[maxmapwh][maxmapwh] are the SIZE of the array. [j] are the index.

Aside from what Yixx correctly points out, I realize of course that [maxmapwh][maxmapwh] define the size of the 2d array, and that i & j are indexes into an array - but you are not indexing the array you defined using map[maxmapwh][maxmapwh]. I was simply using examples directly from your code to point out where your errors are. The bottom line is, you need to use the "map" array var and not "udg_map".

#### Hijax

Level 6
well, thanks. i have some more errors, but that was one of them. i dont have my code here, so i cant check what else is there.

#### Storyyeller

Level 6
How did you get the brackets to show up in your code? Whenever I try, it replaces them with HTML escape characters

#### Hijax

Level 6
i have no sorts of idea. i just... kinda put them there, lol.
edit: yes, it worked! Thank you guys, about 95% of my errors were misplaced udg_'s. +rep to you.

Last edited:
Status
Not open for further replies.

Replies
12
Views
1K
Replies
1
Views
853
Replies
4
Views
1K
Replies
3
Views
1K
Replies
14
Views
975