From fe523215ff0d3a1485d30bc51e8026f88cbb2374 Mon Sep 17 00:00:00 2001 From: Jack Farhall Date: Tue, 17 Dec 2024 01:20:06 +0000 Subject: [PATCH] fix: freight missions not failing on mission store (#472) fixes #471 --- Client Side/Framework/CfgFunctions.hpp | 1 + .../Functions/Freight/fn_claimFreight.sqf | 3 +- .../Freight/fn_onEachFrameFreight.sqf | 29 +++++++++++++++++++ .../Functions/Missions/CfgMissions.hpp | 2 +- .../Functions/Selects/fn_selectObject.sqf | 2 +- 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 Client Side/Framework/Functions/Freight/fn_onEachFrameFreight.sqf diff --git a/Client Side/Framework/CfgFunctions.hpp b/Client Side/Framework/CfgFunctions.hpp index 80056e75..082daafd 100644 --- a/Client Side/Framework/CfgFunctions.hpp +++ b/Client Side/Framework/CfgFunctions.hpp @@ -807,6 +807,7 @@ class CfgFunctions { file = "Functions\Freight"; class claimFreight {}; class finishFreight {}; + class onEachFrameFreight {}; }; class Shipwreck { diff --git a/Client Side/Framework/Functions/Freight/fn_claimFreight.sqf b/Client Side/Framework/Functions/Freight/fn_claimFreight.sqf index b98b7383..824958cd 100644 --- a/Client Side/Framework/Functions/Freight/fn_claimFreight.sqf +++ b/Client Side/Framework/Functions/Freight/fn_claimFreight.sqf @@ -33,9 +33,10 @@ if (_near isEqualTo []) exitWith { [(findDisplay getNumber(configFile >> "RscDisplayMission" >> "idd")), (_near apply { ([typeOf _x] call ULP_fnc_vehicleCfg) params [ "", "", "_picture", "_name" ]; [_picture, _name, _x call BIS_fnc_netId, 0]; -}), ["Fill", "Cancel"], [_trader], { +}), ["Fill", "Cancel"], [_trader, _mission], { _this params [ ["_trader", objNull, [objNull]], + ["_mission", "Kavala_Freight", [""]], ["_display", displayNull, [displayNull]] ]; diff --git a/Client Side/Framework/Functions/Freight/fn_onEachFrameFreight.sqf b/Client Side/Framework/Functions/Freight/fn_onEachFrameFreight.sqf new file mode 100644 index 00000000..c3cee1d1 --- /dev/null +++ b/Client Side/Framework/Functions/Freight/fn_onEachFrameFreight.sqf @@ -0,0 +1,29 @@ +/* +** Author: Jack "Scarso" Farhall +** Description: +*/ +#include "..\..\script_macros.hpp" +scopeName "fn_onEachFrameFreight"; + +_this params [ "_location", "_pos" ]; + +private _vehicle = (missionNamespace getVariable ["ULP_FreightVehicle", [objNull, 0]]) param [0, objNull]; + +if (isNull _vehicle || { !(alive _vehicle) }) exitWith { + private _freightMission = ULP_Missions getOrDefault ["CorporateFreight", []]; + + if !(_freightMission isEqualTo []) then { + _freightMission params [ + "_task", "_reward", "_eachFrame" + ]; + + _task setTaskState "Failed"; + player removeSimpleTask _task; + + ULP_Missions deleteAt "CorporateFreight"; + + ["Your vehicle was lost and your freight mission has failed."] call ULP_fnc_hint; + }; + + [_thisEventHandler] call ULP_fnc_removeEachFrame; +}; \ No newline at end of file diff --git a/Client Side/Framework/Functions/Missions/CfgMissions.hpp b/Client Side/Framework/Functions/Missions/CfgMissions.hpp index c4a3bf3d..51371cbc 100644 --- a/Client Side/Framework/Functions/Missions/CfgMissions.hpp +++ b/Client Side/Framework/Functions/Missions/CfgMissions.hpp @@ -362,7 +362,7 @@ class CfgMissions { description = "You need to deliver the given corporate freight to %1"; factions[] = { "Civilian" }; condition = "[""Freight""] call ULP_fnc_hasGroupPerk"; - eachFrame = ""; + eachFrame = "_this call ULP_fnc_onEachFrameFreight"; onClaimed = ""; onFinished = "_this call ULP_fnc_finishFreight"; class Locations { diff --git a/Client Side/Framework/Functions/Selects/fn_selectObject.sqf b/Client Side/Framework/Functions/Selects/fn_selectObject.sqf index 264e71f6..9f53939d 100644 --- a/Client Side/Framework/Functions/Selects/fn_selectObject.sqf +++ b/Client Side/Framework/Functions/Selects/fn_selectObject.sqf @@ -3,7 +3,7 @@ ** Description: */ #include "..\..\script_macros.hpp" -scopeName "fn_selectVehicles"; +scopeName "fn_selectObject"; _this params [ ["_parent", displayNull, [displayNull]],