Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interaction - Add actions based on animations #6144

Merged
merged 34 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c9cdf70
Add actions based on animations
Dystopian Feb 10, 2018
019417a
Add setting
Dystopian Feb 12, 2018
eecc496
Add ability to set items for users
Dystopian Feb 12, 2018
0803c32
Merge remote-tracking branch 'upstream/master' into anim_actions
Dystopian Apr 21, 2018
1e336e0
Add actions for 1.82 changes
Dystopian Apr 22, 2018
982705c
Merge remote-tracking branch 'upstream/master' into anim_actions
Dystopian Aug 14, 2018
a9067c5
Add RHS 0.4.6 ZIL spare
Dystopian Aug 14, 2018
0fa0f1f
Merge remote-tracking branch 'upstream/master' into anim_actions
Dystopian Sep 19, 2018
70d7c9e
Update to new standards
Dystopian Sep 19, 2018
5c2ced1
Handle RHS BTR retread system
Dystopian Sep 19, 2018
30dfa0e
Make init faster: move condition to configClasses
Dystopian Sep 23, 2018
bc7a2e4
Fix CUP fake anims
Dystopian Sep 23, 2018
2711901
Merge remote-tracking branch 'upstream/master' into anim_actions
Dystopian Dec 9, 2018
36c6846
Merge branch 'my2' into anim_actions
Dystopian Mar 17, 2019
b9c73ab
Merge remote-tracking branch 'upstream/master' into anim_actions
Dystopian Apr 22, 2021
d0f3aa5
Refactor
Dystopian Apr 23, 2021
724d127
Rework
Dystopian Apr 25, 2021
233e4c4
Rename init function
Dystopian Apr 25, 2021
34fd0d8
Decrease number of classes to init
Dystopian Apr 25, 2021
d7922b8
Merge branch 'master' into anim_actions
Dystopian Jul 25, 2021
69fb345
Fix merge mistake
Dystopian Jul 25, 2021
7f929bb
Apply suggestions from code review
jonpas Oct 12, 2021
25adfec
Merge branch 'master' into anim_actions
jonpas Oct 12, 2021
be26111
Merge branch 'master' into pr/6144
johnb432 Jul 20, 2024
f291fe1
Updated code for current mod structure
johnb432 Jul 20, 2024
6d80dcc
Multiple fixes & tweaks
johnb432 Jul 20, 2024
b50119f
Merge branch 'master' into pr/6144
johnb432 Jul 20, 2024
b160189
Update CfgVehicles.hpp
johnb432 Jul 22, 2024
2b0faa7
cache config lookup at preStart
PabstMirror Aug 9, 2024
76937f9
Merge branch 'master' into pr/6144
johnb432 Aug 9, 2024
dd7df53
Fix error
johnb432 Aug 9, 2024
dccb240
Add text config entry for progress bar title
johnb432 Aug 9, 2024
e36682a
Restructure interactions, improved some locations & added interaction…
johnb432 Aug 9, 2024
1d0aa16
Reverted preInit change
johnb432 Aug 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 113 additions & 1 deletion addons/interaction/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,15 @@ class CfgVehicles {
};
};

