2015-12-15 22:43:26 +00:00
|
|
|
/*
|
|
|
|
Author: Aaron Clark - EpochMod.com
|
|
|
|
|
|
|
|
Contributors:
|
|
|
|
|
|
|
|
Description:
|
|
|
|
Performs damage related effects
|
|
|
|
|
|
|
|
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/environment/EPOCH_client_bitePlayer.sqf
|
2015-12-15 22:43:26 +00:00
|
|
|
|
|
|
|
Example:
|
2016-05-23 20:01:40 +00:00
|
|
|
_dog call EPOCH_client_bitePlayer;
|
2015-12-15 22:43:26 +00:00
|
|
|
|
|
|
|
Parameter(s):
|
2016-06-15 00:58:22 +00:00
|
|
|
_unit: OBJECT - attacker
|
2015-12-15 22:43:26 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
NOTHING
|
|
|
|
*/
|
2016-09-01 02:20:07 +00:00
|
|
|
//[[[cog import generate_private_arrays ]]]
|
2017-09-27 02:20:41 +00:00
|
|
|
private ["_animConfigArray","_animationEffect","_animationEffectGlobal","_bleedAmount","_bleedChance","_bloodpAmount","_bloodpChance","_canSee","_cfgObjectInteraction","_distance","_doAttack","_fatigueChance","_playerBloodPKeyFinal","_playerImmunityKeyFinal","_playerToxicityKeyFinal","_ppEffect","_say3dsoundsConfig","_selectedMove","_selectedSound","_soundConfigArray","_soundEffect","_soundEffectGlobal","_switchMovehandlerConfig","_target","_toxicAmount","_toxicChance"];
|
2016-09-01 02:20:07 +00:00
|
|
|
//[[[end]]]
|
2016-06-15 00:58:22 +00:00
|
|
|
params [["_unit",objNull],["_target",player]];
|
|
|
|
if (isNull _unit && isNull _target) exitWith {};
|
2017-06-24 15:36:48 +00:00
|
|
|
_doAttack = false;
|
|
|
|
|
|
|
|
// check if target is on foot
|
|
|
|
if (isNull objectParent _target) then {
|
|
|
|
if (_target isEqualTo player) then {
|
|
|
|
// handle attack for local player
|
|
|
|
_doAttack = true;
|
|
|
|
} else {
|
|
|
|
// send attack to other player
|
2017-06-24 15:40:41 +00:00
|
|
|
if (isPlayer _target) then {
|
2017-10-03 14:11:18 +00:00
|
|
|
[_unit] remoteExec ["EPOCH_client_bitePlayer", _target];
|
2017-06-24 15:36:48 +00:00
|
|
|
};
|
|
|
|
};
|
2016-06-15 00:58:22 +00:00
|
|
|
} else {
|
2017-06-24 15:36:48 +00:00
|
|
|
// target is inside a vehicle, target entire vehicle crew
|
2017-10-03 14:11:18 +00:00
|
|
|
private _targets = [];
|
2017-06-24 15:36:48 +00:00
|
|
|
{
|
|
|
|
if (_x isEqualTo player) then {
|
|
|
|
// handle attack for local player if inside vehicle
|
|
|
|
_target = _x;
|
|
|
|
_doAttack = true;
|
|
|
|
} else {
|
|
|
|
// send attack to other players
|
2017-06-24 15:40:41 +00:00
|
|
|
if (isPlayer _x) then {
|
2017-10-03 14:11:18 +00:00
|
|
|
_targets pushBack _x;
|
2017-06-24 15:36:48 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
} forEach (crew _target);
|
2017-10-03 14:11:18 +00:00
|
|
|
if !(_targets isEqualTo []) then {
|
|
|
|
[_unit] remoteExec ["EPOCH_client_bitePlayer", _targets];
|
|
|
|
};
|
2017-06-24 15:36:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (_doAttack) then {
|
2015-12-15 22:43:26 +00:00
|
|
|
|
2016-06-15 00:58:22 +00:00
|
|
|
if !(isNull _unit && alive _unit) then {
|
2015-09-14 20:55:36 +00:00
|
|
|
|
2016-06-15 00:58:22 +00:00
|
|
|
_cfgObjectInteraction = (('CfgObjectInteractions' call EPOCH_returnConfig) >> (typeOf _unit));
|
|
|
|
if (isClass _cfgObjectInteraction) then {
|
2016-07-05 19:15:42 +00:00
|
|
|
|
2016-06-15 00:58:22 +00:00
|
|
|
_distance = getNumber (_cfgObjectInteraction >> "distance");
|
|
|
|
_toxicChance = getNumber (_cfgObjectInteraction >> "toxicChance");
|
2016-07-05 19:15:42 +00:00
|
|
|
_bleedChance = getNumber (_cfgObjectInteraction >> "bleedChance");
|
2016-06-15 00:58:22 +00:00
|
|
|
_bloodpChance = getNumber (_cfgObjectInteraction >> "bloodpChance");
|
|
|
|
_fatigueChance = getNumber (_cfgObjectInteraction >> "fatigueChance");
|
|
|
|
_bleedAmount = getNumber (_cfgObjectInteraction >> "bleedAmount");
|
|
|
|
_bloodpAmount = getNumber (_cfgObjectInteraction >> "bloodpAmount");
|
2017-09-20 14:23:46 +00:00
|
|
|
_toxicAmount = getNumber (_cfgObjectInteraction >> "toxicAmount");
|
2016-07-05 19:15:42 +00:00
|
|
|
|
2016-06-15 00:58:22 +00:00
|
|
|
_soundConfigArray = getArray (_cfgObjectInteraction >> "soundEffect");
|
2016-07-06 19:35:20 +00:00
|
|
|
_soundEffect = "";
|
2016-06-15 00:58:22 +00:00
|
|
|
if !(_soundConfigArray isEqualTo []) then {
|
|
|
|
_soundEffect = selectRandom _soundConfigArray;
|
|
|
|
};
|
|
|
|
_soundEffectGlobal = getNumber (_cfgObjectInteraction >> "soundEffectGlobal");
|
|
|
|
_animConfigArray = getArray (_cfgObjectInteraction >> "animationEffect");
|
2016-07-06 19:35:20 +00:00
|
|
|
_animationEffect = "";
|
2016-06-15 00:58:22 +00:00
|
|
|
if !(_animConfigArray isEqualTo []) then {
|
|
|
|
_animationEffect = selectRandom _animConfigArray;
|
|
|
|
};
|
|
|
|
_animationEffectGlobal = getNumber (_cfgObjectInteraction >> "animationEffectGlobal");
|
|
|
|
_canSee = call compile (getText (_cfgObjectInteraction >> "canSee"));
|
2016-09-01 02:20:07 +00:00
|
|
|
_ppEffect = getArray (_cfgObjectInteraction >> "ppEffect");
|
2015-09-14 20:55:36 +00:00
|
|
|
|
2016-07-05 18:22:14 +00:00
|
|
|
if ((_unit distance player) < _distance && _canSee) then {
|
|
|
|
|
|
|
|
_say3dsoundsConfig = 'CfgSay3Dhandler' call EPOCH_returnConfig;
|
|
|
|
_switchMovehandlerConfig = 'CfgSwitchMovehandler' call EPOCH_returnConfig;
|
2016-05-23 20:01:40 +00:00
|
|
|
|
2016-07-05 18:22:14 +00:00
|
|
|
if (_soundEffect isEqualType []) then {
|
|
|
|
_soundEffect params ["_soundEffectFinal",["_soundEffectRange",0]];
|
|
|
|
playSound3D [_soundEffectFinal, _unit, false, getPosASL _unit, 1, 1, _soundEffectRange];
|
|
|
|
} else {
|
|
|
|
_selectedSound = (_say3dsoundsConfig >> _soundEffect);
|
|
|
|
if (isClass _selectedSound) then {
|
|
|
|
_unit say3D _soundEffect;
|
|
|
|
if (_soundEffectGlobal isEqualTo 1) then {
|
|
|
|
[player, _unit, _soundEffect, Epoch_personalToken] remoteExec ["EPOCH_server_handle_say3D",2];
|
|
|
|
};
|
2016-06-15 00:58:22 +00:00
|
|
|
};
|
|
|
|
};
|
2016-05-23 20:01:40 +00:00
|
|
|
|
2016-07-05 18:22:14 +00:00
|
|
|
_selectedMove = (_switchMovehandlerConfig >> _animationEffect);
|
|
|
|
if (isClass _selectedMove) then {
|
|
|
|
_unit switchMove _animationEffect;
|
|
|
|
if (_animationEffectGlobal isEqualTo 1) then {
|
|
|
|
[player, _animationEffect, Epoch_personalToken, _unit] remoteExec ["EPOCH_server_handle_switchMove",2];
|
|
|
|
};
|
2016-06-15 00:58:22 +00:00
|
|
|
};
|
2016-05-23 20:01:40 +00:00
|
|
|
|
2016-07-05 18:22:14 +00:00
|
|
|
if (random 1 < _toxicChance) then {
|
2017-09-27 02:20:41 +00:00
|
|
|
_playerToxicityKeyFinal = "EPOCH_playerToxicity";
|
|
|
|
_playerImmunityKeyFinal = "EPOCH_playerImmunity";
|
2017-09-28 17:00:48 +00:00
|
|
|
if !(isNil "_playerToxicityKey") then {_playerToxicityKeyFinal = _playerToxicityKey};
|
|
|
|
if !(isNil "_playerImmunityKey") then {_playerImmunityKeyFinal = _playerImmunityKey};
|
2017-09-27 02:20:41 +00:00
|
|
|
[_playerToxicityKeyFinal,random(_toxicAmount - (missionNamespace getVariable [_playerImmunityKeyFinal, 0])),100,0] call EPOCH_fnc_setVariableLimited;
|
2016-07-05 18:22:14 +00:00
|
|
|
};
|
|
|
|
if (random 1 < _bleedChance) then {
|
|
|
|
player setBleedingRemaining((getBleedingRemaining player) + _bleedAmount);
|
|
|
|
};
|
|
|
|
if (random 1 < _bloodpChance) then {
|
2017-09-27 02:20:41 +00:00
|
|
|
_playerBloodPKeyFinal = "EPOCH_playerBloodP";
|
2017-09-28 17:00:48 +00:00
|
|
|
if !(isNil "_playerBloodPKey") then {_playerBloodPKeyFinal = _playerBloodPKey};
|
2017-10-04 12:57:28 +00:00
|
|
|
[_playerBloodPKeyFinal,_bloodpAmount,190,0] call EPOCH_fnc_setVariableLimited;
|
2016-09-01 02:20:07 +00:00
|
|
|
if !(_ppEffect isEqualTo []) then {
|
2016-09-05 04:32:38 +00:00
|
|
|
[_ppEffect] spawn EPOCH_fnc_spawnEffects;
|
2016-06-15 00:58:22 +00:00
|
|
|
};
|
2015-09-14 20:55:36 +00:00
|
|
|
};
|
2016-07-05 18:22:14 +00:00
|
|
|
if (random 1 < _fatigueChance) then {
|
|
|
|
player setFatigue 1;
|
|
|
|
};
|
2016-06-15 00:58:22 +00:00
|
|
|
};
|
2015-09-14 20:55:36 +00:00
|
|
|
};
|
|
|
|
};
|
2015-12-15 22:43:26 +00:00
|
|
|
};
|