ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Playing the Game
Vanilla Bullet Sponges? Well, Yes and No

« Previous 10 events | 1 2 | All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  02:02:05  16 September 2015
profilee-mailreply Message URLTo the Top
Max Chill
Super Murderhobo


On forum: 04/28/2014
Messages: 608
We shall await his glorious return.
  13:21:11  7 January 2016
profilee-mailreply Message URLTo the Top
Senior Resident

On forum: 06/15/2007
Messages: 4163
Someone called offizierkoma on Reddit feels he has refuted a claim I've made:

1 - NatVac's points are pretty accurate and there's no point in arguing them but there's one fatal mistake he made.

>> And no, the difficulty setting does NOT determine how often YOUR shots hit the target, It roughly determines how often the NPC shots hit you.

I call bullshit. That's because hit_probability_gd_X is universal, and why is that? Because weapons are working on their own with complete independence from both the Player and the AI. Also, the stats that control probability affect both the Player and the AI. Proof? It's in the engine's source code - - That doesn't satisfy you? Set hit_probability_gd_X to 0 and see what happens.

I disagree, offizierkoma. That bit of source code actually supports my assertions. What follows is an analysis and the application of that analysis to provide proof that you can duplicate at home.

First, let's examine closely the code at the Pastebin site (thanks for linking it). That "engine source code" is a series of excerpts from somewhere. I don't have the source so I'll grant for this discussion that they are from SoC vanilla. The excerpts are like quotes out of context; the parts included are primarily snippets of routines. But I can analyze what's there and draw some conclusions and speculate on more.

The evidence suggests THREE uses of hit_probability: actor, NPC, weapon. I venture that the first one (m_hit_probability in CActor::OnDifficultyChanged()) represents the odds the NPC will hit you, although the code snippets have only the use of a CActor function (probably an encapsulation of the member variable) to prove/disprove that -- and it's not actually used. More on that in a moment.

The second is set by stalker->SpecificCharacter().hit_probability_factor() if stalker is valid -- that is, if the initiator of the shot (the one shooting) is a stalker NPC. Here, hpf is the variable storing that value, but we don't see where it is initialized if the player is the initiator. One guess is 1.0f for the player. And we don't see how hpf is used in this excerpt. ("Bad excerpt! Bad!") It could very well be that it doesn't apply to the actor at all.

I first thought this hit_probability_factor() value might be derived from the first. Standing against that possibility is the existence of two different hit_probability_gd_* value sets, one in config\creatures\actor.ltx and one in config\defines.ltx.

The third, returned by CWeapon::hit_probability() in the Pastebin code, is always m_hit_probability[egdNovice] as set by CWeapon::Load(). The local variable game_difficulty_hit_probability, briefly assigned to actor->HitProbability(), is assigned this new value if there is a weapon for the bullet's weapon_id -- and there logically is a weapon for any bullet (the NPCs don't throw the bullets at you), so the actor's hit_probability_factor() assignment is always overridden. This weapon hit probability value is then used in a calculation (as you'll see) to set the variable ahp, another one whose use is missing from this excerpt.

Note the egdNovice constant, which is always used. In plain language: Master difficulty has nothing to do with this particular "weapon probability", just Novice difficulty. Always. I empirically determined that this is the novice value in config\defines.ltx. (IMPORTANT INFO 1)

Keep in mind that m_hit_probability is a member variable ("m_" is commonly used in C++ to begin member variable names) for the class that uses it. For CActor (the player) it is a single value. For CWeapon, it is an array of values -- see CWeapon::Load().

