Skip to content

Commit

Permalink
fix: freight missions not failing on mission store (#472)
Browse files Browse the repository at this point in the history
fixes #471
  • Loading branch information
Scarso327 authored Dec 17, 2024
1 parent bc13cea commit fe52321
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions Client Side/Framework/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ class CfgFunctions {
file = "Functions\Freight";
class claimFreight {};
class finishFreight {};
class onEachFrameFreight {};
};

class Shipwreck {
Expand Down
3 changes: 2 additions & 1 deletion Client Side/Framework/Functions/Freight/fn_claimFreight.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
];

Expand Down
29 changes: 29 additions & 0 deletions Client Side/Framework/Functions/Freight/fn_onEachFrameFreight.sqf
Original file line number Diff line number Diff line change
@@ -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;
};
2 changes: 1 addition & 1 deletion Client Side/Framework/Functions/Missions/CfgMissions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
** Description:
*/
#include "..\..\script_macros.hpp"
scopeName "fn_selectVehicles";
scopeName "fn_selectObject";

_this params [
["_parent", displayNull, [displayNull]],
Expand Down

0 comments on commit fe52321

Please sign in to comment.