Home   Help Search Login Register  

Author Topic: Nearest object detect tank/APC  (Read 509 times)

0 Members and 1 Guest are viewing this topic.

Offline granQ

  • Contributing Member
  • **
    • Anrop.se
Nearest object detect tank/APC
« on: 05 Jul 2004, 09:38:44 »
With the counttype i can get all apc/tanks from a array, and with typeof i get the specfic classname, right?

What i want to create is a very simple thing (if just the commands was there).

First detect when the missile is fired, and then make nearest object on a loop around that to try detect any tank/apc and finaly make a "topdown" attack on it.

maybe should check how missile car project made their missile..
Cura Posterior

Offline MI_Fred

  • Members
  • *
  • AA
    • OFP Team Finlanders
Re:Nearest object detect tank/APC
« Reply #1 on: 05 Jul 2004, 11:23:40 »
I so shouldn't be answering this with these kind of guesses but I'm bored and I'm at work  ;D

I don't know how your gona get an array of all vehicles with countType, that only returns the count of them. Nor do I know how to do this for an addon, as I'm guessing that's what you want? I added something in the end of this post that might be helpful, but you need to get the list in another manner than a trigger obviously...

Here's the way you can optain closeby targets
Code: [Select]
_veharray = ?
_missile = _this select 4
_tempGL = "Logic" camCreate getPos _missile
#loop
_v = 0
@ (_missile distance _tempGL > 25) || (isNull _missile)
? (isNull _missile) : exit
_tempGL setPos getPos _missile
while "_v < (count _veharray)" do {if(format ["%1",isNull (nearestObject [_missile,_veharray select _v])] == "false") then {consequences;};_v = _v + 1;};
goto "loop"

What that does is create a Logic object, move it to the _missiles position, wait till it's 25m (half of the span of nearestobject I think) from the missile (or vice versa  ;D), see that it has not seized to exist (that isNull condition or the one in the while do sentence), then go through the vehicle array and seek for any existing vehicles. And obviously I don't know how to do the javelin type of approach. K time to stop making an arse out of myself.
I can verify the correct syntax at home if need be. Oh and you know that MAP has this javelin?

Code: [Select]
//find tanks/apcs
_veharray = [];
_ve = 0;
while "_ve < (count list alllist)" do
{
    _temparray = [];
    if(vehicle(list alllist select _ve) != (list alllist select _ve) then
    {
         _temparray = _temparray + [(list alllist select _ve)];
         if (("tank" countType _temparray > 0)||("apc" countType _temparray > 0)) then
        {
            _veharray = _veharray + [(_temparray select _ve)];};
        };
    };
_ve = _ve + 1;
};
There's gooks over there, there's mines over there, and watch out those goddamn monkeys talk, I'll bite ya.