Page 1 of 2

How to make a ballistic weapon arc just a little

Posted: 21 Aug 2011, 12:18
by Erik
Hijacking: How to make a ballistic weapon arc just a little, i only saw the "hightrajectory" tag (which has a ridiculus arc height)?

Re: How to make a ballistic weapon arc just a little

Posted: 21 Aug 2011, 16:25
by Das Bruce
Don't hijack threads. You're allowed to make your own.

Re: How to make a ballistic weapon arc just a little

Posted: 21 Aug 2011, 17:50
by FLOZi
Play around with gravityAffected = true and various myGravity = x settings, as well as the velocity of the weapon.

Re: How to make a ballistic weapon arc just a little

Posted: 21 Aug 2011, 18:36
by Google_Frog
For a Cannon make the weaponVelocity high or myGravity low.

Re: How to make a ballistic weapon arc just a little

Posted: 22 Aug 2011, 03:11
by Forboding Angel
Google_Frog wrote:For a Cannon make the weaponVelocity low or myGravity high.
Fixed :-)

Re: How to make a ballistic weapon arc just a little

Posted: 22 Aug 2011, 03:25
by Google_Frog
From my understanding he wants it to arc "just a little" not a lot, as in a mostly flat trajectory. Your fixes are wrong forb.

Re: How to make a ballistic weapon arc just a little

Posted: 22 Aug 2011, 10:19
by Forboding Angel
If your ballistic shot is so fast that the trajectory is flat, you slow down the projectile and it will start being fired in an arc. OR You increase gravity on the projectile so that the unit must aim higher to get more distance. My fixes are very right.

Re: How to make a ballistic weapon arc just a little

Posted: 22 Aug 2011, 11:58
by Erik
a problem i encountered with this is that the procetile isn't fired at the maximum range and also has problems with targeting higher terrain.

What i want would be: behaviour similar to "hightrajectory" aka fire in the air with at least 45 degrees angular but without the shot going to the moon and back.
Perhaps the missile weapontype is more usefull for that?

Re: How to make a ballistic weapon arc just a little

Posted: 22 Aug 2011, 12:50
by knorke
Erik wrote:Perhaps the missile weapontype is more usefull for that?
imo yes, it has the TrajectoryHeight tag.
ie TrajectoryHeight = 2.5
->arc is 2.5 times as high as long
usually needs turnrate to hit though.

Re: How to make a ballistic weapon arc just a little

Posted: 22 Aug 2011, 19:58
by Forboding Angel
Yeah knorke is right. Achieving that kind of angle and still getting maximum range on a cannon weapontype is very difficult if not outright impossible. In this way, missiles are a lot easier to get along with.

Re: How to make a ballistic weapon arc just a little

Posted: 23 Aug 2011, 08:16
by Google_Frog
Forboding Angel wrote:If your ballistic shot is so fast that the trajectory is flat, you slow down the projectile and it will start being fired in an arc. OR You increase gravity on the projectile so that the unit must aim higher to get more distance. My fixes are very right.
This appears to be a misunderstanding stemming from the colloquial phrase 'just a little'. I interpret it that he wants a reduction of value; 'just a little, not a lot'. Whereas you interpreted it as 'just a little more than the current nothing'.

Using a missile is not a good solution. A missile will not look like a ballistic projectile, the arc and velocity is not quite the same, it doesn't gain or lose ranged based on height in the same way (I know this one can be modified, but it wouldn't look balistic).

A 45 degree firing is easy but a bit tedious. Set myGravity on the weapon to something around 0.1-0.2 depending on weaponVelocity and range. Here is an example:
  • range = 820
  • weaponVelocity = 300
  • myGravity = 0.11
Those are some values to give you a sense of scale, if weaponVelocity is higher or range lower you can set myGravity higher.

Then execute this algorithm:

Code: Select all

While (not fedUp)

    if actualRange < range then 
         decrease myGravity

    if angle < 45 degrees then 
         increase myGravity 

    restart Spring
end while
actualRange can be measured by spawning a unit in the top left corner of the man and checking the position of the range ring. Check the tooltip for position numbers, they have the same units as range.

angle can be measured by 'eyeing-off' the projectile as your unit fires, scroll down to look at it side on.

Re: How to make a ballistic weapon arc just a little

Posted: 23 Aug 2011, 08:54
by Forboding Angel
45 degrees isn't just a little. It's quite a bit. But as I originally stated. You would achieve it by increasing gravity or decreasing velocity.

