diff --git a/SQF/Bus%20System.Altis/RR_functions/fn_busFare.sqf b/SQF/Bus%20System.Altis/RR_functions/fn_busFare.sqf new file mode 100644 index 0000000..4ac9ffe --- /dev/null +++ b/SQF/Bus%20System.Altis/RR_functions/fn_busFare.sqf @@ -0,0 +1,15 @@ +/** + * Copyright© Benjamin Kyd 2019 + * fn_distance3D.sqf + * + * Calculate 3D distance between 2 points in + * 3D space + */ + +params [ + ["_distance", 0, [0]] +]; + +private _fare = _distance * 3; + +_fare; diff --git a/SQF/Bus%20System.Altis/RR_functions/fn_distance3D.sqf b/SQF/Bus%20System.Altis/RR_functions/fn_distance3D.sqf new file mode 100644 index 0000000..3f44c99 --- /dev/null +++ b/SQF/Bus%20System.Altis/RR_functions/fn_distance3D.sqf @@ -0,0 +1,22 @@ +/** + * Copyright© Benjamin Kyd 2019 + * fn_distance3D.sqf + * + * Calculate 3D distance between 2 points in + * 3D space + */ + +params [ + ["_x", [], [[]]], + ["_y", [], [[]]] +]; + +private _result = 0; + +_xD = (_x select 0) - (_y select 0); +_yD = (_x select 1) - (_y select 1); +_zD = (_x select 2) - (_y select 2); + +_result = sqrt [_xD + _yD + _zD]; + +_result; diff --git a/SQF/Bus%20System.Altis/RR_functions/fn_doSignPressed.sqf b/SQF/Bus%20System.Altis/RR_functions/fn_doSignPressed.sqf new file mode 100644 index 0000000..adb41ba --- /dev/null +++ b/SQF/Bus%20System.Altis/RR_functions/fn_doSignPressed.sqf @@ -0,0 +1,40 @@ +/** + * Copyright© Benjamin Kyd 2019 + * fn_doSignPressed.sqf + * + * Bus sign was pressed, prepair to teleport + * player and do other such tasks + */ + +params [ + ["_target", objNull, [objNull]], + ["_caller", objNull, [objNull]], + ["_id", 0, [0]], + ["_args", [], [[]]] +]; + +private _dest = _args select 0; +private _price = _args select 1; + +private _stops = getArray (missionConfigFile >> "cfgBus" >> "stops" >> "names"); +private _locations = getArray (missionConfigFile >> "cfgBus" >> "stops" >> "locations"); + +private _positionInStops = 0; + +if (!(_dest in _stops)) exitWith { }; + +private _i = 0; +{ + if (_x isEqualTo _dest) then { _positionInStops = _i; }; + _i = _i + 1; +} forEach _stops; + +// Take money from bank account + +hint "Your bus will arrive in 10 seconds"; +uiSleep 10; +hint "All aboard!"; + +[(_locations select _positionInStops)] call RR_fnc_doTeleport; + +hint format ["You have arrived at %1! Enjoy your stay", _dest]; diff --git a/SQF/Bus%20System.Altis/RR_functions/fn_doTeleport.sqf b/SQF/Bus%20System.Altis/RR_functions/fn_doTeleport.sqf new file mode 100644 index 0000000..5600065 --- /dev/null +++ b/SQF/Bus%20System.Altis/RR_functions/fn_doTeleport.sqf @@ -0,0 +1,12 @@ +/** + * Copyright© Benjamin Kyd 2019 + * fn_doSignPressed.sqf + * + * Teleports player and starts camera animation + */ + +params [ + ["_target", [], [[]]] +]; + +player setPos (target); diff --git a/SQF/Bus%20System.Altis/RR_functions/fn_setupSigns.sqf b/SQF/Bus%20System.Altis/RR_functions/fn_setupSigns.sqf index 819f9d4..964b18f 100644 --- a/SQF/Bus%20System.Altis/RR_functions/fn_setupSigns.sqf +++ b/SQF/Bus%20System.Altis/RR_functions/fn_setupSigns.sqf @@ -1,5 +1,46 @@ /** * Copyright© Benjamin Kyd 2019 * fn_setupSigns.sqf + * + * Spawns and sets up signs at every location */ +params [ + ["_stops", [], [[]] ], + ["_locations", [], [[]] ] +]; + + +private _signs = []; + +private _i = 0; +{ + private _location = _locations select _i; + // Create sign at location + private _sign = createVehicle ["Land_InfoStand_V1_F", _location]; + + // Add shit to sign + private _j = 0; + { + private _destLocation = _locations select _j; + private _distance = [_location, _destLocation] call RR_fnc_distance3D; + + private _price = [parseNumber [_distance]] call RR_fnc_busFare; + + private _signName = format ["%1 - £%2", _x, _price]; + + _sign addAction [ + _x, RR_fnc_doSignPressed, [_x, _price] + ]; + _j = _j + 1; + } forEach _stops; + + // Add sign to the array of signs + _signs pushBack _sign; + + _i = _i + 1; +} forEach _stops; + + +// return signs +_signs; diff --git a/SQF/Bus%20System.Altis/config_bus.hpp b/SQF/Bus%20System.Altis/config_bus.hpp index 03051e7..e5e2073 100644 --- a/SQF/Bus%20System.Altis/config_bus.hpp +++ b/SQF/Bus%20System.Altis/config_bus.hpp @@ -1,53 +1,52 @@ class cfgBus { - - class stops { + class stops { names[] = { - "Abdera", - "Agios", - "Airport", - "Athira", - "Chalkia", - "Charkia", - "Feres", - "Kavala", - "Kore", - "Lakka", - "Molos", - "Negardes", - "Neochori", - "Oreokastro", - "Panagia", - "Panochori", - "Paros", - "Pyrgos", - "Sofia", - "Telos", - "Therisa", - "Zaros" + "Abdera", + "Agios", + "Airport", + "Athira", + "Chalkia", + "Charkia", + "Feres", + "Kavala", + "Kore", + "Lakka", + "Molos", + "Negardes", + "Neochori", + "Oreokastro", + "Panagia", + "Panochori", + "Paros", + "Pyrgos", + "Sofia", + "Telos", + "Therisa", + "Zaros" }; locations[] = { - {9414,20294,0}, - {9344,15885,0}, - {14502,16889,0}, - {14070,18584,0}, //athira - {19983,11471,0}, - {18087,15195,0}, - {21785,7482,0}, //feres - {3651,13273,0}, - {7096,16414,0}, - {12372,15778,0},//lakka - {27012,23282,0}, - {4908,16140,0}, - {12568,14349,0},//neochori - {4577,21392,0}, - {20602,8841,0}, - {5093,11263,0},//panochori - {20917,16908,0}, - {16658,12463,0}, - {25742,21387,0},//sofia - {16269,17325,0}, - {10714,12312,0}, - {9055,11985,0}//zaros + {9414,20294,0}, + {9344,15885,0}, + {14502,16889,0}, + {14070,18584,0}, //athira + {19983,11471,0}, + {18087,15195,0}, + {21785,7482,0}, //feres + {3651,13273,0}, + {7096,16414,0}, + {12372,15778,0}, //lakka + {27012,23282,0}, + {4908,16140,0}, + {12568,14349,0}, //neochori + {4577,21392,0}, + {20602,8841,0}, + {5093,11263,0}, //panochori + {20917,16908,0}, + {16658,12463,0}, + {25742,21387,0}, //sofia + {16269,17325,0}, + {10714,12312,0}, + {9055,11985,0} //zaros }; - }; + }; }; diff --git a/SQF/Bus%20System.Altis/functions.hpp b/SQF/Bus%20System.Altis/functions.hpp index 09891aa..52f6b8d 100644 --- a/SQF/Bus%20System.Altis/functions.hpp +++ b/SQF/Bus%20System.Altis/functions.hpp @@ -2,7 +2,10 @@ class RR { tag = "RR"; class functions { file = "RR_functions"; - class loadConfig {}; class setupSigns {}; + class doSignPressed {}; + class doTeleport {}; + class distance3D {}; + class busFare {}; }; }; diff --git a/SQF/Bus%20System.Altis/init.sqf b/SQF/Bus%20System.Altis/init.sqf index c8d26b1..add603c 100644 --- a/SQF/Bus%20System.Altis/init.sqf +++ b/SQF/Bus%20System.Altis/init.sqf @@ -3,6 +3,8 @@ * init.sqf */ -[] call RR_fnc_loadConfig; +private _stops = getArray (missionConfigFile >> "cfgBus" >> "stops" >> "names"); +private _locations = getArray (missionConfigFile >> "cfgBus" >> "stops" >> "locations"); +private _signs = [_stops, _locations] call RR_fnc_setupSigns; diff --git a/SQF/Bus%20System.Altis/mission.sqm b/SQF/Bus%20System.Altis/mission.sqm index f45d0fa..df6ed16 100644 Binary files a/SQF/Bus%20System.Altis/mission.sqm and b/SQF/Bus%20System.Altis/mission.sqm differ