BROKEN bus system with basic functionality - 2 commits missed somehow

This commit is contained in:
Benjamin Kyd
2019-05-13 00:20:50 +01:00
parent b9cda04514
commit 6cb5cbef32
9 changed files with 183 additions and 49 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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];

View File

@@ -0,0 +1,12 @@
/**
* Copyright© Benjamin Kyd 2019
* fn_doSignPressed.sqf
*
* Teleports player and starts camera animation
*/
params [
["_target", [], [[]]]
];
player setPos (target);

View File

@@ -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;

View File

@@ -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
};
};
};
};

View File

@@ -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 {};
};
};

View File

@@ -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;

Binary file not shown.