From 66f15a968fbbf81fd7f610c73f094a41416bcad4 Mon Sep 17 00:00:00 2001 From: vbawol Date: Sat, 24 Jun 2017 10:36:48 -0500 Subject: [PATCH] make bitePlayer function also work with vehicles --- .../environment/EPOCH_client_bitePlayer.sqf | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/Sources/epoch_code/compile/environment/EPOCH_client_bitePlayer.sqf b/Sources/epoch_code/compile/environment/EPOCH_client_bitePlayer.sqf index d979a939..8d46ecef 100644 --- a/Sources/epoch_code/compile/environment/EPOCH_client_bitePlayer.sqf +++ b/Sources/epoch_code/compile/environment/EPOCH_client_bitePlayer.sqf @@ -22,14 +22,40 @@ NOTHING */ //[[[cog import generate_private_arrays ]]] -private ["_animConfigArray","_animationEffect","_animationEffectGlobal","_bleedAmount","_bleedChance","_bloodpAmount","_bloodpChance","_canSee","_cfgObjectInteraction","_distance","_fatigueChance","_handle","_handles","_ppEffect","_say3dsoundsConfig","_selectedMove","_selectedSound","_soundConfigArray","_soundEffect","_soundEffectGlobal","_switchMovehandlerConfig","_toxicChance"]; +private ["_animConfigArray","_animationEffect","_animationEffectGlobal","_bleedAmount","_bleedChance","_bloodpAmount","_bloodpChance","_canSee","_cfgObjectInteraction","_distance","_doAttack","_fatigueChance","_ppEffect","_say3dsoundsConfig","_selectedMove","_selectedSound","_soundConfigArray","_soundEffect","_soundEffectGlobal","_switchMovehandlerConfig","_target","_toxicChance"]; //[[[end]]] params [["_unit",objNull],["_target",player]]; if (isNull _unit && isNull _target) exitWith {}; -if !(_target isEqualTo player) then { - // re to other player - [_unit,_target] remoteExec ["EPOCH_client_bitePlayer", _target]; +_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 + if (isplayer _target) then { + [_unit,_target] remoteExec ["EPOCH_client_bitePlayer", _target]; + }; + }; } else { + // target is inside a vehicle, target entire vehicle crew + { + if (_x isEqualTo player) then { + // handle attack for local player if inside vehicle + _target = _x; + _doAttack = true; + } else { + // send attack to other players + if (isplayer _x) then { + [_unit,_x] remoteExec ["EPOCH_client_bitePlayer", _x]; + }; + }; + } forEach (crew _target); +}; + +if (_doAttack) then { if !(isNull _unit && alive _unit) then {