Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of initial FOB Box, FOB placement #411

Merged
merged 8 commits into from
May 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Missionframework/modules/00_init/fnc/fn_init_loadData.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,14 @@ if (_moduleData isEqualTo []) then {
KPLIB_sectors_blufor = _moduleData select 2;
publicVariable "KPLIB_sectors_blufor";


private _fobPositions = _moduleData select 3;
// Convert FOB positions to markers
{
[_x] call KPLIB_fnc_core_buildFob
} forEach _fobPositions;

// Publish FOB positions
KPLIB_sectors_fobs = _moduleData select 3;
publicVariable "KPLIB_sectors_fobs";
};

Expand Down
19 changes: 6 additions & 13 deletions Missionframework/modules/00_init/fnc/fn_init_saveData.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,11 @@

if (KPLIB_param_debugSave > 0) then {diag_log "[KP LIBERATION] [SAVE] Init module saving...";};

private _moduleData = [];

// Current date and time
_moduleData pushBack date;

// Locked Vehicles array
_moduleData pushBack KPLIB_sectors_lockedVeh;

// Blufor sectors
_moduleData pushBack KPLIB_sectors_blufor;

// FOB positions
_moduleData pushBack KPLIB_sectors_fobs;
private _moduleData = [
date, // Current date and time
KPLIB_sectors_lockedVeh, // Locked Vehicles array
KPLIB_sectors_blufor, // Blufor sectors
KPLIB_sectors_fobs apply {getMarkerPos _x} // FOB positions
];

_moduleData
3 changes: 0 additions & 3 deletions Missionframework/modules/00_init/initModule.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,3 @@ execVM "modules\00_init\scripts\server\saveTimer\timer.sqf";

// Create locked vehicle markers
call KPLIB_fnc_init_createLockedVehMarkers;

// Run FOB marker manager
execVM "modules\00_init\scripts\server\markersUpdater\fobMarkers.sqf";

This file was deleted.

47 changes: 47 additions & 0 deletions Missionframework/modules/01_core/fnc/fn_core_buildFob.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
KPLIB_fnc_core_buildFob

File: fn_core_buildFob.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-05-11
Last Update: 2018-05-11
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html

Description:
Builds FOB on given position.

Parameter(s):
0: OBJECT|ARRAY - Object or position where FOB has to be built.
1: OBJECT - OPTIONAL - Player that initiated building. Mandatory for interactive build. (Default: objNull)
2: BOOL - OPTIONAL - Should FOB be built interactively for player. (Default: false)

Returns:
OBJECT - Spawned vehicle
*/

params ["_position", ["_player", objNull], ["_interactive", false]];

// Get position of build area
private _buildPos = _position;
// If our position is an object we will save it for later deletion
private _box = objNull;

// If position is object, get position of object
if(typeName _buildPos == typeName objNull) then {
_box = _buildPos;
_buildPos = getPosATL _box;
};

// Build FOB
if (_interactive) then {
// TODO we should allow for manual placement of FOB building in interative mode here later
deleteVehicle _box;
private _marker = [_buildPos] call KPLIB_fnc_core_createFobMarker;
KPLIB_sectors_fobs pushBack _marker;
} else {
private _marker = [_buildPos] call KPLIB_fnc_core_createFobMarker;
KPLIB_sectors_fobs pushBack _marker;
};

publicVariable "KPLIB_sectors_fobs";
call KPLIB_fnc_core_updateFobMarkers;
29 changes: 29 additions & 0 deletions Missionframework/modules/01_core/fnc/fn_core_canBuildFob.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
KPLIB_fnc_core_canBuildFob

File: fn_core_canBuildFob.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-05-11
Last Update: 2018-05-12
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html

Description:
Checks if player can build FOB from box.

Parameter(s):
0: OBJECT - FOB box.
1: OBJECT - Player trying to build FOB.

Returns:
BOOLEAN -
*/

params ["_box", "_player"];

// Built FOB range should not overlap over sector range
private _minSectorDist = KPLIB_range_fob + KPLIB_range_capture;

(alive _box
&&_box distance2D KPLIB_eden_startbase > 300
&& ([_minSectorDist, getPos _box] call KPLIB_fnc_core_getNearestSector == ""))

29 changes: 29 additions & 0 deletions Missionframework/modules/01_core/fnc/fn_core_createFobMarker.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
KPLIB_fnc_core_createFobMarker

File: fn_core_createFobMarker.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-05-12
Last Update: 2018-05-12
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html

Description:
Creates FOB marker

Parameter(s):
0: ARRAY - Position where FOB has to be built.

