diff --git a/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyDown.sqf b/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyDown.sqf index 295c0f7c..4a2ede58 100644 --- a/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyDown.sqf +++ b/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyDown.sqf @@ -72,7 +72,7 @@ if (_ctrl && _dikCode == EPOCH_keysVolumeDown) then { }; // ESC default to cancel -if (_dikCode == 0x01) then { +if (_dikCode in (actionKeys "ingamePause")) then { if !(isNull EPOCH_Target) then { if !(EPOCH_Target isKindOf "ThingX") then { deleteVehicle EPOCH_Target; @@ -264,4 +264,29 @@ if (_dikCode in (actionKeys "NightVision")) then { }; }; +if(!_ctrl && (_dikCode in (actionKeys "HeliRopeAction")))then{ + _msg = ""; + if(EPOCH_ArmaSlingLoad)then{ + if(driver vehicle player isEqualTo player)then{ + _slung = ropeAttachedObjects vehicle player; + if(_slung isEqualTo [])then{ + if!('ItemRope' in magazines player) then { + _msg = "You need rope to hook"; + _handled = true; + }else{ + player removeItem 'ItemRope'; + }; + }else{ + player addItem 'ItemRope'; + }; + }; + }else{ + _msg = "Hook/Unhook Malfunction, overrode by R3F or AdvSlingLoad"; + _handled = true; + }; + if!(_msg isEqualTo "")then{ + [_msg,5,[[0,0,0,0.2],[1,1,1,1]]] call Epoch_message_stack; + }; +}; + _handled diff --git a/Sources/epoch_code/compile/interface_event_handlers/EPOCH_handleUIActions.sqf b/Sources/epoch_code/compile/interface_event_handlers/EPOCH_handleUIActions.sqf new file mode 100644 index 00000000..e8ed286b --- /dev/null +++ b/Sources/epoch_code/compile/interface_event_handlers/EPOCH_handleUIActions.sqf @@ -0,0 +1,81 @@ +/* + Author: DirtySanchez - ported from DonkeyPunch eXpoch http://DonkeyPunch.INFO + + Contributors: + + Licence: + Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike + + Github: + https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/interface_event_handlers/EPOCH_handleUIActions.sqf +*/ +private['_msg', '_type', '_disableSlingLoad', '_slung']; +params [ + ['_actionObj',objNull], + ['_player',objNull], + ['_index',0], + ['_actionName',''], + ['_actionDisplayName',''], + ['_priority',1], + ['_showWindow',false], + ['_hideOnUse',true], + ['_shortCut',''], + ['_visibility',false], + ['_eventName',''] +]; +_blocked = false; +_msg = ''; +_type = typeOf _actionObj; +switch(true)do{ + case (_actionName isEqualTo 'FireInflame'): { + if!('lighter_epoch' in magazines player) then { + _msg = 'You need a lighter'; + _blocked = true; + }else{ + [player,'lighter_epoch',-1] call EPOCH_usedItemRepack; + //[_actionObj] remoteExec ['EPOCH_server_addToFireSystem',2]; + }; + }; + case (_actionName isEqualTo 'FirePutDown'): { + if(_type isEqualTo 'BurnBarrel_EPOCH')then{ + if!('ItemFireExtinguisher' in magazines player) then { + _msg = 'You need an extinguisher'; + _blocked = true; + }else{ + [player,'ItemFireExtinguisher',-1] call EPOCH_usedItemRepack; + }; + }; + }; + case (_actionName isEqualTo 'HookCargo'): { + if(EPOCH_ArmaSlingLoad)then{ + if(driver vehicle player isEqualTo player)then{ + _slung = ropeAttachedObjects vehicle player; + if(_slung isEqualTo [])then{ + if!('ItemRope' in magazines player) then { + _msg = 'You need rope to hook'; + _blocked = true; + }else{ + player removeItem 'ItemRope'; + }; + }else{ + player addItem 'ItemRope'; + }; + }; + }else{ + _msg = 'Hook Malfunction, overrode by R3F or AdvSlingLoad'; + _blocked = true; + }; + }; + case (_actionName isEqualTo 'UnhookCargo'): { + if(EPOCH_ArmaSlingLoad)then{ + player addItem 'ItemRope'; + }else{ + _msg = 'Unhook Malfunction, overrode by R3F or AdvSlingLoad'; + _blocked = true; + }; + }; +}; +if!(_msg isEqualTo '')then{ + [_msg,5,[[0,0,0,0.2],[1,1,1,1]]] call Epoch_message_stack; +}; +_blocked \ No newline at end of file diff --git a/Sources/epoch_code/compile/inventory/EPOCH_usedItemRepack.sqf b/Sources/epoch_code/compile/inventory/EPOCH_usedItemRepack.sqf new file mode 100644 index 00000000..a4f897a2 --- /dev/null +++ b/Sources/epoch_code/compile/inventory/EPOCH_usedItemRepack.sqf @@ -0,0 +1,65 @@ +/* + Author: DirtySanchez - ported from DonkeyPunch eXpoch http://DonkeyPunch.INFO + + Contributors: + + Licence: + Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike + + Github: + https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/inventory/EPOCH_usedItemRepack.sqf + + Description: + Allows adjustments to mag with least ammo. + Can be used server and client side as addMagazine is a global command + + Local Usage: + [player,'lighter_epoch',-1] call EPOCH_usedItemRepack; + + Global Usage: + [_playerObj,'lighter_epoch',-1] call EPOCH_usedItemRepack; +*/ +private["_msg","_itemMags","_displayName","_itemAmmoType","_mags","_ammoType","_total","_maxAmmo","_wholeMags","_remainder","_index","_usedItemArray"]; +params[ + ["_player",objNull], + ["_item",""], + ["_chg",0] +]; + +if(isNull _player) exitWith {diag_log "[EPOCHDebug] EPOCH_usedItemRepack - player isNull"}; + +if(_item isEqualTo "") exitWith {diag_log "[EPOCHDebug] EPOCH_usedItemRepack - classname is empty string"}; + +if!(isClass(configFile >> "CfgMagazines" >> _item)) exitWith {diag_log format["[EPOCHDebug] EPOCH_usedItemRepack - Classname does not exist",_item]}; + +_msg = ""; +_itemMags = []; +_displayName = getText(configFile >> "CfgMagazines" >> _item >> "displayName"); + +//get all mags of same classname and ammo type +_mags = magazinesAmmo _player; +{ + _x params ["_className","_count"]; + if(_className isEqualTo _item)then{ + _itemMags pushBack _x; + }; +}forEach _mags; + +// if more than 1 sort them by ammo count +if(count _itemMags > 1)then{ + _itemMags = [_itemMags,[],{_x select 1},"ASCEND"] call BIS_fnc_sortBy; +}; + +// adjust the item +if!(_chg isEqualTo 0)then{ + _index = ((count _itemMags) - 1); + _usedItemArray = _itemMags select _index; + _usedItemArray params ["_mag","_count"]; + _itemMags pushBack [_mag, (_count + _chg)]; + _itemMags = _itemMags - [_usedItemArray]; + _player removeMagazines _mag; + { + _player addMagazine _x; + [format["You have used your %1", _displayName],5,[[0,0,0,0.2],[1,1,1,1]]] call Epoch_message_stack; + }forEach _itemMags; +}; diff --git a/Sources/epoch_code/compile/setup/EPOCH_clientInit.sqf b/Sources/epoch_code/compile/setup/EPOCH_clientInit.sqf index b07ee0af..8ba26bff 100644 --- a/Sources/epoch_code/compile/setup/EPOCH_clientInit.sqf +++ b/Sources/epoch_code/compile/setup/EPOCH_clientInit.sqf @@ -53,3 +53,15 @@ EPOCH_playerStaminaMax = 100; enableSentences false; enableRadio false; player setVariable["BIS_noCoreConversations", true]; + +EPOCH_ArmaSlingLoad = true; +_r3fON = if(!isNil "R3F_LOG_CFG_can_lift")then{if!(R3F_LOG_CFG_can_lift isEqualTo [])then{true}else{false}}else{false}; +_advSling = if(!isNil "ASL_ROPE_INIT")then{if(ASL_ROPE_INIT)then{true}else{false}}else{false}; +if (_r3fON || _advSling)then{ + EPOCH_ArmaSlingLoad = false; +}; + +// handle actions, prevactions, nextactions +inGameUISetEventHandler ["Action", "if(!(_this isEqualTo []) && !(_this select 10 in ['PrevAction','NextAction']))then{_this call EPOCH_handleUIActions}"]; +//inGameUISetEventHandler ["NextAction", "_this call EPOCH_handleUIActions"]; +//inGameUISetEventHandler ["PrevAction", "_this call EPOCH_handleUIActions"]; diff --git a/Sources/epoch_config/Configs/CfgClientFunctions.hpp b/Sources/epoch_config/Configs/CfgClientFunctions.hpp index 58937b61..639c3088 100644 --- a/Sources/epoch_config/Configs/CfgClientFunctions.hpp +++ b/Sources/epoch_config/Configs/CfgClientFunctions.hpp @@ -91,6 +91,7 @@ class CfgClientFunctions }; class KeyUp {}; class onChar {}; + class handleUIActions {}; }; class event_handlers { @@ -207,6 +208,7 @@ class CfgClientFunctions class refeshUI {}; class equip {}; class itemTypeSlot {}; + class usedItemRepack {}; }; class servicepoint { diff --git a/Sources/epoch_config/Configs/CfgItemSort.hpp b/Sources/epoch_config/Configs/CfgItemSort.hpp index ff070a82..60f3c617 100644 --- a/Sources/epoch_config/Configs/CfgItemSort.hpp +++ b/Sources/epoch_config/Configs/CfgItemSort.hpp @@ -1128,7 +1128,8 @@ class CfgItemSort "SeedPacket_Hemp", "SeedPacket_Poppy", "SeedPacket_Pumpkin", - "SeedPacket_Sunflower" + "SeedPacket_Sunflower", + "ItemFireExtinguisher" }; Vehicles_Land[] = { "ebike_epoch", // Motorrad diff --git a/Sources/epoch_config/Configs/CfgPricing.hpp b/Sources/epoch_config/Configs/CfgPricing.hpp index 19ecf509..cbf500f3 100644 --- a/Sources/epoch_config/Configs/CfgPricing.hpp +++ b/Sources/epoch_config/Configs/CfgPricing.hpp @@ -1824,6 +1824,10 @@ class CfgPricing { price = 50; }; + class ItemFireExtinguisher + { + price = 50; + } class WoodLog_EPOCH { price = 2;