Jump to content
Sign in to follow this  
csj

turrey direction ?

Recommended Posts

Trying to get direction tank turret is facing

last post I read which half made sence to me was this..

old post searched

Quote[/b] ]It is absolutly possible to get the direction the turret is heading, all you need is to check for a certain ammo and which direction this ammo has (and that would be initialized over the "fired" eh).

Now taking things literally as I do

I have this in EH

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">fired="[_this select 0,_this select 1,_this select 2,_this select 3,_this select 4] exec ""\CSJontos\CSJontosscripts\maingun.sqs"" ";

when trying to 'getDir' of _this select 4 (ammo) or any of _this select 2 or _this select 3

I get a message "scarlar bool array string 0xfcfffef"

_this select 1 works obviously but this is the direction which the tank is facing and not the turret (most of the time).

Can someone plz

Share this post


Link to post
Share on other sites

If the gunner is moving together with the turret, you can check the direction of the gunner instead.

Also this line is bad:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">fired="[_this select 0,_this select 1,_this select 2,_this select 3,_this select 4] exec ""\CSJontos\CSJontosscripts\maingun.sqs"" ";

Better write

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">fired="_this exec ""\CSJontos\CSJontosscripts\maingun.sqs"" ";

which has the same effect but makes reading much easier.

You can't take any of the arguments to use getDir on. What you need to do is do a nearestObject on the tank to grab the ammo and check the direction of that ammo then.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_ammo = nearestObject[_this select 0, _this select 4]; _dir = getDir _ammo

Share this post


Link to post
Share on other sites
If the gunner is moving together with the turret, you can check the direction of the gunner instead.

Doesn't work for me on e.g. the Fuchs.

Are you sure that it does work?

Share this post


Link to post
Share on other sites

You can, but only once (sometimes even twice), then you have to get out and get back in the weapon and then you can again check the gunners dir once, and so forth...

Share this post


Link to post
Share on other sites

Check RHS T-80's, there's another trick, way better. For the SHTORA-1 EOCMDAS scripts...

biggrin_o.gif

Ok, let's say it just works, nothing more and nothing less...

Share this post


Link to post
Share on other sites

You cant get the direction, directly from the gunner. It just returns the vehicles direction.

You can get the turret dir, using the gunners position and the center point of the vehicle. Depends on how the gunner is positioned, relative to the turret.

You can also use game logics, check the turrets I did for your Troop Transporter. They use logics. Same goes for MCar to, you can also get the gun elevation. WHich might come in handy, if I'm guessing right about what your trying to do.

And as hard rock said, if you only need the dir, after the vehicle has fired. You can also use the fired event.

Share this post


Link to post
Share on other sites

The model was pretty much finished without any scripting

except for the fact that everytime you fire the main gun the tank kicks like a *&%*#! mule.

After a couple days searching I find that removing the recoil is not possible

so then its back down the old path of 'recreate the wheel'.

thnx Unn, I will look at the ATCH scripts and see what I can make from them.  

(You know how much I luuuuuv scripting  inlove.gif )

Share this post


Link to post
Share on other sites

If your trying to supress the recoil, try this in the tanks init:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">This AddEventHandler ["Fired",{_This Exec "Script.sqs"}]

And script.sqs is:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Vehicle=_This Select 0

_V=Velocity _Vehicle

_T=Time+1

@(Call {_Vehicle SetVelocity _V; Time>_T})

It might work huh.gif depends how quickly, and how long the recoil kicks in, after firing. You may have to vary the amount of time it's run, by changing the 1 in Time+1.

Is there nothing you can do with the config or p3d?

Share this post


Link to post
Share on other sites

lol interesting code - without really reading the script I increased the

_T=Time+1 to _T=Time+2

and found this actually increases the effect of the recoil.

my poor little tank flew backwards about 15 metres.

Anyway this is what I have atm - still needs some finer tuning

the first #suppressionLoop (is only for stationary vehicle)

