Home   Help Search Login Register  

Author Topic: Boomerang  (Read 7460 times)

0 Members and 1 Guest are viewing this topic.

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Boomerang
« on: 22 Jun 2008, 02:03:28 »
Shoutout to all those scriptors that think they can help me with this;

There is a device called the Boomerang mounted acoustic detection system.
(see here http://www.gizmag.com/go/4497/)

Thinking about scripting to when a bullet travels within "x" yards of the unit, it gives the relantice (maybe o'clock) bearing, distance on the xy plane (some trig, i.e. a2 + b2 = c2) and vertical displacement (getposasl1 select 2 - getposasl2 select 2).

Wondering, was there any way to do that? (maybe get the bullet type, use side direction and find the unit of the side it came from, maybe match the ammo to the weapon?)

Anyway sounds like an .sqf and I'm so helpless with those, I could drown in my own ignorance.

Much appreciated for ideas, helps, examples, provided scripts, etc.

Thanx to the OFPEC community as always.

Luke
Pesky Human!!
Wort Wort Wort.

Offline Rommel92

  • Members
  • *
Re: Boomerang
« Reply #1 on: 22 Jun 2008, 03:22:03 »
Done this before, however it is unrealiable due to the fact I currently do not know how to find how long the bullet has lived, which means even if you trace it back to its source, if he was standing up or moving etc, or even gravity will alter these results insanely and it simply will just miss him.

Better off having Fired eventHandlers everywhere then attempting this personally.  :P

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Boomerang
« Reply #2 on: 22 Jun 2008, 05:24:45 »
Rommel

Thought about that, and that seemed messy, plus arent EH non-MP compatable?

The bullet usually strikes w/in a second, couldnt there be a relative tolerance, i.e. look for guy on this side (maybe with this weapon), at angle + .6o?

Luke
Pesky Human!!
Wort Wort Wort.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Boomerang
« Reply #3 on: 22 Jun 2008, 08:54:49 »
First, ArmA Event Handers work in MP.

Once a sniper's bullet is detected, Boomerang's display panel, which is located inside the vehicle, alerts soldiers through audio and visual signals that a bullet has been fired, its direction and elevation.

You can attach a "FIRED" event hander to all the soldiers or only these of sniper type. When they fire you get the direction and elevation of their primary weapon. Now you:
- Check the distance between firing unit and an array of existing Boomerang vehicles.
- If distance is < 1000 (for example), you check the direction of the weapon relative to the direction between firing unit and Boomerang vehicle.
- If the difference between these direction is less than 10 degrees and the elevation of the weapon is < 10 and > -10 degrees, for example, you may assume that the bullet has been effectively shot against the area where the boomerang device is, and now you need to publish some vars so that the boomerang device displays a bearing (not a range, only the general direction of the shot).


Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Boomerang
« Reply #4 on: 24 Jun 2008, 03:24:51 »

Once a sniper's bullet is detected, Boomerang's display panel, which is located inside the vehicle, alerts soldiers through audio and visual signals that a bullet has been fired, its direction and elevation.


Mandoble,

It may or may not have been mentioned, but it also does give range to the nearest  ~10m.
Don't know if you get Discovery ChannelTM of Future Weapons, but this was featured in Future Weapons episode No.17, "Immediate Action," Season 2 episonde No.11, Origionally aired March 26, 2007.

However, as mentioned before all those EHs seem too messy.

Is there any other way?

Please respond, not that your imput hasn't been appreciated already.

Thanx for the feedback, as always.

Luke
Pesky Human!!
Wort Wort Wort.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Boomerang
« Reply #5 on: 24 Jun 2008, 11:44:45 »
You may also try to detect "BulletBase" objects near the Boomerang vehicle, but you will need to do that check in a tight loop so you dont miss many bullets.

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Boomerang
« Reply #6 on: 26 Jun 2008, 06:03:10 »
Mando,

How would I do that? I'm brain dead when it comes to .sqf's.

Would the code be like:

Code: [Select]
_boomerang=_this select 0
_boomerange=_this select 1

#loop
_bullet=nearestObjects [_boomerang, ["BulletBase"], _boomerange]
_bulpos=getpos _bullet
Side _bullet== Side _boomerang: goto "loop"
?! _bullet isNull:goto "found";
~.0001;
goto "loop";
getdir _bullet=_buldir;
If {_buldir < 180} then {_dir=180+_buldir} else {_dir=_buldir-180};
_shooterlist=getpos _boomerang nearObjects 10000;
_x=0;
#search
_shooter=_shooterlist select _x;
_shootdir=getdir _shooter;
? (_shootdir<(_buldir + 4))&&(_shootdir>(_buldir - 4)):goto "poscheck";
_x=_x+1;
goto "search";
#poscheck;
getpos _shooter= _shotpos;
_difpos=_shotpos - _bulpos;
_difpos2=_shotpos - _boompos;
_shotang=arctan (_difpos select 1)/(_difpos select 0);
_dist=sqrt((_difpos select 0 * _difpos select 0) + (_difpos select 1 * _difpos select 1));
_dist2=sqrt((_difpos2 select 0 * _difpos2 select 0) + (_difpos2 select 1 * _difpos2 select 1));
? (((_bulpos select 0) + (_dist * _shotang)) < (_shotpos select 0 + 3))&&(((_bulpos select 0) + (_dist * _shotang)) > (_shotpos select 0 - 3)):goto "solve";
_x=_x+1;
goto "search";
#solve
_boompos=getpos _boomerang
_boomdir=getdir _boomerang;
_reldir=_boomdir-_buldir;
_elev=_difpos2 select 2
If {_reldir>=360} the {_reldir=_reldir-360};
If {_reldir<0} the {_reldir=_reldir+360};
hint "Direction: _buldir \nRelative Direction: _reldir \nRange: _dist2 \n Elevation: _elev"
exit

If not could one, or two, or more of you guys please look it over?

If it is like this, then could one of you guys .sqf-itize it for me?

Any help response at all would be helpful.

Thanx for any help/replies, as always.

Luke

« Last Edit: 08 Oct 2008, 23:19:28 by bedges »
Pesky Human!!
Wort Wort Wort.

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Boomerang
« Reply #7 on: 15 Jul 2008, 06:40:22 »
Would putting this in .sqf make it any faster and more capable at catching bullets?

Thanx for the replies, as always.

Luke
Pesky Human!!
Wort Wort Wort.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Boomerang
« Reply #8 on: 15 Jul 2008, 10:47:17 »
.sqf does run faster than .sqs in most cases. However, I suspect that most of the time in your script is used in the nearestObjects/nearObjects commands which you can't make any faster ;P Learning SQF is always a good idea though and could make scripting a lot easier in the long term.

In SQF, however, you can use waitUntil to make a loop that runs exactly once per frame. Sleep (SQF) and ~ (SQS) only ask the interpreter to wait for at least the amount of time and you can't absolutely guarantee that it works every frame in a loop where you wait for an approximate amount of time. That could possibly be why you are missing bullets. The other issue is the frame-rate on the PC, since if you have 60FPS then you will pick up considerably more bullets than at 10FPS! In the latter case, some bullets will have been fired and hit the target before you get to detect them!

If you are not having a lot of luck, then consider putting "FIRED" event handlers on the potential shooters and then track the locations of the bullets that appear. Although this will not be fast, it will pick up all bullets as they are fired and might even be considerably faster than running nearestObjects/nearObjects on a large area.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Trexian

  • Members
  • *
Re: Boomerang
« Reply #9 on: 15 Jul 2008, 19:29:05 »
Is there some way to maybe set up an extended event handler to determine when an AI is targeting and use that to basically "warn" the script that a firing might happen?

May be more complicated than useful. :D
Sic semper tyrannosauro.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Boomerang
« Reply #10 on: 15 Jul 2008, 19:58:36 »
You don't need any eventhandler to check whether a unit is targeting someone, assignedTarget will do.
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 #11 on: 17 Jul 2008, 01:58:49 »
Hey everybody,

NEW CODE ALERT!!

Here's my blood, sweat, tears, drool, & elbow-grease under the filter of an .sqf

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
_bullet=nearestObjects [_boomerang, ["BulletBase"], _boomerange];
waitUntil ! _bullet isNull;
_bpos=getpos _bullet;
? Side _bullet== Side _boomerang: exit;
_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 {((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;

;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} then {_reldir=_reldir-360};
while {_reldir<0} then {_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 "Direction: _nudir \nRelative Direction: _reldir \nRange: _dist2 \n Elevation: _elev";
sleep 5;
exit


Could someone spot check it for errors.

P.S.
Three things:
1. I never use .sqf so i don't know how to call it, (I'm SO ashamed!!  :-[ )
2. I don't know how to get it  to loop and keep looking for bullets.
3. I do not recall what the command is, but it is something equivalent to a "set knowsabout" sort of thing,
want to add this like group _boomerang "command" _shooter 4.

Any response at all would be helpful.

Thanx for any help/replies, as always.

Luke

EDIT: Fixed a typo

EDIT2: "arctan" changed to "atan2"
« Last Edit: 17 Jul 2008, 18:29:20 by Luke »
Pesky Human!!
Wort Wort Wort.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Boomerang
« Reply #12 on: 17 Jul 2008, 09:36:25 »
1. For this script, you are best using execVM (same syntax as exec, as you would use in SQS).

2.
Code: [Select]
;The inits
_boomerang=_this select 0;
_boomerange=_this select 1;

// Might want "alive (driver _boomerang)" or something instead, depending on how you want it to work.
while { alive _boomerang } do
{
    // Do everything inside here
};

3. You can't give people specific values of knowsAbout. Using the command reveal just gives someone knowsAbout value of 1.
Code: [Select]
(group (driver _boomerang)) reveal _shooter;

General:
4. exit doesn't do anything in SQF. The script will just end at the end without you needing a command. If you need to finish an SQF script early, you can:
Code: [Select]
if (true) exitWith {};

5. Always use atan2 rather than atan, since it handles more cases properly (doesn't give you divide by zero errors, for example).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Barbolani

  • Members
  • *
Re: Boomerang
« Reply #13 on: 17 Jul 2008, 17:31:40 »
Hello,

Dont want to piss you, but IMHO In the reality, this device is completely useless...

1. Real snipers tend to move (and hide) after their shot

2. All the most exact data that this device can provide cannot give you an aprox. about the sniper's position... does the device know the windspeed and direction in the exact moment of the shot?? the altitude of the sinper??? If the shot is fired standed up or crouched, the difference is great, a bullet falls to the floor at the same velocity if you drop one or if you shoot it, so the difference is hundereds of meters.... K, can give you an aprox, but useless for an infantry counterattack...

3. ...and nobody calls arty to kill a sniper....

I repeat, dont want to dissapoint nobody and I donno if this is the good place to write this... If someone gets angry, Ill invite him to have a drink talking about modern waponary...

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Boomerang
« Reply #14 on: 17 Jul 2008, 18:17:04 »
 >:(

Barbolani!!!!!!!!

Nah, I'm fine.  :D

Reponse to each of the respective quotes in  order:

First, it is not completely useless, it's not even mostly useless (shoutout), knowing the relative direction can give you an idea of which cover is useful:
(if you just hear the shot and hide behind a building, only to take a shot in the leg from the same guy, and try to crawl to the otherside, you're a sitting duck.  :no: )

1. The time it takes for him to get up and move is enough for you to react, and if he's moving while standing up, you'll likely see him and which way he's going.

2. Did you look at the link?  The shockwave from the bullet's occluded sound front traveling by is picked up in a particular order by the microphones that a computer sorts out to get the direction, then it times between that sound front and the actual crack of the rifle, tables them out to get a distance, uses the same series of mics to get the sounds direction and basically draws a virtual line from the bullet to the target.  As for windspeed, etc. IDK but this is ARMA so we don't have to worry about that changing bullet trajectory.

Infantry counterattack, with this you now know where the sniper is, and I planned on having a koulesvleto thingamabob light up the shooter and use the command reveal (thanx Spooner  :good: ) to 'show' the AI where the sniper is.

3. Maybe not arty, but a Mando Airstrike (plug)  could help. (plus, that won't matter if your a good shot.)

Look at my profile, I'm 17, no drinks for me (unless you got rootbeer :D ).

Lastly,

Modern? When I see this on the Discovery Channel on a show titled "FutureWeapons" (under the episode "Immediate Action") my thought is that this would be a pretty modern piece of equipment.

Anyway, I don't want my response to make YOU mad so...

I apologise if this defense seemed harsh, I just attempt to the best of my ability to defend my projects, especially since this is my first 'serious' project.

However, your criticism is duely noted, and for all I know this could flop.

At any rate,

Thanx for the replies, as always.

Luke

EDIT: @ Spooner,
You seem knowledgeble,  :D
whether I use cut text or hint, it always shows:
"Direction: _nudir
Relative Direction: _reldir
Range: _dist2
Elevation: _elev"

(i.e. it displays the names and not the values).
Can you help?

Thanx for the replies, as always
« Last Edit: 18 Jul 2008, 20:30:34 by bedges »
Pesky Human!!
Wort Wort Wort.

Offline Barbolani

  • Members
  • *
Re: Boomerang
« Reply #15 on: 17 Jul 2008, 19:26:54 »
I apologyse. I didn't seen the link.

True. In fact, the distance is perfectly predictable with maths, playing with doppler effect...

The angle (except about the wind speed / direction) can be detected.

BUT (of course, theres a but) I think a sniper will have enough time to move and hide... but (also) maybe not to make another shot...

Useful, useful xD

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Boomerang
« Reply #16 on: 17 Jul 2008, 20:46:28 »
But why do this so insanely complex when you can get the position of the sniper with 'fired' event and one line of code..  :dunno:
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Boomerang
« Reply #17 on: 17 Jul 2008, 22:23:54 »
Yeah, you need to use the format command to get variable's into a string for outputting.

I'm with h- about the fired handler though. Would make life 100x easier.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Boomerang
« Reply #18 on: 17 Jul 2008, 23:09:47 »
Alright guys,
I'll bite.

What's this single line of code?
The only way I see that done is going through each unit's init and adding an EH.
That sure doesn't seem 10000% easier to me.

@ Spooner; How would I put them in a string?
I tried hint"format ["blab 1%, blab 2%", item1, item2]
but all i got was the hint "format [".

Thanx for the replies, as always.

Luke
« Last Edit: 08 Oct 2008, 23:20:26 by bedges »
Pesky Human!!
Wort Wort Wort.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Boomerang
« Reply #19 on: 17 Jul 2008, 23:15:01 »
Might be using the correct syntax, as it is quite obvious your command has an extra "
Code: [Select]
hint format ["blab 1%, blab 2%", item1, item2]

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Boomerang
« Reply #20 on: 17 Jul 2008, 23:21:30 »
Sorry,

I meant hint"format ["blab 1%, blab 2%", item1, item2]"

Then how do you define where the hint ends?

Thanx for the replies, as always.

Luke

Pesky Human!!
Wort Wort Wort.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Boomerang
« Reply #21 on: 17 Jul 2008, 23:28:46 »
~Now your line has 2 extra ".

You don't need to enclose the format line in quotes.


Planck
I know a little about a lot, and a lot about a little.

Offline Luke

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

Doesn't that define what's in the hint?

Thanx for the replies, as always.

Luke
Pesky Human!!
Wort Wort Wort.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Boomerang
« Reply #23 on: 17 Jul 2008, 23:32:07 »
Then how do you define where the hint ends?

 :blink: :blink: :blink:
hint (<- ENDS HERE)
hint -> (HAS A STRING HERE)
And what returns format command is a string.
hint "2"
or
hint format ["%1", 2]
format ["%1", 2] is equal to "2" which is a text string.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Boomerang
« Reply #24 on: 17 Jul 2008, 23:32:42 »
In this case your hint is "blah %1, blah %2"

Which are already enclosed.

Planck
« Last Edit: 17 Jul 2008, 23:38:10 by Planck »
I know a little about a lot, and a lot about a little.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Boomerang
« Reply #25 on: 17 Jul 2008, 23:35:24 »

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Boomerang
« Reply #26 on: 17 Jul 2008, 23:36:55 »
Guys,

So I would want
Code: [Select]
hint Direction: _nudir \nRelative Direction: _reldir \nRange: _dist \nElevation: _elev;

or

Code: [Select]
hint format["Direction: %1,\nRelative Direction: %2, \nRange: %3, \nElevation: %3",_nudir,_reldir,_dist,_elev]

???
 :dunno:

Thanx for the replies, as always.

Luke
Pesky Human!!
Wort Wort Wort.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Boomerang
« Reply #27 on: 17 Jul 2008, 23:51:52 »
Try both and see what happens, while I would go with the second one ;)

Offline Luke

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

My biggest concern is the phrase:

Code: [Select]
_bullet=nearestObjects [_boomerang, ["BulletBase"], _boomerange];
waitUntil ! _bullet isNull;
_bpos=getpos _bullet;
? Side _bullet== Side _boomerang: exit;
_bdir = getdir _bullet;

and wheter it will catch anything.

Thanx for the replies, as always.

Luke

EDIT: I'm getting an error

'[ # ]sleep 5;'
Error generic error in expression.

and a scalar bool string blab blah 000000000xefjsdfksjkgf (not verbatum) message in each field...
except elevation: that's a random number.

???
:dunno:
« Last Edit: 18 Jul 2008, 00:17:51 by Luke »
Pesky Human!!
Wort Wort Wort.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Boomerang
« Reply #29 on: 18 Jul 2008, 00:15:46 »
Code: [Select]
waitUntil{_bulletS=nearestObjects [_boomerang, ["BulletBase"], _boomerange];count _bulletS > 0};
And now lets say _bulletS array has 300 bullets inside, what now?

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.

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Boomerang
« Reply #45 on: 23 Jul 2008, 18:55:42 »
So in the fired EH, would the script:

Code: [Select]
_unit=_this select 0 select 0;
_weapon=_this select 0 select 1;
_muzzle=_this select 0 select 2;
_mode=_this select 0 select 3;
_type=_this select 0 select 4;

hint format ["%1",_this select 0 select 4];
_ammo=format ["nearestObject [%1, %2]",_unit,_type];
?_unit in _unitlist;
_unitnum = count _unitlist
format ["_unit = _unit_%1",_unitnum]
_unitlist=[_unitlist]+[_unit];
_ammonum = count _ammolist
format ["_ammo = _ammo_%1",_ammonum]
_ammolist=[_ammo] + [_ammolist];
@_ammo = isnull;
_ammolist=[_ammolist]-[_ammo];
_unitlist=[_unitlist]-[_unit];
exit

Work?  ???

Luke

P.S.

Here's the boomerang script:

Code: [Select]
_Boomerang=_this select 0
_range = 10
#loop
?_boomerang distance _ammo < _range : goto "getguy"
goto "loop"
#getguy
_number= _ammolist find _ammo
_shooter = _unitlist select _number
_boomposx=getpos _boomerang select 0;
_boomposy=getpos _boomerang select 1;
_boomposz=getpos _boomerang select 2;
_spos= getpos _shooter;
_sposx= getpos _shooter select 0;
_sposy= getpos _shooter select 1;
_sposz= getpos _shooter select 2;
_boompos=getpos _boomerang;
_boomdir=getdir _boomerang;
_reldir = ((_boomposx)-(_sposX)) atan2 ((_boomposy)-(_sposY));
_elev=(_sposz) - (_boomposz);
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 format ["Bullet type: %1\nRelative Direction: %2\nRange: %3\n Elevation: %4",_ammo,_reldir,_dist,_elev];
exit

EDIT: * all code is .sqs *
« Last Edit: 23 Jul 2008, 19:34:55 by Luke »
Pesky Human!!
Wort Wort Wort.

Offline USM-CPT.Dyson

  • Members
  • *
Re: Boomerang
« Reply #46 on: 11 Sep 2008, 17:54:20 »
did it work, i want to implement it into a mission
CTI SectorLink
Version: Beta 7
http://hosted.filefront.com/Spyder001/

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Boomerang
« Reply #47 on: 12 Sep 2008, 05:48:19 »
Wish it had. :(

Be willing to give what I have to ya,
but you have to give if you get it to work.

By the way, the only thing that works is the nearestobject command,

so I have an attempt at a work-around, but cant get to it right now.

Post it tomorrow.

Luke

EDIT: Here it is!!
« Last Edit: 17 Sep 2008, 01:28:11 by Luke »
Pesky Human!!
Wort Wort Wort.

Offline USM-CPT.Dyson

  • Members
  • *
Re: Boomerang
« Reply #48 on: 02 Oct 2008, 03:10:39 »
Can anyone help luke get this working? This looks like a pretty awesome idea that I want to use (Saw it on Future Weapons). :)
« Last Edit: 03 Oct 2008, 18:40:52 by USM-CPT.Dyson »
CTI SectorLink
Version: Beta 7
http://hosted.filefront.com/Spyder001/