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

--LEVEL SETUP

--set Background
--texture, width, height, position X, position Y
--setBackGround(map_BackGround, 200, 200, 0, 0);
setBackGround("map_onehorse.dds", 200, 200, 0, 0);
setTerrainMap("terraininfo_onehorse.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, 14, 14, false, false, "saveTown(); gofile(\"control.lua\")");
addLinkPoint(100, 15.7, 14, false, false, "saveTown(); gofile(\"control.lua\")");
addLinkPoint(-5.11, -32.8, 7, false, true, "gofile(\"store/store_dealer.lua\")");
addLinkPoint(-50.1, 37.1, 7, false, true, "gofile(\"store/store_gunsOnehorse.lua\")");
addLinkPoint(7.4, 36.4, 7, false, true, "gofile(\"store/store_trader.lua\")");
addLinkPoint(32, -31.4, 7, false, true, "gofile(\"store/store_missions.lua\")");

addBaseSprite(vel_baseArrow, -94, 14, PI * 0.5);
addBaseSprite(vel_baseArrow, 94, 16, PI * 1.5);
addBaseSprite(vel_baseCars, -5.11, -32.8, PI * 0.00);
addBaseSprite(vel_baseGuns, -50.1, 37.1, PI * 0.00);
addBaseSprite(vel_baseTrade, 7.4, 36.4, PI * 0.00);
addBaseSprite(vel_baseJobs, 32, -31.4, 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, 23.6, 23.2, -52.25, 58.95, PI * 1.9984);
addObstacleBox(map_Building, 17.1, 18.6, -33.6, 56.8, PI * 1.9944);
addObstacleBox(map_Building, 64.89, 31.9, 4.68, 62.95, PI * 0.011141);
addObstacleBox(map_Building, 24.7, 26.5, 68.37, 63.67, PI * 0.000796);
addObstacleBox(map_Building, 23.9, 35.6, 59.22, -26.67, PI * 0.01901);
addObstacleBox(map_Building, 12.9, 16.5, 45.385, -27.65, PI * 0.02944);



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

--dealership
car1 = addBeing(dealerCar1, -30.5, -39, PI * 0.73, 1);
car2 = addBeing(dealerCar2, -15.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();
