Home   Help Search Login Register  

Author Topic: Where are you pointing at?  (Read 1584 times)

0 Members and 1 Guest are viewing this topic.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Where are you pointing at?
« on: 30 Dec 2005, 23:51:26 »
getDir or direction gives unit heading (vehicle or body), but not direction where the unit is looking at. For example, if you use binocs and look few degrees left or right, your direction does not change (your body does not change direction).

Is there any way to calculate the direction where a unit is looking at?

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:Where are you pointing at?
« Reply #1 on: 31 Dec 2005, 00:28:15 »
Unfortunately not.

OFP: Elite's scripting commands list includes one called 'weaponDirection', supposedly, but unfortunately there is no equivalent in Op Flash.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re:Where are you pointing at?
« Reply #2 on: 31 Dec 2005, 04:49:53 »
Thanks Fragorl.
The purpose was to aim accurately custom missiles. And the only way I found out is to fire a bullet with a "Fired" event handler attached to the firing unit, then get the bullet object with nearestobject and get its velocity vector just before deleting the object. Problem is that this way I will not be able to aim from vehicles.

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:Where are you pointing at?
« Reply #3 on: 31 Dec 2005, 11:04:07 »
Yes, this is the only workaround I am aware of.

If you don't want a unit to have to fire off their current weapon, since this has the obvious drawbacks of losing ammo, possibly harming closeby units if the script can't catch and delete the bullet in time (and hey, I've seen it happen) and so on, then you might be able to add them a temporary weapon. This weapon can possibly be configured to have a.) no model (for instant switch time), b.) slow ammo and c.) harmless ammo.

So you addmagazine the correct magazines, and addWeapon the weapon, selectWeapon it, fire off a round and run the script, then removeWeapon the weapon and selectWeapon back to the unit's Weapons select 0.
I can't vouch for all that working, but it just occurred to me now that it might be worth a try.

bored_onion

  • Guest
Re:Where are you pointing at?
« Reply #4 on: 31 Dec 2005, 11:09:52 »
how does the laser designator send directions to scripts etc? i know there are a lot of commands for it but the answer may be buried deep in the config or something. either way, could you transfer a similar kind of operation from a laser designator to another weapon? im not sure it will work and it might not be worth the bother but its worth floating the idea in case someone has anymore information.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Where are you pointing at?
« Reply #5 on: 31 Dec 2005, 12:01:33 »
Quote
how does the laser designator send directions to scripts etc?
It doesn't..

If you are referring to things mentioned in snYpir's LD tutorial, all the scripts used and mentioned there are external to the LD and have nothing to do with it per se...
They are just a workaround to get the position where the laser is pointing at, etc...

Most parts of the LD functionality are hardcoded (simulation="laserdesignate", in the LD 'ammo' class..), and you can't use the same on any other weapon without turning it into a LD..

Afaik, correct me if I'm wrong ::) :P
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:Where are you pointing at?
« Reply #6 on: 31 Dec 2005, 12:10:25 »
Frarorl, do you mean some BIS weapon? I dont want to depend on a non standar addon for this purpose.

Onion, laser designator creates an special unique object there where it hits the ground (the laser bean). You need to check for that object presence and then you may get its coordinates.  And yes, it would be an option, but then you need to have a laser designator as a weapon, enormous device that can be carried only by some units. And again, how to aim from a vehicle?

Lets say I'm into a standar BIS boat as a driver, for example. The boat has custom missiles (not any extra addon, just few scripts running). Now the driver (you) need to target an enemy chopper aproaching from your left (you can see it clearly turning your head to the left, but not the boat).

bored_onion

  • Guest
Re:Where are you pointing at?
« Reply #7 on: 31 Dec 2005, 12:10:54 »
i kneel to superior knowledge. but if snYpir could work around it for the laser designator could the same technique be used in this case? or am i being a little naive?

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re:Where are you pointing at?
« Reply #8 on: 31 Dec 2005, 12:54:01 »
Onion, as far as I know, you cannot use your LD from inside vehicles. The LD unit would need to get out its vehicle to get a target. In my example, if you get out of the boat, you will die in seconds.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Where are you pointing at?
« Reply #9 on: 31 Dec 2005, 16:15:34 »
@bored_onion:
Quote
i kneel to superior knowledge.
Oh come on.. Let's not get carried away :P

Quote
if snYpir could work around it for the laser designator could the same technique be used in this case?
What snYpir does is he uses scripts to detect that invisible target the LD creates when you 'fire' it at some target..
So no, can't really be used in this case...

@Mandoble:
Quote
The purpose was to aim accurately custom missiles. And the only way I found out is to fire a bullet with a "Fired" event handler attached to the firing unit, then get the bullet object with nearestobject and get its velocity vector just before deleting the object. Problem is that this way I will not be able to aim from vehicles.
If you take a look at MCAR (after following that link, scroll down to Reply #7, and then downwards *shameless plug ;D*) you will see how it has been done with that... Although all vehicles done with that are cars, same 'system' can be used on boats for example..
(there are things done pretty much the way Fragorl theorized too..)

But you won't need much, the vehicle needs to have a mannable mounted MG and then you do basicly what you already described, use the fired EH, nearestObject and velocity stuff...

Or am I misunderstanding your problem... It being almost new years eve and all ;D ::)
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:Where are you pointing at?
« Reply #10 on: 31 Dec 2005, 16:58:12 »
HateR, the problem here is that the custom missile system should  be able to equip any unit or vehicle, not only those with mannable mgs (a truck, a submarine, a transport ship, a C130 Herc, whatever).

Anyway, thanks a lot for your help and Happy New Year.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Where are you pointing at?
« Reply #11 on: 31 Dec 2005, 17:33:47 »
Ok, so in that case you're outta luck.. :(
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:Where are you pointing at?
« Reply #12 on: 01 Jan 2006, 02:07:18 »
Aha, I see. In that case, this may or may not be a job for FWatch, either that or some other form of key/mouse command interception (there is a script that doesn't require a new exe and an addon, but unfortunately it is limited in the keys it can pick up). Then you just create a missile based on the type of vehicle the player is in (and if you want to make the missile script very generic, without typeof checks, then make sure you create the missile well away from the vehicle position, perhaps adding some nice drop effects until you do create the missile)

EDIT:
Ok, so you want to do all of this when the player is driver, and create the missile in the direction he is looking in. This might be impossible, unfortunately. But, with getdir, plus the vehicle-angle detection functions (GetBank etc) you would be able to fire the missile in the true direction that the vehicle is pointing in. Compromise?

EDIT2:
This might be possible in Fwatch. Simply wait until the player mounts the vehicle, then run a mouse-position-fetching script with a short delay to query the mouse position from FWatch. This, combined with a small amount of trivial vector maths (I'm happy to do it) would get you your player's viewing direction. The key lies in the fact that the player's view direction snaps to the vehicle direction when the player mounts a vehicle. As I said before, this requires a new exe and one addon for all who want to play the mission. Compromise? ;D
« Last Edit: 01 Jan 2006, 02:21:47 by Fragorl »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re:Where are you pointing at?
« Reply #13 on: 01 Jan 2006, 17:06:28 »
Fragorl,
to launch a missile there are two steps (2 different actions): 1 - Lock on a target. 2 - Launch the missile against the last selected target (if not objNull).

The problem is only related to step 1.

FWatch is not an option for the current version of the missile suite, It is mandatory to do not depend on any external executable file or non BIS addon.

Any way, thanks for your ideas, they may be an option for future versions of the missile suite.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re:Where are you pointing at?
« Reply #14 on: 03 Jan 2006, 10:38:49 »
Well, there may be an averagely good solution. If you dont know where your head is pointing at, at least you may know where your body is pointing at. Activating a targeting action, a serie of anti-gravity (static in the air) glowing drops will mark where your body is pointing at (your direction) for 2 seconds, 200 meters away. So, you only need to turn a bit left or right to align with the desired target (aligning your sight with your body direction mark in the space).

I'll try to post the full missile suite scripts with some example missions today at the beta testing forum.