Jump to content
Sign in to follow this  
Doolittle

True artillery

Recommended Posts

Now we can fire that "Shell105" at the enemy from really far away, rather than just drop it on 'em like before!  Can you say:

m-102-dvic491-s.jpgmr.gif

physics-of-football-kick.gif

Here's a good start:

cannon.sqs

;Basic Cannon

;by Doolittle

;Give me the position of your cannon

;The direction it is pointing

;The angle of the gun to the ground

;The muzzle velocity of the gun

_pos = _this select 0

_dir = _this select 1

_ang = _this select 2

_vel = _this select 3

_type = "Heat105"

_hyp = _vel * cos _ang

_vx = _hyp * cos _dir

_vz = _hyp * sin _dir

_vy = _vel * sin _ang

_obj = _type camCreate [_pos select 0, _pos select 1, (_pos select 2) + 1]

_obj setVelocity [_vx, _vz, _vy]

That's it!  (We love you setVelocity)  Note I created an H obj. on the ground as a firing point.  You may need to raise your point if it puts it inside your tank or whatever other object you've placed at _pos.

Now I need to figure out a way to get the computer to calculate the angle & muzzle velocity by itself.  Humans have been working on this problem for their entire history (because we love each other so much)!!

http://www.dean.usma.edu/math/pubs/mmm99/C6.HTM

http://www.phy.ntnu.edu.tw/java/projectile3/projectile3.html

http://www.fas.org/man/dod-101/sys/land/m102.htm

http://www.molonlabe.net/johns/ballisti.htm

Doolittle

Share this post


Link to post
Share on other sites

Doolittle, it's not so simple

the ShotShell simulation terminates at T+20, detonating the shell.

that means for a 45% angle, you're limited to 490x20 seconds, or 9.8 km, and high-angle fire is out of the question.

Now if you want the shell travelling at realistic speeds, with all those options, you're gonna have to get fancy.

Share this post


Link to post
Share on other sites

So you're talking about rocket propelled artillery?

My script above is just a beginning...just to get people going.  That's all of yesterday's work up there...I'd totally forgotten all my math.  I have like 5 pages of scratch paper laying around that has a bunch of attempts/calculations on them and I did this thing in Excel...

101720022161142.jpg

I wanted to save someone all that trouble (I know, I know, there's people out there that have these equations memorized)

Doolittle

Share this post


Link to post
Share on other sites

Hi all

Dinger the short flight time is sufficient for 60 and 80mm Mortars though smile.gif

It is not perfect but most of the islands are less than 9k wide and you would not want artilery to be able to fire right the way across the islands at their current size it would unbalance the game.

As islands become bigger (OFP 2 perhaps) This would become more important. It will need to beworked on but we have a start.

Proper indirect fire will allow OFP to begin to fulfill its potential as a strategic first person shooter and leave all the CS and quake clones in its dust.

Kind Regards walker

Share this post


Link to post
Share on other sites
Guest

You can always fake it by removing the shell before detonation and camcreating a new one (and set the appropriate velocity vector)

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">I wanted to save someone all that trouble (I know, I know, there's people out there that have these equations memorized)

<span id='postcolor'>

I love you

Share this post


Link to post
Share on other sites

true denoir. Then you run into the MP-camcreate bug/feature, and have to camcreate spoof shells as well. It's a mess pretty quick.

but yeah, it's cool for many purposes.

Here's what I'm thinking of doing doolittle:

you've got your artillery gun, and via the action menu you set the charge. You can get ranging information by firing a "rangefinder" that triggers a fired eventhandler that snaps up the dummy projectile, reads its velocity vectors, and calculates the gun's elevation (then destroys the dummy projecitle), and displays the range info for the given charge.

The gun itself has some shell types to choose from (HE, WP, ICM, FASCAM, CLGP, etc). YOu select a shell type and use the actionmenu again to set the fuze. Fire, and again onfired tracks the shell and produces the appropriate munitions effects. Cool, huh?

Share this post


Link to post
Share on other sites

Dinger, may I ask what all of those abreviations stand for?

Is there a difference between "Heat73" and "Heat105" for example? (Difference in the game??)

Doolittle

Share this post


Link to post
Share on other sites

just correcting an little error in your routines, then it works fine:

_hyp = _vel * cos _ang

_vx = _hyp * SIN _dir

_vz = _hyp * COS _dir

_vy = _vel * sin _ang

but except of this: great work, doolittle!!!

Share this post


Link to post
Share on other sites

Actually the sin, cos, tan functions all have 0 degrees starting to the east (and increment counter clockwise).  All objects are placed 0 degrees if they are facing north (and increment clockwise).  Perhaps I shouldn't have used the var name _dir.  wink.gif

Doolittle

Share this post


Link to post
Share on other sites

How do I solve something like sin (2 theta) = C?? Where C is any constant. That becomes 2 cos (theta) sin (theta) = C ...now what ??

Help please..

Doolittle

Share this post


Link to post
Share on other sites

Erm, I can't even do asin 37.9 degrees in OFP!!  It returns -1.#IND.  My calculator can do this...says it's 41.42 degrees (or 0.72281 radians (divide that by 0.01745 radians to get degrees)).  I also thought arcsine functions gave two solutions, so I assume OFP is getting 2 and doesn't know what to do with that?  What should I do?  Please?  Anyone?

Is there a way to restrict the domain? -PI/2 to PI/2?

Doolittle

Share this post


Link to post
Share on other sites

arcsine should take in the real number between -1 and 1, and spit out corresponding angle.

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">sin (2 theta) = C<span id='postcolor'>

to solve, do this

(arcsine C)/2

there might be some issues regarding +/- of the angle.

Share this post


Link to post
Share on other sites
Guest

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Doolittle @ Oct. 19 2002,03:53)</td></tr><tr><td id="QUOTE">How do I solve something like sin (2 theta) = C??  Where C is any constant.  That becomes 2 cos (theta) sin (theta) = C ...now what ??

