Jump to content

Infection level set to fake infection level when infected?


Recommended Posts

Quick question, am I reading this correctly?  If you take the trait hypochondriac, making it so that you can become infected, but not actually infected, and that happens, but then you get infected, your infection level is set to what your character thought it was?


Better put:

1. You make a character that is a hypochondriac

2. Your character believes herself to be infected at an infection level x

3. Your character later actually gets infected and now has an infection level y

4. On the next frame update your infection level is changed from y to x (which is going to be higher)


A little bit of background:


I was reading through BodyDamage.class trying to answer a question that came up a few times in the IWBUMS: Build 30 thread.  People were wondering whether or not there really is a 4% chance to survive infection from a zombie.  Since there was a bit of discussion on it, I said to myself, well, lets settle this once and for all and look at the source.  I couldn't find it in any of the LUA files, so I popped open the most relevant looking class file, BodyDamage.class.  While browsing through this file I found code in the update() method that seems to say that what I put up above.


This is something that piqued my curiosity more than the 4% infection survival rate, so I thought I'd ask about it here.  Also my apologies ahead of time if looking at the class files is something that TIS finds inappropriate.  The modding rules seem to imply that it is okay, but, being a developer myself, I know reverse engineering can be a touchy subject for developers.

Java is not a language I program in, and Project Zomboid is not the sort of codebase I can familiarise myself with in 15 minutes, which is why I am asking here.


Relevant snippet:

        if (IsInfected(i))        {          setInf(true);          if (IsFakeInfected(i))          {            DisableFakeInfection(i);            setInfectionLevel(getFakeInfectionLevel());            setFakeInfectionLevel(0.0F);            setIsFakeInfected(false);            setReduceFakeInfection(false);          }        }
Link to comment
Share on other sites

I can only guess a BodyPart is never meant to be fake-infected; if it is, the infection is actually real and the character is infected. Part of this depends on whether DisableFakeInfection(BodyPart) impacts the overall FakeInfection level of BodyDamage or not.

Perhaps it could also be used in the case of latent illness? No negative health effect, then bam, negative health affect? *Shrug*

But yeah, might be a bug if that's not intended.

Link to comment
Share on other sites

DisableFakeInfection(BodyPart) simply sets the IsFakeInfected property on that BodyPart to false it does not reduce the FakeInfectionLevel of BodyDamage. The code snippet included in the original post is from a loop that checks every BodyPart each frame.

More information on how FakeInfection seems to work:


It appears anytime you are bitten and the BodyPart infected IsFakeInfected is set to false and IsInfected is set to true. When you are scratched though if IsInfected isn't set to true then there is a 20% chance that you IsFakeInfected will be set to true (provided you have the appropriate trait).

In BodyDamage the apparent infection level is set to either your InfectionLevel, your FakeInfectionLevel, or your FoodSicknessLevel, whichever is highest.

If any BodyPart is FakeInfected then you will become FakeInfected. In BodyDamage if you are FakeInfected then your FakeInfectionLevel will rise according to the games InfectionGrowthRate until it is over 100, at which point it will be set to 100 and begin to go down. It will only rise if getReduceInfectionPower returns 0 though. The ReduceInfectionPower is set based on food you eat. Once it begins to go down it goes down at a rate of twice as fast as the InfectionGrowthRate for the game (not counting traits).

Interesting side note, something else noticed while reading through this, that while not relevant to this discussion may be of interest to anyone reading. Resilient makes your actual infection level go up 3x slower, and Prone to Illness makes it go up 3x as fast. I've also seen no code that appears to reduce your actual infection level making me think that it is not actually possible to get cured of infection.

If getReduceInfectionPower returns something over 0, then your FakeInfectionLevel goes down by the InfectionGrowthRate again (making it 3x speed). This reduces ReduceInfectionPower by the InfectionGrowthRate as well, so we essentially use points from ReduceInfectionPower to reduce your FakeInfectionLevel.


I don't know if the changing your InfectionLevel to equal your FakeInfectionLevel when you do actually become infected is a bug or not, but it does seem unfair. I think it would be better to keep them separate and allow the FakeInfectionLevel to slowly drop until it is lower than the InfectionLevel. If it was done that way you might run into a situation where your character thinks you are infected, you begin to get better and then part of the way through getting better you suddenly begin to get very ill again. This to me seems like a much more realistic scenario.

I'd love to see a developer confirm my reading of all of this.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...