Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /************************************************************
- RWR and spoofing script: Based on Franze's Su-17/22 RWR script!
- Updated by HCPOOKIE to work with:
- - POOK_EF2000
- - POOK Soviet AF
- - VME_PLA Vehicles
- - Fuller's USAF mod
- - Other mods can employ this script as well.
- Please credit appropriately.
- ///////////////////////////////////
- * This is the POOK_SovAF version!!!
- ///////////////////////////////////
- USAGE:
- - Action-based script to attempt to spoof incoming missiles
- `
- - Relies on two other functions which must be loaded on INIT:
- EF2K_pitchbank = compile preprocessFileLineNumbers "\mod\scripts\fsetpitch.sqf";
- EF2K_getpb = compile preprocessFileLineNumbers "\mod\scripts\frotate.sqf";
- - Checks for certain jammer pods on plane; if none, checks
- if plane is of certain types that contain on-board jamming
- equipment; if neither, revert to default action
- - Reads missile attributes to determine if the following
- POOK_SAM pack values are present, and modify behavior
- accordingly (see POOK_SAM pack documentation for more info):
- - POOK_HOJ
- - POOK_Band
- - POOK_HOP
- - Missiles have chance to burn-through jamming, making results
- semi-random. Pilots should plan to adjust flight to dodge
- missiles, and employ standard countermeasures while jamming.
- - Script also provides RWR notification to pilot and animates
- on-board RWR cockpit indicators if so equipped.
- - Pilot also receives vehicle chat notifications regardless
- if the plane has an animated RWR system.
- ************************************************************/
- private ["_v","_amm","_aTyp","_shooter","_theta","_p","_pMsl","_rng",
- "_ico","_msl","_dev","_VXmis","_VYmis","_HOJ","_HOP","_B",
- "_pbvar","_pitch","_bank","_typ","_ECM","_I","_Ip","_Q","_icT"];
- _v = _this select 0; // incomingMissile EH: unit: Object - Object the event handler is assigned to
- _amm = _this select 1; // incomingMissile EH: ammo: String - Ammo type that was fired on the unit
- _shooter = _this select 2; // incomingMissile EH: whoFired: Object - Object that fired the weapon
- _theta = 0;
- _ECM = false;
- _p = getpos _v;
- _msl = nearestobject [_shooter,_amm]; // EH select 2, EH select 1
- _pMsl = getpos _msl;
- _rng = _pMsl distance _p;
- /*********** RWR alarm sound and master caution lamps *********************************************************/
- _v animate ['missile_launch_ind',0];
- _v animate ['master_caution_ind',0];
- /*********** Check for pod and/or plane class that contains internal jamming systems Pook_SOV_BB**************************/
- _I = [_v] call pook_SOV_FNC_tCheck;
- _Ip = [_v] call pook_SOV_FNC_pCheck;
- // if either checks are TRUE then full ECM can activate
- if ((_I) || (_Ip)) then {
- _ECM = true;
- };
- /*********** Get pook_SAM missile data values if present *****************************************************/
- _aTyp = toUpper (_amm);
- _HOJ = [(configFile >> "cfgAmmo" >> _aTyp),"pook_HOJ",2] call BIS_fnc_returnConfigEntry;
- _B = [(configFile >> "cfgAmmo" >> _aTyp),"pook_Band",2] call BIS_fnc_returnConfigEntry;
- _HOP = [(configFile >> "cfgAmmo" >> _aTyp),"pook_HOP",2] call BIS_fnc_returnConfigEntry;
- /*********** JAMMING OFFSET *******************************
- _dev = Baseline offset value.
- Determines amount of missile deflection during jam loop
- Larger = more deviation
- Also used to calculate missile burn-through rate, as
- a product of "distance * _chance".
- 0.0005 base value for vanilla and undocumented missiles
- **********************************************************/
- switch (_B) do {
- /*
- 0.00035 = extreme wiggle in path
- 0.000275 = median spoofing
- case "C":{_dev = 0.0005;}; // SA2; (also MIM23 search)
- case "J":{_dev = 0.00025;}; // SA19
- case "X":{_dev = 0.000275;}; // typical
- case "G":{_dev = 0.0001;}; // MIM104, SA15
- */
- case "C":{if (_ECM) then {_dev = 0.000325;} else {_dev = 0.0003;};}; // SA2; (also MIM23 search)
- case "J":{if (_ECM) then {_dev = 0.0003125;} else {_dev = 0.000275;};}; // SA8, SA19
- case "X":{if (_ECM) then {_dev = 0.0003;} else {_dev = 0.00025;};}; // typical: SA3,SA10,SA11,SA17,SA20,SA21,SA22,NAS,MIM23
- case "G":{if (_ECM) then {_dev = 0.000125;} else {_dev = 0.0001;};}; // MIM104, SA15
- // following are search radars, and not directly involved in jamming actions
- case "A":{_dev = 0.0001;}; // SA2 search; SA3 search
- case "H":{_dev = 0.0001;}; // SA11/SA17 search
- case "S":{_dev = 0.0001;}; // SA-22 search
- case "E":{_dev = 0.0001;}; // SA-19 search
- case "L":{_dev = 0.0001;}; // SA-21 search
- case "I":{_dev = 0.00001;}; // Infra-red (IR)
- default {_dev = 0.0005;}; // undocumented missiles (vanilla, etc)
- };
- /** animate RWR "TYPE" warning light (Russian type) ************************************************************/
- /**
- if (_shooter isKindOf "Air") then {
- _v setobjecttexture [87,"\fza_su17\su17_rwrlights.paa"];
- };
- if (_shooter isKindOf "Land" and _rng > 20000) then {
- _v setobjecttexture [90,"\fza_su17\su17_rwrlights.paa"];
- };
- if (_shooter isKindOf "Land" and _rng > 10000 and _rng < 20000) then {
- _v setobjecttexture [91,"\fza_su17\su17_rwrlights.paa"];
- };
- if (_shooter isKindOf "Land" and _rng < 10000) then {
- _v setobjecttexture [92,"\fza_su17\su17_rwrlights.paa"];
- };
- **/
- /** animate RWR "TYPE" warning light (NATO type) ***************************************************************/
- _icT = [_aTyp] call pook_SOV_FNC_aTyp;
- //_typ = ([_aTyp] call pook_SOV_FNC_aTyp) select 1;
- _ico = _icT select 0;
- _typ = _icT select 1;
- while {(alive _msl)} do {
- private ["_pP","_pM","_rng","_qd","_reldir","_oc","_ocF","_ocN","_highlow"];
- _pP = getpos _v;
- _pM = getpos _msl;
- _rng = _pM distance _pP;
- };
- private["_highlow","_pP","_pM"];
- /** missile HEIGHT check - is it "high" or "low" ***************************************************************/
- if (_pP select 2 > _pM select 2) then {
- _highlow = "Low";
- } else {
- _highlow = "High";
- };
- /** calculate incoming DIRECTION ***************************************************************/
- _reldir = ((_pM select 0) - (_pP select 0)) atan2 ((_pM select 1) - (_pP select 1));
- if (_reldir < 0) then {
- _reldir = _reldir + 360;
- };
- _Theta = [_reldir,_v] call pook_SOV_FNC_Theta;
- _oc = _Theta select 0;
- _ocF = _Theta select 1;
- _ocN = _Theta select 2;
- _qd = _Theta select 3;
- _v vehiclechat format ["%4 Missile %1 OClock %2 %3 Meters",_oc,_highlow,_rng,_typ];
- /** animate RWR warn flash *************************************************************
- _v setObjectTexture [_qd,"\pook_EF2000\data\cockpit\mfd3_ca.paa"]; // red on
- sleep 0.25;
- _v setObjectTexture [_qd,""]; // red off
- sleep 0.25;
- _v setObjectTexture [_qd,"\pook_EF2000\data\cockpit\mfd3_ca.paa"]; // red on
- sleep 0.25;
- _v setObjectTexture [_qd,""]; // red off
- sleep 0.25;
- _v setObjectTexture [_qd,"\pook_EF2000\data\cockpit\mfd3_ca.paa"]; // red on
- sleep 0.25;
- _v setObjectTexture [_qd,""]; // red off
- **/
- /** RWR incoming ident *************************************************************
- if (_rng > 1500) then {
- if (_rng > 5000) then {
- _v setObjectTexture [_ocF, _ico]; // far
- } else {
- _v setObjectTexture [_ocN, _ico]; // near
- };
- } else {
- _v setObjectTexture [35, _ico]; // close
- };
- **/
- /** "has passed" check - cancel ECM if true ***************************************************************/
- private ["_ps"];
- _ps = _msl distance _v;
- sleep 1;
- if ((_msl distance _v) > _ps) exitWith {};
- /////////////////////////////////////////////////////////////////// begin spoofing section
- _VXmis = vectorup _msl;
- _VYmis = vectordir _msl;
- /*
- // Freq - FUTURE: Set jammer to different modes/Freq
- // If false it halves the amount of deflection. Missile flight model
- // may still allow missile to overcome ECM with this active
- if !(_B == 1) then {
- // _Freq = _v getVariable "ECM_Freq";
- if (_Freq in jammerarray) then {
- _jam = active
- };
- _dev = _dev * 0.0025;
- };
- */
- if (_ECM) then {
- while {(alive _msl) && (alive _v)} do {
- // Distance calculation for spoof percentage increase as distance to target decreases
- // Simulates the "burn-through" capability of missile's on-board radar
- // examples:
- // X-band @ 2000m = 0.75% / 4000m = 1.50%
- // G-band @ 2000m = 1.00% / 4000m = 2.00%
- // C-band @ 2000m = 0.20% / 4000m = 0.40%
- _distance = _v distance _msl; // closing distance in M
- _burnThrough = _dev * _distance;
- // hint format ["Burnthrough: %1, Distance: %2, curvupmis: %3, curvdirmis: %4",_burnThrough,_distance,_VXmis,_VYmis];
- // Frequency Hop check: Increased chance for ECM to fail
- // (by pausing ECM actions) if missile can frequency hop
- // The pause stacks on the HOJ pause, if > 0
- if (_HOP == 1) then {
- sleep (sqrt(floor(random _burnThrough)*0.1)*((sqrt _distance)*0.1));
- };
- if (_distance < 4000) then {
- // Home-On-Jam check: Increased chance for ECM to fail
- // (by adding ECM pauses) if missile can Home-On-Jam
- if (_HOJ == 1) then {
- sleep (floor(random 0.125)+((sqrt _distance)*0.1));
- };
- };
- // FUTURE: Adjust pitch/bank vector amounts based on _burnThrough
- _msl setvectorup _VXmis;
- _msl setvectordir _VYmis;
- _pbvar = _msl call EF2K_RWR_getpb; // frotate.sqf
- _pitch = _pbvar select 0; // PITCH
- _bank = _pbvar select 1; // BANK
- _bank = _bank - _dev;
- _pitch = _pitch - _dev;
- [_msl, _pitch, _bank] call EF2K_RWR_pitchbank; // fsetpitch.sqf
- // find missile vector up and vector dir for next loop
- _VXmis = vectorup _msl;
- _VYmis = vectordir _msl;
- // 0.25 = spoof never successful
- // closer to target, shorter sleep loops (more active scanner)
- // This means more attempts to counter ECM, and the greater
- // the chance for missile to succeed vs. ECM
- sleep _burnThrough;
- };
- } else {
- _v forceWeaponFire ["CMFlareLauncher","Burst"];
- };
- /////////////////////////////////////////////////////////////////// end spoofing section
- /** Reset RWR icons for THIS LOOP ***************************************************************/
- /**
- sleep 1;
- _v setObjectTexture [15,""];
- _v setObjectTexture [16,""];
- _v setObjectTexture [17,""];
- _v setObjectTexture [18,""];
- _v setObjectTexture [19,""];
- _v setObjectTexture [20,""];
- _v setObjectTexture [21,""];
- _v setObjectTexture [22,""];
- _v setObjectTexture [23,""];
- _v setObjectTexture [24,""];
- _v setObjectTexture [25,""];
- _v setObjectTexture [26,""];
- _v setObjectTexture [27,""];
- _v setObjectTexture [28,""];
- _v setObjectTexture [29,""];
- _v setObjectTexture [30,""];
- _v setObjectTexture [31,""];
- _v setObjectTexture [32,""];
- _v setObjectTexture [33,""];
- _v setObjectTexture [34,""];
- _v setObjectTexture [35,""];
- }; // WHILE ALIVE MISSILE LOOP
- **/
- /** CLEAN-UP: RESET COCKPIT WARN LIGHTS and RWR ***************************************************************/
- _v animate ['missile_launch_ind',1];
- _v animate ['master_caution_ind',1];
- /**
- _v setObjectTexture [7,"\pook_EF2000\data\cockpit\mfd2_ca.paa"];
- _v setObjectTexture [8,"\pook_EF2000\data\cockpit\mfd2_ca.paa"];
- _v setObjectTexture [9,"\pook_EF2000\data\cockpit\mfd2_ca.paa"];
- _v setObjectTexture [10,"\pook_EF2000\data\cockpit\mfd2_ca.paa"];
- _v setObjectTexture [11,"\pook_EF2000\data\cockpit\mfd2_ca.paa"];
- _v setObjectTexture [12,"\pook_EF2000\data\cockpit\mfd2_ca.paa"];
- _v setObjectTexture [13,"\pook_EF2000\data\cockpit\mfd2_ca.paa"];
- _v setObjectTexture [14,"\pook_EF2000\data\cockpit\mfd2_ca.paa"];
- _v setObjectTexture [15,""];
- _v setObjectTexture [16,""];
- _v setObjectTexture [17,""];
- _v setObjectTexture [18,""];
- _v setObjectTexture [19,""];
- _v setObjectTexture [20,""];
- _v setObjectTexture [21,""];
- _v setObjectTexture [22,""];
- _v setObjectTexture [23,""];
- _v setObjectTexture [24,""];
- _v setObjectTexture [25,""];
- _v setObjectTexture [26,""];
- _v setObjectTexture [27,""];
- _v setObjectTexture [28,""];
- _v setObjectTexture [29,""];
- _v setObjectTexture [30,""];
- _v setObjectTexture [31,""];
- _v setObjectTexture [32,""];
- _v setObjectTexture [33,""];
- _v setObjectTexture [34,""];
- _v setObjectTexture [35,""];
- **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement