Skip to content

Commit

Permalink
asr ai 0.9.28
Browse files Browse the repository at this point in the history
  • Loading branch information
robalo committed Mar 2, 2016
1 parent d42753f commit 3b2637d
Show file tree
Hide file tree
Showing 39 changed files with 226 additions and 186 deletions.
3 changes: 1 addition & 2 deletions asr_ai3/addons/greenrico/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ PRELOAD_ADDONS;
class Extended_InitPost_EventHandlers {
class asdg_I_Soldier_recon_base {
class ADDON {
serverInit = "(_this select 0) execVM ""\A3\Characters_F_Bootcamp\Data\Scripts\randomize_gue1.sqf""";
init = "if (local (_this select 0)) then {[(_this select 0), [], []] call BIS_fnc_unitHeadgear;};";
};
};
};
Expand Down Expand Up @@ -107,7 +107,6 @@ class CfgVehicles {
textPlural = "$STR_A3_nameSound_veh_infantry_SF_p";
nameSound = "veh_infantry_SF_s";
vehicleClass = "MenRecon";
sensitivity = 3.5;
detectSkill = 30;
ASR_AI_SKILL_SOF2;
ASR_AI_COST_SPECIAL;
Expand Down
9 changes: 4 additions & 5 deletions asr_ai3/addons/main/CfgAmmo.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#define __AUDIBLE0 1
#define __AUDIBLE1 12
#define __AUDIBLE2 16
#define __RANGE_HIT_FAR 1000
#define __RANGE_HIT_SMALL 5
#define __RANGE_CRACKS 100
Expand Down Expand Up @@ -144,22 +143,22 @@ class CfgAmmo {
};

class B_127x33_Ball : BulletBase {
audibleFire = __AUDIBLE2; //12;
audibleFire = __AUDIBLE1; //12;
};

class B_127x99_Ball : BulletBase {
audibleFire = __AUDIBLE2; //15;
audibleFire = __AUDIBLE1; //15;
dangerRadiusBulletClose = __RANGE_CRACKS;
dangerRadiusHit = __RANGE_HIT_SMALL;
};

class B_127x108_Ball : BulletBase {
audibleFire = __AUDIBLE2; //48;
audibleFire = __AUDIBLE1; //15;
dangerRadiusBulletClose = __RANGE_CRACKS;
dangerRadiusHit = __RANGE_HIT_SMALL;
};
class B_127x108_APDS : B_127x108_Ball {
audibleFire = __AUDIBLE2; //15;
audibleFire = __AUDIBLE1; //15;
};

class B_19mm_HE : BulletBase {
Expand Down
26 changes: 0 additions & 26 deletions asr_ai3/addons/main/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
class CfgVehicles {

class AllVehicles;
class Air : AllVehicles {
sensitivity = 6;
};
class Helicopter_Base_H;
class Heli_Light_01_base_F : Helicopter_Base_H {
sensitivity = 6;
};
class Heli_Light_02_base_F : Helicopter_Base_H {
sensitivity = 6;
};

class Man;
class CAManBase: Man {
ASR_AI_SKILL_INS2; // default insurgent
//sensitivity = 3.0;
//sensitivityEar = 0.5;
audible = 0.01; //0.05
//lyingLimitSpeedHiding = 0.8;
Expand All @@ -32,7 +19,6 @@ class CfgVehicles {
class Civilian: CAManBase {
ASR_AI_SKILL_CIV1; // default civilian
ASR_AI_COST_LESS;
sensitivity = 2;
minFireTime = 10;
ASR_AI_CAMO_NONE;
accuracy = 0.2;
Expand Down Expand Up @@ -241,24 +227,20 @@ class CfgVehicles {
class B_Soldier_sniper_base_F: B_Soldier_base_F {
ASR_AI_SKILL_SNP1;
ASR_AI_COST_SPECIAL;
sensitivity = 4;
minFireTime = 5;
ASR_AI_CAMO_GHIL;
};
class B_spotter_F: B_Soldier_sniper_base_F {
ASR_AI_SKILL_SOF2;
ASR_AI_COST_SPECIAL;
sensitivity = 4;
ASR_AI_CAMO_GHIL;
};
class B_sniper_F: B_Soldier_sniper_base_F {
ASR_AI_COST_SPECIAL;
sensitivity = 4;
ASR_AI_CAMO_GHIL;
};
class B_ghillie_base_F : B_Soldier_sniper_base_F {
ASR_AI_COST_SPECIAL;
sensitivity = 4;
};

// officer
Expand Down Expand Up @@ -559,24 +541,20 @@ class CfgVehicles {
class O_Soldier_sniper_base_F: O_Soldier_base_F {
ASR_AI_SKILL_SNP1;
ASR_AI_COST_SPECIAL;
sensitivity = 4;
minFireTime = 5;
ASR_AI_CAMO_GHIL;
};
class O_spotter_F: O_Soldier_sniper_base_F {
ASR_AI_SKILL_SOF2;
ASR_AI_COST_SPECIAL;
sensitivity = 4;
ASR_AI_CAMO_GHIL;
};
class O_sniper_F: O_Soldier_sniper_base_F {
ASR_AI_COST_SPECIAL;
sensitivity = 4;
ASR_AI_CAMO_GHIL;
};
class O_ghillie_base_F : O_Soldier_sniper_base_F {
ASR_AI_COST_SPECIAL;
sensitivity = 4;
};

// officer
Expand Down Expand Up @@ -760,23 +738,19 @@ class CfgVehicles {
class I_Soldier_sniper_base_F: I_Soldier_base_F {
ASR_AI_SKILL_SNP1;
ASR_AI_COST_SPECIAL;
sensitivity = 4;
minFireTime = 5;
ASR_AI_CAMO_GHIL;
};
class I_Spotter_F: I_Soldier_sniper_base_F {
ASR_AI_COST_SPECIAL;
sensitivity = 4;
ASR_AI_CAMO_GHIL;
};
class I_Sniper_F: I_Soldier_sniper_base_F {
ASR_AI_COST_SPECIAL;
sensitivity = 4;
ASR_AI_CAMO_GHIL;
};
class I_ghillie_base_F : I_Soldier_sniper_base_F {
ASR_AI_COST_SPECIAL;
sensitivity = 4;
};

// diver
Expand Down
8 changes: 7 additions & 1 deletion asr_ai3/addons/main/CfgWeapons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,13 @@ class CfgWeapons {
ASR_AI_DISP_SNIPER;
};
};
class cannon_105mm: cannon_120mm {
class cannon_125mm : CannonCore {
class player;
class close: player {
ASR_AI_DISP_SNIPER;
};
};
class cannon_105mm: CannonCore {
class player;
class close: player {
ASR_AI_DISP_SNIPER;
Expand Down
4 changes: 1 addition & 3 deletions asr_ai3/addons/main/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if (isServer) then {
// Server, propagate settings and required functions to clients
publicVariable "ASR_AI3_SETTINGS";
if (GVAR(enabled) == 1) then {
["itemAdd", [QGVAR(cfgLoop), {while {count GVAR(configQueue) > 0} do {(GVAR(configQueue) deleteAt 0) call FUNC(configureUnit)}}, 20]] call BIS_fnc_loop;
["itemAdd", [QGVAR(cfgLoop), {call FUNC(configLoop);}, 10]] call BIS_fnc_loop;

if (GVAR(rearm) > 0) then {
[] spawn {
Expand Down Expand Up @@ -63,7 +63,5 @@ if (hasInterface) then {
waitUntil {time > 5 && player == player};
//make player leader on teamswitch; prevents AI left in place from sending stupid orders
if (GVAR(onteamswitch) > 0) then {onTeamSwitch {[_from,_to] call FUNC(onTeamSwitch)}};
//Disables fatigue for AI units in player's group so they are able to keep up
if (GVAR(disableAIPGfatigue) > 0) then {{_x enableFatigue (isPlayer _x)} forEach (units group player)};
}
};
47 changes: 35 additions & 12 deletions asr_ai3/addons/main/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -1,38 +1,56 @@
//#define DEBUG_MODE_FULL
#include "\a3\editor_f\Data\Scripts\dikCodes.h"
#include "script_component.hpp"
LOG(MSG_INIT);

if (isServer) then {
ASR_AI3_SETTINGS = compile preprocessFileLineNumbers "\userconfig\asr_ai3\asr_ai3_settings.sqf";
if (!isNil "ASR_AI3_SETTINGS") then {
[] call ASR_AI3_SETTINGS; // Load the global defaults
};
ASR_AI3_SETTINGS_SS = compile preprocessFileLineNumbers "\userconfig\asr_ai3\asr_ai3_settings_ss.sqf";
if (!isNil "ASR_AI3_SETTINGS_SS") then {
[] call ASR_AI3_SETTINGS_SS; // Load the server-side defaults
};
if (isFilePatchingEnabled) then {
ASR_AI3_SETTINGS = compile preprocessFileLineNumbers "\userconfig\asr_ai3\asr_ai3_settings.sqf";
if (!isNil "ASR_AI3_SETTINGS") then {
[] call ASR_AI3_SETTINGS; // Load the global defaults
};
ASR_AI3_SETTINGS_SS = compile preprocessFileLineNumbers "\userconfig\asr_ai3\asr_ai3_settings_ss.sqf";
if (!isNil "ASR_AI3_SETTINGS_SS") then {
[] call ASR_AI3_SETTINGS_SS; // Load the server-side defaults
};
} else {
diag_log "ASR AI3: Loading default settings, launch the game with -filePatching to enable userconfig";
};
};

ASR_AI_SETDEFAULT(enabled,1);
ASR_AI_SETDEFAULT(radiorange,500);
ASR_AI_SETDEFAULT(radiorange,600);
ASR_AI_SETDEFAULT(seekcover,1);
ASR_AI_SETDEFAULT(usebuildings,0.8);
ASR_AI_SETDEFAULT(getinweapons,0.5);
ASR_AI_SETDEFAULT(packNVG,1);
ASR_AI_SETDEFAULT(disableAIPGfatigue,1);
ASR_AI_SETDEFAULT(onteamswitch,1);
ASR_AI_SETDEFAULT(copymystance,1);
ASR_AI_SETDEFAULT(debug,0);

ASR_AI_SETDEFAULT(setskills,1);
ASR_AI_SETDEFAULT(rearm,40);
ASR_AI_SETDEFAULT(joinlast,2);
ASR_AI_SETDEFAULT(removegimps,300);
ASR_AI_SETDEFAULT(rearm,40);
ASR_AI_SETDEFAULT(sets,[]);
ASR_AI_SETDEFAULT(levels_units,[]);
ASR_AI_SETDEFAULT(factions,[]);

if (count GVAR(sets) < 10) then {GVAR(sets) = [["aiming",[1,0],"spotting",[1,0],"general",[1,0]],["aiming",[0.4,0.1],"spotting",[0.4,0.2],"general",[0.8,0.2]],["aiming",[0.35,0.1],"spotting",[0.35,0.2],"general",[0.75,0.2]],["aiming",[0.3,0.1],"spotting",[0.3,0.2],"general",[0.7,0.2]],["aiming",[0.25,0.1],"spotting",[0.25,0.2],"general",[0.65,0.2]],["aiming",[0.2,0.1],"spotting",[0.2,0.2],"general",[0.6,0.2]],["aiming",[0.15,0.1],"spotting",[0.15,0.2],"general",[0.55,0.2]],["aiming",[0.1,0.1],"spotting",[0.1,0.2],"general",[0.5,0.2]],["aiming",[0.25,0.1],"spotting",[0.5,0.2],"general",[0.7,0.2]],["aiming",[0.2,0.1],"spotting",[0.4,0.2],"general",[0.6,0.2]],["aiming",[0.6,0.4],"spotting",[0.8,0.2],"general",[0.8,0.2]]]};
if (count GVAR(sets) < 10) then {
GVAR(sets) = [
[ "general",[1.00,0.0], "aiming",[1.00,0.0], "spotting",[1.00,0.0] ],
[ "general",[0.90,0.1], "aiming",[0.40,0.2], "spotting",[0.40,0.1] ],
[ "general",[0.85,0.1], "aiming",[0.35,0.2], "spotting",[0.35,0.1] ],
[ "general",[0.80,0.1], "aiming",[0.30,0.1], "spotting",[0.30,0.1] ],
[ "general",[0.75,0.1], "aiming",[0.25,0.1], "spotting",[0.25,0.1] ],
[ "general",[0.70,0.1], "aiming",[0.20,0.1], "spotting",[0.20,0.1] ],
[ "general",[0.65,0.1], "aiming",[0.15,0.1], "spotting",[0.15,0.1] ],
[ "general",[0.60,0.1], "aiming",[0.10,0.1], "spotting",[0.10,0.1] ],
[ "general",[0.80,0.1], "aiming",[0.25,0.1], "spotting",[0.35,0.1] ],
[ "general",[0.70,0.1], "aiming",[0.20,0.1], "spotting",[0.30,0.1] ],
[ "general",[0.90,0.1], "aiming",[0.70,0.3], "spotting",[0.90,0.1] ]
]
};
if (count GVAR(levels_units) < 10) then {GVAR(levels_units) = [[],[],[],[],[],[],[],[],[],[],[]]};

ASR_AI_SETDEFAULT(gunshothearing,1.1);
Expand All @@ -44,6 +62,7 @@ GVAR(needmax) = [ // The level of supplies the unit will try to maintain
];

GVAR(configQueue) = [];
GVAR(copymystance) = 0;

FUNC(isValidUnit) = {!(isNull _this) && {alive _this} && {!(_this isKindOf "Civilian")} && {!(_this getVariable ["asr_ai_exclude", false])}};
FUNC(isValidUnitC) = {_this call FUNC(isValidUnit) && {!(_this call FUNC(isUnc))}};
Expand Down Expand Up @@ -85,3 +104,7 @@ PREP(getCompatMags);
PREP(countItems);
PREP(inventoryCheck);
PREP(rearm);
PREP(copyMyStance);
PREP(configLoop);

["ASR AI3", "ASR AI3", ["Toggle Copy My Stance", "asr_ai3_copymystance"], {player call FUNC(copyMyStance)}, {}, [DIK_BACKSLASH, [true, true, false]]] call cba_fnc_addKeybind;
6 changes: 2 additions & 4 deletions asr_ai3/addons/main/fnc_addUnitToQueue.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_1(_unit);
params ["_unit"];

if (GVAR(enabled) == 1) then {
GVAR(configQueue) pushBack _unit;
};
if (GVAR(enabled) == 1) then {GVAR(configQueue) pushBack _unit};
2 changes: 1 addition & 1 deletion asr_ai3/addons/main/fnc_broadcastInfo.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_2(_grp,_info);
params ["_grp", "_info"];
private ["_leader","_recgroups"];
_leader = leader _grp;
// if leader valid and not already sending and has radio
Expand Down
10 changes: 10 additions & 0 deletions asr_ai3/addons/main/fnc_configLoop.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//#define DEBUG_MODE_FULL
#include "script_component.hpp"

while {count GVAR(configQueue) > 0} do {
(GVAR(configQueue) deleteAt 0) call FUNC(configureUnit);
};

if (GVAR(packNVG) == 1) then {
{_x call FUNC(setupGear)} forEach allUnits;
};
20 changes: 3 additions & 17 deletions asr_ai3/addons/main/fnc_configureUnit.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_1(_unit);
params ["_unit"];

if (!isNull _unit && {alive _unit} && {!(_unit getVariable ["asr_ai_exclude", false])}) then {

Expand All @@ -11,23 +11,9 @@ if (!isNull _unit && {alive _unit} && {!(_unit getVariable ["asr_ai_exclude", fa
};

if (GVAR(setskills) > 0) then {_unit call FUNC(setUnitSkill)};
if (GVAR(packNVG) == 1) then {_unit call FUNC(setupGear)};

if (GVAR(copymystance) == 1 && {isPlayer leader _unit}) then {
_unit spawn {
private ["_lead"];
while {alive _this} do {
_lead = leader _this;
if (isPlayer _lead && !isPlayer _this) then {
switch (stance _lead) do {
case "CROUCH": {_this setUnitPosWeak "MIDDLE"};
case "PRONE": {_this setUnitPosWeak "DOWN"};
default {_this setUnitPosWeak "AUTO"};
};
};
sleep 2;
};
};
if (isPlayer leader _unit) then {
if (GVAR(disableAIPGfatigue) > 0) then {_unit enableFatigue (isPlayer _unit)};
};

_unit setVariable [QGVAR(configured),true];
Expand Down
31 changes: 31 additions & 0 deletions asr_ai3/addons/main/fnc_copyMyStance.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
params ["_caller"];
if (leader _caller != _caller) exitWith {hint "ASR-AI3 :: Copy My Stance : You are not the leader of the group !"; false};

if (GVAR(copymystance) == 0) then {
GVAR(copymystance) = 1;
{
_x spawn {
private "_leader";
while {alive _this && GVAR(copymystance) == 1} do {
_leader = leader _this;
if (isPlayer _leader && !isPlayer _this) then {
switch (stance _leader) do {
case "CROUCH": {_this setUnitPos "MIDDLE"};
case "PRONE": {_this setUnitPos "DOWN"};
default {_this setUnitPos "AUTO"};
};
};
sleep 2;
};
};
} forEach units group _caller;
hintSilent "ASR-AI3 :: Copy My Stance : Enabled";
} else {
GVAR(copymystance) = 0;
{ if (!isPlayer _x) then {_x setUnitPos "AUTO"} } forEach units group _caller;
hintSilent "ASR-AI3 :: Copy My Stance : Disabled";
};

true
2 changes: 1 addition & 1 deletion asr_ai3/addons/main/fnc_countItems.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// return number of items that list (param 1) has from a list (param 2)
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_2(_magpool,_check);
params ["_magpool", "_check"];

private["_m","_c"];
_c = 0;
Expand Down
3 changes: 1 addition & 2 deletions asr_ai3/addons/main/fnc_findCover.sqf
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// returns array with 1 cover position near unit
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_2(_unit,_dangerobj);
DEFAULT_PARAM(2,_maxdisttocover,100);
params ["_unit", "_dangerobj", ["_maxdisttocover", 100]];

scopeName "main";
private ["_cover","_enemydist","_dangerpos","_coverpos","_debug","_fnc_debug","_bposa","_bbdim","_maxWidth","_maxLength","_maxHeight","_min","_max","_objpos","_nBuilding","_isHouse"];
Expand Down
2 changes: 1 addition & 1 deletion asr_ai3/addons/main/fnc_firedEH.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// help the AI hear weapons fired
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
params ["_shooter", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile"];
#define _MAXREVEAL_ 1.7

//limit
Expand Down
Loading

0 comments on commit 3b2637d

Please sign in to comment.