Jump to content

Photo
- - - - -

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


  • Please log in to reply
5 replies to this topic
Thread Starter
Ashram 1-1
Ashram 1-1

    Lance Corporal

  • Members
  • 42 posts

#1

Posted 02 May 2012 - 14:54

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
Soldiers must be cautious when throwing grenades up stairs. This is not the most desired method of employment.
FM 3-06.11

twirly
twirly

    Master Gunnery Sergeant

  • Members
  • 1302 posts

#2

Posted 02 May 2012 - 22:59

Have you tried using disableAI?

"Learn by doing!" - Quoted from a post by Imutep

OUTERRA - OUTERRA - OUTERRA - OUTERRA - BLOWMIND!

Thread Starter
Ashram 1-1
Ashram 1-1

    Lance Corporal

  • Members
  • 42 posts

#3

Posted 03 May 2012 - 05:15

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
Soldiers must be cautious when throwing grenades up stairs. This is not the most desired method of employment.
FM 3-06.11

2nd Ranger
2nd Ranger

    Sergeant Major

  • Members
  • 1509 posts

#4

Posted 03 May 2012 - 09:03

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".

empty all your clips at their locations

Vote!
http://feedback.arma...ew.php?id=24134 - Hunter MRAPs sometimes won't move to waypoints
http://feedback.arma...iew.php?id=9341 - Random placement of units and waypoints does not work near buildings
http://feedback.arma...ew.php?id=17665 - Backpacks can't be placed accurately in editor


mikie boy
mikie boy

    Master Sergeant

  • Members
  • 660 posts

#5

Posted 03 May 2012 - 11:21

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]];

[FOCK] Mikie J -
Giving bad advice since 2009 :)

Looking for New Players/scripters at Fockersteam
http://fockers.moonfruit.com/
Email: fockersteam@hotmail.co.uk

A3
3 Chapters of Scripting Tutotials -http://www.armaholic...=20465#comments MORE TO FOLLOW
TvTCache Hunt - [FOCK]ers Cache Hunt TvT-x [ALPHA]
Fock Recruit/Group Management - http://www.armaholic...ge.php?id=19041

Currently NOT ACTIVE- Awaiting completion of MSc Computer Science - will return soon....

Thread Starter
Ashram 1-1
Ashram 1-1

    Lance Corporal

  • Members
  • 42 posts

#6

Posted 10 May 2012 - 17:20

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
Soldiers must be cautious when throwing grenades up stairs. This is not the most desired method of employment.
FM 3-06.11