Home   Help Search Login Register  

Author Topic: Boomerang  (Read 7475 times)

0 Members and 1 Guest are viewing this topic.

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Boomerang
« Reply #30 on: 18 Jul 2008, 00:23:38 »
Mando,

What do you mean 300 bullets inside?

Thanx for the reply, as always.

Luke
Pesky Human!!
Wort Wort Wort.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Boomerang
« Reply #31 on: 18 Jul 2008, 00:26:19 »
Just butting in....

Quote
What's this single line of code?
_pos = position (_this select 0);

You can always use a trigger covering the whole area (activated by anyone for example) and add something like this into the triggers on act field
Code: [Select]
{if (typeOf _x == "SoldierWSniper") then {_x addEventHandler ["fired",{_this execVM "script.sqf"}]}} forEach thislistWith this example each West side sniper inside the trigger area will have the eventhandler without you having to touch individual units at all..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Boomerang
« Reply #32 on: 18 Jul 2008, 00:27:09 »
Please, check nearestObjects and see what kind of value does it return: An array of detected objects. Now several machinegunners decide to fire in your direction and you detect 300 bullets at a time.

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Boomerang
« Reply #33 on: 18 Jul 2008, 00:33:10 »
Mando,

It would (hopefully) pick out the first bullet and give info on that shooter.

Thanx for the reply as always.

Luke

P.S. you gave me an idea!

