print("Loading SeaSide Level")
saveSlot();
clear();

--LEVEL SETUP

--set Background
--texture, width, height, position X, position Y
--setBackGround(map_BackGround, 200, 200, 0, 0);
setBackGround("map_seaside.dds", 200, 200, 0, 0);
setTerrainMap("terraininfo_seaside.tga");
setGameMode(3);
gofile("setViewDistance.lua");

--set Sun
--distance X, distance Y
setSunDist(-0.55, 1.0);

--set Dust visual element
setDustElement(vel_dust);
setSkidElement(vel_skid);

--set Borders
--position X, position Y, direction, elasticity
addBorder(0, 100, PI, 0.7);
addBorder(100, 0, HALFPI, 0.7);
addBorder(0, -100, 0, 0.7);
addBorder(-100, 0, THREEHALFPI, 0.7);

--setWaypoints
--position X, position Y
addWaypoint(-60, 65);
addWaypoint(50, 65);
addWaypoint(40, -25);
addWaypoint(-60, -30);

--setLinkPoints
--position X, position Y, radius, clearlevel?(never use), mustStop?, dofile
addLinkPoint(-65.6, 100, 14, false, false, "saveTown(); gofile(\"control.lua\")");
addLinkPoint(-4.73, -100.0, 14, false, false, "saveTown(); gofile(\"control.lua\")");
addLinkPoint(-63.74, -85.246, 7, false, true, "gofile(\"store/store_dealer.lua\")");
addLinkPoint(17.15, -54.0, 7, false, true, "gofile(\"store/store_gunsSeaside.lua\")");
addLinkPoint(-88.7, -53.76, 7, false, true, "gofile(\"store/store_trader.lua\")");
addLinkPoint(-22.9, 70.66, 7, false, true, "gofile(\"store/store_missions.lua\")");

addBaseSprite(vel_baseArrow, -65, 94, PI * 0.09);
addBaseSprite(vel_baseArrow, -8, -94, PI * 1.06);
addBaseSprite(vel_baseCars, -63.74, -85.246, PI * 0.00);
addBaseSprite(vel_baseGuns, 17.15, -54.0, PI * 0.00);
addBaseSprite(vel_baseTrade, -88.7, -53.76, PI * 0.00);
addBaseSprite(vel_baseJobs, -22.9, 70.66, PI * 0.00);

--set Camera Extents
--max X, min X, max Y, min Y
--setCameraExtents(50.0, -50.0, 62.5, -62.5);
autoCameraExtents();

--set Obstacles
--texture, size X, size Y, position X, position Y, direction 
addObstacleBox(map_Building, 21.0, 39.8, -91.811, -83.32, PI * 1.995);
addObstacleBox(map_Building, 3.8, 16.2, -51.71, -92.34, PI * 2.00);

addObstacleBox(map_Building, 23.6, 58.8, -2.77, 68.59, PI * 2.00);

addObstacleBox(map_Building, 12.8, 31.9, 38.212, -65.616, PI * 1.98);
addObstacleBox(map_Building, 19.4, 25.7, 38.212, -65.616, PI * 1.98);

addObstacleBox(map_Building, 5.3, 20.2, 42.75, -91.65, PI * 0.001592);
addObstacleBox(map_Building, 8.9, 66.9, 31.88, -21.07, PI * 0.179845);
addObstacleBox(map_Building, 6.9, 19.5, 28.388, -23.84, PI * 0.196556);

addObstacleBox(map_Building, 7.69, 24.2, 10.27, 25.79, PI * 0.002387);
addObstacleBox(map_Building, 5.89, 32.4, 15.044, 17.26, PI * 0.042972);






--misc Mobs
--texture, size X, size Y, position X, position Y, mass, elastic, friction, round 

--set Waves
--line1 return handle> min Enemies
--lines wave handel, being handle, pos X, pos Y, team, tatic
--wave_1 = addWave(0);
--setWaveEntry(wave_1, car_camino, 60, -220, 2, 0);

loadTown(townseaside);

--dealership
car1 = addBeing(dealerCar1, -41.15, -76.85, PI * 0.732, 1);
car2 = addBeing(dealerCar2, -39.07, -89.522, PI * 0.732, 1);
addToDealer(car1);
addToDealer(car2);
--addBeing(playerCar, -36.8, -10.0, 0, 1);

--general store
--carParts, tequlia, fireworks, swag, pills
--setStoreCargo(4, 13, 5, 12, 1);
--setCargoPrices(3, 8, 10, 5, 50);
--setStoreCash(780);




--setup Player: Car, audio listener, and camera follow
player = addBeing(playerCar, -22.2, -40.05, PI * 0.093, 1);
setPlayerBeing(player);
setMobHealth(player, getPlayerHealth());
setWeapon(player, 1, playerWeapon1);
setWeapon(player, 2, playerWeapon2);

saveSlot();
