Shashman 0 Posted May 2, 2006 Hi all, I was making a map for my squad's Air Wing last night for training purposes and the idea of simulating an electronic warfare mission popped up. What I would like to know is this : Would it be possible to, through scripting or any other method, stop any/all AA vehicles on a map from engaging a target? I was thinking along the lines of; when the EW platform gets to within a certain distance of an AA vehicle, that vehicle can no longer engage aircraft, and when the EW platform leaves this area, the ability to engage is returned to the AA vehicle. I know that the distance from a set point/unit can be used to trigger an event of some sort through scripting, as I've seen this in other scripts, so either by removing all the AA vehicle's ammo (temporarily) or forbidding it from opening fire when these distance parameters are met, my idea should be feasable? I don't think anything like this has been attempted before so I'm rather excited about it. It would give us OFP pilots a new mission to perform, other than the usual attack/transport ones we are so used to An EW platform is a valuable and vulnerable asset so all sorts of mission possibilities would be opened up Mission candidates include: Simulating the French C-160 GABRIEL system Simulating the US EC-130H Compass Call system Simulating the US F-4G Wild Weasel system Simulating the US EA-6B Prowler system Simulating the Russian Gardeniya family of internally mounted and podded airborne radar/communications-band jammers which can be fitted to most fighter types as well as the Mi-17 (As stated above, MIG-29, SU-27, SU-25, Mi-17...) Simulating the German and Italian Tornado ECR system Simulating the US EA-18G growler system Share this post Link to post Share on other sites
mandoble 1 Posted May 2, 2006 Put the following code in the init field of each enemy AA unit: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> [this, ewunitname, desired range]exec"ewjamming.sqs" <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ;ewjamming.sqs ; _aaunit = _this select 0 _ewunit = _this select 1 _minrange = _this select 2 #checkrange @ (_aaunit distance _ewunit) < _minrange _aaunit setBehaviour "CARELESS" @ (_aaunit distance _ewunit) > _minrange _aaunit setBehaviour "AWARE" goto "checkrange" EDIT: The above script is valid for AI units. If you want prevent players to fire, you need to substitute the "_aaunit setBehaviour "CARELESS"/"AWARE" lines by the corresponding set of instructions to remove the AA magazines and to reload them respectively. Share this post Link to post Share on other sites
Shashman 0 Posted May 3, 2006 Wow thanks a lot for that, Mandoble, really! I'll go try it now. I guess I could associate an elliptical marker, covering the range of the EW platform's systems, which would be displayed on the map, moving in real time, so that players can see the area affected. How would I do that? Share this post Link to post Share on other sites
mandoble 1 Posted May 3, 2006 Put the following in the EW unit INIT field: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> [this, markername with quotes]exec"ewmarker.sqs" <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ;ewmarker.sqs ; _ewunit = _this select 0 _marker = _this select 1 #placemarker _pos = [getPos _ewunit select 0, getPos _ewunit select 1] _marker setMarkerPos _pos ~1 goto "placemarker" For example, with a plane named ew1 and a marker named mk_ew1: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> [this, "mk_ew1"]exec"ewmarker.sqs" One option you may play with is the flying altitude of the EW plane, so, the higher, the bigger size of the marker and the larger area affected by the EW emissions, but also less probability of effectively jamming the AA systems. Share this post Link to post Share on other sites
Shashman 0 Posted May 3, 2006 Put the following in the EW unit INIT field:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> [this, markername with quotes]exec"ewmarker.sqs" <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ;ewmarker.sqs ; _ewunit = _this select 0 _marker = _this select 1 #placemarker _pos = [getPos _ewunit select 0, getPos _ewunit select 1] _marker setMarkerPos _pos ~1 goto "placemarker" For example, with a plane named ew1 and a marker named mk_ew1: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> [this, "mk_ew1"]exec"ewmarker.sqs" One option you may play with is the flying altitude of the EW plane, so, the higher, the bigger size of the marker and the larger area affected by the EW emissions, but also less probability of effectively jamming the AA systems. Oooooo well thanks for that What would the script for your suggestion look like? I'm a scripting n00b quite obviously Share this post Link to post Share on other sites
mandoble 1 Posted May 3, 2006 How many ew planes do you plan to have flying in the mission? Only one? How many AA units do you plan to have at maximum in the map? Share this post Link to post Share on other sites
Shashman 0 Posted May 3, 2006 Well, there will be one EW platform (Hawk's updated C-130 representing an EC-130H Compass Call) . Is the number of AA units necessary? Could I not define all the vehicle types I want to be affected by the EW aircraft somewhere, then needing to know the total amount wouldn't be necessary? Share this post Link to post Share on other sites
mandoble 1 Posted May 3, 2006 Well, I will assume you have only one EW plane: Script for the INIT field of each enemy AA unit: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ;ewjammed.sqs by Mandoble ; _aaunit = _this select 0 _ewunit = _this select 1 #checkrange ~1 ?damage _aaunit > 0.9:exit ;Nobody inside the aa unit? ?count crew _aaunit == 0:goto "checkrange" ?(_aaunit distance _ewunit) > ewrange: goto "checkrange" _luck = random 1.0 ;you may try also gunner _aaunit setBehaviour "CARELESS" ?_luck < eficiency:_aaunit setBehaviour "CARELESS" ;you may try also gunner _aaunit setBehaviour "AWARE" ?_luck > eficiency:_aaunit setBehaviour "AWARE" goto "checkrange" Script for the INIT field of the EW plane: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ;ewjamming.sqs by Mandoble ; _ewunit     = _this select 0 _minewalt    = _this select 1 _maxewalt    = _this select 2 _rangeatminalt = _this select 3 _rangeatmaxalt = _this select 4 _marker     = _this select 5 ;The following two lines assume there is only one EW plane present ewrange = 1 eficiency = 0.0 #checkrange ~1 ;if too damaged, no more ew jamming ?damage _ewunit > 0.5: ewrange = 1;eficiency = 0.0;exit ;if no pilot, no ew jamming ?format["%1", driver _ewunit] == "<NULL-object>":goto"outofalt" _alt = getPos _ewunit select 2 ? (_alt < _minewalt) || (_alt > _maxewalt): goto "outofalt" _drg = _rangeatmaxalt - _rangeatminalt _dalt = _maxewalt - _minewalt _xd = (_maxewalt - _alt)*(_drg/2)/_dalt _eff = (_xd + 0.1) / (_drg / 2.0) _rg = _rangeatmaxalt - _xd * 2.0 _marker setMarkerSize [_rg, _rg] _pos = [getPos _ewunit select 0, getPos _ewunit select 1] _marker setMarkerPos _pos _marker setMarkerColor "ColorBlue" ;The following two lines assume there is only one EW plane present ewrange = _rg eficiency = _eff goto "checkrange" ;Above or below minimum/maximum effective ew altitudes #outofalt _rg = 1 _marker setMarkerSize [_rg, _rg] _pos = [getPos _ewunit select 0, getPos _ewunit select 1] _marker setMarkerPos _pos _marker setMarkerColor "ColorWhite" ;The following two lines assume there is only one EW plane present ewrange = 1 eficiency = 0.0 goto "checkrange" Lets say you have two Shilkas and one EW plane named ew1, and one marker named mk_ew1 (ellipse with grid fill). For the init fields of the shilkas: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> [this, ew1]exec"ewjammed.sqs" For the init field of EW plane: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> [this, 30, 300, 100, 1000, "mk_ew1"]exec"ewjamming.sqs" The arguments are as follows: ew unit, minimum ew effective altitude, maximum ew effective altitude, ew range at minimum altitude, ew range at maximum altitude marker name Maximum EW efficiency is for minimum ew effective altitude and minimum range. Share this post Link to post Share on other sites
Shashman 0 Posted May 3, 2006 This is wonderful! Thankyou so much Madoble I noticed while testing your original script (ewjamming.sqs which you posted in your first reply) that the enemy AA vehicles still fire, so I changed the script to this : <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;ewjammingSA11.sqs ; _aaunit = _this select 0 _ewunit = _this select 1 _minrange = _this select 2 #checkrange @ (_aaunit distance _ewunit) < _minrange removeallweapons _aaunit _ewunit SideChat "---*9S470M1 FIRE DOME* SIGNAL DETECTED. COMMENCING JAM---" @ (_aaunit distance _ewunit) > _minrange _aaunit addmagazine "9M38_Launcher" _aaunit addmagazine "9M38_Launcher" _aaunit addmagazine "9M38_Launcher" _aaunit addweapon "9M38_Launcher" _ewunit SideChat "---OUT OF JAMMER RANGE. SIGNAL JAMMING ENDED---" goto "checkrange" I had to go for the weapon removal option as they didn't seem to care whether they were in "CARELESS" or "AWARE" mode. They opened fire whenever they wanted to Share this post Link to post Share on other sites
mandoble 1 Posted May 4, 2006 Shashman, if you use ewjamming.sqs for the EW unit, modify the last ewjammed.sqs I write to add the magazines code. Note that in their last version ewjammed.sqs is for AA units and ewjamming.sqs is for the EW unit. You may add a new parameter after the marker name, this would be an efficiency multiplier between 0.1 and 1. Pick up this parameter and multiply it by the resulting efficiency. This way you may simulate the different maximum efficiencies of different EW plane types. For example, with a 0.5, the plane would not get more than 50% chances of nullifying AA units at the minimum efective range/alt. EDIT: About AWARE and CARELESS, you should try to use <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> gunner _aaunit setBehaviour "CARELESS" (or "AWARE") instead of _aaunit setBehaviour "CARELESS" or "AWARE" If the unit has a commander, you may try commander _aaunit setBehaviour "CARELESS" or "AWARE" Share this post Link to post Share on other sites
Shashman 0 Posted May 4, 2006 Yeah I was just thinking last night about how I could simulate system efficiency, percentage of succesful jamming, etc... Once again, sorry for being a n00b, but could you tell me how to implement this/these efficiency parameter(s)? Thanks again, Mandoble UPDATE: OK Mandoble, I have made a quick sample mission using your ewjamming and ewjammed scripts, but nothing much seems to be happening. I see no marker (I made an elliptical solid blue marker left at default dimensions and called it mk_ew1) on the map, and I get shot down left, right and centre lol. I don't really understand what this modified script does exactly now, now that I analyse it closer lol. Share this post Link to post Share on other sites
mandoble 1 Posted May 4, 2006 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ;ewjamming.sqs by Mandoble ; ;Usage: ;[ewunit,minealt,maxealt,maxrgminalt,maxrgmaxalt,marker,maxeff]exec"ewjamming.sqs" ; ;Arguments: ; ewunit: name of the ew plane ; minealt: Minimum effective altitude. This is where the range is minimum but efficiency is maximum (1). Below this alt, there is no EW jamming. ;    maxealt: Maximum effective altitude. This is where the range is maximum but efficiency is minimum (0.1). Above this alt there is no EW jamming. ; maxrgminalt: Maximum range at minimum effective altitude. This range should be smaller than range at max alt. ; maxrgmaxalt: Maximum range at maximum effective altitude. ; marker: Name of the marker between quotes. ; Maximum efficiency: Number between 0.1 and 1. This factor is multiplied by the resulting efficiency calculated based on altitude. ; _ewunit     = _this select 0 _minewalt    = _this select 1 _maxewalt    = _this select 2 _rangeatminalt = _this select 3 _rangeatmaxalt = _this select 4 _marker     = _this select 5 _maxeff     = _this select 6 ;Global variable for ewunit,used in jammingmissile.sqs ewunit = _ewunit ;The following two lines assume there is only one EW plane present ewrange = 1 eficiency = 0.0 #checkrange ~1 ;if too damaged, no more ew jamming ?damage _ewunit > 0.5: ewrange = 1;eficiency = 0.0;exit ;if no pilot, no ew jamming ?format["%1", driver _ewunit] == "<NULL-object>":goto"outofalt" _alt = getPos _ewunit select 2 ? (_alt < _minewalt) || (_alt > _maxewalt): goto "outofalt" _drg = _rangeatmaxalt - _rangeatminalt _dalt = _maxewalt - _minewalt _xd = (_maxewalt - _alt)*(_drg/2)/_dalt _eff = (_xd + 0.1) / (_drg / 2.0) _rg = _rangeatmaxalt - _xd * 2.0 _marker setMarkerSize [_rg, _rg] _pos = [getPos _ewunit select 0, getPos _ewunit select 1] _marker setMarkerPos _pos _marker setMarkerColor "ColorBlue" ;The following two lines assume there is only one EW plane present. ewrange = _rg ;Final efficiency is multiplied by maximum efficiency allowed for the ew unit. eficiency = _eff*_maxeff goto "checkrange" ;Above or below minimum/maximum effective ew altitudes #outofalt _rg = 1 _marker setMarkerSize [_rg, _rg] _pos = [getPos _ewunit select 0, getPos _ewunit select 1] _marker setMarkerPos _pos _marker setMarkerColor "ColorWhite" ;The following two lines assume there is only one EW plane present ewrange = 1 eficiency = 0.0 goto "checkrange" <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ;ewjammed.sqs by Mandoble ; _aaunit = _this select 0 _ewunit = _this select 1 #checkrange ~1 ?damage _aaunit > 0.9:exit ;Nobody inside the aa unit? ?count crew _aaunit == 0:goto "checkrange" ?(_aaunit distance _ewunit) > ewrange: goto "checkrange" _luck = random 1.0 ;you may try also gunner _aaunit setBehaviour "CARELESS" ?_luck < eficiency:_aaunit setBehaviour "CARELESS" ;you may try also gunner _aaunit setBehaviour "AWARE" ?_luck > eficiency:_aaunit setBehaviour "AWARE" goto "checkrange" This is to add as "IncomingMissile" EventHandler to the ew unit, so that even if the AA unit fires a missile, the EW unit has chances to destroy it. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ;jammingmissile.sqs hint "INCOMMING" _unit = _this select 0 _missiletype = _this select 1 _aaunit = _this select 2 _missile = nearestObject [_aaunit, _missiletype] driver _unit sideChat "INCOMMING MISSILE!" #tryjamm ~0.3 ?format["%1", _missile] == "<NULL-object>":exit ? ewunit distance _missile > ewrange: goto "tryjamm" _luck = random 1.0 ;jamming the incomming missile is twice harder than jamming the launcher unit _luck = _luck + 0.5 ?_luck > eficiency: goto "tryjamm" _pos = getPos _missile _warhead = "Heat73" camCreate _pos _warhead = "Heat73" camCreate _pos deleteVehicle _missile driver ewunit sideChat "Missile jammed!" exit With all the above INIT field of AA units: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> [this, ew1]exec"ewjammed.sqs" INIT field of EW unit: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> [this, 10, 300, 100, 1000, "mk_ew1", 1]exec"ewjamming.sqs";this addEventHandler ["IncomingMissile",{_this exec "ewjammingmissile.sqs"}] INIT field of friendly (to ew plane) planes: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> this addEventHandler ["IncomingMissile",{_this exec "ewjammingmissile.sqs"}] Share this post Link to post Share on other sites
Shashman 0 Posted May 4, 2006 I can't thank you enough for the thought and effort you have put into this, Mandoble. Thankyou very much. I'll go and try this out and get back to you Share this post Link to post Share on other sites
mandoble 1 Posted May 4, 2006 Just got interested by your idea If you want to go further into EW and missile wars, try the "Mandomissile 2" demo misson and the intro of "Mandomissile 0". You may have easily even antimissile systems. Mandomisil Suite Share this post Link to post Share on other sites
Shashman 0 Posted May 4, 2006 Yes I downloaded and played about with your missile suite as soon as you released it. Very good work I notice you're from Spain. My 'flight instructor' (Furia on here and in the squad) in the OFP squad I'm a member of is also from Spain, he's a real life chopper pilot. We could certainly use your skills (both scripting genius and virtual pilot ) SabreWolves Armed Forces forum Share this post Link to post Share on other sites
mandoble 1 Posted May 4, 2006 The good point about this is that you can easily modify the mandomisildef.sqs script to affect incomming missiles (their velocity vectors, so they will miss) instead of firing antimissile missiles against them. This way you may have, for example, a ship or a plane with several antimissile system and one jamming system. About the current scripts being discussed here, you should consider two limitations: 1- incomingMissile EventHandler only works with missiles, it will not stop bullets shot by Shilkas, for example. 2 - ewjammed.sqs is too generous with the AA unit, every second your planes are in range, it has a chance of getting a luck factor greater than the efficiency of the EW plane, so it will fire. So I modified it to be able to add a penalty factor against the AA unit: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ewjammed.sqs by Mandoble ; _aaunit = _this select 0 _ewunit = _this select 1 _penalty = _this select 2 #checkrange ~1 ?damage _aaunit > 0.9:exit ;Nobody inside the aa unit? ?count crew _aaunit == 0:goto "checkrange" ?(_aaunit distance _ewunit) > ewrange: goto "checkrange" _luck = random 1.0 _luck = _luck - _penalty ;you may try also gunner _aaunit setBehaviour "CARELESS" ?_luck < eficiency:_aaunit setBehaviour "CARELESS" ;you may try also gunner _aaunit setBehaviour "AWARE" ?_luck > eficiency:_aaunit setBehaviour "AWARE" goto "checkrange" Lets say your EW is at most efficiency height with maxeff factor of 1, so it is getting a resulting efficiency of 1. If you set a penalty factor of 0.2, the AA unit will never get a luck greater than 0.8, being unable to lock on targets. Your new init field of AA units would look like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> [this, ew1, 0.2]exec"ewjammed.sqs" Share this post Link to post Share on other sites
mandoble 1 Posted May 4, 2006 We could certainly use your skills (both scripting genius and virtual pilot ) LOL, as virtual pilot I'm "restricted" to Aces High OFP world, while excelent for land and sea, it is too limited (small) for air warfare Share this post Link to post Share on other sites
Shashman 0 Posted May 4, 2006 I beg to differ... I've been a PC pilot ever since my first PC, from Aces Over Europe, to Chuck Yeager's Air Combat to Jane's Longbow 1 and 2 to MS FS for Win 3.1 through to Jane's F/A-18, Falcon 4.0, Lock On, MS FS 2002 and I have to say that OFP is one of the best helicopter sims available (this is also the opinion of Furia, a real life helicopter pilot with hours logged on choppers ranging from the KA-32, Mi-8, A109...) . Of course the systems are limited in comparison to beefier sims available, but OFP does pretty well considering it's mainly a ground combat sim SWAF is modelled on a US Army battallion and thus we cover everything from infantry, armour to aviation. One mission as a pilot, you may be tasked with MEDEVAC duties, next mission you would be dropping LGBs on a power plant. We're an international squad, and we certainly aim for fun through realism and discipline. We're definitely not CSers Share this post Link to post Share on other sites
mandoble 1 Posted May 5, 2006 Finally I got some time to test all these scripts in a mission, while they work pretty well, the incomming missile script is too dangerous for the launcher. If missile is jammed at first try, it will explode in the face of the launcher unit, destroying it, which is way incorrect. The new script will make the incomming missile to keep going without tracking the target. Real missile is deleted and substituted by a copy which will keep the same velocity vector as the original and will generate similar smoke trail. The jammed missile will keep flying several seconds and then will explode (far away from the launching unit). <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ;jammingmissile.sqs hint "INCOMMING" _unit = _this select 0 _missiletype = _this select 1 _aaunit = _this select 2 _missile = nearestObject [_aaunit, _missiletype] driver _unit sideChat "INCOMMING MISSILE!" #tryjamm ~0.2 ;If missile does not exist, we exit ?format["%1", _missile] == "<NULL-object>":exit ;If missile is out of jamming range ? ewunit distance _missile > ewrange: goto "tryjamm" ;Luck is the luck of the missile, if greater than your efficiency ;the missile will keep pursuing the target _luck = random 1.0 ;If you want to make twice harder to jamm missiles, ;uncomment the next line ;_luck = _luck + 0.5 ?_luck > eficiency: goto "tryjamm" ;Missile jammed hint "JAMMED!" driver ewunit sideChat "Missile jammed!" ;We change the real missile by a copy _timeini = time _vel = velocity _missile _pos = getPos _missile _dir = getDir _missile deleteVehicle _missile _missile = _missiletype createVehicle _pos _missile setDir _dir _missile setVelocity _vel ;The missile will keep going (not tracking the target) for 3 seconds #keepgoing _missile setVelocity _vel drop["cl_basic","","Billboard",100,3,[0,0,0],[0,0,0],0,20,20,0.05,[1,1.5,2,2],[[0.8,0.8,0.8,0.6],[0.8,0.8,0.8,0.5],[0.8,0.8,0.8,0.4],[0,0,0,0]],[0,1,0,0.33,0.66],0,0,"","",_missile] ~0.02 ? (time - _timeini) < 3: goto "keepgoing" _pos = getPos _missile deleteVehicle _missile _warhead = "Heat125" camCreate _pos _warhead = "Heat125" camCreate _pos exit Share this post Link to post Share on other sites