firewill 3880 Posted October 12, 2014 Hi, I'm just Silently making for KF-16C/F-16C for ROK ARMED FORCES 2035 mod. i'm currently make some Anti-Radiation Missile, like AGM-88 HARM.(ROKAF have AGM-88 HARM Missile for KF-16C). but ArmA is not support the "Following Radar Signal", so i decided for HARM is Only can damage for Anti-Air Vehicles. My Plan is, Shoot the HARM at T-100 Tank, damage is minimal. but If Target is Tigris AA Vehicles, Tigris is Finished by HARM. Anyway, Problem is HARM can't Destroy the AA Vehicles. My Script is: private ["_ArrayAA","_countAA","_unitAA"]; _harm= _this select 0; hintsilent "fired HARM"; if (not alive _harm) exitwith {}; _zpos = getpos _harm select 2; while {_zpos > 10} do { _zpos = getpos _harm select 2; hintSilent "Missile is moving"; sleep 0.2; }; _zpos = getpos _harm select 2; if (_zpos < 9) then { hintsilent "HARM in 9 meter"; _ArrayAA = nearestobjects [getpos _harm,["O_APC_Tracked_02_AA_F"],10]; }; _CountAA = count _ArrayAA; for "_i" from 0 to _CountAA do { if (_harm distance (_ArrayAA select _i) < 2 and (_ArrayAA select _i) iskindof "O_APC_Tracked_02_AA_F") then { (_ArrayAA select _i) setdamage 1; hintsilent "AA Destroyed"; }; }; but i can't see some any Warning or Error Message in RPT.. is mean Script is Normal? Thank you. Firewill Share this post Link to post Share on other sites
x3kj 1247 Posted October 12, 2014 (edited) *nothing to see here, pass along* Edited October 12, 2014 by Fennek statement was wrong Share this post Link to post Share on other sites
firewill 3880 Posted October 12, 2014 *nothing to see here, pass along* _zpos is working. because fired the missile, if HARM below altitude 9m, print the hint "HARM in 9 meter". i think main problem is nearestobjects and for structure.. i guess. but i don't know what is wrong. because in RPT, i don't have any seen about Error Message. Share this post Link to post Share on other sites
x3kj 1247 Posted October 12, 2014 (edited) Hm let's think about this: if (_zpos < 9) then { hintsilent "HARM in 9 meter"; _ArrayAA = nearestobjects [getpos _harm,["O_APC_Tracked_02_AA_F"],10]; }; Your missile is 9m above the current piece of ground. And it checks in a 10m radius. That's a very small area on the ground that you are checking for suitable targets. and only right below the missile. Have you tried to look for the objects in a bigger radius just for test purposes? Edit: tracked vanilla A3 missiles aim directly at the target. THerefore you won't find anything in front of the missile if it's in 9m height when you check with 10m radius. You will only find targets below the missile. Depending on the angle of the missiles speed vector to the groundplane, the shallower you fire the missile the higher the search radius needs to be in order to check for the actual impact position. Edited October 12, 2014 by Fennek Share this post Link to post Share on other sites
firewill 3880 Posted October 12, 2014 (edited) Hm let's think about this: if (_zpos < 9) then { hintsilent "HARM in 9 meter"; _ArrayAA = nearestobjects [getpos _harm,["O_APC_Tracked_02_AA_F"],10]; }; Your missile is 9m above the current piece of ground. And it checks in a 10m radius. That's a very small area on the ground that you are checking for suitable targets. and only right below the missile. Have you tried to look for the objects in a bigger radius just for test purposes? Edit: tracked vanilla A3 missiles aim directly at the target. THerefore you won't find anything in front of the missile if it's in 9m height when you check with 10m radius. You will only find targets below the missile Still not change the anything.. :-( Edited October 12, 2014 by firewill Share this post Link to post Share on other sites
x3kj 1247 Posted October 12, 2014 (edited) A better approach might be to use the missile flightvector and draw a line with one of the lineIntersects commands to get the estimated impact location of the current flight vector. From this location you can do your search and with a delay, kill the targets that you predetermined. I would try another approach (though i'm not an expert, so it may be more difficult) that comes closer to the real thing. What i would try instead, is to create a dumbfire missile. A fired eventhandler detects the shot, and searches for suitable targets in a larger area around the aircraft. As you only check for few very specific targets (AA) i dont think it would be too performance intensive. You need to filter out a suitable target that is infront of the aircraft. Now, once a suitable target is found, the missile gets rotated into the direction it needs to go. I'm not sure if you can script an A3 missile/weapon lock onto a missile mid flight. Alternatively, create an invisible extra vehicle at the place of the dumbfire missile with an AI in it, and command it to fire at the target you found with a new, guided missle to get a proper weapon lock. Delete the dumbfire missile and the AI vehicle after that. Edited October 12, 2014 by Fennek Share this post Link to post Share on other sites
John Spartan 89 Posted October 12, 2014 (edited) How about different approach: - set the weapon ammo setting IRtarget = 0; and with same time add lasertarget =1; - that will mean the ammo wont be allowing tab lock on a tank in first place - then add a code [small loop] that waits until AGM88 is selected by player if (currnetweapon ==) then {}; - once player selects AGM 88 script looks for all suitable targets within your definition and adds a fake empty laser target at actual targets position - with the attached fakelasertarget player gets a chance to lock on it via TABlock - once missile is fiered game engine will do the rest - in the code you loop in case player switches to a different weapon add a line that destroys fake targets [camdestroy] not deletevehicle [that might crash the game if missile in mid air loosed it's target] - additionally create on a config entry a fake target vehicle [like example below] - side-effect on this approach is players being able to laser guide this weapon via designator In real life AGM 88 is designed to seek active radar targets, but payload in the warhead is still has enough punch to heavily damage armoured vehicle in case of direct hit [some players have mastered manual bomb/missile releases more than enough to hit a tank without a tab lock assistance]. See the code example used on FA18's to restrict JDAM/TAB lock usage: while {(_FA18X animationphase "switch_GPS_TGT_CLEAR" < 0.01) and (alive _FA18X)} do { if ((currentweapon _FA18X == "js_w_FA18X_GBU38BombLauncher") or (currentweapon _FA18X == "js_w_FA18X_GBU32BombLauncher") or (currentweapon _FA18X == "js_w_FA18X_GBU31BombLauncher")) then {_target hideObject false} else {_target hideObject true}; sleep 0.1; }; fake target cfgvehicles config class MY_fake_radar: LaserTarget { displayName = "RADAR Target"; nameSound = ""; // threat (VSoft, VArmor, VAir), how threatening vehicle is to unit types threat[] = {0.0, 0.0, 1.0}; camouflage = 99; // how dificult to spot - bigger - better spotable accuracy = 0; // accuracy needed to recognize type of this target alwaysTarget = 1; type = VArmor; simulation = "artillerymarker"; laserTarget = true; irTarget = false; nvTarget = false; artilleryTarget = false; allowTabLock = 1; side = TEast; scope = protected; }; just instead of using "_target hideObject" use createvehicle _target [for each suitable target] There is always more than way of archiving the goal. Edited October 12, 2014 by John_Spartan Share this post Link to post Share on other sites
firewill 3880 Posted October 12, 2014 ok, i find some other solution. thank you, Fennek Share this post Link to post Share on other sites
x3kj 1247 Posted October 12, 2014 - once player selects AGM 88 script looks for all suitable targets within your definition and adds a fake empty laser target at actual targets position But that would lead to other weapons (from other vehicles) beeing able to lock on it as well without knowing about it Share this post Link to post Share on other sites
John Spartan 89 Posted October 12, 2014 @Fennek - createvehiclelocal is solution in this case. Aslo via script you can manipulate hide/unhide object with more conditions [depends how far you want to push it] Share this post Link to post Share on other sites
x3kj 1247 Posted October 12, 2014 Ah ok nice, haven't thought of that possibility Share this post Link to post Share on other sites
firewill 3880 Posted October 13, 2014 How about different approach: - set the weapon ammo setting IRtarget = 0; and with same time add lasertarget =1; - that will mean the ammo wont be allowing tab lock on a tank in first place - then add a code [small loop] that waits until AGM88 is selected by player if (currnetweapon ==) then {}; - once player selects AGM 88 script looks for all suitable targets within your definition and adds a fake empty laser target at actual targets position - with the attached fakelasertarget player gets a chance to lock on it via TABlock - once missile is fiered game engine will do the rest - in the code you loop in case player switches to a different weapon add a line that destroys fake targets [camdestroy] not deletevehicle [that might crash the game if missile in mid air loosed it's target] - additionally create on a config entry a fake target vehicle [like example below] - side-effect on this approach is players being able to laser guide this weapon via designator In real life AGM 88 is designed to seek active radar targets, but payload in the warhead is still has enough punch to heavily damage armoured vehicle in case of direct hit [some players have mastered manual bomb/missile releases more than enough to hit a tank without a tab lock assistance]. See the code example used on FA18's to restrict JDAM/TAB lock usage: fake target cfgvehicles config just instead of using "_target hideObject" use createvehicle _target [for each suitable target] There is always more than way of archiving the goal. Ok, I will Try it. Thank you! Share this post Link to post Share on other sites
firewill 3880 Posted October 13, 2014 i'm working on script based of John_Spartan's approach, some modified. in Config.cpp class UserActions { class FindRadarTGT { displayName = "Find Radar Target"; position = "pos cano"; radius = 15; condition = "currentweapon this == ""FIR_AGM88"";"; statement = "[this] execVM ""\FIR_F16\sqs\harm2.sqf"";"; onlyforplayer = "False"; }; if F-16 Select the HARM, find radar target action is enable. Currently Working on this harm2.sqf _f16 = _this select 0; _ArrayAA = nearestobjects [getpos _f16,["O_APC_Tracked_02_AA_F"],100000]; _CountAA = count _ArrayAA; for "_i" from 0 to _CountAA do { private ["_RDRTGT"]; _RDRTGT = "FIR_Radar_TGT" createVehicleLocal position (_ArrayAA select _i); _RDRTGT attachTo [(_ArrayAA select _i),[0,0,0]]; }; But i have some Problem is "Error Undefined variable in expression: _rdrtgt" in RPT. Anyway, Radar Target is Successfully Create on Enemy AA Vehicle, just Attach of between them. Share this post Link to post Share on other sites
John Spartan 89 Posted October 13, 2014 (edited) @Firewill - define _RDRTGT = as nill in the beginning of code, it has to have an initial value - using attachto command for adding fake target use offset slightly above "target" [just a little] to avoid fake target geometry [and therefore visibility] to be obstructed by vehicles geometry, otherwise game engine wont let you see the target [see BI WIKI on LODS] And a small suggestion if I may, you have added 100km search radius for the radar [in RL correct] but in ARMA due to the scale of map it's worth considering a bit of a "watered down" radar sys. Like 2/3 or 1/2 of map size. Gameplay vs realism. If you make it to realistic it wont be fun. Also in the code evaluation you can use lineIntersects script command, since radar can be obstructed by terrain or bigger objects. Add this to an evaluation of valid target. Loop it with 0.5 or 1 [don't do per frame loops if possible, that costs FPS on weaker machines and is a hustle to already stuttering MP] Edited October 13, 2014 by John_Spartan Share this post Link to post Share on other sites
firewill 3880 Posted October 13, 2014 @John_Spartan Still have undefined variable problem. _RDRTGT = nil; <- its right syntax? Share this post Link to post Share on other sites
John Spartan 89 Posted October 13, 2014 @Firewill, To define empty array use _RDRTGT = []; Why is the private in the loop? Doe is has any specific meaning for being there. Wrong positioned private variable will mean that variable will be visible only within the current scope of code block. If no specific reason for it being there delete it, or move to top together with base variable definitions. Share this post Link to post Share on other sites
eggbeast 3684 Posted October 13, 2014 just a comment on this great project... we did this in unsung to remove IR targeting from most airborne weapons and add lasertarget = 1; in all the radar using vehicles, and allow lasertargeting (laserlock = 1) in the ARM weapons and it works a treat. Given the other weaponry available in modern theatre, the approach John has suggested looks sound to me. You might also consider tinkering with reveal target as sometimes the laser target does not get revealed and so while you can lock it 100% of the time in testing oin editor, especially in a busy multiplayer server you can spend ages trying to lock it. not sure exactly how this may help you yet, just thinking out loud in case it may help in MP implementation... mykes GPS/INS adds a whole new targeting ability to certain weapons, perhaps we could clone that and add a radargroundlock = true and radarairlock = true function to our work? in fact i may do just that in our Arma 2 air mod. this would enable air and ground radar targeting... and could make use of the radar reach of the vehicle, or the missile, if specified... getting better... Share this post Link to post Share on other sites
firewill 3880 Posted October 14, 2014 undefined variable problem is solved, but Still Radar target can't Attach to AA Vehicles. but script is working fine, because last hintsilent is printed in screen. harm2.sqf (Range 100km is for TEST) _f16 = _this select 0; _f16 animate ["WWSwitch",1]; _ArrayAA = nearestobjects [getpos _f16,["O_APC_Tracked_02_AA_F"],100000]; _CountAA = count _ArrayAA; for "_i" from 0 to _CountAA do { _RDRTGT = "FIR_Radar_TGT" createVehicleLocal position (_ArrayAA select _i); sleep 0.5; _ArrayRDR = nearestobjects [getpos _f16,["FIR_Radar_TGT"],100000]; _countRDR = count _ArrayRDR; for "_j" from 0 to _countRDR do { if (_i == _j) then { (_ArrayRDR select _j) setpos (getpos (_ArrayAA select _i)); (_ArrayRDR select _j) attachTo [(_ArrayAA select _i),[0,0,0],"OsaVelitele"]; hintsilent "radar target is attach to AA Vehicle"; }; }; sleep 1; }; Share this post Link to post Share on other sites
John Spartan 89 Posted October 14, 2014 @Firewill, OsaVelitele the memory point might not be present in all vehicles that are classed as target, don't go for memory point you can attacto with just offset [relative to center of 3d modelspace of tgt]. Share this post Link to post Share on other sites
firewill 3880 Posted October 14, 2014 @Firewill, OsaVelitele the memory point might not be present in all vehicles that are classed as target, don't go for memory point you can attacto with just offset [relative to center of 3d modelspace of tgt]. using offset for first try, but can't attach it. use the memory point is not working too. :-( Share this post Link to post Share on other sites
John Spartan 89 Posted October 14, 2014 @Firewill, as for correct usage of attach to: attaching a object 1 to object 2 without usage of memory point. _object_1 attachTo [_object_2,[0.0,0.0,0.0]]; Capture the object before you give it to attach to _ArrayRDR_i =_ArrayRDR select _j; Also make sure that you capture the right object hintsilent format["VAR1: %1\nVAR2: %2",_ArrayRDR_i, _ArrayRDR_j]; Also try to attach a visible object instead of laser target first [like a small item] just to see is the code working visually. Share this post Link to post Share on other sites