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;