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

add buildingPos dummy object #1138

Merged
merged 8 commits into from
May 10, 2019
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
Binary file added addons/ai/BuildingPos.p3d
Binary file not shown.
7 changes: 7 additions & 0 deletions addons/ai/CfgAddons.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CfgAddons {
class PreloadAddons {
class CBA {
list[] = {QUOTE(ADDON)};
};
};
};
1 change: 1 addition & 0 deletions addons/ai/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class CfgFunctions {
PATHTO_FNC(taskDefend);
PATHTO_FNC(taskPatrol);
PATHTO_FNC(taskSearchArea);
PATHTO_FNC(buildingPositions);
};
};
};
19 changes: 19 additions & 0 deletions addons/ai/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
class CfgVehicles {
class B_TargetSoldier;
class CBA_B_InvisibleTarget: B_TargetSoldier {
author = "$STR_CBA_Author";
scope = 2;
scopeCurator = 2;
scopeArsenal = 0;
model = QPATHTOF(InvisibleTarget.p3d);
icon = "CBA_iconInvisibleTarget";
Expand All @@ -11,7 +13,9 @@ class CfgVehicles {

class O_TargetSoldier;
class CBA_O_InvisibleTarget: O_TargetSoldier {
author = "$STR_CBA_Author";
scope = 2;
scopeCurator = 2;
scopeArsenal = 0;
model = QPATHTOF(InvisibleTarget.p3d);
icon = "CBA_iconInvisibleTarget";
Expand All @@ -21,11 +25,26 @@ class CfgVehicles {

class I_TargetSoldier;
class CBA_I_InvisibleTarget: I_TargetSoldier {
author = "$STR_CBA_Author";
scope = 2;
scopeCurator = 2;
scopeArsenal = 0;
model = QPATHTOF(InvisibleTarget.p3d);
icon = "CBA_iconInvisibleTarget";

class HitPoints {};
};

class Strategic;
class CBA_BuildingPos: Strategic {
author = "$STR_CBA_Author";
scope = 2;
scopeCurator = 2;
scopeArsenal = 0;
displayName = CSTRING(BuildingPos);
model = QPATHTOF(BuildingPos.p3d);
icon = "iconObject_circle";
editorCategory = "EdCat_VRObjects";
editorSubcategory = "EdSubcat_Helpers";
};
};
3 changes: 2 additions & 1 deletion addons/ai/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class CfgPatches {
author = "$STR_CBA_Author";
name = CSTRING(component);
url = "$STR_CBA_URL";
units[] = {"CBA_B_InvisibleTarget","CBA_O_InvisibleTarget","CBA_I_InvisibleTarget"};
units[] = {"CBA_B_InvisibleTarget","CBA_O_InvisibleTarget","CBA_I_InvisibleTarget","CBA_BuildingPos"};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"cba_common"};
version = VERSION;
Expand All @@ -17,3 +17,4 @@ class CfgPatches {
#include "CfgVehicles.hpp"
#include "CfgVehicleIcons.hpp"
#include "CfgWaypoints.hpp"
#include "CfgAddons.hpp"
63 changes: 63 additions & 0 deletions addons/ai/fnc_buildingPositions.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include "script_component.hpp"
/* ----------------------------------------------------------------------------
Function: CBA_fnc_buildingPositions

Description:
Reports positions of the building including nearby custom building positions.

Parameters:
0: _building - The building. <OBJECT>
1: _max - Maximum number of positions. (optional, default: all) <NUMBER>

Example:
(begin example)
[_building, _maxNumberOfPositions] call CBA_fnc_buildingPositions
(end)

Returns:
Available building positions including custom positions <ARRAY <PosAGL>>

Author:
commy2
---------------------------------------------------------------------------- */

params [["_building", objNull, [objNull]], ["_max", -1, [0]]];

private _availablePositions = _building buildingPos -1;

// add nearby custom building positions
(0 boundingBoxReal _building) params ["_pos1", "_pos2", "_diameter"];
_pos1 params ["_x1", "_y1", "_z1"];
_pos2 params ["_x2", "_y2", "_z2"];

private _polygonTop = [
[_x1, _y1, 0],
[_x2, _y1, 0],
[_x2, _y2, 0],
[_x1, _y2, 0]
];

private _polygonSide = [
[_x1, _z1, 0],
[_x2, _z1, 0],
[_x2, _z2, 0],
[_x1, _z2, 0]
];

private _customPositions = nearestObjects [_building, ["CBA_buildingPos"], _diameter, true] apply {
_x buildingPos 0
} select {
private _customPositionTop = _building worldToModel _x;
private _customPositionSide = +_customPositionTop;
_customPositionSide pushBack (_customPositionSide deleteAt 1); // swap y and z

_customPositionTop inPolygon _polygonTop && _customPositionSide inPolygon _polygonSide
};

_availablePositions append _customPositions;

if (_max >= 0) then {
_availablePositions resize (_max min count _availablePositions);
};

_availablePositions
4 changes: 4 additions & 0 deletions addons/ai/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@
<Turkish>Community Base Addons - Yapay Zeka</Turkish>
<Italian>Community Base Addons - Intelligenza Artificiale</Italian>
</Key>
<Key ID="STR_CBA_AI_BuildingPos">
<English>AI Building Position</English>
<German>KI Gebäudeposition</German>
</Key>
</Package>
</Project>