Infection chance details and mechanics. Looking deep into the code's eyes.
3 3

43 posts in this topic

Recommended Posts

So I ve been trying to find definitive answers to a few infection questions, but I only found quotes and sayings with no 100% certainty, so I started digging through the Project Zomboid code and here are my findings.

 

All of the game mechanics in this thread are true as of version 39.67.5 (No changes from 38.30)

 

Spoilers here to avoid huge wall of text. Read the TL;DR if you dont care about details:

 

Spoiler

 

I ve put some very simple and modified code below with comments so hopefully the flow can be understood.

 


//This is a comment, not code. Its a comment because it starts with //. Simple enough.

//    An indentation/tabulation in the code, like this, means that this code only gets run if the previous "if" condition is true.

 

//So you got hit by a zombie and received some damage, but now you are wondering if you also got infected. 
//From here on, the game code calculates if you are screwed.


bitten = false
scratched = false

//Right now, you are neither bitten nor scratched from this hit. Things look bright, but that is going to end soon.

 


baseDefensePercentage = 75;     //The higher, the better, but by default
                                // you have this 75 "defense" so to speak.
if (player has thickSkin Skill)
    baseDefensePercentage = 85
if (player has thinSkin Skill)
    baseDefensePercentage = 65

ExtraGuardPoints = PerkLevel.BluntGuard
if (player wields blade weapon in primary)    //If using a blade, Blunt Guard level gets
    ExtraGuardPoints = PerkLevel.BladeGuard   // replaced with Blade Guard level.

baseDefensePercentage = baseDefensePercentage + ExtraGuardPoints

//The skill "(Blunt/Blade) Guard" subtracts -5 to baseDefensePercentage at level 0, up to adding +7 at level 10.

 


randomNumber = Number from 0 to 99    //This is the first random number that decides some of your fate

//Now, based on your calculated defense chance, it checks if the zombie left some kind of mark on your body:


if randomNumber > baseDefensePercentage    //If you have no Blunt/Blade Guard perk or thin/thick skin, the 
                                           // chance of this being true is 29%, which is not too bad.
                                           // With both thickSkin and bluntGuard 10, its a 7% chance.
    
    //If the above its true, you were marked by the zombie, sucks to be you.
    newRandomNumber = Number from 0 to 99   //Second random number that decides your fateful fate.
    
    if (newRandomNumber > 75)   //This means it has a 24% of being true.
        bitten = true       //Soon to be dead. This plays a unique "bitten" sound and leaves a pool of blood.
    else
        scratched = true    //Maaaaybe not dead. This plays a unique "scratched" sound.

        
//Now you may be wondering... how much chance do I have of dying after being bitten or scratched?


//From being scratched
default = 25% deadly infection
With thick Skinned Skill = 12% deadly infection
With thin Skinned Skill = 40% deadly infection

//And about dying from bites...


100 FUCKING PERCENT CHANCE  //No way of avoiding this


//So thickSkinned does protect against scratches, and even bites due to the lower percentage of getting marked at all with it.

 

//FIN


So you are a normal boy/girl in town, doing your thing, and a zombie comes out of nowhere and hits you. What are your chances of eventually dying?

 

 * Default character *
Getting deadly scratched: 5.51%
Getting deadly bitten: 6.96%
Total death chance: ~12.5%

 

 * Default character, max Blunt/Blade Guard *
Getting deadly scratched: 3.23%
Getting deadly bitten: 4.08%
Total death chance: ~7.3%
 
 * Thick skinned *
Getting deadly scratched: 1.7328%
Getting deadly bitten: 4.56%
Total death chance: ~6.3%

 

 * Thick skinned, max Blunt/Blade Guard *
Getting deadly scratched: 0.6384%
Getting deadly bitten: 1.68%
Total death chance: ~2,3%


Each zombie hit has the same chance, so practically speaking its like virtually rolling a dice for each hit, based on those chances.

 

