Hey janbo,
Code for leaving the scene and going to the world map:
function travel_mode_loadup()
if GetObjectX( game.player.objID ) > 26.0 or GetObjectX( game.player.objID ) < -26.0 or GetObjectZ( game.player.objID ) > 26.0 or GetObjectZ( game.player.objID ) < -26.0
map_travel_mode = 1
stop_pathfinding()
else // need to add door in dungeon for player to leave
exitfunction
endif
delete_prev_area()
dim_global_arrays()
load_travel_map()
SetCameraPosition( 1, 0, 8.0, 0 )
SetCameraLookAt( 1, 0, 0, 0, 0 )
SetShadowMappingMode( 3 )
SetShadowSmoothing( 2 )
setshadowrange( 8.0 )
SetShadowMapSize( 1024, 1024 )
SetShadowBias( 0.0012 )
SetObjectVisible( game.player.objID, 0 )
endfunction
Deleting the scene:
function delete_prev_area()
if current_area = 1
for i = 0 to house_area_images.length
if GetImageExists( house_area_images[i] ) = 1 then DeleteImage( house_area_images[i] )
next i
for i = 0 to house_area_objects.length
if GetObjectExists( house_area_objects[i] ) = 1 then DeleteObject( house_area_objects[i] )
next i
for i = 0 to house_construction.length
if GetObjectExists( house_construction[i].ID ) = 1 then DeleteObject( house_construction[i].ID )
next i
for i = 0 to area_doors.length
if GetObjectExists( area_doors[i].ID ) = 1 then DeleteObject( area_doors[i].ID )
next i
for i = 0 to resource_obj_imgs.length
if GetImageExists( resource_obj_imgs[i] ) = 1 then DeleteImage( resource_obj_imgs[i] )
next i
for i = 0 to terrain_images.length
if GetImageExists( terrain_images[i] ) = 1 then DeleteImage( terrain_images[i] )
next i
DeleteObject( home_grd )
home_grd = 0
DeleteShader( terrainshader )
undim terrain_images[]
undim resource_obj_imgs[]
undim area_doors[]
undim house_construction[]
undim house_area_objects[]
undim house_area_images[]
undim house_obj_screen_coords[]
SetSpriteVisible( carpenter_sprite, 0 )
elseif current_area = 2
delete_dungeon_assets()
endif
undim loot_tracker_info[]
undim area_loot_containers[]
for i = 0 to resource_objs.length
if GetObjectExists( resource_objs[i].ID ) = 1 then DeleteObject( resource_objs[i].ID )
next i
// need to add resource images
undim resource_objs[] // not needed in dungeons
undim area_loot_containers[]
for i = 0 to area_objects.length
if GetObjectExists( area_objects[i] ) = 1 then DeleteObject( area_objects[i] )
next i
undim area_objects[]
undim pf_node_info[]
if map_travel_mode = 1
for i = 0 to mapobjectarray.length
DeleteObject( mapobjectarray[i].ID )
next i
undim mapobjectarray[]
for i = 0 to mapimagearray.length
DeleteImage( mapimagearray[i] )
next i
undim mapimagearray[]
DeleteObject( travel_map_grd )
endif
health_and_dura_icon_maintenance_hide()
SetSpriteVisible( xpbar_spr, 0 )
Dim global arrays function
function dim_global_arrays()
/// global msg arrays are declared in the global msg setup function since we never need to undim it
if map_travel_mode = 0
dim loot_tracker_info[] as inventory_items
dim area_loot_containers[] as storage_container //for UI purposes
dim area_objects[]
dim ph_loot[] as ph_loots
if current_area = 1
dim house_area_images[] as integer
dim house_area_objects[] as integer
dim area_doors[] as doors //place doors here to test
dim house_construction[] as Home_Objects
dim house_obj_screen_coords[1] as float
dim home_containers[] as storage_container
dim resource_objs[] as resource_objects //trees etc... not needed in dungeons
dim resource_obj_imgs[9] as integer
dim terrain_images[6] as integer
endif
if current_area = 2
dim maptracking[100,3] as map
dim rm_Size[100,4] as map
dim ObjIDs[100,200] as dng_object
dim pf_node_info[pf_gridx,pf_gridz,1] // 0 = vector, 1 = walkable
endif
elseif map_travel_mode = 1
dim mapobjectarray[] as area_world_map
dim mapimagearray[] as integer
endif
endfunction
function to load new area
function load_new_area( n )
if mapobjectarray[n].area_name = "Home"
delete_prev_area()
map_travel_mode = 0
current_area = 1
LoadHome()
game_state = 100
endif
endfunction
LoadHome function
pf_gridx = 60 //needs to be grid world size X
pf_gridz = 60 //needs to be grid world size Z
pathfinder_array_setup() //needs to be before load area objects to get trees
dim_global_arrays() //loads arrays needed for area
load_ground_overland() //loads terrain
Doors_Walls_Floors_Windows_asset_load() //loads house construction stuff
load_area_objects() // need to redo this loads resources
pathfinding_grid_setup()
SetSpriteVisible( carpenter_sprite, 1 )
health_and_dura_icon_maintenance()
update_dura_doll()
updatexpbar_gi()
SetObjectPosition( game.player.objID, 0, .1, 25 )
SetObjectPosition( game.player.collisionbox, GetObjectX(game.player.objID), GetObjectY(game.player.objID), GetObjectZ(game.player.objID))
SetObjectVisible( game.player.objID, 1 )
x# = GetObjectX(game.player.objID)
y# = GetObjectY(game.player.objID)
z# = GetObjectZ(game.player.objID)
//SetPointLightPosition( 1, x#, -.15, z# )
SetCameraPosition( 1, x#, y#, z# )
SetCameraRotation( 1, -25, 25, -0 )
MoveCameraLocalY( 1, player_camera_zoom#)
MoveCameraLocalZ( 1, -.95 )
//SetCameraRotation( 1, -35, 25, 0 )
//MoveCameraLocalY( 1, 7.5)
SetCameraLookAt(1, x#, y#, z#, 0 )
Function to create the terrain
home_grd = CreateObjectPlane( 70, 70 ) //split up into different objs or use heightmap?
SetObjectCollisionMode( home_grd, 0 )
SetObjectRotation( home_grd, 90, 0, 0)
SetGenerateMipmaps(1)
terrain_images[0] = LoadImage("/media/terraintest/splatmap.png")
//terrain_images[1] = LoadImage( "/media/terraintest/terrain_n.png" )
//SetObjectNormalMap( home_grd, terrain_images[1] )
SetObjectLightMode( home_grd, 1 )
terrain_images[2] = LoadImage( "/media/terraintest/grass.png" ) //doesnt show up after the 1st time
terrain_images[3] = LoadImage( "/media/terraintest/rock.png" ) //doesnt show up after the 1st time
terrain_images[4] = LoadImage( "/media/terraintest/dirt.png" ) //ground
SetImageWrapU( terrain_images[2], 1 )
SetImageWrapV( terrain_images[2], 1 )
SetImageWrapU( terrain_images[3], 1 )
SetImageWrapV( terrain_images[3], 1 )
SetImageWrapU( terrain_images[4], 1 )
SetImageWrapV( terrain_images[4], 1 )
uvscale = 36
SetObjectImage( home_grd, terrain_images[4], 0 ) //ground
SetObjectUVScale( home_grd, 0, uvscale, uvscale )
SetObjectImage( home_grd, terrain_images[2], 1 ) //grass //doesnt show up after the 1st time
SetObjectUVScale( home_grd, 1, uvscale, uvscale )
SetObjectImage( home_grd, terrain_images[3], 2 ) //rock //doesnt show up after the 1st time
SetObjectUVScale( home_grd, 3, uvscale, uvscale )
SetObjectImage( home_grd, terrain_images[0], 3 ) // splat
SetObjectUVScale( home_grd, 4, 1, 1 )
terrain_images[6] = LoadImage( "/media/terraintest/neon.png" )
SetObjectImage( home_grd, terrain_images[6], 4 )
SetObjectPosition( home_grd, 0, 0, 0 )
terrainshader = LoadShader( "/media/shaders/splatmapterrain.vs", "/media/shaders/splatmapterrain.ps" )
SetObjectShader( home_grd, terrainshader )
Loading the map:
function load_travel_map()
SetGenerateMipmaps(1)
mapimagearray.insert( LoadImage( "/media/travelmap/artifactrockprint.png" ) )
mapimagearray.insert( LoadImage( "/media/travelmap/lowpolymap.png" ) )
mapimagearray.insert( LoadImage( "/media/travelmap/stronghold.png" ) )
mapimagearray.insert( LoadImage( "/media/travelmap/mainmap.png" ) )
mapimagearray.insert( LoadImage( "/media/animaltexture.png" ) )
SetGenerateMipmaps(0)
T as area_world_map
travel_map_grd = CreateObjectPlane( 25, 25 ) //needs to be global?
SetObjectCollisionMode( travel_map_grd, 0 )
SetObjectRotation( travel_map_grd, 90, 0, 0 )
SetObjectImage( travel_map_grd, mapimagearray[3], 0 )
T.ID = LoadObject( "/media/travelmap/cave.fbx" )
T.area_name = "Helheim"
mapobjectarray.insert( T ) //Helheim
SetObjectImage( mapobjectarray[0].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[0].ID, -0.504356, 0, 9.86548 )
SetObjectCastShadow( mapobjectarray[0].ID , 1 )
T.ID = LoadObject( "/media/travelmap/tree_area.fbx" )
T.area_name = "Amelthus' Forest"
mapobjectarray.insert( T ) //Amelthus' Forest
SetObjectImage( mapobjectarray[1].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[1].ID, 2.61349, 0, -1.26013 )
SetObjectCastShadow( mapobjectarray[1].ID, 1 )
T.ID = LoadObject( "/media/travelmap/rock_area.fbx" )
T.area_name = "Malmr Jord"
mapobjectarray.insert( T ) //Malmr Jord
SetObjectImage( mapobjectarray[2].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[2].ID, -0.41394, 0, -1.94185 )
SetObjectCastShadow( mapobjectarray[2].ID , 1 )
T.ID = LoadObject( "/media/travelmap/home.fbx" )
T.area_name = "Home"
mapobjectarray.insert( T ) //Home
SetObjectImage( mapobjectarray[3].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[3].ID, -3.16121, 0, -1.70895 )
SetObjectCastShadow( mapobjectarray[3].ID , 1 )
T.ID = LoadObject( "/media/travelmap/glowingancientstones.fbx" )
T.area_name = "Alfheim"
mapobjectarray.insert( T ) //Alfheim
SetObjectMeshImage( mapobjectarray[4].ID, 1, mapimagearray[1], 0 )
SetObjectMeshImage( mapobjectarray[4].ID, 2, mapimagearray[0], 0 )
//SetObjectLightMode( mapobjectarray[4].ID, 0 )
SetObjectPosition( mapobjectarray[4].ID, -8.88319, 0, -7.51452 )
SetObjectCastShadow( mapobjectarray[4].ID , 1 )
T.ID = LoadObject( "/media/travelmap/tower.fbx" )
T.area_name = "Building of the Gods"
mapobjectarray.insert( T ) //Building of the Gods AKA Vingolf
SetObjectImage( mapobjectarray[5].ID, mapimagearray[2], 0 )
SetObjectPosition( mapobjectarray[5].ID, 10.7216, 0, 7.07375 )
SetObjectCastShadow( mapobjectarray[5].ID , 1 )
T.ID = LoadObject( "/media/travelmap/bigtree.fbx" )
T.area_name = "World Tree"
mapobjectarray.insert( T ) //World Tree - Yggdrasil
SetObjectImage( mapobjectarray[6].ID, level_texture, 0 )
SetObjectNormalMap( mapobjectarray[6].ID, level_texture_nrm )
SetObjectPosition( mapobjectarray[6].ID, -5.73164, 0, -10.0471 )
SetObjectAlphaMask( mapobjectarray[6].ID, 1 )
SetObjectCastShadow( mapobjectarray[6].ID , 1 )
T.ID = LoadObject( "/media/travelmap/tent.fbx" )
T.area_name = "Harald's Camp"
mapobjectarray.insert( T ) //Harald's Camp
SetObjectImage( mapobjectarray[7].ID, level_texture, 0 )
SetObjectNormalMap( mapobjectarray[7].ID, level_texture_nrm )
SetObjectPosition( mapobjectarray[7].ID, -9.2069, 0, 0.042912 )
SetObjectCastShadow( mapobjectarray[7].ID , 1 )
T.ID = LoadObject( "/media/travelmap/city.fbx" )
T.area_name = "Birka"
mapobjectarray.insert( T ) //Birka
SetObjectImage( mapobjectarray[8].ID, level_texture, 0 )
SetObjectNormalMap( mapobjectarray[8].ID, level_texture_nrm )
SetObjectPosition( mapobjectarray[8].ID, 3.80388, -0.05, -10.0 )
SetObjectLightMode( mapobjectarray[8].ID, 0 )
SetObjectCastShadow( mapobjectarray[8].ID , 1 )
T.ID = LoadObject( "/media/travelmap/longhouse.fbx" )
T.area_name = "Wodan-stad"
mapobjectarray.insert( T ) // Wodan-stad
SetObjectImage( mapobjectarray[9].ID, level_texture, 0 )
SetObjectNormalMap( mapobjectarray[9].ID, level_texture_nrm )
SetObjectPosition( mapobjectarray[9].ID, 3.63484, 0, 0.671384 )
SetObjectLightMode( mapobjectarray[9].ID, 0 )
SetObjectCastShadow( mapobjectarray[9].ID , 1 )
T.ID = LoadObject( "/media/travelmap/teleporter.fbx" )
T.area_name = "Vak's Hideout"
mapobjectarray.insert( T ) //Vak's Hideout
SetObjectImage( mapobjectarray[10].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[10].ID, -10.4987, 0, 10.4736 )
SetObjectCastShadow( mapobjectarray[10].ID , 1 )
T.ID = LoadObject( "/media/travelmap/tree_area2.fbx" )
T.area_name = "Munin's Grove"
mapobjectarray.insert( T ) // Munin 's Grove
SetObjectImage( mapobjectarray[11].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[11].ID, 5.72626, 0, -0.882749 )
SetObjectCastShadow( mapobjectarray[11].ID , 1 )
T.ID = LoadObject( "/media/travelmap/tree_area3.fbx" )
T.area_name = "Forest of Odin"
mapobjectarray.insert( T ) // Forest of Odin
SetObjectImage( mapobjectarray[12].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[12].ID, 5.62802, 0, 1.98208 )
SetObjectCastShadow( mapobjectarray[12].ID , 1 )
T.ID = LoadObject( "/media/travelmap/rock_area2.fbx" )
T.area_name = "Stone Cliff"
mapobjectarray.insert( T ) //Stone aCliff
SetObjectImage( mapobjectarray[13].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[13].ID, -4.02774, 0, -4.04799 )
SetObjectCastShadow( mapobjectarray[13].ID , 1 )
T.ID = LoadObject( "/media/travelmap/rock_area3.fbx" )
T.area_name = "Rock Ridge"
mapobjectarray.insert( T ) // Rock Ridge
SetObjectImage( mapobjectarray[14].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[14].ID, -1.2701, 0, -7.56566 )
SetObjectCastShadow( mapobjectarray[14].ID , 1 )
T.ID = CloneObject( mapobjectarray[0].ID )
T.area_name = "Balder's Hellir"
mapobjectarray.insert( T ) //Balder's Hellir
SetObjectImage( mapobjectarray[15].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[15].ID, 8.04013, 0, -9.61343 )
SetObjectCastShadow( mapobjectarray[15].ID , 1 )
SetObjectRotation( mapobjectarray[15].ID, 0, 150.0, 0 )
T.ID = CloneObject( mapobjectarray[9].ID )
T.area_name = "Erik-stad"
mapobjectarray.insert( T ) //Erik-stad
SetObjectImage( mapobjectarray[16].ID, level_texture, 0 )
SetObjectNormalMap( mapobjectarray[16].ID, level_texture_nrm )
SetObjectPosition( mapobjectarray[16].ID, -4.80766, 0, 2.09919 )
SetObjectLightMode( mapobjectarray[16].ID, 0 )
SetObjectCastShadow( mapobjectarray[16].ID , 1 )
SetObjectRotation( mapobjectarray[16].ID, 0, 250.0, 0 )
T.ID = CloneObject( mapobjectarray[12].ID )
T.area_name = "Ashwood Grove"
mapobjectarray.insert( T ) // Ashwood Grove
SetObjectImage( mapobjectarray[17].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[17].ID, -9.08281, 0, -11.2054 )
SetObjectCastShadow( mapobjectarray[17].ID , 1 )
T.ID = CloneObject( mapobjectarray[10].ID )
T.area_name = "Mimir's Well"
mapobjectarray.insert( T ) // Mimir's Well
SetObjectImage( mapobjectarray[18].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[18].ID, -1.10251, 0, 1.23683 )
SetObjectCastShadow( mapobjectarray[18].ID , 1 )
T.ID = CloneObject( mapobjectarray[7].ID )
T.area_name = "Abandoned Camp"
mapobjectarray.insert( T ) //abanonded camp
SetObjectImage( mapobjectarray[19].ID, level_texture, 0 )
SetObjectNormalMap( mapobjectarray[19].ID, level_texture_nrm )
SetObjectPosition( mapobjectarray[19].ID, -2.97838, 0, 6.57185 )
SetObjectCastShadow( mapobjectarray[19].ID , 1 )
T.ID = LoadObject( "/media/travelmap/campfire.fbx" )
T.area_name = "Skoggangr's Cove"
mapobjectarray.insert( T ) // skóggangr's cove - skógarmaðr meant bandit
SetObjectImage( mapobjectarray[20].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[20].ID, 3.58573, 0, 3.90104 )
SetObjectCastShadow( mapobjectarray[20].ID , 1 )
T.ID = CloneObject( mapobjectarray[14].ID )
T.area_name = "Wolve's Ridge"
mapobjectarray.insert( T ) //rockarea 3 Wolve's Ridge
SetObjectImage( mapobjectarray[21].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[21].ID, 5.97769, 0, 6.39724 )
SetObjectCastShadow( mapobjectarray[21].ID , 1 )
T.ID = CloneObject( mapobjectarray[13].ID )
T.area_name = "Loki's Ridge"
mapobjectarray.insert( T ) // Loki's Ridge
SetObjectImage( mapobjectarray[22].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[22].ID, -8.90663, 0, -4.68944 )
SetObjectCastShadow( mapobjectarray[22].ID , 1 )
T.ID = LoadObject( "/media/travelmap/animals.fbx" )
T.area_name = "Thor's Meadow"
mapobjectarray.insert( T ) // Thor's Meadow
SetObjectImage( mapobjectarray[23].ID, mapimagearray[4], 0 )
SetObjectPosition( mapobjectarray[23].ID, -9.98484, 0, 2.70887 )
SetObjectCastShadow( mapobjectarray[23].ID , 1 )
T.ID = CloneObject( mapobjectarray[23].ID )
T.area_name = "Freya's Field"
mapobjectarray.insert( T ) //animals Freya's Field
SetObjectImage( mapobjectarray[24].ID, mapimagearray[4], 0 )
SetObjectPosition( mapobjectarray[24].ID, 2.41648, 0, 9.08448 )
SetObjectCastShadow( mapobjectarray[24].ID , 1 )
T.ID = CloneObject( mapobjectarray[23].ID )
T.area_name = "Freki's Jord"
mapobjectarray.insert( T ) //animals Freki's Jord
SetObjectImage( mapobjectarray[25].ID, mapimagearray[4], 0 )
SetObjectPosition( mapobjectarray[25].ID, 4.40301, 0, -6.58623 )
SetObjectCastShadow( mapobjectarray[25].ID , 1 )
T.ID = CloneObject( mapobjectarray[12].ID )
T.area_name = "Spruce Forest"
mapobjectarray.insert( T ) //tree area 3 // Spruce Forest
SetObjectImage( mapobjectarray[26].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[26].ID, 6.80364, 0, 10.2788 )
SetObjectCastShadow( mapobjectarray[26].ID , 1 )
T.ID = CloneObject( mapobjectarray[9].ID )
T.area_name = "Bjorn-stad"
mapobjectarray.insert( T ) //longhouse //Bjorn-stad
SetObjectImage( mapobjectarray[27].ID, level_texture, 0 )
SetObjectNormalMap( mapobjectarray[27].ID, level_texture_nrm )
SetObjectPosition( mapobjectarray[27].ID, -7.06038, 0, 10.2436 )
SetObjectLightMode( mapobjectarray[27].ID, 0 )
SetObjectCastShadow( mapobjectarray[27].ID , 1 )
SetObjectRotation( mapobjectarray[27].ID, 0, 250.0, 0 )
T.ID = CloneObject( mapobjectarray[11].ID )
T.area_name = "Dark Forest"
mapobjectarray.insert( T ) //tree area 2 Dark Forest
SetObjectImage( mapobjectarray[28].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[28].ID, -7.78676, 0, 6.72063 )
SetObjectCastShadow( mapobjectarray[28].ID , 1 )
T.ID = CloneObject( mapobjectarray[10].ID )
T.area_name = "Gnipahellir"
mapobjectarray.insert( T ) //Gnipahellir
SetObjectImage( mapobjectarray[29].ID, mapimagearray[1], 0 )
SetObjectPosition( mapobjectarray[29].ID, 9.20183, 0, -3.49096 )
SetObjectCastShadow( mapobjectarray[29].ID , 1 )
endfunction