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

--LEVEL SETUP

--set Background
--texture, width, height, position X, position Y
--setBackGround(map_BackGround, 200, 200, 0, 0);
setBackGround("map_western.dds", 200, 200, 0, 0);
setTerrainMap("terraininfo_western.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, -15, 14, false, false, "saveTown(); gofile(\"control.lua\")");
addLinkPoint(100, 3.33, 14, false, false, "saveTown(); gofile(\"control.lua\")");
addLinkPoint(-2.65, -30.37, 7, false, true, "gofile(\"store/store_dealer.lua\")");
addLinkPoint(24.1, 46.5, 7, false, true, "gofile(\"store/store_gunsWestern.lua\")");
addLinkPoint(-44.8, 43, 7, false, true, "gofile(\"store/store_trader.lua\")");
addLinkPoint(-50, -13.5, 7, false, true, "gofile(\"store/store_missions.lua\")");

addBaseSprite(vel_baseArrow,-94, -11, PI * 0.73848);
addBaseSprite(vel_baseArrow, 94, 8, PI * 1.276);
addBaseSprite(vel_baseCars, -2.65, -30.37, PI * 0.00);
addBaseSprite(vel_baseGuns, 24.1, 46.5, PI * 0.00);
addBaseSprite(vel_baseTrade, -44.8, 43, PI * 0.00);
addBaseSprite(vel_baseJobs,-50, -13.5, 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, 71, 16, -51, -29, PI * 0.015);
addObstacleBox(map_Building, 51.3, 24.4, -46.98, 65.28, PI * 0.027);
addObstacleBox(map_Building, 44.3, 23.0, 12.56, 67.57, PI * 0.004775);


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

--dealership
car1 = addBeing(dealerCar1, 13.5, -39, PI * 0.73, 1);
car2 = addBeing(dealerCar2, 29.9, -44.5, PI * 0.76, 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, -72.0, 19.0, PI * 1.25, 1);
setPlayerBeing(player);
setMobHealth(player, getPlayerHealth());
setWeapon(player, 1, playerWeapon1);
setWeapon(player, 2, playerWeapon2);

saveSlot();
