Home   Help Search Login Register  

Author Topic: Get tank's turret direction?  (Read 1193 times)

0 Members and 2 Guests are viewing this topic.

illario

  • Guest
Get tank's turret direction?
« on: 24 Mar 2004, 09:34:52 »
Hello to you all !
In the game, i tryed use script to get Turret orientation(direction) of the Tank (m1abrams for example).
(it need me to upgrade the game of my armour resistanse calculations...)
But i can't get its(Turet) direction. I only can get a whole tank direction(hull)
What i need to do to get exactly turret dir?
Thank you for your future answer!
With regards, illario

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Get tank's turret direction?
« Reply #1 on: 24 Mar 2004, 09:48:58 »
getDir on the gunner?
Plenty of reviewed ArmA missions for you to play

m21man

  • Guest
Re:Get tank's turret direction?
« Reply #2 on: 24 Mar 2004, 14:19:49 »
You can get the direction of the turret immediately after the gun has been fired.

illario

  • Guest
Re:Get tank's turret direction?
« Reply #3 on: 24 Mar 2004, 14:48:25 »
getDir on the gunner?
Ok i tryed this but i got bad results,
my sqs:

_arr              = _this select 0
_tank            =_arr   select 0
_gunner        = gunner _tank
_commander = commander _tank

_gundir = getdir _gunner
_comdir = getdir _commander

In both ways _gundir=0 and _comdir=0 at any turret position
I tryed to get gunner and commander positions:

_gunpos = getpos _gunner
_compos = getpos _commander

But this values the same as a tank position(_tpos = getpos _tank)
Little succes was when i tryed to get the commander position when he
uncovered (hatch is open), but only global position but not the direction!
Anyway i can calculate the angle of turret , substructing the tank and commander position whith sin or cos->
But if commander is uncovered it is easy becomes to be killed??!!
I need somehow at one moment to uncover commander, get his pos and cover him in the tank (at combat mode), But i don't know how to make it quickly
The command like  action ["TURNOUT",_tank] and action ["TURNIN",_tank] are very slow. MAYBE IS SOME OTHER WAY?

STRANGE when some crewman is inside (combat mode) the tank, the OFP thinks that crewman's position and direction is same as a tank. I dont know why?!

sa8gecko

  • Guest
Re:Get tank's turret direction?
« Reply #4 on: 24 Mar 2004, 17:15:54 »
Quote
getDir on the gunner?
I'm afraid this doesn't  work

Quote
Anyway i can calculate the angle of turret , substructing the tank and commander position whith sin or cos->
But if commander is uncovered it is easy becomes to be killed??!!
I need somehow at one moment to uncover commander, get his pos and cover him in the tank (at combat mode), But i don't know how to make it quickly
The command like  action ["TURNOUT",_tank] and action ["TURNIN",_tank] are very slow. MAYBE IS SOME OTHER WAY?

Well, if you can take commander viewing direction when he's out of
the hatch (and hopingly it's not the same dir as the main gun one) then this could
be used to give the commander an additional machine gun, operated by the action menu. So when the gunner engages tank or apc with the main
gun, the commander could engage infantry or low flying helos .

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Get tank's turret direction?
« Reply #5 on: 24 Mar 2004, 17:45:29 »
Could you setpos the commander to an offshore island, getDir him there then moveinvehicle him back?    Dunno.

m21man's answer might be better:  I assume you use an eventhandler fired to detect the firing then the script launched thereby uses nearestobject to grab the shell.    Use a dash of trigonometry to figure out the angle between tank and shell and bob's your auntie's live in lover.

Plenty of reviewed ArmA missions for you to play

Offline Igor Drukov

  • Contributing Member
  • **
  • Conscientious Subjector
Re:Get tank's turret direction?
« Reply #6 on: 24 Mar 2004, 18:09:39 »
Hello all !

This thread might be of some interest.

It shows the issue is not easily solved  :-\

sa8gecko

  • Guest
Re:Get tank's turret direction?
« Reply #7 on: 24 Mar 2004, 18:56:12 »
The problem with tank shell is that sometimes they fly too fast for
a script to catch them, above all if the scenario is very 'crowded' and
view distance is high, i.e. when framerate drops less than 15.
If the shell is catched then there is no problem at all to figure out
where the turret is turned, and you can even find the target. This is what
we have done to fire missiles from car type units. But maybe Illario doesn't
want to fire a shell to know turret's orientation.

Unnamed

  • Guest
Re:Get tank's turret direction?
« Reply #8 on: 30 Mar 2004, 18:54:34 »
Quote
Anyway i can calculate the angle of turret , substructing the tank and commander position whith sin or cos->
But if commander is uncovered it is easy becomes to be killed??!!

Well spotted illario, I guess it gives positional info for anything that can be shot at.

I thought it might apply for game logics and cargo spaces to, so I knocked up this to try it out:

http://www.ofpec.com/yabbse/index.php?board=13;action=display;threadid=16663;start=%200#lastPost

Despite some draw backs it does kind of work, well at least its a start at getting this kind of info from an addon.

:cheers:

sa8gecko

  • Guest
Re:Get tank's turret direction?
« Reply #9 on: 30 Mar 2004, 20:53:59 »
Good work, Unnamed, fantastic work. You open the way for a new
class of vehicles (you know what they are).
Please, if you still haven't done it, read your PMs.

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:Get tank's turret direction?
« Reply #10 on: 14 Apr 2004, 05:46:41 »
How about finding the animation phase of the tank turret?  There must be an animation for it because it turns, so if one can dig through the config file for the tank, maybe they can find the name for the turret animation?  

Animation phases are in a decimal range from 0 to 1, so if you knew the tank's direction and the animation phase you could calculate the turret direction relative to the tank direction (it would be the returned animation phase * 360) + the tank direction).  Anyway this is all worthless unless someone knows what the animation phase name is for the turret.

The syntax for the command would be:

Code: [Select]
_tank animationPhase "turret"
I tried, this but "turret" must not be the term used in the tank's config file.  I did do some looking around and saw this code in the cfgVehicles.hpp:

class TurretBase
{
   gunAxis = "OsaHlavne";
   turretAxis = "OsaVeze";
   soundServo[]={Vehicles\gun_elevate,db-30,1.0};

   gunBeg = "usti hlavne";
   gunEnd = "konec hlavne";
         
   minElev=-4; maxElev=+20;
   minTurn=-360; maxTurn=+360;

   body = "OtocVez";
   gun = "OtocHlaven";
};

I tried the "OsaHlavne" and "OsaVeze" in place of turret, but these also returned a value of 0 regardless of the turret direction.

sa8gecko

  • Guest
Re:Get tank's turret direction?
« Reply #11 on: 14 Apr 2004, 06:52:19 »
hey, Raptorsaurus, how are you ? How's the tomahawk going on ?

About the animation phase of the turret, maybe it's hard coded into
the game. As for the pitching thing. About it: some progresses ?

returning to this topic, using Unnamed's method you can do this, but
you have to modify the p3d model. Anyway as now it's the only way
I know to have the turret'd direction returned, and it works always,
there's no need to fire the weapon. This has some side effects, like
that we could even guide the ammo ...


Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:Get tank's turret direction?
« Reply #12 on: 14 Apr 2004, 22:18:41 »
sa8gecko,

I'm doing well.  I do not have much experience with p3d modeling.  How does one access the p3d?  The link Unnamed provided for his mods does not work.

As for the other stuff (missile pitch etc. check your PMs)