totally rids tank of any recoil action but the gun barrels do drop about 6" or so.

This is Ok coz its said that after these guns were fired once they usually needed resighting anyway.

#suppression2 (for moving vehicle)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Vehicle=_This Select 0

_Vehspd = (speed _Vehicle)

?(_Vehspd >5) :goto "suppression2"

_VehiclePos = getpos _Vehicle

_V=Velocity _Vehicle

_T=Time

#suppressionLoop

@(Call {_Vehicle Setpos _VehiclePos; Time>_T})

?Time - _T <=1 : goto "suppressionLoop"

exit

#suppression2

@(Call {_Vehicle SetVelocity _V; Time>_T})

Share this post


Link to post
Share on other sites

I did wonder if the recoil would be applied before the script kicks in, thats why it's worse. It's just amplyfing the problem. Perhaps if you launch a function from the event, you could get the velocity before the recoil kicks in. I will give it a try, next time I get a chance.

For the stationary loop, you could use SetVelocity [0,0,0]. It should not be as abrupt as set pos, but have the same effect.

Share this post


Link to post
Share on other sites

I am and was running the from cpp EH

This is final script that I have, works good on my tank.

The stabilizing is slightly effected by main gun angle/elevation.

I haven't tried it on other tank models as yet.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Vehicle=_This Select 0

_Vehspd = (speed _Vehicle)

_VehiclePos = getpos _Vehicle

_V=Velocity _Vehicle

_T=Time

?(_Vehspd >5) :goto "suppression2"

?(_Vehspd <-7) :goto "suppression2"

#suppressionLoop

@(Call {_Vehicle Setpos _VehiclePos; Time>_T})

?Time - _T <=1 : goto "suppressionLoop"

exit

#suppression2

@(Call {_Vehicle Setpos _VehiclePos; Time>_T})

@(Call {_Vehicle SetVelocity _V; Time>_T})

Still could be refined alot more but as it is atm saves me a sh!t load of work and time

Share this post


Link to post
Share on other sites

I just tested the timing of the recoil with the M60, try this. It should work ok for your tank to:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">This AddEventHandler ["Fired",{[_This Select 0,Velocity (_This Select 0)] Exec "Script.sqs"}]

And Script.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Vehicle=_This Select 0

_V=_This Select 1

_T=Time+1

@(Call {_Vehicle SetVelocity _V; Time>_T})

It's down to the timing of events. If you grab the velocity within the event handler, it acts like a function. So you get the vehicles velocity, just before it fires. If you get the velocity in the script (my old example) there is a small delay before the script is executed. So you end up with even worse recoil than before.

The new version works just as well with moving or stationary vehicles.

Share this post


Link to post
Share on other sites

Yes it worked but I still got some vertical and backward movement with main hull.

One more thing I have added to my version is a section to skip the other guns (machine gun and spotting rifle).

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Vehicle=_This Select 0

_weapon =_This Select 1

?(_weapon == "csjGun106"):goto "suppress"

exit

#suppress

_Vehspd = (speed _Vehicle)

_VehiclePos = getpos _Vehicle

_V=Velocity _Vehicle

_T=Time

?(_Vehspd >5) :goto "suppression2"

?(_Vehspd <-7) :goto "suppression2"

#suppressionLoop

@(Call {_Vehicle Setpos _VehiclePos; Time>_T})

?Time - _T <=1 : goto "suppressionLoop"

exit

#suppression2

@(Call {_Vehicle Setpos _VehiclePos; Time>_T})

@(Call {_Vehicle SetVelocity _V; Time>_T})

Share this post


Link to post
Share on other sites

That must be one hell of a kick smile_o.gif I only tried it on a stationary M60. If you sidechat the velocity from the eventhandler, it's [0,0,0]. When you display it from the script, it's all over the place, due to the recoil. I guess that short delay gives the recoil chance to act.

Did you try your version on slopes and uneven terrain? Setpos might cause it to realign with the terrain, which can look a bit odd.

