Compare commits

...

4 Commits

Author SHA1 Message Date
Jacob Schmidt
b1959ee06d Refactor event listener registration and update logging settings for task events 2026-05-15 20:22:42 -05:00
Jacob Schmidt
27c3c5e502 Route sync and notifications through event bus
- add EventBus-backed notification and sync requests with direct RPC fallback
- centralize org notification/sync dispatch and reuse notification helpers
- update economy, store, garage, locker, bank, and CAD flows to emit events
2026-05-15 20:17:19 -05:00
Jacob Schmidt
c6a0982450 Emit task and CAD state changes on the event bus
- Add task reward, notification, and rating events
- Emit CAD assignment, request, and group updates
- Route org and bank sync through event bus listeners
2026-05-15 19:57:19 -05:00
Jacob Schmidt
9deb73ec8e Migrate task logic to object classes
- Move task implementations from prototype scripts into `functions/objects`
- Keep public task functions as compatibility adapters
- Update docs and init wiring for the new object-based layout
2026-05-15 18:50:28 -05:00
61 changed files with 1560 additions and 1308 deletions

View File

@ -1,3 +1,21 @@
#include "script_component.hpp"
call FUNC(initBank);
if (isNil QEGVAR(common,EventBus)) then { call EFUNC(common,eventBus); };
if (isNil QGVAR(AccountSyncEventTokens)) then {
private _sendAccountSync = {
params ["_event"];
private _uid = _event getOrDefault ["uid", ""];
private _account = _event getOrDefault ["account", createHashMap];
private _responseEvent = _event getOrDefault ["responseEvent", CRPC(bank,responseSyncBank)];
if (_uid isEqualTo "" || { _account isEqualTo createHashMap }) exitWith {};
GVAR(BankMessenger) call ["sendAccountSync", [_uid, _account, _responseEvent]];
};
GVAR(AccountSyncEventTokens) = [
EGVAR(common,EventBus) call ["on", ["bank.account.sync.requested", _sendAccountSync, "bank.account.sync"]]
];
};

View File

@ -243,12 +243,24 @@ GVAR(BankBaseStore) = compileFinal createHashMapFromArray [
private _orgPatch = _orgResult getOrDefault ["patch", createHashMap];
if (_orgPatch isNotEqualTo createHashMap) then {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [_orgPatch], _memberPlayer] call CFUNC(targetEvent);
};
} forEach (_orgResult getOrDefault ["memberUids", []]);
private _memberUids = +(_orgResult getOrDefault ["memberUids", []]);
if (isNil QEGVAR(common,EventBus)) then {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [_orgPatch], _memberPlayer] call CFUNC(targetEvent);
};
} forEach _memberUids;
} else {
EGVAR(common,EventBus) call ["emit", [
"org.sync.requested",
createHashMapFromArray [
["memberUids", _memberUids],
["patch", +_orgPatch]
],
createHashMapFromArray [["source", "bank"]]
]];
};
};
if (_persistenceFailures isNotEqualTo []) then {

View File

@ -5,4 +5,4 @@ PREP(initGroupRepository);
PREP(initPermissionService);
PREP(initPersistenceService);
PREP(initRequestRepository);
PREP(registerTaskEventListeners);
PREP(registerEventListeners);

View File

@ -5,7 +5,7 @@ PREP_RECOMPILE_START;
PREP_RECOMPILE_END;
call FUNC(initCadStore);
call FUNC(registerTaskEventListeners);
call FUNC(registerEventListeners);
[QGVAR(requestHydrateCad), {
params [["_uid", "", [""]]];
@ -35,7 +35,7 @@ call FUNC(registerTaskEventListeners);
CRPC(cad,responseCadAssignment),
"assignTaskToGroup",
[_uid, _taskID, _groupID, _note],
true,
false,
false
]];
}] call CFUNC(addEventHandler);
@ -60,7 +60,7 @@ call FUNC(registerTaskEventListeners);
CRPC(cad,responseCadAssignment),
"createDispatchOrder",
[_uid, _assigneeGroupID, _targetGroupID, _note, _priority, _request],
true,
false,
false
]];
}] call CFUNC(addEventHandler);
@ -83,7 +83,7 @@ call FUNC(registerTaskEventListeners);
CRPC(cad,responseCadRequest),
"submitSupportRequest",
[_uid, _type, _fields, _priority],
true,
false,
false
]];
}] call CFUNC(addEventHandler);
@ -101,7 +101,7 @@ call FUNC(registerTaskEventListeners);
CRPC(cad,responseCadRequest),
"closeSupportRequest",
[_uid, _requestID],
true,
false,
false
]];
}] call CFUNC(addEventHandler);
@ -119,7 +119,7 @@ call FUNC(registerTaskEventListeners);
CRPC(cad,responseCadAssignment),
"acknowledgeTask",
[_uid, _taskID],
true,
false,
false
]];
}] call CFUNC(addEventHandler);
@ -137,7 +137,7 @@ call FUNC(registerTaskEventListeners);
CRPC(cad,responseCadAssignment),
"closeDispatchOrder",
[_uid, _taskID],
true,
false,
false
]];
}] call CFUNC(addEventHandler);
@ -155,7 +155,7 @@ call FUNC(registerTaskEventListeners);
CRPC(cad,responseCadAssignment),
"declineTask",
[_uid, _taskID],
true,
false,
false
]];
}] call CFUNC(addEventHandler);
@ -173,7 +173,7 @@ call FUNC(registerTaskEventListeners);
CRPC(cad,responseCadGroupUpdate),
"updateGroupStatus",
[_uid, _groupID, _status],
true,
false,
true
]];
}] call CFUNC(addEventHandler);
@ -191,7 +191,7 @@ call FUNC(registerTaskEventListeners);
CRPC(cad,responseCadGroupUpdate),
"updateGroupRole",
[_uid, _groupID, _role],
true,
false,
true
]];
}] call CFUNC(addEventHandler);
@ -214,7 +214,7 @@ call FUNC(registerTaskEventListeners);
CRPC(cad,responseCadGroupUpdate),
"updateGroupProfile",
[_uid, _groupID, _status, _role],
true,
false,
true
]];
}] call CFUNC(addEventHandler);

View File

