Home   Help Search Login Register  

Author Topic: GetDir tank turret?  (Read 3111 times)

0 Members and 1 Guest are viewing this topic.

Ace Productions

  • Guest
GetDir tank turret?
« on: 11 Nov 2003, 22:27:10 »
Is there any way to get the direction a tank's turret is facing. I've tried getting the gunner's direction assuming they both face at the same direction but it's not the case.  :(

Kilo11

  • Guest
Re:GetDir tank turret?
« Reply #1 on: 11 Nov 2003, 23:21:45 »
Well, this isnt the "right" way if you will, but it works.  Create a "GameLogic" and put "this moveingunner tank1" into it's Init field.  Then you can either change the direction of the Game Logics Amuitz (Which does not work all the time), or find a target/object/unit that is in hte same direction as you wnat the turret to point, and you give the command "this doTarget xxxx" in the init field.  I have used this and it works fine.  Keep in mind that this  will disable the players ability to get in the tank as a  gunner, so make a second trigger that has a 10 second delay and then is activated with this in the On Activation: deleteVehicle nameofGameLogic.  Hope that works, sorry, that was a mouth full....


-=Kilo=-

m21man

  • Guest
Re:GetDir tank turret?
« Reply #2 on: 12 Nov 2003, 00:04:20 »
If the tank was targeting something, you could find out what angle the turret is pointing at. But, this would require (*m21man bursts into song*):

[size=20]Trigonometry![/size][/sub]
« Last Edit: 12 Nov 2003, 00:07:53 by m21man »

Komuna

  • Guest
Re:GetDir tank turret?
« Reply #3 on: 12 Nov 2003, 13:47:48 »
An idea just uccured to me... I'm a trignometry fan too, but I think that you can easily detect the turret's direction by getting the direction of the gunner or the commander... Not guaranteed, though.

hint format["Tank's dir: %1\nTurret's dir: %2",getdir MyTank,getdir gunner MyTank]

This formated hint will return into your screen the values of the tank's direction (1) and the gunner's direction (2).

I hope that works, mate!

#EDIT
Oooopsss looks like I was wrong!
« Last Edit: 13 Nov 2003, 12:51:13 by Komuna »

Unnamed

  • Guest
Re:GetDir tank turret?
« Reply #4 on: 12 Nov 2003, 15:09:36 »
Quote
An idea just uccured to me... I'm a trignometry fan too, but I think that you can easily detect the turret's direction by getting the direction of the gunner or the commander... Not guaranteed, though.

I tried it a while back, it just returns the actual veichle heading for any of the crew. It's like each guys individual identities disapear when they enter a vehicle.

Offline Igor Drukov

  • Contributing Member
  • **
  • Conscientious Subjector
Re:GetDir tank turret?
« Reply #5 on: 12 Nov 2003, 15:26:27 »
Hey !

@ Komuna and Unnamed :

your solution has already been tried, I think, by Ace Productions when he says :

Quote
I've tried getting the gunner's direction assuming they both face at the same direction but it's not the case.

Anyway, I know it might not be exactly what Ace Productions wants but who knows ? I think it's quite simple and therefore worth mentioning :

to get the direction of the turret once the tank has shot (which is where the shoe undeniably pinches), add in its init line :

Code: [Select]
this addEventHandler ["fired",{call format ["bullet=nearestObject [player,""%1""]",_this select 4];hint format ["%1", getdir (bullet)]}]
Like this, every time the tank shoots, the direction of the bullet (and thereby of the turret) will be returned.

Hope this can be used as a work-around !
(Ace, feel free to ask for further explanations of this line if you don't get it).


Ig.


Unnamed

  • Guest
Re:GetDir tank turret?
« Reply #6 on: 12 Nov 2003, 16:23:56 »
I posted my solution a while back when someone asked a similar question:

http://www.ofpec.com/yabbse/index.php?board=8;action=display;threadid=11968;start=0

But I suspect Ace does not want to worry about making addons as such, I toyed with using knowsabout and the invisible target addon. But I think that will suffer from the same problem.

The game logic is interesting idea, but I suspect that will be grouped with the crew as well. But hey, there only idea's and idea's never harmed anyone......errr well not the sort posted here :)

It depends on when and where Ace wants to use the turret direction, before firing, after firing or continuously?

Offline Igor Drukov

  • Contributing Member
  • **
  • Conscientious Subjector
Re:GetDir tank turret?
« Reply #7 on: 12 Nov 2003, 17:04:32 »
Hey !

Unnamed, does this mean that what a tank "DOWATCHes" corresponds to what the turret is pointing at ?
In which case, to answer Ace's question, what we 'd need would be a command such as G E T W A T C H ?

(Hum, hope this is clear enough  :P)

Ig.
« Last Edit: 12 Nov 2003, 17:08:10 by Igor Drukov »

Ace Productions

  • Guest
Re:GetDir tank turret?
« Reply #8 on: 12 Nov 2003, 20:34:46 »
Guys thanks a lot for your replies and your suggestions.

The biggest of problems is that the turret direction is needed at all times (not when firing).

I'm an engineer, so trigonometry is no problem but the main component for any mathematical approach to this problem is the angle of the gun barrel and the north (which I can't get!).

I've tried the GetDir _gunner but as you already know it returns the tank direction.

I've read somewhere about someone creating some invisible addons and I was wondering if the "Fired" EH can work on them (if I find them?).




Unnamed

  • Guest
Re:GetDir tank turret?
« Reply #9 on: 12 Nov 2003, 22:58:18 »
Quote
Unnamed, does this mean that what a tank "DOWATCHes" corresponds to what the turret is pointing at ?

