From bbd958ed52d50a2bf56d42fd5b1ba6c3b29701fc Mon Sep 17 00:00:00 2001 From: vbawol Date: Tue, 3 Oct 2017 09:04:30 -0500 Subject: [PATCH] energy fixes --- .../epoch_code/compile/building/EPOCH_simulSwap.sqf | 13 +++++++++---- .../compile/building/EPOCH_staticMove.sqf | 10 +++++++--- .../interface_event_handlers/EPOCH_KeyDown.sqf | 7 +++++-- Sources/epoch_config/Configs/CfgClientFunctions.hpp | 4 +++- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Sources/epoch_code/compile/building/EPOCH_simulSwap.sqf b/Sources/epoch_code/compile/building/EPOCH_simulSwap.sqf index 708fa9f8..39721e4d 100644 --- a/Sources/epoch_code/compile/building/EPOCH_simulSwap.sqf +++ b/Sources/epoch_code/compile/building/EPOCH_simulSwap.sqf @@ -22,7 +22,7 @@ NOTHING */ //[[[cog import generate_private_arrays ]]] -private ["_allowedSnapObjects","_allowedSnapPoints","_cfgBaseBuilding","_class","_create","_currentTarget","_dir2","_direction","_disallowed","_distance","_distanceMod","_distanceNear","_energyCost","_isSnap","_lastCheckTime","_maxHeight","_nearestObject","_nearestObjectRaw","_newObj","_objSlot","_objType","_object","_oemType","_offset","_onContactEH","_pOffset","_playerdistance","_pos2","_prevSnapDistance","_previousDistanceNear","_rejectMove","_return","_simulClassConfig","_snapArrayPara","_snapArrayPerp","_snapDistance","_snapObjects","_snapPointsPara","_snapPointsPerp","_snapPos","_snapPosition","_snapType","_textureSlot","_up2","_vel2","_velocityTransformation","_worldspace"]; +private ["_allowedSnapObjects","_allowedSnapPoints","_cfgBaseBuilding","_class","_create","_currentTarget","_dir2","_direction","_disallowed","_distance","_distanceMod","_distanceNear","_energyCost","_isSnap","_lastCheckTime","_maxHeight","_nearestObject","_nearestObjectRaw","_newObj","_objSlot","_objType","_object","_oemType","_offset","_onContactEH","_pOffset","_playerEnergy","_playerEnergyKeyFinal","_playerdistance","_pos2","_prevSnapDistance","_previousDistanceNear","_rejectMove","_return","_simulClassConfig","_snapArrayPara","_snapArrayPerp","_snapDistance","_snapObjects","_snapPointsPara","_snapPointsPerp","_snapPos","_snapPosition","_snapType","_textureSlot","_up2","_vel2","_velocityTransformation","_worldspace"]; //[[[end]]] if !(isNil "EPOCH_simulSwap_Lock") exitWith{}; @@ -34,7 +34,11 @@ _objType = typeOf _object; _isSnap = false; -if (EPOCH_playerEnergy <= 0) exitWith { +_playerEnergyKeyFinal = "EPOCH_playerEnergy"; +if !(isNil "_playerEnergyKey") then {_playerEnergyKeyFinal = _playerEnergyKey}; +_playerEnergy = missionNamespace getVariable [_playerEnergyKeyFinal,[]]; + +if (_playerEnergy <= 0) exitWith { ["Need Energy", 5] call Epoch_message; }; if !(_object call EPOCH_isBuildAllowed) exitWith{}; @@ -106,7 +110,8 @@ if (isText(_simulClassConfig)) then { EPOCH_Z_OFFSET = _offset select 2; _lastCheckTime = diag_tickTime; while {EPOCH_target == _currentTarget} do { - if (EPOCH_playerEnergy <= 0) exitWith { EPOCH_target = objNull; }; + _playerEnergy = missionNamespace getVariable [_playerEnergyKeyFinal,[]]; + if (_playerEnergy <= 0) exitWith { EPOCH_target = objNull; }; _rejectMove = false; if ((diag_tickTime - _lastCheckTime) > 10) then { _lastCheckTime = diag_tickTime; @@ -226,7 +231,7 @@ if (isText(_simulClassConfig)) then { }; }; }; - EPOCH_playerEnergy = (EPOCH_playerEnergy - _energyCost) max 0; + [_playerEnergyKeyFinal, -_energyCost, 2500 , 0] call EPOCH_fnc_setVariableLimited; uiSleep 0.1; }; _currentTarget removeEventHandler["EpeContactStart", _onContactEH]; diff --git a/Sources/epoch_code/compile/building/EPOCH_staticMove.sqf b/Sources/epoch_code/compile/building/EPOCH_staticMove.sqf index fe8e9998..ce2450e2 100644 --- a/Sources/epoch_code/compile/building/EPOCH_staticMove.sqf +++ b/Sources/epoch_code/compile/building/EPOCH_staticMove.sqf @@ -23,7 +23,7 @@ NOTHING */ //[[[cog import generate_private_arrays ]]] -private ["_AnchorPos","_EPOCH_1","_EPOCH_2","_MoveObject","_Snapdirection","_allowedSnapObjects","_allowedSnapPoints","_arr_snapPoints","_baselineSnapPos","_cfgBaseBuilding","_class","_currentOffSet","_currentPos","_currentTarget","_currentTargetAttachedTo","_dir2","_direction","_distance","_energyCost","_helper","_ins","_isSnap","_lastCheckTime","_maxHeight","_maxSnapDistance","_nearestObject","_nearestObjects","_newDirAndUp","_numberOfContacts","_objSlot","_objType","_offSet","_offsetZPos","_pOffset","_pos1_snap","_pos2","_pos2ATL","_pos2_snap","_pos_snapObj","_rejectMove","_simulClass","_snapChecks","_snapConfig","_snapDistance","_snapPointsPara","_snapPointsPerp","_snapPos","_snapPos1","_snapPosition","_snapType","_snapped","_stabilityCheck","_worldspace","_snapMemoryPoint","_vectorDir","_vectorUp","_tempClass","_newDir"]; +private ["_AnchorPos","_EPOCH_1","_EPOCH_2","_MoveObject","_Snapdirection","_allowedSnapObjects","_allowedSnapPoints","_arr_snapPoints","_baselineSnapPos","_cfgBaseBuilding","_class","_currentOffSet","_currentPos","_currentTarget","_currentTargetAttachedTo","_dir2","_direction","_distance","_energyCost","_helper","_ins","_isSnap","_lastCheckTime","_maxHeight","_maxSnapDistance","_nearestObject","_nearestObjects","_newDir","_newDirAndUp","_numberOfContacts","_objSlot","_objType","_offSet","_offsetZPos","_pOffset","_playerEnergy","_playerEnergyKeyFinal","_pos1_snap","_pos2","_pos2ATL","_pos2_snap","_pos_snapObj","_rejectMove","_simulClass","_snapChecks","_snapConfig","_snapDistance","_snapMemoryPoint","_snapPointsPara","_snapPointsPerp","_snapPos","_snapPos1","_snapPosition","_snapType","_snapped","_stabilityCheck","_tempClass","_tiltFB","_tiltLR","_vectorDir","_vectorUp","_worldspace"]; //[[[end]]] if !(isNil "EPOCH_simulSwap_Lock") exitWith{}; @@ -37,7 +37,11 @@ if (isNull _object) exitWith{ EPOCH_target = objNull; }; // exit if item is not given if (_item == "") exitWith{ EPOCH_target = objNull; }; -if (EPOCH_playerEnergy <= 0) exitWith{ +_playerEnergyKeyFinal = "EPOCH_playerEnergy"; +if !(isNil "_playerEnergyKey") then {_playerEnergyKeyFinal = _playerEnergyKey}; +_playerEnergy = missionNamespace getVariable [_playerEnergyKeyFinal,[]]; + +if (_playerEnergy <= 0) exitWith{ ["Need Energy", 5] call Epoch_message; }; @@ -172,7 +176,7 @@ if (_class != "") then { _EPOCH_1 = diag_tickTime; if !(isNull EPOCH_target) then { _nearestObjects = nearestObjects[EPOCH_target, _allowedSnapObjects, 12]; - ["EPOCH_playerEnergy", -_energyCost, 5000 , 0] call EPOCH_fnc_setVariableLimited; + [_playerEnergyKeyFinal, -_energyCost, 2500 , 0] call EPOCH_fnc_setVariableLimited; }; }; if !(_currentTargetAttachedTo isequalto EPOCH_target_attachedTo) then { 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 932a4328..43f87523 100644 --- a/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyDown.sqf +++ b/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyDown.sqf @@ -26,12 +26,14 @@ BOOL */ //[[[cog import generate_private_arrays ]]] -private ["_adj","_currentPos","_handled","_playerStaminaKeyFinal","_step"]; +private ["_adj","_currentPos","_handled","_playerEnergy","_playerEnergyKeyFinal","_playerStaminaKeyFinal","_step"]; //[[[end]]] params ["_display","_dikCode","_shift","_ctrl","_alt"]; _playerStaminaKeyFinal = "EPOCH_playerStamina"; +_playerEnergyKeyFinal = "EPOCH_playerEnergy"; if !(isNil "_playerStaminaKey") then {_playerStaminaKeyFinal = _playerStaminaKey}; +if !(isNil "_playerEnergyKey") then {_playerEnergyKeyFinal = _playerEnergyKey}; _handled = false; @@ -253,7 +255,8 @@ if (_dikCode in (actionKeys "TacticalView")) then { _handled = true; }; if (_dikCode in (actionKeys "NightVision")) then { - if (EPOCH_playerEnergy == 0) then { + _playerEnergy = missionNamespace getVariable [_playerEnergyKeyFinal,[]]; + if (_playerEnergy == 0) then { ["Night Vision Goggles: Need Energy", 5] call Epoch_message; _handled = true; }; diff --git a/Sources/epoch_config/Configs/CfgClientFunctions.hpp b/Sources/epoch_config/Configs/CfgClientFunctions.hpp index 727d31f9..390a873f 100644 --- a/Sources/epoch_config/Configs/CfgClientFunctions.hpp +++ b/Sources/epoch_config/Configs/CfgClientFunctions.hpp @@ -57,7 +57,9 @@ class CfgClientFunctions class countdown {}; class fnc_SelectTargetBuild {}; class isBuildAllowed {}; - class simulSwap {}; + class simulSwap { + customHeader = 1; + }; class staticMove { customHeader = 1; };