MoXiSt_Epshtein 0 Posted February 17, 2020 i got a script from this guy i did all he said and some how my script does not work. this is the script for each sqf file FILE 1 init.sqf call compile preprocessFileLineNumbers "IronDome.sqf"; if(isServer)then{ { if (_x isKindOf "B_SAM_System_02_F")then{ [_x,4000]call addToIronDome; }; } forEach vehicles; }; FILE 2 IronDome.sqf if(isServer)then{ addToIronDome = { params["_launcher", "_detectionrange"]; _null = [_launcher, _detectionrange]spawn{ private ["_launcher","_detectionrange", "_incoming","_destination","_interceptor"]; _launcher = _this select 0; _detectionrange = _this select 1; _mag = weaponState [_launcher, [0]]; _ammo = getText (configFile ˃˃ "CfgMagazines" ˃˃ magazines _launcher select 0 ˃˃ "ammo"); while {alive _launcher}do{ _incoming = _launcher nearObjects ["RocketBase", _detectionrange]; _incoming = _incoming + (_launcher nearObjects["MissileBase", _detectionrange]); _incoming = _incoming + (_launcher nearObjects["ShellBase", _detectionrange]); if (count _incoming ˃ 0) then{ _target = selectRandom _incoming; _fromTarget = _target getDir _launcher; _dirTarget = direction _target; _destination = position _target; _launcher lookAt _destination; _tracked = _target getVariable "engaged"; if((typeOf _target != _ammo) && (_dirTarget ˂_fromTarget + 60) && (_dirTarget ˃_fromTarget - 60) && (alive _target) && (isNil "_tracked")) then { _target setVariable ["engaged", 123,true]; [_launcher, _mag select 1] call BIS_fnc_fire; sleep 0.1; _interceptor = position _launcher nearObjects [_ammo, 100] select 0; _fails = 0; while {alive _interceptor} do { _minDist = _target distance _interceptor; _velocity = (velocityModelSpace _interceptor) vectorMultiply 1.01; _velocityTrue = velocityModelSpace _interceptor; _dirHor = [_interceptor, _target] call BIS_fnc_DirTo; _interceptor setDir _dirHor; _dirVer = acos ((_target distance2D _interceptor) /(_target distance _interceptor)); [_interceptor, _dirVer, 0] call BIS_fnc_setPitchBank; _interceptor setVelocityModelSpace _velocity; sleep 0.002; if (_minDist ˂ _target distance _interceptor) then { _fails = _fails + 1; } else {_fails = 0}; if (_fails ˃ 3) then { "HelicopterExploBig" createVehicle (getPos _interceptor); deleteVehicle _interceptor; }; if (_interceptor distance _target ˂ 60) then { "HelicopterExploBig" createVehicle (getPos _interceptor); deleteVehicle _interceptor; sleep 0.5; "HelicopterExploBig" createVehicle (getPos _target); deleteVehicle _target; }; }; }; }; if (count _incoming == 0) then { sleep 0.5; }; }; }; }; }; If some one can help me with that on discord i will be very glad. Share this post Link to post Share on other sites
Harzach 2507 Posted February 17, 2020 What are you using to create your .sqf files? If the formatting in them is the same as what you pasted above, that's a problem. You can't flatten code like that and expect it to run. Your files should look something like this: Spoiler call compile preprocessFileLineNumbers "IronDome.sqf"; if (isServer) then { { if (_x isKindOf "B_SAM_System_02_F") then { [_x, 4000] call addToIronDome; }; } forEach vehicles; }; Spoiler if (isServer) then { addToIronDome = { params ["_launcher", "_detectionrange"]; _null = [_launcher, _detectionrange] spawn { private ["_launcher","_detectionrange","_incoming","_destination","_interceptor"]; _launcher = _this select 0; _detectionrange = _this select 1; _mag = weaponState [_launcher, [0]]; _ammo = getText (configFile >> "CfgMagazines" >> magazines _launcher select 0 >> "ammo"); while {alive _launcher} do { _incoming = _launcher nearObjects ["RocketBase", _detectionrange]; _incoming = _incoming + (_launcher nearObjects["MissileBase", _detectionrange]); _incoming = _incoming + (_launcher nearObjects["ShellBase", _detectionrange]); if (count _incoming > 0) then { _target = selectRandom _incoming; _fromTarget = _target getDir _launcher; _dirTarget = direction _target; _destination = position _target; _launcher lookAt _destination; _tracked = _target getVariable "engaged"; if ((typeOf _target != _ammo) && (_dirTarget < _fromTarget + 60) && (_dirTarget > _fromTarget - 60) && (alive _target) && (isNil "_tracked")) then { _target setVariable ["engaged", 123,true]; [_launcher, _mag select 1] call BIS_fnc_fire; sleep 0.1; _interceptor = position _launcher nearObjects [_ammo, 100] select 0; _fails = 0; while {alive _interceptor} do { _minDist = _target distance _interceptor; _velocity = (velocityModelSpace _interceptor) vectorMultiply 1.01; _velocityTrue = velocityModelSpace _interceptor; _dirHor = [_interceptor, _target] call BIS_fnc_DirTo; _interceptor setDir _dirHor; _dirVer = acos ((_target distance2D _interceptor) / (_target distance _interceptor)); [_interceptor, _dirVer, 0] call BIS_fnc_setPitchBank; _interceptor setVelocityModelSpace _velocity; sleep 0.002; if (_minDist < _target distance _interceptor) then { _fails = _fails + 1; } else { _fails = 0; }; if (_fails > 3) then { "HelicopterExploBig" createVehicle (getPos _interceptor); deleteVehicle _interceptor; }; if (_interceptor distance _target < 60) then { "HelicopterExploBig" createVehicle (getPos _interceptor); deleteVehicle _interceptor; sleep 0.5; "HelicopterExploBig" createVehicle (getPos _target); deleteVehicle _target; }; }; }; }; if (count _incoming == 0) then { sleep 0.5; }; }; }; }; }; There were also a few instances where whitespace was removed and operators were prepended to variable names, breaking things rather well. Share this post Link to post Share on other sites
Harzach 2507 Posted February 17, 2020 Just tested, and it sort of works. When a launcher runs out of ammo, it throws an undefined variable error for "_interceptor," so maybe a check needs to be made for that somewhere. Share this post Link to post Share on other sites
MoXiSt_Epshtein 0 Posted February 18, 2020 would like to get help via discord because the script doesn't work for me. even after your help Share this post Link to post Share on other sites
Harzach 2507 Posted February 18, 2020 Share your mission file. Share this post Link to post Share on other sites
MoXiSt_Epshtein 0 Posted February 18, 2020 sqm file ? i am not that good in arma things sry for that... Share this post Link to post Share on other sites
MoXiSt_Epshtein 0 Posted February 18, 2020 I uploaded my mission folder with all sqf and sqm files in it over here http://www.mediafire.com/folder/zwr6z4q7e2r38/matan.hebontes Share this post Link to post Share on other sites
Harzach 2507 Posted February 18, 2020 The best way to troubleshoot this sort of thing (or anything, really) is to break it down to its basic components. Try a simple repro mission using only vanilla assets. Here's mine: https://www.dropbox.com/home/Public/ironDome.VR Share this post Link to post Share on other sites
MoXiSt_Epshtein 0 Posted February 19, 2020 it saying for me in the dropbox "The folder ‘/Public/ironDome.VR’ doesn’t exist." Share this post Link to post Share on other sites
MoXiSt_Epshtein 0 Posted February 19, 2020 when i did all i need it saying me this thing Share this post Link to post Share on other sites
MoXiSt_Epshtein 0 Posted February 19, 2020 Can you help me with that on discord ? Share this post Link to post Share on other sites
Harzach 2507 Posted February 19, 2020 Not sure why that link didn't work. Here's a different Dropbox link:https://www.dropbox.com/sh/8xy5l66ezwyfjx4/AABx59ecmNjcAieeGaKXuXm7a?dl=0 Share your simple repro mission. I can't personally do any more for you on Discord than I can for you here, but anyone else is obviously free to jump in. Share this post Link to post Share on other sites
MoXiSt_Epshtein 0 Posted February 19, 2020 on teamviewer ? maybe Share this post Link to post Share on other sites
MoXiSt_Epshtein 0 Posted February 19, 2020 on your mission it saying me this Share this post Link to post Share on other sites
MoXiSt_Epshtein 0 Posted February 19, 2020 by the way the launcher took a look on the shells but didn't shot and then froze Share this post Link to post Share on other sites
MoXiSt_Epshtein 0 Posted February 19, 2020 as you can see here Share this post Link to post Share on other sites
Harzach 2507 Posted February 19, 2020 Yes, as I mentioned previously: On 2/17/2020 at 6:54 PM, Harzach said: Just tested, and it sort of works. When a launcher runs out of ammo, it throws an undefined variable error for "_interceptor," so maybe a check needs to be made for that somewhere. Open my mission in the editor: Share this post Link to post Share on other sites
Harzach 2507 Posted February 19, 2020 Don't know what to tell you, other than to ask you again to share your simple repro mission. The mission I shared is working as described on my end, and throws no errors when turrets are given infinite ammo. Share this post Link to post Share on other sites
MoXiSt_Epshtein 0 Posted February 19, 2020 maybe can you help me via teamviewer and talk with me because it is really hard for me to understand all of this and i am doing wrong, btw i launched your mission and it showing me the error Share this post Link to post Share on other sites
Harzach 2507 Posted February 19, 2020 Yes, the error will appear until you place the given code in the launcher. I am actually in the middle of work, so I can't help other than via messages here. Share this post Link to post Share on other sites
MoXiSt_Epshtein 0 Posted February 19, 2020 when you free tell me and i will try to be free as you,i really need to make that script work Share this post Link to post Share on other sites
Harzach 2507 Posted February 19, 2020 The script itself still has issues, the main one being the occasional missile fired in a seemingly random direction (though I suspect it's actually firing at [0,0,0] in lieu of a valid position). Honestly, I'm not likely to be of much help outside this forum (and of limited help within, to be sure). As far as it is capable, the script works. There is something wrong on your end. Please share your simple repro mission. Share this post Link to post Share on other sites
MoXiSt_Epshtein 0 Posted February 19, 2020 the thing is that the launcher looking at the shells and the rockets but not shooting. Share this post Link to post Share on other sites