Supposedly, if you immediately check the health panel and your scratched body part says "Infected" and it werent before, then you have the deadly zombie infection (but honestly Im not 100% sure of this), unless you are Hypochondriac, in which case it might be fake. But then again, you need medical skills to see the "Infected" status sooner, so not being infected does not mean you are on the clear. 


Also, let me reiterate that once you are bitten, you are 100% terminally infected.

 

Setting up options in sandbox mode like "Transmission: None", completely avoids getting infected. "Infection mortality: Never" makes it so you get the same chances of infection, but once infected it shouldnt reduce health from the infection itself. You will still lose health from other moods related to the infection though.

 

 


TL;DR
By default: Bites are 100% deadly. Scratches are 25% deadly. Both Thick skin and Blunt Guard skills (Blade Guard if wielding a blade weapon) adds in avoiding bites and scratches, and Thick skin further reduces the probability of a deadly scratch. Thin skin worsens everything.

 


 

More game mechanics:

 

 



If someone has suggestions, questions about parts of code and such, or found any errors/things I might have overlooked, feel free to post or msg me about it and I ll do my best to check.

Edited by Damntry
Check for code changes in new version

Share this post


Link to post
Share on other sites

So, if blade guard doesn't help against scratches n shit, what exactly does it do? Also, thank you for being someone the community can reach out to if they have some questions about the game code but are not of the lua inclined persuasion. If you could take a look at engine loudness, and find out how many units of engine loud would produce 10 or 20 meters, or, if engine loudness even works like that at all, that'd be great. The way the zomboids react to a running car is just... odd, n I've been wondering about how it works.

Share this post


Link to post
Share on other sites
5 hours ago, TheZombiesPro115 said:

So, if blade guard doesn't help against scratches n shit, what exactly does it do? Also, thank you for being someone the community can reach out to if they have some questions about the game code but are not of the lua inclined persuasion. If you could take a look at engine loudness, and find out how many units of engine loud would produce 10 or 20 meters, or, if engine loudness even works like that at all, that'd be great. The way the zomboids react to a running car is just... odd, n I've been wondering about how it works.

 

Blade guard works the same as Blunt guard, except it acts only when you have a bladed weapon equipped.

I forgot to add that, I ll edit the main post, thanks!

 

About engines, right now I only have the code from the current live version which has no vehicles, so I cant answer that.

Edited by Damntry

Share this post


Link to post
Share on other sites

Know if a scratch if of the deadly type ? Check your health menu after being treated of any DoT wounds types (bleeding mostly) and w/o any health regen buff (food mostly).

 

If it's a fatal scratch, the health bar drop (slowly and regularly) ; it can't be stopped and kill you eventually (except if you can keep some of HP regen buff up constantly). That's said w/o Hypocondriac flaw (2 pts for that crap one is far way to low).

Edited by agreubill

Share this post


Link to post
Share on other sites

great stuff :)

 

does the "lucky" trait affects the "randomNumber" outcome? (not in tzhis code but maybe in an other code were it might say somethink like "randomNumber always +/- 5"?

 

EDIT: sorry, I have absolutly no idea of coding so it might be a silly question :oops:

Edited by King-Salomon

Share this post


Link to post
Share on other sites
58 minutes ago, agreubill said:

Know if a scratch if of the deadly type ? Check your health menu after being treated of any DoT wounds types (bleeding mostly) and w/o any health regen buff (food mostly).

 

If it's a fatal scratch, the health bar drop (slowly and regularly) ; it can't be stopped and kill you eventually (except if you can keep some of HP regen buff up constantly). That's said w/o Hypocondriac flaw (2 pts for that crap one is far way to low).

 

That is true, good point. Im still pretty new to the game so most of my knowledge just comes from what I observe from the code.

 

38 minutes ago, King-Salomon said:

great stuff :)

 