Based on what is displayed in the Level_bullet_manager_firetrace.cpp snippet, I reasonably extrapolate that fly_dist is how far the bullet has moved from the shooter, with dist denoting the change since the last calculation; dist_factor is the smaller of either 1.0 or the ratio of fly_dist to the maximum distance (Level().BulletManager().m_fHPMaxDist, which implies a generic non-weapon-specific distance, which I'm persuaded is hit_probability_max_dist based on the floating-point member variable's name of m_fHPMaxDist -- and it's under the [bullet_manager] section in weapons.ltx, to boot); and ahf is the product of this dist_factor and 0.20 (default novice difficulty hit_probability) added to (1 - dist_factor). The dist_factor cannot be bigger than 1 per the assignment made if there is a corresponding weapon (and such weapon is a given here), so the value of ahf can vary as follows:

dist_factor -> ahf (calculation shown in brackets)
0.0 -> 1.00 [ 0.0*0.2 + (1-0.0) ]
0.2 -> 0.84 [ 0.2*0.2 + (1-0.2) ]
0.4 -> 0.68 [ 0.4*0.2 + (1-0.4) ]
0.6 -> 0.52 [ 0.6*0.2 + (1-0.6) ]
0.8 -> 0.36 [ 0.8*0.2 + (1-0.8) ]
1.0 -> 0.20 [ 1.0*0.2 + (1-1.0) ]

We see ahf drops from 1 (for a dist_factor of 0) to 0.2 (dist_factor of 1, at vanilla 10 meters). This makes sense to me. I've noted in the past that the odds of the NPCs hitting you are maximum at hit_probability_max_dist and drop off from there.* I'd tested with hit_probability_gd_master = 1.0 and noted the drop-off.

This hit probability value actually starts at maximum for point-blank shots -- the maximum possibly being the odds set by actor.ltx's hit_probability_gd_* (0.20 novice to 0.50 master vanilla) -- and drops off to the config\defines.ltx novice value at hit_probability_max_dist. (IMPORTANT INFO 2) Conjectures: ahf was either an "adjusted_hit_probability_factor", a multiplier which ranges in vanilla from 1.0 (point-blank) to 0.20, or an added_hit_factor for the actual probability factor used somewhere else (conveniently missing from the excerpts).

In any case, it is a component of the calculation and not really "weapons are working on their own with complete independence from both the Player and the AI". I think you simply meant that weapons have their own hit probability. But even then it is just the novice hit probability, and that is only used to determine a logical reduction in hit probability over increasing distance.

Also, the stats that control probability affect both the Player and the AI. Proof? It's in the engine's source code [link elided] - That doesn't satisfy you?

No, we can't infer that proof from the snippets. As we saw above, the one place where the actor's hit_probability value is used, it is subsequently overwritten by the weapon's value. There may be other code using the actor value (I'd expect so), but not here.

I do see the snippet calculations used in the AI's shots at me, but not the reverse (see below).

Okay, that's the code discussion. Next, 1) observation, 2) hypotheses, 3) testing, 4) conclusions.

Every vanilla player has had the experience (1) that their shots don't seem to be doing much. Without really thinking about it, they conclude (4) that the NPCs are bullet sponges, or (4) their shots are disappearing. If the latter, they see code words in the game files like hit_probability and conclude (4) that must be why: their shots have a probability of striking the target.

Technically, with full auto the NPCs really are bullet sponges, as discussed on the "What You Know That Ain't So" page as well as on the first page of this thread. The time_to_aim delay is apparently used to weaken rapid-fire shots after the first, giving the impression NPCs are invulnerable when reeling from that first shot.

But the hit probability belief is just a superstition.

Someone challenges that oft-repeated superstitious jump from 1 to 4 without going through 2 and 3. He investigates as much as possible, adding Lua source evidence to the observation pool. He makes guesses as to what drives these observations (2), makes changes to code and sees the result (3). He quantifies the effects with real measurements of damage (3), sees that the results are consistent and follow the logic given by his guesses (2), correcting and refining based on the results, then retesting. He publishes his conclusions (4) (see the "What You Know That Ain't So" page linked below) and everyone gets in a tizzy, starting threads to vote on whether the conclusions have any merit instead of actually repeating the tests with the provided tools to see for themselves.

Oh, look! Now we have source code we don't understand, but it has hit probability in it, and for weapons, too! Burn him at the stake, for surely the tests must be wrong!

