sarogahtyp   1108 Posted March 19, 2019 If I did no logical mistake due to brain farting 😉 then this should give you the impact position by simulating the flight path:  Spoiler /* Author: Sarogahtyp File: impact_pos.sqf Description: Calculates the impact postion of non propelled artillery shell by a very simple and unprecise simulation of flight path Parameter(s): 0: shell - the object of the shell one likes to know impact position of - default is null object Returns: position - impact position */ params [["_shell", objNull]]; if (_shell isEqualTo objNull) exitWith {[0,0,-100]}; //return nonsense position if no object was given _epsilon = 3; // meters - height at which calculation will abort due to near impact _curr_pos = position _shell; _shell_height = _curr_pos select 2; if (_shell_height < _epsilon) exitWith {position _shell}; //shell is already/nearly impacted, return its position _grav = -9.81; _time_step = 1; // second - iteration resolution - could be adjusted to needs _curr_vel = velocity _shell; _curr_pos_asl = getPosASL _shell; while {_shell_height > _epsilon} do { _shell_height = (ASLToATL _curr_pos_asl) select 2; //calculate next shell position by adding velocity vector to current position _curr_pos_asl = _curr_pos_asl vectorAdd (_curr_vel vectorMultiply _time_step); //calculate next velocity vector by just taking gravity into account _curr_vel = _curr_vel vectorAdd [0, 0, _grav * _time_step]; }; //return the impact position (ASLToATL _curr_pos_asl)  you should play around with _time_step to get a good balance between precision and performance. I did not test anything. errors may happen.  EDIT: corrected position calculation to use ASL position format. 2 Share this post Link to post Share on other sites
sarogahtyp   1108 Posted March 19, 2019 Next step is taking thrust into account: Spoiler /* Author: Sarogahtyp File: calc_impact_pos.sqf Description: Calculates the impact postion of non propelled or self propelled artillery shell by a very simple and unprecise simulation of flight path This version takes possible thrust of self-propelled shell into account Parameter(s): 0: shell - the object of the shell one likes to know impact position of - default is null object Returns: position - impact position */ params [["_shell", objNull]]; if (_shell isEqualTo objNull) exitWith {[0,0,-100]}; //return nonsense position if no object was given _epsilon = 3; // meters - height at which calculation will abort due to near impact _curr_pos = position _shell; _shell_height = _curr_pos select 2; if (_shell_height < _epsilon) exitWith {position _shell}; //shell is already/nearly impacted, return its position _max_speed = 0; _grav = -9.81; _time_step = 1; // second - iteration resolution - could be adjusted to needs _thust_vec = [0,0,0]; _thrust = getNumber(configFile >> "CfgAmmo" >> (typeOf _shell) >> "thrust"); if ( _thrust > 0) then { _max_speed = getNumber(configFile >> "CfgAmmo" >> (typeOf _shell) >> "maxSpeed"); _thrust_vec = (vectorDir _shell) vectorMultiply _thrust; } _curr_vel = velocity _shell; _curr_pos_asl = getPosASL _shell; while {_shell_height > _epsilon} do { _shell_height = (ASLToATL _curr_pos_asl) select 2; //calculate next shell position by adding velocity vector to current position _curr_pos_asl = curr_pos_asl vectorAdd (_curr_vel vectorMultiply _time_step); // add velocity change caused by gravity to current velocity vector _curr_vel = _curr_vel vectorAdd [0, 0, _grav * _time_step]; // add current thrust vector to current velocity vector to take thrust into account if ((_thrust > 0) && ((vectorMagnitude _curr_vel) < _max_speed) then { _curr_vel = _curr_vel vectorAdd (_thrust_vec vectorMultiply _time_step); //calculate next base thrust vector by normalizing next velocity vector and applying base thrust _thrust_vec = (vectorNormalized _curr_vel) vectorMultiply _thrust; }; }; //return the impact position (ASLToATL _curr_pos_asl)  This script is untested as well. before testing this version you should test the version without thrust to get rid of possible errors.  Next step is to calculate acceleration/deceleration between time steps more precisely. After that the impact position should be relatively precise.  EDIT: corrected position calculation to use ASL position format. EDIT2: corrected name of shell object in CfgAmmo lookup EDIT3: maybe this script with thrust will not work. depends on fact if mlrs uses winglets to control flight path. If so then I cant imagine a way to predict its flight path. 1 Share this post Link to post Share on other sites
Eroge   3 Posted March 19, 2019 Does this radar detect the shells that would fall in the range of detection, or it detects the shells that already entered the range of detection? Cause I want to modify this script into an arty warning script for vehicles like Warthunder Share this post Link to post Share on other sites
sarogahtyp   1108 Posted March 19, 2019  3 minutes ago, Eroge said: Does this radar detect the shells that would fall in the range of detection, or it detects the shells that already entered the range of detection? Cause I want to modify this script into an arty warning script for vehicles like Warthunder afaik it detects a shell which entered the radar range, calculates its impact position and draws a marker on the map where the impact will happen. Share this post Link to post Share on other sites
ofp_f3d3   28 Posted March 19, 2019 15 minutes ago, sarogahtyp said:  afaik it detects a shell which entered the radar range, calculates its impact position and draws a marker on the map where the impact will happen. Couldnt have said it any better myself 😂.  Your brain farting gave me an idea, i discovered that the angle and speed is correctly measured. But for example, if my expected distance is 2400 meters, i need to add the ASL altitude of the final position which is pretty simple, ill test this and return to announce if it was a brilliant idea or a stroke.  EDIT: MASSIVE STROKE Share this post Link to post Share on other sites
sarogahtyp   1108 Posted March 19, 2019 40 minutes ago, ofp_f3d3 said: Your brain farting gave me an idea, i discovered that the angle and speed is correctly measured. But for example, if my expected distance is 2400 meters, i need to add the ASL altitude of the final position which is pretty simple, ill test this and return to announce if it was a brilliant idea or a stroke.  I would be surprised if this solves it. As I told before, what does your script when a mountain is hit during the flight and how do you know the terrain height of the impact point before calculating it? Also how do you like to get thrust into your calculations? Its direction is changing while propulsion is active.  EDIT: But I think my scripts have a big mistake in it currently therefore it will not work. I've to think about. EDIT2: First script should have correct calculations now. EDIT3: 2nd script corrected as well. Share this post Link to post Share on other sites
ofp_f3d3   28 Posted March 19, 2019 I´ve run some more tests.  The following pictures show 2 tests done with you method and mine, using the same target. The crosshair is where the AI was told to fire 1 Round of HE. First picture shows the prediction made by my solution.   This one is from your 2nd script posted above  As you can see, both have almost the same spread error.  BTW, where can i find the functions used by the artillery computer??? i would love to read where does the computer get the SPREAD value from. 1 Share this post Link to post Share on other sites
sarogahtyp   1108 Posted March 19, 2019 You are using a flat area relativly near above sea level. try it with the target in a much higher area. it should make a difference I guess. Also what happens if you set _time_step to 0.1 in my script? it should be much more precise then. Last thing is you should not draw the crosshair at the intended target location but exactly where the shell has hit the ground. 1 1 Share this post Link to post Share on other sites
ofp_f3d3   28 Posted March 19, 2019 56 minutes ago, sarogahtyp said: You are using a flat area relativly near above sea level. try it with the target in a much higher area. it should make a difference I guess. Also what happens if you set _time_step to 0.1 in my script? it should be much more precise then. Last thing is you should not draw the crosshair at the intended target location but exactly where the shell has hit the ground. i lowered that var to 0.1 and the center of the marker literally missed by 2 meters, F***ING PIN-POINT ACCURACY. ABSOLUTELY MAGNIFICENT. And no fps drop even with 15 rounds one after another. 😠 I actually dont know how to thank you for the help man. I´ll use your method and give you the proper credit. i´ll upload Version 0.1 today wth some minor changes + this new calculation method. 3 Share this post Link to post Share on other sites
sarogahtyp   1108 Posted March 19, 2019 I'm absolutly happy that I was able to help you here. Thank you for the scripting idea and for your respond to my solution. 😊 I think you should use the 1st script which is without thrust. I doubt that my thrust method works with mlrs rounds as I told above. But you could test the 2nd with mlrs and if it works then use it.  You could try to optimize the _time_step value. I think a value which produces an error of 10-20 meters should be good as well and would save some calculation iterations.  just FYI if you double the value then you save the half calculation time. If the flight time from grabbing to impact is 30 second then a value of 0.1 means 300 calculation iterations. With 0.2 its 150! Therefore you should set it as low as necessary but as high as possible. 1 Share this post Link to post Share on other sites
ofp_f3d3 Â Â 28 Posted March 19, 2019 Released 0.1!!! Changelog in first post 2 Share this post Link to post Share on other sites
sarogahtyp   1108 Posted March 19, 2019 .rar file seems to be broken. maybe you could upload it again? Share this post Link to post Share on other sites
ofp_f3d3 Â Â 28 Posted March 20, 2019 1 hour ago, sarogahtyp said: .rar file seems to be broken. maybe you could upload it again? Weird, i downloaded it myself... i took it down now and re-uploaded it. Share this post Link to post Share on other sites
sarogahtyp   1108 Posted March 20, 2019 On ‎3‎/‎20‎/‎2019 at 1:04 AM, ofp_f3d3 said: Weird, i downloaded it myself... i took it down now and re-uploaded it. thx, works now.  Currently I'm looking into your script to find optimizations. Ill expand this post with my finds to not spam your thread with posts for every new find.  Spoiler 1. ArtRadar.sqf: This script will be executed on each machine (clients and server) because if someone sets an object in mission editor and adds an init line then this line is executed everywhere. You should add this as first code line: if(!isServer) exitWith {};  2. Radar_Main.sqf: The var _radaralt and _radarpos are not used. You could just delete these lines: _radarpos = position _radar; _radaralt = (getPosASL _radar) select 2;  3. Radar_FiltroRondas.sqf: The following line can have heavy impact if there are many shells in radar range (like in a tank battle). The reason is that all conditions in your select section are checked for every shell and those config file crawling can have a heavy performance impact then. _rondas = _radarpos nearObjects ["ShellBase",_rango] select {(getPosASL _x) select 2 > _radaralt + 500 && ((getNumber(configFile >> "CfgAmmo" >> (typeOf _x) >> "artilleryLock")) == 1)}; You should better use lazy evaluation for it to avoid the config crawling for low height tank shells: _rondas = _radarpos nearObjects ["ShellBase",_rango] select {(getPosASL _x) select 2 > _radaralt + 500 && {((getNumber(configFile >> "CfgAmmo" >> (typeOf _x) >> "artilleryLock")) == 1)}}; to be continued ...  Continuation: Spoiler Radar_FiltoRondas.sqf: 1. This calculates _radaralt + 500 for each shell again. _radaralt = _radarpos select 2; _rondas = _radarpos nearObjects ["ShellBase",_rango] select {(getPosASL _x) select 2 > _radaralt + 500 && {((getNumber(configFile >> "CfgAmmo" >> (typeOf _x) >> "artilleryLock")) == 1)}}; better is to do things once if possible: _radaralt = 500 + _radarpos select 2; _rondas = _radarpos nearObjects ["ShellBase",_rango] select {(getPosASL _x) select 2 > _radaralt && {((getNumber(configFile >> "CfgAmmo" >> (typeOf _x) >> "artilleryLock")) == 1)}};  2. Also you are mixing position formats which produces wrong results. Your are getting radar pos with height (z) above sea level with _radarpos = getPosASL _radar; but nearObjects needs a position with height above terrain level. This means if terrain height is 300 meters above sea level then nearObjects is looking for shells 300 meters higher as you intend. You always have to care about the position format a command needs... Correct calculation should be this: _radar = _this select 0; _rango = _this select 1; _radarpos = position _radar; _radaralt = 500 + _radarpos select 2; //return value needs not necessarily a variable name, a line which returns a value is all you need here _radarpos nearObjects ["ShellBase",_rango] select {(position _x) select 2 > _radaralt && {((getNumber(configFile >> "CfgAmmo" >> (typeOf _x) >> "artilleryLock")) == 1)}}  Radar_CalculoFinal.sqf: 1. This is nonsense _pos = ASLtoATL getPosASL _ronda; better get ATL pos directly _pos = position _ronda;  2. findIf is faster, allPlayers already has all players in, no need to crawl playableUnits params["_ronda", "_bando"]; _pos = position _ronda; _radioHit = getNumber(configFile >> "CfgAmmo" >> typeOf _ronda >> "indirectHit") * 3; //do it once only _radioHitLimit = _radioHit + 100; _poss= [_ronda] call Radar_CalcImpact; //findIf and lazy evaluation should be fastest way I guess if( (allPlayers - entities "HeadlessClient_F") findIf {alive _x && {side _x == _bando && {_x distance2D _poss < _radioHitLimit}}} > -1) exitWith {[_poss, _radioHit] call Radar_MrkCaida}; //exit script and return marker //no player near, just return empty marker ""  EDIT: forgot a function call (Radar_CalcImpact) 1 1 Share this post Link to post Share on other sites
ofp_f3d3 Â Â 28 Posted March 21, 2019 0.2 Released!! Some optimization and Improvements for PVP environments Share this post Link to post Share on other sites
ofp_f3d3   28 Posted March 25, 2019 0.3 Released. Now that it works and has been tested extensively in Dedicated server environment, development will focus on making it more accesible to players giving them better warning signs other than markers. Although it was tested in a 16 people dedicated server with great results and players really happy because now they can actually fight against artillery strikes and not instantly die without warning.😂 2 Share this post Link to post Share on other sites
sarogahtyp   1108 Posted March 27, 2019 improvement suggestion:  you could calculate ETA by summing up _time_step and then make a countdown for impact. Share this post Link to post Share on other sites
RL - AVE   21 Posted May 29, 2019 I'm looking forward to try out your script, this will balance the use of A3 artillery and contribute greatly when predict launch position is implemented! Player Counter-battery fire FTW! 1 Share this post Link to post Share on other sites