forge/arma/server/addons/task/functions/modules/fnc_defendModule.sqf
Jacob Schmidt 0cd6509337 Refactor phone and task systems around repositories
- Rename phone class to repository and update client event handlers
- Split task helpers/modules/prototypes and add mission generator flow
- Add reward parsing, mission manager startup, and attack logging
2026-05-02 01:29:25 -05:00

78 lines
3.0 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Initializes the defend task module.
* Reads parameters from the logic object and delegates to fnc_startTask.
* The designer must place a named marker in Eden for the defense zone.
* Enemy waves are spawned automatically by fnc_defend — no entities need
* to be synced to this module.
*
* Arguments:
* 0: Logic <OBJECT>
* 1: Units <ARRAY>
* 2: Activated <BOOL>
*
* Return Value:
* None
*
* Public: No
*/
params [["_logic", objNull, [objNull]], ["_units", [], [[]]], ["_activated", true, [true]]];
if !(_activated) exitWith {};
private _taskID = _logic getVariable ["TaskID", ""];
private _defenseZone = _logic getVariable ["DefenseZone", ""];
if (_taskID isEqualTo "") exitWith {
["ERROR", "Defend module: no task ID configured."] call EFUNC(common,log);
};
if (_defenseZone isEqualTo "" || { markerShape _defenseZone isEqualTo "" }) exitWith {
["ERROR", format ["Defend module '%1': DefenseZone marker '%2' is missing or invalid.", _taskID, _defenseZone]] call EFUNC(common,log);
};
["INFO", format [
"Defend Module Parameters: TaskID: %1, DefenseZone: %2, DefendTime: %3, WaveCount: %4, WaveCooldown: %5, MinBlufor: %6",
_taskID, _defenseZone,
_logic getVariable ["DefendTime", 600],
_logic getVariable ["WaveCount", 3],
_logic getVariable ["WaveCooldown", 300],
_logic getVariable ["MinBlufor", 1]
]] call EFUNC(common,log);
private _equipmentRewards = [_logic getVariable ["EquipmentRewards", "[]"], _taskID, "equipment"] call FUNC(parseRewards);
private _supplyRewards = [_logic getVariable ["SupplyRewards", "[]"], _taskID, "supplies"] call FUNC(parseRewards);
private _weaponRewards = [_logic getVariable ["WeaponRewards", "[]"], _taskID, "weapons"] call FUNC(parseRewards);
private _vehicleRewards = [_logic getVariable ["VehicleRewards", "[]"], _taskID, "vehicles"] call FUNC(parseRewards);
private _specialRewards = [_logic getVariable ["SpecialRewards", "[]"], _taskID, "special"] call FUNC(parseRewards);
[
"defend",
_taskID,
getMarkerPos _defenseZone,
format ["Defend: %1", _taskID],
"Hold the defense zone against incoming enemy forces.",
createHashMap,
createHashMapFromArray [
["funds", _logic getVariable ["CompanyFunds", 0]],
["ratingFail", _logic getVariable ["RatingFail", 0]],
["ratingSuccess", _logic getVariable ["RatingSuccess", 0]],
["endSuccess", _logic getVariable ["EndSuccess", false]],
["endFail", _logic getVariable ["EndFail", false]],
["defenseZone", _defenseZone],
["defendTime", _logic getVariable ["DefendTime", 600]],
["waveCount", _logic getVariable ["WaveCount", 3]],
["waveCooldown", _logic getVariable ["WaveCooldown", 300]],
["minBlufor", _logic getVariable ["MinBlufor", 1]],
["equipment", _equipmentRewards],
["supplies", _supplyRewards],
["weapons", _weaponRewards],
["vehicles", _vehicleRewards],
["special", _specialRewards]
]
] call FUNC(startTask);
deleteVehicle _logic;