Browse Source

Merge branch 'add-droid-dispenser' of https://github.com/Zatama/Aux-Mod-501st into add-droid-dispenser

Erliens 4 years ago
parent
commit
4b2426504e

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

@@ -0,0 +1,4 @@
+#include "config_macros.hpp"
+GVAR(spawnTime) = 5;
+GVAR(spawnerDefaultObject) = "Land_Cargo_House_V1_F";
+GVAR(fireSupportSpawnDelay) = 8;

+ 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)];

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

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

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

@@ -0,0 +1,69 @@
+#include "config_macros.hpp"
+#define COMPILE_FILE(name) compile preprocessFileLineNumbers SQUOTE(ADDON\name.sqf)
+//Land_Cargo_House_V1_F
+class CfgPatches {
+	class ADDON
+	{
+		name = QUOTE(Droid Dispenser);
+		author = "RD501";
+		requiredAddons[] = {};
+		units[] = { QUOTE(ORDNANCE(DroidDispenser)) };
+		weapons[] = {};
+	};
+};
+class CfgVehicles
+{
+	class ModuleOrdnance_F;
+	class ORDNANCE(DroidDispenser): ModuleOrdnance_F
+	{
+		author = "RD501";
+		isGlobal = 1;
+		scope = 1;
+		scopeCurator = 2;
+		simulation = "house";
+		category = "Ordnance";
+		model = "\a3\Modules_F_Curator\Ordnance\surfacehowitzer.p3d";
+        function = QUOTE(FUNC(newSpawner));
+        functionPriority = 1;
+		displayName = QUOTE(Droid Dispenser);
+		portrait = "\a3\Modules_F_Curator\Data\portraitOrdnanceMortar_ca.paa";
+		ammo = QUOTE(RD501_Droid_Dispenser_Round);
+		delete Arguments;
+	};
+};
+class CfgAmmo
+{
+	class ModuleOrdnanceHowitzer_F_ammo;
+	class ModuleOrdnanceMortar_F_ammo;
+	class ModuleOrdnanceRocket_F_ammo;
+	class RD501_Droid_Dispenser_Round : ModuleOrdnanceHowitzer_F_ammo
+	{
+		caliber = 950;
+		hit = 1000;
+		allowAgainstInfantry = 1;
+		canLock = 0;
+		explosive = 1;
+		fuseDistance = 30;
+		indirectHit = 200;
+		indirectHitRange = 2;
+		maxSpeed = 1100;
+		typicalSpeed = 1050;
+		sideAirFriction = 0;
+		submunitionAmmo = "";
+		submunitionConeAngle = 30;
+		simulation = "shotshell";
+		model="\A3\Structures_F\Mil\Cargo\Cargo_House_V1_F.p3d";
+	};
+};
+
+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));
+    };
+};

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

@@ -0,0 +1,17 @@
+#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))
+	#define ORDNANCE(name) CONCAT_3(PREFIX,_Ordnance_,name)
+#endif

+ 16 - 0
addons - Copy/RD501_Droid_Dispenser/functions/fnc_newSpawner.sqf

@@ -0,0 +1,16 @@
+#include "function_macros.hpp"
+
+LOG("Triggered newSpawner");
+//wait for projectile to land and then spawn vehicle
+params["_module"];
+_position = position _module;
+LOGF_2("Firing Spawner Artillery at %1, for %2",_postition,_unit);
+[{
+	params["_position"];
+	_spawner = GVAR(spawnerDefaultObject) createVehicle _position;
+	LOGF_2("Created Spawner %1 at %2",_spawner,position _spawner);
+	[_spawner] call FUNC(spawnerInit);
+}, [_position], GVAR(fireSupportSpawnDelay)] call CBA_fnc_waitAndExecute;
+
+// fire projectile
+_this call ace_zeus_fnc_bi_moduleProjectile;

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

@@ -0,0 +1,42 @@
+#include "function_macros.hpp"
+params ["_args", "_handle"];
+_args params ["_target"];
+systemChat format["Evaluating PFH %1",_handle];
+
+if(isNil "_target") exitWith {
+	LOGF_1("Removing PFH %1, Reason: Null Target",_handle);
+	[_handle] call CBA_fnc_removePerFrameHandler;
+};
+
+if(!isServer) exitWith {
+	LOGF_1("Removing PFH %1, Reason: Not Server",_handle);
+	[_handle] call CBA_fnc_removePerFrameHandler;
+}; 
+
+if(!alive _target) exitWith {
+	LOGF_1("Removing PFH %1, Reason: Spawner Dead",_handle);
+	[_handle] call CBA_fnc_removePerFrameHandler;
+};
+
+_group = _target getVariable QGVAR(group);
+
+if(isNil "_group") then 
+{
+	LOGF_1("PFH %1 Group empty, creating new",_handle);
+	_target setVariable [QGVAR(group), createGroup [opfor, true]];
+	_group = _target getVariable QGVAR(group);
+};
+
+_aliveUnits = ({alive _x} count (units _group));
+LOGF_2("Alive units for spawner %1 :: %2",_target,_aliveUnits);
+if(_aliveUnits < _target getVariable QGVAR(maxUnits)) exitWith 
+{
+	_possibleUnits = _target getVariable QGVAR(possibleUnits);
+	_selectedUnit = selectRandom _possibleUnits;
+	if(_selectedUnit == _possibleUnits select 0) then {
+		_selectedUnit = selectRandom _possibleUnits; // if its a b2, (first be default atm) random again (requires 2 rolls on b2 to spawn one)
+	};
+	LOGF_2("%1 spawning in %2",_target,_selectedUnit);
+	_group createUnit [_selectedUnit, position _target, [], 0, "NONE"];
+};
+LOGF_1("%1 not spawning anything",_target);

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

@@ -0,0 +1,18 @@
+#include "function_macros.hpp"
+params ["_target"];
+
+if(!isServer) exitWith
+{	
+	LOG_ERROR("Not Server, Exiting PFH"); 
+};
+
+LOGF_1("Initialising spawner %1",_target);
+// TODO: Read these vars from config, maybe CfgVehicles to allow placement of vehicles, although may be better to use static object with HP and destroyed mesh rather
+_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_AT_heavy","RD501_opfor_unit_B1","RD501_opfor_unit_B1_marksman"]];
+// Start PFH
+LOGF_1("Attempting to start PFH on %1",_target);
+_params= [_target];
+ _handle = [FUNC(spawnDroidPFH), GVAR(spawnTime), _params] call CBA_fnc_addPerFrameHandler;

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

@@ -0,0 +1,10 @@
+#include "../config_macros.hpp";
+#define LOG_BASE(level,msg) diag_log text format[QUOTE(ADDON[level]: %1), msg]
+#define LOG(msg) LOG_BASE(DEBUG, LOG_FILENUMBER(msg))
+#define LOGF_1(msg,arg0) LOG(format[ARR_2(msg,arg0)])
+#define LOGF_2(msg,arg0,arg1) LOG(format[ARR_3(msg,arg0,arg1)])
+#define LOGF_3(msg,arg0,arg1,arg2) LOG(format[ARR_4(msg,arg0,arg1,arg2)])
+#define LOG_ERROR(msg) LOG_BASE(ERR,LOG_FILENUMBER(msg))
+#define LOG_ERRORF_1(msg,arg0) LOG_ERROR(format[ARR_2(msg,arg0)])
+#define LOG_ERRORF_2(msg,arg0,arg1) LOG_ERROR(format[ARR_3(msg,arg0,arg1)])
+#define LOG_FILENUMBER(msg) format [ARR_4('%1 at %2:%3',msg,__FILE__,__LINE__ + 1)]