When making an FPS game, there is something called armor which reduces the damage for the health.
Rain gun damage=100
Result after the raingun damage:
Anyone? I spent hours doing a google search for it but came out empty handed.
I'll respond to this in a more general way, hoping that is what you're looking for, rather than an application specific answer. This is a common problem that a lot of programmers face - you've gotten to the point where you have no problem putting pictures, models, levels on the screen, which always seemed to be the hard part, but is really only the foundation on which an actual game is built.
Most formulae you'll need can be reduced to this form:
f(a) = mx+b
where a = the desired result; m = a scaling constant (possibly a complex one); x = a variable (possibly a random number); and b= an offset. You made need to change the equation to an equality, or a condition (programmatically, of course), such as
if (f(a) \< THRESHHOLD_VALUE), etc., but the principle remains the same.
You might recognize this as the general equation of a line from your pre-calc class. It's a pretty useful formula for a lot of more or less simple problems.
So how does this help you?
Well, if you have a design document, refer to it, and find all of the factors that are used to determine a hit, or damage, or whatever it is your working on.
Don't have design document? No worries, it just takes a little longer, and you probably want to start one - even it only consists, at this point, of comments embedded in your code. Something like this: (just pulling stuff out of thin air here)
// Things that affect the amount of damage taken:
// 1. The state of current armor (as a percentage)
// 2. The angle of fire relative to headon (as an offset percentage)
// 3. Possible ammo modifier (to account for heat seeking missile and grenades)
// 4. The targets evasion skill
// you get the picture by now
Now, you need to decide (it is your game after all) how much of an effect you want each of these factors to have and how you want them to inter-relate. I generally start out simple, test, add complexity, test, add more complexity, test, etc. I put the formula into a spreadsheet or my graphing calculator and run it a few thousand times to make sure I'm getting the kind of numbers I want and tweak until I get what I want.
A couple of tips here are:
Normalize your quantities. I like to use percentages, so I design from the ground up to express as many numbers as possible into this format.
Avoid floating point calclations wherever possible. This may be just becaue I'm old, but I try to keep everything as integers, then format the numbers once to the screen when the appearance of floating point is needed. So, while I might present percentages to the user, I'm really using whole numbers between 1 and 100, and using integer arithmetic - usually just throwing away remainders to keep things neat.
Multiply or Divide by 2 or multiples of 2 as often as possible - thus bonus and penalties tend to be 50%, 25%, 12.5%, 6.25%, etc (repeated division by 2). This is easier on the CPU because it is simply a right shift or a left shift operation.
So, to show a simple example, your formula might look like this
damage = AMMO_TYPE * ((Armor/2) + (angle mitigation) + luck_factor))
Using the general formula I gave you above, you can see the correspondence:
m = ((Armor/2) + (angle mitigation) + luck_factor))
x = Ammo_type
b = distance_factor (we're adding a negative number).
And my dad always said I would never use any of that math in real life.
Hope this helps.