Jump to content
ofp_f3d3

Problems trying to replace nearobjects with nearentities

Recommended Posts

Hi fellow editors, its my first post here even though i´ve been lurking the forums for a while.

 

The topic of the post is this. Im trying to create a functional artillery radar that can intercept airborne rounds, calculate and predict its target in order to give time to the players, so they can react accordingly.

 

the issue began when i started testing the script in altis ( i wrote it and tested it in VR for faster loading times and blablabla). I need to use a big radius in order to have enough time to allow the players to react. As the script is a mess right now, ill post the code that i need to modify but even after 4 hours of trial and error didnt succeed.

 

_radar = _this select 0; // nombre del objeto que sera radar (DEBE ESTAR INMOVIL )
_rango = _this select 1; // radio de deteccion del radar ( IRL FUNCIONAN HASTA 50KM )
_alarma = _this select 2; // si se desea que reproduzca un sonido de sirena
_intervalo = _this select 3; // intervalo de actualizacion de estado ( CADA CUANTO HACE UNA REVISASION, NO MENOR A 5 )

_radarpos = position _radar;

_rondas=[];
_rondasC=0;
_sonando = false;
while {alive _radar} do 
	{
	_rondas = _radarpos nearObjects [["ShellBase"], _rango]
	_rondas = _rondas + (_radarpos nearObjects [["RocketBase"], _rango]);
	_rondas = _rondas + (_radarpos nearObjects [["MissileBase"], _rango]);*/
	//hint str _rondas;
	_rondastotal = count _rondas;
	if (_rondastotal > 0) then
		{
		if (_alarma && !_sonando) then {_radar say3d "sirena"; _sonando = true;};
		while{_rondastotal > _rondasC} do
			{
			[position (_rondas select 0), velocity (_rondas select 0), getDir (_rondas select 0), _rondas select 0] call Radar_CalculoFinal;
			_rondasC = _rondasC + 1;
			//hint str _rondastotal;
			};
		}
		else
		{_sonando = false;};
	if (_rondastotal < _rondasC) then {_rondasC = _rondasC - 1;};
	//hint format ["RT: %1 --- R: %2 --- RC: %3", _rondastotal, count _rondas, _rondasC];
	sleep _intervalo;
	};

I read that nearentities is a lot faster than nearobjects so i´ll try to get more performance with this, but i cant make it work.

 

The calculations made by the script barely miss so im happy with that, but if want this to be usable in regular mapsi need to change the methos used to acquire the rounds.

Any help is appreciated.

Share this post


Link to post
Share on other sites

Unfortunately, nearEntities doesn't detect rockets, shells, or missiles.

 

There are other ways to increase performance in your scripts.

If you haven't already, have a read through Code Optimisation.

 

 

Line 13 - 15 jumped out at me.
Your nearObjects typeName is an array.

I wasn't sure if this was correct or nor, so I run a test in the Debug Console and I couldn't detect any incoming artillery.
I have amended it for reference.

_rondas = _radarpos nearObjects ["ShellBase", _rango]; //	Removed square brackets and added semicolon.

_rondas = _rondas + (_radarpos nearObjects ["RocketBase", _rango]);	//	Removed square brackets.

_rondas = _rondas + (_radarpos nearObjects ["MissileBase", _rango]);	//	Removed square brackets and end of block comment error.

 

I wish I could help more but it is late here.

 

Buena suerte.

 

 

Share this post


Link to post
Share on other sites

Best way would be to add a fired eventhandler to all arty guns on the map, ammo check inside to exclude commander hmg/gmg turrets and put all valid arty shell into a global array.

Then filter the array and display only those projectiles via markers/draws on the map that meet certain criteria (above 1km altitude / vertical velocity < 0 / etc.) and remove null elements every n seconds.

 

Cheers

  • Like 2

Share this post


Link to post
Share on other sites

@Maff

 

Yeah my bad, i copied and pasted that code and forgot to correct it to the proper way that nearobjects works. With nearobjects it works fine, but i cant define a radius big enough to give players time to move out.

 

 

@Grumpy Old Man

 

That was the first idea that popped into my head, but i really wanted to keep it as real as possible, trying to avoid registering every mortar and checking who fired. Im still trying to figure out other ways to accomplish this but no jackpot yet.

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×