Compare commits

..

2 Commits

Author SHA1 Message Date
Jacob Schmidt
635460f9d8 Merge branch 'master' of https://gitea.innovativedevsolutions.org/IDSolutions/client
Some checks failed
Build / Build (push) Failing after 11s
2025-05-25 14:20:40 -05:00
Jacob Schmidt
86ae5c4248 feat: Implement task rewards and penalties
This commit introduces a new task reward and penalty system.

The following changes were made:

- Added `handleTaskRewards` to `XEH_PREP.hpp` for pre-processing.
- Added parameters for equipment, supply, weapon, vehicle, and special rewards to the task definition functions (`fnc_defuse.sqf`, `fnc_destroy.sqf`, `fnc_attack.sqf`, `fnc_hvt.sqf`, `fnc_delivery.sqf`, `fnc_defend.sqf`, `fnc_hostage.sqf`).
- Modified task completion logic to handle rewards and penalties using the new `handleTaskRewards` function.
- Replaced direct reputation and fund modifications with the new reward system.
- Updated documentation to reflect the new reward parameters.
2025-05-25 14:20:36 -05:00
9 changed files with 452 additions and 168 deletions

View File

@ -10,6 +10,7 @@ PREP(destroy);
PREP(destroyModule);
PREP(explosivesModule);
PREP(handler);
PREP(handleTaskRewards);
PREP(heartBeat);
PREP(hostage);
PREP(hostageModule);

View File