Help please..

Doolittle<span id='postcolor'>

You mean solve for theta?

theta = ( arcsin C )/2

Edit: Lol, ralph, you were quicker smile.gif

Share this post


Link to post
Share on other sites

sad.gif

Yeah, I'm doing arcsine...OFP wants it in degrees which isn't usually how it's done. So asin 37 (arcsine) bombs out on me with a -1.#IND. Why!?

Thanks for the help nonetheless!

Doolittle

Share this post


Link to post
Share on other sites
Guest

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Doolittle @ Oct. 19 2002,09:44)</td></tr><tr><td id="QUOTE">sad.gif

Yeah, I'm doing arcsine...OFP wants it in degrees which isn't usually how it's done.  So asin 37 (arcsine) bombs out on me with a -1.#IND.  Why!?

Thanks for the help nonetheless!

Doolittle<span id='postcolor'>

Because asin (x) for x> 1 is a complex number smile.gif

For real numbers the argument to the asin function must be -1 <= x<= 1.

This is nothing strange since the sinus function returns values between -1 and 1 for real numbers as argument. Arcus sinus is just the inverse function.

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Doolittle @ Oct. 18 2002,17:36)</td></tr><tr><td id="QUOTE">Dinger, may I ask what all of those abreviations stand for?

Is there a difference between "Heat73" and "Heat105" for example?  (Difference in the game??)

Doolittle<span id='postcolor'>

Last question first, yes there is.

Last I checked, HEAT stands for "High Explosive Anti-Tank". What they mean is HE (High Explosive).

Over in the O2 section they have a commented config, and you can see the difference between HEAT73 and HEAT105 yourself:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">

class Heat73: Heat

{

hit=400;indirectHit=100;

cost=500;

};

class Heat105: Heat73

{

hit=450;indirectHit=150;

cost=600;

};

<span id='postcolor'>

The shell series is what shows up as "Sabot", an armor-piercing projectile. Shell73 and Shell105 are:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">

class Shell73: Shell

{

hit=100;indirectHit=90;

cost=500;

soundHit[]={Explosions\expl1,db40,1};

};

class Shell105: Shell73

{

hit=150;indirectHit=110;

cost=200;

soundHit[]={Explosions\expl2,db40,1};

};

<span id='postcolor'>

Yet if you camcreate Heats and shells on groups of infantry, you'll find out that Shells are much more lethal. What's going on?

Well, in the class for Shell, IndirectHitRange is set to 8; in the class for Heat, it is 1. So indirecthitrange is very important to overall lethality.

Now, for question two, the abbreviations. Someone correct me if I'm wrong on these; I'm no redleg:

HE -- High Explosive. It makes its own introduction

ICM -- Improved Combat Munition. Actually this is a family of shells that solve the cube-root issue by ejecting submunitions over the target area (usually this is done by blowing the base out of the projectile and letting the rotation of the shell blow the submunitions out. By itself, it usually refers to APICM, your artillery equivalent of clusterbombs. DPICM is designed for soft-skinned vehicles (though the grenades it deploys can go through up to 2.5 inches of armor). there are other newer sorts, like something that deploys armor-homing submunitions.

WP -- White Phosphorus -- it has a smoke and incendiary effect. This is the bad boy you see on the films, blowing up in a blossom of white smoke.

Currently there's also a smoke shell that uses WP -- basically it works like an ICM shell and ejects a bunch of chunks of WP over the area.

FASCAM = Family of Scatterable Mines. US 155s dump ADAMs (AP mines) and RAAMS (Armor ones). A textbook fire mission includes 3 rounds (x 4 tubes in the platoon) of RAAMS and 1(x4) of ADAM. A RAAMS shell contains nine mines; ADAM has 36.

CLGP = Cannon-Launched Guided Projectile, aka Copperhead. It has deployable fins and is laser guided to its target.

For more fun with that, I recommend checking out the artillery field manuals available through:

http://www.adtdl.army.mil/

(FM-6-xx)

Share this post


Link to post
Share on other sites

Thanks Dinger!!  And Denoir and Ralph Wiggum!  I was reading what you guys said, it just wasn't clicking.  I think what threw me off is that you do sin 40 (for example)...i.e. you send it DEGREES.  But with asin they wanted radians!  I know...I could have just read this in the manual, but I was so used to switching over to degrees that it didn't occur to me.  Sorry about that!

Woah they launch mines?  I didn't know they did that.  I always thought a bunch of people went out and put them around.  Haha, seems kinda like a lazy approach on the Army's part.  (Then again maybe not.)  And the guided projectile, that's cool.  Also the cluster bomb like equiv.  Right now I'm just going to do one shell.  I just tackled arcsine so I don't wanna do any other hurdle today.

Now I'm running into the problem of air drag or something like that.  I didn't think they'd have had that programmed in.  Maybe friction is always turned "on" no matter if you're flying or on the ground.  I'm not going to worry about that either since the ALTITUDE thing is a bigger hurdle.  (Everything is at pos 0 if it's on the ground!! )

