-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathfn_SniperEngage.sqf
More file actions
103 lines (85 loc) · 2.82 KB
/
Copy pathfn_SniperEngage.sqf
File metadata and controls
103 lines (85 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
Author: Genesis
Description:
This function handles the snipers actively engaging enemies from a large distance
Parameter(s):
0: ARRAY - List of all "range capable" units within a group
Returns:
nil
*/
params ["_Snipers","_Group"];
private _NearestEnemys = (leader _Group) call VCM_fnc_ClstKnwnEnmy;
if (count _NearestEnemys > 0) then
{
private _ShootArray = [];
{
if (_Group knowsAbout _x >= 1.5) then
{
_ShootArray pushback (_x # 1);
};
} foreach _NearestEnemys;
if (count _ShootArray > 0) then
{
{
private _Unit = _x;
private _NearestEnemy = [_ShootArray,_Unit,true,""] call VCM_fnc_ClstObj;
_x lookat (getposATL _NearestEnemy);
_x doTarget _NearestEnemy;
//Based off distance - change skill
private _Dist = _x distance2D _NearestEnemy;
if (_Dist > 50) then
{
private _SkillSet = linearConversion[300, 1200,_Dist,1, 0.5, true];
_x setSkill ["aimingShake",_SkillSet];
_x setSkill ["aimingSpeed",_SkillSet];
_x setSkill ["aimingAccuracy",_SkillSet];
}
else
{
_x setSkill 0.9;
_x allowFleeing 0;
{
_x setSkill _x;
} forEach VCM_AIDIFA;
if (VCM_CLASSNAMESPECIFIC && {count VCM_SKILL_CLASSNAMES > 0}) then
{
{
if (typeOf _x isEqualTo (_x select 0)) exitWith
{
_ClassnameSet = true;
_x setSkill ["aimingAccuracy",((_x select 1) select 0)];_x setSkill ["aimingShake",((_x select 1) select 1)];_x setSkill ["spotDistance",((_x select 1) select 2)];_x setSkill ["spotTime",((_x select 1) select 3)];_x setSkill ["courage",((_x select 1) select 4)];_x setSkill ["commanding",((_x select 1) select 5)]; _x setSkill ["aimingSpeed",((_x select 1) select 6)];_x setSkill ["general",((_x select 1) select 7)];_x setSkill ["endurance",((_x select 1) select 8)];_x setSkill ["reloadSpeed",((_x select 1) select 9)];
};
} foreach VCM_SKILL_CLASSNAMES;
};
if (VCM_SIDESPECIFICSKILL) then
{
_x call VCM_AISIDESPEC;
};
};
sleep (2 + RANDOM 4);
private _LOS = lineIntersectsSurfaces [eyePos _x, eyePos _NearestEnemy, (vehicle _NearestEnemy), _x, true, 1,"VIEW","GEOM"];
if ((count _LOS) < 1) then
{
private _FireModes = (getArray (configFile >> "CfgWeapons" >> currentWeapon _x >> "modes"));
_x forceWeaponFire [ primaryWeapon _x,(selectrandom _FireModes)];
_x spawn {sleep 2;if !(unitPos _this isEqualTo "Auto") then {_this setUnitPos "Auto"};};
_x reveal [_NearestEnemy,4];
}
else
{
private _IntersectPos = ((_LOS # 0) # 0);
if (_IntersectPos distance2D _NearestEnemy < 20) then
{
_x setUnitPos "UP";
};
private _SA = [];
{
if (_x distance2D _NearestEnemy < 20) then
{
_Unit reveal [_x,4];
};
} foreach (_NearestEnemy call VCM_fnc_FriendlyArray);
};
} foreach _Snipers;
};
};