Home » MODDING HQ 1.13 » v1.13 Modding, Customising, Editing » v1.13 Time Capsule (How-to Library) » New Chance To Hit system - The Formula
New Chance To Hit system - The Formula[message #250989]
|
Wed, 05 May 2010 19:55
|
|
Headrock |
|
Messages:1760
Registered:March 2006 Location: Jerusalem |
|
|
Given that I have already written much of the system down, I figured it would be a good time to reveal the formula itself - how CTH and shooting would be calculated in the new system.
Hopefully, by doing so you might be able to reveal problems I haven't spotted or thought of. In-game, of course, the only feedback we get is the final result, so spotting problems just by playing would be somewhat more difficult, which is where this formula comes in handy.
Also, disclosing this formula will make it easier to play with the INI variables that will be supplied with the new system. If you know what factor comes in where, you'll have a better understanding of how to change it and by how much.
Several notes before I begin:
1. This is written in Pseudo-code like all my other articles. You don't have to understand C++ to read this, but you do have to understand basic maths and logic. That's just how these things go.
2. Any variable shown in CAPITAL LETTERS (like "NORMAL_SHOOTING_DISTANCE") is an externalized coefficient. They are placed in the INI and thus are fully tweakable. They almost always act as a sort of multiplier to some part of the formula. You'll understand once you see them.
3. The default values of the externalized coefficients is given in parenthesis, so for instance you will see "NORMAL_SHOOTING_DISTANCE(70)", meaning that the current default value is 70. Since these are fully externalized, testers will be able to change these variables as they see fit, and the values here are not by any means final - just the ones I'm using right now - and aren't guaranteed to be anywhere balanced.
4. Most coefficients are treated as FLOATs, meaning that they can take a decimal point. This is not always shown in the pseudo-code just because I'm lazy.
-------------------------------------------------------
<font size="">CALCULATING BASE CTH</font>
Base CTH is a free amount of CTH given to the character with ANY shot with the same weapon. The initial value is based primarily on skills. After that is calculated, all conditional factors like injury are summed up together and the final result used as a percentage to modify Base CTH.
Base CTH mainly represents the amount of CTH you'll have when taking shots without extra aiming. It is supposed to represent pulling the trigger when the gun is aimed in the general direction of the target, but no time has been spent making sure that the muzzle is actually pointing towards the target itself.
Experience = Shooter's_Experience_Level * 10 * BASE_EXP_LEVEL(3)
Marksmanship = Shooter's_Marksmanship * BASE_MARKS(1)
Wisdom = Shooter's_Wisdom * BASE_WISDOM(1)
Dexterity = Shooter's_Dexterity * BASE_DEXTERITY(1)
Base_CTH = (Experience + Marksmanship + Wisdom + Dexterity)
As you can see, the most important part of the calculation so far is Experience Level, which counts as three times as much as the other skills. That's because we're only calculating a rudimentary aim level which hasn't yet employed precision aiming at all. It's just the shooter's ability to place the gun nearer the target center in a "snap shot" situation, and hence benefits more from the shooter's experience than things like marksmanship.
Divisor = BASE_EXP_LEVEL(3) + BASE_MARKS(1) + BASE_WISDOM(1) + BASE_DEXTERITY(1)
Base_CTH = Base_CTH / Divisor
The divisor is used here to return the sum of all skills into a range of 0-100. This is similar to averaging the skills, but taking into account the fact that some are (or can be) more important than others. We use the coefficients in a way that modding the importance of any skill would still result in a 0-100 final range.
Base_CTH is divided by 3.
This gives us a final range of 0-33. We don't want shooters who are 100% accurate with base shots, ever. Of course, at very close distance, a value of 30% would mean that the shooter stands a very good chance to hit the target even without any extra aiming involved. This would be great for pistols or burst-fire weapons, which would be very useful at close range.
Assuming no bad conditions apply to the shooter (see below), the average merc should have around 15-20 base CTH. As mercs gain experience, this should increase considerably.
Base_CTH is increased by Weapon's_Base_CTH_Modifier
Weapon's_Base_CTH_Modifier is calculated from the weapon itself and its attachments. This is a flat modifier to Base CTH. I'm not sure which weapons or attachments should give such a bonus, but it's possible. Note that this allows weapons to go past the 0-33 range. It can't go below 0 however, in cases where the weapon/attachment lower the Base CTH for any reason.
Calculating the Base Modifier
Now we've got the preliminary value for Base CTH, and we start calculating the various factors that will affect it. These are added together into a separate final number, which is then used as a percentage to modify our Base CTH. The order in which these are added is largely irrelevant, but I'll write them here in the same order I have them written in the code.
"Base_Modifier" will be used as the final sum of all bonuses/penalties.
If Shooter's_Morale is greater than 50, then
Morale_Modifier = (Shooter's_Morale - 45) / 10
Base_Modifier is increased by (Morale_Modifier * BASE_HIGH_MORALE(2))
Else if Shooter's_Morale is lower than 50, then
Morale_Modifier = (Shooter's_Morale - 50 ) / 2.5
Base_Modifier is increased by (Morale_Modifier * BASE_LOW_MORALE(-1))
Morale greater than 50 gives +2 points for 55 morale, +4 points for 65, +6 for 75, etcetera.
Morale lower than 50 gives -1 points for 47 morale, -2 for 45 morale, -3 for 42 morale, etcetera.
The difference between how low and high morale are used really isn't my fault - it's using the program's Morale Calculator formula which takes into account the fact that NPCs have a different sort of morale from player characters. Can't be helped unless I rewrite that formula to make more sense.
If Shooter is a Psycho, then
Base_Modifier is increased by BASE_PSYCHO(-3)
Note that when a coefficient is negative, like BASE_PSYCHO is in this code, then Base_Modifier is actually DECREASED. Testers will of course be able to change that into a positive coefficient if they feel it's necessary. I personally don't think psychos should be MORE accurate than anyone else - in fact they're more likely to shoot more bullets randomly at the target...
If shooting at the same target in the same tile, then
Base_Modifier is increased by BASE_SAME_TARGET(5)
This only happens when shooting at a target that hasn't moved since the last time you shot at it. Also, if the shooter moves, this bonus disappears. Shooting at the same tile twice also gives this bonus, whether or not the same target is standing there (or any target at all).
If Shooter's_Current_Health is below 100, then
Base_Modifier is increased by (Bleeding_Injuries * BASE_INJURY(-30)) / Max_Life
Base_Modifier is increased by ((Bandaged_Injuries * BASE_INJURY(-30))) / Max_Life / 3
We use injury as a percentage here. If our merc has 50% bleeding injuries compared to his own maximum health value, he gets half the penalty, which would be -15 points. It's impossible to get the full -30 point penalty of course, since that would mean the shooter is dead (100% bleeding injuries).
Note that bandaged damage is only 1/3 as powerful as bleeding injuries.
Base_Modifier is increased by (BASE_FATIGUE(-15) * Shooter's_Breath) / 100
Breath is also used as a percentage. If the shooter has 50 breath points (half the maximum for all mercs), he gets half the penalty: -7.5 points.
If Shooter is Tipsy, then
Base_Modifier is increased by BASE_DRUNK_TIPSY(-5)
If Shooter is Drunk, then
Base_Modifier is increased by BASE_DRUNK(-20)
If Shooter is Wasted, then
Base_Modifier is increased by BASE_DRUNK_WASTED(-50)
If Shooter is Hung-Over, then
Base_Modifier is increased by BASE_DRUNK_HUNGOVER(-10)
Drunkness really affects base CTH, as you can see. Each level of drunkness has its own coefficient, so you can play with the values as you see fit.
If Shooter is in gas without a gas mask, then
Base_Modifier is increased by BASE_GASSED(-50)
Gas makes it REALLY difficult to shoot straight - it'll kill half our Base CTH.
If Shooter is being bandaged by another merc, then
Base_Modifier is increased by BASE_BEING_BANDAGED(-5)
I've decided not to apply a great penalty on being bandaged, at least not nearly as great as it was in the old system.
If Shooter has any Suppression Shock, then
Shock_Modifier = (Shooter's_Shock * 100) / Maximum_Shock
Base_Modifier is increased by ((Shock_Modifier * BASE_SHOCK(-150)) / 100)
This is Shock from suppression (though severe injuries can also add shock for a few turns). As you see, the maximum possible penalty from this is a whopping -150, but this is only achievable by complete noobs under very heavy suppressing fire - they won't get any Base CTH. Maximum Shock is around 30 (depending on your HAM INI settings), and as a shooter gets more experience and morale and so forth, it's likely that his actual limit would be much lower. Still, a few shock points can be very powerful, delivering -5 points each.
Height_Modifier = Calculate Height Difference.
If Height_Modifier is lower than 0, then
Height_Modifier = 0.
Base_Modifier is increased by ((Height_Modifier * BASE_SHOOTING_UPWARDS(-15)) / Range_to_Target)
This is a little more complex. First we determine the difference in height between the elevation of the gun and the point we are aiming at.
For shooter elevation:
STANDING:
Shooter_Height = 3
CROUCHED:
Shooter_Height = 2
PRONE:
Shooter_Height = 1
For target elevation:
LEGS:
Target_Height = 1
TORSO:
Target_Height = 2
HEAD:
Target_Height = 3
In addition, Target_Height is increased by 3 points if it is on the roof.
Basically, this means that shooting from prone stance at a target's head counts as two Height Difference points. Shooting from standing stance to the torso of a character on the roof counts as one Height Difference point. And so on.
Shooting DOWNWARDS is not affected at all. The penalty only exists when pointing the gun upwards, which is much more difficult than shooting straight or down due to the uncomfortable angles it involves.
Also note that the penalty is divided by Range_to_target, so it is strongest at close range and gets considerably weaker as we go past 10 or so tiles. Shooting at a target on a roof 10 tiles away is almost the same as shooting straight ahead, really.
Target_Skill_Modifier = either Target_Experience_Level or Target_Agility, whichever is higher.
Base_Modifier = (Target_Skill_Modifier * BASE_AGILE_TARGET(-5)) / 100
This is somewhat of a relic inherited from the old CTH system. Basically it means that a target can anticipate shots and duck out of the way. I'm not too fond of this, since it's hard to properly model it on how it would work in real life. If you don't like it, just set BASE_AGILE_TARGET to 0, and the penalty's gone. You can see I've set it pretty low to begin with - only targets with 100 experience or 100 agility will give the full -5 point penalty anyway.
If Target is not within visual range, then
Base_Modifier is increased by BASE_INVISIBLE_TARGET(-100).
An invisible target reduces the modifier by 100 points. If you can't see the target, rudimentary aim is going to be rather inaccurate. Remember of course that extra aiming _CAN_ make up for this, and also that 0% CTH (even WITH aiming) doesn't mean you're going to miss the target. It really depends a lot on distance.
If Shooter is an enemy combatant, then
If Difficulty Level is NOVICE, then
Base_Modifier is increased by BASE_DIFFICULTY_NOVICE(-30)
If Difficulty Level is EXPERIENCED, then
Base_Modifier is increased by BASE_DIFFICULTY_EXPERIENCED(0)
If Difficulty Level is EXPERT, then
Base_Modifier is increased by BASE_DIFFICULTY_EXPERT(20)
If Difficulty Level is INSANE, then
Base_Modifier is increased by BASE_DIFFICULTY_INSANE(50)
Enemy combatants do cheat at higher difficulty levels. This is also a relic from the old CTH system, and again you can now mess with the coefficients if you don't want them to. At Experienced difficulty, they get no bonus. At INSANE difficulty, they are 50% more accurate (with their Base CTH).
Gun Handling
This is almost a separate part of the formula, and a very important one overall. This part calculates how hard it is to prepare the gun for shooting, and how hard it is to hold the gun steady. It's represented by the Gun Handling value, and takes into account several important conditions.
Please have patience while reading this - the Base_Modifier will not be adjusted until the VERY END of this formula!
Gun_Handling = Gun's AP_to_Ready cost, with all modifiers applied from attachments
Gun Handling is based primarily off the gun's Ready Costs. That value already takes into account a lot of things about weapon handling, so it stands to reason that it should be used here. At least in 1.13, StarWalker's done a good job with these, so they already correlate directly to the size, weight and shape of the gun.
Now we start modifying this value based on various conditions.
If shooting two guns at the same time, then
Two_Guns_Modifier = BASE_TWO_GUNS(3.5)
Two_Guns_Modifier is decreased by 1.
For each level of AMBIDEXTROUS, do:
Two_Guns_Modifier is divided by 2.
Two_Guns_Modifier is increased by 1.
Gun_Handling is multiplied by Two_Guns_Modifier
By default, shooting two guns is 3.5 times more difficult than each gun on its own. Ambidextrous mercs reduce this to 2.25 times more difficult. Note that this system opens the way to having mercs with two levels in the ambidextrous trait, where these "expert" ambi's will get only about 1.62.
The trick I did there with decreasing by 1 and increasing by 1 later is only for making sure that Ambi mercs don't shoot EASIER with two hands than with one, regardless of the value of BASE_TWO_GUNS. It's just math wizardry, so ignore it if you don't get it.
If shooting a one-handed gun with only one hand, then
Gun_Handling is multiplied by BASE_ONE_HANDED(2)
A gun fired with just one hand is half as easy to handle as a gun fired with both hands. This happens when a one-handed gun, like a pistol or small SMG, is fired while the other hand is holding a non-gun item.
If shooting a "Heavy Weapon", then
Heavy_Weapon_Modifier = BASE_HEAVY_WEAPON(2)
Heavy_Weapon_Modifier is decreased by 1.
For each level of HEAVY WEAPONS, do:
Heavy_Weapon_Modifier is divided by 2.
Heavy_Weapon_Modifier is increased by 1.
Gun_Handling is multiplied by Heavy_Weapon_Modifier
Once again, math wizardry. A normal merc would find a Heavy Weapon twice as hard to shoot. HEAVY WEAPON skill reduces this to 1.5, and EXPERT HEAVY WEAPON reduces it to 1.25. Note that I'm not terribly sure about the values here, because most heavy weapons are already going to have a massive Gun Handling due to their inherently high AP_to_Ready value.
STANDING:
No modifier.
CROUCHING:
Gun_Handling is multiplied by BASE_CROUCHING_STANCE(2)
PRONE:
Gun_Handling is multiplied by BASE_PRONE_STANCE(3)
Stance influences how easily we can handle our guns. Note that since we are calculating Base CTH - the amount of CTH we get for a "snap shot", we actually suffer for crouched and prone stances. Of course, these stances will benefit more when adding Extra Aiming levels. In other words, for quick fire you want to stand up, and for aimed fire you want to get down.
If PRONE and using a Bipod, then:
Gun_Handling = (Gun_Handling * (100-Bipod_Bonus)) / 100
I'm not yet sure how to make Bipods work as far as XML tags and all that. But I do know that this is how they are going to affect gun handling. In other words, a bipod with perfect balancing (100) will eliminated Gun Handling completely, regardless of the size and weight of the gun. A bipod with 10 points will only reduce Gun Handling by 10 percent.
And finally:
Base_Modifier is increased by (Gun_Handling * BASE_GUN_HANDLING(-2))
This is where Gun Handling finally affects our base modifier. We lose two points from the modifier per Gun Handling point. At this point a pistol used with two hands while standing up gives the lowest penalty. A Sniper Rifle or Heavy Weapon while prone gives the worst penalty, could be up to -40 given the (-2) coefficient.
Final calculation
Now that Base_Modifier is all calculated, we can apply it to our Base CTH. This is done as a percentage:
Base_CTH is increased by ((Base_CTH * Base_Modifier) / 100).
If Base_Modifier was a negative number, which it usually is, then Base_CTH is decreased by that amount. For instance, -20 Base Modifier gives a 20% reduction in Base CTH. If the modifier was positive, that's an increase. For instance, 5 Base_Modifier gives a 5% increase in Base CTH.
What does it mean?
As mentioned previously, Base CTH is a free amount of CTH given for every shot with the weapon. Of course, it really depends on what weapon, what stance, and other factors as shown above. It will normally be between 0-30, while VERY skilled shooters can go higher than that, but not by much.
What this basically means is a 0-30% decrease in Muzzle Sway. At 0, muzzle sway is as large as possible, by default 22.5 degrees to either side of the target. At 30, muzzle sway is 30% smaller than the maximum, giving an angle of about 18 degrees to either side.
Of course, most shooters will want to add extra aiming points to improve their aim. This is pretty much essential for hitting targets more than a couple of tiles away. That's when we go into aiming CTH territory, as will be explained shortly.
(To be continued)
[Updated on: Mon, 22 June 2020 04:03] by Moderator Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Tue Sep 17 02:26:07 GMT+3 2024
Total time taken to generate the page: 0.00933 seconds
|