does the "lucky" trait affects the "randomNumber" outcome? (not in tzhis code but maybe in an other code were it might say somethink like "randomNumber always +/- 5"?

 

EDIT: sorry, I have absolutly no idea of coding so it might be a silly question :oops:

 

Lucky:

  • Decreases by 5% the chances of failing a repair.
  • Each type of container has a predetermined table of a number of items, with its rarity. When the game fills a container, Lucky adds a ~10% probability for each item to spawn in it. So not only it increases the probability of getting more rare loot, it also increases loot quantity.

The opposite is true for unlucky.

Share this post


Link to post
Share on other sites

The only problem I have here is that I've survived a bite. I don't have the save file to prove it anymore, but I actually had a survivor survive two bites once.

 

Never have I even survived a bite once before then, or since. But back in build, I dunno, 34 or so, I had a character survive two bites.

 

Interesting, no?

Share this post


Link to post
Share on other sites
16 hours ago, FireOnAsphalt said:

The only problem I have here is that I've survived a bite. I don't have the save file to prove it anymore, but I actually had a survivor survive two bites once.

 

Never have I even survived a bite once before then, or since. But back in build, I dunno, 34 or so, I had a character survive two bites.

 

Interesting, no?

 

It would mean that once you get infected with the zombie variant, you can cure yourself somehow. Im going to check if there is something about removing the bite effect. 

 

Did you have to stay with the infection for a very, very long time?

Share this post


Link to post
Share on other sites
17 hours ago, FireOnAsphalt said:

The only problem I have here is that I've survived a bite. I don't have the save file to prove it anymore, but I actually had a survivor survive two bites once.

 

Never have I even survived a bite once before then, or since. But back in build, I dunno, 34 or so, I had a character survive two bites.

 

Interesting, no?

In Sandbox (also MP server), there's an option that disable totally zombinfection. It's the only way in Vanilla (beside a bug) to survive a bite (some mods may allows it).

Share this post


Link to post
Share on other sites

An interesting find though, there is a variable called BiteTime (and ScratchTime). While BiteTime > 0, you take extra health damage and the wound gets more infected. 

BiteTime starts decreasing very slowly while the part is bandaged, until it reaches 0.


Having zero BiteTime eventually removes the Bite and infection from the body part, though the zombie infection is still in your body. This zombie infection keeps sapping your life away, forever.

 

No idea on how long to reach zero BiteTime though, but having Fast Healer decreases the time needed. I tried making a very rough and dirty calculation and got, at best, around 15 minutes real time, but Im sure that must be completely wrong. Maybe I ll try getting a good number later but that requires far more time than Im willing to commit.

 

 

Another thing I found. The setting "Infection Mortality" doesnt seem to change anything unless you set it to "1-2 weeks" (reduces infection damage by a huge quantity) or "Never".
Theoretically, there is no fixed limit and you could live with a zombie infection beyond 3 days by overeating. Can anyone confirm this in practice?

Edited by Damntry
Better formatting and clarification

Share this post


Link to post
Share on other sites
6 hours ago, Damntry said:

 

 

 

Quote

 {snip}

...you could live with a zombie infection beyond 3 days by overeating. Can anyone confirm this in practice?

Yes, but you have to keep stuffing your face with food. I did I one time until I just gave up because I was eating all my food. :)

 

Hmm can't seem to delete that first quote box with my limited mobile skills... Oh well.

Edited by SlightlyOff
streamlining effort failed

Share this post


Link to post
Share on other sites
14 hours ago, SlightlyOff said:

Yes, but you have to keep stuffing your face with food. I did I one time until I just gave up because I was eating all my food. :)

 

Stuffing yourself to death seems like a good way to die.

Share this post


Link to post
Share on other sites

Panic mechanics I checked for a friend, I dont have specific numbers this time though. I pulled a bit more data:

 

