Defibrillator

This commit is contained in:
He-Man 2018-05-01 17:03:30 +02:00
parent 7ba61ea46c
commit 1add566571
5 changed files with 108 additions and 4 deletions

View File

@ -0,0 +1,57 @@
/*
Author: He-Man - EpochMod.com
Contributors:
Description:
Epoch use Defibrillator function
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/EPOCH_DefibrillatorUse.sqf
*/
private ["_item","_energyneeded","_totalDefis","_CurDefiArr"];
params ["_unit"];
if (isplayer _unit) then {
_item = 'ItemDefibrillator';
if (_item in magazines player) then {
_energyneeded = 3;
_totalDefis = (magazinesammo player) select {(_x select 0) isequalto _item};
_CurDefiArr = [];
{
if ((_x select 1) >= _energyneeded) exitwith {
_CurDefiArr = _totalDefis deleteat _foreachindex;
};
} foreach _totalDefis;
if (_CurDefiArr isequalto []) exitwith {
["Defibrillator needs more Energy",5] call Epoch_Message;
};
if ((_CurDefiArr select 1) - _energyneeded > 0) then {
_CurDefiArr set [1,(_CurDefiArr select 1) - _energyneeded];
_totalDefis pushback _CurDefiArr;
};
player removemagazines _item;
{
_x call EPOCH_fnc_addMagazineOverflow;
} foreach _totalDefis;
_unit spawn {
player playMove 'AinvPknlMstpSnonWrflDnon_medic0';
player playMove 'AinvPknlMstpSnonWrflDnon_medicEnd';
uisleep 8;
if (alive player && isplayer _this) then {
[_this,player,Epoch_personalToken] remoteExec ['EPOCH_server_revivePlayer',2];
};
};
}
else {
['You need a Defibrillator to Revive',5] call Epoch_Message;
};
}
else {
['This Player can not be revived',5] call Epoch_Message;
};

View File

@ -431,6 +431,47 @@ switch _interactOption do {
[format["%1 is not needed at this time",_item call EPOCH_itemDisplayName], 5] call Epoch_message; [format["%1 is not needed at this time",_item call EPOCH_itemDisplayName], 5] call Epoch_message;
}; };
}; };
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;
};
};
default { default {
["Found nothing", 5] call Epoch_message; ["Found nothing", 5] call Epoch_message;

View File

@ -545,8 +545,8 @@ class player_tempGroup_requests
class player_revive class player_revive
{ {
condition = "dyna_isDeadPlayer && ('ItemDefibrillator' in dyna_magazinesPlayer)"; condition = "dyna_isDeadPlayer && isplayer dyna_cursorTarget";
action = "[dyna_cursorTarget, player, Epoch_personalToken] remoteExec ['EPOCH_server_revivePlayer',2];"; action = "dyna_cursorTarget call EPOCH_DefibrillatorUse;";
icon = "x\addons\a3_epoch_code\Data\UI\buttons\group_requests_ca.paa"; icon = "x\addons\a3_epoch_code\Data\UI\buttons\Revive.paa";
tooltip = "Revive Player"; tooltipcode = "format ['Revive %1',name dyna_cursorTarget]";
}; };

View File

@ -51,6 +51,7 @@ class CfgClientFunctions
class unit_onKilledEH {}; class unit_onKilledEH {};
class AutoRun_Check {}; class AutoRun_Check {};
class AutoRun {}; class AutoRun {};
class DefibrillatorUse {};
}; };
class building class building
{ {

View File

@ -1055,5 +1055,10 @@ class CfgItemInteractions
interactText = "USE"; interactText = "USE";
interactAttributes[] = {{"Radiation",-15},{"Thirst",-50},{"Immunity",5}}; interactAttributes[] = {{"Radiation",-15},{"Thirst",-50},{"Immunity",5}};
}; };
class ItemDefibrillator : Default
{
interactAction = 17;
interactText = "ReCharge";
};
}; };
/*[[[end]]]*/ /*[[[end]]]*/