EDIT: more errors
this time:
Code: [Select]
{if (side _x in [side player, civilian]) then {_slist =_slist - [_x]}}foreach _slist;
{if ((getdir _x > _bdir +.3)or(getdir _x < _bdir -.3)) then {_slist = _slist - [_x]}}foreach _slist;
{if (((atan2 ((getpos _x select 0) / (_getpos _x select1))) > (atan2 ((bpos select 0) / (bpos select 1)) +.5)) or ((atan2 ((getpos _x select 0) / (_getpos _x select1))) < (atan2 ((bpos select 0) / (bpos select 1)) -.5))) then {_slist = _slist - [_x]}}[ #]forEach _slist;
foreach: Error type String, expected code.
 :dunno:
« Last Edit: 18 Jul 2008, 00:51:50 by Luke »
Pesky Human!!
Wort Wort Wort.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Boomerang
« Reply #34 on: 18 Jul 2008, 00:52:44 »
The first, or the last, or all of them, or none. Fired EH is a far far better aproach.

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Boomerang
« Reply #35 on: 18 Jul 2008, 00:54:31 »
Mando,

I don't follow.

Thanx for the replies, as always.

Luke

EDIT:

Here's the newest update.

Code: [Select]
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
//;Boomerang shot-finding script v0.8
//;By: Luke, created 7/16/08
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
The inits;*/
_boomerang=_this select 0;
_boomerange=_this select 1;
//;start
;While (alive (_boomerang)) do {
_objs= _boompos nearObjects _boomrange
};
if ("BulletBase" in _objs) then {_c = 1};
waitUntil {_c==1};
_bullet = [_boomerang, ["BulletBase"], _boomerange];
hint format ["%1",_bullet];
_bpos=getpos _bullet;
if (Side _bullet== Side _boomerang) exitwith {};
_bdir = getdir _bullet;
//getlist;
_slist=getpos _boomerang nearObjects 10000;
{if (side _x in [side player, civilian]) then {_slist =_slist - [_x]}}foreach _slist;
{if ((getdir _x > _bdir +.3)or(getdir _x < _bdir -.3)) then {_slist = _slist - [_x]}}foreach _slist;
{if ((((getpos _x select 0) atan2 (getpos _x select 1)) > (((bpos select 0) atan2 (bpos select 1)) +.5) or (((getpos _x select 0) atan2 (getpos _x select 1)) < (((bpos select 0) atan2 (bpos select 1)) -.5)))) then {_slist = _slist - [_x]}}forEach _slist;

//shooter found;

_shooter= _slist select 0;

//;data

_spos= getpos _shooter;
_boompos=getpos _boomerang;
_boomdir=getdir _boomerang;
If (_bdir >= 180) then {_nudir = _bdir - 180} else {_nudir = _bdir +180};
_reldir=_boomdir-_nudir;
_elev=(_spos select 2) - (_boompos select 2);
While (_reldir>=360) do {_reldir=_reldir-360};
While (_reldir < 0) do {_reldir=_reldir+360};
_dist= sqrt(((_spos select 0) - (_boompos select 0))^2 + (((_spos select 1) - (_boompos select 1))^2));

//;hint to directon, range, etc.;

hint format ["Direction: %1\nRelative Direction: %2\nRange: %3\n Elevation: %4",_nudir,_reldir,_dist,_elev];

if (alive _boomerang) then {[_boomerang,_boomerange] execvm "boomer.sqf"};

Won't work & I don't know why.
« Last Edit: 18 Jul 2008, 01:58:22 by Luke »
Pesky Human!!
Wort Wort Wort.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Boomerang
« Reply #36 on: 18 Jul 2008, 10:02:31 »
- While/do uses curly brackets, so it should be while {condition} do {stuff}:
Code: [Select]
While {alive (_boomerang)} do
         {_objs= _boompos nearObjects _boomrange};
You have a ; in front of the while/do which will cause an error and the script not to run properly.
But even if you remove that the script won't work because there is no exit for the while/do loop, with condition alive _boomerang the while/do will loop as long as the vehicle is alive and only after it is dead the script moves on.
You need to exit the loop when the first bullet is found.

Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Boomerang
« Reply #37 on: 18 Jul 2008, 19:32:48 »
Thanx h-,

but can you tell stupid little me how to do that?

Thanx for the reply, as always.

Luke
Pesky Human!!
Wort Wort Wort.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Boomerang
« Reply #38 on: 18 Jul 2008, 20:13:00 »
For example
Code: [Select]
_objs = [];
While {alive (_boomerang) && (count _objs)==0} do
         {_objs= _boompos nearObjects _boomrange};
Or something like that..
« Last Edit: 18 Jul 2008, 20:14:51 by h- »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Boomerang
« Reply #39 on: 18 Jul 2008, 20:25:03 »
h-,

Tried it,

Nuthin' doin'.   >:(

Could somebody check the syntax as I am incapable of doing so myself.

Thanx for the replies, as always.

Luke

P.S. Try what I posted, modify it, whatever, just let me know if you get it to work!!!  :weeping:
Pesky Human!!
Wort Wort Wort.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Boomerang
« Reply #40 on: 18 Jul 2008, 22:53:29 »
Looking through your script there a lot of illogical things..

This part in you script makes no sense at all:
Code: [Select]
if ("BulletBase" in _objs) then {_c = 1};
waitUntil {_c==1};
This makes the code waitUntil forever if "BulletBase" is not in the object array..

You first search the bullet with the first while/do loop, but then you apparently try to search it later again with this line.
Code: [Select]
_bullet = [_boomerang, ["BulletBase"], _boomerange];Which by the way is wrong, it's missing the nearestObjects command.
You have already found the bullet so why try find it again?
Besides, nearestObjects command does not find bullets, it only finds vehicle class objects (basicly everything else than most foliage and bullets).

You have typos which will make things not function (_boomerange->_boomrange), missing variables (_boompos is not defined anywhere).


Anyway, I have tried several methods of finding bulletbase with all of the nearestObject commands and it's not possible; all the new ArmA nearestObject commands such as the above mentioned nearestObjects [] and nearObjects only detect vehicle class objects, not bullets.
Only the OFP era nearestObject can find bullets but it works only to 50m radius and didn't seem to work unless I use it from a fired eventhandler.

EDIT:
What I don't understand is what you're trying to achieve with this? How are you going to make the player know that the computer has found a sniper? How exactly does it find it if you search say 1000 meter area and there are several people engaged in a fire fight?
(well, these questions are moot since you can't detect bullets with the nearestObjects stuff)

If you are just trying to find snipers you can simulate the whole system by adding fired events to all enemy snipers (example given earlier) and when one those fires you can instantly get data such as snipers position ([x,y,z]) and weapon direction vector (at the moment of firing) so you can tell which sniper was aiming at who, and then point out that sniper, or something like that  :dunno:
« Last Edit: 18 Jul 2008, 23:10:02 by h- »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Boomerang
« Reply #41 on: 21 Jul 2008, 19:31:33 »
h-,

to your edit,
the script would first try and find all the people not in the player's or civ sides; then it would try and find someone who was facing the same direction as the bullet, (you have to in order to fire it that direction!) lastly on the basis that the bullet will fall on a line from the person to the shooter, I emply trig to get whether the bullet and the shooter have the same relative direction from the eyes of the boomerang.

to the community,

Looks like I might be using fired event handlers after all,

Luke

EDIT: I was wondering, if you can't use "nearestobject" to catch the bullet, how would you do it in a "fired" EH? Wouldn't it return just the type of ammo, not the projectile?
« Last Edit: 23 Jul 2008, 01:26:41 by Luke »
Pesky Human!!
Wort Wort Wort.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Boomerang
« Reply #42 on: 23 Jul 2008, 16:52:10 »
You can use fired eventhandler to catch the bullet with the old OFP era nearestObject command (_bullet = nearestObject [_this select 0,_this select 4]).
Be sure you put that straight into the fired eventhandler and not into the script launched by it, otherwise on lower FPS the bullet will escape the 'trap'.

I had no luck catching bullets with it from a loop though, but I'm guessing it's down to the fact that you have to have a sleep in the loop otherwise you will crash the game or if using waitUntil like Spooner suggested you will have a 8 FPS slideshow going on (I used sleep 0.001). It also has the 50 meter radius limit which makes it kinda useless even if it worked.
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Boomerang
« Reply #43 on: 23 Jul 2008, 18:34:27 »
You can use fired eventhandler to catch the bullet with the old OFP era nearestObject command

h-,

I'm confused (Me ==>  ??? ),

If it's an OFP era command, will it work in arma?

Luke
Pesky Human!!
Wort Wort Wort.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Boomerang
« Reply #44 on: 23 Jul 2008, 18:50:32 »
Yes, it will work in ArmA. I just meant it has been there since OFP..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.