Effects of Panic:

 

  • Panic ranges from 0 (No panic) to 4 (Max panic).
  • Cant sleep.
  • Increases reload time.
  • Reduces a bit of visibility at max panic.
  • Reduces hit damage by a small amount. Only noticiable on weapons with low damage, since the reduced value is not % based.
    • Reduces melee damage for each level of Panic (from 2 to 4), cumulative for each level.
    • Reduces ranged damage for each level of Panic (from 3 to 4), cumulative for each level. Only affects players with Aiming skill under level 6.
  • Increases knockdown chance on weapon hit, by at least 13% for each panic level.
  • Increases the heartbeat sound (Can be lowered in settings).
  • Eliminates boredom when you reach any panic level (guess it makes sense).
  • Panic increases based on the number of zombies around. Cowardly doubles this, Brave reduces it by 70%, Desensitized (Veteran) eliminates it. There are more causes of panic that those perks do not cover though, like invasions and sleeper zombies, but zombie numbers is the main one.
  • (Needs testing Tested by TheLeonBM, seems its not happening) When you open a window, at high levels of panic it smashes it instead.


Panic goes away faster based on the amount of months you survive, up to 5.

Edited by Damntry
Added numbers and detail, and fixed a couple errors

Share this post


Link to post
Share on other sites
13 hours ago, Damntry said:

Panic mechanics I checked for a friend, I dont have specific numbers this time though:

 

Effects of Panic:

  • Cant sleep.
  • Increases reload time.
  • Reduces a bit of visibility, at max panic.
  • Reduces a bit of damage dealt with melee.
  • Reduces knockdown chance with each panic level.
  • Increases the heartbeat sound (Can be lowered in settings).
  • Panic increases based on the number of zombies around. Cowardly doubles this, Brave reduces it by 70%, Desensitized (Veteran) eliminates it. There are more causes of panic that those perks do not cover though, like invasions and sleeper zombies, but zombie numbers is the main one.
  • (Needs testing) When you open a window, at high levels of panic it smashes it instead.
  • Eliminates boredom when you reach a certain panic level (guess it makes sense).  


Panic goes away faster based on the amount of months you survive, up to 5.

 

My char I run on my server has Cowardly, Agoraphobic and Claustrophobic, so I'm in constant extreme panic, and I can say a few things: boredom doesn't go away, it still behaves pretty much the same. The window thing doesn't happen,  or at least I was lucky enough to not ever experience it in hundreds of hours. The knockdown reduce must be minimal, cause I'm  a knife user and I'm constantly knocking zeds back pretty consistently, so If it does happen, is not big enough to make a difference, same with damage (I've used most weapons while in extreme panic and I've not noticed an efficiency difference in terms of damage).

The other things do happen like stated: you can't sleep, cowardly increases depending on number of zeds that are somewhat close to you, visibility suffers quite a bit at max compared to no panic at all, reload time does increase quite a bit, and the heart sound last as long as your panic and increases the sound level depending on how panicked you are.

 

About panic going away faster I can't really say, since I always played with chars either in constant panic or almost no panic at all.

 

Don't know if It's relevant to the discussion, but any state of panic (no matter how extreme) can be temporarily nullified by getting drunk or taking beta blockers, but the more in panic you were the less the effect lasts.

 

Also keep in mind this is all mp, maybe in sp behaves differently. I stopped playing panicked chars in sp after a bug with agoraphobic that has to be adressed (around build 36), so maybe some of this is outdated.

Edited by TheLeonBM

Share this post


Link to post
Share on other sites
7 hours ago, TheLeonBM said:

...The knockdown reduce must be minimal, cause I'm  a knife user and I'm constantly knocking zeds back pretty consistently, so If it does happen, is not big enough to make a difference...

