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

--LEVEL SETUP

--set Background
--texture, width, height, position X, position Y
--setBackGround(map_BackGround, 200, 200, 0, 0);
setBackGround("map_rivertown.dds", 200, 200, 0, 0);
setTerrainMap("terraininfo_rivertown.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(-100, 2.9, 14, false, false, "saveTown(); gofile(\"control.lua\")");
addLinkPoint(100, -73.6, 14, false, false, "saveTown(); gofile(\"control.lua\")");
addLinkPoint(45.32, -46.5, 7, false, true, "gofile(\"store/store_dealer.lua\")");
addLinkPoint(-71.7, -23.56, 7, false, true, "gofile(\"store/store_gunsRiver.lua\")");
addLinkPoint(62.85, 4.8, 7, false, true, "gofile(\"store/store_trader.lua\")");
addLinkPoint(-61.64, 51.22, 7, false, true, "gofile(\"store/store_missions.lua\")");

addBaseSprite(vel_baseArrow, -94, 5, PI * 0.656);
addBaseSprite(vel_baseArrow, 94, -68, PI * 1.26);
addBaseSprite(vel_baseCars, 45.32, -46.5, PI * 0.00);
addBaseSprite(vel_baseGuns, -71.7, -23.56, PI * 0.00);
addBaseSprite(vel_baseTrade, 62.85, 4.8, PI * 0.00);
addBaseSprite(vel_baseJobs, -61.64, 51.22, 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, 25.0, 44.2, -34.18, 56.8, PI * 1.848);
addObstacleBox(map_Building, 6.4, 88.5, -16.3, 61.8, PI * 1.853574);
addObstacleBox(map_Building, 25.2, 51.6, 50.73, 30.67, PI * 1.844);
addObstacleBox(map_Building, 25.2, 24.0, 74.86, 71.98, PI * 1.844);
addObstacleBox(map_Building, 10.8, 14.6, 64.2757, 57.749, PI * 1.844);
addObstacleBox(map_Building, 10.8, 115.2, 47.786236, 53.9306, PI * 1.836066);

addObstacleBox(map_Building, 67.7, 7.8, -5.6835, 14.916, PI * 1.890976);
addObstacleBox(map_Building, 67.59, 6.0, -13.0437, -5.126, PI * 1.890976);

addObstacleBox(map_Building, 13.8, 31.7, -54.0, -30.5, PI * 1.952);
addObstacleBox(map_Building, 7.0, 29.3, -41.85, -8.7, PI * 1.961);
addObstacleBox(map_Building, 9.4, 14.8, -51.74, -53.8, PI * 0.002387);
addObstacleBox(map_Building, 8.2, 49.89, -48.1, -85.94, PI * 1.982493);

addObstacleBox(map_Building, 8.2, 58.89, 9.546, -42.796, PI * 1.961802);
addObstacleBox(map_Building, 5.4, 34.0, 11.935, -84.378, PI * 0.098676);


--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(townrivertown);

--dealership
car1 = addBeing(dealerCar1, 39.5, -55.46, PI * 0.311, 1);
car2 = addBeing(dealerCar2, 36.3, -63.22, PI * 0.311, 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, 57.0, -25.0, PI * 0.311, 1);
setPlayerBeing(player);
setMobHealth(player, getPlayerHealth());
setWeapon(player, 1, playerWeapon1);
setWeapon(player, 2, playerWeapon2);

saveSlot();
