Skip to content

Commit

Permalink
More ace actions
Browse files Browse the repository at this point in the history
  • Loading branch information
theace0296 committed Nov 21, 2021
1 parent 0fa1f6e commit 74f4366
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 27 deletions.
25 changes: 21 additions & 4 deletions RandFramework/Client/init/fn_generalPlayerLoop.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,33 @@ format[localize "STR_TRGM2_debugFunctionString", _fnc_scriptName, _fnc_scriptNam
while {true} do {
if (side player != civilian) then {
if (count TRGM_VAR_ObjectivePositions > 0 && TRGM_VAR_AllowUAVLocateHelp) then {
private _useAceInteractionForTransport = [false, true] select ((["EnableAceActions", 0] call BIS_fnc_getParamValue) isEqualTo 1);
if ((player distance (TRGM_VAR_ObjectivePositions select 0)) < 25) then {
if ((player getVariable ["calUAVActionID", -1]) isEqualTo -1) then {
[(localize "STR_TRGM2_TRGMInitPlayerLocal_UAVAvailable")] call TRGM_GLOBAL_fnc_notify;
private _actionID = player addAction [localize "STR_TRGM2_TRGMInitPlayerLocal_CallUAV",{[0] spawn TRGM_GLOBAL_fnc_callUAVFindObjective}];
player setVariable ["calUAVActionID",_actionID];
if (_useAceInteractionForTransport && call TRGM_GLOBAL_fnc_isAceLoaded) then {
private _selfAction = [
'STR_TRGM2_TRGMInitPlayerLocal_CallUAV',
localize 'STR_TRGM2_TRGMInitPlayerLocal_CallUAV',
'',
{[0] spawn TRGM_GLOBAL_fnc_callUAVFindObjective}
] call ACE_interact_menu_fnc_createAction;
[_selfAction] call TRGM_GLOBAL_fnc_addAceActionToPlayer;
player setVariable ["calUAVActionID", _selfAction];
} else {
private _actionID = player addAction [localize "STR_TRGM2_TRGMInitPlayerLocal_CallUAV",{[0] spawn TRGM_GLOBAL_fnc_callUAVFindObjective}];
player setVariable ["calUAVActionID",_actionID];
};
};
} else {
if ((player getVariable ["calUAVActionID", -1]) != -1) then {
player removeAction (player getVariable ["calUAVActionID", -1]);
player setVariable ["calUAVActionID", nil];
if (_useAceInteractionForTransport && call TRGM_GLOBAL_fnc_isAceLoaded) then {
[(player getVariable ["calUAVActionID", -1])] call TRGM_GLOBAL_fnc_removeAceActionFromPlayer;
player setVariable ["calUAVActionID", nil];
} else {
player removeAction (player getVariable ["calUAVActionID", -1]);
player setVariable ["calUAVActionID", nil];
};
[localize "STR_TRGM2_TRGMInitPlayerLocal_UAVNoAvailable"] call TRGM_GLOBAL_fnc_notify;
};
};
Expand Down
3 changes: 2 additions & 1 deletion RandFramework/Client/init/fn_main.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ if (_isTraining) then {
//training
[player, 100] call BIS_fnc_respawnTickets;

if (call TRGM_GLOBAL_fnc_isAceLoaded) then {
private _useAceInteractionForTransport = [false, true] select ((["EnableAceActions", 0] call BIS_fnc_getParamValue) isEqualTo 1);
if (_useAceInteractionForTransport && call TRGM_GLOBAL_fnc_isAceLoaded) then {
myaction = ['TraceBulletAction',localize 'STR_TRGM2_TRGMInitPlayerLocal_TraceBullets','',{},{true}] call ace_interact_menu_fnc_createAction;
[player, 1, ["ACE_SelfActions"], myaction] call ace_interact_menu_fnc_addActionToObject;

Expand Down
13 changes: 13 additions & 0 deletions RandFramework/Global/ace/fn_removeAceActionFromObject.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// private _fnc_scriptName = "TRGM_GLOBAL_fnc_removeAceActionFromObject";
params ["_action", "_object"];
format[localize "STR_TRGM2_debugFunctionString", _fnc_scriptName, _fnc_scriptNameParent, (["Client", "Server"] select isServer)] call TRGM_GLOBAL_fnc_log;

private _existingActions = _object getVariable ["TRGM_addedAceActions",[]];

if(_action in _existingActions) then {
[_object, 1, ["ACE_SelfActions", (_action select 0)]] remoteExec ["ACE_interact_menu_fnc_removeActionFromObject", [0, -2] select isDedicated, true];
_existingActions deleteAt (_existingActions find _action);
_object setVariable ["TRGM_addedAceActions", _existingActions];
};

true;
15 changes: 15 additions & 0 deletions RandFramework/Global/ace/fn_removeAceActionFromPlayer.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// private _fnc_scriptName = "TRGM_GLOBAL_fnc_removeAceActionFromPlayer";
params ["_action"];
format[localize "STR_TRGM2_debugFunctionString", _fnc_scriptName, _fnc_scriptNameParent, (["Client", "Server"] select isServer)] call TRGM_GLOBAL_fnc_log;

if !(hasInterface) exitWith {};

private _existingActions = player getVariable ["TRGM_addedAceActions",[]];

if(_action in _existingActions) then {
[player, 1, ["ACE_SelfActions", (_action select 0)]] call ACE_interact_menu_fnc_removeActionFromObject;
_existingActions deleteAt (_existingActions find _action);
player setVariable ["TRGM_addedAceActions", _existingActions];
};

true;
68 changes: 46 additions & 22 deletions RandFramework/Global/transport/fn_helocastLanding.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,53 @@ waitUntil { _vehicle getVariable ["landingInProgress", false]; };

[[_vehicle], {
params ["_thisVehicle"];
private _actionId = _thisVehicle addAction [
localize "STR_TRGM2_jumpIntoWater",
{
private _useAceInteractionForTransport = [false, true] select ((["EnableAceActions", 0] call BIS_fnc_getParamValue) isEqualTo 1);
if (_useAceInteractionForTransport && call TRGM_GLOBAL_fnc_isAceLoaded) then {
private _vehicleAction = [
'JumpIntoWater',
localize "STR_TRGM2_jumpIntoWater",
'',
{
[[_x], {
sleep (floor(random 5) max 1);
unassignVehicle (_this select 0);
moveOut (_this select 0);
}] remoteExec ["spawn", _x];
} forEach units group (_this select 1);
},
nil,
-20, //priority
false,
true,
"",
"_this in (crew _target) && (speed _target) < 1",
-1,
false,
""
];
waitUntil {([_thisVehicle] call TRGM_GLOBAL_fnc_isOnlyBoardCrewOnboard);};
_thisVehicle removeAction _actionId;
{
[[_x], {
sleep (floor(random 5) max 1);
unassignVehicle (_this select 0);
moveOut (_this select 0);
}] remoteExec ["spawn", _x];
} forEach units group (_this select 1);
},
{
(_this select 1) in (crew (_this select 0)) && (speed (_this select 0)) < 1;
}
] call ACE_interact_menu_fnc_createAction;
[_vehicleAction, _vehicle] call TRGM_GLOBAL_fnc_addAceActionToObject;
waitUntil {([_thisVehicle] call TRGM_GLOBAL_fnc_isOnlyBoardCrewOnboard);};
[_vehicleAction, _vehicle] call TRGM_GLOBAL_fnc_removeAceActionFromObject;
} else {
private _actionId = _thisVehicle addAction [
localize "STR_TRGM2_jumpIntoWater",
{
{
[[_x], {
sleep (floor(random 5) max 1);
unassignVehicle (_this select 0);
moveOut (_this select 0);
}] remoteExec ["spawn", _x];
} forEach units group (_this select 1);
},
nil,
-20, //priority
false,
true,
"",
"_this in (crew _target) && (speed _target) < 1",
-1,
false,
""
];
waitUntil {([_thisVehicle] call TRGM_GLOBAL_fnc_isOnlyBoardCrewOnboard);};
_thisVehicle removeAction _actionId;
};
}] remoteExec ["spawn", 0, true];

waitUntil { getPos _vehicle select 2 >= 0 && getPos _vehicle select 2 <= 6; };
Expand Down
2 changes: 2 additions & 0 deletions RandFramework/cfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ class TRGM_GLOBAL {
file = "RandFramework\Global\ace";
class addAceActionToObject {};
class addAceActionToPlayer {};
class removeAceActionFromObject {};
class removeAceActionFromPlayer {};
};

class common {
Expand Down

0 comments on commit 74f4366

Please sign in to comment.