Fix firedNear did not work as intended

This commit is contained in:
A Man
2022-05-05 17:58:36 +02:00
parent effb78fe13
commit 89d4bdfc9a

View File

@@ -1,36 +1,25 @@
//[unit, weapon, muzzle, mode, ammo, magazine, projectile]
private ["_handled"];
//Init
//[unit, firer, distance, weapon, muzzle, mode, ammo] //[unit, firer, distance, weapon, muzzle, mode, ammo]
_unit = _this select 0; local _unit = _this select 0;
_firer = _this select 1; local _firer = _this select 1;
_distance = _this select 2;
_weapon = _this select 3;
_ammo = _this select 6;
//_killerID = _firer getVariable["MemberID",0];
_handled = false; local _distance = _this select 2;
_arc = 60; local _weapon = _this select 3;
_isBallistic = (getNumber (configfile >> "CfgAmmo" >> _ammo >> "whistleOnFire") > 0); local _ammo = _this select 6;
_dmgDistance = getNumber (configfile >> "CfgAmmo" >> _ammo >> "whistleDist");
_isRocket = ((_ammo isKindOf "RocketBase") && (_firer isKindOf "CAManBase")); local _handled = false;
_isPlayer = (_unit == player); local _arc = 60;
_inVehicle = (vehicle _unit != _unit); local _isBallistic = (getNumber (configfile >> "CfgAmmo" >> _ammo >> "whistleOnFire") > 0);
//_evType = ""; local _dmgDistance = getNumber (configfile >> "CfgAmmo" >> _ammo >> "whistleDist");
//_recordable = false; local _isRocket = ((_ammo isKindOf "RocketBase") && (_firer isKindOf "CAManBase"));
local _isPlayer = (_unit == player);
local _inVehicle = (vehicle _unit != _unit);
// Both the firer and those nearby (<=8m) go into "combat" to prevent ALT-F4 // Both the firer and those nearby (<=8m) go into "combat" to prevent ALT-F4
//diag_log ("DEBUG: AMMO TYPE: " +str(_ammo)); //diag_log ("DEBUG: AMMO TYPE: " +str(_ammo));
if !(_ammo isKindOf "LitObject") then { if (!(_ammo isKindOf "LitObject") && !(_ammo isKindOf "ThrownObjects")) then {
_firer setVariable["startcombattimer", 1]; // Fired eventhandler handles the combat of the firer
if !(_firer getVariable["inCombat",false]) then {
_firer setVariable["inCombat",true,true];
};
if (_distance <= 8) then { if (_distance <= 8) then {
_unit setVariable["startcombattimer", 1]; [player,true] call fnc_setCombat;
if !(_unit getVariable["inCombat",false]) then {
_unit setVariable["inCombat",true,true];
};
}; };
}; };
@@ -38,17 +27,17 @@ private ["_handled"];
if (_firer == player) exitWith {}; if (_firer == player) exitWith {};
//Is in danger angle? //Is in danger angle?
_turretDir = _firer weaponDirection _weapon; local _turretDir = _firer weaponDirection _weapon;
_weaponDir = ((_turretDir select 0) atan2 (_turretDir select 1)); local _weaponDir = ((_turretDir select 0) atan2 (_turretDir select 1));
_pos1 = getPosATL _unit; local _pos1 = getPosATL _unit;
_pos2 = getPosATL _firer; local _pos2 = getPosATL _firer;
_facing = ((_pos1 select 0) - (_pos2 select 0)) atan2 ((_pos1 select 1) - (_pos2 select 1)); local _facing = ((_pos1 select 0) - (_pos2 select 0)) atan2 ((_pos1 select 1) - (_pos2 select 1));
_firingArc = (_weaponDir - _facing); local _firingArc = (_weaponDir - _facing);
_firingArc = (-_firingArc) max (_firingArc); local _firingArc = (-_firingArc) max (_firingArc);
//In front? //In front?
_isInFront = (_firingArc < _arc); local _isInFront = (_firingArc < _arc);
_isInRear = (_firingArc > (180 - _arc)); local _isInRear = (_firingArc > (180 - _arc));
//Ballistic Handler //Ballistic Handler
if ((_isBallistic && _isInFront) && (_distance < (_dmgDistance * 2))) then { if ((_isBallistic && _isInFront) && (_distance < (_dmgDistance * 2))) then {