>> Set hit_probability_gd_X to 0 and see what happens.

I did. Thanks to your code reference, this time I tried something I hadn't tried before because it didn't seem to apply: Tweaking a specific hit_probability_gd_novice while playing master.

Even though I'd done this testing long ago, I did go back and recheck it in the Rescue Nimble mission for this discussion, using ranges of values for actor.ltx hit_probability_gd_master (0, 0.01, 0.6), actor.ltx hit_probability_gd_novice (0, 0.24), and weapons.ltx hit_probability_max_dist (0, 1, 10, 50). Normal master gameplay for me involves a lot of sneaking around and using cover, but on [0, 0, 1] I was able to waltz through the compound and shoot the bandits with the silenced Makarov without needing to use a medkit at all. Only shotgun bandits gave me trouble (10 pellets per shot practically guarantee a hit at close range), but in replaying this scenario I easily dealt with them from a distance.

As long as I waited time_to_aim before shooting a bandit, I was deadly. To make the last few tests easier, I dropped in the gamedata.dbb_fps mini-mod to set time_to_aim to zero. In one test I even used the default actor.ltx with 0.50 master hit probability. The bandits barely landed any shots for small values of hit_probability_max_dist, definitely far less than 50%. I had no trouble surviving -- and I had no trouble making headshots. Within the 50-meter range of the pistol, all my shots hit within the crosshairs (enabled for testing).

For the sake of argument, let's consider another hypothesis that perhaps the hit probability does apply to the player while moving or not aiming, and its effect is reduced over time_to_aim seconds to zero impact (that is, no final hit probability as per the previous tests). A simple test of that hypothesis: Set the k_disp multiplier for the pistol's ammo to 0 (perfect weapon accuracy) and actor.ltx's base_disp to 0.0 (no actor component to aiming) before running through the rescue scenario again without gamedata.dbb_fps in play. The crosshair is just a plus sign (+).

Guess what? Instant headshots from the hip up to 50 meters away with the silenced pistol. Not even a hint of any hit probability for me.

Okay, let's go to extremes.


Forget the final nail in the coffin, forget the "nuke from orbit" -- it's time for another use of the Omega-13 device! Let's prove that this code is valid for SoC and put out of our (or at least my) misery this mistaken hit-probability belief with this simple experiment: Combine the (IMPORTANT INFOS 1 and 2) above. Set hit_probability_gd_novice in config\defines.ltx to 0 and set hit_probability_max_dist in weapons.ltx to 0. Play.

You become invisible to enemy bullets, whereas your ability to deal hurt and headshots with your own bullet-based weapons will remain unchanged. The rescue Nimble scenario becomes trivial. Even shotguns pose no threat to you. And guess what -- setting actor.ltx's hit_probability_gd_novice and hit_probability_gd_master to 0 has no effect on your shooting at all.

I believe there is sufficient proof here that my original statement stands as is. Hit probability as discussed here is not "universal". The hypotheses are testable, and the test results are consistently repeatable. The SoC code snippets even serve to corroborate the statements I've made, with the possible minor adjustment that the drop-off might begin immediately and level off at hit_probability_max_dist -- within the bounds of the code snippets; there might be even fewer bullets impacting the player's hitbox as the distance from the shooter grows beyond that.

If you are talking vanilla, I think you are being misled by the time_to_aim value and possibly the accuracy and distance limits on pistols/shotguns. The debug support advantage of the ZRP is that you can actually see what damage you do when you shoot NPCs and mutants -- you can KNOW you are hitting the target and that bullets are not disappearing. Here's a suggested test: Enable show_hit_damage in ZRP's xr_motivator.script. Make a save with an enemy reasonably close. Go full auto on him and note the damage reported. Install gamedata.dbb_fps, start the game again and load that save, go full auto again on him. See how the values are higher just by changing time_to_aim.