Share this post


Link to post
Share on other sites

CSJ -

You've probably tried this already, but can you increase the overall mass of the tank in the GeoLOD, and reduce the recoil that way?

Share this post


Link to post
Share on other sites

@Unn - good point

tested it seemed Ok with my model.

Just checked on bridge which I figure would be problem, it is if not moving.

@Footmunch

Yeah, was 1 of the first things I tried.

Raised from 20,000 thru to 120,000 - made no visible difference re recoil effect, I thought it would have.

Share this post


Link to post
Share on other sites
Quote[/b] ]Just checked on bridge which I figure would be problem, it is if not moving.

Bridges should be easy enough to fix, if they do give you a problem. You just have to come up with a different way of getting the Z position.

Share this post


Link to post
Share on other sites

sorry to drag this thread up, but i need a similiar solution, but something which is faaaaaaar less complex.

now, I have a vehicle which barrel is stowed in a sling during transport/non combat situation. When in combat, the barrel raises out, and the sling lowers.

initially I've been playing with the unit behvaior commands, which work fine with AI (in that when they're turned out, the barrel returns to the neutral position), but doesnt really account for where they left the barrel if they got out, and obviously doesnt work for the player very well

@raedor, I've looked at the rhs scripts for shotra, but your scripting mind works differently to mine - i like to break scripts up into sections so i can easily read through the processes they're doing, whereas yours came out to me looking like one mass of text - very complex and amazing scripting, but utterly confusing for someone of my abilities.

all i really need is a script that can check when the barrel has moved either vertically or horizontally away from the neutral position, and when it returns to that position.

I'd like to possibly link this with a simpler code if the crew is entirely AI, as then i can happily rely on just the unit behaviour commands.

cheers for any help!

Share this post


Link to post
Share on other sites

What raedor did was put a game logic in a cargo space on the turret. If you do the same only put the cargo space on the barrel itself, and get the position of the logic, you can calculate the barrel's position relative to the tank (with trig, of course).

Edit: Sorry for the 10 day late reply.  tounge2.gif

Share this post


Link to post
Share on other sites

If this is what your after I made a basic example to demonstrate the idea:

http://homepages.gotadsl.co.uk/~gssoft/GameLogic.zip

Along with a tutorial that uses the principle to fit smoke grenades to a Bradley, here.

http://homepages.gotadsl.co.uk/~gssoft/MCAR-GameLogics.zip

You might not need as much scripting as that if you only want to check when it's in the stowed position. Rather than getting it's direction and elevation.

There is some other stuff not covered in the tute about MP and removing the move in back option. As I mentioned in this thread back in 2005, you can also checkout MCar and CSJ's ATC Troop transporter, for the most recent version.

Share this post


Link to post
Share on other sites

cheers guys.

realised that I could work a much quicker and simpler method for this, essentially using the principle that a vehicle with no weap, the turret doesnt move, so in stowed config it has no weapon, user action to deploy, gives weapon, gun cradle lowrs... easy solution indeed, perhaps a bit of a lazy route... but it doesnt hurt to learn the old smoke nades thing anyway.

Share this post


Link to post
Share on other sites
Quote[/b] ]easy solution indeed, perhaps a bit of a lazy route

I must admit, I was not exactly sure about what you wanted to do. But using game logics did seem a bit like over kill. Otherwise I would have mentioned it sooner.

Quote[/b] ]but it doesnt hurt to learn the old smoke nades thing anyway

With Arma, I don't think we will have to worry about such complicated methods to get things like the position of animated selections.

Share this post


Link to post
Share on other sites

This was the command that I was thinking about:

selectionPosition

Sounds like it will do the job? One of the many things to test come February.

Share this post


Link to post
Share on other sites

Whether it actually helps remains to be seen since it returns the position in model coords, not in the world coords.. Right huh.gif

Quote[/b] ]Returns position in model space.

Now to think of it, that might not even matter.. banghead.gif

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×