@ -71,11 +71,24 @@ GVAR(CadStoreBaseClass) = compileFinal createHashMapFromArray [
];
if (_uid isEqualTo "" || { _message isEqualTo "" }) exitWith { false };
if (isNil QEGVAR(common,EventBus)) exitWith {
private _player = [_uid] call EFUNC(common,getPlayer);
if (_player isEqualTo objNull) exitWith { false };
private _player = [_uid] call EFUNC(common,getPlayer);
if (_player isEqualTo objNull) exitWith { false };
[CRPC(notifications,recieveNotification), [_type, _title, _message], _player] call CFUNC(targetEvent);
true
};
[CRPC(notifications,recieveNotification), [_type, _title, _message], _player] call CFUNC(targetEvent);
EGVAR(common,EventBus) call ["emit", [
"notification.requested",
createHashMapFromArray [
["uids", [_uid]],
["notificationType", _type],
["title", _title],
["message", _message]
],
createHashMapFromArray [["source", "cad"]]
]];
true
}],
["resolveRequestPlayer", compileFinal {
@ -130,6 +143,71 @@ GVAR(CadStoreBaseClass) = compileFinal createHashMapFromArray [
_self call ["sendRpcResult", [_player, _responseRpc, _result, _invalidateOnSuccess, _requireChanged]];
_result
}],
["emitAssignmentEvent", compileFinal {
params [["_eventName", "", [""]], ["_result", createHashMap, [createHashMap]]];
if (_eventName isEqualTo "" || { !(_result getOrDefault ["success", false]) }) exitWith { createHashMap };
if (isNil QEGVAR(common,EventBus)) exitWith { createHashMap };
private _assignment = +(_result getOrDefault ["assignment", createHashMap]);
private _payload = createHashMapFromArray [
["taskID", _assignment getOrDefault ["taskId", ""]],
["assignment", _assignment],
["leaderUid", _result getOrDefault ["leaderUid", ""]],
["isDispatchOrder", _result getOrDefault ["isDispatchOrder", false]],
["message", _result getOrDefault ["message", ""]]
];
if (_result getOrDefault ["isDispatchOrder", false]) then {
_payload set ["order", +(_result getOrDefault ["order", createHashMap])];
};
EGVAR(common,EventBus) call ["emit", [
_eventName,
_payload,
createHashMapFromArray [["source", "cad"]]
]]
}],
["emitRequestEvent", compileFinal {
params [["_eventName", "", [""]], ["_result", createHashMap, [createHashMap]]];
if (_eventName isEqualTo "" || { !(_result getOrDefault ["success", false]) }) exitWith { createHashMap };
if (isNil QEGVAR(common,EventBus)) exitWith { createHashMap };
private _request = +(_result getOrDefault ["request", createHashMap]);
EGVAR(common,EventBus) call ["emit", [
_eventName,
createHashMapFromArray [
["requestID", _request getOrDefault ["requestId", ""]],
["groupID", _request getOrDefault ["groupId", ""]],
["request", _request],
["message", _result getOrDefault ["message", ""]]
],
createHashMapFromArray [["source", "cad"]]
]]
}],
["emitGroupEvent", compileFinal {
params [["_eventName", "", [""]], ["_result", createHashMap, [createHashMap]]];
if (
_eventName isEqualTo ""
|| { !(_result getOrDefault ["success", false]) }
|| { !(_result getOrDefault ["changed", true]) }
) exitWith { createHashMap };
if (isNil QEGVAR(common,EventBus)) exitWith { createHashMap };
private _group = +(_result getOrDefault ["group", createHashMap]);
EGVAR(common,EventBus) call ["emit", [
_eventName,
createHashMapFromArray [
["groupID", _group getOrDefault ["groupId", ""]],
["group", _group],
["message", _result getOrDefault ["message", ""]],
["changed", _result getOrDefault ["changed", true]]
],
createHashMapFromArray [["source", "cad"]]
]]
}],
["notifyAssignmentLeader", compileFinal {
params [["_result", createHashMap, [createHashMap]]];
@ -165,6 +243,7 @@ GVAR(CadStoreBaseClass) = compileFinal createHashMapFromArray [
if !(_result getOrDefault ["success", false]) exitWith { _result };
_self call ["notifyAssignmentLeader", [_result]];
_self call ["emitAssignmentEvent", ["cad.assignment.assigned", _result]];
_result
}],
["createDispatchOrder", compileFinal {
@ -172,31 +251,48 @@ GVAR(CadStoreBaseClass) = compileFinal createHashMapFromArray [
if !(_result getOrDefault ["success", false]) exitWith { _result };
_self call ["notifyAssignmentLeader", [_result]];
_self call ["emitAssignmentEvent", ["cad.assignment.created", _result]];
_result
}],
["closeDispatchOrder", compileFinal {
(_self get "AssignmentRepository") call ["closeDispatchOrder", _this]
private _result = (_self get "AssignmentRepository") call ["closeDispatchOrder", _this];
_self call ["emitAssignmentEvent", ["cad.assignment.closed", _result]];
_result
}],
["submitSupportRequest", compileFinal {
(_self get "RequestRepository") call ["submitRequest", _this]
private _result = (_self get "RequestRepository") call ["submitRequest", _this];
_self call ["emitRequestEvent", ["cad.request.submitted", _result]];
_result
}],
["closeSupportRequest", compileFinal {
(_self get "RequestRepository") call ["closeRequest", _this]
private _result = (_self get "RequestRepository") call ["closeRequest", _this];
_self call ["emitRequestEvent", ["cad.request.closed", _result]];
_result
}],
["acknowledgeTask", compileFinal {
(_self get "AssignmentRepository") call ["acknowledgeTask", _this]
private _result = (_self get "AssignmentRepository") call ["acknowledgeTask", _this];
_self call ["emitAssignmentEvent", ["cad.assignment.acknowledged", _result]];
_result
}],
["declineTask", compileFinal {
(_self get "AssignmentRepository") call ["declineTask", _this]
private _result = (_self get "AssignmentRepository") call ["declineTask", _this];
_self call ["emitAssignmentEvent", ["cad.assignment.declined", _result]];
_result
}],
["updateGroupStatus", compileFinal {
(_self get "GroupRepository") call ["updateGroupStatus", _this]
private _result = (_self get "GroupRepository") call ["updateGroupStatus", _this];
_self call ["emitGroupEvent", ["cad.group.updated", _result]];
_result
}],
["updateGroupRole", compileFinal {
(_self get "GroupRepository") call ["updateGroupRole", _this]
private _result = (_self get "GroupRepository") call ["updateGroupRole", _this];
_self call ["emitGroupEvent", ["cad.group.updated", _result]];
_result
}],
["updateGroupProfile", compileFinal {
(_self get "GroupRepository") call ["updateGroupProfile", _this]
private _result = (_self get "GroupRepository") call ["updateGroupProfile", _this];
_self call ["emitGroupEvent", ["cad.group.updated", _result]];
_result
}],
["buildHydratePayload", compileFinal {
params [["_uid", "", [""]]];

View File

@ -0,0 +1,98 @@
#include "..\script_component.hpp"
/*
* File: fnc_registerEventListeners.sqf
* Author: IDSolutions
* Date: 2026-05-14
* Public: No
*
* Description:
* Registers CAD listeners for framework events that should refresh CAD state.
*
* Arguments:
* None
*
* Return Value:
* Listener tokens [ARRAY]
*
* Example:
* call forge_server_cad_fnc_registerEventListeners
*/
if (isNil QEGVAR(common,EventBus)) then { call EFUNC(common,eventBus); };
if !(isNil QGVAR(TaskEventListenerTokens)) exitWith { GVAR(TaskEventListenerTokens) };
private _invalidateCadState = {
params ["_event"];
["INFO", format [
"CAD task event received: %1 taskID=%2 taskType=%3 status=%4",
_event getOrDefault ["event", ""],
_event getOrDefault ["taskID", ""],
_event getOrDefault ["taskType", ""],
_event getOrDefault ["status", ""]
]] call EFUNC(common,log);
[CRPC(cad,invalidateCadState), []] call CFUNC(globalEvent);
};
private _invalidateCadAssignmentState = {
params ["_event"];
private _assignment = _event getOrDefault ["assignment", createHashMap];
["INFO", format [
"CAD assignment event received: %1 taskID=%2 groupID=%3 state=%4",
_event getOrDefault ["event", ""],
_event getOrDefault ["taskID", ""],
_assignment getOrDefault ["groupId", ""],
_assignment getOrDefault ["state", ""]
]] call EFUNC(common,log);
[CRPC(cad,invalidateCadState), []] call CFUNC(globalEvent);
};
private _invalidateCadRequestState = {
params ["_event"];
["INFO", format [
"CAD request event received: %1 requestID=%2 groupID=%3",
_event getOrDefault ["event", ""],
_event getOrDefault ["requestID", ""],
_event getOrDefault ["groupID", ""]
]] call EFUNC(common,log);
[CRPC(cad,invalidateCadState), []] call CFUNC(globalEvent);
};
private _invalidateCadGroupState = {
params ["_event"];
private _group = _event getOrDefault ["group", createHashMap];
["INFO", format [
"CAD group event received: %1 groupID=%2 status=%3 role=%4",
_event getOrDefault ["event", ""],
_event getOrDefault ["groupID", ""],
_group getOrDefault ["status", ""],
_group getOrDefault ["role", ""]
]] call EFUNC(common,log);
[CRPC(cad,invalidateCadState), []] call CFUNC(globalEvent);
};
GVAR(TaskEventListenerTokens) = [
EGVAR(common,EventBus) call ["on", ["task.created", _invalidateCadState, "cad.task.invalidate"]],
EGVAR(common,EventBus) call ["on", ["task.started", _invalidateCadState, "cad.task.invalidate"]],
EGVAR(common,EventBus) call ["on", ["task.completed", _invalidateCadState, "cad.task.invalidate"]],
EGVAR(common,EventBus) call ["on", ["task.failed", _invalidateCadState, "cad.task.invalidate"]],
EGVAR(common,EventBus) call ["on", ["task.cleared", _invalidateCadState, "cad.task.invalidate"]],
EGVAR(common,EventBus) call ["on", ["cad.assignment.assigned", _invalidateCadAssignmentState, "cad.assignment.invalidate"]],
EGVAR(common,EventBus) call ["on", ["cad.assignment.created", _invalidateCadAssignmentState, "cad.assignment.invalidate"]],
EGVAR(common,EventBus) call ["on", ["cad.assignment.acknowledged", _invalidateCadAssignmentState, "cad.assignment.invalidate"]],
EGVAR(common,EventBus) call ["on", ["cad.assignment.declined", _invalidateCadAssignmentState, "cad.assignment.invalidate"]],
EGVAR(common,EventBus) call ["on", ["cad.assignment.closed", _invalidateCadAssignmentState, "cad.assignment.invalidate"]],
EGVAR(common,EventBus) call ["on", ["cad.request.submitted", _invalidateCadRequestState, "cad.request.invalidate"]],
EGVAR(common,EventBus) call ["on", ["cad.request.closed", _invalidateCadRequestState, "cad.request.invalidate"]],
EGVAR(common,EventBus) call ["on", ["cad.group.updated", _invalidateCadGroupState, "cad.group.invalidate"]]
];
GVAR(TaskEventListenerTokens)

View File

@ -1,47 +0,0 @@
#include "..\script_component.hpp"
/*
* File: fnc_registerTaskEventListeners.sqf
* Author: IDSolutions
* Date: 2026-05-14
* Public: No
*
* Description:
* Registers CAD listeners for framework task lifecycle events.
*
* Arguments:
* None
*
* Return Value:
* Listener tokens [ARRAY]
*
* Example:
* call forge_server_cad_fnc_registerTaskEventListeners
*/
if (isNil QEGVAR(common,EventBus)) then { call EFUNC(common,eventBus); };
if !(isNil QGVAR(TaskEventListenerTokens)) exitWith { GVAR(TaskEventListenerTokens) };
private _invalidateCadState = {
params ["_event"];
["INFO", format [
"CAD task event received: %1 taskID=%2 taskType=%3 status=%4",
_event getOrDefault ["event", ""],
_event getOrDefault ["taskID", ""],
_event getOrDefault ["taskType", ""],
_event getOrDefault ["status", ""]
]] call EFUNC(common,log);
[CRPC(cad,invalidateCadState), []] call CFUNC(globalEvent);
};
GVAR(TaskEventListenerTokens) = [
EGVAR(common,EventBus) call ["on", ["task.created", _invalidateCadState, "cad.task.invalidate"]],
EGVAR(common,EventBus) call ["on", ["task.started", _invalidateCadState, "cad.task.invalidate"]],
EGVAR(common,EventBus) call ["on", ["task.completed", _invalidateCadState, "cad.task.invalidate"]],
EGVAR(common,EventBus) call ["on", ["task.failed", _invalidateCadState, "cad.task.invalidate"]],
EGVAR(common,EventBus) call ["on", ["task.cleared", _invalidateCadState, "cad.task.invalidate"]]
];
GVAR(TaskEventListenerTokens)

View File

@ -29,6 +29,55 @@ The event bus is initialized as `forge_server_common_EventBus` during store
bootstrap. It is synchronous and in-process: listeners run immediately when an
event is emitted.
### Event Naming
Use lower-case dot-separated names:
- `<domain>.<entity>.<action>` for domain events, such as `cad.assignment.assigned`
- `<domain>.<action>` for simple lifecycle events, such as `task.started`
Prefer past-tense action names for events that report completed state changes:
`created`, `started`, `assigned`, `acknowledged`, `declined`, `completed`,
`failed`, `cleared`, `updated`, `closed`.
Payloads should be hash maps and should include stable identifiers first:
`taskID`, `requestID`, `groupID`, `uid`, `orgID`, or `accountID` as appropriate.
The event bus adds `event`, `source`, and `timestamp` when the event is emitted.
### Current Events
Task lifecycle:
- `task.created`
- `task.started`
- `task.completed`
- `task.failed`
- `task.cleared`
Task rewards and notifications:
- `task.reward.requested`
- `task.reward.applied`
- `task.reward.failed`
- `task.rating.applied`
- `task.rating.failed`
- `task.notification.requested`
- `task.reward.notification.requested`
CAD state:
- `cad.assignment.assigned`
- `cad.assignment.created`
- `cad.assignment.acknowledged`
- `cad.assignment.declined`
- `cad.assignment.closed`
- `cad.request.submitted`
- `cad.request.closed`
- `cad.group.updated`
Client sync and notification requests:
- `notification.requested`
- `bank.account.sync.requested`
- `org.sync.requested`
- `locker.sync.requested`
- `locker.va.sync.requested`
- `garage.vgarage.sync.requested`
```sqf
private _token = EGVAR(common,EventBus) call ["on", [
"task.completed",

View File

@ -5,3 +5,33 @@ PREP_RECOMPILE_START;
PREP_RECOMPILE_END;
// private _category = [QUOTE(MOD_NAME), LLSTRING(displayName)];
if (isNil QGVAR(EventBus)) then { call FUNC(eventBus); };
if (isNil QGVAR(NotificationEventTokens)) then {
private _sendNotification = {
params ["_event"];
private _uids = +(_event getOrDefault ["uids", []]);
private _type = _event getOrDefault ["notificationType", "info"];
private _title = _event getOrDefault ["title", ""];
private _message = _event getOrDefault ["message", ""];
private _duration = _event getOrDefault ["duration", -1];
if (_message isEqualTo "" || { _uids isEqualTo [] }) exitWith {};
private _params = [_type, _title, _message];
if (_duration >= 0) then {
_params pushBack _duration;
};
{
private _player = [_x] call FUNC(getPlayer);
if (isNull _player) then { continue; };
[CRPC(notifications,recieveNotification), _params, _player] call CFUNC(targetEvent);
} forEach _uids;
};
GVAR(NotificationEventTokens) = [
GVAR(EventBus) call ["on", ["notification.requested", _sendNotification, "common.notification.send"]]
];
};

View File

@ -4,7 +4,7 @@
* File: fnc_initFEconomyStore.sqf
* Author: IDSolutions
* Date: 2025-12-20
* Last Update: 2026-04-18
* Last Update: 2026-05-15
* Public: No
*
* Description:
@ -54,6 +54,30 @@ GVAR(FEconomyStore) = createHashMapObject [[
SETVAR(_target,liters,0);
true
}],
["notify", {
params [["_unit", objNull, [objNull]], ["_type", "info", [""]], ["_title", "Refueling", [""]], ["_message", "", [""]]];
if (isNull _unit || { _message isEqualTo "" }) exitWith { false };
private _uid = getPlayerUID _unit;
if (_uid isEqualTo "") exitWith { false };
if (isNil QEGVAR(common,EventBus)) then {
[CRPC(notifications,recieveNotification), [_type, _title, _message], _unit] call CFUNC(targetEvent);
} else {
EGVAR(common,EventBus) call ["emit", [
"notification.requested",
createHashMapFromArray [
["uids", [_uid]],
["notificationType", _type],
["title", _title],
["message", _message]
],
createHashMapFromArray [["source", "economy"]]
]];
};
true
}],
["refuel", {
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]]];
@ -62,13 +86,13 @@ GVAR(FEconomyStore) = createHashMapObject [[
private _currentFuel = fuel _target;
private _missingFuel = (1 - _currentFuel) max 0 min 1;
if (_missingFuel <= 0.001) exitWith {
[CRPC(notifications,recieveNotification), ["info", "Refueling", "Vehicle fuel tank is already full."], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "info", "Refueling", "Vehicle fuel tank is already full."]];
false
};
if (isNil QGVAR(SEconomyStore)) exitWith {
["ERROR", "Service economy store unavailable for garage refueling charge.", nil, nil] call EFUNC(common,log);
[CRPC(notifications,recieveNotification), ["danger", "Refueling", "Organization billing is unavailable. Refueling was not completed."], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "danger", "Refueling", "Organization billing is unavailable. Refueling was not completed."]];
false
};
@ -79,7 +103,7 @@ GVAR(FEconomyStore) = createHashMapObject [[
private _totalCost = _totalLiters * GVAR(FuelCost);
private _chargeResult = GVAR(SEconomyStore) call ["chargeOrg", [_unit, _totalCost, "Refueling"]];
if !(_chargeResult getOrDefault ["success", false]) exitWith {
[CRPC(notifications,recieveNotification), ["danger", "Refueling", _chargeResult getOrDefault ["message", "Organization funds cannot cover this refuel. Refueling was not completed."]], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "danger", "Refueling", _chargeResult getOrDefault ["message", "Organization funds cannot cover this refuel. Refueling was not completed."]]];
false
};
@ -88,7 +112,7 @@ GVAR(FEconomyStore) = createHashMapObject [[
private _formattedTotalCost = [_totalCost] call EFUNC(common,formatNumber);
private _formattedTotalLiters = _totalLiters toFixed 2;
[CRPC(notifications,recieveNotification), ["info", "Refueling", format ["Refueling complete: %1L<br />Organization charged $%2.", _formattedTotalLiters, _formattedTotalCost]], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "info", "Refueling", format ["Refueling complete: %1L<br />Organization charged $%2.", _formattedTotalLiters, _formattedTotalCost]]];
true
}],
["stop", {
@ -117,25 +141,25 @@ GVAR(FEconomyStore) = createHashMapObject [[
};
if (_totalCost <= 0) exitWith {
[CRPC(notifications,recieveNotification), ["info", "Refueling", format ["Refueling complete: %1L", _formattedTotalLiters]], _player] call CFUNC(targetEvent);
_self call ["notify", [_player, "info", "Refueling", format ["Refueling complete: %1L", _formattedTotalLiters]]];
_fuelRegistry deleteAt _index;
};
if (isNil QGVAR(SEconomyStore)) exitWith {
["ERROR", "Service economy store unavailable for refueling charge.", nil, nil] call EFUNC(common,log);
[CRPC(notifications,recieveNotification), ["danger", "Refueling", "Organization billing is unavailable. Refueling was not completed."], _player] call CFUNC(targetEvent);
_self call ["notify", [_player, "danger", "Refueling", "Organization billing is unavailable. Refueling was not completed."]];
_self call ["rollbackFuel", [_target, _initialFuel]];
_fuelRegistry deleteAt _index;
};
private _chargeResult = GVAR(SEconomyStore) call ["chargeOrg", [_player, _totalCost, "Refueling"]];
if !(_chargeResult getOrDefault ["success", false]) exitWith {
[CRPC(notifications,recieveNotification), ["danger", "Refueling", _chargeResult getOrDefault ["message", "Organization funds cannot cover this refuel. Refueling was not completed."]], _player] call CFUNC(targetEvent);
_self call ["notify", [_player, "danger", "Refueling", _chargeResult getOrDefault ["message", "Organization funds cannot cover this refuel. Refueling was not completed."]]];
_self call ["rollbackFuel", [_target, _initialFuel]];
_fuelRegistry deleteAt _index;
};
[CRPC(notifications,recieveNotification), ["info", "Refueling", format ["Refueling complete: %1L<br />Organization charged $%2.", _formattedTotalLiters, _formattedTotalCost]], _player] call CFUNC(targetEvent);
_self call ["notify", [_player, "info", "Refueling", format ["Refueling complete: %1L<br />Organization charged $%2.", _formattedTotalLiters, _formattedTotalCost]]];
_fuelRegistry deleteAt _index;
}]
]];

View File

@ -4,7 +4,7 @@
* File: fnc_initMEconomyStore.sqf
* Author: IDSolutions
* Date: 2025-12-20
* Last Update: 2026-04-18
* Last Update: 2026-05-15
* Public: No
*
* Description:
@ -66,6 +66,30 @@ GVAR(MEconomyStore) = createHashMapObject [[
} forEach _mSpawns;
};
}],
["notify", {
params [["_unit", objNull, [objNull]], ["_type", "info", [""]], ["_title", "Medical Billing", [""]], ["_message", "", [""]]];
if (isNull _unit || { _message isEqualTo "" }) exitWith { false };
private _uid = getPlayerUID _unit;
if (_uid isEqualTo "") exitWith { false };
if (isNil QEGVAR(common,EventBus)) then {
[CRPC(notifications,recieveNotification), [_type, _title, _message], _unit] call CFUNC(targetEvent);
} else {
EGVAR(common,EventBus) call ["emit", [
"notification.requested",
createHashMapFromArray [
["uids", [_uid]],
["notificationType", _type],
["title", _title],
["message", _message]
],
createHashMapFromArray [["source", "economy"]]
]];
};
true
}],
["chargePlayer", {
params [["_uid", "", [""]], ["_amount", 0, [0]]];
@ -118,7 +142,18 @@ GVAR(MEconomyStore) = createHashMapObject [[
private _patch = _charge getOrDefault ["patch", createHashMap];
if (_patch isNotEqualTo createHashMap && { !(isNil QEGVAR(bank,BankMessenger)) }) then {
EGVAR(bank,BankMessenger) call ["sendAccountSync", [_uid, _patch]];
if (isNil QEGVAR(common,EventBus)) then {
EGVAR(bank,BankMessenger) call ["sendAccountSync", [_uid, _patch]];
} else {
EGVAR(common,EventBus) call ["emit", [
"bank.account.sync.requested",
createHashMapFromArray [
["uid", _uid],
["account", +_patch]
],
createHashMapFromArray [["source", "economy"]]
]];
};
};
private _savedAccount = EGVAR(bank,BankStore) call ["save", [_uid]];
@ -144,27 +179,27 @@ GVAR(MEconomyStore) = createHashMapObject [[
private _personalCharge = _self call ["chargePlayer", [_uid, _healCost]];
if (_personalCharge getOrDefault ["success", false]) exitWith {
private _sourceLabel = ["cash", "bank"] select ((_personalCharge getOrDefault ["source", "bank"]) isEqualTo "bank");
[CRPC(notifications,recieveNotification), ["info", "Medical Billing", format ["Medical service charged $%1 from your %2.", [_healCost] call EFUNC(common,formatNumber), _sourceLabel]], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "info", "Medical Billing", format ["Medical service charged $%1 from your %2.", [_healCost] call EFUNC(common,formatNumber), _sourceLabel]]];
[CRPC(actor,onActorHealed), [], _unit] call CFUNC(targetEvent);
};
if !(_personalCharge getOrDefault ["fallbackEligible", false]) exitWith {
private _message = _personalCharge getOrDefault ["message", "Personal funds could not be charged for medical service."];
[CRPC(notifications,recieveNotification), ["danger", "Medical Billing", _message], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "danger", "Medical Billing", _message]];
};
if (isNil QGVAR(SEconomyStore)) exitWith {
["ERROR", "Service economy store unavailable for medical organization fallback charge.", nil, nil] call EFUNC(common,log);
[CRPC(notifications,recieveNotification), ["danger", "Medical Billing", "Organization billing is unavailable. Medical service cannot complete."], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "danger", "Medical Billing", "Organization billing is unavailable. Medical service cannot complete."]];
};
private _chargeResult = GVAR(SEconomyStore) call ["chargeOrg", [_unit, _healCost, "Medical", true]];
if !(_chargeResult getOrDefault ["success", false]) exitWith {
private _message = _chargeResult getOrDefault ["message", "Organization funds cannot cover this medical service."];
[CRPC(notifications,recieveNotification), ["danger", "Medical Billing", _message], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "danger", "Medical Billing", _message]];
};
[CRPC(notifications,recieveNotification), ["info", "Medical Billing", format ["Personal funds could not cover medical service. Organization charged $%1; repay it through your organization credit line.", [_healCost] call EFUNC(common,formatNumber)]], _unit] call CFUNC(targetEvent);
_self call ["notify", [_unit, "info", "Medical Billing", format ["Personal funds could not cover medical service. Organization charged $%1; repay it through your organization credit line.", [_healCost] call EFUNC(common,formatNumber)]]];
[CRPC(actor,onActorHealed), [], _unit] call CFUNC(targetEvent);
}],
["onRespawn", {

View File

@ -4,7 +4,7 @@
* File: fnc_initSEconomyStore.sqf
* Author: IDSolutions
* Date: 2025-12-20
* Last Update: 2026-04-18
* Last Update: 2026-05-15
* Public: No
*
* Description:
@ -34,7 +34,22 @@ GVAR(SEconomyStore) = createHashMapObject [[
if (isNull _unit || { _message isEqualTo "" }) exitWith { false };
[CRPC(notifications,recieveNotification), [_type, _title, _message], _unit] call CFUNC(targetEvent);
private _uid = getPlayerUID _unit;
if (_uid isEqualTo "") exitWith { false };
if (isNil QEGVAR(common,EventBus)) then {
[CRPC(notifications,recieveNotification), [_type, _title, _message], _unit] call CFUNC(targetEvent);
} else {
EGVAR(common,EventBus) call ["emit", [
"notification.requested",
createHashMapFromArray [
["uids", [_uid]],
["notificationType", _type],
["title", _title],
["message", _message]
],
createHashMapFromArray [["source", "economy"]]
]];
};
true
}],
["syncOrgPatch", {
@ -43,12 +58,24 @@ GVAR(SEconomyStore) = createHashMapObject [[
private _patch = _result getOrDefault ["patch", createHashMap];
if ((keys _patch) isEqualTo []) exitWith { false };
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [_patch], _memberPlayer] call CFUNC(targetEvent);
};
} forEach (_result getOrDefault ["memberUids", []]);
private _memberUids = +(_result getOrDefault ["memberUids", []]);
if (isNil QEGVAR(common,EventBus)) then {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [_patch], _memberPlayer] call CFUNC(targetEvent);
};
} forEach _memberUids;
} else {
EGVAR(common,EventBus) call ["emit", [
"org.sync.requested",
createHashMapFromArray [
["memberUids", _memberUids],
["patch", +_patch]
],
createHashMapFromArray [["source", "economy"]]
]];
};
true
}],

View File

@ -1,3 +1,24 @@
#include "script_component.hpp"
call FUNC(initGarage);
if (isNil QEGVAR(common,EventBus)) then { call EFUNC(common,eventBus); };
if (isNil QGVAR(SyncEventTokens)) then {
private _sendVGarageSync = {
params ["_event"];
private _uid = _event getOrDefault ["uid", ""];
private _patch = _event getOrDefault ["patch", createHashMap];
if (_uid isEqualTo "" || { _patch isEqualTo createHashMap }) exitWith {};
private _player = [_uid] call EFUNC(common,getPlayer);
if (isNull _player) exitWith {};
[CRPC(garage,responseSyncVG), [_patch], _player] call CFUNC(targetEvent);
};
GVAR(SyncEventTokens) = [
EGVAR(common,EventBus) call ["on", ["garage.vgarage.sync.requested", _sendVGarageSync, "garage.vgarage.sync"]]
];
};

View File

@ -1,3 +1,39 @@
#include "script_component.hpp"
call FUNC(initLocker);
if (isNil QEGVAR(common,EventBus)) then { call EFUNC(common,eventBus); };
if (isNil QGVAR(SyncEventTokens)) then {
private _sendLockerSync = {
params ["_event"];
private _uid = _event getOrDefault ["uid", ""];
private _patch = _event getOrDefault ["patch", createHashMap];
if (_uid isEqualTo "" || { _patch isEqualTo createHashMap }) exitWith {};
private _player = [_uid] call EFUNC(common,getPlayer);
if (isNull _player) exitWith {};
[CRPC(locker,responseSyncLocker), [_patch], _player] call CFUNC(targetEvent);
};
private _sendVASync = {
params ["_event"];
private _uid = _event getOrDefault ["uid", ""];
private _patch = _event getOrDefault ["patch", createHashMap];
if (_uid isEqualTo "" || { _patch isEqualTo createHashMap }) exitWith {};
private _player = [_uid] call EFUNC(common,getPlayer);
if (isNull _player) exitWith {};
[CRPC(locker,responseSyncVA), [_patch], _player] call CFUNC(targetEvent);
};
GVAR(SyncEventTokens) = [
EGVAR(common,EventBus) call ["on", ["locker.sync.requested", _sendLockerSync, "locker.sync"]],
EGVAR(common,EventBus) call ["on", ["locker.va.sync.requested", _sendVASync, "locker.va.sync"]]
];
};

View File

@ -1 +1,23 @@
#include "script_component.hpp"
if (isNil QEGVAR(common,EventBus)) then { call EFUNC(common,eventBus); };
if (isNil QGVAR(SyncEventTokens)) then {
private _sendOrgSync = {
params ["_event"];
private _patch = _event getOrDefault ["patch", createHashMap];
private _memberUids = +(_event getOrDefault ["memberUids", []]);
if (_memberUids isEqualTo []) exitWith {};
{
private _player = [_x] call EFUNC(common,getPlayer);
if (isNull _player) then { continue; };
[CRPC(org,responseSyncOrg), [_patch], _player] call CFUNC(targetEvent);
} forEach _memberUids;
};
GVAR(SyncEventTokens) = [
EGVAR(common,EventBus) call ["on", ["org.sync.requested", _sendOrgSync, "org.sync"]]
];
};

View File

@ -6,6 +6,67 @@ PREP_RECOMPILE_END;
// private _category = [QUOTE(MOD_NAME), LLSTRING(displayName)];
GVAR(RequestOrgSync) = {
params [["_memberUids", [], [[]]], ["_patch", createHashMap, [createHashMap]]];
if (_memberUids isEqualTo []) exitWith {};
if (isNil QEGVAR(common,EventBus)) exitWith {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [_patch], _memberPlayer] call CFUNC(targetEvent);
};
} forEach _memberUids;
};
EGVAR(common,EventBus) call ["emit", [
"org.sync.requested",
createHashMapFromArray [
["memberUids", +_memberUids],
["patch", +_patch]
],
createHashMapFromArray [["source", "org"]]
]];
};
GVAR(RequestNotification) = {
params [
["_uids", [], [[]]],
["_type", "info", [""]],
["_title", "", [""]],
["_message", "", [""]],
["_duration", -1, [0]]
];
if (_uids isEqualTo [] || { _message isEqualTo "" }) exitWith {};
if (isNil QEGVAR(common,EventBus)) exitWith {
private _params = [_type, _title, _message];
if (_duration >= 0) then { _params pushBack _duration; };
{
private _player = [_x] call EFUNC(common,getPlayer);
if (_player isNotEqualTo objNull) then {
[CRPC(notifications,recieveNotification), _params, _player] call CFUNC(targetEvent);
};
} forEach _uids;
};
private _payload = createHashMapFromArray [
["uids", +_uids],
["notificationType", _type],
["title", _title],
["message", _message]
];
if (_duration >= 0) then { _payload set ["duration", _duration]; };
EGVAR(common,EventBus) call ["emit", [
"notification.requested",
_payload,
createHashMapFromArray [["source", "org"]]
]];
};
[QGVAR(requestInitOrg), {
params [["_uid", "", [""]]];
@ -71,12 +132,9 @@ PREP_RECOMPILE_END;
if (_result getOrDefault ["success", false]) then {
private _patch = _result getOrDefault ["patch", createHashMap];
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull && { _patch isNotEqualTo createHashMap }) then {
[CRPC(org,responseSyncOrg), [_patch], _memberPlayer] call CFUNC(targetEvent);
};
} forEach (_result getOrDefault ["memberUids", []]);
if (_patch isNotEqualTo createHashMap) then {
[_result getOrDefault ["memberUids", []], _patch] call GVAR(RequestOrgSync);
};
};
[CRPC(org,responseCreditLine), [createHashMapFromArray [
@ -100,14 +158,9 @@ PREP_RECOMPILE_END;
private _result = GVAR(OrgStore) call ["runPayroll", [_uid, _amount]];
if (_result getOrDefault ["success", false]) then {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [createHashMap], _memberPlayer] call CFUNC(targetEvent);
};
} forEach (_result getOrDefault ["memberUids", []]);
[CRPC(org,responseSyncOrg), [createHashMap], _requester] call CFUNC(targetEvent);
private _syncTargets = +(_result getOrDefault ["memberUids", []]);
_syncTargets pushBackUnique _uid;
[_syncTargets, createHashMap] call GVAR(RequestOrgSync);
};
[CRPC(org,responseTreasuryAction), [createHashMapFromArray [
@ -133,14 +186,9 @@ PREP_RECOMPILE_END;
private _result = GVAR(OrgStore) call ["transferFunds", [_uid, _memberUid, _memberName, _amount]];
if (_result getOrDefault ["success", false]) then {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [createHashMap], _memberPlayer] call CFUNC(targetEvent);
};
} forEach (_result getOrDefault ["memberUids", []]);
[CRPC(org,responseSyncOrg), [createHashMap], _requester] call CFUNC(targetEvent);
private _syncTargets = +(_result getOrDefault ["memberUids", []]);
_syncTargets pushBackUnique _uid;
[_syncTargets, createHashMap] call GVAR(RequestOrgSync);
};
[CRPC(org,responseTreasuryAction), [createHashMapFromArray [
@ -161,22 +209,9 @@ PREP_RECOMPILE_END;
private _result = GVAR(OrgStore) call ["inviteMember", [_uid, _targetUid, _targetName]];
if (_result getOrDefault ["success", false]) then {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [createHashMap], _memberPlayer] call CFUNC(targetEvent);
};
} forEach [_uid, _result getOrDefault ["targetUid", _targetUid]];
private _targetPlayer = [_result getOrDefault ["targetUid", _targetUid]] call EFUNC(common,getPlayer);
if (_targetPlayer isNotEqualTo objNull) then {
[CRPC(notifications,recieveNotification), [
"info",
"Organization Invite",
"You received an organization invite. Open the organization portal to accept or decline it.",
7000
], _targetPlayer] call CFUNC(targetEvent);
};
private _resolvedTargetUid = _result getOrDefault ["targetUid", _targetUid];
[[_uid, _resolvedTargetUid], createHashMap] call GVAR(RequestOrgSync);
[[_resolvedTargetUid], "info", "Organization Invite", "You received an organization invite. Open the organization portal to accept or decline it.", 7000] call GVAR(RequestNotification);
};
[CRPC(org,responseInviteOrg), [createHashMapFromArray [
@ -215,12 +250,7 @@ PREP_RECOMPILE_END;
} forEach (_orgData getOrDefault ["members", createHashMap]);
} forEach (_result getOrDefault ["affectedOrgIds", []]);
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [createHashMap], _memberPlayer] call CFUNC(targetEvent);
};
} forEach _syncTargets;
[_syncTargets, createHashMap] call GVAR(RequestOrgSync);
};
[CRPC(org,responseInviteDecision), [createHashMapFromArray [
@ -255,12 +285,7 @@ PREP_RECOMPILE_END;
} forEach (_orgData getOrDefault ["members", createHashMap]);
} forEach (_result getOrDefault ["affectedOrgIds", []]);
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [createHashMap], _memberPlayer] call CFUNC(targetEvent);
};
} forEach _syncTargets;
[_syncTargets, createHashMap] call GVAR(RequestOrgSync);
};
[CRPC(org,responseInviteDecision), [createHashMapFromArray [
@ -291,7 +316,8 @@ PREP_RECOMPILE_END;
private _notificationParams = _result getOrDefault ["notification", []];
if (_notificationParams isEqualType [] && { count _notificationParams > 0 }) then {
[CRPC(notifications,recieveNotification), _notificationParams, _player] call CFUNC(targetEvent);
private _duration = if ((count _notificationParams) > 3) then { _notificationParams # 3 } else { -1 };
[[_uid], _notificationParams # 0, _notificationParams # 1, _notificationParams # 2, _duration] call GVAR(RequestNotification);
};
};
@ -344,7 +370,8 @@ PREP_RECOMPILE_END;
private _notificationParams = _member getOrDefault ["notification", []];
if (_notificationParams isEqualType [] && { count _notificationParams > 0 }) then {
[CRPC(notifications,recieveNotification), _notificationParams, _memberPlayer] call CFUNC(targetEvent);
private _duration = if ((count _notificationParams) > 3) then { _notificationParams # 3 } else { -1 };
[[_memberUid], _notificationParams # 0, _notificationParams # 1, _notificationParams # 2, _duration] call GVAR(RequestNotification);
};
};
} forEach (_result getOrDefault ["members", []]);

View File

@ -4,7 +4,7 @@
* File: fnc_initOrgStore.sqf
* Author: IDSolutions
* Date: 2026-02-13
* Last Update: 2026-04-18
* Last Update: 2026-05-15
* Public: Yes
*
* Description:
@ -748,10 +748,34 @@ GVAR(OrgBaseStore) = compileFinal createHashMapFromArray [
private _currentBank = _account getOrDefault ["bank", 0];
private _patch = EGVAR(bank,BankStore) call ["mset", [_memberUid, createHashMapFromArray [["bank", _currentBank + _amount]], true]];
if (_patch isEqualTo createHashMap) exitWith { false };
if (isNil QEGVAR(common,EventBus)) then {
EGVAR(bank,BankMessenger) call ["sendAccountSync", [_memberUid, _patch]];
} else {
EGVAR(common,EventBus) call ["emit", [
"bank.account.sync.requested",
createHashMapFromArray [
["uid", _memberUid],
["account", +_patch]
],
createHashMapFromArray [["source", "org"]]
]];
};
EGVAR(bank,BankMessenger) call ["sendAccountSync", [_memberUid, _patch]];
if (_message isNotEqualTo "") then {
EGVAR(bank,BankMessenger) call ["sendNotification", [_memberUid, "info", "Treasury", _message]];
if (isNil QEGVAR(common,EventBus)) then {
EGVAR(bank,BankMessenger) call ["sendNotification", [_memberUid, "info", "Treasury", _message]];
} else {
EGVAR(common,EventBus) call ["emit", [
"notification.requested",
createHashMapFromArray [
["uids", [_memberUid]],
["notificationType", "info"],
["title", "Treasury"],
["message", _message]
],
createHashMapFromArray [["source", "org"]]
]];
};
};
true

View File

@ -238,19 +238,86 @@ GVAR(StorefrontBaseStore) = compileFinal createHashMapFromArray [
private _vgPatch = _result getOrDefault ["vgaragePatch", createHashMap];
private _bankPatch = _result getOrDefault ["bankPatch", createHashMap];
private _orgPatch = _result getOrDefault ["orgPatch", createHashMap];
private _uid = getPlayerUID _player;
if (keys _lockerPatch isNotEqualTo []) then { [CRPC(locker,responseSyncLocker), [_lockerPatch], _player] call CFUNC(targetEvent); };
if (keys _vaPatch isNotEqualTo []) then { [CRPC(locker,responseSyncVA), [_vaPatch], _player] call CFUNC(targetEvent); };
if (keys _vgPatch isNotEqualTo []) then { [CRPC(garage,responseSyncVG), [_vgPatch], _player] call CFUNC(targetEvent); };
if (keys _bankPatch isNotEqualTo []) then { [CRPC(bank,responseSyncBank), [_bankPatch], _player] call CFUNC(targetEvent); };
if (keys _lockerPatch isNotEqualTo []) then {
if (isNil QEGVAR(common,EventBus)) then {
[CRPC(locker,responseSyncLocker), [_lockerPatch], _player] call CFUNC(targetEvent);
} else {
EGVAR(common,EventBus) call ["emit", [
"locker.sync.requested",
createHashMapFromArray [
["uid", _uid],
["patch", +_lockerPatch]
],
createHashMapFromArray [["source", "store"]]
]];
};
};
if (keys _vaPatch isNotEqualTo []) then {
if (isNil QEGVAR(common,EventBus)) then {
[CRPC(locker,responseSyncVA), [_vaPatch], _player] call CFUNC(targetEvent);
} else {
EGVAR(common,EventBus) call ["emit", [
"locker.va.sync.requested",
createHashMapFromArray [
["uid", _uid],
["patch", +_vaPatch]
],
createHashMapFromArray [["source", "store"]]
]];
};
};
if (keys _vgPatch isNotEqualTo []) then {
if (isNil QEGVAR(common,EventBus)) then {
[CRPC(garage,responseSyncVG), [_vgPatch], _player] call CFUNC(targetEvent);
} else {
EGVAR(common,EventBus) call ["emit", [
"garage.vgarage.sync.requested",
createHashMapFromArray [
["uid", _uid],
["patch", +_vgPatch]
],
createHashMapFromArray [["source", "store"]]
]];
};
};
if (keys _bankPatch isNotEqualTo []) then {
if (isNil QEGVAR(common,EventBus)) then {
[CRPC(bank,responseSyncBank), [_bankPatch], _player] call CFUNC(targetEvent);
} else {
EGVAR(common,EventBus) call ["emit", [
"bank.account.sync.requested",
createHashMapFromArray [
["uid", _uid],
["account", +_bankPatch]
],
createHashMapFromArray [["source", "store"]]
]];
};
};
if (keys _orgPatch isNotEqualTo []) then {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [_orgPatch], _memberPlayer] call CFUNC(targetEvent);
};
} forEach (_result getOrDefault ["orgTargetUids", []]);
private _orgTargetUids = +(_result getOrDefault ["orgTargetUids", []]);
if (isNil QEGVAR(common,EventBus)) then {
{
private _memberPlayer = [_x] call EFUNC(common,getPlayer);
if (_memberPlayer isNotEqualTo objNull) then {
[CRPC(org,responseSyncOrg), [_orgPatch], _memberPlayer] call CFUNC(targetEvent);
};
} forEach _orgTargetUids;
} else {
EGVAR(common,EventBus) call ["emit", [
"org.sync.requested",
createHashMapFromArray [
["memberUids", _orgTargetUids],
["patch", +_orgPatch]
],
createHashMapFromArray [["source", "store"]]
]];
};
};
true

View File

@ -41,17 +41,17 @@ system intentionally starts clean after each server or mission restart.
- defuse progress
- per-task entity registries for cargo, hostages, HVTs, IEDs, protected entities, shooters, and targets
### Object Model Prototype
A review-only prototype for object-based task instances lives under
`prototypes/`. It is not wired into runtime.
### Object Model
Object-style task instances and entity controllers live under
`functions/objects/` and are initialized directly from `XEH_preInit.sqf`.
- `forge_server_task_fnc_initPrototypes`
- `prototypes/README.md`
- `TaskInstanceBaseClass`
- `EntityControllerBaseClass`
- `functions/objects/README.md`
The prototype sketches task classes for attack, defuse, defend, delivery,
destroy, hostage, and HVT flows using `createHashMapObject` so the team can
review a stateful per-task design without replacing the current procedural task
flows.
The task functions are compatibility adapters around these object-style task
classes. This keeps the public task function names stable while moving stateful
task behavior into per-task `createHashMapObject` instances.
### Reward Handling
`fnc_handleTaskRewards.sqf` applies org-owned rewards:
@ -212,6 +212,7 @@ If you want the accepting player's org to own the task rewards, use `fnc_handler
- compiles functions
- initializes `TaskStore`
- `XEH_postInit.sqf`
- registers temporary task lifecycle event logs for migration testing
- registers the ACE defuse event hook
## Notes

View File

@ -19,7 +19,6 @@ PREP(initTaskStore);
PREP_SUBDIR(generators,attackMissionGenerator);
PREP_SUBDIR(helpers,handleTaskRewards);
PREP_SUBDIR(helpers,heartBeat);
PREP_SUBDIR(helpers,parseRewards);
PREP_SUBDIR(helpers,spawnEnemyWave);
PREP_SUBDIR(helpers,startTask);
@ -37,21 +36,20 @@ PREP_SUBDIR(modules,hvtModule);
PREP_SUBDIR(modules,protectedModule);
PREP_SUBDIR(modules,shootersModule);
PREP_SUBDIR(prototypes,initPrototypes);
PREP_SUBDIR(prototypes,TaskInstanceBaseClass);
PREP_SUBDIR(prototypes,EntityControllerBaseClass);
PREP_SUBDIR(prototypes,AttackTaskBaseClass);
PREP_SUBDIR(prototypes,HostageTaskBaseClass);
PREP_SUBDIR(prototypes,HostageEntityController);
PREP_SUBDIR(prototypes,TargetEntityController);
PREP_SUBDIR(prototypes,ShooterEntityController);
PREP_SUBDIR(prototypes,HVTEntityController);
PREP_SUBDIR(prototypes,CargoEntityController);
PREP_SUBDIR(prototypes,ProtectedEntityController);
PREP_SUBDIR(prototypes,IEDEntityController);
PREP_SUBDIR(prototypes,DefenseEnemyController);
PREP_SUBDIR(prototypes,DefuseTaskBaseClass);
PREP_SUBDIR(prototypes,DestroyTaskBaseClass);
PREP_SUBDIR(prototypes,DeliveryTaskBaseClass);
PREP_SUBDIR(prototypes,HVTTaskBaseClass);
PREP_SUBDIR(prototypes,DefendTaskBaseClass);
PREP_SUBDIR(objects,TaskInstanceBaseClass);
PREP_SUBDIR(objects,EntityControllerBaseClass);
PREP_SUBDIR(objects,AttackTaskBaseClass);
PREP_SUBDIR(objects,HostageTaskBaseClass);
PREP_SUBDIR(objects,HostageEntityController);
PREP_SUBDIR(objects,TargetEntityController);
PREP_SUBDIR(objects,ShooterEntityController);
PREP_SUBDIR(objects,HVTEntityController);
PREP_SUBDIR(objects,CargoEntityController);
PREP_SUBDIR(objects,ProtectedEntityController);
PREP_SUBDIR(objects,IEDEntityController);
PREP_SUBDIR(objects,DefenseEnemyController);
PREP_SUBDIR(objects,DefuseTaskBaseClass);
PREP_SUBDIR(objects,DestroyTaskBaseClass);
PREP_SUBDIR(objects,DeliveryTaskBaseClass);
PREP_SUBDIR(objects,HVTTaskBaseClass);
PREP_SUBDIR(objects,DefendTaskBaseClass);

View File

@ -5,6 +5,8 @@ if (isNil QGVAR(TaskLifecycleEventLogTokens)) then {
private _logTaskLifecycleEvent = {
params ["_event"];
if !(missionNamespace getVariable [QGVAR(enableEventLogs), false]) exitWith {};
["INFO", format [
"Task lifecycle event: %1 taskID=%2 taskType=%3 status=%4 participants=%5",
_event getOrDefault ["event", ""],
@ -15,12 +17,92 @@ if (isNil QGVAR(TaskLifecycleEventLogTokens)) then {
]] call EFUNC(common,log);
};
private _logTaskRewardEvent = {
params ["_event"];
if !(missionNamespace getVariable [QGVAR(enableEventLogs), false]) exitWith {};
["INFO", format [
"Task reward event: %1 taskID=%2 success=%3 message=%4",
_event getOrDefault ["event", ""],
_event getOrDefault ["taskID", ""],
!((_event getOrDefault ["event", ""]) in ["task.reward.failed", "task.rating.failed"]),
_event getOrDefault ["message", ""]
]] call EFUNC(common,log);
};
GVAR(TaskLifecycleEventLogTokens) = [
EGVAR(common,EventBus) call ["on", ["task.created", _logTaskLifecycleEvent, "task.lifecycle.log"]],
EGVAR(common,EventBus) call ["on", ["task.started", _logTaskLifecycleEvent, "task.lifecycle.log"]],
EGVAR(common,EventBus) call ["on", ["task.completed", _logTaskLifecycleEvent, "task.lifecycle.log"]],
EGVAR(common,EventBus) call ["on", ["task.failed", _logTaskLifecycleEvent, "task.lifecycle.log"]],
EGVAR(common,EventBus) call ["on", ["task.cleared", _logTaskLifecycleEvent, "task.lifecycle.log"]]
EGVAR(common,EventBus) call ["on", ["task.cleared", _logTaskLifecycleEvent, "task.lifecycle.log"]],
EGVAR(common,EventBus) call ["on", ["task.reward.requested", _logTaskRewardEvent, "task.reward.log"]],
EGVAR(common,EventBus) call ["on", ["task.reward.applied", _logTaskRewardEvent, "task.reward.log"]],
EGVAR(common,EventBus) call ["on", ["task.reward.failed", _logTaskRewardEvent, "task.reward.log"]],
EGVAR(common,EventBus) call ["on", ["task.rating.applied", _logTaskRewardEvent, "task.reward.log"]],
EGVAR(common,EventBus) call ["on", ["task.rating.failed", _logTaskRewardEvent, "task.reward.log"]]
];
};
if (isNil QGVAR(TaskNotificationEventTokens)) then {
private _sendTaskNotification = {
params ["_event"];
private _type = _event getOrDefault ["notificationType", "info"];
private _title = _event getOrDefault ["title", "Tasks"];
private _message = _event getOrDefault ["message", ""];
private _participantUids = +(_event getOrDefault ["participantUids", []]);
if (_message isEqualTo "" || { _participantUids isEqualTo [] }) exitWith {};
{
private _player = [_x] call EFUNC(common,getPlayer);
if (isNull _player) then { continue; };
[CRPC(notifications,recieveNotification), [_type, _title, _message], _player] call CFUNC(targetEvent);
} forEach _participantUids;
if (missionNamespace getVariable [QGVAR(enableEventLogs), false]) then {
["INFO", format [
"Task notification event: taskID=%1 type=%2 recipients=%3 message=%4",
_event getOrDefault ["taskID", ""],
_type,
_participantUids,
_message
]] call EFUNC(common,log);
};
};
private _sendRewardNotification = {
params ["_event"];
private _type = _event getOrDefault ["notificationType", "info"];
private _title = _event getOrDefault ["title", "Tasks"];
private _message = _event getOrDefault ["message", ""];
private _memberUids = +(_event getOrDefault ["memberUids", []]);
if (_message isEqualTo "" || { _memberUids isEqualTo [] }) exitWith {};
{
private _player = [_x] call EFUNC(common,getPlayer);
if (isNull _player) then { continue; };
[CRPC(notifications,recieveNotification), [_type, _title, _message], _player] call CFUNC(targetEvent);
} forEach _memberUids;
if (missionNamespace getVariable [QGVAR(enableEventLogs), false]) then {
["INFO", format [
"Task reward notification event: taskID=%1 type=%2 recipients=%3 message=%4",
_event getOrDefault ["taskID", ""],
_type,
_memberUids,
_message
]] call EFUNC(common,log);
};
};
GVAR(TaskNotificationEventTokens) = [
EGVAR(common,EventBus) call ["on", ["task.notification.requested", _sendTaskNotification, "task.notification.send"]],
EGVAR(common,EventBus) call ["on", ["task.reward.notification.requested", _sendRewardNotification, "task.reward.notification.send"]]
];
};

View File

@ -6,7 +6,7 @@
*
* This public function is now a compatibility adapter around
* AttackTaskBaseClass. Keep the argument list stable for Eden modules,
* startTask, and external scripts while the object-style task prototypes
* startTask, and external scripts while the object-style task objects
* become the live implementation.
*
* Arguments:

View File

@ -1,35 +1,7 @@
#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Registers a defend task where players must hold a zone marked by a marker
*
* Arguments:
* 0: ID of the task <STRING>
* 1: Defense zone marker name <STRING>
* 2: Time to defend in seconds <NUMBER>
* 3: Amount of funds the company receives if the task is successful <NUMBER> (default: 0)
* 4: Amount of rating the company and player lose if the task is failed <NUMBER> (default: 0)
* 5: Amount of rating the company and player receive 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: 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: Enemy template groups <ARRAY> (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
*
* Example:
* ["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_server_task_fnc_defend;
*
* Public: Yes
* Compatibility adapter for the object-style defend task implementation.
*/
params [
@ -52,103 +24,34 @@ params [
["_specialRewards", [], [[]]]
];
if (_defenseZone == "" || !(markerShape _defenseZone in ["RECTANGLE", "ELLIPSE"])) exitWith {
["ERROR", format ["Invalid defense zone marker: %1", _defenseZone]] call EFUNC(common,log);
};
private _taskParams = createHashMapFromArray [
["defenseZone", _defenseZone],
["defendTime", _defendTime],
["funds", _companyFunds],
["ratingFail", _ratingFail],
["ratingSuccess", _ratingSuccess],
["endSuccess", _endSuccess],
["endFail", _endFail],
["waveCount", _waveCount],
["waveCooldown", _waveCooldown],
["minBlufor", _minBlufor],
["enemyTemplates", _enemyTemplates],
["useTaskStore", true]
];
private _result = 0;
private _startTime = -1;
private _nextWaveTime = -1;
private _currentWave = 0;
private _zoneEmptyCounter = 0;
private _warningIssued = false;
private _defenseStarted = false;
if (_equipmentRewards isNotEqualTo []) then { _taskParams set ["equipment", _equipmentRewards]; };
if (_supplyRewards isNotEqualTo []) then { _taskParams set ["supplies", _supplyRewards]; };
if (_weaponRewards isNotEqualTo []) then { _taskParams set ["weapons", _weaponRewards]; };
if (_vehicleRewards isNotEqualTo []) then { _taskParams set ["vehicles", _vehicleRewards]; };
if (_specialRewards isNotEqualTo []) then { _taskParams set ["special", _specialRewards]; };
waitUntil {
sleep 1;
GVAR(TaskStore) call ["isTaskAccepted", [_taskID]]
};
private _task = createHashMapObject [
GVAR(DefendTaskBaseClass),
[
_taskID,
createHashMap,
_taskParams
]
];
waitUntil {
sleep 1;
GVAR(TaskStore) call ["trackParticipants", [_taskID, [], _defenseZone, 0]];
private _bluforInZone = count (allUnits select { _x isKindOf "CAManBase" && { side _x == west } && { alive _x }} inAreaArray _defenseZone);
private _readyToStart = _bluforInZone >= _minBlufor;
if (_readyToStart) then {
_defenseStarted = true;
_startTime = time;
_nextWaveTime = _startTime;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "info", "Tasks", "Defense has started. Hold the zone."]];
};
_readyToStart
};
waitUntil {
sleep 1;
GVAR(TaskStore) call ["trackParticipants", [_taskID, [], _defenseZone, 0]];
private _bluforInZone = count (allUnits select { _x isKindOf "CAManBase" && { side _x == west } && { alive _x }} inAreaArray _defenseZone);
private _timeElapsed = if (_defenseStarted) then { time - _startTime } else { 0 };
if (_bluforInZone < _minBlufor) then {
_zoneEmptyCounter = _zoneEmptyCounter + 1;
if (_zoneEmptyCounter == 15 && !_warningIssued) then {
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", "Defense zone is empty. Return immediately."]];
_warningIssued = true;
};
} else {
_zoneEmptyCounter = 0;
_warningIssued = false;
};
if (_currentWave < _waveCount && _defenseStarted && { time >= _nextWaveTime }) then {
[_defenseZone, _taskID, _currentWave, _enemyTemplates] call FUNC(spawnEnemyWave);
_currentWave = _currentWave + 1;
_nextWaveTime = time + _waveCooldown;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "info", "Tasks", format ["Enemy forces approaching. Wave %1 of %2.", _currentWave, _waveCount]]];
};
if (_zoneEmptyCounter >= 30) then { _result = 1; };
(_result == 1) or ((_bluforInZone >= _minBlufor) && (_timeElapsed >= _defendTime) && (_currentWave >= _waveCount));
};
if (_result == 1) then {
[_taskID, "FAILED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "failed"]];
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
if (_endFail) then { "EveryoneLost" call BFUNC(endMissionServer); };
} else {
private _rewards = createHashMap;
_rewards set ["funds", _companyFunds];
if (_equipmentRewards isNotEqualTo []) then { _rewards set ["equipment", _equipmentRewards]; };
if (_supplyRewards isNotEqualTo []) then { _rewards set ["supplies", _supplyRewards]; };
if (_weaponRewards isNotEqualTo []) then { _rewards set ["weapons", _weaponRewards]; };
if (_vehicleRewards isNotEqualTo []) then { _rewards set ["vehicles", _vehicleRewards]; };
if (_specialRewards isNotEqualTo []) then { _rewards set ["special", _specialRewards]; };
[_taskID, _rewards] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_companyFunds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
if (_endSuccess) then { "EveryoneWon" call BFUNC(endMissionServer); };
};
_task call ["runLoop", []];

View File

@ -1,120 +1,52 @@
#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Registers a defuse task
*
* Arguments:
* 0: ID of the task <STRING>
* 1: Amount of entities destroyed to fail the task <NUMBER>
* 2: Amount of ieds defused to complete the task <NUMBER>
* 3: Amount of funds the company recieves if the task is successful <NUMBER> (default: 0)
* 4: Amount of rating the company and player lose if the task is failed <NUMBER> (default: 0)
* 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
*
* Example:
* ["task_name", 2, 3, 375000, -75, 300, false, false] spawn forge_server_task_fnc_defuse;
*
* Public: Yes
* Compatibility adapter for the object-style defuse task implementation.
*/
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", [], [[]]]
["_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;
private _ieds = [];
private _taskParams = createHashMapFromArray [
["limitFail", _limitFail],
["limitSuccess", _limitSuccess],
["funds", _companyFunds],
["ratingFail", _ratingFail],
["ratingSuccess", _ratingSuccess],
["endSuccess", _endSuccess],
["endFail", _endFail],
["useTaskStore", true]
];
waitUntil {
sleep 1;
_ieds = GVAR(TaskStore) call ["getTaskEntities", ["ieds", _taskID]];
count _ieds > 0
};
if (_equipmentRewards isNotEqualTo []) then { _taskParams set ["equipment", _equipmentRewards]; };
if (_supplyRewards isNotEqualTo []) then { _taskParams set ["supplies", _supplyRewards]; };
if (_weaponRewards isNotEqualTo []) then { _taskParams set ["weapons", _weaponRewards]; };
if (_vehicleRewards isNotEqualTo []) then { _taskParams set ["vehicles", _vehicleRewards]; };
if (_specialRewards isNotEqualTo []) then { _taskParams set ["special", _specialRewards]; };
_ieds = GVAR(TaskStore) call ["getTaskEntities", ["ieds", _taskID]];
private _entities = GVAR(TaskStore) call ["getTaskEntities", ["entities", _taskID]];
private _requiredDefusals = if (_limitSuccess < 0) then { count _ieds } else { _limitSuccess };
private _maxProtectedLosses = if (_limitFail < 0) then { count _entities } else { _limitFail };
private _entitiesDestroyed = 0;
private _defusedCount = 0;
private _shouldFail = false;
private _shouldSucceed = false;
private _done = false;
private _task = createHashMapObject [
GVAR(DefuseTaskBaseClass),
[
_taskID,
createHashMapFromArray [
["ieds", GVAR(TaskStore) call ["getTaskEntities", ["ieds", _taskID]]],
["protected", GVAR(TaskStore) call ["getTaskEntities", ["entities", _taskID]]]
],
_taskParams
]
];
waitUntil {
sleep 1;
GVAR(TaskStore) call ["trackParticipants", [_taskID, _ieds + _entities, "", 250]];
_entitiesDestroyed = ({ !alive _x } count _entities);
_defusedCount = GVAR(TaskStore) call ["getDefuseCount", [_taskID]];
_shouldFail = (_maxProtectedLosses > 0) && { _entitiesDestroyed >= _maxProtectedLosses };
_shouldSucceed = (_requiredDefusals > 0) && { _defusedCount >= _requiredDefusals } && { (_maxProtectedLosses <= 0) || { _entitiesDestroyed < _maxProtectedLosses } };
_done = false;
if (_shouldFail) then { _result = 1; };
if ((_result == 1) or _shouldSucceed) then { _done = true; };
_done
};
if (_result == 1) then {
{ deleteVehicle _x } forEach _ieds;
{ deleteVehicle _x } forEach _entities;
[_taskID, "FAILED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "failed"]];
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
if (_endFail) then { "EveryoneLost" call BFUNC(endMissionServer); };
} else {
{ deleteVehicle _x } forEach _ieds;
{ deleteVehicle _x } forEach _entities;
private _rewards = createHashMap;
_rewards set ["funds", _companyFunds];
if (_equipmentRewards isNotEqualTo []) then { _rewards set ["equipment", _equipmentRewards]; };
if (_supplyRewards isNotEqualTo []) then { _rewards set ["supplies", _supplyRewards]; };
if (_weaponRewards isNotEqualTo []) then { _rewards set ["weapons", _weaponRewards]; };
if (_vehicleRewards isNotEqualTo []) then { _rewards set ["vehicles", _vehicleRewards]; };
if (_specialRewards isNotEqualTo []) then { _rewards set ["special", _specialRewards]; };
[_taskID, _rewards] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_companyFunds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
if (_endSuccess) then { "EveryoneWon" call BFUNC(endMissionServer); };
};
GVAR(TaskStore) call ["clearTask", [_taskID]];
_task call ["runLoop", []];

View File

@ -1,34 +1,7 @@
#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Registers a delivery task
*
* Arguments:
* 0: ID of the task <STRING>
* 1: Amount of damaged cargo to fail the task <NUMBER>
* 2: Amount of cargo delivered to complete the task <NUMBER>
* 3: Marker name for the delivery zone <STRING>
* 4: Amount of funds the company receives if the task is successful <NUMBER> (default: 0)
* 5: Amount of rating the company and player lose if the task is failed <NUMBER> (default: 0)
* 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: 0)
* 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
*
* Example:
* ["delivery_1", 1, 3, "delivery_zone", 250000, -75, 300, false, false] spawn forge_server_task_fnc_delivery;
* ["delivery_1", 1, 3, "delivery_zone", 250000, -75, 300, false, false, 900] spawn forge_server_task_fnc_delivery;
*
* Public: Yes
* Compatibility adapter for the object-style delivery task implementation.
*/
params [
@ -43,88 +16,38 @@ params [
["_endFail", false, [false]],
["_timeLimit", 0, [0]],
["_equipmentRewards", [], [[]]],
["_supplyRewards", [], [[]]],
["_weaponRewards", [], [[]]],
["_vehicleRewards", [], [[]]],
["_specialRewards", [], [[]]]
["_supplyRewards", [], [[]]],
["_weaponRewards", [], [[]]],
["_vehicleRewards", [], [[]]],
["_specialRewards", [], [[]]]
];
private _result = 0;
private _cargo = [];
private _taskParams = createHashMapFromArray [
["limitFail", _limitFail],
["limitSuccess", _limitSuccess],
["deliveryZone", _deliveryZone],
["funds", _companyFunds],
["ratingFail", _ratingFail],
["ratingSuccess", _ratingSuccess],
["endSuccess", _endSuccess],
["endFail", _endFail],
["timeLimit", _timeLimit],
["useTaskStore", true]
];
waitUntil {
sleep 1;
_cargo = GVAR(TaskStore) call ["getTaskEntities", ["cargo", _taskID]];
GVAR(TaskStore) call ["trackParticipants", [_taskID, _cargo, _deliveryZone, 125]];
count _cargo > 0
};
if (_equipmentRewards isNotEqualTo []) then { _taskParams set ["equipment", _equipmentRewards]; };
if (_supplyRewards isNotEqualTo []) then { _taskParams set ["supplies", _supplyRewards]; };
if (_weaponRewards isNotEqualTo []) then { _taskParams set ["weapons", _weaponRewards]; };
if (_vehicleRewards isNotEqualTo []) then { _taskParams set ["vehicles", _vehicleRewards]; };
if (_specialRewards isNotEqualTo []) then { _taskParams set ["special", _specialRewards]; };
_cargo = GVAR(TaskStore) call ["getTaskEntities", ["cargo", _taskID]];
private _task = createHashMapObject [
GVAR(DeliveryTaskBaseClass),
[
_taskID,
createHashMapFromArray [["cargo", GVAR(TaskStore) call ["getTaskEntities", ["cargo", _taskID]]]],
_taskParams
]
];
if (_timeLimit isNotEqualTo 0) then {
waitUntil {
sleep 1;
GVAR(TaskStore) call ["isTaskAccepted", [_taskID]]
};
};
private _startTime = if (_timeLimit isNotEqualTo 0) then { floor(time) } else { nil };
waitUntil {
sleep 1;
GVAR(TaskStore) call ["trackParticipants", [_taskID, _cargo, _deliveryZone, 125]];
private _cargoDelivered = ({ _x inArea _deliveryZone && (damage _x) < 0.7 } count _cargo);
private _cargoDamaged = ({ damage _x >= 0.7 } count _cargo);
if (_timeLimit isNotEqualTo 0) then {
private _timeExpired = (floor time - _startTime >= _timeLimit);
if (_cargoDamaged >= _limitFail) then { _result = 1; };
if (_cargoDelivered < _limitSuccess && _timeExpired) then { _result = 1; };
(_result == 1) or ((_cargoDelivered >= _limitSuccess) && (_cargoDamaged < _limitFail))
} else {
if (_cargoDamaged >= _limitFail) then { _result = 1; };
(_result == 1) or ((_cargoDelivered >= _limitSuccess) && (_cargoDamaged < _limitFail))
};
};
if (_result == 1) then {
{ deleteVehicle _x } forEach _cargo;
[_taskID, "FAILED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "failed"]];
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
if (_endFail) then { "EveryoneLost" call BFUNC(endMissionServer); };
} else {
{ deleteVehicle _x } forEach _cargo;
private _rewards = createHashMap;
_rewards set ["funds", _companyFunds];
if (_equipmentRewards isNotEqualTo []) then { _rewards set ["equipment", _equipmentRewards]; };
if (_supplyRewards isNotEqualTo []) then { _rewards set ["supplies", _supplyRewards]; };
if (_weaponRewards isNotEqualTo []) then { _rewards set ["weapons", _weaponRewards]; };
if (_vehicleRewards isNotEqualTo []) then { _rewards set ["vehicles", _vehicleRewards]; };
if (_specialRewards isNotEqualTo []) then { _rewards set ["special", _specialRewards]; };
[_taskID, _rewards] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_companyFunds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
if (_endSuccess) then { "EveryoneWon" call BFUNC(endMissionServer); };
};
_task call ["runLoop", []];

View File

@ -1,124 +1,51 @@
#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Registers an destroy task
*
* Arguments:
* 0: ID of the task <STRING>
* 1: Amount of targets escaped to fail the task <NUMBER>
* 2: Amount of targets eliminated to complete the task <NUMBER>
* 3: Amount of funds the company recieves if the task is successful <NUMBER> (default: 0)
* 4: Amount of rating the company and player lose if the task is failed <NUMBER> (default: 0)
* 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: 0, 0 = no limit)
* 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
*
* Example:
* ["task_name", 1, 2, 250000, -75, 300, false, false] spawn forge_server_task_fnc_destroy;
* ["task_name", 1, 2, 250000, -75, 300, false, false, 45] spawn forge_server_task_fnc_destroy;
*
* Public: Yes
* Compatibility adapter for the object-style destroy task implementation.
*/
params [
["_taskID", "", [""]],
["_limitFail", -1, [0]],
["_limitSuccess", -1, [0]],
["_companyFunds", 0, [0]],
["_ratingFail", 0, [0]],
["_ratingSuccess", 0, [0]],
["_endSuccess", false, [false]],
["_endFail", false, [false]],
["_timeLimit", 0, [0]],
["_equipmentRewards", [], [[]]],
["_supplyRewards", [], [[]]],
["_weaponRewards", [], [[]]],
["_vehicleRewards", [], [[]]],
["_specialRewards", [], [[]]]
["_taskID", "", [""]],
["_limitFail", -1, [0]],
["_limitSuccess", -1, [0]],
["_companyFunds", 0, [0]],
["_ratingFail", 0, [0]],
["_ratingSuccess", 0, [0]],
["_endSuccess", false, [false]],
["_endFail", false, [false]],
["_timeLimit", 0, [0]],
["_equipmentRewards", [], [[]]],
["_supplyRewards", [], [[]]],
["_weaponRewards", [], [[]]],
["_vehicleRewards", [], [[]]],
["_specialRewards", [], [[]]]
];
private _result = 0;
private _targets = [];
private _taskParams = createHashMapFromArray [
["limitFail", _limitFail],
["limitSuccess", _limitSuccess],
["funds", _companyFunds],
["ratingFail", _ratingFail],
["ratingSuccess", _ratingSuccess],
["endSuccess", _endSuccess],
["endFail", _endFail],
["timeLimit", _timeLimit],
["useTaskStore", true]
];
waitUntil {
sleep 1;
_targets = GVAR(TaskStore) call ["getTaskEntities", ["targets", _taskID]];
GVAR(TaskStore) call ["trackParticipants", [_taskID, _targets, "", 300]];
count _targets > 0
};
if (_equipmentRewards isNotEqualTo []) then { _taskParams set ["equipment", _equipmentRewards]; };
if (_supplyRewards isNotEqualTo []) then { _taskParams set ["supplies", _supplyRewards]; };
if (_weaponRewards isNotEqualTo []) then { _taskParams set ["weapons", _weaponRewards]; };
if (_vehicleRewards isNotEqualTo []) then { _taskParams set ["vehicles", _vehicleRewards]; };
if (_specialRewards isNotEqualTo []) then { _taskParams set ["special", _specialRewards]; };
_targets = GVAR(TaskStore) call ["getTaskEntities", ["targets", _taskID]];
private _task = createHashMapObject [
GVAR(DestroyTaskBaseClass),
[
_taskID,
createHashMapFromArray [["targets", GVAR(TaskStore) call ["getTaskEntities", ["targets", _taskID]]]],
_taskParams
]
];
if (_timeLimit isNotEqualTo 0) then {
waitUntil {
sleep 1;
GVAR(TaskStore) call ["isTaskAccepted", [_taskID]]
};
};
private _startTime = if (_timeLimit isNotEqualTo 0) then { floor(time) } else { nil };
waitUntil {
sleep 1;
GVAR(TaskStore) call ["trackParticipants", [_taskID, _targets, "", 300]];
private _targetsDestroyed = ({ !alive _x } count _targets);
if (_timeLimit isNotEqualTo 0) then {
private _timeExpired = (floor time - _startTime >= _timeLimit);
if (_targetsDestroyed < _limitSuccess && _timeExpired) then { _result = 1; };
(_result == 1) or (_targetsDestroyed >= _limitSuccess)
} else {
(_targetsDestroyed >= _limitSuccess)
};
};
if (_result == 1) then {
{ deleteVehicle _x } forEach _targets;
[_taskID, "FAILED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "failed"]];
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
if (_endFail) then { "EveryoneLost" call BFUNC(endMissionServer); };
} else {
{ deleteVehicle _x } forEach _targets;
private _rewards = createHashMap;
_rewards set ["funds", _companyFunds];
if (_equipmentRewards isNotEqualTo []) then { _rewards set ["equipment", _equipmentRewards]; };
if (_supplyRewards isNotEqualTo []) then { _rewards set ["supplies", _supplyRewards]; };
if (_weaponRewards isNotEqualTo []) then { _rewards set ["weapons", _weaponRewards]; };
if (_vehicleRewards isNotEqualTo []) then { _rewards set ["vehicles", _vehicleRewards]; };
if (_specialRewards isNotEqualTo []) then { _rewards set ["special", _specialRewards]; };
[_taskID, _rewards] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_companyFunds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
if (_endSuccess) then { "EveryoneWon" call BFUNC(endMissionServer); };
};
_task call ["runLoop", []];

View File

@ -1,186 +1,62 @@
#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Registers an hostage task
*
* Arguments:
* 0: ID of the task <STRING>
* 1: Amount of hostages KIA to fail the task <NUMBER>
* 2: Amount of hostages rescued to complete the task <NUMBER>
* 3: Marker name for the extraction zone <STRING>
* 4: Amount of funds the company recieves if the task is successful <NUMBER> (default: 0)
* 5: Amount of rating the company and player lose if the task is failed <NUMBER> (default: 0)
* 6: Amount of rating the company and player recieve if the task is successful <NUMBER> (default: 0)
* 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) are executed <NUMBER> (default: 0, 0 = no limit)
* 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
*
* Example:
* ["task_name", 1, 2, "marker_name", 1500000, -75, 500, [false, true], false, false] spawn forge_server_task_fnc_hostage;
* ["task_name", 1, 2, "marker_name", 1500000, -75, 500, [false, true], false, false, 45] spawn forge_server_task_fnc_hostage;
* ["task_name", 1, 2, "marker_name", 1500000, -75, 500, [true, false], false, false, 45, "marker_name"] spawn forge_server_task_fnc_hostage;
*
* Public: Yes
* Compatibility adapter for the object-style hostage task implementation.
*/
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]],
["_timeLimit", 0, [0]],
["_cbrnZone", "", [""]],
["_equipmentRewards", [], [[]]],
["_supplyRewards", [], [[]]],
["_weaponRewards", [], [[]]],
["_vehicleRewards", [], [[]]],
["_specialRewards", [], [[]]]
["_taskID", "", [""]],
["_limitFail", -1, [0]],
["_limitSuccess", -1, [0]],
["_extZone", "", [""]],
["_companyFunds", 0, [0]],
["_ratingFail", 0, [0]],
["_ratingSuccess", 0, [0]],
["_type", [false, true], [[]]],
["_endSuccess", false, [false]],
["_endFail", false, [false]],
["_timeLimit", 0, [0]],
["_cbrnZone", "", [""]],
["_equipmentRewards", [], [[]]],
["_supplyRewards", [], [[]]],
["_weaponRewards", [], [[]]],
["_vehicleRewards", [], [[]]],
["_specialRewards", [], [[]]]
];
private _cbrn = (_this select 7) select 0;
private _hostage = (_this select 7) select 1;
private _result = 0;
private _hostages = [];
private _shooters = [];
private _taskParams = createHashMapFromArray [
["limitFail", _limitFail],
["limitSuccess", _limitSuccess],
["extractionZone", _extZone],
["funds", _companyFunds],
["ratingFail", _ratingFail],
["ratingSuccess", _ratingSuccess],
["type", _type],
["cbrn", _type param [0, false, [false]]],
["execution", _type param [1, true, [false]]],
["endSuccess", _endSuccess],
["endFail", _endFail],
["timeLimit", _timeLimit],
["cbrnZone", _cbrnZone],
["useTaskStore", true]
];
waitUntil {
sleep 1;
_hostages = GVAR(TaskStore) call ["getTaskEntities", ["hostages", _taskID]];
count _hostages > 0
};
if (_equipmentRewards isNotEqualTo []) then { _taskParams set ["equipment", _equipmentRewards]; };
if (_supplyRewards isNotEqualTo []) then { _taskParams set ["supplies", _supplyRewards]; };
if (_weaponRewards isNotEqualTo []) then { _taskParams set ["weapons", _weaponRewards]; };
if (_vehicleRewards isNotEqualTo []) then { _taskParams set ["vehicles", _vehicleRewards]; };
if (_specialRewards isNotEqualTo []) then { _taskParams set ["special", _specialRewards]; };
waitUntil {
sleep 1;
_shooters = GVAR(TaskStore) call ["getTaskEntities", ["shooters", _taskID]];
GVAR(TaskStore) call ["trackParticipants", [_taskID, _hostages + _shooters, _extZone, 250]];
count _shooters > 0
};
private _task = createHashMapObject [
GVAR(HostageTaskBaseClass),
[
_taskID,
createHashMapFromArray [
["hostages", GVAR(TaskStore) call ["getTaskEntities", ["hostages", _taskID]]],
["shooters", GVAR(TaskStore) call ["getTaskEntities", ["shooters", _taskID]]]
],
_taskParams
]
];
_hostages = GVAR(TaskStore) call ["getTaskEntities", ["hostages", _taskID]];
_shooters = GVAR(TaskStore) call ["getTaskEntities", ["shooters", _taskID]];
private _requiredRescues = if (_limitSuccess < 0) then { count _hostages } else { _limitSuccess };
private _maxHostageLosses = if (_limitFail < 0) then { count _hostages } else { _limitFail };
if (_timeLimit isNotEqualTo 0) then {
waitUntil {
sleep 1;
GVAR(TaskStore) call ["isTaskAccepted", [_taskID]]
};
};
private _startTime = if (_timeLimit isNotEqualTo 0) then { floor(time) } else { nil };
waitUntil {
sleep 1;
GVAR(TaskStore) call ["trackParticipants", [_taskID, _hostages + _shooters, _extZone, 250]];
private _hostagesInZone = ({ _x inArea _extZone } count _hostages);
private _hostagesKilled = ({ !alive _x } count _hostages);
private _shootersAlive = ({ alive _x } count _shooters);
private _hostageSucceeded = (_hostagesInZone >= _requiredRescues) && { _hostagesKilled < _maxHostageLosses };
private _shootersClearedSucceeded = (!isNil "_shooters") && { _shootersAlive <= 0 } && { _hostageSucceeded };
if (_timeLimit isNotEqualTo 0) then {
private _timeExpired = (floor time - _startTime >= _timeLimit);
if (!_hostageSucceeded && _timeExpired) then { _result = 1; };
if (_hostagesKilled >= _maxHostageLosses) then { _result = 1; };
(_result == 1) or
_hostageSucceeded or
_shootersClearedSucceeded
} else {
if (_hostagesKilled >= _maxHostageLosses) then { _result = 1; };
(_result == 1) or
_hostageSucceeded or
_shootersClearedSucceeded
};
};
if (_result == 1) then {
if (_cbrn) then {
"SmokeShellYellow" createVehicle getMarkerPos _cbrnZone;
sleep 5;
{
if (captive _x) then {
_x setDamage 0.9;
_x playMove "acts_executionvictim_kill_end";
sleep 2.75;
_x setDamage 1;
}
} forEach _hostages;
};
if (_hostage) then {
{
_x enableAIFeature ["MOVE", true];
_x playMove "";
} forEach _shooters;
sleep 1;
{ _x setCaptive false; } forEach _hostages;
sleep 5;
};
{ deleteVehicle _x } forEach _hostages;
{ deleteVehicle _x } forEach _shooters;
[_taskID, "FAILED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "failed"]];
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
if (_endFail) then { "EveryoneLost" call BFUNC(endMissionServer); };
} else {
{ deleteVehicle _x } forEach _hostages;
{ deleteVehicle _x } forEach _shooters;
private _rewards = createHashMap;
_rewards set ["funds", _companyFunds];
if (_equipmentRewards isNotEqualTo []) then { _rewards set ["equipment", _equipmentRewards]; };
if (_supplyRewards isNotEqualTo []) then { _rewards set ["supplies", _supplyRewards]; };
if (_weaponRewards isNotEqualTo []) then { _rewards set ["weapons", _weaponRewards]; };
if (_vehicleRewards isNotEqualTo []) then { _rewards set ["vehicles", _vehicleRewards]; };
if (_specialRewards isNotEqualTo []) then { _rewards set ["special", _specialRewards]; };
[_taskID, _rewards] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_companyFunds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
if (_endSuccess) then { "EveryoneWon" call BFUNC(endMissionServer); };
};
_task call ["runLoop", []];

View File

@ -1,141 +1,56 @@
#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Registers an hvt task
*
* Arguments:
* 0: ID of the task <STRING>
* 1: Amount of HVTs KIA to fail the task <NUMBER>
* 2: Amount of HVTs Captured or KIA to complete the task <NUMBER>
* 3: Marker name for the extraction zone <STRING>
* 4: Amount of funds the company recieves if the task is successful <NUMBER> (default: 0)
* 5: Amount of rating the company and player lose if the task is failed <NUMBER> (default: 0)
* 6: Amount of rating the company and player recieve if the task is successful <NUMBER> (default: 0)
* 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 task fails <NUMBER> (default: 0, 0 = no limit)
* 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:
* ["task_name", 1, 1, "marker_name", 500000, -75, 300, [true, false], false, false] spawn forge_server_task_fnc_hvt;
* ["task_name", -1, 1, "", 500000, -75, 300, [false, true], false, false] spawn forge_server_task_fnc_hvt;
* ["task_name", 1, 1, "marker_name", 500000, -75, 300, [true, false], false, false, 45] spawn forge_server_task_fnc_hvt;
* ["task_name", -1, 1, "", 500000, -75, 300, [false, true], false, false, 45] spawn forge_server_task_fnc_hvt;
*
* Public: Yes
* Compatibility adapter for the object-style HVT task implementation.
*/
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]],
["_timeLimit", 0, [0]],
["_equipmentRewards", [], [[]]],
["_supplyRewards", [], [[]]],
["_weaponRewards", [], [[]]],
["_vehicleRewards", [], [[]]],
["_specialRewards", [], [[]]]
["_taskID", "", [""]],
["_limitFail", -1, [0]],
["_limitSuccess", -1, [0]],
["_extZone", "", [""]],
["_companyFunds", 0, [0]],
["_ratingFail", 0, [0]],
["_ratingSuccess", 0, [0]],
["_type", [true, false], [[]]],
["_endSuccess", false, [false]],
["_endFail", false, [false]],
["_timeLimit", 0, [0]],
["_equipmentRewards", [], [[]]],
["_supplyRewards", [], [[]]],
["_weaponRewards", [], [[]]],
["_vehicleRewards", [], [[]]],
["_specialRewards", [], [[]]]
];
private _capture = (_this select 7) select 0;
private _eliminate = (_this select 7) select 1;
private _result = 0;
private _hvts = [];
private _taskParams = createHashMapFromArray [
["limitFail", _limitFail],
["limitSuccess", _limitSuccess],
["extractionZone", _extZone],
["funds", _companyFunds],
["ratingFail", _ratingFail],
["ratingSuccess", _ratingSuccess],
["type", _type],
["captureHvt", _type param [0, true, [false]]],
["endSuccess", _endSuccess],
["endFail", _endFail],
["timeLimit", _timeLimit],
["useTaskStore", true]
];
waitUntil {
sleep 1;
_hvts = GVAR(TaskStore) call ["getTaskEntities", ["hvts", _taskID]];
GVAR(TaskStore) call ["trackParticipants", [_taskID, _hvts, _extZone, 250]];
count _hvts > 0
};
if (_equipmentRewards isNotEqualTo []) then { _taskParams set ["equipment", _equipmentRewards]; };
if (_supplyRewards isNotEqualTo []) then { _taskParams set ["supplies", _supplyRewards]; };
if (_weaponRewards isNotEqualTo []) then { _taskParams set ["weapons", _weaponRewards]; };
if (_vehicleRewards isNotEqualTo []) then { _taskParams set ["vehicles", _vehicleRewards]; };
if (_specialRewards isNotEqualTo []) then { _taskParams set ["special", _specialRewards]; };
_hvts = GVAR(TaskStore) call ["getTaskEntities", ["hvts", _taskID]];
private _requiredHvts = if (_limitSuccess < 0) then { count _hvts } else { _limitSuccess };
private _maxHvtLosses = if (_limitFail < 0) then { count _hvts } else { _limitFail };
private _task = createHashMapObject [
GVAR(HVTTaskBaseClass),
[
_taskID,
createHashMapFromArray [["hvts", GVAR(TaskStore) call ["getTaskEntities", ["hvts", _taskID]]]],
_taskParams
]
];
if (_timeLimit isNotEqualTo 0) then {
waitUntil {
sleep 1;
GVAR(TaskStore) call ["isTaskAccepted", [_taskID]]
};
};
private _startTime = if (_timeLimit isNotEqualTo 0) then { floor(time) } else { nil };
waitUntil {
sleep 1;
GVAR(TaskStore) call ["trackParticipants", [_taskID, _hvts, _extZone, 250]];
private _hvtsKilled = ({ !alive _x } count _hvts);
private _hvtsInZone = ({ _x inArea _extZone } count _hvts);
private _captureSucceeded = _capture && { _hvtsInZone >= _requiredHvts } && { _hvtsKilled < _maxHvtLosses };
private _eliminateSucceeded = _eliminate && { _hvtsKilled >= _requiredHvts };
if (_timeLimit isNotEqualTo 0) then {
private _timeExpired = (floor time - _startTime >= _timeLimit);
if (_capture && { _hvtsKilled >= _maxHvtLosses }) then { _result = 1; };
if (_capture && { !_captureSucceeded } && { _timeExpired }) then { _result = 1; };
if (_eliminate && { !_eliminateSucceeded } && { _timeExpired }) then { _result = 1; };
(_result == 1) or _captureSucceeded or _eliminateSucceeded
} else {
if (_capture && { _hvtsKilled >= _maxHvtLosses }) then { _result = 1; };
(_result == 1) or _captureSucceeded or _eliminateSucceeded
};
};
if (_result == 1) then {
{ deleteVehicle _x } forEach _hvts;
[_taskID, "FAILED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "failed"]];
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
if (_endFail) then { "EveryoneLost" call BFUNC(endMissionServer); };
} else {
{ deleteVehicle _x } forEach _hvts;
private _rewards = createHashMap;
_rewards set ["funds", _companyFunds];
if (_equipmentRewards isNotEqualTo []) then { _rewards set ["equipment", _equipmentRewards]; };
if (_supplyRewards isNotEqualTo []) then { _rewards set ["supplies", _supplyRewards]; };
if (_weaponRewards isNotEqualTo []) then { _rewards set ["weapons", _weaponRewards]; };
if (_vehicleRewards isNotEqualTo []) then { _rewards set ["vehicles", _vehicleRewards]; };
if (_specialRewards isNotEqualTo []) then { _rewards set ["special", _specialRewards]; };
[_taskID, _rewards] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_companyFunds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
if (_endSuccess) then { "EveryoneWon" call BFUNC(endMissionServer); };
};
_task call ["runLoop", []];

View File

@ -574,11 +574,29 @@ GVAR(TaskStore) = createHashMapObject [[
private _participantSnapshots = +(_participantRegistry getOrDefault [_taskID, createHashMap]);
if (_participantSnapshots isEqualTo createHashMap) exitWith { false };
{
private _player = [_x] call EFUNC(common,getPlayer);
if (isNull _player) then { continue; };
[CRPC(notifications,recieveNotification), [_type, _title, _message], _player] call CFUNC(targetEvent);
} forEach (keys _participantSnapshots);
private _participantUids = keys _participantSnapshots;
if (_participantUids isEqualTo []) exitWith { false };
if (isNil QEGVAR(common,EventBus)) exitWith {
{
private _player = [_x] call EFUNC(common,getPlayer);
if (isNull _player) then { continue; };
[CRPC(notifications,recieveNotification), [_type, _title, _message], _player] call CFUNC(targetEvent);
} forEach _participantUids;
true
};
EGVAR(common,EventBus) call ["emit", [
"task.notification.requested",
createHashMapFromArray [
["taskID", _taskID],
["notificationType", _type],
["title", _title],
["message", _message],
["participantUids", _participantUids]
],
createHashMapFromArray [["source", "task"]]
]];
true
}],
@ -586,9 +604,6 @@ GVAR(TaskStore) = createHashMapObject [[
params [["_taskID", "", [""]]];
if (_taskID isEqualTo "") exitWith { false };
if !(isNil QGVAR(MissionManager)) then {
GVAR(MissionManager) call ["completeMission", [_taskID]];
};
_self call ["emitTaskLifecycleEvent", ["task.cleared", _taskID, "cleared", createHashMap]];
@ -607,6 +622,22 @@ GVAR(TaskStore) = createHashMapObject [[
["applyRatingOutcome", compileFinal {
params [["_taskID", "", [""]], ["_delta", 0, [0]]];
private _emitRatingEvent = {
params [["_eventName", "", [""]], ["_payload", createHashMap, [createHashMap]]];
if (_eventName isEqualTo "" || { isNil QEGVAR(common,EventBus) }) exitWith { createHashMap };
private _eventPayload = +_payload;
_eventPayload set ["taskID", _taskID];
_eventPayload set ["ratingDelta", _delta];
EGVAR(common,EventBus) call ["emit", [
_eventName,
_eventPayload,
createHashMapFromArray [["source", "task"]]
]]
};
private _result = createHashMapFromArray [
["participantUids", []],
["orgIds", []],
@ -640,7 +671,19 @@ GVAR(TaskStore) = createHashMapObject [[
};
};
};
if (_participantUids isEqualTo []) exitWith { _result };
if (_participantUids isEqualTo []) exitWith {
_result set ["success", false];
_result set ["message", "No task participants were available for rating outcome."];
["task.rating.failed", createHashMapFromArray [
["participantUids", []],
["orgIds", []],
["contributions", createHashMap],
["mutationFailures", []],
["persistenceFailures", []],
["message", _result get "message"]
]] call _emitRatingEvent;
_result
};
private _orgIds = [];
private _contributions = createHashMap;
@ -660,6 +703,16 @@ GVAR(TaskStore) = createHashMapObject [[
};
if (_totalContribution <= 0) exitWith {
_result set ["success", false];
_result set ["message", "No eligible participant contribution was available for rating outcome."];
["task.rating.failed", createHashMapFromArray [
["participantUids", +_participantUids],
["orgIds", +_orgIds],
["contributions", +_contributions],
["mutationFailures", []],
["persistenceFailures", []],
["message", _result get "message"]
]] call _emitRatingEvent;
_self call ["clearTask", [_taskID]];
_result
};
@ -696,7 +749,19 @@ GVAR(TaskStore) = createHashMapObject [[
if !(_patch isEqualType createHashMap) then { continue; };
if (_patch isEqualTo createHashMap) then { continue; };
EGVAR(bank,BankMessenger) call ["sendAccountSync", [_uid, _patch]];
if (isNil QEGVAR(common,EventBus)) then {
EGVAR(bank,BankMessenger) call ["sendAccountSync", [_uid, _patch]];
} else {
EGVAR(common,EventBus) call ["emit", [
"bank.account.sync.requested",
createHashMapFromArray [
["uid", _uid],
["account", +_patch]
],
createHashMapFromArray [["source", "task"]]
]];
};
if ((EGVAR(bank,BankStore) call ["save", [_uid]]) isEqualTo createHashMap) then {
_persistenceFailures pushBackUnique format ["bank:%1", _uid];
["ERROR", format ["Task %1 updated bank earnings for %2, but durable save failed.", _taskID, _uid]] call EFUNC(common,log);
@ -724,11 +789,23 @@ GVAR(TaskStore) = createHashMapObject [[
if (_updatedOrg isNotEqualTo createHashMap) then {
private _patch = createHashMapFromArray [["reputation", _nextReputation]];
private _memberUids = _rewardContext getOrDefault ["memberUids", []];
{
private _player = [_x] call EFUNC(common,getPlayer);
if (isNull _player) then { continue; };
[CRPC(org,responseSyncOrg), [_patch], _player] call CFUNC(targetEvent);
} forEach _memberUids;
if (isNil QEGVAR(common,EventBus)) then {
{
private _player = [_x] call EFUNC(common,getPlayer);
if (isNull _player) then { continue; };
[CRPC(org,responseSyncOrg), [_patch], _player] call CFUNC(targetEvent);
} forEach _memberUids;
} else {
EGVAR(common,EventBus) call ["emit", [
"org.sync.requested",
createHashMapFromArray [
["orgID", _ownerOrgID],
["memberUids", +_memberUids],
["patch", +_patch]
],
createHashMapFromArray [["source", "task"]]
]];
};
_orgIds = [_ownerOrgID];
if ((EGVAR(org,OrgStore) call ["saveById", [_ownerOrgID]]) isEqualTo createHashMap) then {
@ -758,6 +835,17 @@ GVAR(TaskStore) = createHashMapObject [[
};
_result set ["message", _messageParts joinString "; "];
};
private _eventName = ["task.rating.failed", "task.rating.applied"] select (_result getOrDefault ["success", false]);
[_eventName, createHashMapFromArray [
["participantUids", +(_result getOrDefault ["participantUids", []])],
["orgIds", +(_result getOrDefault ["orgIds", []])],
["contributions", +(_result getOrDefault ["contributions", createHashMap])],
["mutationFailures", +(_result getOrDefault ["mutationFailures", []])],
["persistenceFailures", +(_result getOrDefault ["persistenceFailures", []])],
["message", _result getOrDefault ["message", ""]]
]] call _emitRatingEvent;
_result
}]
]];

View File

@ -1,41 +1,22 @@
#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Assigns cargo to a task for delivery
* Assigns cargo to a task for delivery.
*
* Arguments:
* 0: Object to convert to delivery cargo <OBJECT>
* 1: Task ID to assign the cargo to <STRING>
*
* Return Value:
* None
*
* Example:
* [_cargoObject, "delivery_1"] call forge_server_task_fnc_makeCargo;
*
* Public: Yes
* Public compatibility adapter around CargoEntityController.
*/
params [["_cargo", objNull, [objNull]], ["_taskID", "", [""]]];
["INFO", format ["Make Cargo: %1", _this]] call EFUNC(common,log);
if (isNull _cargo) exitWith { ["ERROR", "Attempt to create cargo from null object"] call EFUNC(common,log); };
if (_taskID == "") exitWith { ["ERROR", "No task ID provided for cargo"] call EFUNC(common,log); };
if (isNull _cargo) exitWith { ["ERROR", "Attempt to create cargo from null object"] call EFUNC(common,log); false };
if (_taskID isEqualTo "") exitWith { ["ERROR", "No task ID provided for cargo"] call EFUNC(common,log); false };
SETPVAR(_cargo,assignedTask,_taskID);
GVAR(TaskStore) call ["registerTaskEntity", ["cargo", _taskID, _cargo]];
private _controller = createHashMapObject [
GVAR(CargoEntityController),
[_taskID, _cargo, createHashMap]
];
_cargo addEventHandler ["Dammaged", {
params ["_unit", "_hitSelection", "_damage", "_hitPartIndex", "_hitPoint", "_shooter", "_projectile"];
if (damage _unit >= 0.7) then {
private _taskID = GETVAR(_unit,assignedTask,"");
if (_taskID isEqualTo "") exitWith {};
if (_unit getVariable [QGVAR(cargoDamageWarned), false]) exitWith {};
_unit setVariable [QGVAR(cargoDamageWarned), true];
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Cargo for task %1 has been severely damaged.", _taskID]]];
};
}];
if !(_controller call ["registerTaskEntity", ["cargo"]]) exitWith { false };
_controller call ["watchDamage", []]

View File

@ -1,30 +1,23 @@
#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Assigns an AI unit to a task as a hvt
* Assigns an AI unit to a task as an HVT.
*
* Arguments:
* 0: The AI unit <OBJECT>
* 1: ID of the task <STRING>
*
* Return Value:
* None
*
* Example:
* [this, "task_name"] spawn forge_server_task_fnc_makeHVT;
*
* Public: Yes
* Public compatibility adapter around HVTEntityController.
*/
params [["_entity", objNull, [objNull, grpNull]], ["_taskID", "", [""]]];
if (isNull _entity) exitWith { ["ERROR", "Attempt to create entity from null object"] call EFUNC(common,log); };
if (_taskID == "") exitWith { ["ERROR", "No task ID provided for entity"] call EFUNC(common,log); };
if (isNull _entity) exitWith { ["ERROR", "Attempt to create entity from null object"] call EFUNC(common,log); false };
if (_taskID isEqualTo "") exitWith { ["ERROR", "No task ID provided for entity"] call EFUNC(common,log); false };
["INFO", format ["Make HVT: %1", _this]] call EFUNC(common,log);
SETVAR(_entity,assignedTask,_taskID);
GVAR(TaskStore) call ["registerTaskEntity", ["hvts", _taskID, _entity]];
private _controller = createHashMapObject [
GVAR(HVTEntityController),
[_taskID, _entity, createHashMap]
];
if (alive _entity) then { [_entity, "hvt"] spawn FUNC(heartBeat); };
_controller call ["registerTaskEntity", ["hvts"]];
true

View File

@ -1,35 +1,24 @@
#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Assigns an AI unit to a task as a hostage
* Assigns an AI unit to a task as a hostage.
*
* Arguments:
* 0: The AI unit <OBJECT>
* 1: ID of the task <STRING>
*
* Return Value:
* None
*
* Example:
* [this, "task_name"] spawn forge_server_task_fnc_makeHostage;
*
* Public: Yes
* Public compatibility adapter around HostageEntityController. The hostage
* task instance owns the rescue loop, so this helper only registers and
* applies initial state.
*/
params [["_entity", objNull, [objNull, grpNull]], ["_taskID", "", [""]]];
if (isNull _entity) exitWith { ["ERROR", "Attempt to create entity from null object"] call EFUNC(common,log); };
if (_taskID == "") exitWith { ["ERROR", "No task ID provided for entity"] call EFUNC(common,log); };
if (isNull _entity) exitWith { ["ERROR", "Attempt to create entity from null object"] call EFUNC(common,log); false };
if (_taskID isEqualTo "") exitWith { ["ERROR", "No task ID provided for entity"] call EFUNC(common,log); false };
["INFO", format ["Make Hostage: %1", _this]] call EFUNC(common,log);
SETVAR(_entity,assignedTask,_taskID);
GVAR(TaskStore) call ["registerTaskEntity", ["hostages", _taskID, _entity]];
private _controller = createHashMapObject [
GVAR(HostageEntityController),
[_taskID, _entity, createHashMap]
];
if (alive _entity) then {
_entity setCaptive true;
_entity enableAIFeature ["MOVE", false];
[_entity, "hostage"] spawn FUNC(heartBeat);
};
if !(_controller call ["registerTaskEntity", ["hostages"]]) exitWith { false };
_controller call ["applyInitialState", []]

View File

@ -1,32 +1,26 @@
#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Assigns an IED to a task and starts its required countdown timer
* Assigns an IED to a task and starts its required countdown timer.
*
* Arguments:
* 0: The object <OBJECT>
* 1: ID of the task <STRING>
* 2: Countdown timer in seconds <NUMBER> (must be greater than 0)
*
* Return Value:
* None
*
* Example:
* [this, "task_name", 30] spawn forge_server_task_fnc_makeIED;
*
* Public: Yes
* Public compatibility adapter around IEDEntityController.
*/
params [["_entity", objNull, [objNull]], ["_taskID", "", [""]], ["_time", 0, [0]]];
if (isNull _entity) exitWith { ["ERROR", "Attempt to create entity from null object"] call EFUNC(common,log); };
if (_taskID == "") exitWith { ["ERROR", "No task ID provided for entity"] call EFUNC(common,log); };
if (_time <= 0) exitWith { ["ERROR", "Invalid time provided for IED"] call EFUNC(common,log); };
if (isNull _entity) exitWith { ["ERROR", "Attempt to create entity from null object"] call EFUNC(common,log); false };
if (_taskID isEqualTo "") exitWith { ["ERROR", "No task ID provided for entity"] call EFUNC(common,log); false };
if (_time <= 0) exitWith { ["ERROR", "Invalid time provided for IED"] call EFUNC(common,log); false };
["INFO", format ["Make IED: %1", _this]] call EFUNC(common,log);
SETPVAR(_entity,assignedTask,_taskID);
GVAR(TaskStore) call ["registerTaskEntity", ["ieds", _taskID, _entity]];
_entity setVariable [QGVAR(iedCountdown), _time, true];
if (alive _entity) then { [_entity, "ied", _time] spawn FUNC(heartBeat); };
private _controller = createHashMapObject [
GVAR(IEDEntityController),
[_taskID, _entity, createHashMapFromArray [["countdown", _time]]]
];
_controller call ["registerTaskEntity", ["ieds"]];
true

View File

@ -1,28 +1,21 @@
#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Assigns an object to a task as a protected target
* Assigns an object to a task as a protected target.
*
* Arguments:
* 0: The object <OBJECT>
* 1: ID of the task <STRING>
*
* Return Value:
* None
*
* Example:
* [this, "task_name"] spawn forge_server_task_fnc_makeObject;
*
* Public: Yes
* Public compatibility adapter around ProtectedEntityController.
*/
params [["_entity", objNull, [objNull]], ["_taskID", "", [""]]];
if (isNull _entity) exitWith { ["ERROR", "Attempt to create entity from null object"] call EFUNC(common,log); };
if (_taskID == "") exitWith { ["ERROR", "No task ID provided for entity"] call EFUNC(common,log); };
if (isNull _entity) exitWith { ["ERROR", "Attempt to create entity from null object"] call EFUNC(common,log); false };
if (_taskID isEqualTo "") exitWith { ["ERROR", "No task ID provided for entity"] call EFUNC(common,log); false };
["INFO", format ["Make Object: %1", _this]] call EFUNC(common,log);
SETPVAR(_entity,assignedTask,_taskID);
GVAR(TaskStore) call ["registerTaskEntity", ["entities", _taskID, _entity]];
private _controller = createHashMapObject [
GVAR(ProtectedEntityController),
[_taskID, _entity, createHashMap]
];
_controller call ["registerTaskEntity", ["entities"]]

View File

@ -1,28 +1,21 @@
#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Assigns an AI unit to a task as a shooter
* Assigns an AI unit to a task as a shooter.
*
* Arguments:
* 0: The AI unit <OBJECT>
* 1: ID of the task <STRING>
*
* Return Value:
* None
*
* Example:
* [this, "task_name"] spawn forge_server_task_fnc_makeShooter;
*
* Public: Yes
* Public compatibility adapter around ShooterEntityController.
*/
params [["_entity", objNull, [objNull, grpNull]], ["_taskID", "", [""]]];
if (isNull _entity) exitWith { ["ERROR", "Attempt to create entity from null object"] call EFUNC(common,log); };
if (_taskID == "") exitWith { ["ERROR", "No task ID provided for entity"] call EFUNC(common,log); };
if (isNull _entity) exitWith { ["ERROR", "Attempt to create entity from null object"] call EFUNC(common,log); false };
if (_taskID isEqualTo "") exitWith { ["ERROR", "No task ID provided for entity"] call EFUNC(common,log); false };
["INFO", format ["Make Shooter: %1", _this]] call EFUNC(common,log);
SETVAR(_entity,assignedTask,_taskID);
GVAR(TaskStore) call ["registerTaskEntity", ["shooters", _taskID, _entity]];
private _controller = createHashMapObject [
GVAR(ShooterEntityController),
[_taskID, _entity, createHashMap]
];
_controller call ["registerTaskEntity", ["shooters"]]

View File

@ -1,28 +1,21 @@
#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Assigns an object to a task as a target
* Assigns an object to a task as a target.
*
* Arguments:
* 0: The object <OBJECT>
* 1: ID of the task <STRING>
*
* Return Value:
* None
*
* Example:
* [this, "task_name"] spawn forge_server_task_fnc_makeTarget;
*
* Public: Yes
* Public compatibility adapter around TargetEntityController.
*/
params [["_entity", objNull, [objNull, grpNull]], ["_taskID", "", [""]]];
if (isNull _entity) exitWith { ["ERROR", "Attempt to create entity from null object"] call EFUNC(common,log); };
if (_taskID == "") exitWith { ["ERROR", "No task ID provided for entity"] call EFUNC(common,log); };
if (isNull _entity) exitWith { ["ERROR", "Attempt to create entity from null object"] call EFUNC(common,log); false };
if (_taskID isEqualTo "") exitWith { ["ERROR", "No task ID provided for entity"] call EFUNC(common,log); false };
["INFO", format ["Make Target: %1", _this]] call EFUNC(common,log);
SETVAR(_entity,assignedTask,_taskID);
GVAR(TaskStore) call ["registerTaskEntity", ["targets", _taskID, _entity]];
private _controller = createHashMapObject [
GVAR(TargetEntityController),
[_taskID, _entity, createHashMap]
];
_controller call ["registerTaskEntity", ["targets"]]

View File

@ -131,6 +131,26 @@ GVAR(MissionManagerBaseClass) = compileFinal createHashMapFromArray [
];
GVAR(MissionManager) = createHashMapObject [GVAR(MissionManagerBaseClass)];
if (isNil QEGVAR(common,EventBus)) then { call EFUNC(common,eventBus); };
if (isNil QGVAR(MissionManagerTaskEventTokens)) then {
private _handleTaskCleared = {
params ["_event"];
private _taskID = _event getOrDefault ["taskID", ""];
if (_taskID isEqualTo "") exitWith {};
if (isNil QGVAR(MissionManager)) exitWith {};
if (GVAR(MissionManager) call ["completeMission", [_taskID]]) then {
["INFO", format ["Mission manager completed generated mission from event. TaskID=%1", _taskID]] call EFUNC(common,log);
};
};
GVAR(MissionManagerTaskEventTokens) = [
EGVAR(common,EventBus) call ["on", ["task.cleared", _handleTaskCleared, "task.missionManager.cleanup"]]
];
};
if (GVAR(enableGenerator)) then {
GVAR(MissionManagerPFH) = [{
GVAR(MissionManager) call ["cleanupCompletedMissions", []];

View File

@ -39,15 +39,39 @@ if (_taskID == "") exitWith {
false
};
private _emitRewardEvent = {
params [["_eventName", "", [""]], ["_payload", createHashMap, [createHashMap]]];
if (_eventName isEqualTo "" || { isNil QEGVAR(common,EventBus) }) exitWith { createHashMap };
private _eventPayload = +_payload;
_eventPayload set ["taskID", _taskID];
_eventPayload set ["rewardData", +_rewards];
EGVAR(common,EventBus) call ["emit", [
_eventName,
_eventPayload,
createHashMapFromArray [["source", "task"]]
]]
};
private _rewardContext = GVAR(TaskStore) call ["resolveRewardContext", [_taskID]];
private _requesterUid = _rewardContext getOrDefault ["requesterUid", ""];
private _orgID = _rewardContext getOrDefault ["orgID", ""];
private _memberUids = _rewardContext getOrDefault ["memberUids", []];
if (_orgID isEqualTo "") exitWith {
["ERROR", format ["No organization reward context found for task %1.", _taskID]] call EFUNC(common,log);
["task.reward.failed", createHashMapFromArray [
["rewardContext", _rewardContext],
["failureMessages", ["missing organization reward context"]]
]] call _emitRewardEvent;
false
};
["task.reward.requested", createHashMapFromArray [
["rewardContext", _rewardContext]
]] call _emitRewardEvent;
private _success = true;
private _funds = _rewards getOrDefault ["funds", 0];
private _rewardMessages = [];
@ -78,22 +102,48 @@ private _notifyMembers = {
params [["_type", "info", [""]], ["_title", "Tasks", [""]], ["_message", "", [""]]];
if (_message isEqualTo "") exitWith {};
{
private _player = [_x] call EFUNC(common,getPlayer);
if (isNull _player) then { continue; };
[CRPC(notifications,recieveNotification), [_type, _title, _message], _player] call CFUNC(targetEvent);
} forEach _memberUids;
if (isNil QEGVAR(common,EventBus)) exitWith {
{
private _player = [_x] call EFUNC(common,getPlayer);
if (isNull _player) then { continue; };
[CRPC(notifications,recieveNotification), [_type, _title, _message], _player] call CFUNC(targetEvent);
} forEach _memberUids;
};
EGVAR(common,EventBus) call ["emit", [
"task.reward.notification.requested",
createHashMapFromArray [
["taskID", _taskID],
["notificationType", _type],
["title", _title],
["message", _message],
["memberUids", +_memberUids]
],
createHashMapFromArray [["source", "task"]]
]];
};
private _syncOrgPatch = {
params [["_patch", createHashMap, [createHashMap]]];
if (_patch isEqualTo createHashMap) exitWith {};
{
private _player = [_x] call EFUNC(common,getPlayer);
if (isNull _player) then { continue; };
[CRPC(org,responseSyncOrg), [_patch], _player] call CFUNC(targetEvent);
} forEach _memberUids;
if (isNil QEGVAR(common,EventBus)) exitWith {
{
private _player = [_x] call EFUNC(common,getPlayer);
if (isNull _player) then { continue; };
[CRPC(org,responseSyncOrg), [_patch], _player] call CFUNC(targetEvent);
} forEach _memberUids;
};
EGVAR(common,EventBus) call ["emit", [
"org.sync.requested",
createHashMapFromArray [
["orgID", _orgID],
["memberUids", +_memberUids],
["patch", +_patch]
],
createHashMapFromArray [["source", "task"]]
]];
};
if (_funds > 0) then {
@ -227,6 +277,11 @@ if (_success) then {
["INFO", _message] call EFUNC(common,log);
["success", "Tasks", _message] call _notifyMembers;
["task.reward.applied", createHashMapFromArray [
["rewardContext", _rewardContext],
["rewardMessages", +_rewardMessages],
["message", _message]
]] call _emitRewardEvent;
} else {
private _warningMessage = format ["Task %1 completed, but one or more org rewards failed to apply.", _taskID];
if (_failureMessages isNotEqualTo []) then {
@ -234,6 +289,12 @@ if (_success) then {
};
["warning", "Tasks", _warningMessage] call _notifyMembers;
["task.reward.failed", createHashMapFromArray [
["rewardContext", _rewardContext],
["rewardMessages", +_rewardMessages],
["failureMessages", +_failureMessages],
["message", _warningMessage]
]] call _emitRewardEvent;
};
_success

View File

@ -0,0 +1,62 @@
# Task Objects
This folder documents the active `createHashMapObject` task instances and entity
controllers. Their source lives under `functions/objects/`, and each class is
initialized directly from `XEH_preInit.sqf`.
Current task objects:
- `TaskInstanceBaseClass`
- `EntityControllerBaseClass`
- `TargetEntityController`
- `ShooterEntityController`
- `AttackTaskBaseClass`
- `HostageTaskBaseClass`
- `HostageEntityController`
- `HVTEntityController`
- `CargoEntityController`
- `ProtectedEntityController`
- `IEDEntityController`
- `DefenseEnemyController`
- `DefuseTaskBaseClass`
- `DestroyTaskBaseClass`
- `DeliveryTaskBaseClass`
- `HVTTaskBaseClass`
- `DefendTaskBaseClass`
Source entry points:
- [fnc_TaskInstanceBaseClass.sqf](./fnc_TaskInstanceBaseClass.sqf)
- [fnc_EntityControllerBaseClass.sqf](./fnc_EntityControllerBaseClass.sqf)
- [fnc_TargetEntityController.sqf](./fnc_TargetEntityController.sqf)
- [fnc_ShooterEntityController.sqf](./fnc_ShooterEntityController.sqf)
- [fnc_AttackTaskBaseClass.sqf](./fnc_AttackTaskBaseClass.sqf)
- [fnc_HostageTaskBaseClass.sqf](./fnc_HostageTaskBaseClass.sqf)
- [fnc_HostageEntityController.sqf](./fnc_HostageEntityController.sqf)
- [fnc_HVTEntityController.sqf](./fnc_HVTEntityController.sqf)
- [fnc_CargoEntityController.sqf](./fnc_CargoEntityController.sqf)
- [fnc_ProtectedEntityController.sqf](./fnc_ProtectedEntityController.sqf)
- [fnc_IEDEntityController.sqf](./fnc_IEDEntityController.sqf)
- [fnc_DefenseEnemyController.sqf](./fnc_DefenseEnemyController.sqf)
- [fnc_DefuseTaskBaseClass.sqf](./fnc_DefuseTaskBaseClass.sqf)
- [fnc_DestroyTaskBaseClass.sqf](./fnc_DestroyTaskBaseClass.sqf)
- [fnc_DeliveryTaskBaseClass.sqf](./fnc_DeliveryTaskBaseClass.sqf)
- [fnc_HVTTaskBaseClass.sqf](./fnc_HVTTaskBaseClass.sqf)
- [fnc_DefendTaskBaseClass.sqf](./fnc_DefendTaskBaseClass.sqf)
Purpose:
- keep per-task instance state in task objects
- keep per-entity behavior in controller objects
- separate state ownership from long procedural function flows
- keep shared lifecycle and reward initialization in `TaskInstanceBaseClass`
- so concrete task objects only define task-specific state
- keep heartbeat-style AI/object behavior in separate entity controllers instead
of mixing it into task outcome loops
Important design choice:
- these objects use explicit `markSucceeded`, `markFailed`, and `cleanup`
methods instead of relying on `#delete`
- task loops that use `sleep` or `waitUntil` with `sleep` must be started from
scheduled code, typically via `spawn`
That is intentional. `createHashMapObject` destructor timing is reference-based,
so `#delete` is not a good primitive for mission-critical task completion or
reward flow.

View File

@ -1,13 +1,13 @@
#include "..\script_component.hpp"
/*
* Review-only prototype attack task class.
* Object-style attack task class.
*
* Example:
* call compile preprocessFileLineNumbers
* "\forge\forge_server\addons\task\prototypes\TaskInstanceBaseClass.sqf";
* "\forge\forge_server\addons\task\objects\TaskInstanceBaseClass.sqf";
* call compile preprocessFileLineNumbers
* "\forge\forge_server\addons\task\prototypes\AttackTaskBaseClass.sqf";
* "\forge\forge_server\addons\task\objects\AttackTaskBaseClass.sqf";
*
* private _task = createHashMapObject [
* GVAR(AttackTaskBaseClass),
@ -203,8 +203,8 @@ GVAR(AttackTaskBaseClass) = createHashMapFromArray [
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
};
@ -214,14 +214,14 @@ GVAR(AttackTaskBaseClass) = createHashMapFromArray [
{ deleteVehicle _x } forEach _targets;
if (_useTaskStore) then {
[_taskID, _rewardData] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
[_taskID, _rewardData] call FUNC(handleTaskRewards);
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
};

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp"
/*
* Review-only prototype delivery cargo entity controller.
* Object-style delivery cargo entity controller.
*/
#pragma hemtt ignore_variables ["_self"]
@ -23,7 +23,7 @@ GVAR(CargoEntityController) = createHashMapFromArray [
["#delete", compileFinal {
_self call ["cleanup", []];
}],
["installDamageWarningHandler", compileFinal {
["watchDamage", compileFinal {
private _entity = _self getOrDefault ["entity", objNull];
if (isNull _entity) exitWith { false };
@ -64,7 +64,7 @@ GVAR(CargoEntityController) = createHashMapFromArray [
false
};
_self call ["installDamageWarningHandler", []];
_self call ["watchDamage", []];
_self call ["markActive", []];
waitUntil {

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp"
/*
* Review-only prototype defend task class.
* Object-style defend task class.
*/
#pragma hemtt ignore_variables ["_self"]
@ -149,8 +149,8 @@ GVAR(DefendTaskBaseClass) = createHashMapFromArray [
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
};
@ -165,14 +165,14 @@ GVAR(DefendTaskBaseClass) = createHashMapFromArray [
private _endSuccess = (_self getOrDefault ["taskParams", createHashMap]) getOrDefault ["endSuccess", false];
if (_self getOrDefault ["useTaskStore", false]) then {
[_taskID, _rewardData] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
[_taskID, _rewardData] call FUNC(handleTaskRewards);
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
};

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp"
/*
* Review-only prototype defense enemy controller.
* Object-style defense enemy controller.
*/
#pragma hemtt ignore_variables ["_self"]

View File

@ -1,13 +1,13 @@
#include "..\script_component.hpp"
/*
* Review-only prototype defuse task class.
* Object-style defuse task class.
*
* Example:
* call compile preprocessFileLineNumbers
* "\forge\forge_server\addons\task\prototypes\TaskInstanceBaseClass.sqf";
* "\forge\forge_server\addons\task\objects\TaskInstanceBaseClass.sqf";
* call compile preprocessFileLineNumbers
* "\forge\forge_server\addons\task\prototypes\DefuseTaskBaseClass.sqf";
* "\forge\forge_server\addons\task\objects\DefuseTaskBaseClass.sqf";
*
* private _task = createHashMapObject [
* GVAR(DefuseTaskBaseClass),
@ -64,12 +64,89 @@ GVAR(DefuseTaskBaseClass) = createHashMapFromArray [
_self set ["iedTimer", _taskParams getOrDefault ["iedTimer", 300]];
_self set ["useTaskStore", _taskParams getOrDefault ["useTaskStore", false]];
_self set ["localDefuseCount", _taskParams getOrDefault ["localDefuseCount", 0]];
_self set ["iedControllers", []];
_self call ["registerInstance", []];
}],
["#delete", compileFinal {
_self call ["unregisterInstance", []];
}],
["refreshEntitiesFromStore", compileFinal {
private _taskID = _self getOrDefault ["taskID", ""];
if (_taskID isEqualTo "" || { !(_self getOrDefault ["useTaskStore", false]) }) exitWith { false };
private _ieds = GVAR(TaskStore) call ["getTaskEntities", ["ieds", _taskID]];
private _protected = GVAR(TaskStore) call ["getTaskEntities", ["entities", _taskID]];
_self set ["ieds", _ieds];
_self set ["protected", _protected];
private _taskParams = _self getOrDefault ["taskParams", createHashMap];
private _requiredDefusals = _taskParams getOrDefault ["limitSuccess", -1];
if (_requiredDefusals < 0) then { _requiredDefusals = count _ieds; };
private _maxProtectedLosses = _taskParams getOrDefault ["limitFail", -1];
if (_maxProtectedLosses < 0) then { _maxProtectedLosses = count _protected; };
_self set ["requiredDefusals", _requiredDefusals];
_self set ["maxProtectedLosses", _maxProtectedLosses];
true
}],
["trackParticipants", compileFinal {
private _taskID = _self getOrDefault ["taskID", ""];
if (_taskID isEqualTo "" || { !(_self getOrDefault ["useTaskStore", false]) }) exitWith { false };
GVAR(TaskStore) call ["trackParticipants", [_taskID, (_self getOrDefault ["ieds", []]) + (_self getOrDefault ["protected", []]), "", 250]];
true
}],
["waitForRequiredEntities", compileFinal {
if (_self getOrDefault ["useTaskStore", false]) then {
waitUntil {
sleep 1;
_self call ["refreshEntitiesFromStore", []];
count (_self getOrDefault ["ieds", []]) > 0
};
} else {
waitUntil {
sleep 1;
count (_self getOrDefault ["ieds", []]) > 0
};
};
true
}],
["startIedControllers", compileFinal {
if ((_self getOrDefault ["iedControllers", []]) isNotEqualTo []) exitWith { true };
private _taskID = _self getOrDefault ["taskID", ""];
private _defaultCountdown = _self getOrDefault ["iedTimer", 300];
private _controllers = [];
{
if (!isNull _x) then {
private _countdown = _x getVariable [QGVAR(iedCountdown), _defaultCountdown];
private _controller = createHashMapObject [
GVAR(IEDEntityController),
[
_taskID,
_x,
createHashMapFromArray [
["countdown", _countdown],
["waitForAcceptance", true]
]
]
];
_controllers pushBack _controller;
[_controller] spawn {
params ["_controller"];
_controller call ["runLoop", []];
};
};
} forEach (_self getOrDefault ["ieds", []]);
_self set ["iedControllers", _controllers];
true
}],
["countProtectedDestroyed", compileFinal {
private _protected = _self getOrDefault ["protected", []];
{ !alive _x } count _protected
@ -120,8 +197,8 @@ GVAR(DefuseTaskBaseClass) = createHashMapFromArray [
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
};
@ -141,14 +218,14 @@ GVAR(DefuseTaskBaseClass) = createHashMapFromArray [
{ deleteVehicle _x } forEach _protected;
if (_self getOrDefault ["useTaskStore", false]) then {
[_taskID, _rewardData] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
[_taskID, _rewardData] call FUNC(handleTaskRewards);
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
};
@ -156,9 +233,12 @@ GVAR(DefuseTaskBaseClass) = createHashMapFromArray [
true
}],
["runLoop", compileFinal {
_self call ["waitForRequiredEntities", []];
_self call ["startIedControllers", []];
_self call ["markActive", []];
while { (_self call ["getStatus", []]) isEqualTo "active" } do {
_self call ["trackParticipants", []];
private _snapshot = _self call ["tick", []];
if (_snapshot getOrDefault ["shouldFail", false]) exitWith {

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp"
/*
* Review-only prototype delivery task class.
* Object-style delivery task class.
*/
#pragma hemtt ignore_variables ["_self"]
@ -140,8 +140,8 @@ GVAR(DeliveryTaskBaseClass) = createHashMapFromArray [
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
};
@ -159,14 +159,14 @@ GVAR(DeliveryTaskBaseClass) = createHashMapFromArray [
{ deleteVehicle _x } forEach _cargo;
if (_self getOrDefault ["useTaskStore", false]) then {
[_taskID, _rewardData] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
[_taskID, _rewardData] call FUNC(handleTaskRewards);
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
};

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp"
/*
* Review-only prototype destroy task class.
* Object-style destroy task class.
*/
#pragma hemtt ignore_variables ["_self"]
@ -120,8 +120,8 @@ GVAR(DestroyTaskBaseClass) = createHashMapFromArray [
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
};
@ -139,14 +139,14 @@ GVAR(DestroyTaskBaseClass) = createHashMapFromArray [
{ deleteVehicle _x } forEach _targets;
if (_self getOrDefault ["useTaskStore", false]) then {
[_taskID, _rewardData] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
[_taskID, _rewardData] call FUNC(handleTaskRewards);
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
};

View File

@ -1,11 +1,11 @@
#include "..\script_component.hpp"
/*
* Review-only prototype base class for object-based entity controllers.
* Object-style base class for object-based entity controllers.
*
* Example:
* call compile preprocessFileLineNumbers
* "\forge\forge_server\addons\task\prototypes\EntityControllerBaseClass.sqf";
* "\forge\forge_server\addons\task\objects\EntityControllerBaseClass.sqf";
*
* private _controller = createHashMapObject [
* GVAR(EntityControllerBaseClass),
@ -105,9 +105,9 @@ GVAR(EntityControllerBaseClass) = createHashMapFromArray [
private _registryKey = _self call ["getRegistryKey", []];
if (_registryKey isEqualTo "") exitWith { false };
private _registry = missionNamespace getVariable [QGVAR(PrototypeControllerInstances), createHashMap];
private _registry = missionNamespace getVariable [QGVAR(ObjectControllerInstances), createHashMap];
_registry set [_registryKey, _self];
missionNamespace setVariable [QGVAR(PrototypeControllerInstances), _registry];
missionNamespace setVariable [QGVAR(ObjectControllerInstances), _registry];
missionNamespace setVariable [_registryKey, _self];
true
}],
@ -115,7 +115,7 @@ GVAR(EntityControllerBaseClass) = createHashMapFromArray [
private _registryKey = _self call ["getRegistryKey", []];
if (_registryKey isEqualTo "") exitWith { false };
private _registry = missionNamespace getVariable [QGVAR(PrototypeControllerInstances), createHashMap];
private _registry = missionNamespace getVariable [QGVAR(ObjectControllerInstances), createHashMap];
_registry deleteAt _registryKey;
missionNamespace setVariable [_registryKey, nil];
true

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp"
/*
* Review-only prototype HVT entity controller.
* Object-style HVT entity controller.
*/
#pragma hemtt ignore_variables ["_self"]

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp"
/*
* Review-only prototype HVT task class.
* Object-style HVT task class.
*/
#pragma hemtt ignore_variables ["_self"]
@ -42,6 +42,7 @@ GVAR(HVTTaskBaseClass) = createHashMapFromArray [
_self set ["eliminate", _eliminate];
_self set ["timeLimit", _taskParams getOrDefault ["timeLimit", 0]];
_self set ["useTaskStore", _taskParams getOrDefault ["useTaskStore", false]];
_self set ["hvtControllers", []];
_self call ["registerInstance", []];
}],
@ -90,6 +91,30 @@ GVAR(HVTTaskBaseClass) = createHashMapFromArray [
_self set ["maxKilled", _maxKilled];
true
}],
["startHvtControllers", compileFinal {
if ((_self getOrDefault ["hvtControllers", []]) isNotEqualTo []) exitWith { true };
private _taskID = _self getOrDefault ["taskID", ""];
private _controllers = [];
{
if (!isNull _x) then {
private _controller = createHashMapObject [
GVAR(HVTEntityController),
[_taskID, _x, createHashMapFromArray [["captureRadius", 2]]]
];
_controllers pushBack _controller;
[_controller] spawn {
params ["_controller"];
_controller call ["runLoop", []];
};
};
} forEach (_self getOrDefault ["hvts", []]);
_self set ["hvtControllers", _controllers];
true
}],
["waitForAssignmentIfTimed", compileFinal {
private _timeLimit = _self getOrDefault ["timeLimit", 0];
private _taskID = _self getOrDefault ["taskID", ""];
@ -150,8 +175,8 @@ GVAR(HVTTaskBaseClass) = createHashMapFromArray [
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
};
@ -169,14 +194,14 @@ GVAR(HVTTaskBaseClass) = createHashMapFromArray [
{ deleteVehicle _x } forEach _hvts;
if (_self getOrDefault ["useTaskStore", false]) then {
[_taskID, _rewardData] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
[_taskID, _rewardData] call FUNC(handleTaskRewards);
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
};
@ -185,6 +210,7 @@ GVAR(HVTTaskBaseClass) = createHashMapFromArray [
}],
["runLoop", compileFinal {
_self call ["waitForRequiredEntities", []];
_self call ["startHvtControllers", []];
_self call ["waitForAssignmentIfTimed", []];
_self call ["markActive", []];

View File

@ -1,13 +1,13 @@
#include "..\script_component.hpp"
/*
* Review-only prototype hostage entity controller.
* Object-style hostage entity controller.
*
* Example:
* call compile preprocessFileLineNumbers
* "\forge\forge_server\addons\task\prototypes\EntityControllerBaseClass.sqf";
* "\forge\forge_server\addons\task\objects\EntityControllerBaseClass.sqf";
* call compile preprocessFileLineNumbers
* "\forge\forge_server\addons\task\prototypes\HostageEntityController.sqf";
* "\forge\forge_server\addons\task\objects\HostageEntityController.sqf";
*
* private _controller = createHashMapObject [
* GVAR(HostageEntityController),

View File

@ -1,13 +1,13 @@
#include "..\script_component.hpp"
/*
* Review-only prototype hostage task class.
* Object-style hostage task class.
*
* Example:
* call compile preprocessFileLineNumbers
* "\forge\forge_server\addons\task\prototypes\TaskInstanceBaseClass.sqf";
* "\forge\forge_server\addons\task\objects\TaskInstanceBaseClass.sqf";
* call compile preprocessFileLineNumbers
* "\forge\forge_server\addons\task\prototypes\HostageTaskBaseClass.sqf";
* "\forge\forge_server\addons\task\objects\HostageTaskBaseClass.sqf";
*
* private _task = createHashMapObject [
* GVAR(HostageTaskBaseClass),
@ -299,8 +299,8 @@ GVAR(HostageTaskBaseClass) = createHashMapFromArray [
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingFail]];
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "warning", "Tasks", format ["Task failed: %1 reputation", _ratingFail]]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
};
@ -321,13 +321,14 @@ GVAR(HostageTaskBaseClass) = createHashMapFromArray [
{ deleteVehicle _x } forEach _shooters;
if (_useTaskStore) then {
[_taskID, _rewardData] call FUNC(handleTaskRewards);
[_taskID, "SUCCEEDED"] call BFUNC(taskSetState);
GVAR(TaskStore) call ["setTaskStatus", [_taskID, "succeeded"]];
[_taskID, _rewardData] call FUNC(handleTaskRewards);
sleep 1;
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["applyRatingOutcome", [_taskID, _ratingSuccess]];
GVAR(TaskStore) call ["notifyParticipants", [_taskID, "success", "Tasks", format ["Task completed: %1 reputation, $%2 funds", _ratingSuccess, [_funds] call EFUNC(common,formatNumber)]]];
GVAR(TaskStore) call ["clearTask", [_taskID]];
};

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp"
/*
* Review-only prototype IED entity controller.
* Object-style IED entity controller.
*/
#pragma hemtt ignore_variables ["_self"]

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp"
/*
* Review-only prototype protected entity controller.
* Object-style protected entity controller.
*/
#pragma hemtt ignore_variables ["_self"]

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp"
/*
* Review-only prototype shooter entity controller.
* Object-style shooter entity controller.
*/
#pragma hemtt ignore_variables ["_self"]

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp"
/*
* Review-only prototype target entity controller.
* Object-style target entity controller.
*/
#pragma hemtt ignore_variables ["_self"]

View File

@ -1,11 +1,11 @@
#include "..\script_component.hpp"
/*
* Review-only prototype base class for object-based task instances.
* Object-style base class for object-based task instances.
*
* Example:
* call compile preprocessFileLineNumbers
* "\forge\forge_server\addons\task\prototypes\TaskInstanceBaseClass.sqf";
* "\forge\forge_server\addons\task\objects\TaskInstanceBaseClass.sqf";
*
* private _task = createHashMapObject [
* GVAR(TaskInstanceBaseClass),
@ -93,9 +93,9 @@ GVAR(TaskInstanceBaseClass) = createHashMapFromArray [
private _registryKey = _self call ["getRegistryKey", []];
if (_registryKey isEqualTo "") exitWith { false };
private _registry = missionNamespace getVariable [QGVAR(PrototypeTaskInstances), createHashMap];
private _registry = missionNamespace getVariable [QGVAR(ObjectTaskInstances), createHashMap];
_registry set [_registryKey, _self];
missionNamespace setVariable [QGVAR(PrototypeTaskInstances), _registry];
missionNamespace setVariable [QGVAR(ObjectTaskInstances), _registry];
missionNamespace setVariable [_registryKey, _self];
true
}],
@ -103,7 +103,7 @@ GVAR(TaskInstanceBaseClass) = createHashMapFromArray [
private _registryKey = _self call ["getRegistryKey", []];
if (_registryKey isEqualTo "") exitWith { false };
private _registry = missionNamespace getVariable [QGVAR(PrototypeTaskInstances), createHashMap];
private _registry = missionNamespace getVariable [QGVAR(ObjectTaskInstances), createHashMap];
_registry deleteAt _registryKey;
missionNamespace setVariable [_registryKey, nil];
true

View File

@ -1,66 +0,0 @@
# Task Object Prototypes
This folder contains review-only `createHashMapObject` prototypes for task
instances. Their source now lives under `functions/prototypes/`, and they are
loaded for review with `[] call forge_server_task_fnc_initPrototypes;`.
Current prototypes:
- `TaskInstanceBaseClass`
- `EntityControllerBaseClass`
- `TargetEntityController`
- `ShooterEntityController`
- `AttackTaskBaseClass`
- `HostageTaskBaseClass`
- `HostageEntityController`
- `HVTEntityController`
- `CargoEntityController`
- `ProtectedEntityController`
- `IEDEntityController`
- `DefenseEnemyController`
- `DefuseTaskBaseClass`
- `DestroyTaskBaseClass`
- `DeliveryTaskBaseClass`
- `HVTTaskBaseClass`
- `DefendTaskBaseClass`
Review entry points:
- [taskObjectPrototypes.sqf](./taskObjectPrototypes.sqf)
- [fnc_initPrototypes.sqf](../functions/prototypes/fnc_initPrototypes.sqf)
- [fnc_TaskInstanceBaseClass.sqf](../functions/prototypes/fnc_TaskInstanceBaseClass.sqf)
- [fnc_EntityControllerBaseClass.sqf](../functions/prototypes/fnc_EntityControllerBaseClass.sqf)
- [fnc_TargetEntityController.sqf](../functions/prototypes/fnc_TargetEntityController.sqf)
- [fnc_ShooterEntityController.sqf](../functions/prototypes/fnc_ShooterEntityController.sqf)
- [fnc_AttackTaskBaseClass.sqf](../functions/prototypes/fnc_AttackTaskBaseClass.sqf)
- [fnc_HostageTaskBaseClass.sqf](../functions/prototypes/fnc_HostageTaskBaseClass.sqf)
- [fnc_HostageEntityController.sqf](../functions/prototypes/fnc_HostageEntityController.sqf)
- [fnc_HVTEntityController.sqf](../functions/prototypes/fnc_HVTEntityController.sqf)
- [fnc_CargoEntityController.sqf](../functions/prototypes/fnc_CargoEntityController.sqf)
- [fnc_ProtectedEntityController.sqf](../functions/prototypes/fnc_ProtectedEntityController.sqf)
- [fnc_IEDEntityController.sqf](../functions/prototypes/fnc_IEDEntityController.sqf)
- [fnc_DefenseEnemyController.sqf](../functions/prototypes/fnc_DefenseEnemyController.sqf)
- [fnc_DefuseTaskBaseClass.sqf](../functions/prototypes/fnc_DefuseTaskBaseClass.sqf)
- [fnc_DestroyTaskBaseClass.sqf](../functions/prototypes/fnc_DestroyTaskBaseClass.sqf)
- [fnc_DeliveryTaskBaseClass.sqf](../functions/prototypes/fnc_DeliveryTaskBaseClass.sqf)
- [fnc_HVTTaskBaseClass.sqf](../functions/prototypes/fnc_HVTTaskBaseClass.sqf)
- [fnc_DefendTaskBaseClass.sqf](../functions/prototypes/fnc_DefendTaskBaseClass.sqf)
Purpose:
- show what per-task instance objects could look like
- show what per-entity heartbeat/controller objects could look like
- separate state ownership from the current long procedural functions
- avoid committing the live addon to a large refactor before the model is
reviewed
- keep shared lifecycle and reward initialization in `TaskInstanceBaseClass`
so concrete task prototypes only define task-specific state
- keep heartbeat-style AI/object behavior in separate entity controllers instead
of mixing it into task outcome loops
Important design choice:
- these prototypes use explicit `markSucceeded`, `markFailed`, and `cleanup`
methods instead of relying on `#delete`
- task loops that use `sleep` or `waitUntil` with `sleep` must be started from
scheduled code, typically via `spawn`
That is intentional. `createHashMapObject` destructor timing is reference-based,
so `#delete` is not a good primitive for mission-critical task completion or
reward flow.

View File

@ -1,64 +0,0 @@
#include "..\script_component.hpp"
/*
* Review-only prototype initializer for object-based task instances.
*
* Usage in debug/testing:
* private _prototypes = [] call FUNC(initPrototypes);
*
* private _task = createHashMapObject [
* _prototypes get "HostageTaskBaseClass",
* [
* "task_hostage_review",
* createHashMapFromArray [
* ["hostages", [hostage1, hostage2]],
* ["shooters", [shooter1, shooter2]]
* ],
* createHashMapFromArray [
* ["extractionZone", "hostage_extract"],
* ["limitSuccess", 2],
* ["limitFail", 1],
* ["execution", true],
* ["timeLimit", 900]
* ]
* ]
* ];
*/
[] call FUNC(TaskInstanceBaseClass);
[] call FUNC(EntityControllerBaseClass);
[] call FUNC(AttackTaskBaseClass);
[] call FUNC(HostageTaskBaseClass);
[] call FUNC(HostageEntityController);
[] call FUNC(TargetEntityController);
[] call FUNC(ShooterEntityController);
[] call FUNC(HVTEntityController);
[] call FUNC(CargoEntityController);
[] call FUNC(ProtectedEntityController);
[] call FUNC(IEDEntityController);
[] call FUNC(DefenseEnemyController);
[] call FUNC(DefuseTaskBaseClass);
[] call FUNC(DestroyTaskBaseClass);
[] call FUNC(DeliveryTaskBaseClass);
[] call FUNC(HVTTaskBaseClass);
[] call FUNC(DefendTaskBaseClass);
createHashMapFromArray [
["TaskInstanceBaseClass", GVAR(TaskInstanceBaseClass)],
["EntityControllerBaseClass", GVAR(EntityControllerBaseClass)],
["AttackTaskBaseClass", GVAR(AttackTaskBaseClass)],
["HostageTaskBaseClass", GVAR(HostageTaskBaseClass)],
["HostageEntityController", GVAR(HostageEntityController)],
["TargetEntityController", GVAR(TargetEntityController)],
["ShooterEntityController", GVAR(ShooterEntityController)],
["HVTEntityController", GVAR(HVTEntityController)],
["CargoEntityController", GVAR(CargoEntityController)],
["ProtectedEntityController", GVAR(ProtectedEntityController)],
["IEDEntityController", GVAR(IEDEntityController)],
["DefenseEnemyController", GVAR(DefenseEnemyController)],
["DefuseTaskBaseClass", GVAR(DefuseTaskBaseClass)],
["DestroyTaskBaseClass", GVAR(DestroyTaskBaseClass)],
["DeliveryTaskBaseClass", GVAR(DeliveryTaskBaseClass)],
["HVTTaskBaseClass", GVAR(HVTTaskBaseClass)],
["DefendTaskBaseClass", GVAR(DefendTaskBaseClass)]
]

View File

@ -3,3 +3,9 @@
[LSTRING(enableGenerator), LSTRING(enableGeneratorTooltip)],
_category, false, true
] call CBA_fnc_addSetting;
[
QGVAR(enableEventLogs), "CHECKBOX",
[LSTRING(enableEventLogs), LSTRING(enableEventLogsTooltip)],
_category, false, true
] call CBA_fnc_addSetting;

View File

@ -4,6 +4,12 @@
<Key ID="STR_forge_server_task_displayName">
<English>Task</English>
</Key>
<Key ID="STR_forge_server_task_enableEventLogs">
<English>Enable Event Logs</English>
</Key>
<Key ID="STR_forge_server_task_enableEventLogsTooltip">
<English>Log task event bus lifecycle, reward, rating, and notification events for debugging.</English>
</Key>
<Key ID="STR_forge_server_task_enableGenerator">
<English>Enable Generator</English>
</Key>