Using single-shot mode, aim and shoot at NPCs from a distance with a reasonably accurate weapon (or adjust your game with the ZRP's FPS configuration). The show_hit_damage report will prove to you that you are hitting your target independently of any hit probability setting.

Again (ad nauseam for me if not for you), hit probability does not apply to the player. The variables I mention on the "What You Know That Ain't So" page do.

Thanks again for the source information, offizierkoma. By revealing the illogical use of hit_probability_gd_novice while playing on master, the code helped put this superstition down.

Your second point is good, although it only applies to NPCs and not the player.

tl;dr: The above provides conclusive proof that the game's hit probability settings do not apply to the player. If you disagree, you really should go back and read the reasons why the code is supporting my assertions, not disproving them. There's a simple test you can run to see. Also read the "What You Know That Ain't So" page.

Maybe it's the crosshairs? Many players turn them off -- how do they know if their target is completely within the crosshair marks? Now that's a valid hit probability: Only two-thirds of the bullets fired will hit a target that covers (subtends? encompasses?) only two-thirds of the inner crosshair circle.



If you had waited 6 more days it would have been exactly one year
between the last post made on this thread and your new one today.

Well, more like three days, four hours, twenty minutes.

Okay everyone. Let's all meet back here one year from now when NatVac returns.

I guess my calendar is broken.

Thanks, guys, for reading and learning -- or at least trying to...


*I've mentioned this in multiple places, including the previously-linked "What You Know That Ain't So" page:

and in the ZRP thread, page 131:

  14:37:19  7 January 2016
profilee-mailreply Message URLTo the Top
Don Reba
Bishop and Councilor of War


On forum: 12/04/2002

Message edited by:
Don Reba
01/07/2016 20:52:55
Messages: 11537
I haven't been this impressed since I saw a 150-page thesis on how to add graphics to LaTeX documents.
  22:03:09  7 January 2016
profilee-mailreply Message URLTo the Top
Tejas Stalker
Official Stalker on Facebook


On forum: 05/12/2007
Messages: 22065
Vanilla Bullet Sponges? Well, Yes and No

Hi NatVac~

Offizierkoma ( known on this Forum as Koma ) doesn't really hang out
here ( has about 5 or 6 posts ) so I'm not so sure he will see this post
as a reply to his Reddit post. However maybe you were just replying
to the GSC Forums audience instead so certainly no harm in doing that.

Just one clarification between you and me though...

I said "If you had waited 6 more days it would have been exactly one
year between the last post made on this thread and your new one today."

To which you replied "Well, more like three days, four hours, twenty minutes."

Actually I'm still sticking with the 6 days since I said "the last post..."
( Charcharo: September 18th ) and not "your last post..."

Now I have to go back and read your longer explanation and absorb it.

  07:09:29  8 January 2016
profilee-mailreply Message URLTo the Top
On forum: 08/04/2014
Messages: 12
Well hot damn, I guess I have been proven wrong at one point.

Good analysis you've done there. I'll keep it in mind.
  00:10:25  24 March 2016
profilee-mailreply Message URLTo the Top
Ambrosije Luigevic
On forum: 03/20/2016
Messages: 15
I have to say HET.(NO) Usually I favor sniping than be a new Rambo, and my targets go to find Old Nick very fastly.

I have my own tactics: I bring with me everytime 4 weapons: knife, a pistol, a rifle for sniping put on single shot, and another rifle put in Aut. fire for have an extensive and powerful fire superiority at short ranges.

Actually my weapons of choice are the IL-86 (Sniping) the SGI-5K (fire superiority) and the UDP Compact.
Each word should be at least 3 characters long.
Search conditions:    - spaces as AND    - spaces as OR   
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Playing the Game

All short dates are in Month-Day-Year format.


Copyright © 1995-2007 GSC Game World. All rights reserved.
This site is best viewed in Internet Explorer 4.xx and up and Javascript enabled. Webmaster.
Opera Software products are not supported.
If any problem concerning the site functioning under Opera Software appears apply
to Opera Software technical support service.