Returns:
STRING - Marker name
*/
params ["_position"];

private _markerName = format ["KPLIB_fob_%1", mapGridPosition _position];

private _marker = createMarker [_markerName, _position];
_marker setMarkerShape "ICON";
_marker setMarkerType "b_hq";
_marker setMarkerSize [1.5, 1.5];
_marker setMarkerColor "ColorYellow";

_marker
25 changes: 21 additions & 4 deletions Missionframework/modules/01_core/fnc/fn_core_redeploy.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ lbAdd [_loadouts_idc, "--"];
{lbAdd [_loadouts_idc, _x];} forEach _loadouts_data;
lbSetCurSel [_loadouts_idc, 0];

// Array for all possible spawnpoints
/*
Array for all posible spawnpoints

Structure:
0: STRING - Label of spawn position
1: ARRAY - position of respawn area
2: OBJECT - OPTIONAL - Mobile respawn object
*/
private _spawnchoices = [];

// Selection storages
Expand All @@ -79,7 +86,13 @@ while {dialog && (alive player) && (KPLIB_dialog_deploy == 0)} do {

// Add the FOBs to the spawn list
for "_i" from 0 to (count KPLIB_sectors_fobs - 1) do {
_spawnchoices pushBack [format ["FOB %1 - %2", (KPLIB_preset_alphabet select _i), mapGridPosition (KPLIB_sectors_fobs select _i)], (KPLIB_sectors_fobs select _i)];
// Convert marker array to positions array
private _position = (KPLIB_sectors_fobs apply {getMarkerPos _x}) select _i;

_spawnchoices pushBack [
format ["FOB %1 - %2", (KPLIB_preset_alphabet select _i), mapGridPosition (_position)],
_position
];
};

// Add mobile respawns to the spawn list if parameter isn't disabled
Expand All @@ -89,7 +102,11 @@ while {dialog && (alive player) && (KPLIB_dialog_deploy == 0)} do {

// Adding the mobile respawns with object refence as third element, to access it on spawning
for "_i" from 0 to (count _mobileSpawns - 1) do {
_spawnchoices pushBack [format ["%1 - %2", localize "STR_RESPAWN_TRUCK", mapGridPosition (getPosATL (_mobileSpawns select _i))], getPosATL (_mobileSpawns select _i), (_mobileSpawns select _i)];
_spawnchoices pushBack [
format ["%1 - %2", localize "STR_RESPAWN_TRUCK", mapGridPosition (getPosATL (_mobileSpawns select _i))],
getPosATL (_mobileSpawns select _i),
(_mobileSpawns select _i)
];
};
};
};
Expand All @@ -101,7 +118,7 @@ while {dialog && (alive player) && (KPLIB_dialog_deploy == 0)} do {
} forEach _spawnchoices;

if (lbCurSel _spawnlist_idc == -1) then {
lbSetCurSel [_spawnlist_idc, 0];
lbSetCurSel [_spawnlist_idc, 0];
};

// Adjust respawn camera if selection has changed
Expand Down
32 changes: 32 additions & 0 deletions Missionframework/modules/01_core/fnc/fn_core_spawnFobVehicle.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
KPLIB_fnc_core_spawnFobVehicle

File: fn_core_spawnFobVehicle.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-05-11
Last Update: 2018-05-12
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html

Description:
Spawns vehicle and attaches FOB deploy action to it. It uses KPLIB_fnc_core_spawnVehicle internally.

Parameter(s):
0: STRING - Classname of the vehicle which should be spawned.
1: POSITION - Position ATL where the vehicle should be spawned.
2: NUMBER - OPTIONAL - Heading for the vehicle from 0 to 360. (Default: random direction)

Returns:
OBJECT - Spawned vehicle
*/

params [["_classname", KPLIB_preset_fobBox], ["_spawnPos", getPos player], ["_spawnDir", random 360]];

private _vehicle = [_classname, _spawnPos, _spawnDir, true] call KPLIB_fnc_core_spawnVehicle;

// Add action for every player and queue for JIP
[
_vehicle,
[localize "STR_FOB_DEPLOY", {[param [0], param [1], param[3]] call KPLIB_fnc_core_buildFob}, true, -1000, false, false, "", "[_target, _this] call KPLIB_fnc_core_canBuildFob", 10]
] remoteExecCall ["addAction", 0, true];

_vehicle
32 changes: 19 additions & 13 deletions Missionframework/modules/01_core/fnc/fn_core_spawnPotato.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
File: fn_core_spawnPotato.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2017-05-01
Last Update: 2018-05-04
Last Update: 2018-05-09
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html