Doolittle

Share this post


Link to post
Share on other sites
Guest

Arcsin does not take an angle as an argument. It returns an angle. So the value you give to arcsin must always be between -1 and 1 if you want a real value back regardless if you are using radians or not. smile.gif

Share this post


Link to post
Share on other sites

Drag = SideAirFriction or something in the config.cpp. It's funky though.

Shells just drop according to gravity (up until a certain point, it seems). So, if you drop one from Z+490, it hits the ground in ten seconds.

there are many ways for calculating ASL and getting around the "z = hieght AGL" problem. The most effective is to setpos [x,y] a trigger on the spot you want to measure. That trigger will be at sea level and its Z value will give you sea level in aGL terms (e.g., at 488 AsL, the trigger's Z will be -488).

There's nothing "lazy" about launching mines if you're targeting an enemy moving in an area you can't get grunts to. Area denial.

Share this post


Link to post
Share on other sites

Are you aware of the objects having mass? My calculations for the artillery are just off for long distances like there is definite air drag on shells. The shells also have like a lifespan, then go away after "existing" for a certain amount of time it seems.

Doolittle

Share this post


Link to post
Share on other sites

So are any of you mathematicians gonna come up with a way to put this into the game and get some sort of test mission ?

Share this post


Link to post
Share on other sites

Shells last for 20 seconds. At T+20 they explode whether they're in contact with the ground or not.

I don't know if it's mass, but there is something that looks like terminal velocity. If you drop it from 490 meters, it hits the ground in 10 seconds. if you drop it from 1102 meters, it takes longer than 15 seconds -- at least I think it does. anyway, you can check this for yourself.

The timeout can be used for fuzing effects. Or you can camcreate a FxExploGround1 on the shell.

in the end, I don't care where the shots come from, but where they land. wink.gif

Share this post


Link to post
Share on other sites

Here's basically the math I'm doing (all math here is good/correct, there's just no air drag factored in):

V = muzzle velocity (like say 100)

x = (target's x - gun's x)

z = (target's z - gun's z)

distance = squareroot (x^2 + z^2)

direction = arctan (z / x)

This next line is single most important thing!!!!

It's the angle of the gun to the ground

angle = 1/2 * arcsine ((9.8 * distance) / V^2)

Hyp is that line under the V vector..what I like to think of as it's "shadow" (basically it's distance / time)

Vy = V * sine (angle)

Hyp = V * cosine (angle)

Vx = Hyp * cosine (direction)

Vz = Hyp * sine (direction)

This should give us the velocity to fire the cannon at.  The problem I'm having is...well, the shell's falling short.  There is air drag involved!!!!  And I don't know where to fit that into my above equation!  (I tried extending the distance by some factor & changing gravity constant & stuff like that but that doesn't work...I need air friction)

gravity = -9.8 wow.gif

Height is 0 when you start so...

0 = V * sine (angle) * time + 1/2 * -9.8 * time^2

distance = V * cosine (angle) * time

(those two equations are given, just accept them)

Now we do...

distance / (V * cosine (angle)) = time

Substitued time into other equation...

0 = V * sine (angle) * distance / (V * cosine (angle)) + 1/2 * -9.8 * [distance / (V * cosine (angle))]^2

Multiply everything by [V*cosine(angle)]^2, divide by distance, and multiply by 2 and you get...

0 = 2 * V * sine (angle) * (V * cosine (angle)) + -9.8 * distance

2 sine(angle) cosine(angle) = sine (2*angle)

Sooo...

9.8 * distance = V^2 * sine (2*angle)

Now take the arcsine...

arcsine [ (9.8 * distance) / V^2 ] = 2*angle

How is my math?  Do you see any wrongdoing?  How can I get air drag in there?

Thank you for reading this far!  Math hurts...!  But it also helps us kill more/better.  I am ready to release this script, it would just be nice to stick in air drag.

Doolittle

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  

×