From 1a4a7d688f1737f45fe1a2c597a826d4d1dcc628 Mon Sep 17 00:00:00 2001 From: Madin Date: Sat, 11 May 2024 00:12:22 +0200 Subject: [PATCH] added simple spawn (WIP) --- addons/simpleSpawn/$PBOPREFIX$ | 1 + addons/simpleSpawn/CfgEden.hpp | 11 ++ addons/simpleSpawn/CfgModuleCategories.hpp | 12 ++ addons/simpleSpawn/DisplayEden.hpp | 13 ++ addons/simpleSpawn/README.md | 8 + addons/simpleSpawn/config.cpp | 19 +++ addons/simpleSpawn/functions/fn_despawn.sqf | 77 ++++++++++ .../simpleSpawn/functions/fn_firstState.sqf | 52 +++++++ addons/simpleSpawn/functions/fn_getGroups.sqf | 125 +++++++++++++++ .../functions/fn_init.sqf} | 49 +++--- .../functions/fn_initCall.sqf} | 37 +++-- addons/simpleSpawn/functions/fn_interval.sqf | 144 ++++++++++++++++++ addons/simpleSpawn/functions/fn_waitUntil.sqf | 71 +++++++++ addons/simpleSpawn/script_component.hpp | 14 ++ addons/simpleSpawn/script_debug.hpp | 25 +++ addons/simpleSpawn/script_macros.hpp | 27 ++++ addons/simpleSpawn/script_mod.hpp | 16 ++ addons/simpleSpawn/script_version.hpp | 3 + addons/simpleSpawn/stringtable.xml | 15 ++ 19 files changed, 674 insertions(+), 45 deletions(-) create mode 100644 addons/simpleSpawn/$PBOPREFIX$ create mode 100644 addons/simpleSpawn/CfgEden.hpp create mode 100644 addons/simpleSpawn/CfgModuleCategories.hpp create mode 100644 addons/simpleSpawn/DisplayEden.hpp create mode 100644 addons/simpleSpawn/README.md create mode 100644 addons/simpleSpawn/config.cpp create mode 100644 addons/simpleSpawn/functions/fn_despawn.sqf create mode 100644 addons/simpleSpawn/functions/fn_firstState.sqf create mode 100644 addons/simpleSpawn/functions/fn_getGroups.sqf rename addons/{hiddenUnitSpawner/functions/fnc_init.sqf => simpleSpawn/functions/fn_init.sqf} (52%) rename addons/{hiddenUnitSpawner/functions/fnc_initCall.sqf => simpleSpawn/functions/fn_initCall.sqf} (81%) create mode 100644 addons/simpleSpawn/functions/fn_interval.sqf create mode 100644 addons/simpleSpawn/functions/fn_waitUntil.sqf create mode 100644 addons/simpleSpawn/script_component.hpp create mode 100644 addons/simpleSpawn/script_debug.hpp create mode 100644 addons/simpleSpawn/script_macros.hpp create mode 100644 addons/simpleSpawn/script_mod.hpp create mode 100644 addons/simpleSpawn/script_version.hpp create mode 100644 addons/simpleSpawn/stringtable.xml diff --git a/addons/simpleSpawn/$PBOPREFIX$ b/addons/simpleSpawn/$PBOPREFIX$ new file mode 100644 index 0000000..e564cd4 --- /dev/null +++ b/addons/simpleSpawn/$PBOPREFIX$ @@ -0,0 +1 @@ +z\afmf\addons\simplespawn \ No newline at end of file diff --git a/addons/simpleSpawn/CfgEden.hpp b/addons/simpleSpawn/CfgEden.hpp new file mode 100644 index 0000000..a8a162e --- /dev/null +++ b/addons/simpleSpawn/CfgEden.hpp @@ -0,0 +1,11 @@ +class Cfg3DEN { + class Object { + class AttributeCategories { + class PREFIX { + displayName = CSTRING(Attributes); + collapsed = 1; + class Attributes {}; + }; + }; + }; +}; diff --git a/addons/simpleSpawn/CfgModuleCategories.hpp b/addons/simpleSpawn/CfgModuleCategories.hpp new file mode 100644 index 0000000..5fca03b --- /dev/null +++ b/addons/simpleSpawn/CfgModuleCategories.hpp @@ -0,0 +1,12 @@ +class CfgFactionClasses { + class NO_CATEGORY; + class PREFIX: NO_CATEGORY { + displayName = CSTRING(Category); + }; +}; + +class CfgVehicleClasses { + class PREFIX##_Vehicles { + displayName = CSTRING(Category); + }; +}; diff --git a/addons/simpleSpawn/DisplayEden.hpp b/addons/simpleSpawn/DisplayEden.hpp new file mode 100644 index 0000000..ba8fa63 --- /dev/null +++ b/addons/simpleSpawn/DisplayEden.hpp @@ -0,0 +1,13 @@ +class CtrlMenuStrip; +class Display3DEN { + class Controls { + class MenuStrip: CtrlMenuStrip { + class Items { + items[] += {QUOTE(PREFIX)}; + class PREFIX { + text = CSTRING(Toolbar); + }; + }; + }; + }; +}; diff --git a/addons/simpleSpawn/README.md b/addons/simpleSpawn/README.md new file mode 100644 index 0000000..dbf3223 --- /dev/null +++ b/addons/simpleSpawn/README.md @@ -0,0 +1,8 @@ +## Main + +Base for other components. Provides CBA Macros framework, editor categories and similar. + +### Authors + +- [3Mydlo3](http://github.com/3Mydlo3) +- [Madin](http://github.com/Madin5) diff --git a/addons/simpleSpawn/config.cpp b/addons/simpleSpawn/config.cpp new file mode 100644 index 0000000..2c86d83 --- /dev/null +++ b/addons/simpleSpawn/config.cpp @@ -0,0 +1,19 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = COMPONENT_NAME; + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = { + "cba_main" + }; + author = "ArmaForces"; + VERSION_CONFIG; + }; +}; + +#include "CfgEden.hpp" +#include "CfgModuleCategories.hpp" +#include "DisplayEden.hpp" diff --git a/addons/simpleSpawn/functions/fn_despawn.sqf b/addons/simpleSpawn/functions/fn_despawn.sqf new file mode 100644 index 0000000..f755cc5 --- /dev/null +++ b/addons/simpleSpawn/functions/fn_despawn.sqf @@ -0,0 +1,77 @@ + /* + MAI_fnc_simpleSpawnDespawn + + Description: + Despawn units + + Arguments: + 0: Logic + 1: + + Return Value: + None + +*/ + +params [ + ["_logic", objNull, [objNull]] +]; + +if (_logic isEqualTo objNull) exitWith {}; + +private _spawnedGroups = _logic getVariable ["spawnedGroups", []]; +// check for every group if there are any allive units. +private _aliveGroupIndex = _spawnedGroups findIf { + (units _x findIf {alive _x}) != -1 +}; +if (_aliveGroupIndex == -1) exitWith {}; // no alive units left. + +private _activation = _logic getVariable ["activation", 750]; +private _deactivation = _logic getVariable ["deactivation", 750]; +private _deactivationDistance = _activation + _deactivation; + +private _nearUnits = _logic nearEntities ["AllVehicles", _deactivationDistance]; + +private _playersNear = (_nearUnits findIf {isPlayer _x && {alive _x}}) != -1; + +private _activateByDistance = ((_nearUnits findIf {isPlayer _x}) != -1); + +if !(_activateByDistance) exitWith { + { + { + if (alive _x && stance _x == "STAND") then { + [_x,"AmovPercMstpSrasWrflDnon_AinvPknlMstpSlayWrflDnon"] remoteExecCall ["switchMove", 0]; + }; + } forEach units _x; + } forEach _spawnedGroups; + [ + { + params [["_logic", objNull, [objNull]]]; + private _spawnedGroups = _logic getVariable ["spawnedGroups", []]; + private _groupsArray = [_spawnedGroups] call MAI_fnc_simpleSpawnGetGroups; + _groupsArray params ["_groups", "_vehiclesInfo", "_vehiclesToDelete"]; + _logic setVariable ["groups", _groups]; + _logic setVariable ["vehiclesInfo", _vehiclesInfo]; + private _vehicles = _logic getVariable ["vehicles", []]; + { + deleteVehicle _x; + } forEach _vehicles; + _logic setVariable ["vehicles", nil]; + [ + {_this call MAI_fnc_simpleSpawnWaitUntil}, + _this, + random [0.9,1,1.1] + ] call CBA_fnc_waitAndExecute; + }, + _this, + 0.5 + ] call CBA_fnc_waitAndExecute; +}; + +[ + {_this call MAI_fnc_simpleSpawnDespawn}, + _this, + random [0.9,1,1.1] +] call CBA_fnc_waitAndExecute; + +Nil \ No newline at end of file diff --git a/addons/simpleSpawn/functions/fn_firstState.sqf b/addons/simpleSpawn/functions/fn_firstState.sqf new file mode 100644 index 0000000..69e7dff --- /dev/null +++ b/addons/simpleSpawn/functions/fn_firstState.sqf @@ -0,0 +1,52 @@ + /* + MAI_fnc_simpleSpawnFirstState + + Description: + wait until Resp Point condition meet to start script + + Arguments: + 0: Logic + 1: + + Return Value: + None + +*/ + +params [ + ["_logic", objNull], + "_activationTriggers", + ["_groups", []], + ["_vehiclesInfo", []], + ["_interval", 0.1], + ["_unitsPerInterval", 1], + ["_deleteVehicles", false], + ["_activation", 750], + ["_deactivation", -1], + ["_includeAir", false], + ["_forceActivate", true], + ["_checkBuildings", true], + ["_activateCondition", {true}], + ["_executionCodeUnit", {}], + ["_executionCodePatrol", {}], + ["_executionCodeVehicle", {}] +]; + +if (_logic isEqualTo objNull) exitWith {}; +_logic setVariable ["activationTriggers", _activationTriggers]; +_logic setVariable ["groups", _groups]; +_logic setVariable ["vehiclesInfo", _vehiclesInfo]; +_logic setVariable ["activation", _activation]; +_logic setVariable ["deactivation", _deactivation]; +_logic setVariable ["includeAir", _includeAir]; +_logic setVariable ["forceActivate", _forceActivate]; +_logic setVariable ["checkBuildings", _checkBuildings]; +_logic setVariable ["activateCondition", _activateCondition]; +_logic setVariable ["interval", _interval]; +_logic setVariable ["deleteVehicles", _deleteVehicles]; +_logic setVariable ["unitsPerInterval", _unitsPerInterval]; +_logic setVariable ["executionCodeUnit", _executionCodeUnit]; +_logic setVariable ["executionCodePatrol", _executionCodePatrol]; +_logic setVariable ["executionCodeVehicle", _executionCodeVehicle]; + +[_logic, _groups, _vehiclesInfo] call MAI_fnc_simpleSpawnInterval; \ No newline at end of file diff --git a/addons/simpleSpawn/functions/fn_getGroups.sqf b/addons/simpleSpawn/functions/fn_getGroups.sqf new file mode 100644 index 0000000..25f9843 --- /dev/null +++ b/addons/simpleSpawn/functions/fn_getGroups.sqf @@ -0,0 +1,125 @@ + /* + MAI_fnc_simpleSpawnGetGroups + + Description: + Initiate simple spawn on server, then wait until condition meet + + Arguments: + 0: Logic + 1: Trigger activated + 2: Placed by curator + + Return Value: + None + +*/ +params [ + ["_groupsInput",[],[[]]] +]; + +private _groups = []; +private _vehiclesInfo = []; +private _vehiclesToDelete = []; +{ + private _group = _x; + private _leader = leader _group; + + private _side = side _x; + private _waypoints = []; + private _behaviour = behaviour _leader; + private _units = []; + + // waypoints + { + private _wPos = waypointPosition _x; + // don't include "dummy" waypoint + if (_forEachIndex > 0) then { + private _wType = waypointType _x; + private _wTimeout = waypointTimeout _x; + private _behaviourWp = waypointBehaviour _x; + _waypoints pushBack [_wPos, _wType, _wTimeout, _behaviourWp]; + }; + } forEach (waypoints _group); + // units + { + private _unit = _x; + if (alive _unit) then { + private _type = typeOf _unit; + private _loadout = getUnitLoadout _unit; + private _pos = _unit modelToWorld [0, 0, 0]; + private _dir = getDir _unit; + private _stance = unitPos _unit; + + private _disabledAiFeatures = []; + { + if !(_unit checkAIFeature _x) then { + _disabledAiFeatures pushBack _x + }; + }forEach [ + "TARGET", + "AUTOTARGET", + "MOVE", + "ANIM", + "TEAMSWITCH", + "FSM", + "WEAPONAIM", + "AIMINGERROR", + "SUPPRESSION", + "CHECKVISIBLE", + "COVER", + "AUTOCOMBAT", + "PATH", + "MINEDETECTION", + "NVG", + "LIGHTS", + "RADIOPROTOCOL" + ]; + + private _vehicleArray = []; + private _vehicle = vehicle _unit; + if !(_vehicle isKindOf "MAN") then { + private _vehicleRole = assignedVehicleRole _unit; + private _vehicleIndex = -1; + _vehicleIndex = _vehiclesToDelete findIf {_x isEqualTo _vehicle}; + if (_vehicleIndex == -1) then { + private _vehInfo = _vehicle call MAI_fnc_getVehicleInfo; + _vehiclesInfo pushBack _vehInfo; + _vehiclesToDelete pushBack _vehicle; + _vehicleIndex = count _vehiclesInfo - 1; + }; + private _assignedRole = assignedVehicleRole _unit; + private _cargoIndex = _vehicle getCargoIndex _unit; + _vehicleArray = [ + _vehicle, + _assignedRole, + _cargoIndex, + _vehicleIndex + ]; + }; + + // check if building above/below unit is "alive" + // if true, do not spawn unit when that building will not be "alive" + private _posASL = getposASL _unit; + private _building = objNull; + private _buildingStatus = false; + private _objects = lineIntersectsWith [_posASL vectorAdd [0,0,0.5], _posASL vectorAdd [0,0,50], _unit, vehicle _unit, true]; + if (_objects isEqualTo []) then { + _objects = lineIntersectsWith [_posASL vectorAdd [0,0,0.5], _posASL vectorAdd [0,0,-1.5], _unit, vehicle _unit, true]; + }; + if !(_objects isEqualTo [])then { + private _object = _objects select 0; + _building = _object; + _buildingStatus = alive _object; + }; + + _units pushBack [_type, _loadout, _pos, _dir, _stance, _disabledAiFeatures, _vehicleArray, _building, _buildingStatus]; + }; + deleteVehicle _unit; + } forEach units _group; + if !(_units isEqualTo []) then { + _groups pushBack [_side, _units, _waypoints, _behaviour, formation _group, combatMode _group, speedMode _group]; + }; + deleteGroup _group; +} forEach _groupsInput; + +[_groups, _vehiclesInfo, _vehiclesToDelete] \ No newline at end of file diff --git a/addons/hiddenUnitSpawner/functions/fnc_init.sqf b/addons/simpleSpawn/functions/fn_init.sqf similarity index 52% rename from addons/hiddenUnitSpawner/functions/fnc_init.sqf rename to addons/simpleSpawn/functions/fn_init.sqf index be39ea2..6e5538b 100644 --- a/addons/hiddenUnitSpawner/functions/fnc_init.sqf +++ b/addons/simpleSpawn/functions/fn_init.sqf @@ -1,23 +1,20 @@ -#include "script_component.hpp" -/* - * Author: - * Function description - * - * Arguments: - * 0: Objects - * 1: All - * - * Return Value: - * None - * - * Example: - * [[bob, ted], false] call afmf_main_fnc_example - * - * Public: No - */ + /* + MAI_fnc_simpleSpawnInit + Description: + Initiate simple spawn on server, then wait until condition meet + + Arguments: + 0: Logic + 1: Trigger activated + 2: Placed by curator + + Return Value: + None + +*/ if (!isServer) exitWith { - // diag_log text "[MAI_fnc_staticSpawnInit] script intended to be only used on server, exit."; + diag_log text "[MAI_fnc_buildSpawnInit] script intended to be only used on server, exit."; }; params [ ["_logic",objNull,[objNull]], @@ -28,7 +25,7 @@ params [ private _synchronizedObjects = synchronizedObjects _logic; if (_synchronizedObjects isEqualTo []) exitWith { - // (format ["[%1] STATIC SPAWN - No units synchronized!", _logic]) call BIS_fnc_error; + (format ["[%1] SIMPLE SPAWN - No units synchronized!", _logic]) call BIS_fnc_error; }; _activationTriggers = []; @@ -39,27 +36,29 @@ private _groupSync = []; }else{ if (_x isKindOf "Man") then { _groupSync pushBackUnique group _x; + }else{ + { + _groupSync pushBackUnique group _x + } forEach crew _x; }; }; } forEach _synchronizedObjects; _logic setVariable ["activationTriggers",_activationTriggers]; -private _groupsArray = [_groupSync, _logic] call EFUNC(main,getGroups); -_groupsArray params ["_groups", "_vehiclesInfo"]; -_logic setVariable [QGVAR(vehiclesInfo), _vehiclesInfo]; +private _groupsArray = [_groupSync] call MAI_fnc_simpleSpawnGetGroups; +_groupsArray params ["_groups", "_vehiclesInfo", "_vehiclesToDelete"]; +_logic setVariable ["vehiclesInfo", _vehiclesInfo]; -/* private _deleteVehicles = _logic getVariable ["deleteVehicles", false]; if (_deleteVehicles) then { {deleteVehicle _x} forEach _vehiclesToDelete; }; -*/ _logic setVariable ["groups", _groups]; [ - {_this call FUNC(WaitUntil)}, + {_this call MAI_fnc_simpleSpawnWaitUntil}, [_logic], 1 ]call CBA_fnc_waitAndExecute; diff --git a/addons/hiddenUnitSpawner/functions/fnc_initCall.sqf b/addons/simpleSpawn/functions/fn_initCall.sqf similarity index 81% rename from addons/hiddenUnitSpawner/functions/fnc_initCall.sqf rename to addons/simpleSpawn/functions/fn_initCall.sqf index ab22050..323521b 100644 --- a/addons/hiddenUnitSpawner/functions/fnc_initCall.sqf +++ b/addons/simpleSpawn/functions/fn_initCall.sqf @@ -1,21 +1,17 @@ -#include "script_component.hpp" -/* - * Author: - * Function description - * - * Arguments: - * 0: Objects - * 1: All - * - * Return Value: - * None - * - * Example: - * [[bob, ted], false] call afmf_main_fnc_example - * - * Public: No - */ - + /* + MAI_fnc_simpleSpawnInitCall + + Description: + Initiate Respawn Point from 3den + + Arguments: + predefined by arma https://community.bistudio.com/wiki/Modules + synchronized units are used + + Return Value: + None + +*/ if (!isServer) exitWith {}; private _mode = param [0,"",[""]]; @@ -24,11 +20,11 @@ private _input = param [1,[],[[]]]; switch _mode do { // Default object init case "init": { - //if (is3DEN) exitWith { + // if (is3DEN) exitWith { //["init", 0] call BIS_fnc_3DENNotification; //}; [ - {_this call FUNC(Init)}, + {_this call MAI_fnc_simpleSpawnInit}, _input ] call CBA_fnc_execNextFrame; }; @@ -58,4 +54,5 @@ switch _mode do { //["dragged3DEN", 0] call BIS_fnc_3DENNotification; }; }; + Nil \ No newline at end of file diff --git a/addons/simpleSpawn/functions/fn_interval.sqf b/addons/simpleSpawn/functions/fn_interval.sqf new file mode 100644 index 0000000..35bff0b --- /dev/null +++ b/addons/simpleSpawn/functions/fn_interval.sqf @@ -0,0 +1,144 @@ + /* + MAI_fnc_simpleSpawnInterval + + Description: + Sequential units spawn + + Arguments: + 0: Logic + 1: + + Return Value: + None + +*/ + +params [ + ["_logic", objNull], + ["_groups", []], + ["_vehiclesInfo", []] +]; +if (_logic isEqualTo objNull) exitWith {}; +if (_groups isEqualTo []) exitWith {}; + +private _deleteVehicles = _logic getVariable ["deleteVehicles", false]; +private _vehicles = _logic getVariable ["vehicles", []]; +private _unitsPerInterval = _logic getVariable ["unitsPerInterval", 1]; +private _interval = _logic getVariable ["interval", 0.1]; +private _executionCodeVehicle = _logic getVariable ["executionCodeVehicle", {}]; +private _checkBuildings = _logic getVariable ["checkBuildings", true]; + +// spawn vehicles +if (_deleteVehicles && !(_vehiclesInfo isEqualTo [])) exitWith { + private _vehiclesInfoNew = +_vehiclesInfo; + for "_i" from 1 to (_unitsPerInterval min count _vehiclesInfoNew) do { + private _vehInfo = _vehiclesInfoNew deleteAt 0; + private _vehicle = _vehInfo call MAI_fnc_createVehicleFromInfo; + [_vehicle] call _executionCodeVehicle; + _vehicles pushBack _vehicle; + _logic setVariable ["vehicles", _vehicles]; + }; + [ + { + _this call MAI_fnc_simpleSpawnInterval; + }, + [_logic, _groups, _vehiclesInfoNew], + _interval + ] call CBA_fnc_waitAndExecute; +}; + +private _executionCodeUnit = _logic getVariable ["executionCodeUnit", {}]; +private _executionCodePatrol = _logic getVariable ["executionCodePatrol", {}]; + +private _spawnedUnits = _logic getVariable ["spawnedUnits", 0]; + +private _groupArray = _groups select 0; + +_groupArray params ["_side", "_units", "_waypoints", "_behaviour", "_formation", "_combatmode", "_speedMode", ["_group", grpNull]]; + +// create group when not present +if (_group isEqualTo grpNull) then { + _group = createGroup [_side, true]; + _groupArray set [7, _group]; + [_group] call _executionCodePatrol; + private _spawnedGroups = _logic getVariable ["spawnedGroups", []]; + _spawnedGroups pushBack _group; + _logic setVariable ["spawnedGroups", _spawnedGroups]; + { + _x params ["_wPos", "_wType", "_wTimeout", "_behaviourWp"]; + private _wp =_group addWaypoint [_wPos, 0]; + _wp setWaypointType _wType; + _wp setWaypointTimeout _wTimeout; + _wp setWaypointBehaviour _behaviourWp; + } forEach _waypoints; +}; + +while {_spawnedUnits < _unitsPerInterval && !(_units isEqualTo [])} do { + private _unit = objNull; + private _unitArray = _units deleteAt 0; + _unitArray params ["_type", "_loadout", "_pos", "_dir", "_stance", "_disabledAiFeatures", "_vehicleArray", "_building", "_buildingStatus"]; + if !(_vehicleArray isEqualTo []) then { + _vehicleArray params ["_vehicle", "_role", "_cargoIndex", "_vehicleIndex"]; + if (_deleteVehicles && {_vehicle isEqualTo objNull}) then { + _vehicle = _vehicles select _vehicleIndex; + }; + if (alive _vehicle) then { + // check if vehicle is static and _checkBuildings option is set + if ( + _checkBuildings && { + _vehicle isKindOf "StaticWeapon" && + {!(alive _building isEqualTo _buildingStatus)} + }) exitWith {}; + _unit = [_group, _type, _pos, _dir, 0, false] call MAI_fnc_spawnAI; + _spawnedUnits = _spawnedUnits + 1; + _unit setUnitLoadout _loadout; + _group addVehicle _vehicle; + [_unit, _vehicle, _role, _cargoIndex] call MAI_fnc_moveInVehicleRole; + }; + } else { + if (!_checkBuildings || alive _building isEqualTo _buildingStatus) then { + _unit = [_group, _type, _pos, _dir] call MAI_fnc_spawnAI; + _spawnedUnits = _spawnedUnits + 1; + _unit setUnitLoadout _loadout; + _unit setUnitPos _stance; + }; + }; + + { + [_unit, _x] remoteExecCall ["disableAI", 0, _unit]; + } forEach _disabledAiFeatures; + + [_unit] call _executionCodeUnit; + + if (count units _group == 1) then { + _group setFormation _formation; + _group setCombatMode _combatmode; + _group setBehaviourStrong _behaviour; + _group setSpeedMode _speedMode; + }; + + if (_units isEqualTo []) then { + _groups deleteAt 0; + }; +}; + +if (_groups isEqualTo []) exitWith { + private _deactivation = _logic getVariable ["deactivation", -1]; + if (_deactivation >= 0) then { + [ + {_this call MAI_fnc_simpleSpawnDespawn}, + [_logic], + 1 + ]call CBA_fnc_waitAndExecute; + }; +}; + +[ + { + _this call MAI_fnc_simpleSpawnInterval; + }, + _this, + _interval +] call CBA_fnc_waitAndExecute; + +Nil \ No newline at end of file diff --git a/addons/simpleSpawn/functions/fn_waitUntil.sqf b/addons/simpleSpawn/functions/fn_waitUntil.sqf new file mode 100644 index 0000000..2424d24 --- /dev/null +++ b/addons/simpleSpawn/functions/fn_waitUntil.sqf @@ -0,0 +1,71 @@ + /* + MAI_fnc_simpleSpawnWaitUntil + + Description: + wait until Resp Point condition meet to start script + + Arguments: + 0: Logic + 1: + + Return Value: + None + +*/ + +params [["_logic",objNull]]; + +if (_logic isEqualTo objNull) exitWith {}; + +private _activate = [_logic] call MAI_fnc_checkActivateConditions; + +if (_activate) then { + private _groups = _logic getVariable ["groups", []]; + private _vehiclesInfo = _logic getVariable ["vehiclesInfo" ,[]]; + + if (!isServer && !hasInterface) exitWith { + [_logic, _groups, _vehiclesInfo] call MAI_fnc_simpleSpawnInterval; + }; + + private _activationTriggers = _logic getVariable ["activationTriggers" ,[]]; + private _interval = _logic getVariable ["interval" ,[]]; + private _unitsPerInterval = _logic getVariable ["unitsPerInterval", []]; + private _deleteVehicles = _logic getVariable ["deleteVehicles", false]; + private _activation = _logic getVariable ["activation", 750]; + private _deactivation = _logic getVariable ["deactivation", -1]; + private _includeAir = _logic getVariable ["includeAir", false]; + private _forceActivate = _logic getVariable ["forceActivate", false]; + private _checkBuildings = _logic getVariable ["checkBuildings", true]; + private _activateCondition = _logic getVariable ["activateCondition", {true}]; + private _executionCodeUnit = _logic getVariable ["executionCodeUnit", {}]; + private _executionCodePatrol = _logic getVariable ["executionCodePatrol", {}]; + private _executionCodeVehicle = _logic getVariable ["executionCodeVehicle", {}]; + + private _owner = call MAI_fnc_HCfind; + [ + _logic, + _activationTriggers, + _groups, + _vehiclesInfo, + _interval, + _unitsPerInterval, + _deleteVehicles, + _activation, + _deactivation, + _includeAir, + _forceActivate, + _checkBuildings, + _activateCondition, + _executionCodeUnit, + _executionCodePatrol, + _executionCodeVehicle + ] remoteExecCall ["MAI_fnc_simpleSpawnFirstState",_owner,false]; +}else +{ + [{_this call MAI_fnc_simpleSpawnWaitUntil}, + _this, + random [0.9,1,1.1] + ] call CBA_fnc_waitAndExecute; +}; + +Nil \ No newline at end of file diff --git a/addons/simpleSpawn/script_component.hpp b/addons/simpleSpawn/script_component.hpp new file mode 100644 index 0000000..920a503 --- /dev/null +++ b/addons/simpleSpawn/script_component.hpp @@ -0,0 +1,14 @@ +#define COMPONENT main +#include "\z\afmf\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE + +#ifdef DEBUG_ENABLED_MAIN + #define DEBUG_MODE_FULL +#endif + #ifdef DEBUG_SETTINGS_MAIN + #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN +#endif + +#include "\z\afmf\addons\main\script_macros.hpp" diff --git a/addons/simpleSpawn/script_debug.hpp b/addons/simpleSpawn/script_debug.hpp new file mode 100644 index 0000000..1a57c6b --- /dev/null +++ b/addons/simpleSpawn/script_debug.hpp @@ -0,0 +1,25 @@ + +/** + Fast Recompiling via function +**/ +// #define DISABLE_COMPILE_CACHE +// To Use: [] call afmf_PREP_RECOMPILE; + +#ifdef DISABLE_COMPILE_CACHE + #define LINKFUNC(x) {_this call FUNC(x)} + #define PREP_RECOMPILE_ADD_BUTTON \ + if (isNil 'PREFIX##_PREP_RECOMPILE_BUTTON') then {\ + [] spawn {\ + INFO('Adding Recompilation button');\ + [['Recomp. PREFIX', 'Recompile functions of PREFIX'], {call PREFIX##_PREP_RECOMPILE}] call afm_debug_console_fnc_addButton;\ + };\ + PREFIX##_PREP_RECOMPILE_BUTTON = true;\ + } + #define PREP_RECOMPILE_START if (isNil 'PREFIX##_PREP_RECOMPILE') then {PREFIX##_RECOMPILES = []; PREFIX##_PREP_RECOMPILE = {{call _x} forEach PREFIX##_RECOMPILES;}}; private _recomp = {INFO('Compiling'); + #define PREP_RECOMPILE_END }; call _recomp; PREFIX##_RECOMPILES pushBack _recomp; PREP_RECOMPILE_ADD_BUTTON; +#else + #define LINKFUNC(x) FUNC(x) + #define PREP_RECOMPILE_ADD_BUTTON /* */ + #define PREP_RECOMPILE_START /* */ + #define PREP_RECOMPILE_END /* */ +#endif diff --git a/addons/simpleSpawn/script_macros.hpp b/addons/simpleSpawn/script_macros.hpp new file mode 100644 index 0000000..41baf98 --- /dev/null +++ b/addons/simpleSpawn/script_macros.hpp @@ -0,0 +1,27 @@ +#include "\x\cba\addons\main\script_macros_common.hpp" +#define DFUNC(module) TRIPLES(ADDON,fnc,module) +#ifdef DISABLE_COMPILE_CACHE + #undef PREP + #define PREP(fncName) DFUNC(fncName) = compile preprocessFileLineNumbers QPATHTOF(functions\DOUBLES(fnc,fncName).sqf) +#else + #undef PREP + #define PREP(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf), QFUNC(fncName)] call CBA_fnc_compileFunction +#endif + +// ACE3 reference macros +#define ACE_PREFIX ace + +#define ACEGVAR(module,var) TRIPLES(ACE_PREFIX,module,var) +#define QACEGVAR(module,var) QUOTE(ACEGVAR(module,var)) + +#define ACEFUNC(module,function) TRIPLES(DOUBLES(ACE_PREFIX,module),fnc,function) +#define QACEFUNC(module,function) QUOTE(ACEFUNC(module,function)) + +#define ACELSTRING(module,string) QUOTE(TRIPLES(STR,DOUBLES(ACE_PREFIX,module),string)) +#define ACECSTRING(module,string) QUOTE(TRIPLES($STR,DOUBLES(ACE_PREFIX,module),string)) + +// AFMF macros +#define IS_MOD_LOADED(modclass) (isClass (configFile >> "CfgPatches" >> #modclass)) + +// AFMF Debug macros +#include "\z\afmf\addons\main\script_debug.hpp" diff --git a/addons/simpleSpawn/script_mod.hpp b/addons/simpleSpawn/script_mod.hpp new file mode 100644 index 0000000..37f3bc8 --- /dev/null +++ b/addons/simpleSpawn/script_mod.hpp @@ -0,0 +1,16 @@ +#define MAINPREFIX z +#define PREFIX afmf + +#include "script_version.hpp" + +#define VERSION MAJOR.MINOR +#define VERSION_STR MAJOR.MINOR.PATCH +#define VERSION_AR MAJOR,MINOR,PATCH + +#define REQUIRED_VERSION 1.94 + +#ifdef COMPONENT_BEAUTIFIED + #define COMPONENT_NAME QUOTE(AFMF - COMPONENT_BEAUTIFIED) +#else + #define COMPONENT_NAME QUOTE(AFMF - COMPONENT) +#endif diff --git a/addons/simpleSpawn/script_version.hpp b/addons/simpleSpawn/script_version.hpp new file mode 100644 index 0000000..bed65fe --- /dev/null +++ b/addons/simpleSpawn/script_version.hpp @@ -0,0 +1,3 @@ +#define MAJOR 0 +#define MINOR 0 +#define PATCH 0 diff --git a/addons/simpleSpawn/stringtable.xml b/addons/simpleSpawn/stringtable.xml new file mode 100644 index 0000000..6f307b2 --- /dev/null +++ b/addons/simpleSpawn/stringtable.xml @@ -0,0 +1,15 @@ + + + + + ArmaForces Attributes + Atrybuty ArmaForces + + + ArmaForces + + + ArmaForces + + +