When I played around with the DoWatch command on an AI controlled tank, it would always point the tank hull in the same direction of the gun.

Another thing I tried was using KnowsAbout. The KnowsAbout value of a target will increase as it moves into the centre of the screen, and decrease as it moves towards the edge. If you setup a ring of invisible targets around a tank, then get the knowsAbout value for all the targets, the largest value will be the one the tank is looking at.

I have yet to see what happens when the gunner is looking at one target and the driver another. But again OFP appears to treat any units in the same vehicle as one large virtual group, even if you have two or three different groups as crew and cargo.

When I get the chance to mess with weapons and stuff in the config.cpp I will try and create a silent gun to see if it can be used.

Quote
I've read somewhere about someone creating some invisible addons and I was wondering if the "Fired" EH can work on them (if I find them?).

If it does not, it probably wont take much to add the functionality. It's quite simple, but works very well. I can mail it to you if you want? Can't remember where I downloaded it from now.

I plan to use it to sample how much visibility a unit has, of the surrounding area, at certain points in time.

Offline Zayfod

  • ECP Team
  • *
  • Llama, softest natural fibre in the world.
Re:GetDir tank turret?
« Reply #10 on: 24 Nov 2003, 08:57:24 »
LOL sumone else with the "invisible firing gun on the tank turret idea"--yup this was my idea of how to solve it too but I dont know nuff bout addons yet.

I wanted this to compliment my threat function that I made. I got the idea for the threat function after reading toadys great threat matrix function.

Funny how all this stuff kinda links together--why did I need a threat function? I wanted the AI in  in my AI cover & hold script to know when they were underfire and if they werent underfire to asses individually if they thought they were about to be fired upon.

So now in the next version that I will post (soon)they wont be randomly taking cover as they do in  the current version 1.7, they will actually hide when under fire or if they know enuff about the enemy and they see the enemy aiming at them. Toady came up with the majic knowsabout numbers too (good ol Toady), I forget what they are--check the knowsabout section in the functions library. Using these a lot can be achieved but u do need direction.

Works perfect for infantry, so hopefully sumone will make this addon then I can allow my AI to figure out if a tank is about to blow their head off. ;D

Sumone put this in addons requested, :P

Zay
« Last Edit: 24 Nov 2003, 09:03:04 by Zayfod »
"I have come here to kick ass and chew bubble gum......an I'm all outta bubble gum!"

Unnamed

  • Guest
Re:GetDir tank turret?
« Reply #11 on: 26 Nov 2003, 23:17:33 »
Quote
LOL sumone else with the "invisible firing gun on the tank turret idea.

LOL

Quote
So now in the next version that I will post (soon) they wont be randomly taking cover as they do in  the current version 1.7, they will actually hide when under fire or if they know enuff about the enemy and they see the enemy aiming at them.

Sounds good, can you get say. A single guy to hold fire and hide, even if there is an enemy squad close by? I could do with something like that for my Observer.

Offline Zayfod

  • ECP Team
  • *
  • Llama, softest natural fibre in the world.
Re:GetDir tank turret?
« Reply #12 on: 26 Nov 2003, 23:45:50 »
Yer, no problem at all.

My latest version ( that I havent uploaded yet) already has this. I use it to stop AI wasting AT ammo on tanks that are no danger to them but are still alive. IE they can drive around but cant fire--no point in wasting a law on it when there might be a new BMP coming over the hill ;D

Currently my method is to attain an array of all his weapons and ammo when ever he is engaging armour. When the armour aint a threat to him no more I take away his AT ammo. ;D If he spots another one that is a threat I give back tha AT ammo that he had left before I took it off him prior. Work real good however the ammo and weapon array calculation has to be perfect. If it is not it will cause a CTD.

Took me ages to get it right. Now works 100%.

Note it also works the other way round too. While he is busy aiming at the tank his buddys are busy covering him with rifles for incoming infantry. So while he has AT selected I take away his rifle ammo. Coz sumtimes stupid AI decide they wanna engage troops half way thru engaging armour. This stops him swapping back and fourth from AT to rifle.

When I post next version feel free to rip it all apart and have a look. Or I can isolate the code and send it to you. :)

Zay
"I have come here to kick ass and chew bubble gum......an I'm all outta bubble gum!"

Offline Zayfod

  • ECP Team
  • *
  • Llama, softest natural fibre in the world.
Re:GetDir tank turret?
« Reply #13 on: 27 Nov 2003, 00:42:59 »
This may be another option for u.

Quote
unit stop stop

Operand types:
unit: Object
stop: Boolean
Type of returned value:
Nothing
Description:
Stop AI unit. This function is obsolete. Use disableAI to get better control on stopping unit.

Example:
soldierOne stop true

comment »


this stops a unit cold. He wont fire, move, or any thing. It disables all his ai functions I think. Then once your threat has passed or if the enemy discover your observer and fire on him u could set it to false and he would come back to life and defend himself or run away --up to u.

Zay
« Last Edit: 27 Nov 2003, 00:45:47 by Zayfod »
"I have come here to kick ass and chew bubble gum......an I'm all outta bubble gum!"

Offline ACF

  • Members
  • *
  • Llama?? Ain't that French for tanks?
Re:GetDir tank turret?
« Reply #14 on: 27 Nov 2003, 15:07:50 »
At the risk of being off-topic, there's always the classic:

singleguy SetBehaviour "STEALTH"
singleguy SetCombatMode "BLUE"

combo (or "GREEN" to give him a fighting chance if seen).

Better yet would be to call the take cover / hide option you get as a leader to make sure he finds cover, but this doesn't seem to exist as an action or command (please prove me wrong . . .)