fnc_antidote_eff_increase =
{
private "_unit";
_unit = _this;
_poise = _unit getvariable ["poise", 0];
_antidote_effect = _unit getvariable ["antidote_eff", 0];
_unit setvariable ["antidote_eff", (_antidote_effect + 20 + random 5), true];
if ((_unit getvariable ["antidote_eff", 0]) > (100 - _poise/2)) then
{
_unit setvariable ["antidote_eff", 100, true];
};
};
// функция использования антидота на юните
fnc_antidote_use =
{
if (((_this select 1) getvariable ["antidote_amount", antidote_ammount_global]) > 0) then
{
(_this select 1) setvariable
[
"antidote_amount",
(((_this select 1) getvariable ["antidote_amount", antidote_ammount_global]) - 1),
true
];
if (((_this select 1) getvariable ["antidote_amount", antidote_ammount_global]) < 1) then {(_this select 0) removeaction (_this select 2);};
_poise = (_this select 0) getvariable ["poise", 1];
_antidote_value = 20 + (random 5);
if (_poise <= _antidote_value) then
{
(_this select 0) setvariable ["poise", 0, true];
[
"<t align = 'center' color='#FFFF00' shadow = '0' size = '0.6'>" + (localize "STR_Antidote_toxin_neutralized") + " " + (name (_this select 0)) + ".<br/>" +
str ((_this select 1) getvariable ["antidote_amount", antidote_ammount_global]) + " " + localize "STR_Antidote_ammount_left" + "</t>",
0.0, 0.0, 3, 2, 0, 201
] spawn BIS_fnc_dynamicText;
} else
{
(_this select 0) setvariable ["poise", _poise - _antidote_value, true];
[
"<t align = 'center' color='#FFFF00' shadow = '0' size = '0.6'>" + str ((_this select 1) getvariable ["antidote_amount", antidote_ammount_global]) + " " + localize "STR_Antidote_ammount_left" + "</t>",
0.0, 0.0, 3, 2, 0, 201
] spawn BIS_fnc_dynamicText;
};
(_this select 0) call fnc_antidote_eff_increase;
playsound ["antidote_use", true];
// передача публичной переменной для активации звука
if (isserver) then
{
public_antidote_use = true;
(owner (_this select 0)) publicvariableclient "public_antidote_use";
} else
{
public_antidote_use_server = (_this select 0);
publicvariableserver "public_antidote_use_server";
};
} else
{
(_this select 0) removeaction (_this select 2);
};
};
// функция использования антидота на себе
fnc_antidote_use_self =
{
if (((_this select 1) getvariable ["antidote_amount", antidote_ammount_global]) > 0) then
{
(_this select 0) setvariable
[
"antidote_amount",
(((_this select 0) getvariable ["antidote_amount", antidote_ammount_global]) - 1),
true
];
if (((_this select 0) getvariable ["antidote_amount", antidote_ammount_global]) < 1) then {(_this select 0) removeaction (_this select 2);};
playsound ["antidote_use", true];
_poise = (_this select 0) getvariable ["poise", 1];
_antidote_value = 20 + (random 5);
if (_poise <= _antidote_value) then
{
(_this select 0) setvariable ["poise", 0, true];
[
"<t align = 'center' color='#00FF00' shadow = '0' size = '0.6'>" + (localize "STR_Antidote_toxin_neutralized_self") + "<br/>" +
str ((_this select 1) getvariable ["antidote_amount", antidote_ammount_global]) + " " + localize "STR_Antidote_ammount_left" + "</t>",
0.0, 0.0, 3, 2, 0, 201
] spawn BIS_fnc_dynamicText;
} else
{
(_this select 0) setvariable ["poise", _poise - _antidote_value, true];
[
"<t align = 'center' color='#00FF00' shadow = '0' size = '0.6'>" + str ((_this select 1) getvariable ["antidote_amount", antidote_ammount_global]) + " " + localize "STR_Antidote_ammount_left" + "</t>",
0.0, 0.0, 3, 2, 0, 201
] spawn BIS_fnc_dynamicText;
};
(_this select 0) call fnc_antidote_eff_increase;
} else
{
(_this select 0) removeaction (_this select 2);
};
};
// функция добавления дейстий на использования антидота на всех игроков
fnc_addaction_antidote_use =
{
{
if (alive _x) then
{
_action_id = _x addaction
[
("<t color='#FFFF00'>" + (localize "STR_Antidote_action_use") + " " + (name _x)),
{_this call fnc_antidote_use},
nil,
0,
true,
true,
"",
"(_this distance _target) < 2"
];
_x setvariable ["action_antidote_id", _action_id];
};
_x spawn
{
waituntil
{
sleep 1;
((!alive _this) or ((player getvariable ["antidote_amount", antidote_ammount_global]) < 1));
};
_action_id = _this getvariable "action_antidote_id";
_this removeaction _action_id;
};
} foreach ((switchableunits + playableunits) - [player]);
};
// функция добавления действия на использование антидота на себя
fnc_addaction_antidote_use_self =
{
_action_antidote_id = player addaction
[
("<t color='#00FF00'>" + (localize "STR_Antidote_action_use_self")),
{_this call fnc_antidote_use_self},
nil,
0
];
};
// добавления действия на "антидот"
[] spawn
{
waituntil {T_INIT};
if (isnil "task_antidote") then {task_antidote = false;};
if (typeof player == "B_medic_F") then
{
waituntil
{
sleep 2;
task_antidote;
};
if (alive antidote) then
{
antidote addaction
[
("<t color='#00FF00'>" + localize "STR_Antidote_action_take"),
{
(_this select 1) removeaction (_this select 2);
deletevehicle (_this select 0);
(_this select 1) setvariable ["antidote_amount", antidote_ammount_global, true];
call fnc_addaction_antidote_use;
call fnc_addaction_antidote_use_self;
},
nil,
0,
true,
true,
"",
"(_this distance _target) < 2"
];
} else
{
if ((player getvariable ["antidote_amount", antidote_ammount_global]) > 0) then
{
call fnc_addaction_antidote_use;
call fnc_addaction_antidote_use_self;
};
};
};
};