Since some of you guys have shown interest in what I'm doing under the hood, I had the idea to post what I did tonight concerning finishing up the "Scatterburst" weapon (which is like a shotgun).

I had the look pretty much how I wanted, but it was still "static" in its damage calculation. The bullet would hit the enemy and do X damage regardless of range. My criteria to finish up the behavior of this weapon, though, was that each bullet would have higher damage and crit chance the closer the target is to you -- Ideally have it so damage is

*really *high if the range is point blank, and rather very low if at the furthest reaches of the bullet's range. The other part of the criteria is it needs to, like all of my other secondary weapons, have its damage tied to the global attribute "special damage modifier", which begins the game at 100. This is so that as you level up, all of your acquired secondary weapons have their characteristics improve just from that one number. They all tie into it in different ways.

To begin, what I did was within the shotgun bullet behavior, create an attribute that goes up by 1 each frame. I then did some tests with the print to see what this number is at at each point in its range to an enemy.

Next it was time to figure out how to incorporate that number into the damage calculation within the enemy's behavior. Upon impact with the bullet, the enemy will get that attribute from the bullet and then tie it into its damage calculation.

As usual, I roll a crit attribute between 1 and 100. I wanted to incorporate the shotgun's range modifier into the crit chance. Through print statement testing I'd determined that the furthest reaches of the bullet would have a modifier of about 25-30, and at point blank it's 1-3 or so. So I multiply that number by 10, such that a point blank impact has a 70% - 100% chance to crit, and the furthest ranges having little or no chance.

Moving on down, we see now that we divide the global special damage mod (which begins the game at 100 and can be raised as you level up) by the range modifier. A non-crit is halved (it's typical for crits to be about double damage in my weapons). For good measure, just so there's always a bit of randomness, I add a small amount at the end of the calculation. Not every damage calculation is the same, but in this case I just wanted a chance to add 0 to 5 damage to the calculation, this makes the max range shots a bit less useless and also keeps the numbers from all being identical when the shotgun blast hits, which makes it more.. fun, I guess.

End result:

http://gfycat.com/SanePitifulCentipede.webmwe see that we get glancing damage at far ranges, and tons of damage and crits at point blank. while the specific number amounts may be edited, and in fact are likely to be as balancing goes, the basic functionality feels pretty good.

Let me know if you have any questions