Author Topic: How should I go about simulating gunfire?  (Read 2952 times)

0 Members and 1 Guest are viewing this topic.

Offline redsniper

  • 211
  • Aim for the Top!
How should I go about simulating gunfire?
I'm attempting to make a game... of sorts. Having cracked the mysteries of basic computer coding, I'm now trying my hand at amateur game development and seeing if I can implement some of the ideas I've had over the years. I don't have any delusions of making BEST GAEM EVAR! not even close; I'm just playing around, having fun.

Right now, I'm shooting for a turn-based tactical kind of game (think X-COMish but not nearly so fancy for now) the foolhardiness of which can be discussed later.

I'd like to have the shooting mechanics at least somewhat grounded in reality. Every weapon will have a certain inherent accuracy and every character will have a firearms skill (or several, for different gun types). I'd like to have these, along with range and other factors, affect every shot's chance to hit. At first, I had the shooting skill represent how much the gun wobbled in a person's hands and calculated from there how much area could be hit at so many meters with so many degrees of wobble, then compared this to the size of whatever theoretical target we're trying to hit. This seemed to be excessive and now I'm trying to come up with a simpler system that is still fairly realistic.

I'm now thinking that the skill (ranging from 0 to 100) should represent the base chance to hit at a certain range (100m maybe) and then modify this based on range, whether target or shooter are moving, etc. First things first, how should range affect this? Obviously the chance will be lower the farther away a target is, but would a trained marksman really have that much harder of a time hitting something at 60m instead of 50m? Is there a range at which things become significantly harder to hit?

I'd appreciate your input on this, especially if you have actual shooting experience. I shoot occasionally myself, and know enough about firearms that I can probably talk about this intelligently. :D
« Last Edit: April 04, 2008, 02:00:41 am by redsniper »
"Think about nice things not unhappy things.
The future makes happy, if you make it yourself.
No war; think about happy things."   -WouterSmitssm

Hard Light Productions:
"...this conversation is pointlessly confrontational."

 

Offline Davros

  • 29
Re: How should I go about simulating gunfire?
just do something really simple
like

chance of hit = random number between 100 and skill level
if chance of hit >  90 = a hit)

eg:
skill 70 so chance of hit = random number between 70 and 100
chance of hit > 90 then hit
else
   miss

skill 30 so chance of hit = random number between 30 and 100
chance of hit > 90 then hit
else
   miss

