Browse Source

Initial working droid dispenser [Just script part]

is a standalone pbo for time being, reckon the moving parts would be better to put together than not since they are from many of the other categories. (Units/Ammo/Zeus/Main)
m3ales 4 years ago
parent
commit
2a0da3e178

+ 2 - 0
addons - Copy/RD501_Droid_Dispenser/XEH_postInit.sqf

@@ -0,0 +1,2 @@
+#include "config_macros.hpp"
+GVAR(spawnTime) = 5;

+ 3 - 0
addons - Copy/RD501_Droid_Dispenser/XEH_preInit.sqf

@@ -0,0 +1,3 @@
+#include "config_macros.hpp"
+#include "XEH_prep.hpp"
+diag_log format["%1 PREP COMPLETE", QUOTE(ADDON)];

+ 4 - 0
addons - Copy/RD501_Droid_Dispenser/XEH_prep.hpp

@@ -0,0 +1,4 @@
+#include "config_macros.hpp"
+#define PREP(name) FUNC(name) = compile preProcessFileLineNumbers QUOTE(ADDON\functions\CONCAT(fnc_,name).sqf)
+PREP(spawnDroidPFH);
+PREP(spawnerInit);

+ 25 - 0
addons - Copy/RD501_Droid_Dispenser/config.cpp

@@ -0,0 +1,25 @@
+#include "config_macros.hpp"
+#define COMPILE_FILE(name) compile preprocessFileLineNumbers SQUOTE(ADDON\name.sqf)
+
+class CfgPatches {
+	class ADDON
+	{
+		name = QUOTE(Droid Dispenser);
+		author = "M3ales";
+		requiredAddons[] = {};
+		units[] = {};
+		weapons[] = {};
+	};
+};
+
+class Extended_PreInit_EventHandlers {
+    class ADDON {
+        init = QUOTE(call COMPILE_FILE(XEH_preInit));
+    };
+};
+
+class Extended_PostInit_EventHandlers {
+    class ADDON {
+        init = QUOTE(call COMPILE_FILE(XEH_postInit));
+    };
+};

+ 16 - 0
addons - Copy/RD501_Droid_Dispenser/config_macros.hpp

@@ -0,0 +1,16 @@
+#ifndef RD501_DROID_DISPENSER
+	#define RD501_DROID_DISPENSER
+	#define ADDON RD501_Droid_Dispenser
+	#define PREFIX rd501
+	#define QUOTE(target) #target
+	#define SQUOTE(target) 'target'
+	#define CONCAT(a,b) a##b
+	#define CONCAT_3(a,b,c) CONCAT(a,CONCAT(b,c))
+	#define FUNC(name) CONCAT_3(PREFIX,_fnc_,name)
+	#define ARR_2(a,b) a,b
+	#define ARR_3(a,b,c) a,b,c
+	#define ARR_4(a,b,c,d) a,b,c,d
+	#define GVAR(name) CONCAT(PREFIX,CONCAT(_,name))
+	#define QGVAR(name) QUOTE(GVAR(name))
+	#define UNIT_NAME(side,name) CONCAT_3(PREFIX,_,CONCAT_3(side,_unit_,name))
+#endif

+ 24 - 0
addons - Copy/RD501_Droid_Dispenser/functions/fnc_spawnDroidPFH.sqf

@@ -0,0 +1,24 @@
+#include "function_macros.hpp"
+params ["_args", "_handle"];
+_args params ["_target"];
+systemChat format["Evaluating PFH %1",_handle];
+
+if(isNil "_target") exitWith {
+	systemChat format["Removing PFH %1 due to null target",_handle];
+};
+
+if(!isServer || ! alive _target) exitWith {
+	systemChat format["Removing PFH %1",_handle];
+	[_handle] call CBA_fnc_removePerFrameHandler;
+};
+_group = _target getVariable QGVAR(group);
+
+_aliveUnits = ({alive _x} count (units _group));
+systemChat format["%1 :: %2",_target,_aliveUnits];
+if(_aliveUnits < _target getVariable QGVAR(maxUnits)) exitWith 
+{
+	_selectedUnit = selectRandom (_target getVariable QGVAR(possibleUnits));
+	systemChat format["%1 spawning in %2",_target,_selectedUnit];
+	_group createUnit [_selectedUnit, position _target, [], 0, "NONE"];
+};
+systemChat format["%1 not spawning anything"];

+ 12 - 0
addons - Copy/RD501_Droid_Dispenser/functions/fnc_spawnerInit.sqf

@@ -0,0 +1,12 @@
+#include "function_macros.hpp"
+params ["_target"];
+if(!isServer) exitWith { systemChat "Not Server, Exiting PFH"; };
+systemChat format["Initialising spawner %1",_target];
+_target setVariable [QGVAR(group), createGroup [opfor, true]]; // group that units will be spawned into
+_target setVariable [QGVAR(boundUnits), []]; // units currently bound to this unit
+_target setVariable [QGVAR(maxUnits),20]; // max units that can be alive at any time from this spawner
+_target setVariable [QGVAR(possibleUnits),["RD501_opfor_unit_B2_droid_Standard","RD501_opfor_unit_b1_grenadier","RD501_opfor_unit_B2_droid_Standard","RD501_opfor_unit_B1_AA","RD501_opfor_unit_B1_AT_heavy","RD501_opfor_unit_B1","RD501_opfor_unit_B1_marksman"]];
+// Start PFH
+systemChat format["Starting PFH on %1",_target];
+_params= [_target];
+ _handle = [FUNC(spawnDroidPFH), GVAR(spawnTime), _params] call CBA_fnc_addPerFrameHandler;

+ 1 - 0
addons - Copy/RD501_Droid_Dispenser/functions/function_macros.hpp

@@ -0,0 +1 @@
+#include "../config_macros.hpp";