@ -13,7 +13,12 @@
* 5: Amount of rating the company and player recieve if the task is successful <NUMBER> (default: 0)
* 6: Should the mission end (MissionSuccess) if the task is successful <BOOL> (default: false)
* 7: Should the mission end (MissionFailed) if the task is failed <BOOL> (default: false)
* 8: Amount of time before target(s) escape <NUMBER> (default: nil)
* 8: Amount of time before target(s) escape <NUMBER> (default: -1)
* 9: Equipment rewards <ARRAY> (default: [])
* 10: Supply rewards <ARRAY> (default: [])
* 11: Weapon rewards <ARRAY> (default: [])
* 12: Vehicle rewards <ARRAY> (default: [])
* 13: Special rewards <ARRAY> (default: [])
*
* Return Value:
* None
@ -25,7 +30,22 @@
* Public: Yes
*/
params [["_taskID", ""], ["_limitFail", -1], ["_limitSuccess", -1], ["_companyFunds", 0], ["_ratingFail", 0], ["_ratingSuccess", 0], ["_endSuccess", false], ["_endFail", false], "_time"];
params [
["_taskID", "", [""]],
["_limitFail", -1, [0]],
["_limitSuccess", -1, [0]],
["_companyFunds", 0, [0]],
["_ratingFail", 0, [0]],
["_ratingSuccess", 0, [0]],
["_endSuccess", false, [false]],
["_endFail", false, [false]],
["_time", -1, [0]],
["_equipmentRewards", [], [[]]],
["_supplyRewards", [], [[]]],
["_weaponRewards", [], [[]]],
["_vehicleRewards", [], [[]]],
["_specialRewards", [], [[]]]
];
private _result = 0;
@ -43,7 +63,7 @@ waitUntil {
private _targetsKilled = ({ !alive _x } count _targets);
if (!isNil "_time") then {
if (_time isNotEqualTo -1) then {
private _timeExpired = (floor time - _startTime >= _time);
if (_targetsKilled < _limitSuccess && _timeExpired) then { _result = 1; };
@ -59,35 +79,39 @@ if (_result == 1) then {
[_taskID, "FAILED"] call BFUNC(taskSetState);
if (_endFail) then {
["MissionFail", false] remoteExecCall ["BIS_fnc_endMission", playerSide];
};
private _penalties = createHashMap;
_penalties set ["reputation", _ratingFail];
// ["deduct", _ratingFail] remoteExecCall ["forge_server_rating_fnc_handleRating", 2];
[_ratingFail] call EFUNC(org,addReputation);
[format ["Task failed: %1 reputation", _ratingFail], "warning", 5, "right"] call EFUNC(misc,notify);
[_taskID, _penalties] call FUNC(handleTaskRewards);
sleep 1;
sleep 1;
{ [_x, _ratingFail] remoteExec ["addRating", -2] } forEach allPlayers;
[format ["Task failed: %1 reputation", _ratingFail], "warning", 5, "right"] call EFUNC(misc,notify);
{ [_x, _ratingFail] remoteExec ["addRating", -2] } forEach allPlayers;
if (_endFail) then { ["MissionFail", false] remoteExecCall ["BIS_fnc_endMission", playerSide]; };
} else {
{ deleteVehicle _x } forEach _targets;
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
private _rewards = createHashMap;
_rewards set ["funds", _companyFunds];
_rewards set ["reputation", _ratingSuccess];
if (_endSuccess) then {
["MissionSuccess", true] remoteExecCall ["BIS_fnc_endMission", playerSide];
};
if (count _equipmentRewards > 0) then { _rewards set ["equipment", _equipmentRewards]; };
if (count _supplyRewards > 0) then { _rewards set ["supplies", _supplyRewards]; };
if (count _weaponRewards > 0) then { _rewards set ["weapons", _weaponRewards]; };
if (count _vehicleRewards > 0) then { _rewards set ["vehicles", _vehicleRewards]; };
if (count _specialRewards > 0) then { _rewards set ["special", _specialRewards]; };
[_taskID, _rewards] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BIS_fnc_taskSetState;
// ["advance", _ratingSuccess] remoteExecCall ["forge_server_rating_fnc_handleRating", 2];
[_ratingSuccess] call EFUNC(org,addReputation);
[format ["Task completed: %1 reputation", _ratingSuccess], "success", 5, "right"] call EFUNC(misc,notify);
sleep 1;
sleep 1;
{ [_x, _ratingSuccess] remoteExec ["addRating", -2] } forEach allPlayers;
{ [_x, _ratingSuccess] remoteExec ["addRating", -2] } forEach allPlayers;
// ["advance", _companyFunds] remoteExecCall ["forge_server_money_fnc_handleFunds", 2];
[_companyFunds] call EFUNC(org,addFunds);
[format ["Task completed: %1 reputation", _ratingSuccess], "success", 5, "right"] call EFUNC(misc,notify);
[format ["Task completed: %1 funds", _companyFunds], "success", 5, "right"] call EFUNC(misc,notify);
if (_endSuccess) then { ["MissionSuccess", true] remoteExecCall ["BIS_fnc_endMission", playerSide]; };
};

View File

@ -16,17 +16,39 @@
* 8: Enemy wave count <NUMBER> (default: 3)
* 9: Time between waves in seconds <NUMBER> (default: 300)
* 10: Minimum BLUFOR units required in zone <NUMBER> (default: 1)
* 11: Equipment rewards <ARRAY> (default: [])
* 12: Supply rewards <ARRAY> (default: [])
* 13: Weapon rewards <ARRAY> (default: [])
* 14: Vehicle rewards <ARRAY> (default: [])
* 15: Special rewards <ARRAY> (default: [])
*
* Return Value:
* None
*
* Example:
* ["defend_zone_1", "defend_marker", 900, 500000, -100, 400, false, false, 3, 300, 1] spawn forge_client_task_fnc_defend;
* ["defend_zone_1", "defend_marker", 900, 500000, -100, 400, false, false, 3, 300, 1, ["ItemGPS"], ["FirstAidKit"], ["arifle_MX_F"], ["B_MRAP_01_F"], ["B_UAV_01_F"]] spawn forge_client_task_fnc_defend;
*
* Public: Yes
*/
params [["_taskID", "", [""]], ["_defenseZone", "", [""]], ["_defendTime", 600, [0]], ["_companyFunds", 0, [0]], ["_ratingFail", 0, [0]], ["_ratingSuccess", 0, [0]], ["_endSuccess", false, [false]], ["_endFail", false, [false]], ["_waveCount", 3, [0]], ["_waveCooldown", 300, [0]], ["_minBlufor", 1, [0]]];
params [
["_taskID", "", [""]],
["_defenseZone", "", [""]],
["_defendTime", 600, [0]],
["_companyFunds", 0, [0]],
["_ratingFail", 0, [0]],
["_ratingSuccess", 0, [0]],
["_endSuccess", false, [false]],
["_endFail", false, [false]],
["_waveCount", 3, [0]],
["_waveCooldown", 300, [0]],
["_minBlufor", 1, [0]],
["_equipmentRewards", [], [[]]],
["_supplyRewards", [], [[]]],
["_weaponRewards", [], [[]]],
["_vehicleRewards", [], [[]]],
["_specialRewards", [], [[]]]
];
if (_defenseZone == "" || !(markerShape _defenseZone in ["RECTANGLE", "ELLIPSE"])) exitWith { diag_log format ["ERROR: Invalid defense zone marker: %1", _defenseZone]; };
@ -39,12 +61,7 @@ private _warningIssued = false;
waitUntil {
sleep 1;
private _bluforInZone = count (allUnits select {
_x isKindOf "CAManBase" &&
{side _x == west} &&
{alive _x}
} inAreaArray _defenseZone);
private _bluforInZone = count (allUnits select { _x isKindOf "CAManBase" && { side _x == west } && { alive _x }} inAreaArray _defenseZone);
private _timeElapsed = time - _startTime;
if (_bluforInZone < _minBlufor) then {
@ -76,30 +93,37 @@ waitUntil {
if (_result == 1) then {
[_taskID, "FAILED"] call BFUNC(taskSetState);
if (_endFail) then {
["MissionFail", false] remoteExecCall ["BIS_fnc_endMission", playerSide];
};
private _penalties = createHashMap;
_penalties set ["reputation", _ratingFail];
// ["deduct", _ratingFail] remoteExecCall ["forge_server_rating_fnc_handleRating", 2];
[_ratingFail] call EFUNC(org,addReputation);
[_taskID, _penalties] call FUNC(handleTaskRewards);
sleep 1;
{ [_x, _ratingFail] remoteExec ["addRating", -2] } forEach allPlayers;
[format ["Task failed: %1 reputation", _ratingFail], "warning", 5, "right"] call EFUNC(misc,notify);
if (_endFail) then { ["MissionFail", false] remoteExecCall ["BIS_fnc_endMission", playerSide]; };
} else {
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
private _rewards = createHashMap;
_rewards set ["funds", _companyFunds];
_rewards set ["reputation", _ratingSuccess];
if (_endSuccess) then {
["MissionSuccess", false] remoteExecCall ["BIS_fnc_endMission", playerSide];
};
// ["advance", _ratingSuccess] remoteExecCall ["forge_server_rating_fnc_handleRating", 2];
[_ratingSuccess] call EFUNC(org,addReputation);
[format ["Task succeeded: %1 reputation", _ratingSuccess], "success", 5, "right"] call EFUNC(misc,notify);
if (count _equipmentRewards > 0) then { _rewards set ["equipment", _equipmentRewards]; };
if (count _supplyRewards > 0) then { _rewards set ["supplies", _supplyRewards]; };
if (count _weaponRewards > 0) then { _rewards set ["weapons", _weaponRewards]; };
if (count _vehicleRewards > 0) then { _rewards set ["vehicles", _vehicleRewards]; };
if (count _specialRewards > 0) then { _rewards set ["special", _specialRewards]; };
[_taskID, _rewards] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BIS_fnc_taskSetState;
sleep 1;
{ [_x, _ratingSuccess] remoteExec ["addRating", -2] } forEach allPlayers;
// ["advance", _companyFunds] remoteExecCall ["forge_server_money_fnc_handleFunds", 2];
[_companyFunds] call EFUNC(org,addFunds);
[format ["Task succeeded: %1 funds", _companyFunds], "success", 5, "right"] call EFUNC(misc,notify);
[format ["Task completed: %1 reputation", _ratingSuccess], "success", 5, "right"] call EFUNC(misc,notify);
[format ["Task completed: %1 funds", _companyFunds], "success", 5, "right"] call EFUNC(misc,notify);
if (_endSuccess) then { ["MissionSuccess", true] remoteExecCall ["BIS_fnc_endMission", playerSide]; };
};

View File

@ -13,6 +13,11 @@
* 5: Amount of rating the company and player recieve if the task is successful <NUMBER> (default: 0)
* 6: Should the mission end (MissionSuccess) if the task is successful <BOOL> (default: false)
* 7: Should the mission end (MissionFailed) if the task is failed <BOOL> (default: false)
* 8: Equipment rewards <ARRAY> (default: [])
* 9: Supply rewards <ARRAY> (default: [])
* 10: Weapon rewards <ARRAY> (default: [])
* 11: Vehicle rewards <ARRAY> (default: [])
* 12: Special rewards <ARRAY> (default: [])
*
* Return Value:
* None
@ -23,7 +28,21 @@
* Public: Yes
*/
params [["_taskID", ""], ["_limitFail", -1], ["_limitSuccess", -1], ["_companyFunds", 0], ["_ratingFail", 0], ["_ratingSuccess", 0], ["_endSuccess", false], ["_endFail", false]];
params [
["_taskID", "", [""]],
["_limitFail", -1, [0]],
["_limitSuccess", -1, [0]],
["_companyFunds", 0, [0]],
["_ratingFail", 0, [0]],
["_ratingSuccess", 0, [0]],
["_endSuccess", false, [false]],
["_endFail", false, [false]],
["_equipmentRewards", [], [[]]],
["_supplyRewards", [], [[]]],
["_weaponRewards", [], [[]]],
["_vehicleRewards", [], [[]]],
["_specialRewards", [], [[]]]
];
private _result = 0;
@ -58,38 +77,42 @@ if (_result == 1) then {
[_taskID, "FAILED"] call BFUNC(taskSetState);
if (_endFail) then {
["MissionFail", false] remoteExecCall ["BIS_fnc_endMission", playerSide];
};
private _penalties = createHashMap;
_penalties set ["reputation", _ratingFail];
// ["deduct", _ratingFail] remoteExecCall ["forge_server_rating_fnc_handleRating", 2];
[_ratingFail] call EFUNC(org,addReputation);
[format ["Task failed: %1 reputation", _ratingFail], "warning", 5, "right"] call EFUNC(misc,notify);
[_taskID, _penalties] call FUNC(handleTaskRewards);
sleep 1;
sleep 1;
{ [_x, _ratingFail] remoteExec ["addRating", -2] } forEach allPlayers;
[format ["Task failed: %1 reputation", _ratingFail], "warning", 5, "right"] call EFUNC(misc,notify);
{ [_x, _ratingFail] remoteExec ["addRating", -2] } forEach allPlayers;
if (_endFail) then { ["MissionFail", false] remoteExecCall ["BIS_fnc_endMission", playerSide]; };
} else {
{ deleteVehicle _x } forEach _ieds;
{ deleteVehicle _x } forEach _entities;
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
private _rewards = createHashMap;
_rewards set ["funds", _companyFunds];
_rewards set ["reputation", _ratingSuccess];
if (_endSuccess) then {
["MissionSuccess", true] remoteExecCall ["BIS_fnc_endMission", playerSide];
};
if (count _equipmentRewards > 0) then { _rewards set ["equipment", _equipmentRewards]; };
if (count _supplyRewards > 0) then { _rewards set ["supplies", _supplyRewards]; };
if (count _weaponRewards > 0) then { _rewards set ["weapons", _weaponRewards]; };
if (count _vehicleRewards > 0) then { _rewards set ["vehicles", _vehicleRewards]; };
if (count _specialRewards > 0) then { _rewards set ["special", _specialRewards]; };
[_taskID, _rewards] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BIS_fnc_taskSetState;
// ["advance", _ratingSuccess] remoteExecCall ["forge_server_rating_fnc_handleRating", 2];
[_ratingSuccess] call EFUNC(org,addReputation);
[format ["Task completed: %1 reputation", _ratingSuccess], "success", 5, "right"] call EFUNC(misc,notify);
sleep 1;
sleep 1;
{ [_x, _ratingSuccess] remoteExec ["addRating", -2] } forEach allPlayers;
{ [_x, _ratingSuccess] remoteExec ["addRating", -2] } forEach allPlayers;
// ["advance", _companyFunds] remoteExecCall ["forge_server_money_fnc_handleFunds", 2];
[_companyFunds] call EFUNC(org,addFunds);
[format ["Task completed: %1 reputation", _ratingSuccess], "success", 5, "right"] call EFUNC(misc,notify);
[format ["Task completed: %1 funds", _companyFunds], "success", 5, "right"] call EFUNC(misc,notify);
if (_endSuccess) then { ["MissionSuccess", true] remoteExecCall ["BIS_fnc_endMission", playerSide]; };
};
GVAR(defusedCount) = 0;

View File

@ -14,7 +14,12 @@
* 6: Amount of rating the company and player receive if the task is successful <NUMBER> (default: 0)
* 7: Should the mission end (MissionSuccess) if the task is successful <BOOL> (default: false)
* 8: Should the mission end (MissionFailed) if the task is failed <BOOL> (default: false)
* 9: Amount of time to complete delivery <NUMBER> (default: nil)
* 9: Amount of time to complete delivery <NUMBER> (default: -1)
* 10: Equipment rewards <ARRAY> (default: [])
* 11: Supply rewards <ARRAY> (default: [])
* 12: Weapon rewards <ARRAY> (default: [])
* 13: Vehicle rewards <ARRAY> (default: [])
* 14: Special rewards <ARRAY> (default: [])
*
* Return Value:
* None
@ -26,7 +31,23 @@
* Public: Yes
*/
params [["_taskID", "", [""]], ["_limitFail", -1, [0]], ["_limitSuccess", -1, [0]], ["_deliveryZone", "", [""]], ["_companyFunds", 0, [0]], ["_ratingFail", 0, [0]], ["_ratingSuccess", 0, [0]], ["_endSuccess", false, [false]], ["_endFail", false, [false]], ["_time", nil, [0]]];
params [
["_taskID", "", [""]],
["_limitFail", -1, [0]],
["_limitSuccess", -1, [0]],
["_deliveryZone", "", [""]],
["_companyFunds", 0, [0]],
["_ratingFail", 0, [0]],
["_ratingSuccess", 0, [0]],
["_endSuccess", false, [false]],
["_endFail", false, [false]],
["_time", -1, [0]],
["_equipmentRewards", [], [[]]],
["_supplyRewards", [], [[]]],
["_weaponRewards", [], [[]]],
["_vehicleRewards", [], [[]]],
["_specialRewards", [], [[]]]
];
private _result = 0;
@ -37,7 +58,7 @@ waitUntil {
};
private _cargo = GVAR(allCargo) select { (_x getVariable ["assignedTask", ""]) == _taskID };
private _startTime = if (!isNil "_time") then { floor(time) } else { nil };
private _startTime = if (_time isNotEqualTo -1) then { floor(time) } else { nil };
waitUntil {
sleep 1;
@ -45,7 +66,7 @@ waitUntil {
private _cargoDelivered = ({ _x inArea _deliveryZone && (damage _x) < 0.7 } count _cargo);
private _cargoDamaged = ({ damage _x >= 0.7 } count _cargo);
if (!isNil "_time") then {
if (_time isNotEqualTo -1) then {
private _timeExpired = (floor time - _startTime >= _time);
if (_cargoDamaged >= _limitFail) then { _result = 1; };
@ -62,37 +83,39 @@ waitUntil {
if (_result == 1) then {
{ deleteVehicle _x } forEach _cargo;
[_taskID, "FAILED"] call BFUNC(taskSetState);
private _penalties = createHashMap;
_penalties set ["reputation", _ratingFail];
if (_endFail) then {
["MissionFail", false] remoteExecCall ["BIS_fnc_endMission", playerSide];
};
// ["deduct", _ratingFail] remoteExecCall ["forge_server_rating_fnc_handleRating", 2];
[_ratingFail] call EFUNC(org,addReputation);
[format ["Task failed: %1 reputation", _ratingFail], "warning", 5, "right"] call EFUNC(misc,notify);
[_taskID, _penalties] call FUNC(handleTaskRewards);
sleep 1;
{ [_x, _ratingFail] remoteExec ["addRating", -2] } forEach allPlayers;
[format ["Task failed: %1 reputation", _ratingFail], "warning", 5, "right"] call EFUNC(misc,notify);
if (_endFail) then { ["MissionFail", false] remoteExecCall ["BIS_fnc_endMission", playerSide]; };
} else {
{ deleteVehicle _x } forEach _cargo;
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
private _rewards = createHashMap;
_rewards set ["funds", _companyFunds];
_rewards set ["reputation", _ratingSuccess];
if (_endSuccess) then {
["MissionSuccess", false] remoteExecCall ["BIS_fnc_endMission", playerSide];
};
// ["advance", _ratingSuccess] remoteExecCall ["forge_server_rating_fnc_handleRating", 2];
[_ratingSuccess] call EFUNC(org,addReputation);
[format ["Task succeeded: %1 reputation", _ratingSuccess], "success", 5, "right"] call EFUNC(misc,notify);
if (count _equipmentRewards > 0) then { _rewards set ["equipment", _equipmentRewards]; };
if (count _supplyRewards > 0) then { _rewards set ["supplies", _supplyRewards]; };
if (count _weaponRewards > 0) then { _rewards set ["weapons", _weaponRewards]; };
if (count _vehicleRewards > 0) then { _rewards set ["vehicles", _vehicleRewards]; };
if (count _specialRewards > 0) then { _rewards set ["special", _specialRewards]; };
[_taskID, _rewards] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BIS_fnc_taskSetState;
sleep 1;
{ [_x, _ratingSuccess] remoteExec ["addRating", -2] } forEach allPlayers;
// ["advance", _companyFunds] remoteExecCall ["forge_server_money_fnc_handleFunds", 2];
[_companyFunds] call EFUNC(org,addFunds);
[format ["Task succeeded: %1 funds", _companyFunds], "success", 5, "right"] call EFUNC(misc,notify);
[format ["Task completed: %1 reputation", _ratingSuccess], "success", 5, "right"] call EFUNC(misc,notify);
[format ["Task completed: %1 funds", _companyFunds], "success", 5, "right"] call EFUNC(misc,notify);
if (_endSuccess) then { ["MissionSuccess", true] remoteExecCall ["BIS_fnc_endMission", playerSide]; };
};

View File

@ -13,7 +13,12 @@
* 5: Amount of rating the company and player recieve if the task is successful <NUMBER> (default: 0)
* 6: Should the mission end (MissionSuccess) if the task is successful <BOOL> (default: false)
* 7: Should the mission end (MissionFailed) if the task is failed <BOOL> (default: false)
* 8: Amount of time before target(s) escape <NUMBER> (default: nil)
* 8: Amount of time before target(s) escape <NUMBER> (default: -1)
* 9: Equipment rewards <ARRAY> (default: [])
* 10: Supply rewards <ARRAY> (default: [])
* 11: Weapon rewards <ARRAY> (default: [])
* 12: Vehicle rewards <ARRAY> (default: [])
* 13: Special rewards <ARRAY> (default: [])
*
* Return Value:
* None
@ -25,7 +30,22 @@
* Public: Yes
*/
params [["_taskID", ""], ["_limitFail", -1], ["_limitSuccess", -1], ["_companyFunds", 0], ["_ratingFail", 0], ["_ratingSuccess", 0], ["_endSuccess", false], ["_endFail", false], "_time"];
params [
["_taskID", "", [""]],
["_limitFail", -1, [0]],
["_limitSuccess", -1, [0]],
["_companyFunds", 0, [0]],
["_ratingFail", 0, [0]],
["_ratingSuccess", 0, [0]],
["_endSuccess", false, [false]],
["_endFail", false, [false]],
["_time", -1, [0]],
["_equipmentRewards", [], [[]]],
["_supplyRewards", [], [[]]],
["_weaponRewards", [], [[]]],
["_vehicleRewards", [], [[]]],
["_specialRewards", [], [[]]]
];
private _result = 0;
@ -57,37 +77,39 @@ waitUntil {
if (_result == 1) then {
{ deleteVehicle _x } forEach _targets;
[_taskID, "FAILED"] call BFUNC(taskSetState);
private _penalties = createHashMap;
_penalties set ["reputation", _ratingFail];
if (_endFail) then {
["MissionFail", false] remoteExecCall ["BIS_fnc_endMission", playerSide];
};
[_taskID, _penalties] call FUNC(handleTaskRewards);
// ["deduct", _ratingFail] remoteExecCall ["forge_server_rating_fnc_handleRating", 2];
[_ratingFail] call EFUNC(org,addReputation);
[format ["Task failed: %1 reputation", _ratingFail], "warning", 5, "right"] call EFUNC(misc,notify);
sleep 1;
{ [_x, _ratingFail] remoteExec ["addRating", -2] } forEach allPlayers;
[format ["Task failed: %1 reputation", _ratingFail], "warning", 5, "right"] call EFUNC(misc,notify);
sleep 1;
{ [_x, _ratingFail] remoteExec ["addRating", -2] } forEach allPlayers;
if (_endFail) then { ["MissionFail", false] remoteExecCall ["BIS_fnc_endMission", playerSide]; };
} else {
{ deleteVehicle _x } forEach _targets;
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
private _rewards = createHashMap;
_rewards set ["funds", _companyFunds];
_rewards set ["reputation", _ratingSuccess];
if (_endSuccess) then {
["MissionSuccess", true] remoteExecCall ["BIS_fnc_endMission", playerSide];
};
if (count _equipmentRewards > 0) then { _rewards set ["equipment", _equipmentRewards]; };
if (count _supplyRewards > 0) then { _rewards set ["supplies", _supplyRewards]; };
if (count _weaponRewards > 0) then { _rewards set ["weapons", _weaponRewards]; };
if (count _vehicleRewards > 0) then { _rewards set ["vehicles", _vehicleRewards]; };
if (count _specialRewards > 0) then { _rewards set ["special", _specialRewards]; };
[_taskID, _rewards] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BIS_fnc_taskSetState;
// ["advance", _ratingSuccess] remoteExecCall ["forge_server_rating_fnc_handleRating", 2];
[_ratingSuccess] call EFUNC(org,addReputation);
[format ["Task completed: %1 reputation", _ratingSuccess], "success", 5, "right"] call EFUNC(misc,notify);
sleep 1;
sleep 1;
{ [_x, _ratingSuccess] remoteExec ["addRating", -2] } forEach allPlayers;
{ [_x, _ratingSuccess] remoteExec ["addRating", -2] } forEach allPlayers;
// ["advance", _companyFunds] remoteExecCall ["forge_server_money_fnc_handleFunds", 2];
[_companyFunds] call EFUNC(org,addFunds);
[format ["Task completed: %1 reputation", _ratingSuccess], "success", 5, "right"] call EFUNC(misc,notify);
[format ["Task completed: %1 funds", _companyFunds], "success", 5, "right"] call EFUNC(misc,notify);
if (_endSuccess) then { ["MissionSuccess", true] remoteExecCall ["BIS_fnc_endMission", playerSide]; };
};

View File

@ -0,0 +1,118 @@
#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Handles task completion rewards for organizations
*
* Arguments:
* 0: Task ID <STRING>
* 1: Reward Data <HASHMAP>
* - funds: Amount of money to award <NUMBER>
* - reputation: Amount of reputation to award <NUMBER>
* - equipment: Array of equipment classnames to award <ARRAY>
* - supplies: Array of supply classnames to award <ARRAY>
* - weapons: Array of weapon classnames to award <ARRAY>
* - vehicles: Array of vehicle classnames to award <ARRAY>
* - special: Array of special item classnames to award <ARRAY>
*
* Return Value:
* Success <BOOLEAN>
*
* Example:
* private _rewards = createHashMapFromArray [
* ["funds", 10000],
* ["reputation", 50],
* ["equipment", ["ItemGPS", "ItemCompass"]],
* ["supplies", ["FirstAidKit", "Medikit"]],
* ["weapons", ["arifle_MX_F"]],
* ["vehicles", ["B_MRAP_01_F"]],
* ["special", ["B_UAV_01_F"]]
* ];
* ["task_1", _rewards] call forge_client_task_fnc_handleTaskRewards;
*
* Public: No
*/
params [["_taskID", ""], ["_rewards", createHashMap]];
if (_taskID == "") exitWith {
diag_log "ERROR: No task ID provided for rewards";
false
};
private _store = call EFUNC(org,verifyOrgStore);
if (isNil "_store") exitWith {
["No organization found to receive rewards", "error", 5, "right"] call EFUNC(misc,notify);
false
};
private _success = true;
private _funds = _rewards getOrDefault ["funds", 0];
if (_funds > 0) then {
if !([_funds] call EFUNC(org,addFunds)) then {
diag_log format ["Failed to award funds %1 for task %2", _funds, _taskID];
_success = false;
};
};
private _reputation = _rewards getOrDefault ["reputation", 0];
if (_reputation > 0) then {
if !([_reputation] call EFUNC(org,addReputation)) then {
diag_log format ["Failed to award reputation %1 for task %2", _reputation, _taskID];
_success = false;
};
};
private _fnc_addAssets = {
params ["_type", "_items"];
{
private _properties = createHashMap;
_properties set ["source", format ["Task Reward: %1", _taskID]];
_properties set ["acquired", call EFUNC(misc,getSystemTime)];
if !([_type, _x, _properties] call EFUNC(org,addAsset)) then {
diag_log format ["Failed to award %1 asset %2 for task %3", _type, _x, _taskID];
_success = false;
};
} forEach _items;
};
private _equipment = _rewards getOrDefault ["equipment", []];
if (count _equipment > 0) then {
["equipment", _equipment] call _fnc_addAssets;
};
private _supplies = _rewards getOrDefault ["supplies", []];
if (count _supplies > 0) then {
["supply", _supplies] call _fnc_addAssets;
};
private _weapons = _rewards getOrDefault ["weapons", []];
if (count _weapons > 0) then {
["weapon", _weapons] call _fnc_addAssets;
};
private _vehicles = _rewards getOrDefault ["vehicles", []];
if (count _vehicles > 0) then {
["vehicle", _vehicles] call _fnc_addAssets;
};
private _special = _rewards getOrDefault ["special", []];
if (count _special > 0) then {
["special", _special] call _fnc_addAssets;
};
if (_success) then {
private _rewardText = "Task Rewards:";
if (_funds > 0) then { _rewardText = _rewardText + format ["\n- $%1", _funds call EFUNC(misc,formatNumber)]; };
if (_reputation > 0) then { _rewardText = _rewardText + format ["\n- %1 Reputation", _reputation]; };
if (count _equipment > 0) then { _rewardText = _rewardText + format ["\n- %1 Equipment Items", count _equipment]; };
if (count _supplies > 0) then { _rewardText = _rewardText + format ["\n- %1 Supply Items", count _supplies]; };
if (count _weapons > 0) then { _rewardText = _rewardText + format ["\n- %1 Weapons", count _weapons]; };
if (count _vehicles > 0) then { _rewardText = _rewardText + format ["\n- %1 Vehicles", count _vehicles]; };
if (count _special > 0) then { _rewardText = _rewardText + format ["\n- %1 Special Items", count _special]; };
[_rewardText, "success", 10, "right"] call EFUNC(misc,notify);
};
_success

View File

@ -15,8 +15,13 @@
* 7: Subcategory of task <ARRAY> (default: [false, true])
* 8: Should the mission end (MissionSuccess) if the task is successful <BOOL> (default: false)
* 9: Should the mission end (MissionFailed) if the task is failed <BOOL> (default: false)
* 10: Amount of time before hostage(s) die <NUMBER> (default: nil)
* 11: Marker name for the cbrn zone <STRING> (default: nil)
* 10: Amount of time before hostage(s) die <NUMBER> (default: -1)
* 11: Marker name for the cbrn zone <STRING> (default: "")
* 12: Equipment rewards <ARRAY> (default: [])
* 13: Supply rewards <ARRAY> (default: [])
* 14: Weapon rewards <ARRAY> (default: [])
* 15: Vehicle rewards <ARRAY> (default: [])
* 16: Special rewards <ARRAY> (default: [])
*
* Return Value:
* None
@ -29,7 +34,25 @@
* Public: Yes
*/
params [["_taskID", ""], ["_limitFail", -1], ["_limitSuccess", -1], ["_extZone", ""], ["_companyFunds", 0], ["_ratingFail", 0], ["_ratingSuccess", 0], ["_type", [["_cbrn", false], ["_hostage", true]]], ["_endSuccess", false], ["_endFail", false], "_time", ["_cbrnZone", ""]];
params [
["_taskID", ""],
["_limitFail", -1],
["_limitSuccess", -1],
["_extZone", ""],
["_companyFunds", 0],
["_ratingFail", 0],
["_ratingSuccess", 0],
["_type", [["_cbrn", false, [false]], ["_hostage", true, [false]]]],
["_endSuccess", false, [false]],
["_endFail", false, [false]],
["_time", -1, [0]],
["_cbrnZone", "", [""]]
["_equipmentRewards", [], [[]]],
["_supplyRewards", [], [[]]],
["_weaponRewards", [], [[]]],
["_vehicleRewards", [], [[]]],
["_specialRewards", [], [[]]]
];
private _cbrn = (_this select 7) select 0;
private _hostage = (_this select 7) select 1;
@ -49,7 +72,7 @@ waitUntil {
private _hostages = GVAR(allHostages) select { (_x getVariable ["assignedTask", ""]) == _taskID };
private _shooters = GVAR(allShooters) select { (_x getVariable ["assignedTask", ""]) == _taskID };
private _startTime = if (!isNil "_time") then { floor(time) } else { nil };
private _startTime = if (_time isNotEqualTo -1) then { floor(time) } else { nil };
waitUntil {
sleep 1;
@ -59,7 +82,7 @@ waitUntil {
private _hostagesKilled = ({ !alive _x } count _hostages);
private _shootersAlive = ({ alive _x } count _shooters);
if (!isNil "_time") then {
if (_time isNotEqualTo -1) then {
private _timeExpired = (floor time - _startTime >= _time);
if (_hostagesFreed < _limitSuccess && _timeExpired) then { _result = 1; };
@ -111,38 +134,40 @@ if (_result == 1) then {
{ deleteVehicle _x } forEach _hostages;
{ deleteVehicle _x } forEach _shooters;
[_taskID, "FAILED"] call BFUNC(taskSetState);
private _penalties = createHashMap;
_penalties set ["reputation", _ratingFail];
if (_endFail) then {
["MissionFail", false] remoteExecCall ["BIS_fnc_endMission", playerSide];
};
[_taskID, _penalties] call FUNC(handleTaskRewards);
// ["deduct", _ratingFail] remoteExecCall ["forge_server_rating_fnc_handleRating", 2];
[_ratingFail] call EFUNC(org,addReputation);
[format ["Task failed: %1 reputation", _ratingFail], "warning", 5, "right"] call EFUNC(misc,notify);
sleep 1;
{ [_x, _ratingFail] remoteExec ["addRating", -2] } forEach allPlayers;
[format ["Task failed: %1 reputation", _ratingFail], "warning", 5, "right"] call EFUNC(misc,notify);
sleep 1;
{ [_x, _ratingFail] remoteExec ["addRating", -2] } forEach allPlayers;
if (_endFail) then { ["MissionFail", false] remoteExecCall ["BIS_fnc_endMission", playerSide]; };
} else {
{ deleteVehicle _x } forEach _hostages;
{ deleteVehicle _x } forEach _shooters;
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
private _rewards = createHashMap;
_rewards set ["funds", _companyFunds];
_rewards set ["reputation", _ratingSuccess];
if (_endSuccess) then {
["MissionSuccess", true] remoteExecCall ["BIS_fnc_endMission", playerSide];
};
if (count _equipmentRewards > 0) then { _rewards set ["equipment", _equipmentRewards]; };
if (count _supplyRewards > 0) then { _rewards set ["supplies", _supplyRewards]; };
if (count _weaponRewards > 0) then { _rewards set ["weapons", _weaponRewards]; };
if (count _vehicleRewards > 0) then { _rewards set ["vehicles", _vehicleRewards]; };
if (count _specialRewards > 0) then { _rewards set ["special", _specialRewards]; };
[_taskID, _rewards] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BIS_fnc_taskSetState;
// ["advance", _ratingSuccess] remoteExecCall ["forge_server_rating_fnc_handleRating", 2];
[_ratingSuccess] call EFUNC(org,addReputation);
[format ["Task completed: %1 reputation", _ratingSuccess], "success", 5, "right"] call EFUNC(misc,notify);
sleep 1;
sleep 1;
{ [_x, _ratingSuccess] remoteExec ["addRating", -2] } forEach allPlayers;
{ [_x, _ratingSuccess] remoteExec ["addRating", -2] } forEach allPlayers;
// ["advance", _companyFunds] remoteExecCall ["forge_server_money_fnc_handleFunds", 2];
[_companyFunds] call EFUNC(org,addFunds);
[format ["Task completed: %1 reputation", _ratingSuccess], "success", 5, "right"] call EFUNC(misc,notify);
[format ["Task completed: %1 funds", _companyFunds], "success", 5, "right"] call EFUNC(misc,notify);
if (_endSuccess) then { ["MissionSuccess", true] remoteExecCall ["BIS_fnc_endMission", playerSide]; };
};

View File

@ -15,7 +15,12 @@
* 7: Subcategory of task <ARRAY> (default: [true, false])
* 8: Should the mission end (MissionSuccess) if the task is successful <BOOL> (default: false)
* 9: Should the mission end (MissionFailed) if the task is failed <BOOL> (default: false)
* 10: Amount of time before hvt(s) die <NUMBER> (default: nil)
* 10: Amount of time before hvt(s) die <NUMBER> (default: -1)
* 11: Equipment rewards <ARRAY> (default: [])
* 12: Supply rewards <ARRAY> (default: [])
* 13: Weapon rewards <ARRAY> (default: [])
* 14: Vehicle rewards <ARRAY> (default: [])
* 15: Special rewards <ARRAY> (default: [])
*
* Return Value:
* None
@ -29,7 +34,24 @@
* Public: Yes
*/
params [["_taskID", ""], ["_limitFail", -1], ["_limitSuccess", -1], ["_extZone", ""], ["_companyFunds", 0], ["_ratingFail", 0], ["_ratingSuccess", 0], ["_type", [["_capture", true], ["_eliminate", false]]], ["_endSuccess", false], ["_endFail", false], "_time"];
params [
["_taskID", "", [""]],
["_limitFail", -1, [0]],
["_limitSuccess", -1, [0]],
["_extZone", "", [""]],
["_companyFunds", 0, [0]],
["_ratingFail", 0, [0]],
["_ratingSuccess", 0, [0]],
["_type", [["_capture", true, [false]], ["_eliminate", false, [false]]]],
["_endSuccess", false, [false]],
["_endFail", false, [false]],
["_time", -1, [0]],
["_equipmentRewards", [], [[]]],
["_supplyRewards", [], [[]]],
["_weaponRewards", [], [[]]],
["_vehicleRewards", [], [[]]],
["_specialRewards", [], [[]]]
];
private _capture = (_this select 7) select 0;
private _eliminate = (_this select 7) select 1;
@ -69,37 +91,39 @@ waitUntil {
if (_result == 1) then {
{ deleteVehicle _x } forEach _hvts;
[_taskID, "FAILED"] call BFUNC(taskSetState);
private _penalties = createHashMap;
_penalties set ["reputation", _ratingFail];
if (_endFail) then {
["MissionFail", false] remoteExecCall ["BIS_fnc_endMission", playerSide];
};
[_taskID, _penalties] call FUNC(handleTaskRewards);
// ["deduct", _ratingFail] remoteExecCall ["forge_server_rating_fnc_handleRating", 2];
[_ratingFail] call EFUNC(org,addReputation);
[format ["Task failed: %1 reputation", _ratingFail], "warning", 5, "right"] call EFUNC(misc,notify);
sleep 1;
{ [_x, _ratingFail] remoteExec ["addRating", -2] } forEach allPlayers;
[format ["Task failed: %1 reputation", _ratingFail], "warning", 5, "right"] call EFUNC(misc,notify);
sleep 1;
{ [_x, _ratingFail] remoteExec ["addRating", -2] } forEach allPlayers;
if (_endFail) then { ["MissionFail", false] remoteExecCall ["BIS_fnc_endMission", playerSide]; };
} else {
{ deleteVehicle _x } forEach _hvts;
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
private _rewards = createHashMap;
_rewards set ["funds", _companyFunds];
_rewards set ["reputation", _ratingSuccess];
if (_endSuccess) then {
["MissionSuccess", true] remoteExecCall ["BIS_fnc_endMission", playerSide];
};
if (count _equipmentRewards > 0) then { _rewards set ["equipment", _equipmentRewards]; };
if (count _supplyRewards > 0) then { _rewards set ["supplies", _supplyRewards]; };
if (count _weaponRewards > 0) then { _rewards set ["weapons", _weaponRewards]; };
if (count _vehicleRewards > 0) then { _rewards set ["vehicles", _vehicleRewards]; };
if (count _specialRewards > 0) then { _rewards set ["special", _specialRewards]; };
[_taskID, _rewards] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BIS_fnc_taskSetState;
// ["advance", _ratingSuccess] remoteExecCall ["forge_server_rating_fnc_handleRating", 2];
[_ratingSuccess] call EFUNC(org,addReputation);
[format ["Task succeeded: %1 reputation", _ratingSuccess], "success", 5, "right"] call EFUNC(misc,notify);
sleep 1;
sleep 1;
{ [_x, _ratingSuccess] remoteExec ["addRating", -2] } forEach allPlayers;
{ [_x, _ratingSuccess] remoteExec ["addRating", -2] } forEach allPlayers;
// ["advance", _companyFunds] remoteExecCall ["forge_server_money_fnc_handleFunds", 2];
[_companyFunds] call EFUNC(org,addFunds);
[format ["Task succeeded: %1 funds", _companyFunds], "success", 5, "right"] call EFUNC(misc,notify);
[format ["Task completed: %1 reputation", _ratingSuccess], "success", 5, "right"] call EFUNC(misc,notify);
[format ["Task completed: %1 funds", _companyFunds], "success", 5, "right"] call EFUNC(misc,notify);
if (_endSuccess) then { ["MissionSuccess", true] remoteExecCall ["BIS_fnc_endMission", playerSide]; };
};