-
-
Notifications
You must be signed in to change notification settings - Fork 307
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
Changes from 5 commits
4ae0865
0478dc8
cd11e93
b69c33c
b2f03fa
5764cb8
9ea9ae9
fc31fee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
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"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
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"]; | ||
|
||
private _canBuild = false; | ||
// Built FOB range should not overlap over sector range | ||
private _minSectorDist = KPLIB_range_fob + KPLIB_range_capture; | ||
|
||
_canBuild = ( | ||
alive _box | ||
&&_box distance2D KPLIB_eden_startbase > 300 | ||
&& ([_minSectorDist, getPos _box] call KPLIB_fnc_core_getNearestSector == "") | ||
); | ||
|
||
_canBuild |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
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 _index = count KPLIB_sectors_fobs; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this could be an issue later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe for marker name we could do Do you think is it even worth to store markers here? I wanted to do it for unification as capturable sectors are stored as markers, FOB is kind of sector too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you're right concerning just store the positions for the FOBs. This also eliminates the need to have the getMarkerPosition conversion. |
||
|
||
private _marker = createMarker ["KPLIB_fob_" + str _index, _position]; | ||
_marker setMarkerShape "ICON"; | ||
_marker setMarkerType "b_hq"; | ||
_marker setMarkerText format ["FOB %1", KPLIB_preset_alphabet select (_index)]; | ||
_marker setMarkerSize [1.5, 1.5]; | ||
_marker setMarkerColor "ColorYellow"; | ||
|
||
_marker |
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 |
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}]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess this
false
isn't needed.Just directly the bool condition, which will return true or false.
Maybe even no
_canbuild
variable at all and just the expression as return value.