class Car_F: Car{};
class Car_F: Car {};
class Offroad_01_base_F: Car_F {
class GVAR(anims) {
class HideBackpacks {
position[] = {{-1.15,-1.15,-0.2}, {1.1,-1.15,-0.2}, {1.1,-2.5,-0.2}};
item[] = {"B_TacticalPack_blk", "B_TacticalPack_blk", "B_Carryall_khk", "B_Carryall_khk"};
};
};
};
class Quadbike_01_base_F: Car_F {
class ACE_Actions: ACE_Actions {
class ACE_MainActions: ACE_MainActions {
Expand Down Expand Up @@ -379,6 +387,39 @@ class CfgVehicles {
};
};

class Wheeled_APC_F;
class APC_Wheeled_01_base_F: Wheeled_APC_F {
class GVAR(anims) {
class showBags {
phase = 0;
//selection = "vhc_bags";
position[] = {{-0.685,-2.863,0.218}, {0.685,-2.863,0.218}};
item[] = {"B_Carryall_cbr", "B_Carryall_cbr"};
};
};
};
class APC_Wheeled_02_base_F: Wheeled_APC_F {
class GVAR(anims);
};
class APC_Wheeled_02_base_v2_F: APC_Wheeled_02_base_F {
class GVAR(anims): GVAR(anims) {
class showBags {
phase = 0;
selection = "vhc_bags";
item = "B_Carryall_cbr";
};
};
};
class APC_Wheeled_03_base_F: Wheeled_APC_F {
class GVAR(anims) {
class showBags {
phase = 0;
selection = "vhc_bags";
item[] = {"B_Carryall_cbr", "B_Carryall_cbr"};
};
};
};

class Tank: LandVehicle {
class ACE_Actions {
class ACE_MainActions {
Expand Down Expand Up @@ -406,6 +447,77 @@ class CfgVehicles {
};
};
};
class Tank_F;
class LT_01_base_F: Tank_F {
class GVAR(anims) {
class showBags {
phase = 0;
selection = "vhc_bags";
item = "B_Carryall_cbr";
};
class showBags2: showBags {
selection = "vhc_bags2";
};
};
};

class APC_Tracked_01_base_F: Tank_F {
class GVAR(anims);
};
class B_APC_Tracked_01_base_F: APC_Tracked_01_base_F {
class GVAR(anims):GVAR(anims) {
class showBags {
phase = 0;
selection = "vhc_bags";
item[] = {"B_Carryall_cbr", "B_Carryall_cbr", "B_Carryall_cbr", "B_Carryall_cbr", "B_Carryall_cbr"};
};
};
};
class B_APC_Tracked_01_CRV_F: B_APC_Tracked_01_base_F {
class GVAR(anims): GVAR(anims) {
class showBags: showBags {
item[] = {"B_Carryall_cbr", "B_Carryall_cbr", "B_Carryall_cbr", "B_Carryall_cbr"};
};
};
};

class APC_Tracked_02_base_F: Tank_F {
class GVAR(anims);
};
class O_APC_Tracked_02_base_F: APC_Tracked_02_base_F {};
class O_APC_Tracked_02_cannon_F: O_APC_Tracked_02_base_F {
class GVAR(anims): GVAR(anims) {
class showBags {
phase = 0;
selection = "vhc_bags";
item[] = {"B_Carryall_cbr", "B_Carryall_cbr", "B_Carryall_cbr"};
};
};
};

class APC_Tracked_03_base_F: Tank_F {
class GVAR(anims) {
class showBags {
phase = 0;
selection = "vhc_bags";
item[] = {"B_Carryall_cbr", "B_Carryall_cbr"};
};
};
};

class MBT_01_base_F: Tank_F {
class GVAR(anims);
};
class B_MBT_01_base_F: MBT_01_base_F {};
class B_MBT_01_cannon_F: B_MBT_01_base_F {
class GVAR(anims): GVAR(anims) {
class showBags {
phase = 0;
selection = "vhc_bags";
item[] = {"B_Carryall_cbr", "B_Carryall_cbr", "B_Carryall_cbr", "B_Carryall_cbr", "B_Carryall_cbr", "B_Carryall_cbr"};
};
};
};

class Motorcycle: LandVehicle {
class ACE_Actions {
Expand Down
1 change: 1 addition & 0 deletions addons/interaction/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ PREP(canPush);
PREP(push);

PREP(canFlip);
PREP(switchAnimActions);
PREP(switchLamp);
2 changes: 2 additions & 0 deletions addons/interaction/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

#include "initSettings.sqf"

ADDON = true;
141 changes: 141 additions & 0 deletions addons/interaction/functions/fnc_switchAnimActions.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
* Author: Dystopian
* Controls animation based interactions state.
*
* Arguments:
* 0: Enabled <BOOL>
*
* Return Value:
* None
*
* Example:
* true call ace_interaction_fnc_switchAnimActions
*
* Public: No
*/
#include "script_component.hpp"

params ["_enabled"];

if (!_enabled || {!isNil QGVAR(animActionsInitialized)}) exitWith {};

private _statement = {
params ["_target", "_player", "_params"];
_params params ["_anim", "_phase", "_duration"];
TRACE_5("statement",_target,_player,_anim,_phase,_duration);
[
_duration,
[_target, _player, _anim, _phase],
{
(_this select 0) params ["_target", "_player", "_anim", "_phase"];
scopeName "main";
private _items = _target getVariable [
format [QGVAR(animsItem_%1), _anim],
[configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(anims) >> _anim >> "item"] call BIS_fnc_getCfgData
];
if (!isNil "_items") then {
if (_items isEqualType "") then {_items = [_items]};
private _emptyPosAGL = [_target, _items select 0, _player] call EFUNC(common,findUnloadPosition);
if (_emptyPosAGL isEqualTo []) then {
[localize ELSTRING(common,NoRoomToUnload)] call EFUNC(common,displayTextStructured);
breakOut "main";
};
private ["_weaponHolder"];
{
switch true do {
case (1 == getNumber (configFile >> "CfgVehicles" >> _x >> "isBackpack")): {
if (isNil "_weaponHolder") then {
_weaponHolder = createVehicle ["GroundWeaponHolder", _emptyPosAGL, [], 0, "CAN_COLLIDE"];
};
_weaponHolder addBackpackCargoGlobal [_x, 1];
};
case (getNumber (configfile >> "CfgWeapons" >> _x >> "type") in [4096,131072]): {
Dystopian marked this conversation as resolved.
Show resolved Hide resolved
if (isNil "_weaponHolder") then {
_weaponHolder = createVehicle ["GroundWeaponHolder", _emptyPosAGL, [], 0, "CAN_COLLIDE"];
};
_weaponHolder addItemCargoGlobal [_x, 1];
};
default {
createVehicle [_x, _emptyPosAGL];
};
};
} forEach _items;
};
_target animate [_anim, _phase, true];
},
{},
nil,
{
(_this select 0) params ["_target", "", "_anim", "_phase"];
_target animationPhase _anim != _phase
},
["isNotSwimming"]
] call EFUNC(common,progressBar);
};

private _condition = {
params ["_target", "_player", "_params"];
_params params ["_anim", "_phase"];
private _vehicleConfig = configFile >> "CfgVehicles" >> typeOf _target;
private _animConfig = _vehicleConfig >> "AnimationSources" >> _anim;

GVAR(animActionsEnabled)
&& {isClass _animConfig}
&& {0 != [_animConfig >> "scope", "number", 1] call CBA_fnc_getConfigEntry}
&& {0 != [_vehicleConfig >> QGVAR(anims) >> _anim >> "enabled", "number", 1] call CBA_fnc_getConfigEntry}
&& {_target animationPhase _anim != _phase}
&& {[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)}
};

{
if (isClass (_x >> QGVAR(anims))) then {
private _vehicleConfig = _x;
private _vehicle = configName _vehicleConfig;
{
scopeName "animLoop";
private _anim = configName _x;
private _animConfigParent = inheritsFrom _vehicleConfig >> QGVAR(anims) >> _anim;
if (
!isClass _animConfigParent
|| {_x != _animConfigParent && {0 == [_animConfigParent >> "inherit", "number", 1] call CBA_fnc_getConfigEntry}}
) then {
private _positions = [_x >> "position"] call BIS_fnc_getCfgData;
if (!isNil "_positions") then {
if (_positions isEqualType "") then {
_positions = [compile format [
QUOTE(call compile getText (configFile >> 'CfgVehicles' >> typeOf _target >> QQGVAR(anims) >> '%1' >> 'position')),
_anim
]];
};
} else {
if ("" == getText (_x >> "selection")) then {
ERROR_2("No action position for vehicle %1 anim %2",_vehicle,_anim);
breakTo "animLoop";
};
_positions = [compile format [
QUOTE(_target selectionPosition getText (configFile >> 'CfgVehicles' >> typeOf _target >> QQGVAR(anims) >> '%1' >> 'selection')),
_anim
]];
};

private _phase = [_x >> "phase", "number", 1] call CBA_fnc_getConfigEntry;
private _name = [_x >> "name", "text", localize "str_a3_cfgactions_unmountitem0"] call CBA_fnc_getConfigEntry;
private _icon = [_x >> "icon", "text", "\A3\ui_f\data\igui\cfg\actions\take_ca.paa"] call CBA_fnc_getConfigEntry;
private _duration = [_x >> "duration", "number", 10] call CBA_fnc_getConfigEntry;
private _inherit = 0 != [_x >> "inherit", "number", 1] call CBA_fnc_getConfigEntry;
{
private _action = [
format ["%1%2", _anim, _forEachIndex],
_name, _icon, _statement, _condition, {},
[_anim, _phase, _duration],
_x
] call EFUNC(interact_menu,createAction);
[_vehicle, 0, [], _action, _inherit] call EFUNC(interact_menu,addActionToClass);
TRACE_3("",_vehicle,_anim,_x);
} forEach _positions;
};
} forEach ('true' configClasses (_x >> QGVAR(anims)));
};
} forEach ('true' configClasses (configFile >> "CfgVehicles"));

GVAR(animActionsInitialized) = true;
9 changes: 9 additions & 0 deletions addons/interaction/initSettings.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
QGVAR(animActionsEnabled),
"CHECKBOX",
LSTRING(SettingAnimActionsName),
format ["ACE %1", localize LSTRING(DisplayName)],
true,
true,
LINKFUNC(switchAnimActions)
] call CBA_settings_fnc_init;
4 changes: 4 additions & 0 deletions addons/interaction/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1091,5 +1091,9 @@
<Chinese>拿出屍體</Chinese>
<Chinesesimp>拿出尸体</Chinesesimp>
</Key>
<Key ID="STR_ACE_Interaction_SettingAnimActionsName">
<English>Interaction with animations</English>
<Russian>Взаимодействие с анимациями</Russian>
</Key>
</Package>
</Project>
30 changes: 30 additions & 0 deletions addons/refuel/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@ class CfgVehicles {
// Patria = LAV
GVAR(fuelCapacity) = 269;
};
class APC_Wheeled_02_base_F: Wheeled_APC_F {
class EGVAR(interaction,anims);
};
class APC_Wheeled_02_base_v2_F: APC_Wheeled_02_base_F {
class EGVAR(interaction,anims): EGVAR(interaction,anims) {
class showCanisters {
phase = 0;
position[] = {{-1.188,-3.87,-0.769}, {1.638,-3.87,-0.769}};
item[] = {"Land_CanisterFuel_F", "Land_CanisterFuel_F", "Land_CanisterFuel_F", "Land_CanisterFuel_F"};
};
};
};

class Truck_F: Car_F {
GVAR(fuelCapacity) = 400;
Expand Down Expand Up @@ -285,12 +297,14 @@ class CfgVehicles {
class MBT_01_base_F: Tank_F {
// Merkava IV
GVAR(fuelCapacity) = 1400;
class EGVAR(interaction,anims);
};

class MBT_02_base_F: Tank_F {
// T100 Black Eagle
// Assuming T80
GVAR(fuelCapacity) = 1100;
class EGVAR(interaction,anims);
};

class MBT_03_base_F: Tank_F {
Expand All @@ -301,11 +315,27 @@ class CfgVehicles {
class MBT_01_arty_base_F: MBT_01_base_F {
// Assuming similar 2S3
GVAR(fuelCapacity) = 830;

class EGVAR(interaction,anims): EGVAR(interaction,anims) {
class showCanisters {
phase = 0;
position[] = {{-2,-1.95,-1}, {2,-1.95,-1}, {1.7,-4.898,-0.4}};
item[] = {"Land_CanisterFuel_F", "Land_CanisterFuel_F", "Land_CanisterFuel_F", "Land_CanisterFuel_F", "Land_CanisterFuel_F", "Land_CanisterFuel_F", "Land_CanisterFuel_F"};
};
};
};

class MBT_02_arty_base_F: MBT_02_base_F {
// Assuming similar 2S3
GVAR(fuelCapacity) = 830;

class EGVAR(interaction,anims): EGVAR(interaction,anims) {
class showCanisters {
phase = 0;
position[] = {{1.7,-4.8,-0.5}};
item = "Land_CanisterFuel_F";
};
};
};

class Heli_Light_02_base_F: Helicopter_Base_H {
Expand Down
Loading