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

Build module - single item build, existing items movement #542

Merged
merged 20 commits into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions Missionframework/modules/02_core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ So this is the core gameplay where all other modules are inject their functional

*Get all mobile respawn vehicles.*

* KPLIB_fnc_core_getNearestSector
* KPLIB_fnc_core_getNearestMarker

*Get the nearest capturable sector.*
*Get the marker from array of markers.*

* KPLIB_fnc_core_handleSector

Expand Down
44 changes: 11 additions & 33 deletions Missionframework/modules/02_core/fnc/fn_core_buildFob.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,28 @@
File: fn_core_buildFob.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-05-11
Last Update: 2018-11-09
Last Update: 2018-11-29
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html

Description:
Builds FOB on given position.
Creates FOB on given position.

Parameter(s):
_position - Object or position where FOB has to be built [OBJECT/ARRAY, defaults to []]
_player - Player that initiated building. Mandatory for interactive build [OBJECT, defaults to objNull]
_interactive - Should FOB be built interactively for player [BOOL, defaults to false]
_buildPos - Object or position where FOB has to be built [ARRAY, defaults to []]

Returns:
Spawned vehicle [OBJECT]
Fob marker [STRING]
*/

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

// 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;
["KPLIB_fob_built", [_marker]] call CBA_fnc_localEvent;
} else {
private _marker = [_buildPos] call KPLIB_fnc_core_createFobMarker;
KPLIB_sectors_fobs pushBack _marker;
["KPLIB_fob_built", [_marker]] call CBA_fnc_localEvent;
};
private _marker = [_buildPos] call KPLIB_fnc_core_createFobMarker;
KPLIB_sectors_fobs pushBack _marker;
["KPLIB_fob_built", [_marker]] call CBA_fnc_globalEvent;

publicVariable "KPLIB_sectors_fobs";
call KPLIB_fnc_core_updateFobMarkers;
[] call KPLIB_fnc_core_updateFobMarkers;

_marker
6 changes: 3 additions & 3 deletions Missionframework/modules/02_core/fnc/fn_core_canBuildFob.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
File: fn_core_canBuildFob.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-05-11
Last Update: 2018-11-09
Last Update: 2018-11-29
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html

Description:
Expand All @@ -27,6 +27,6 @@ params [
private _minSectorDist = KPLIB_param_fobRange + KPLIB_param_sectorCapRange;

(alive _box
&& _box distance2D KPLIB_eden_startbase > 300
&& ([_minSectorDist, getPos _box] call KPLIB_fnc_core_getNearestSector == ""))
&& _box distance2D KPLIB_eden_startbase > 1000
&& ([_minSectorDist, getPos _box, KPLIB_sectors_all + KPLIB_sectors_fobs] call KPLIB_fnc_core_getNearestMarker isEqualTo ""))

36 changes: 36 additions & 0 deletions Missionframework/modules/02_core/fnc/fn_core_getNearestMarker.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
KPLIB_fnc_core_getNearestMarker

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

Description:
Get the nearest marker from given array within range of position.

Parameter(s):
_range - Range to search for sectors [NUMBER, defaults to 0]
_centerPos - Center position from where to start searching for markers [POSITION, defaults to getPos player]
_markers - Array of markers to check [ARRAY, defaults to KPLIB_sectors_all]

Returns:
Nearest marker [STRING]
*/

params [
["_range", 0, [0]],
["_centerPos", getPos player, [[]], 3],
["_markers", KPLIB_sectors_all, [[]]]
];


private _markersWithinRange = _markers select {((markerPos _x) distance _centerPos) < _range};
private _markersAscByRange = [_markersWithinRange, [_centerPos], {(markerPos _x) distance _input0}, "ASCEND"] call BIS_fnc_sortBy;
// Return nearest marker
if !(_markersAscByRange isEqualTo []) then {
_markersAscByRange select 0
} else {
""
};
31 changes: 0 additions & 31 deletions Missionframework/modules/02_core/fnc/fn_core_getNearestSector.sqf

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
File: fn_core_handleVehicleSpawn.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-09-10
Last Update: 2018-11-12
Last Update: 2018-11-29
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html

Description:
Expand All @@ -27,7 +27,7 @@ switch(typeOf _vehicle) do {
// Add FOB build action globaly and for JIP
[
_vehicle,
[localize "STR_KPLIB_ACTION_DEPLOY", {[param [0], param [1], param[3]] call KPLIB_fnc_core_buildFob}, true, -800, false, true, "", "[_target, _this] call KPLIB_fnc_core_canBuildFob", 10]
[localize "STR_KPLIB_ACTION_DEPLOY", {["KPLIB_fob_build_requested", _this select 0] call CBA_fnc_localEvent}, true, -800, false, true, "", "[_target, _this] call KPLIB_fnc_core_canBuildFob", 10]
] remoteExecCall ["addAction", 0, true];
Wyqer marked this conversation as resolved.
Show resolved Hide resolved
};

Expand Down
6 changes: 5 additions & 1 deletion Missionframework/modules/02_core/fnc/fn_core_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
File: fn_core_preInit.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-10-18
Last Update: 2018-11-27
Last Update: 2018-11-29
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html