Looking for clarification here. Knockdown and knockback are different things. Knockdown where they fall down on the ground crying for an afterlifelong relationship with my boots where knockback is when they stumble back from a hit or push. You said knockdown is minimal because you are getting knockback while panicked. (What was your character's strength?) Just curious for some clarification.

Share this post


Link to post
Share on other sites
4 minutes ago, SlightlyOff said:

Looking for clarification here. Knockdown and knockback are different things. Knockdown where they fall down on the ground crying for an afterlifelong relationship with my boots where knockback is when they stumble back from a hit or push. You said knockdown is minimal because you are getting knockback while panicked. (What was your character's strength?) Just curious for some clarification.

 

Sorry my bad, I mixed the terms, I was referring to knockdown, though it doesn't seem to affect knockback either. I don't use strength modifiers, so the base amount. 

Share this post


Link to post
Share on other sites

Cool. That's what I figured. It might just be a minor effect that doesn't change too much unless you have other mitigating qualities (low strength, exhaustion, low blunt/blade skill...hmm, actually I don't even know if that affects knockdown/back chances.)

Share this post


Link to post
Share on other sites

I just updated the panic post with a bit more info.

 

I was completely mistaken and it doesnt reduce knockback, it actually increases it by a large sum. So the more panicked you are, the easier it is to make a zombie fall down. Im going to test this out because it sounds too good to be true.

 


 

Made an Agoraphobic on easiest difficulty with no extra traits, and tested with over 50 baseball hits at max panic outdoors, and no panic with beta blockers, avoiding to charge the bat swing (since it increases the knockback chance).

 

At max panic it knocked down 100% of the zombies hit.

At zero panic it knocked down less than 25% of the zombies hit.

 

It may seem like a huge difference but its partly because of the difficulty. There are other factors. This just serves to demonstrate it works that way in practice.

 

9 hours ago, TheLeonBM said:

My char I run on my server has Cowardly, Agoraphobic and Claustrophobic, so I'm in constant extreme panic, and I can say a few things: boredom doesn't go away, it still behaves pretty much the same. The window thing doesn't happen,  or at least I was lucky enough to not ever experience it in hundreds of hours. The knockdown reduce must be minimal, cause I'm  a knife user and I'm constantly knocking zeds back pretty consistently, so If it does happen, is not big enough to make a difference, same with damage (I've used most weapons while in extreme panic and I've not noticed an efficiency difference in terms of damage).

 

Panic removes boredom. Seems like they changed it.

 

And you were right, constant panic helps tremendously in knocking down zombies as you noticed, which makes playing a paranoid character a bit more interesting.

Edited by Damntry
Added testing

Share this post


Link to post
Share on other sites

More random gibberish and factlets. This one is going to be a lot uglier and unnecesarily complex but thats how I roll:

 

Sleep and related effects Mechanics

  • Recovers endurance (Exhaustion effect) and reduces fatigue (tiredness).
    • First level of tiredness moodlet appears at 60% of fatigue, then 70%, 80%, and lastly 90%. This means that even when you dont have the tiredness moodlet, there is a lot more to recover.
    • Sleeping while your fatige is less than 30% is a bit over 3 times slower.
    • Maximum sleep time is based on current fatigue (with some added randomness) and type of bed. Restless sleeper trait halves the result. Ranges from 3 to 14 (7 with Insomniac) hours.
    • Restless sleeper trait also halves fatigue recovery while sleeping.
    • While awake, fatigue gain is respectively increased/decreased by Sleepyhead/Wakeful, by 30%.
  • Strictly speaking there is no real need to sleep, in the sense that you wont lose health from just staying awake at 100% tiredness, though obviously its very inefficient in the long run.
  • Reasons on why you cant sleep:
    • Fatigue less than 30%.
    • Outside in the rain.
    • At least pain level 2, but only with less than 85% fatigue. Ignored with Sleeping pills.
    • Having some level of panic. Ignored with Sleeping pills.
    • Having slept less than 1 hour ago. Ignored with Sleeping pills.
  • Three kind of beds, "goodBed", "badBed", and another one unnamed that it could be considered neutral (No idea where to find this property on objects yet so I cant make a list of each).
  • Waking up has a small effect depending on kind of bed:
    • Good bed: Very small extra fatigue reduction.
    • Neutral bed: 10% chance of receiving pain and between 3 and 12 damage in the neck.
    • Bad bed: Small increase in fatigue. 20% chance of receiving pain and between 5 and 15 damage in the neck.
  • When you start sleeping, there is a delay before you get any actual fatigue reduction benefits, ranging from 0 to 2 hours. This delay is precalculated from the previous waking up, with the following factors:
    • Increased by: Pain, Stress, sleeping on a bad bed, and the Restless sleeper trait.
    • Decreased by: Sleeping on a good bed, and recently having taken a Sleeping tablet before going to sleep.
  • Sleeping tablets boosts fatigue gains, so you get tired and able to sleep faster. After the first tablet, each sucesive one while the effect is still active will increase this fatigue boost, but only by ~10%.
    • Booze has the same outcome, but only up to 20% of the effect of a Sleeping tablet.
  • Starting to sleep immediately removes the effects of Sleeping tablets and Beta blockers.
  • Sources of wake up:
    • Normal player input or alarm clock.
    • Reaching the maximum sleep time.
    • Nightmares: They have a 5% chance of ocurring after sleeping for at least 3 hours. Each level of stress increase those chances by 10%.
    • Spoiler

       

      • Zombie intruders:
        • Only happens if:
          • The character needs at least 4 hours of sleep and its inside a building. Base chance based on "Sleeping event" Sandbox option (2º and 3º option are 20% and 45% respectively).
          • You have not constructed in your current zone (unknown what a zone is) any stairs, door frames, floors or walls.
          • There are zombies spawned in the current cell region.
        • This is actually the only existing "Sleeping event". Nightmares and such do not depend on this setting.
        • Wakes you up with around half full panic, and spawns up to 3 zombies that go after you.
        • Chances can increase based on existing objects on the current building and 2 extra squares around, for each object, up to 70% maximum:
          • Working fridge/freezer: 3%
          • Stove activated: 5%
          • Television turned on: 30%
          • Radio turned on: 30%
          • Open door: 25%
          • Windows. Chances are added for each window depending if lights escapes through it. Windows above ground floor adds half the stated chance:
            • Lighted window, fully open: 20%
            • Lighted window with closed curtain: 3%
            • Lighted window covered with metal or over 4 planks: 0%
            • Dark window, fully open: 5%
            • Dark window with closed curtain: 0%
            • Dark window covered with metal or over 3 planks: 0%
          •  If the game has the highest "Sleeping event" Sandbox option selected, all the previous effects are increased by 50%.
          • Finally, starting to sleep during the day halves chances.

       

 

Also, dont take as traits both Restless sleeper and Sleepy head. You will have a bad time.

Edited by Damntry
Updated zombie intruders

Share this post


Link to post
Share on other sites
57 minutes ago, Blitz said:

May I ask if the lucky trait is quite good, like in fallout? Or a skilled player wouldn't need it?

 

I wouldnt say you absolutely need it but you get a bit more and better loot for just 4 points, in a game about looting. Maybe not a gamechanger but it adds up, especially if you play at higher difficulties where you are short of everything. 

Share this post


Link to post
Share on other sites

Lol. I took restless sleeper and sleepyhead for a solo game a long time ago because I figure I'd just sleep more so it was free points. You are right, it sucked. After that game, I have never taken those again. If I can fit it in, I try to grab wakeful now as I'm scarred by the experience of taking both the negative sleeping traits.

Share this post


Link to post
Share on other sites
Quote

Also, it would seem to have a relatively high chance of happening but I ve never seen it. Could anyone tell if they saw something like this happen?

 

After reading this passage (btw, really interesting job on your part with all the RNG stuff deep in code), i can produce a full video of what you describe, happening durint the game. The video is not mine ; it's from the Let's Play of Jackplay (also user of this forum), and it's in French, but i provide the link anyway ; start looking by the 25mins marks (the intrusion is by 30mins, but all the situation is interesting).

 

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
3 3