Jump to content
Sign in to follow this  
ashram 1-1

nearObjects for pipebomb near AI always returns null object? +++

Recommended Posts

hi, anyone else had problems using nearObjects to get object reference of a satchel charge placed by AI unit?

this was driving me barmy yesterday, today i thought to try with player instead and it works fine with this code in radio trigger:

bomb = ((getpos player) nearObjects ["PipeBomb",50]) select 0;hint format ["nearest bomb is: %1",bomb];

when using this code in a script to make AI destroy an object, always returns null object:

            hint "setting charge";
           _chargeman Fire ["pipebombmuzzle","pipebombmuzzle","pipebomb"];
           _bomb = ((getpos _chargeman) nearObjects ["PipeBomb",50]) select 0;
           hint format ["nearest bomb is: %1",_bomb];

He definitely places a bomb as he barely escapes with his life after deciding to crawl away for the first part instead of run, even with a doMove in careless mode :rolleyes: (i suppose that could be due to target being a RU T-72, although with no fuel or ammo)

On that subject, tried removing the crew with this in vehicle init - seems not to work?

{deleteVehicle _x}forEach crew this;

Doing it this way because I could not get AI AT to reliably attack an empty unit placed in editor, even with the 'switch sides trick' using dummy groups, so I just create a real enemy, set fuel/ammo to zero and tried removing the crew.

Crux is that i am trying to 'teleport' the satchel a bit closer to the target than the minimum of 7m away where that AI will move to and place it. I have tried every move command available, perhaps it is just the case that next to an enemy tank is considered not a friendly place to be.

everything else in my 'project' i have been able to solve by trying different approaches and the sweat of my brow, but i cannot for the life of me get AI to blow up a damn tank. :D

AT man with max skill fires two SMAW rounds at fairly close range on a stationary tank and fails miserably to destroy it, so I really need a backup, please

Share this post


Link to post
Share on other sites

thanks for reply, yes i tried a few combinations of that but perhaps not the right one, i'm away for a few days now so will come back to this thread on my return, perhaps i will think of something on the break.

cheers, Sam

Share this post


Link to post
Share on other sites

unitName addeventhandler ["fired",{
	_unit = _this select 0;
	_ammo = _this select 4;
	if (_ammo == "PipeBomb") then {
		_bomb = nearestobject [_unit,"PipeBomb"];
		_bomb spawn {
			_bomb = _this;
                               if (_bomb distance tank > 7) then {

                                            // do something
                               };
		};
	};
}];

However as twirly suggested, this code may become redundant by using disableAI "FSM".

Share this post


Link to post
Share on other sites

Not sure if this is going to help. Probably add it to the event handler given by 2nd Ranger

Try the attachto command - tried the below and it works.

I tested your code - using OA. Returns PipeBomb when specifying class - and Satchel.p3d when listing nearest objects.


private ["_class"];

_list = nearestObjects [dave, ["Car", "Truck", "Tank"], 20];
_num =  _list select 0;
_name = str(_num);

_class = typeOf _num;

//dave Fire ["pipebombmuzzle", "pipebombmuzzle", "pipebomb"];

sleep 3;

_list1 = ((getpos dave) nearObjects ["PipeBomb",50]) select 0;  
_class1 = typeOf _list1;
hint format["%1",_class1]; 


_list1 attachTo [_num,[0,0,0]];

Share this post


Link to post
Share on other sites

thanks all for the help, i'll try this out soon. unfortunately my motherboard is dead and i'm back on the old PC while i do a return, i might actually get my coursework done with no Arma on this machine. :-)

cheers, Sam

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
Sign in to follow this  

×