Description:
Expand All @@ -14,23 +14,29 @@
NONE

Returns:
BOOL
NOTHING
*/

// Check if there wasn't a Potato 01 already spawned or if the spawned one is destroyed.
// NOTE: As the loading will happen before this function is called, it won't interfere with a loaded Potato 01.
if (isNull KPLIB_core_potato01 || !(alive KPLIB_core_potato01)) then {
// Position for the spawn.
private _spawnPos = getPosATL KPLIB_eden_potatospawn;
if(!isServer || alive KPLIB_core_potato01) exitWith {};

// If Potato 01 wreck is too close to respawn we should delete it.
if((KPLIB_core_potato01 distance2D KPLIB_eden_potatospawn) < 10 && !alive KPLIB_core_potato01) then {
deleteVehicle KPLIB_core_potato01;
// deleteVehicle deletes object in next frame.
// Without sleep player was sometimes unable to interact with object.
uiSleep 1;
};

// Create Potato 01 at the spawn position with a slight height offset.
KPLIB_core_potato01 = [KPLIB_preset_potato, [_spawnPos select 0, _spawnPos select 1, (_spawnPos select 2) + 0.1], getDir KPLIB_eden_potatospawn, true] call KPLIB_fnc_core_spawnVehicle;
// Position for the spawn.
private _spawnPos = getPosATL KPLIB_eden_potatospawn;

// Declare as ace medical vehicle (can also be set if ACE is not used)
KPLIB_core_potato01 setVariable ["ace_medical_medicClass", 1, true];
// Create Potato 01 at the spawn position with a slight height offset.
KPLIB_core_potato01 = [KPLIB_preset_potato, [_spawnPos select 0, _spawnPos select 1, (_spawnPos select 2) + 0.1], getDir KPLIB_eden_potatospawn, true] call KPLIB_fnc_core_spawnVehicle;

// Add event handler to call this script again if we have a "Potato down". Will run only on the server.
KPLIB_core_potato01 addMPEventHandler ["MPKilled", {if (isServer) then {[] call KPLIB_fnc_core_spawnPotato;};}];
};
// Declare as ace medical vehicle (can also be set if ACE is not used)
KPLIB_core_potato01 setVariable ["ace_medical_medicClass", 1, true];

true
// Add event handler to call this script again if we have a "Potato down".
KPLIB_core_potato01 addMPEventHandler ["MPKilled", {[] spawn KPLIB_fnc_core_spawnPotato}];
38 changes: 38 additions & 0 deletions Missionframework/modules/01_core/fnc/fn_core_spawnStartFobBox.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
KPLIB_fnc_core_spawnStartFobBox

File: fn_core_spawnStartFobBox.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-05-09
Last Update: 2018-05-09
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html

Description:
Spawning of the initial FOB box.

Parameter(s):
0: OBJECT - OPTIONAL - Wreck of previous FOB box. Will be deleted.

Returns:
BOOL
*/
params [["_boxWreck", objNull]];

if (!isServer || count KPLIB_sectors_fobs > 0) exitWith {};

// If FOB box wreck is too close to respawn we should delete it.
if((_boxWreck distance2D KPLIB_eden_boxspawn) < 10 && !alive _boxWreck) then {
deleteVehicle _boxWreck;
// deleteVehicle deletes object in next frame.
// Without sleep player was sometimes unable to interact with object.
uiSleep 1;
};

// Position for the spawn.
private _spawnPos = getPosATL KPLIB_eden_boxspawn;

// Create FOB box at the spawn position with a slight height offset.
private _fobBox = [KPLIB_preset_fobBox, [_spawnPos select 0, _spawnPos select 1, (_spawnPos select 2) + 0.1], getDir KPLIB_eden_potatospawn] call KPLIB_fnc_core_spawnFobVehicle;

// Add event handler to call this script again if box was destroyed.
_fobBox addMPEventHandler ["MPKilled", {[_this select 0] spawn KPLIB_fnc_core_spawnStartFobBox}];
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
0: STRING - Classname of the vehicle which should be spawned.
1: POSITION - Position ATL where the vehicle should be spawned.
2: NUMBER - OPTIONAL - Heading for the vehicle from 0 to 360. (Default: random direction)
2: BOOL - OPTIONAL - True for return the spawned vehicle as object, false for return only true on success. (Default: false)
3: BOOL - OPTIONAL - True for return the spawned vehicle as object, false for return only true on success. (Default: false)

Returns:
OBJECT / BOOL - Depends on 3rd parameter. True -> returns object, False -> return true on success.
Expand Down
Loading