Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enemy near changes #2381

Merged
5 changes: 2 additions & 3 deletions A3A/addons/Garage/Public/fn_addVehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ private _inArea = _friendlyMarkers findIf { count ([_player, _vehicle] inAreaArr
if !(_inArea > -1) exitWith {["STR_HR_GRG_Feedback_addVehicle_badLocation",[FactionGet(reb,"name")]] remoteExec ["HR_GRG_fnc_Hint", _client]; false };

//No hostiles near
private _units = (_player nearEntities ["Man",300]) select {([_x] call A3A_fnc_CanFight) && (side _x isEqualTo Occupants || side _x isEqualTo Invaders)};
if (_units findIf {_unit = _x; _players = allPlayers select {(side _x isEqualTo teamPlayer) && (_player distance _x < 300)}; _players findIf {_x in (_unit targets [true, 300])} != -1} != -1) exitWith {

if ([getPosATL _player] call A3A_fnc_enemyNearCheck) exitWith {
["STR_HR_GRG_Feedback_addVehicle_enemiesEngaging"] remoteExec ["HR_GRG_fnc_Hint", _client];
false;
};
if (_units findIf{_player distance _x < 100} != -1) exitWith {["STR_HR_GRG_Feedback_addVehicle_enemiesNear"] remoteExec ["HR_GRG_fnc_Hint", _client]; false };

//LTC refund
if (_class in [FactionGet(occ,"surrenderCrate"), FactionGet(inv,"surrenderCrate")]) exitWith {
Expand Down
8 changes: 4 additions & 4 deletions A3A/addons/core/functions/Base/fn_flagaction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ switch _typeX do
};
case "unit":
{
_flag addAction ["Unit Recruitment", {if ([player,300] call A3A_fnc_enemyNearCheck) then {["Unit Recruitment", "You cannot recruit units while there are enemies near you."] call A3A_fnc_customHint;} else { [] spawn A3A_fnc_unit_recruit; };},nil,0,false,true,"","(isPlayer _this) and (_this == _this getVariable ['owner',objNull])",4]
_flag addAction ["Unit Recruitment", {if ([getPosATL player] call A3A_fnc_enemyNearCheck) then {["Unit Recruitment", "You cannot recruit units while there are enemies near you."] call A3A_fnc_customHint;} else { [] spawn A3A_fnc_unit_recruit; };},nil,0,false,true,"","(isPlayer _this) and (_this == _this getVariable ['owner',objNull])",4]
};
case "vehicle":
{
_flag addAction ["Buy Vehicle", {if ([player,300] call A3A_fnc_enemyNearCheck) then {
_flag addAction ["Buy Vehicle", {if ([getPosATL player] call A3A_fnc_enemyNearCheck) then {
["Buy Vehicle", "You cannot buy vehicles while there are enemies near you."] call A3A_fnc_customHint;
} else {
if (A3A_GUIDevPreview) then {
Expand Down Expand Up @@ -147,9 +147,9 @@ switch _typeX do
if (true) exitWith { ERROR("Disabled due to UseDoomGUI Switch.") };
#endif
removeAllActions _flag;
_flag addAction ["Unit Recruitment", {if ([player,300] call A3A_fnc_enemyNearCheck) then {["Unit Recruitment", "You cannot recruit units while there are enemies near you."] call A3A_fnc_customHint;} else { [] spawn A3A_fnc_unit_recruit; };},nil,0,false,true,"","(isPlayer _this) and (_this == _this getVariable ['owner',objNull])",4];
_flag addAction ["Unit Recruitment", {if ([getPosATL player] call A3A_fnc_enemyNearCheck) then {["Unit Recruitment", "You cannot recruit units while there are enemies near you."] call A3A_fnc_customHint;} else { [] spawn A3A_fnc_unit_recruit; };},nil,0,false,true,"","(isPlayer _this) and (_this == _this getVariable ['owner',objNull])",4];
_flag addAction ["Buy loot box for 10€", {player call A3A_fnc_spawnCrate},nil,0,false,true,"","true", 4];
_flag addAction ["Buy Vehicle", {if ([player,300] call A3A_fnc_enemyNearCheck) then {
_flag addAction ["Buy Vehicle", {if ([getPosATL player] call A3A_fnc_enemyNearCheck) then {
["Buy Vehicle", "You cannot buy vehicles while there are enemies near you."] call A3A_fnc_customHint;
} else {
if (A3A_GUIDevPreview) then {
Expand Down
5 changes: 2 additions & 3 deletions A3A/addons/core/functions/Dialogs/fn_fastTravelRadio.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ if (!isNil "A3A_FFPun_Jailed" && {(getPlayerUID player) in A3A_FFPun_Jailed}) ex

_checkX = false;
//_distanceX = 500 - (([_boss,false] call A3A_fnc_fogCheck) * 450);
_distanceX = 500;

{if ([_x,_distanceX] call A3A_fnc_enemyNearCheck) exitWith {_checkX = true}} forEach units _groupX;
{if ([getPosATL _x] call A3A_fnc_enemyNearCheck) exitWith {_checkX = true}} forEach units _groupX;

if (_checkX) exitWith {["Fast Travel", "You cannot Fast Travel with enemies near the group."] call A3A_fnc_customHint;};

Expand Down Expand Up @@ -54,7 +53,7 @@ if (count _positionTel > 0) then

//if (_base in outpostsFIA) exitWith {hint "You cannot Fast Travel to roadblocks and watchposts"; openMap [false,false]};

if ([getMarkerPos _base,500] call A3A_fnc_enemyNearCheck) exitWith {["Fast Travel", "You cannot Fast Travel to an area under attack or with enemies in the surrounding."] call A3A_fnc_customHint; openMap [false,false]};
if ([getMarkerPos _base] call A3A_fnc_enemyNearCheck) exitWith {["Fast Travel", "You cannot Fast Travel to an area under attack or with enemies in the surrounding."] call A3A_fnc_customHint; openMap [false,false]};
if (!([player] call A3A_fnc_isMember) && {!([_positionTel] call A3A_fnc_playerLeashCheckPosition)}) exitWith {["Fast Travel", format ["There are no members nearby the target location. You need to be within %1 km of HQ or a member.", ceil (memberDistance/1e3)]] call A3A_fnc_customHint;};

if (_positionTel distance getMarkerPos _base < 50) then
Expand Down
2 changes: 1 addition & 1 deletion A3A/addons/core/functions/REINF/fn_addFIAveh.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
FIX_LINE_NUMBERS()
if (!(isNil "placingVehicle") && {placingVehicle}) exitWith {["Add Vehicle", "Unable to buy vehicle, you are already placing something."] call A3A_fnc_customHint;};
if (player != player getVariable ["owner",player]) exitWith {["Add Vehicle", "You cannot buy vehicles while you are controlling AI."] call A3A_fnc_customHint;};
if ([player,300] call A3A_fnc_enemyNearCheck) exitWith {["Add Vehicle", "You cannot buy vehicles with enemies nearby."] call A3A_fnc_customHint;};
if ([getPosATL player] call A3A_fnc_enemyNearCheck) exitWith {["Add Vehicle", "You cannot buy vehicles with enemies nearby."] call A3A_fnc_customHint;};


private _typeVehX = _this select 0;
Expand Down
36 changes: 30 additions & 6 deletions A3A/addons/core/functions/REINF/fn_enemyNearCheck.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
private ["_unit","_dist","_return"];
_unit = _this select 0;
_dist = _this select 1;
_return = false;
{if (_x distance _unit < _dist) exitWith {_return = true}} forEach (allUnits select {((side group _x == Occupants) or (side group _x == Invaders)) and ([_x] call A3A_fnc_canFight)});
_return
/*
Author: [A3A Team]
Enemy near searches
Arguments:
0.<ANY> location/postion that will be used for the center of search
Return Value:
<BOOL> if enemies are near

Scope: Clients
Environment: Unscheduled
Public: yes
Dependencies:

Example:
[cursorObject] call A3A_fnc_enemyNearCheck;
*/

params ["_unitPos"];



private _nearEnemies = (units Occupants + units Invaders) inAreaArray [_unitPos, enemyNearDistance, enemyNearDistance];
_nearEnemies = _nearEnemies select { behaviour _x == "COMBAT" and _x call A3A_fnc_canFight };


(_nearEnemies isNotEqualTo [])




2 changes: 1 addition & 1 deletion A3A/addons/core/functions/REINF/fn_garrisonAdd.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ _positionX = getMarkerPos _markerX;

if (surfaceIsWater _positionX) exitWith {["Garrisons", "This Garrison is still updating, please try again in a few seconds."] call A3A_fnc_customHint;};

if ([_positionX,500] call A3A_fnc_enemyNearCheck) exitWith {["Garrisons", "You cannot Recruit Garrison Units with enemies near the zone."] call A3A_fnc_customHint;};
if ([_positionX] call A3A_fnc_enemyNearCheck) exitWith {["Garrisons", "You cannot Recruit Garrison Units with enemies near the zone."] call A3A_fnc_customHint;};
_nul = [-1,-_costs] remoteExec ["A3A_fnc_resourcesFIA",2];
/*
_garrison = [];
Expand Down
2 changes: 1 addition & 1 deletion A3A/addons/core/functions/REINF/fn_garrisonDialog.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (not(sidesX getVariable [_nearX,sideUnknown] == teamPlayer)) exitWith {
_nul=CreateDialog "build_menu";
#endif
};
if ([_positionX,500] call A3A_fnc_enemyNearCheck) exitWith {
if ([_positionX] call A3A_fnc_enemyNearCheck) exitWith {
["Garrison", "You cannot manage this garrison while there are enemies nearby."] call A3A_fnc_customHint;
#ifdef UseDoomGUI
ERROR("Disabled due to UseDoomGUI Switch.")
Expand Down
2 changes: 1 addition & 1 deletion A3A/addons/core/functions/REINF/fn_reinfPlayer.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if (recruitCooldown > time) exitWith {["AI Recruitment", format ["You need to wa

if (player != player getVariable ["owner",player]) exitWith {["AI Recruitment", "You cannot buy units while you are controlling AI."] call A3A_fnc_customHint;};

if ([player,300] call A3A_fnc_enemyNearCheck) exitWith {["AI Recruitment", "You cannot Recruit Units with enemies nearby."] call A3A_fnc_customHint;};
if ([getPosATL player] call A3A_fnc_enemyNearCheck) exitWith {["AI Recruitment", "You cannot Recruit Units with enemies nearby."] call A3A_fnc_customHint;};

if (player != leader group player) exitWith {["AI Recruitment", "You cannot recruit units as you are not your group leader."] call A3A_fnc_customHint;};

Expand Down
4 changes: 2 additions & 2 deletions A3A/addons/core/functions/init/fn_initClient.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ boxX addAction ["Transfer Vehicle cargo to Ammobox", {[] spawn A3A_fnc_empty;},
boxX addAction ["Move this asset", A3A_fnc_moveHQObject,nil,0,false,true,"","(_this == theBoss)", 4];
if (A3A_hasACE) then { [boxX, boxX] call ace_common_fnc_claim;}; //Disables ALL Ace Interactions
flagX allowDamage false;
flagX addAction ["Unit Recruitment", {if ([player,300] call A3A_fnc_enemyNearCheck) then {["Recruit Unit", "You cannot recruit units while there are enemies near you."] call A3A_fnc_customHint;} else { [] spawn A3A_fnc_unit_recruit; }},nil,0,false,true,"","(isPlayer _this) and (_this == _this getVariable ['owner',objNull]) and (side (group _this) == teamPlayer)"];
flagX addAction ["Unit Recruitment", {if ([getPosATL player] call A3A_fnc_enemyNearCheck) then {["Recruit Unit", "You cannot recruit units while there are enemies near you."] call A3A_fnc_customHint;} else { [] spawn A3A_fnc_unit_recruit; }},nil,0,false,true,"","(isPlayer _this) and (_this == _this getVariable ['owner',objNull]) and (side (group _this) == teamPlayer)"];
flagX addAction ["Move this asset", A3A_fnc_moveHQObject,nil,0,false,true,"","(_this == theBoss)", 4];

//Adds a light to the flag
Expand All @@ -377,7 +377,7 @@ vehicleBox addAction ["Vehicle Arsenal", JN_fnc_arsenal_handleAction, [], 0, tru
if (A3A_hasACE) then { [vehicleBox, VehicleBox] call ace_common_fnc_claim;}; //Disables ALL Ace Interactions

vehicleBox addAction ["Buy Vehicle", {
if ([player,300] call A3A_fnc_enemyNearCheck) then {
if ([getPosATL player] call A3A_fnc_enemyNearCheck) then {
["Purchase Vehicle", "You cannot buy vehicles while there are enemies near you."] call A3A_fnc_customHint;
} else {
if (A3A_GUIDevPreview) then {
Expand Down
1 change: 1 addition & 0 deletions A3A/addons/core/functions/init/fn_initParams.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ A3A_paramTable = [
["autoSave", "autoSave", [], true],
["autoSaveInterval", "autoSaveInterval", [], 3600],
["distanceMission", "mRadius", [], 4000],
["enemyNearDistance", "enemyNearDistanceLimit", [], 300],
["skillMult", "AISkill", [], 2],
["civTraffic", "civTraffic", [], 2],
["limitedFT", "allowFT", [], true], // backwards naming...
Expand Down
7 changes: 7 additions & 0 deletions A3A/addons/maps/MissionDescription/params.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ class Params
texts[] = {"Load from save (Default: Yes)","Yes","No"};
default = 9999;
};
class enemyNearDistanceLimit
{
title = "Distance used to check for enemies near";
values[] = {9999,100,200,300,400,500};
texts[] = {"Load from save (Default: 300)", "100", "200", "300", "400", "500"};
default = 9999;
};
class AISkill
{
title = "Mission Difficulty";
Expand Down