Epoch/Sources/epoch_code/compile/EPOCH_consumeItem.sqf

478 lines
16 KiB
Plaintext
Raw Normal View History

2015-12-07 16:24:52 +00:00
/*
Author: Aaron Clark - EpochMod.com
Contributors:
Description:
Epoch consume item function
Licence:
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
Github:
2016-06-13 16:54:19 +00:00
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/EPOCH_consumeItem.sqf
2015-12-07 16:24:52 +00:00
*/
2016-09-01 00:40:18 +00:00
//[[[cog import generate_private_arrays ]]]
private ["_buildClass","_buildingCountLimit","_canCapacity","_cfgBaseBuilding","_cfgItemInteractions","_color","_currentDMG","_currentFuel","_currentHIT","_fuelCapacity","_ghostClass","_highestDMG","_inputCount","_interactAttributes","_interactOption","_interactReturnOnUse","_isOk","_isStorage","_magazineSize","_magazineSizeMax","_magazinesAmmoFull","_msg","_newDMG","_newFuel","_object","_otherObjects","_output","_paintCanColor","_paintCanIndex","_partCheck","_pos","_removeItem","_transportFuel","_unifiedInteract","_vehicle","_vehicles"];
2016-09-01 00:40:18 +00:00
//[[[end]]]
EPOCH_InteractedItem params ["_text","_item","_pic"];
2015-09-14 20:55:36 +00:00
_cfgBaseBuilding = 'CfgBaseBuilding' call EPOCH_returnConfig;
_cfgItemInteractions = ["CfgItemInteractions", _item] call EPOCH_returnConfigV2;
// _cfgItemInteractions = (('CfgItemInteractions' call EPOCH_returnConfig) >> _item);
2016-05-06 20:30:10 +00:00
_interactOption = getNumber(_cfgItemInteractions >> "interactAction");
_interactAttributes = getArray(_cfgItemInteractions >> "interactAttributes");
_interactReturnOnUse = getText(_cfgItemInteractions >> "interactReturnOnUse");
_inputCount = count _this;
if (_inputCount >= 1) then {
_interactOption = param [0,0];
};
if (_inputCount >= 2) then {
_interactAttributes = param [1,[]];
};
if (_inputCount >= 3) then {
_interactReturnOnUse = param [2,""];
};
// diag_log format["DEBUG: %1",[_interactOption,_interactAttributes,_interactReturnOnUse]];
2015-09-14 20:55:36 +00:00
_removeItem = {([player,_this] call BIS_fnc_invRemove) == 1};
_unifiedInteract = {
2018-04-30 20:29:14 +00:00
private ["_removed","_multi","_maxMagRnd","_totalMags","_remove"];
_removed = false;
_multi = 1;
_maxMagRnd = getnumber (configfile >> "cfgMagazines" >> _item >> "count");
if (_maxMagRnd > 1) then {
_totalMags = (magazinesammo player) select {(_x select 0) isequalto _item};
if !(_totalMags isequalto []) then {
_remove = _totalMags deleteat 0;
_removed = true;
_remove params ["_class","_rounds"];
_multi = _rounds / _maxMagRnd;
player removemagazines _item;
{
_x call EPOCH_fnc_addMagazineOverflow;
} foreach _totalMags;
};
}
else {
_removed = _item call _removeItem;
};
if (_removed) then {
Release 0.3.8 (#502) * first build for 0.3.8 * 0.3.8.0190 * 0.3.8.0202 * 0.3.8.0213 * 0.3.7.0214 * 0.3.8.0222 * 0.3.8.0246 * 0.3.8.0247 fixed typo * 0.3.8.0249 more fixes for server compiler * 0.3.8.0256 * add build number and simple batch file for packing * match build number with internal * add build numbers to server pbo's and mission files also reworked build script for more options * 0.3.8.0261 * 0.3.8.0261 * 0.3.8.0283 * 0.3.8.0284 * changelog * 0.3.8.0307 * 0.3.8.0311 * remove old BEC plugin * update redis-server.exe to latest build and full config * 0.3.8.0314 * 0.3.8.0315 * inverse logic This should correctly prevent spawning these units nearby jammer or protection zones * use pushbackUnique here * optimized loot function by using selectRandom instead of slower sqf logic * 0.3.8.0316 * make use of new getDir functionality instead of BIS fnc * add lower disconnect value to server.cfg * use new getpos functionality * 0.3.8.0317 * 0.3.8.0319 * 0.3.8.0327 * 0.3.8.0338 changelog update tba * changelog * 0.3.8.0341 * BE update * 0.3.8.0353 * changelog * removed duplicates * 0.3.8.0355 fixed error in getIDC * 0.3.8.0356 revert to BIS_fnc_param as params threw errors * 0.3.8.0357 fixes for #496 #497 * 0.3.8.0359 fixed #497 fixed #496 * 0.3.8.0365 * 0.3.8.0371 * 0.3.8.0373 * 0.3.8.0379 * 0.3.8.0381 * 0.3.8.0386 * 0.3.8.0393 * 0.3.8.0395 * 0.3.8.0396 * 0.3.8.0397 * 0.3.8.0406 * 0.3.8.0409 * 0.3.8.0410 loot balance suppress error in spawnloot make near object check based on building size * 0.3.8.0412 * 0.3.8.0414 removed classes with scope 0 test remove loot trash on gear for #498 fixed #501 * 0.3.8.0415 * same
2016-04-08 20:21:46 +00:00
if (_interactReturnOnUse != "") then {
_interactReturnOnUse call EPOCH_fnc_addItemOverflow;
};
2015-09-14 20:55:36 +00:00
{
2018-04-30 20:29:14 +00:00
_output = [_x select 0, round ((_x select 1) * _multi)] call EPOCH_giveAttributes;
Release 0.3.8 (#502) * first build for 0.3.8 * 0.3.8.0190 * 0.3.8.0202 * 0.3.8.0213 * 0.3.7.0214 * 0.3.8.0222 * 0.3.8.0246 * 0.3.8.0247 fixed typo * 0.3.8.0249 more fixes for server compiler * 0.3.8.0256 * add build number and simple batch file for packing * match build number with internal * add build numbers to server pbo's and mission files also reworked build script for more options * 0.3.8.0261 * 0.3.8.0261 * 0.3.8.0283 * 0.3.8.0284 * changelog * 0.3.8.0307 * 0.3.8.0311 * remove old BEC plugin * update redis-server.exe to latest build and full config * 0.3.8.0314 * 0.3.8.0315 * inverse logic This should correctly prevent spawning these units nearby jammer or protection zones * use pushbackUnique here * optimized loot function by using selectRandom instead of slower sqf logic * 0.3.8.0316 * make use of new getDir functionality instead of BIS fnc * add lower disconnect value to server.cfg * use new getpos functionality * 0.3.8.0317 * 0.3.8.0319 * 0.3.8.0327 * 0.3.8.0338 changelog update tba * changelog * 0.3.8.0341 * BE update * 0.3.8.0353 * changelog * removed duplicates * 0.3.8.0355 fixed error in getIDC * 0.3.8.0356 revert to BIS_fnc_param as params threw errors * 0.3.8.0357 fixes for #496 #497 * 0.3.8.0359 fixed #497 fixed #496 * 0.3.8.0365 * 0.3.8.0371 * 0.3.8.0373 * 0.3.8.0379 * 0.3.8.0381 * 0.3.8.0386 * 0.3.8.0393 * 0.3.8.0395 * 0.3.8.0396 * 0.3.8.0397 * 0.3.8.0406 * 0.3.8.0409 * 0.3.8.0410 loot balance suppress error in spawnloot make near object check based on building size * 0.3.8.0412 * 0.3.8.0414 removed classes with scope 0 test remove loot trash on gear for #498 fixed #501 * 0.3.8.0415 * same
2016-04-08 20:21:46 +00:00
if (_output != "") then {
[_output, 5] call Epoch_message_stack;
Release 0.3.8 (#502) * first build for 0.3.8 * 0.3.8.0190 * 0.3.8.0202 * 0.3.8.0213 * 0.3.7.0214 * 0.3.8.0222 * 0.3.8.0246 * 0.3.8.0247 fixed typo * 0.3.8.0249 more fixes for server compiler * 0.3.8.0256 * add build number and simple batch file for packing * match build number with internal * add build numbers to server pbo's and mission files also reworked build script for more options * 0.3.8.0261 * 0.3.8.0261 * 0.3.8.0283 * 0.3.8.0284 * changelog * 0.3.8.0307 * 0.3.8.0311 * remove old BEC plugin * update redis-server.exe to latest build and full config * 0.3.8.0314 * 0.3.8.0315 * inverse logic This should correctly prevent spawning these units nearby jammer or protection zones * use pushbackUnique here * optimized loot function by using selectRandom instead of slower sqf logic * 0.3.8.0316 * make use of new getDir functionality instead of BIS fnc * add lower disconnect value to server.cfg * use new getpos functionality * 0.3.8.0317 * 0.3.8.0319 * 0.3.8.0327 * 0.3.8.0338 changelog update tba * changelog * 0.3.8.0341 * BE update * 0.3.8.0353 * changelog * removed duplicates * 0.3.8.0355 fixed error in getIDC * 0.3.8.0356 revert to BIS_fnc_param as params threw errors * 0.3.8.0357 fixes for #496 #497 * 0.3.8.0359 fixed #497 fixed #496 * 0.3.8.0365 * 0.3.8.0371 * 0.3.8.0373 * 0.3.8.0379 * 0.3.8.0381 * 0.3.8.0386 * 0.3.8.0393 * 0.3.8.0395 * 0.3.8.0396 * 0.3.8.0397 * 0.3.8.0406 * 0.3.8.0409 * 0.3.8.0410 loot balance suppress error in spawnloot make near object check based on building size * 0.3.8.0412 * 0.3.8.0414 removed classes with scope 0 test remove loot trash on gear for #498 fixed #501 * 0.3.8.0415 * same
2016-04-08 20:21:46 +00:00
};
2015-09-14 20:55:36 +00:00
} foreach _interactAttributes;
};
_removed
2015-09-14 20:55:36 +00:00
};
switch _interactOption do {
2015-12-29 18:22:24 +00:00
case 0: {
2016-05-06 20:30:10 +00:00
_magazineSizeMax = getNumber (configfile >> "CfgMagazines" >> _item >> "count");
2015-12-29 18:22:24 +00:00
// allow repack for all magazines with greater than 1 bullet
2016-01-08 04:32:52 +00:00
if (_magazineSizeMax > 1) then {
2017-10-16 22:24:38 +00:00
[_item,_magazineSizeMax] spawn {
params ["_item","_magazineSizeMax"];
if (player == vehicle player) then {
closeDialog 0;
player playMove 'AinvPknlMstpSnonWrflDnon_medic0';
player playMove 'AinvPknlMstpSnonWrflDnon_medicEnd';
uisleep 5;
};
_magazineSize = 0;
_magazinesAmmoFull = magazinesAmmoFull player;
{
if (_item isEqualTo (_x select 0)) then {
if (!(_x select 2)) then {
_magazineSize = _magazineSize + (_x select 1);
};
2016-01-08 04:32:52 +00:00
};
2017-10-16 22:24:38 +00:00
} forEach _magazinesAmmoFull;
player removeMagazines _item;
for "_i" from 1 to floor (_magazineSize / _magazineSizeMax) do
{
2018-01-15 17:48:36 +00:00
[_item, _magazineSizeMax] call EPOCH_fnc_addMagazineOverflow;
2015-12-29 18:22:24 +00:00
};
2017-10-16 22:24:38 +00:00
if ((_magazineSize % _magazineSizeMax) > 0) then {
2018-01-15 17:48:36 +00:00
[_item, floor (_magazineSize % _magazineSizeMax)] call EPOCH_fnc_addMagazineOverflow;
2017-10-16 22:24:38 +00:00
};
["Ammo Repacked", 5] call Epoch_message;
2015-12-29 18:22:24 +00:00
};
};
};
2015-09-14 20:55:36 +00:00
case 1: _unifiedInteract; // Eat 1
case 2: _unifiedInteract; //Drink 2
case 3: { // Build 3
closeDialog 0;
_partCheck = _item in (magazines player);
2016-05-06 20:30:10 +00:00
_buildClass = getText(_cfgItemInteractions >> "buildClass");
if (_buildClass != "" && _partCheck) then {
_isStorage = getNumber(_cfgItemInteractions >> "isStorage");
2015-09-14 20:55:36 +00:00
2015-10-28 15:16:00 +00:00
_isOk = if (_isStorage == 1 || _buildClass isKindOf "Secure_Storage_Temp") then { EPOCH_StorageSlotsCount > 0 } else { EPOCH_BuildingSlotCount > 0 };
2015-09-14 20:55:36 +00:00
if (isNil "EPOCH_simulSwap_Lock") then {
if !(isNil "_isOk") then {
if (_isOk) then {
if (_buildClass call EPOCH_isBuildAllowed) then {
if (EPOCH_playerEnergy > 0) then {
EPOCH_buildMode = 1;
EPOCH_buildDirection = 0;
// base building
_pos = player modelToWorldVisual[0, 5, 0];
_pos set[2, getPosATL player select 2];
if (_buildClass isKindOf "ThingX") then {
// prevent spawning if another simulated object exists still
_otherObjects = nearestObjects[player, [_buildClass], 100];
if (_otherObjects isEqualTo []) then {
_object=createVehicle[_buildClass,_pos,[],0,"CAN_COLLIDE"];
_object setDir ((getDir player) - 180);
[format["Press '%1' to drop object.", "1"], 5] call Epoch_message;
2015-09-14 20:55:36 +00:00
if (([player, _item] call BIS_fnc_invRemove) == 1) then {
[_object] spawn EPOCH_simulSwap;
};
}
else {
2016-06-18 01:22:29 +00:00
["Building Disallowed: Frequency Unstable", 5] call Epoch_message;
2015-09-14 20:55:36 +00:00
};
2017-05-02 00:23:00 +00:00
}
else {
// use ghost GhostPreview if set
_ghostClass = getText(_cfgBaseBuilding >> _buildClass >> "GhostPreview");
if !(_ghostClass isEqualTo "") then {
_buildClass = _ghostClass;
};
_object=createVehicle[_buildClass,_pos,[],0,"CAN_COLLIDE"];
_object setDir ((getDir player) - 180);
[format["Press '%1' to drop object.", "1"], 5] call Epoch_message;
[_object,_item] spawn EPOCH_staticMove;
2015-09-14 20:55:36 +00:00
};
}
else {
2016-06-18 01:22:29 +00:00
["Need Energy", 5] call Epoch_message;
2015-09-14 20:55:36 +00:00
};
};
} else {
2016-06-18 01:22:29 +00:00
["World limit reached", 5] call Epoch_message;
2015-09-14 20:55:36 +00:00
};
};
};
};
};
case 4: { // Refuel 4
2017-09-14 17:51:06 +00:00
if !(player == vehicle player) exitwith {
["Fill from outside!", 5] call Epoch_message;
};
2016-04-17 20:28:21 +00:00
_vehicles = player nearEntities [["LandVehicle","Ship","Air","Tank"], 30];
2015-09-14 20:55:36 +00:00
if (cursorTarget in _vehicles) then {
_vehicle = cursorTarget;
_currentFuel = fuel _vehicle;
2016-01-08 22:27:07 +00:00
_canCapacity = _interactAttributes param [0,10];
2015-09-14 20:55:36 +00:00
_fuelCapacity = getNumber (configfile >> "CfgVehicles" >> (typeOf _vehicle) >> "fuelCapacity");
_currentFuel = _currentFuel * _fuelCapacity;
_newFuel = _currentFuel + _canCapacity;
_newFuel = _newFuel / _fuelCapacity;
if (_item call _removeItem) then {
2017-10-16 22:24:38 +00:00
[_interactReturnOnUse,_vehicle,_newFuel] spawn {
params ["_interactReturnOnUse","_vehicle","_newFuel"];
closeDialog 0;
player playMove 'AinvPknlMstpSnonWrflDnon_medic0';
player playMove 'AinvPknlMstpSnonWrflDnon_medicEnd';
uisleep 5;
_interactReturnOnUse call EPOCH_fnc_addItemOverflow;
[_vehicle,_newFuel,player,Epoch_personalToken] remoteExec ["EPOCH_server_fillVehicle",2];
["Fuel Added", 5] call Epoch_message;
};
2015-09-14 20:55:36 +00:00
};
};
};
case 5: {
2017-10-16 22:24:38 +00:00
if !(player == vehicle player) exitwith {
2018-01-10 20:16:29 +00:00
["Fill from outside!", 5] call Epoch_message;
2017-10-16 22:24:38 +00:00
};
2016-04-17 20:28:21 +00:00
_vehicles = player nearEntities [["LandVehicle","Ship","Air","Tank"], 30];
2016-01-08 22:27:07 +00:00
_canCapacity = _interactAttributes param [0,10];
2015-09-14 20:55:36 +00:00
if (cursorTarget in _vehicles) then {
_vehicle = cursorTarget;
_fuelCapacity = getNumber (configfile >> "CfgVehicles" >> (typeOf _vehicle) >> "fuelCapacity");
_newFuel = (((fuel _vehicle) * _fuelCapacity) - _canCapacity) / _fuelCapacity;
if (_newFuel > 0) then {
if (_item call _removeItem) then {
2018-01-10 20:16:29 +00:00
[_interactReturnOnUse,_vehicle,_newFuel,_item] spawn {
params ["_interactReturnOnUse","_vehicle","_newFuel","_item"];
2017-10-16 22:24:38 +00:00
closeDialog 0;
player playMove 'AinvPknlMstpSnonWrflDnon_medic0';
player playMove 'AinvPknlMstpSnonWrflDnon_medicEnd';
uisleep 5;
_interactReturnOnUse call EPOCH_fnc_addItemOverflow;
[_vehicle,_newFuel,player,Epoch_personalToken] remoteExec ["EPOCH_server_fillVehicle",2];
2018-01-10 20:16:29 +00:00
[format["%1 Filled",_item call EPOCH_itemDisplayName], 5] call Epoch_message;
2017-10-16 22:24:38 +00:00
};
2015-09-14 20:55:36 +00:00
};
} else {
2016-06-18 01:22:29 +00:00
["Not Enough Fuel", 5] call Epoch_message;
2015-09-14 20:55:36 +00:00
};
2016-01-08 22:27:07 +00:00
} else {
// find any other nearby fuel sources
_transportFuel = 0;
{
_transportFuel = _transportFuel + getNumber (configFile >> "CfgVehicles" >> (typeOf _x) >> "transportFuel");
} forEach (player nearObjects["ALL", 6]);
if (_transportFuel > _canCapacity) then {
if (_item call _removeItem) then {
2018-01-10 20:16:29 +00:00
[_interactReturnOnUse,_item] spawn {
params ["_interactReturnOnUse","_item"];
2017-10-16 22:24:38 +00:00
closeDialog 0;
player playMove 'AinvPknlMstpSnonWrflDnon_medic0';
player playMove 'AinvPknlMstpSnonWrflDnon_medicEnd';
uisleep 5;
_interactReturnOnUse call EPOCH_fnc_addItemOverflow;
2018-01-10 20:16:29 +00:00
[format["%1 Filled",_item call EPOCH_itemDisplayName], 5] call Epoch_message;
2017-10-16 22:24:38 +00:00
};
2016-01-08 22:27:07 +00:00
};
} else {
2016-06-18 01:22:29 +00:00
["Not Enough Fuel", 5] call Epoch_message;
2016-01-08 22:27:07 +00:00
};
2015-09-14 20:55:36 +00:00
};
};
case 6: _unifiedInteract; //Clean -25
case 7: _unifiedInteract; //Warm + 1
case 8: _unifiedInteract; //Cold -1
2018-04-30 20:29:14 +00:00
case 9: _unifiedInteract; //Energy 100
2015-09-14 20:55:36 +00:00
case 10: { // Repair 10 - Lite
2017-10-16 22:24:38 +00:00
if !(player == vehicle player) exitwith {
["Repair from outside!", 5] call Epoch_message;
};
2016-04-17 20:28:21 +00:00
_vehicles = player nearEntities [["LandVehicle","Ship","Air","Tank"], 30];
2015-09-14 20:55:36 +00:00
_vehicle = cursorTarget;
if (_vehicle in _vehicles) then {
if (_item call _removeItem) then {
2017-10-16 22:24:38 +00:00
[_vehicle] spawn {
params ["_vehicle"];
closeDialog 0;
player playMove 'AinvPknlMstpSnonWrflDnon_medic0';
player playMove 'AinvPknlMstpSnonWrflDnon_medicEnd';
_vehicle say3d 'vehicle_repair';
uisleep 5;
_highestDMG = 0;
_currentHIT = -1;
_currentDMG = 0;
{
_currentDMG = _x;
if (_currentDMG > _highestDMG) then {
_highestDMG = _currentDMG;
_currentHIT = _forEachIndex;
};
}forEach ((getAllHitPointsDamage _vehicle) param [2,[]]);
if (_highestDMG > 0) then {
_newDMG = ((_highestDMG - 0.5) max 0);
if (local _vehicle) then {
[_vehicle, [[_currentHIT, _newDMG]] ] call EPOCH_client_repairVehicle;
} else {
[_vehicle,[[_currentHIT,_newDMG]],player,Epoch_personalToken] remoteExec ["EPOCH_server_repairVehicle",2];
};
2015-09-14 20:55:36 +00:00
} else {
2017-10-16 22:24:38 +00:00
if ((damage _vehicle) > 0) then {
[_vehicle,["ALL",0],player,Epoch_personalToken] remoteExec ["EPOCH_server_repairVehicle",2];
};
2015-09-14 20:55:36 +00:00
};
2017-10-16 22:24:38 +00:00
["Vehicle Partially Repaired", 5] call Epoch_message;
2015-09-14 20:55:36 +00:00
};
};
};
};
case 11: { // Repair 11 - Heavy
2017-10-16 22:24:38 +00:00
if !(player == vehicle player) exitwith {
["Repair from outside!", 5] call Epoch_message;
};
2016-04-17 20:28:21 +00:00
_vehicles = player nearEntities [["LandVehicle","Ship","Air","Tank"], 30];
2015-09-14 20:55:36 +00:00
_vehicle = cursorTarget;
if (_vehicle in _vehicles) then {
if (_item call _removeItem) then {
2017-10-16 22:24:38 +00:00
[_vehicle] spawn {
params ["_vehicle"];
closeDialog 0;
player playMove 'AinvPknlMstpSnonWrflDnon_medic0';
player playMove 'AinvPknlMstpSnonWrflDnon_medicEnd';
uisleep 5;
_vehicle say3d 'vehicle_repair';
[_vehicle,["ALL",0],player,Epoch_personalToken] remoteExec ["EPOCH_server_repairVehicle",2];
["Vehicle Fully Repaired", 5] call Epoch_message;
};
2015-09-14 20:55:36 +00:00
};
};
};
// case 12 consume paincan and set texture on base object (only if has slot and is static)
case 12: {
closeDialog 0;
_vehicles = player nearObjects["Const_WoodWalls_static_F", 5];
_vehicle = cursorTarget;
if (_vehicle in _vehicles) then {
if ("" call EPOCH_isBuildAllowed) then {
_color = getArray(_cfgBaseBuilding >> (typeOf _vehicle) >> "availableTextures");
2015-09-14 20:55:36 +00:00
if !(_color isEqualTo[]) then {
if (_item call _removeItem) then {
// find _paintCanIndex from config
_paintCanIndex = getNumber(_cfgItemInteractions >> "textureIndex");
_paintCanColor = getText(_cfgItemInteractions >> "colorName");
2015-09-14 20:55:36 +00:00
2015-12-23 17:38:11 +00:00
[_vehicle,_paintCanIndex,player,Epoch_personalToken] remoteExec ["EPOCH_server_paintBUILD",2];
2015-09-14 20:55:36 +00:00
2016-06-18 01:22:29 +00:00
[format["Wall Painted %1", _paintCanColor], 5] call Epoch_message;
2015-09-14 20:55:36 +00:00
};
};
}
else {
2016-06-18 01:22:29 +00:00
["Disallowed", 5] call Epoch_message;
2015-09-14 20:55:36 +00:00
};
};
};
case 13: { //Heal Player
_vehicles = player nearEntities[["Epoch_Male_F", "Epoch_Female_F"], 6];
_vehicle = cursorTarget;
if !(_vehicle in _vehicles) then {
_vehicle = player;
};
if (damage _vehicle != 0 || {_x > 0} count ((getallhitpointsdamage _vehicle) select 2) > 0) then {
if (_item call _removeItem) then {
2017-10-16 22:24:38 +00:00
[_vehicle] spawn {
params ["_vehicle"];
if (player == vehicle player) then {
closeDialog 0;
player playMove 'AinvPknlMstpSnonWrflDnon_medic0';
player playMove 'AinvPknlMstpSnonWrflDnon_medicEnd';
uisleep 5;
};
[_vehicle,["ALL",0],player,Epoch_personalToken] remoteExec ["EPOCH_server_repairVehicle",2];
if (_vehicle isEqualTo player) then {
["Healed yourself", 5] call Epoch_message;
} else {
["Healed other player", 5] call Epoch_message;
};
2015-09-14 20:55:36 +00:00
};
};
};
};
2016-01-08 22:27:07 +00:00
case 14: { // Unpack Backpack
if (_item call _removeItem) then {
[_interactReturnOnUse,player,Epoch_personalToken] remoteExec ["EPOCH_server_unpackBackpack",2];
2016-06-18 01:22:29 +00:00
["Unpacked backpack", 5] call Epoch_message;
2016-01-08 22:27:07 +00:00
};
};
case 15: { // Read
_msg = getArray(missionConfigFile >> "CfgReadingDocuments" >> _item >> "displayMessage");
if!(_msg isEqualTo [])then{
{
[_x,5] call Epoch_message_stack;
}forEach _msg;
}else{
["This document can't be read yet. Blame DirtySanchez!",5] call Epoch_message;
};
};
2017-10-16 18:56:04 +00:00
case 16: { // Morphine
_vehicle = player;
if (damage _vehicle != 0 || {_x > 0} count ((getallhitpointsdamage _vehicle) select 2) > 0) then {
if (call _unifiedInteract) then {
2017-10-16 22:24:38 +00:00
[_vehicle,_item] spawn {
params ["_vehicle","_item"];
if (player == vehicle player) then {
closeDialog 0;
player playMove 'AinvPknlMstpSnonWrflDnon_medic0';
player playMove 'AinvPknlMstpSnonWrflDnon_medicEnd';
uisleep 5;
};
2017-10-16 22:24:38 +00:00
private _out = [];
{
if (_x > 0) then {
_out pushback [_foreachindex,((_x - 0.2) min 0.45) max 0];
};
}forEach ((getAllHitPointsDamage _vehicle) param [2,0]);
if (_out isequalto []) then {
if ((damage _vehicle) > 0) then {
_out = ["ALL",0];
};
};
2017-10-16 22:24:38 +00:00
if !(_out isequalto []) then {
[_vehicle,_out,player,Epoch_personalToken] remoteExec ["EPOCH_server_repairVehicle",2];
};
[format["Used %1 on yourself",_item call EPOCH_itemDisplayName], 5] call Epoch_message;
};
};
} else {
[format["%1 is not needed at this time",_item call EPOCH_itemDisplayName], 5] call Epoch_message;
};
};
2018-05-01 15:03:30 +00:00
case 17: { // Defibrillator
_maxMagRnd = getnumber (configfile >> "cfgMagazines" >> _item >> "count");
_totalDefis = (magazinesammo player) select {(_x select 0) isequalto _item};
_totalMags = (magazinesammo player) select {(_x select 0) in ["EnergyPackLg","EnergyPack"]};
if (_totalDefis isequalto []) exitwith {};
if !(_totalMags isequalto []) then {
_CurDefiArr = [];
{
if ((_x select 1) < _maxMagRnd) exitwith {
_CurDefiArr = _totalDefis deleteat _foreachindex;
};
} foreach _totalDefis;
if (_CurDefiArr isequalto []) exitwith {
["Defibrillator is already fully charged",5] call Epoch_Message;
};
_remove = _totalMags deleteat 0;
_remove params ["_class","_rounds"];
_charge = _rounds min (_maxMagRnd - (_CurDefiArr select 1));
if (_rounds - _charge > 0) then {
_remove set [1,_rounds - _charge];
_totalMags pushback _remove;
};
if (_charge > 0) then {
_CurDefiArr set [1,(_CurDefiArr select 1) + _charge];
_totalDefis pushback _CurDefiArr;
player removemagazines _item;
player removemagazines "EnergyPackLg";
player removemagazines "EnergyPack";
{
_x call EPOCH_fnc_addMagazineOverflow;
} foreach _totalMags;
{
_x call EPOCH_fnc_addMagazineOverflow;
} foreach _totalDefis;
[format ["Recharged Defibrillator with %1 Energy",_charge],5] call Epoch_Message;
};
}
else {
["You need an Energy Pack",5] call Epoch_Message;
};
};
2015-09-14 20:55:36 +00:00
default {
2016-06-18 01:22:29 +00:00
["Found nothing", 5] call Epoch_message;
2015-09-14 20:55:36 +00:00
};
};