Curious if anyone can help me out here. I have moved my code to another agc file that I include in the main. A certain line stopped working, and I have no idea what.
This line:
if GetObjectExists( cloneIDs[t,1,0].door )
wallID = objectspherecast(0, GetObjectX( cloneIDs[t,1,0].door ), 1.0, GetObjectZ( cloneIDs[t,1,0].door ), GetObjectX( cloneIDs[t,1,0].door ), 1.0, GetObjectZ( cloneIDs[t,1,0].door ), 0)
if GetObjectExists( wallID ) then DeleteObject(wallID)
endif
The odd thing is it does exist, and when I printc( cloneIDs[t,1,0].door ) there is an object ID...
main.agc - where it works (its line 171)
Setvirtualresolution(640,480)
ResetTimer()
type tiles
room as integer
roomx as integer
roomy as integer
roomz as integer
wall as integer
door as integer
corridor as integer
chest as integer
crate as integer
barrel as integer
endtype
dim cloneIDs[20, 100, 100] as tiles
dim GPS[20] as tiles
global wallObjID
global floorObjID
global corridorObjID
global doorObjID
global chestObjID
global crateObjID
global barrelObjID
global dng_gen_rooms
GPS[1].roomx = 0
GPS[1].roomy = 0
GPS[1].roomz = 0
dng_gen_rooms = 6
function restartdungeon()
if GetObjectExists( wallObjID ) then DeleteObject( wallObjID )
if GetObjectExists( floorObjID ) then DeleteObject( floorObjID )
if GetObjectExists( corridorObjID ) then DeleteObject( corridorObjID )
if GetObjectExists( doorObjID ) then DeleteObject( doorObjID )
if GetObjectExists( chestObjID ) then DeleteObject( chestObjID )
if GetObjectExists( crateObjID ) then DeleteObject( crateObjID )
if GetObjectExists( barrelObjID ) then DeleteObject( barrelObjID )
if GetImageExists( level_texture ) then DeleteImage ( level_texture )
for t = 0 to 20
for n = 0 to 100
for x = 0 to 100
if GetObjectExists( cloneIDs[t, n, x].room ) then DeleteObject( cloneIDs[t, n, x].room )
if GetObjectExists( cloneIDs[t, n, x].wall ) then DeleteObject( cloneIDs[t, n, x].wall )
if GetObjectExists( cloneIDs[t, n, x].door ) then DeleteObject( cloneIDs[t, n, x].door )
if GetObjectExists( cloneIDs[t, n, x].corridor ) then DeleteObject( cloneIDs[t, n, x].corridor )
if GetObjectExists( cloneIDs[t, n, x].chest ) then DeleteObject( cloneIDs[t, n, x].chest )
if GetObjectExists( cloneIDs[t, n, x].crate ) then DeleteObject( cloneIDs[t, n, x].crate )
if GetObjectExists( cloneIDs[t, n, x].barrel ) then DeleteObject( cloneIDs[t, n, x].barrel )
next x
next n
next t
floorObjID = CreateObjectBox( 2, .25, 2 )
wallObjID = LoadObject( "wall.obj" )
corridorObjID = createobjectbox( 2, .25, 2 )
doorObjID = createobjectbox( 2, 6, 2 )
chestObjID = LoadObject( "Chest_A.obj" )
crateObjID = LoadObject( "crate.obj" )
barrelObjID = LoadObject( "barrel.obj" )
level_texture = LoadImage( "FG_Assets01_Low_D.png" )
SetObjectImage ( chestObjID, level_texture, 0 )
SetObjectImage ( crateObjID, level_texture, 0 )
SetObjectImage ( barrelObjID, level_texture, 0 )
SetObjectImage ( wallObjID, level_texture, 0 )
SetObjectColor( corridorObjID, 75, 155, 75, 255 )
SetObjectColor( wallObjID, 155, 100, 200, 255 )
SetObjectColor( doorObjID, 255, 0, 0, 255 )
SetObjectPosition( floorObjID, 3000, 8000, 3000 )
SetObjectPosition( wallObjID, 3000, 8000, 3000 )
SetObjectPosition( corridorObjID, 3000, 8000, 3000 )
SetObjectPosition( doorObjID, 3000, 8000, 3000 )
SetObjectPosition( chestObjID, 3000, 8000, 3000 )
SetObjectPosition( crateObjID, 3000, 8000, 3000 )
SetObjectPosition( barrelObjID, 3000, 8000, 3000 )
undim GPS[]
undim cloneIDs[]
dim GPS[20] as tiles
dim cloneIDs[20, 100, 100] as tiles
endfunction
function room(t as integer) //create rooms
x_dir = 1
z_dir = 1
z_offset = 0
x_offset = 0
if t > 1
GPS[t].roomx = GetobjectX( cloneIDs[t,1,0].door )
GPS[t].roomz = GetobjectZ( cloneIDs[t,1,0].door )
rm_x_axis_dir = (GetobjectX( cloneIDs[t,1,0].door ) - GetobjectX( cloneIDs[t-1,2,0].door ))
rm_z_axis_dir = (GetobjectZ( cloneIDs[t,1,0].door ) - GetobjectZ( cloneIDs[t-1,2,0].door ))
if rm_x_axis_dir < 0 or rm_z_axis_dir < 0
x_dir = -1
z_dir = -1
endif
if rm_x_axis_dir <> 0 and x_dir = 1
z_offset = 4
elseif rm_z_axis_dir <> 0 and z_dir = 1
x_offset = 4
elseif rm_x_axis_dir <> 0 and x_dir = -1
z_offset = -4
elseif rm_z_axis_dir <> 0 and z_dir = -1
x_offset = -4
endif
endif
x=1
z=0
w = random2(5,10)
h = random2(5,10)
For x = 1 to w+2 //w
if z <> 0 and x <> w+2
cloneIDs[t,x,z].room = CloneObject( floorObjID )
SetObjectPosition( cloneIDs[t,x,z].room, GPS[t].roomx+((x*2)*x_dir)-x_offset, 0, GPS[t].roomz-z_offset )
endif
For z = 1 to h+1
cloneIDs[t,x,z].room = CloneObject( floorObjID )
SetObjectPosition( cloneIDs[t,x,z].room, GPS[t].roomx+((x*2*x_dir)-(x_dir*2))-x_offset, 0, GPS[t].roomz+(z*(z_dir*2))-z_offset )
Next z
Next x
//wall
x=0
z=0
door_ID = 0
For x = 0 to w //bottom //w
cloneIDs[t,x,z].wall = CloneObject( wallObjID )
SetObjectPosition( cloneIDs[t,x,z].wall, GPS[t].roomx+(x*2*x_dir)-x_offset, 3.5, GPS[t].roomz-z_offset )
Next x
x = w+1 //w+1
For z = 0 to h+1 //right side // h+1
cloneIDs[t,x,z].wall = CloneObject( wallObjID )
SetObjectPosition( cloneIDs[t,x,z].wall, GPS[t].roomx+(x*2*x_dir)-x_offset, 3.5, GPS[t].roomz+(z*2*z_dir)-z_offset )
Next z
z=w+1 //w+1
x=w+2 //w+2
For z = w+1 to w+h+1 //left w+1 to w+h+1
cloneIDs[t,x,z].wall = CloneObject( wallObjID )
SetObjectPosition( cloneIDs[t,x,z].wall, GPS[t].roomx-x_offset, 3.5, GPS[t].roomz+((z-w-1)*2*z_dir)-z_offset )
Next z
z = w+h+2 //top w+h+2
For x = w+3 to w+w+4 //w+3 to w+3+w+1
cloneIDs[t,x,z].wall = CloneObject( wallObjID )
SetObjectPosition( cloneIDs[t,x,z].wall, GPS[t].roomx+((x-w-3)*2*x_dir)-x_offset, 3.5, GPS[t].roomz+((z-w-1)*2*z_dir)-z_offset )
Next x
//create function for decor
placedecor( w, h, t )
if t >= 1 and t < dng_gen_rooms
corridorfill( w, h, t, rm_x_axis_dir, rm_z_axis_dir )
chest_chance = Random2(1,100)
if chest_chance >= 20 and chest_chance <= 2
x = random2( 2, w )
z= random2( 2, h )
cloneIDs[t,1,1].chest = CloneObject( chestObjID )
SetObjectPosition( cloneIDs[t,1,1].chest, GetObjectX( cloneIDs[t,x,z].room ), 1, GetObjectZ( cloneIDs[t,x,z].room ) )
endif
endif
if t = dng_gen_rooms
//chest_chance = Random2(1,100)
//if chest_chance >= 20 and chest_chance <= 40
x = random2( 2, w )
z= random2( 2, h )
SetObjectPosition( chestObjID, GetObjectX( cloneIDs[t,x,z].room ), 1, GetObjectZ( cloneIDs[t,x,z].room ) )
endif
if GetObjectExists( cloneIDs[t,1,0].door )
wallID = objectspherecast(0, GetObjectX( cloneIDs[t,1,0].door ), 5.5, GetObjectZ( cloneIDs[t,1,0].door ), GetObjectX( cloneIDs[t,1,0].door ), 5.5, GetObjectZ( cloneIDs[t,1,0].door ), 1)
if GetObjectExists( wallID ) then DeleteObject(wallID)
endif
endfunction
function corridorfill( w as integer, h as integer, t as integer, rm_x_axis_dir as integer, rm_z_axis_dir as integer )
if Last_Corridor_Direction = 1 or Last_Corridor_Direction = 3
if Prvs_Last_Corridor_Direction = 2 or Prvs_Last_Corridor_Direction = 4
repeat
Current_Corridor_Direction = random2(1,4)
until Current_Corridor_Direction <> Last_Corridor_Direction and Current_Corridor_Direction <> 2 and Current_Corridor_Direction <> 4
elseif Prvs_Last_Corridor_Direction = 1
repeat
Current_Corridor_Direction = random2(1,4)
until Current_Corridor_Direction <> Last_Corridor_Direction and Current_Corridor_Direction <> 2
else
repeat
Current_Corridor_Direction = random2(1,4)
until Current_Corridor_Direction <> Last_Corridor_Direction
endif
elseif Last_Corridor_Direction = 2 or Last_Corridor_Direction = 4
if Prvs_Last_Corridor_Direction = 1 or Prvs_Last_Corridor_Direction = 3
repeat
Current_Corridor_Direction = random2(1,4)
until Current_Corridor_Direction <> Last_Corridor_Direction-1 and Current_Corridor_Direction <> Prvs_Last_Corridor_Direction - 1 and Current_Corridor_Direction <> Prvs_Last_Corridor_Direction
else
repeat
Current_Corridor_Direction = random2(1,4)
until Current_Corridor_Direction <> Last_Corridor_Direction-1 and Current_Corridor_Direction <> Prvs_Last_Corridor_Direction-1
endif
else
Current_Corridor_Direction = random2(1,4)
endif
cloneIDs[t,2,0].door = CloneObject( doorObjID )
if Current_Corridor_Direction = 1 //south
x = random2(2,w-1)
z = 0
SetObjectPosition( cloneIDs[t,2,0].door, GetObjectX( cloneIDs[t,x,z].wall ), 2.4, GetObjectZ( cloneIDs[t,x,z].wall ) )
DeleteObject( cloneIDs[t,x,z].wall )
z_dir = 1
elseif Current_Corridor_Direction = 2 //north
x = random2(w+4,w+w+3)
z = w+h+2
SetObjectPosition( cloneIDs[t,2,0].door, GetObjectX( cloneIDs[t,x,z].wall ), 2.4, GetObjectZ( cloneIDs[t,x,z].wall ) )
DeleteObject( cloneIDs[t,x,z].wall )
z_dir = -1
elseif Current_Corridor_Direction = 3 //west
x = w+2
z= random2(w+2,w+h)
SetObjectPosition( cloneIDs[t,2,0].door, GetObjectX( cloneIDs[t,x,z].wall ), 2.4, GetObjectZ( cloneIDs[t,x,z].wall ) )
DeleteObject( cloneIDs[t,x,z].wall )
x_dir = 1
elseif Current_Corridor_Direction = 4 //east
x = w+1
z= random2(1,h)
SetObjectPosition( cloneIDs[t,2,0].door, GetObjectX( cloneIDs[t,x,z].wall ), 2.4, GetObjectZ( cloneIDs[t,x,z].wall ) )
DeleteObject( cloneIDs[t,x,z].wall )
x_dir = -1
endif
counter = random2(4,7) //corridor length
if rm_x_axis_dir < 0 or rm_z_axis_dir < 0
x_dir = x_dir*-1
z_dir = z_dir*-1
endif
z=0
x=0
n = 1
repeat
select Current_Corridor_Direction
case 1: //south
cloneIDs[t,x,z+n].corridor = CloneObject( corridorObjID )
SetObjectPosition( cloneIDs[t,x,z+n].corridor, GetObjectX( cloneIDs[t,2,0].door ), 0, GetObjectZ( cloneIDs[t,2,0].door )-(z_dir*(n*2)) )
if n = counter-1
cloneIDs[t+1,1,0].door = CloneObject( doorObjID )
SetObjectPosition( cloneIDs[t+1,1,0].door, GetObjectX( cloneIDs[t,2,0].door ), 0.0, GetObjectZ( cloneIDs[t,2,0].door )-(z_dir*((n+1)*2) ) )
endif
endcase
case 2: //north
cloneIDs[t,x,z+n].corridor = CloneObject( corridorObjID )
SetObjectPosition( cloneIDs[t,x,z+n].corridor, GetObjectX( cloneIDs[t,2,0].door ), 0, GetObjectZ( cloneIDs[t,2,0].door )-(z_dir*(n*2)) )
if n = counter-1
cloneIDs[t+1,1,0].door = CloneObject( doorObjID )
SetObjectPosition( cloneIDs[t+1,1,0].door, GetObjectX( cloneIDs[t,2,0].door ), 2.4, GetObjectZ( cloneIDs[t,2,0].door )-(z_dir*((n+1)*2)) )
endif
endcase
case 3: //west
cloneIDs[t,x+n,z].corridor = CloneObject( corridorObjID )
SetObjectPosition( cloneIDs[t,x+n,z].corridor, GetObjectX( cloneIDs[t,2,0].door )-x_dir*(n*2), 0, GetObjectZ( cloneIDs[t,2,0].door ) )
if n = counter-1
cloneIDs[t+1,1,0].door = CloneObject( doorObjID )
SetObjectPosition( cloneIDs[t+1,1,0].door, GetObjectX( cloneIDs[t,2,0].door )-x_dir*((n+1)*2), 2.4, GetObjectZ( cloneIDs[t,2,0].door ) )
endif
endcase
case 4: //east
cloneIDs[t,x+n,z].corridor = CloneObject( corridorObjID )
SetObjectPosition( cloneIDs[t,x+n,z].corridor, GetObjectX( cloneIDs[t,2,0].door )-x_dir*(n*2), 0, GetObjectZ( cloneIDs[t,2,0].door ) )
if n = counter-1
cloneIDs[t+1,1,0].door = CloneObject( doorObjID )
SetObjectPosition( cloneIDs[t+1,1,0].door, GetObjectX( cloneIDs[t,2,0].door )-x_dir*((n+1)*2), 2.4, GetObjectZ( cloneIDs[t,2,0].door ) )
endif
endcase
endselect
n=n+1
until n = counter
Prvs_Last_Corridor_Direction = Last_Corridor_Direction
Last_Corridor_Direction = Current_Corridor_Direction
if GetObjectExists( cloneIDs[6,1,0].door ) then SetObjectColor( cloneIDs[6,1,0].door, 255, 150, 75, 255 )
global Current_Corridor_Direction
global Last_Corridor_Direction
global Prvs_Last_Corridor_Direction
dim crd[20] as tiles
crd[t].room = Current_Corridor_Direction
endfunction
function placedecor( w as integer, h as integer, t as integer )
x = random2( 2, w )
z= random2( 2, h )
cloneIDs[t,1,1].barrel = CloneObject( barrelObjID )
SetObjectPosition( cloneIDs[t,1,1].barrel, GetObjectX( cloneIDs[t,x,z].room ), 0, GetObjectZ( cloneIDs[t,x,z].room ) )
endfunction
restartdungeon()
for t = 1 to dng_gen_rooms
room(t)
next t
do
PrintC(Current_Corridor_Direction)
Printc(Last_Corridor_Direction)
Print(Prvs_Last_Corridor_Direction)
t=1
for t =1 to dng_gen_rooms
PrintC(t)
PrintC(": ")
Print(crd[t].room)
next t
SetCameraPosition( 1, GPS[5].roomx, 150, GPS[5].roomz)
SetCameraLookAt( 1, GPS[5].roomx, 0, GPS[5].roomz, 0 )
Sync()
loop
LoadRandomDungeon.agc - everything else works except this line(line 164)
function restartdungeon()
if GetObjectExists( wallObjID ) then DeleteObject( wallObjID )
if GetObjectExists( floorObjID ) then DeleteObject( floorObjID )
if GetObjectExists( corridorObjID ) then DeleteObject( corridorObjID )
if GetObjectExists( doorObjID ) then DeleteObject( doorObjID )
if GetObjectExists( chestObjID ) then DeleteObject( chestObjID )
if GetObjectExists( crateObjID ) then DeleteObject( crateObjID )
if GetObjectExists( barrelObjID ) then DeleteObject( barrelObjID )
if GetImageExists( level_texture ) then DeleteImage ( level_texture )
for t = 0 to 20
for n = 0 to 100
for x = 0 to 100
if GetObjectExists( cloneIDs[t, n, x].room ) then DeleteObject( cloneIDs[t, n, x].room )
if GetObjectExists( cloneIDs[t, n, x].wall ) then DeleteObject( cloneIDs[t, n, x].wall )
if GetObjectExists( cloneIDs[t, n, x].door ) then DeleteObject( cloneIDs[t, n, x].door )
if GetObjectExists( cloneIDs[t, n, x].corridor ) then DeleteObject( cloneIDs[t, n, x].corridor )
if GetObjectExists( cloneIDs[t, n, x].chest ) then DeleteObject( cloneIDs[t, n, x].chest )
if GetObjectExists( cloneIDs[t, n, x].crate ) then DeleteObject( cloneIDs[t, n, x].crate )
if GetObjectExists( cloneIDs[t, n, x].barrel ) then DeleteObject( cloneIDs[t, n, x].barrel )
next x
next n
next t
floorObjID = CreateObjectBox( 2, .25, 2 )
wallObjID = LoadObject( "wall.obj" )
corridorObjID = createobjectbox( 2, .25, 2 )
doorObjID = createobjectbox( 2, 6, 2 )
chestObjID = LoadObject( "Chest_A.obj" )
crateObjID = LoadObject( "crate.obj" )
barrelObjID = LoadObject( "barrel.obj" )
level_texture = LoadImage( "FG_Assets01_Low_D.png" )
SetObjectImage ( chestObjID, level_texture, 0 )
SetObjectImage ( crateObjID, level_texture, 0 )
SetObjectImage ( barrelObjID, level_texture, 0 )
SetObjectImage ( wallObjID, level_texture, 0 )
SetObjectColor( corridorObjID, 75, 155, 75, 255 )
SetObjectColor( doorObjID, 255, 0, 0, 255 )
SetObjectPosition( floorObjID, 3000, 8000, 3000 )
SetObjectPosition( wallObjID, 3000, 8000, 3000 )
SetObjectPosition( corridorObjID, 3000, 8000, 3000 )
SetObjectPosition( doorObjID, 3000, 8000, 3000 )
SetObjectPosition( chestObjID, 3000, 8000, 3000 )
SetObjectPosition( crateObjID, 3000, 8000, 3000 )
SetObjectPosition( barrelObjID, 3000, 8000, 3000 )
undim GPS[]
undim cloneIDs[]
dim GPS[20] as tiles
dim cloneIDs[20, 100, 100] as tiles
endfunction
function room(t as integer) //create rooms
x_dir = 1
z_dir = 1
z_offset = 0
x_offset = 0
if t > 1
GPS[t].roomx = GetobjectX( cloneIDs[t,1,0].door )
GPS[t].roomz = GetobjectZ( cloneIDs[t,1,0].door )
rm_x_axis_dir = (GetobjectX( cloneIDs[t,1,0].door ) - GetobjectX( cloneIDs[t-1,2,0].door ))
rm_z_axis_dir = (GetobjectZ( cloneIDs[t,1,0].door ) - GetobjectZ( cloneIDs[t-1,2,0].door ))
if rm_x_axis_dir < 0 or rm_z_axis_dir < 0
x_dir = -1
z_dir = -1
endif
if rm_x_axis_dir <> 0 and x_dir = 1
z_offset = 4
elseif rm_z_axis_dir <> 0 and z_dir = 1
x_offset = 4
elseif rm_x_axis_dir <> 0 and x_dir = -1
z_offset = -4
elseif rm_z_axis_dir <> 0 and z_dir = -1
x_offset = -4
endif
endif
x=1
z=0
w = random2(5,10)
h = random2(5,10)
For x = 1 to w+2 //w
if z <> 0 and x <> w+2
cloneIDs[t,x,z].room = CloneObject( floorObjID )
SetObjectPosition( cloneIDs[t,x,z].room, GPS[t].roomx+((x*2)*x_dir)-x_offset, 0, GPS[t].roomz-z_offset )
endif
For z = 1 to h+1
cloneIDs[t,x,z].room = CloneObject( floorObjID )
SetObjectPosition( cloneIDs[t,x,z].room, GPS[t].roomx+((x*2*x_dir)-(x_dir*2))-x_offset, 0, GPS[t].roomz+(z*(z_dir*2))-z_offset )
Next z
Next x
//wall
x=0
z=20
door_ID = 0
For x = 0 to w+1 //bottom //w
if GetObjectExists( cloneIDs[t,1,0].door )
door_ID = objectspherecast(0, GPS[t].roomx+(x*2*x_dir)-x_offset, 0, GPS[t].roomz-z_offset, GPS[t].roomx+(x*2*x_dir)-x_offset, 0, GPS[t].roomz-z_offset, 0)
endif
if door_ID = 0
cloneIDs[t,x,z].wall = CloneObject( wallObjID )
SetObjectPosition( cloneIDs[t,x,z].wall, GPS[t].roomx+(x*2*x_dir)-x_offset, 0, GPS[t].roomz-z_offset )
endif
Next x
x = w+1 //w+1
z = 0
For z = 0 to h+1 //right side // h+1
if GetObjectExists( cloneIDs[t,1,0].door )
door_ID = objectspherecast(0, GPS[t].roomx+(x*2*x_dir)-x_offset, 0, GPS[t].roomz+(z*2*z_dir)-z_offset, GPS[t].roomx+(x*2*x_dir)-x_offset, 0, GPS[t].roomz+(z*2*z_dir)-z_offset, 0)
if door_ID <> 0 then door_ID = GPS[t].door
endif
if door_ID = 0
cloneIDs[t,x,z].wall = CloneObject( wallObjID )
SetObjectPosition( cloneIDs[t,x,z].wall, GPS[t].roomx+(x*2*x_dir)-x_offset, 0, GPS[t].roomz+(z*2*z_dir)-z_offset )
SetObjectRotation( cloneIDs[t,x,z].wall, 0, 90, 0 )
endif
Next z
z=w+1 //w+1
x=w+2 //w+2
For z = w+1 to w+h+2 //left w+1 to w+h+1
if GetObjectExists( cloneIDs[t,1,0].door )
door_ID = objectspherecast(0, GPS[t].roomx-x_offset, 0, GPS[t].roomz+((z-w-1)*2*z_dir)-z_offset, GPS[t].roomx-x_offset, 0, GPS[t].roomz+((z-w-1)*2*z_dir)-z_offset, 0)
if door_ID <> 0 then door_ID = GPS[t].door
endif
if door_ID = 0
cloneIDs[t,x,z].wall = CloneObject( wallObjID )
SetObjectPosition( cloneIDs[t,x,z].wall, GPS[t].roomx-x_offset, 0, GPS[t].roomz+((z-w-1)*2*z_dir)-z_offset )
SetObjectRotation( cloneIDs[t,x,z].wall, 0, 90, 0 )
endif
Next z
z = w+h+2 //top w+h+2
For x = w+3 to w+w+4 //w+3 to w+3+w+1
if GetObjectExists( cloneIDs[t,1,0].door )
door_ID = objectspherecast(0, GPS[t].roomx+((x-w-3)*2*x_dir)-x_offset, 0, GPS[t].roomz+((z-w-1)*2*z_dir)-z_offset, GPS[t].roomx+((x-w-3)*2*x_dir)-x_offset, 0, GPS[t].roomz+((z-w-1)*2*z_dir)-z_offset, 0)
if door_ID <> 0 then door_ID = GPS[t].door
endif
if door_ID = 0
cloneIDs[t,x,z].wall = CloneObject( wallObjID )
SetObjectPosition( cloneIDs[t,x,z].wall, GPS[t].roomx+((x-w-3)*2*x_dir)-x_offset, 0, GPS[t].roomz+((z-w-1)*2*z_dir)-z_offset )
endif
Next x
//create function for decor
placedecor( w, h, t )
if t >= 1 and t < dng_gen_rooms
corridorfill( w, h, t, rm_x_axis_dir, rm_z_axis_dir )
chest_chance = Random2(1,100)
if chest_chance >= 20 and chest_chance <= 25
x = random2( 3, w-1 )
z= random2( 3, h-1 )
cloneIDs[t,1,1].chest = CloneObject( chestObjID )
SetObjectPosition( cloneIDs[t,1,1].chest, GetObjectX( cloneIDs[t,x,z].room ), 1, GetObjectZ( cloneIDs[t,x,z].room ) )
endif
endif
if t = dng_gen_rooms
//chest_chance = Random2(1,100)
//if chest_chance >= 20 and chest_chance <= 40
x = random2( 2, w )
z= random2( 2, h )
SetObjectPosition( chestObjID, GetObjectX( cloneIDs[t,x,z].room ), 1, GetObjectZ( cloneIDs[t,x,z].room ) )
endif
if GetObjectExists( cloneIDs[t,1,0].door )
wallID = objectspherecast(0, GetObjectX( cloneIDs[t,1,0].door ), 1.0, GetObjectZ( cloneIDs[t,1,0].door ), GetObjectX( cloneIDs[t,1,0].door ), 1.0, GetObjectZ( cloneIDs[t,1,0].door ), 0)
if GetObjectExists( wallID ) then DeleteObject(wallID)
endif
endfunction
function corridorfill( w as integer, h as integer, t as integer, rm_x_axis_dir as integer, rm_z_axis_dir as integer )
if Last_Corridor_Direction = 1 or Last_Corridor_Direction = 3
if Prvs_Last_Corridor_Direction = 2 or Prvs_Last_Corridor_Direction = 4
repeat
Current_Corridor_Direction = random2(1,4)
until Current_Corridor_Direction <> Last_Corridor_Direction and Current_Corridor_Direction <> 2 and Current_Corridor_Direction <> 4
elseif Prvs_Last_Corridor_Direction = 1
repeat
Current_Corridor_Direction = random2(1,4)
until Current_Corridor_Direction <> Last_Corridor_Direction and Current_Corridor_Direction <> 2
else
repeat
Current_Corridor_Direction = random2(1,4)
until Current_Corridor_Direction <> Last_Corridor_Direction
endif
elseif Last_Corridor_Direction = 2 or Last_Corridor_Direction = 4
if Prvs_Last_Corridor_Direction = 1 or Prvs_Last_Corridor_Direction = 3
repeat
Current_Corridor_Direction = random2(1,4)
until Current_Corridor_Direction <> Last_Corridor_Direction-1 and Current_Corridor_Direction <> Prvs_Last_Corridor_Direction - 1 and Current_Corridor_Direction <> Prvs_Last_Corridor_Direction
else
repeat
Current_Corridor_Direction = random2(1,4)
until Current_Corridor_Direction <> Last_Corridor_Direction-1 and Current_Corridor_Direction <> Prvs_Last_Corridor_Direction-1
endif
else
Current_Corridor_Direction = random2(1,4)
endif
cloneIDs[t,2,0].door = CloneObject( doorObjID )
if Current_Corridor_Direction = 1 //south
x = random2(2,w-1)
z = 20
SetObjectPosition( cloneIDs[t,2,0].door, GetObjectX( cloneIDs[t,x,z].wall ), 0, GetObjectZ( cloneIDs[t,x,z].wall ) )
DeleteObject( cloneIDs[t,x,z].wall )
z_dir = 1
elseif Current_Corridor_Direction = 2 //north
x = random2(w+4,w+w+3)
z = w+h+2
SetObjectPosition( cloneIDs[t,2,0].door, GetObjectX( cloneIDs[t,x,z].wall ), 0, GetObjectZ( cloneIDs[t,x,z].wall ) )
DeleteObject( cloneIDs[t,x,z].wall )
z_dir = -1
elseif Current_Corridor_Direction = 3 //west
x = w+2
z= random2(w+2,w+h)
SetObjectPosition( cloneIDs[t,2,0].door, GetObjectX( cloneIDs[t,x,z].wall ), 0, GetObjectZ( cloneIDs[t,x,z].wall ) )
DeleteObject( cloneIDs[t,x,z].wall )
x_dir = 1
elseif Current_Corridor_Direction = 4 //east
x = w+1
z= random2(1,h)
SetObjectPosition( cloneIDs[t,2,0].door, GetObjectX( cloneIDs[t,x,z].wall ), 0, GetObjectZ( cloneIDs[t,x,z].wall ) )
DeleteObject( cloneIDs[t,x,z].wall )
x_dir = -1
endif
counter = random2(4,7) //corridor length
if rm_x_axis_dir < 0 or rm_z_axis_dir < 0
x_dir = x_dir*-1
z_dir = z_dir*-1
endif
z=0
x=0
n = 1
repeat
select Current_Corridor_Direction
case 1: //south
cloneIDs[t,x,z+n].corridor = CloneObject( corridorObjID )
SetObjectPosition( cloneIDs[t,x,z+n].corridor, GetObjectX( cloneIDs[t,2,0].door ), 0, GetObjectZ( cloneIDs[t,2,0].door )-(z_dir*(n*2)) )
if n = counter-1
cloneIDs[t+1,1,0].door = CloneObject( doorObjID )
SetObjectPosition( cloneIDs[t+1,1,0].door, GetObjectX( cloneIDs[t,2,0].door ), 0, GetObjectZ( cloneIDs[t,2,0].door )-(z_dir*((n+1)*2)) )
endif
endcase
case 2: //north
cloneIDs[t,x,z+n].corridor = CloneObject( corridorObjID )
SetObjectPosition( cloneIDs[t,x,z+n].corridor, GetObjectX( cloneIDs[t,2,0].door ), 0, GetObjectZ( cloneIDs[t,2,0].door )-(z_dir*(n*2)) )
if n = counter-1
cloneIDs[t+1,1,0].door = CloneObject( doorObjID )
SetObjectPosition( cloneIDs[t+1,1,0].door, GetObjectX( cloneIDs[t,2,0].door ), 0, GetObjectZ( cloneIDs[t,2,0].door )-(z_dir*((n+1)*2)) )
endif
endcase
case 3: //west
cloneIDs[t,x+n,z].corridor = CloneObject( corridorObjID )
SetObjectPosition( cloneIDs[t,x+n,z].corridor, GetObjectX( cloneIDs[t,2,0].door )-x_dir*(n*2), 0, GetObjectZ( cloneIDs[t,2,0].door ) )
if n = counter-1
cloneIDs[t+1,1,0].door = CloneObject( doorObjID )
SetObjectPosition( cloneIDs[t+1,1,0].door, GetObjectX( cloneIDs[t,2,0].door )-x_dir*((n+1)*2), 0, GetObjectZ( cloneIDs[t,2,0].door ) )
endif
endcase
case 4: //east
cloneIDs[t,x+n,z].corridor = CloneObject( corridorObjID )
SetObjectPosition( cloneIDs[t,x+n,z].corridor, GetObjectX( cloneIDs[t,2,0].door )-x_dir*(n*2), 0, GetObjectZ( cloneIDs[t,2,0].door ) )
if n = counter-1
cloneIDs[t+1,1,0].door = CloneObject( doorObjID )
SetObjectPosition( cloneIDs[t+1,1,0].door, GetObjectX( cloneIDs[t,2,0].door )-x_dir*((n+1)*2), 0, GetObjectZ( cloneIDs[t,2,0].door ) )
endif
endcase
endselect
n=n+1
until n = counter
Prvs_Last_Corridor_Direction = Last_Corridor_Direction
Last_Corridor_Direction = Current_Corridor_Direction
if GetObjectExists( cloneIDs[6,1,0].door ) then SetObjectColor( cloneIDs[6,1,0].door, 255, 150, 75, 255 )
global Current_Corridor_Direction
global Last_Corridor_Direction
global Prvs_Last_Corridor_Direction
dim crd[20] as tiles
crd[t].room = Current_Corridor_Direction
endfunction
function placedecor( w as integer, h as integer, t as integer )
x = random2( 2, w )
z= random2( 2, h )
cloneIDs[t,1,1].barrel = CloneObject( barrelObjID )
SetObjectPosition( cloneIDs[t,1,1].barrel, GetObjectX( cloneIDs[t,x,z].room ), 0, GetObjectZ( cloneIDs[t,x,z].room ) )
endfunction
This is completely bizarre. I've tried many things, and I have come to the conclusion that is not returning as an object existing. I know this is like finding a needle in a haystack, but maybe there is something I don't understand about #include...