Google, I dunno when the last time you messed with ballistic projectiles was, but the synopsis is this: Lower velocity = more arc (come on, this just makes sense... When you are throwing a baseball as far as you can you don't throw it flat, you arc it so you get more distance, it works the same way in spring).

Increasing gravity is similar to lowering velocity (in effect, you actually are lowering velocity... in a way). But that's all retarded theory of BS bla bla. If you want a faster projectile, then increase velocity and gravity and you will have your arc with a fast moving projectile. The inverse applies, etc etc.

Re: How to make a ballistic weapon arc just a little

Posted: 23 Aug 2011, 13:08
by Google_Frog
Google_Frog wrote:
Forboding Angel wrote:If your ballistic shot is so fast that the trajectory is flat, you slow down the projectile and it will start being fired in an arc. OR You increase gravity on the projectile so that the unit must aim higher to get more distance. My fixes are very right.
This appears to be a misunderstanding stemming from the colloquial phrase 'just a little'. I interpret it that he wants a reduction of value; 'just a little, not a lot'. Whereas you interpreted it as 'just a little more than the current nothing'.

Re: How to make a ballistic weapon arc just a little

Posted: 23 Aug 2011, 15:00
by FLOZi
Getting ballistic weapons to fire exactly (well, so long as map gravity is ~120) at 45 degrees at their maximum range is easy btw.

Code: Select all

local GRAVITY = 120

for weapName in pairs(WeaponDefs) do 
	if WeaponDefs[weapName].customparams then
		if WeaponDefs[weapName].customparams.howitzer then
			WeaponDefs[weapName].weaponvelocity = math.sqrt(WeaponDefs[weapName].range * GRAVITY)
		end
	end
end

Re: How to make a ballistic weapon arc just a little

Posted: 23 Aug 2011, 15:20
by knorke
FLOZi wrote:GRAVITY = 120
Game.gravity?
or does that not work in _post file?

missile/ballistic depends on what you need.
if you just want a slight arc so that tanks can fire over each other when in close formation, I found missiles easier to use.

Re: How to make a ballistic weapon arc just a little

Posted: 23 Aug 2011, 15:31
by FLOZi
knorke wrote:
FLOZi wrote:GRAVITY = 120
Game.gravity?
or does that not work in _post file?.
Bingo, not available at defs loading stage.

Re: How to make a ballistic weapon arc just a little

Posted: 23 Aug 2011, 18:52
by KDR_11k
Just force it with myGravity, keeps maps from fucking with your balancing.

Anyway, cannons in Spring are simulated according to physics and since the bullets are fired at a fixed speed the angle varies according to the target distance. If you want a hightrajectory shot to stay low then slow the projectile down. If that decreases the range then you are asking the impossible from your gun, that it shoots a bullet further than physically possible given the velocity it's fired at. Many games cheat and vary gravity or something to make their shots arc at 45┬░ at any range but Spring isn't designed for that nonsense.

Re: How to make a ballistic weapon arc just a little

Posted: 30 Aug 2011, 17:52
by KingRaptor
Old page by Evil4Zerggin, dunno if it's still accurate.
Weaponvelocity and Range
If a weapon with a ballistic trajectory does not have enough weaponvelocity, it will not be able to hit its listed range.

To hit a target at the same level as the firer, the required weaponvelocity is given as follows:

v >= sqrt(gR)

where v is the weaponvelocity, R is the desired maximum range, and g is the map gravity. If the target is directly above the firer, this becomes

v >= sqrt(2gR)

Map gravity rarely exceeds 150 or so, and most firing points are elevated above surface level, so 150 is generally a good minimum value to use for g.

Weaponvelocity and Firing Angle

More generally speaking, if the firing angle is a, the angle needed to hit a target at the same level as the firer is given by

a = arcsin(gr/v^2)/2

where r is the distance to the target. From this, the following will cause the firing angle to differ more from 45 degrees:
  • Low map gravity.
  • A close target.
  • High weaponvelocity.

Re: How to make a ballistic weapon arc just a little

Posted: 16 Feb 2012, 09:36
by SirDario
KDR_11k wrote:Just force it with myGravity, keeps maps from fucking with your balancing.

Anyway, cannons in Spring are simulated according to physics and since the bullets are fired at a fixed speed the angle varies according to the target distance. If you want a hightrajectory shot to stay low then slow the projectile down. If that decreases the range then you are asking the impossible from your gun, that it shoots a bullet further than physically possible given the velocity it's fired at. Many games cheat and vary gravity or something to make their shots arc at 45┬░ at any range but Spring isn't designed for that nonsense.
Nicely done.
In second thought, if a high powered ballistic weapon fired at its maximum or limit distance that would probably do a curve trajectory on it bullet,right?

Vindicator wrote:Field target cross bows are usually hand-made, often home-made by their users.

Re: How to make a ballistic weapon arc just a little

Posted: 16 Feb 2012, 09:42
by Google_Frog
Idk exactly what you mean so I'll just say a few broad things. Some may be relevant.

A weapon cannot shoot further than it's range. The physical properties (velocity, gravity etc...) have no effect on this fact.

More distance fired = greater fire pitch. Weapon velocity is unchanged, pitch is used to aim between distances.

Projectiles with gravity always curve.