Description:
Expand All @@ -22,6 +22,10 @@ if (isServer) then {diag_log format ["[KP LIBERATION] [%1] [PRE] [CORE] Module i
// Process CBA Settings
[] call KPLIB_fnc_core_settings;

if (isServer) then {
["KPLIB_vehicle_spawned", KPLIB_fnc_core_handleVehicleSpawn] call CBA_fnc_addEventHandler;
};

/*
----- Module Globals -----
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
File: fn_common_setupPlayerActions.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-05-28
Last Update: 2018-11-12
Last Update: 2018-11-29
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html

Description:
Expand All @@ -17,12 +17,6 @@
Function reached the end [BOOL]
*/

// Actions avalible GLOBALLY on objects
if (isServer) then {
// Add actions to supported vehicles
["KPLIB_vehicle_spawned", KPLIB_fnc_core_handleVehicleSpawn] call CBA_fnc_addEventHandler;
};

// Actions avalible LOCALLY to player
if(hasInterface) then {
// FOB redeploy action
veteran29 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
4 changes: 2 additions & 2 deletions Missionframework/modules/02_core/fnc/fn_core_spawnCam.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
File: fn_core_spawnCam.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2017-11-26
Last Update: 2018-11-12
Last Update: 2018-11-29
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html

Description:
Expand All @@ -22,7 +22,7 @@ params [
];

// Get the nearest sector from the current position for the spawn text display
private _nearestSector = [2000] call KPLIB_fnc_core_getNearestSector;
private _nearestSector = [2000] call KPLIB_fnc_core_getNearestMarker;
if (_nearestSector != "") then {_nearestSector = format ["%1 %2", localize "STR_KPLIB_NEAR", markertext _nearestSector];};

// Get the current time for the spawn text display
Expand Down
6 changes: 3 additions & 3 deletions Missionframework/modules/02_core/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
File: functions.hpp
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2017-10-28
Last Update: 2018-11-27
Last Update: 2018-11-29
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html

Description:
Expand Down Expand Up @@ -35,8 +35,8 @@ class core {
// Get all mobile respawn vehicles
class core_getMobSpawns {};

// Get the nearest capturable sector
class core_getNearestSector {};
// Get the nearest marker from array of markers
class core_getNearestMarker {};

// Handle an activated sector
class core_handleSector {};
Expand Down
48 changes: 48 additions & 0 deletions Missionframework/modules/04_build/fnc/fn_build_changeQueueMode.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "script_components.hpp"
#include "..\ui\defines.hpp"
/*
KPLIB_fnc_build_changeQueueMode

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

Description:
Changes build system queue mode.

Parameter(s):
_control - Clicked control [CONTROL, defaults to controlNull]

Returns:
Queue mode was changed [BOOL]
*/
params [
["_control", controlNull, [controlNull]]
];

private _display = ctrlParent _control;
private _confirmBtnControl = _display displayCtrl KPLIB_IDC_BUILD_CONFIRM;

// TODO preserve and restore current build queue
switch (_control getVariable ["KPLIB_mode", 0]) do {
case 0: {
_control ctrlSetText "Move mode";
_control setVariable ["KPLIB_mode", 1];
_confirmBtnControl ctrlEnable false;

private _currentItems = KPLIB_build_saveNamespace getVariable [player getVariable "KPLIB_fob", []];
LSVAR("buildQueue", _currentItems);
};

case 1: {
_control ctrlSetText "Build mode";
_control setVariable ["KPLIB_mode", 0];
_confirmBtnControl ctrlEnable true;

LSVAR("buildQueue", []);
};
};

true
37 changes: 37 additions & 0 deletions Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "script_components.hpp"
/*
KPLIB_fnc_build_confirmAll

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

Description:
Confirms and builds every item in build queue.

Parameter(s):
NONE

Returns:
Items were built [BOOL]
*/

private _validItems = LGVAR(buildQueue) select {_x getVariable ["KPLIB_validPos", true]};
LSVAR("buildQueue", LGVAR(buildQueue) - _validItems);

// TODO implement build queue handling (resource check etc.)
systemChat "buildConfirm: Resource check not implemented yet!";
{
private _dirAndUp = [vectorDir _x, vectorUp _x];
private _pos = getPosATL _x;
private _class = typeOf _x;

deleteVehicle _x;

[[_class, _pos, 0, true], _dirAndUp, player] remoteExecCall ["KPLIB_fnc_build_confirmSingle", 2];

} forEach _validItems;

true
52 changes: 52 additions & 0 deletions Missionframework/modules/04_build/fnc/fn_build_confirmSingle.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
KPLIB_fnc_build_confirmSingle

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

Description:
Confirms single item from build queue.

Parameter(s):
_createParams - Parameters for common_createVehicle [ARRAY, defaults to nil]
_vectorDirAndUp - Vector dir and up for created object [ARRAY, defaults to nil]
_player - Player that initiated the building of object [OBJECT, defaults to objNull]

Returns:
Function reached the end [BOOL]
*/
params [
["_createParams", nil, [[]]],
["_vectorDirAndUp", nil, [[]], 2],
["_player", objNull, [objNull]]
];
_createParams params ["_className", "_pos", "_dir", "_justBuild"];

private ["_obj"];

// TODO save only builings via Build module, units and vehicles should be moved to persistence module
switch true do {
case (_className isKindOf "Man"): {
_obj = [createGroup KPLIB_preset_sidePlayers, _className] call KPLIB_fnc_common_createUnit;
_obj setPosATL _pos;
_obj setVectorDirAndUp _vectorDirAndUp;

// Set watching direction
if (_obj isEqualTo formLeader _obj) then {
_obj setFormDir getDir _obj;
};
};

default {
_obj = _createParams call KPLIB_fnc_common_createVehicle;
_obj setVectorDirAndUp _vectorDirAndUp;
};
};

private _fob = _player getVariable ["KPLIB_fob", ""];

["KPLIB_build_item_built", [_obj, _fob]] call CBA_fnc_globalEvent;
["KPLIB_build_item_built_local", [_obj, _fob], _player] call CBA_fnc_targetEvent;
Loading