that should be good enough for a turn based game
you could also add other modifiers

 

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
Re: How should I go about simulating gunfire?
Guns - assuming you are talking about 'slug throwers' of any kind - have limits to their accuracy. Starting from quality of the weapon and ammunitions - for example no matter how good marksman you were with good old musket and loosely fitting lead balls hitting a barn size object from 50 m was a success. Then even on higher quality weapons the muzzle velocity (which translates quite directly into 'barrel's length in calibers' and combined with bore size of the weapon into the actual barrel length) and weight of the projectile affect the accuracy as well as the effective range. Same goes with rifling...

As for range.. as long as you are within the effective range of the weapon you shouldn't really think range but more as the size of the target as seen by the shooter. Like hitting a small coin from 3m / 10 feet away can be harder than hitting a man sized target 150m / 500 feet away - simple trigonometry... Of course further away the target more will the environment affect the shot - not to mention target's movement. All just depends on how complicated you want to make it.
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Mika

  • 28
Re: How should I go about simulating gunfire?
Wanderer put some good stuff there, I can tell you about my experiences with guns.

Support of each shooting position is probably one of the major factors in the accuracy, the experience with weapons helps with this. Also, shooter's experience helps taking account some effects by surroundings, like wind. Also, if a target is moving, the better experienced shooter, the better rate of success, but fast targets are damn hard to hit. In close quarters, it is the reaction time which has a significant role, also improved by experience.

The funny thing is that I never seem to be able to hit anything with a pistol, where as with a rifle it is much easier - taking account the maximum effective range with both of them. I suspect it is because I cannot support the pistol too well. So yes, even weapon types count.

Mika
Relaxed movement is always more effective than forced movement.

  

Offline Zoltan

  • 26
Re: How should I go about simulating gunfire?
Guns - assuming you are talking about 'slug throwers' of any kind - have limits to their accuracy. Starting from quality of the weapon and ammunitions - for example no matter how good marksman you were with good old musket and loosely fitting lead balls hitting a barn size object from 50 m was a success. Then even on higher quality weapons the muzzle velocity (which translates quite directly into 'barrel's length in calibers' and combined with bore size of the weapon into the actual barrel length) and weight of the projectile affect the accuracy as well as the effective range. Same goes with rifling...

As for range.. as long as you are within the effective range of the weapon you shouldn't really think range but more as the size of the target as seen by the shooter. Like hitting a small coin from 3m / 10 feet away can be harder than hitting a man sized target 150m / 500 feet away - simple trigonometry... Of course further away the target more will the environment affect the shot - not to mention target's movement. All just depends on how complicated you want to make it.

I agree with the first part. I would also like to emphasize the importance of rounds in determining accuracy. For example: some rounds have very odd flight patterns and thus require quite a bit of thought on where to aim depending on the range.

While hitting the coin may be harder to hit due to trigonometry in theory, from a practical standpoint, it is almost impossible to hit because sights are worthless at close range.
"A child of five would understand this. Send someone to fetch a child of five." - Groucho Marx

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: How should I go about simulating gunfire?
i wish more games had more accurate bullet physics, like drop, and wind deflection as well as velocity loss. then you have better modeling on what happens when the bullet hits, such as fragmentation (hollow points damage more area than would fmj), and effects of armor. when a person is hit by a bullet the bullet creates a cone of damage from the hit point to the exit wound (assuming there is one). what id do is model the locations of vital organs, semi vital organs, and the rest would count as a mere flesh wound. so when a bullet hits id determine the amount of energy it has and its type (each would have different cone and energy loss/cm of flesh parameters). if the cone intersects a vital organ then you get instideath, if it hits a semi vital organ then some damage is issued, perhaps a degrading health effect that lasts till you find a med kit, or loss of some functionality. flesh wounds just subtract from your hitpoints based on the area of the impact cone.

modeling of incendiary and explosive rounds would be cool too. most combat flight sims tend to simulate this properly. cfs2 was pretty good. if an incendiary round thit a gas tank something would explode. but if you hit empty structure nothing would happen (cept maybe an increase of the drag coefficient), hiting control surfaces and the like would result in reduced aircraft performance.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: How should I go about simulating gunfire?
You could consult the US Army statistics on soldier accuracy rates at various positions from various ranges -- maybe that'd provide a good foundation to extrapolate from?

I believe they're available for free online.

 
Re: How should I go about simulating gunfire?
i wish more games had more accurate bullet physics, like drop, and wind deflection as well as velocity loss. then you have better modeling on what happens when the bullet hits, such as fragmentation (hollow points damage more area than would fmj), and effects of armor. when a person is hit by a bullet the bullet creates a cone of damage from the hit point to the exit wound (assuming there is one). what id do is model the locations of vital organs, semi vital organs, and the rest would count as a mere flesh wound. so when a bullet hits id determine the amount of energy it has and its type (each would have different cone and energy loss/cm of flesh parameters). if the cone intersects a vital organ then you get instideath, if it hits a semi vital organ then some damage is issued, perhaps a degrading health effect that lasts till you find a med kit, or loss of some functionality. flesh wounds just subtract from your hitpoints based on the area of the impact cone.

modeling of incendiary and explosive rounds would be cool too. most combat flight sims tend to simulate this properly. cfs2 was pretty good. if an incendiary round thit a gas tank something would explode. but if you hit empty structure nothing would happen (cept maybe an increase of the drag coefficient), hiting control surfaces and the like would result in reduced aircraft performance.

'Mere' flesh wound. Okay. I supposed it is deadly when you've got a bullet shot up your ass.
And this ain't no ****. But don't quote me for that one. - Mika

I shall rrreach worrrld domination!

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: How should I go about simulating gunfire?
soldiers can and will do their jobs while wounded by gunfire. when forest gump got shot in the ass he still managed to save lieutenant dan from the napalm blast. dont you kids watch tv anymore?
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 
Re: How should I go about simulating gunfire?
Well, I guess it still kinda hurts. Now I wanna see you running when someone drives even a handgun bullet up your ass.
And this ain't no ****. But don't quote me for that one. - Mika

I shall rrreach worrrld domination!

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: How should I go about simulating gunfire?
fat chance. but anyone who just got shot in the ass while on the battle field their next bit of business is getting away from whoever is shooting them with the ****ty aim, so they run for cover, or to take out who shot them, and sometimes they just run for the medic and get hosed down with lead on the way over. its basic fight or flight instinct, combined with alot of adrenaline.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 
Re: How should I go about simulating gunfire?
Just go with D&D style To Hit Rolls, always works ;).

 

Offline redsniper

  • 211
  • Aim for the Top!
Re: How should I go about simulating gunfire?
Well, I will basically. I'll generate a random number from 1-100 (d100) then check that against the chance-to-hit (DC). The hit-chance will be modified by range, target size, weapon and character accuracy, shooter and target movement, position (standing, sitting, prone, etc.), scope vs iron sights, and anything else that comes to mind.

Or not, if that all ends up being too difficult. Still, I think it's doable, baby steps and all that. :)
"Think about nice things not unhappy things.
The future makes happy, if you make it yourself.
No war; think about happy things."   -WouterSmitssm

Hard Light Productions:
"...this conversation is pointlessly confrontational."

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: How should I go about simulating gunfire?
Did you check out those tables I recommended? They have just those statistics!

 

Offline redsniper

  • 211
  • Aim for the Top!
Re: How should I go about simulating gunfire?
I can't really find anything like what you're describing. I don't know if it's because my Google-fu is just too weak or what.
"Think about nice things not unhappy things.
The future makes happy, if you make it yourself.
No war; think about happy things."   -WouterSmitssm

Hard Light Productions:
"...this conversation is pointlessly confrontational."

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: How should I go about simulating gunfire?
I think they're on GlobalSecurity.org.

 

Offline redsniper

  • 211
  • Aim for the Top!
Re: How should I go about simulating gunfire?
Ooh, found it. Thanks.
"Think about nice things not unhappy things.
The future makes happy, if you make it yourself.
No war; think about happy things."   -WouterSmitssm

Hard Light Productions:
"...this conversation is pointlessly confrontational."

 
Re: How should I go about simulating gunfire?
LOL I'd just like to point out, for everyone's humor, that I first read this as "How should I go about stimulating[/i] gunfire?"

I was wondering why no one just said "Well, just fly around the big gun in your small ship.  That should do the trick."
Could we with ink the ocean fill, and were the skies of parchment made
Were every stalk on earth a quill, and every man a scribe by trade
To write the love of God above, would drain the ocean dry
Nor could the scroll contain the whole, though stretched from sky to sky!