yeah, so i have this system for generating random dungeons.
(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.
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.