Skip to content

Commit

Permalink
Merge pull request #13 from SilenceIsFatto/release-candidate
Browse files Browse the repository at this point in the history
Add more logging, update firedNear, RPG reveal
  • Loading branch information
SilenceIsFatto authored Oct 10, 2024
2 parents 96e1d7f + c2c008e commit b3de615
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 47 deletions.
1 change: 1 addition & 0 deletions hatg/addons/functions/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class CfgFunctions
{
file = QPATHTOFOLDER(functions\conditions);
class canStayHidden {};
class getDetectionDistance {};
class getNearbyUnits {};
class isFoggy {};
class isInBuilding {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ if (_allowedShotsRange isEqualTo -1) then {

[format["Has Ghillie? %1, Has Suppressor? %2, Is Night? %3, Allowed Shots: %4, Current Shots: %5", _hasGhillie, _hasSuppressor, _isNight, _allowedShotsRange, _unitShots], 4, _fnc_scriptName] call HATG_fnc_log;

if (currentWeapon _unit isEqualTo secondaryWeapon _unit) exitWith {false}; // if _unit is not using a launcher
if (_allowedShots isEqualTo -1 || {hatg_setting_simple}) exitWith {true};
if (_unitShots < _allowedShotsRange) exitWith {true};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
Author:
Silence
Description:
Checks all the different factors in detection distance, returns the result
Params:
_unit <OBJECT>
_stance <STRING>
Dependencies:
global variables:
> hatg_setting_distance_close <INT>
> hatg_setting_distance_close_multiplier <INT>
Usage:
[player, "PRONE"] call HATG_fnc_getDetectionDistance;
Return:
_distanceClose <FLOAT>
*/

params ["_unit", ["_stance", "PRONE"]];

private _distanceClose = hatg_setting_distance_close;
private _distanceCloseMultiplier = hatg_setting_distance_close_multiplier;

// Can't think of a better way to do these if statements, there will be a more efficient way. Brain doesn't brain rn
if (hatg_setting_simple) then {
_distanceClose = 10;
_distanceCloseMultiplier = 2;
};

if (_stance == "CROUCH") then {
_distanceClose = _distanceClose * _distanceCloseMultiplier;
};

if (_stance == "STAND") then {
_distanceClose = _distanceClose * (_distanceCloseMultiplier * 2);
};

// Can't exactly merge these into 1 statement since the effects are meant to stack
if (call HATG_fnc_isNight) then {
_distanceClose = _distanceClose / 2;
};

if (call HATG_fnc_isRaining) then {
_distanceClose = _distanceClose / 2;
};

if (call HATG_fnc_isFoggy) then {
_distanceClose = _distanceClose / 2;
};

if ([_unit] call HATG_fnc_isInBuilding) then {
_distanceClose = _distanceClose / 2;
};

if ([_unit] call HATG_fnc_hasGhillie) then { // ghillie should ideally have no benefit if standing
_distanceClose = _distanceClose / 2;
};

_distanceClose = _distanceClose max 5;

_distanceClose;
48 changes: 5 additions & 43 deletions hatg/addons/functions/functions/conditions/fn_getNearbyUnits.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
Silence
Description:
Checks if an enemy unit is near _unit, reduces distance dynamically based on multiple factors
Checks if an enemy unit is near _unit
Params:
_unit <OBJECT>
_stance <STRING>
Dependencies:
global variables:
> hatg_setting_distance_close <INT>
> hatg_setting_distance_close_multiplier <INT>
N/A
Usage:
[player] call HATG_fnc_getNearbyUnits;
Expand All @@ -23,53 +21,17 @@

params ["_unit", ["_stance", "PRONE"]];

private _distanceClose = hatg_setting_distance_close;
private _distanceCloseMultiplier = hatg_setting_distance_close_multiplier;
private _distanceClose = [_unit, _stance] call HATG_fnc_getDetectionDistance;

// Can't think of a better way to do these if statements, there will be a more efficient way. Brain doesn't brain rn
if (hatg_setting_simple) then {
_distanceClose = 10;
_distanceCloseMultiplier = 2;
};

if (_stance == "CROUCH") then {
_distanceClose = _distanceClose * _distanceCloseMultiplier;
};

if (_stance == "STAND") then {
_distanceClose = _distanceClose * (_distanceCloseMultiplier * 2);
};

// Can't exactly merge these into 1 statement since the effects are meant to stack
if (call HATG_fnc_isNight) then {
_distanceClose = _distanceClose / 2;
};

if (call HATG_fnc_isRaining) then {
_distanceClose = _distanceClose / 2;
};

if (call HATG_fnc_isFoggy) then {
_distanceClose = _distanceClose / 2;
};

if ([_unit] call HATG_fnc_isInBuilding) then {
_distanceClose = _distanceClose / 2;
};

if ([_unit] call HATG_fnc_hasGhillie) then { // ghillie should ideally have no benefit if standing
_distanceClose = _distanceClose / 2;
};

_distanceClose = _distanceClose max 5;
[format["Detection Distance: %1", _distanceClose], 3, _fnc_scriptName] call HATG_fnc_log;

private _nearbyUnit = _unit findNearestEnemy _unit;

if (isNil "_nearbyUnit" || {_nearbyUnit isEqualTo ObjNull}) exitWith {false};
if (_nearbyUnit distance2D _unit >= _distanceClose) exitWith {false};
if (_nearbyUnit getVariable ["ACE_isUnconscious", false] isEqualTo true) exitWith {false};

[format["Detection Distance: %1, Close Unit? %2", _distanceClose, _nearbyUnit], 4, _fnc_scriptName] call HATG_fnc_log;
[format["Close Unit? %1", _nearbyUnit], 4, _fnc_scriptName] call HATG_fnc_log;

true;

Expand Down
4 changes: 3 additions & 1 deletion hatg/addons/functions/functions/conditions/fn_isFoggy.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
if (fog >= 0.6) exitWith {true};
if (fog >= 0.3) exitWith {true};

[format["Fog Level: %1", fog], 3, _fnc_scriptName] call HATG_fnc_log;

false;
4 changes: 3 additions & 1 deletion hatg/addons/functions/functions/conditions/fn_isRaining.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
if (rain >= 0.6) exitWith {true};
if (rain >= 0.3) exitWith {true};

[format["Rain Level: %1", rain], 3, _fnc_scriptName] call HATG_fnc_log;

false;
14 changes: 12 additions & 2 deletions hatg/addons/functions/functions/handlers/fn_onFiredNear.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,20 @@ params ["_unit", "_firer"];

[format["%1 was caught in a 'fired' event. %2 was the firer. Checking conditions", name _unit, name _firer], 4, _fnc_scriptName] call HATG_fnc_log;

if (_unit isEqualTo _firer) exitWith {false};

if ((_unit distance _firer) <= hatg_setting_distance_close) exitWith {
[_unit] remoteExecCall ["HATG_fnc_cooldown", 0];
[format["%1 was caught in a 'fired' event. %2 was the firer. Giving them a distance cooldown", name _unit, name _firer], 4, _fnc_scriptName] call HATG_fnc_log;
false;
};

if ((_unit distance _firer) >= hatg_setting_distance_close) exitWith {false};
if (hatg_setting_reveal_nearby isEqualTo false) exitWith {["Failed 'Fired' Setting Check", 4, _fnc_scriptName] call HATG_fnc_log; false};
if ([_firer] call HATG_fnc_getMirror isNotEqualTo ObjNull) exitWith {["Failed 'Fired' Mirror Check", 4, _fnc_scriptName] call HATG_fnc_log; false};
if ([_firer, (stance _firer)] call HATG_fnc_canCreateMirror) exitWith {["Failed 'Fired' Can Create Mirror Check", 4, _fnc_scriptName] call HATG_fnc_log; false};

[format["%1 was caught in a 'fired' event. %2 was the firer. Giving them a cooldown.", name _unit, name _firer], 4, _fnc_scriptName] call HATG_fnc_log;
[_unit] remoteExecCall ["HATG_fnc_cooldown", 0]; // Needs to be broadcasted, otherwise remote clients won't recieve the cooldown
[format["%1 was caught in a 'fired' event. %2 was the firer. Giving them a cooldown", name _unit, name _firer], 4, _fnc_scriptName] call HATG_fnc_log;

[_unit] remoteExecCall ["HATG_fnc_cooldown", 0]; // Needs to be broadcasted, otherwise remote clients won't recieve the cooldown
false;

0 comments on commit b3de615

Please sign in to comment.