Showing posts with label alcohol. Show all posts
Showing posts with label alcohol. Show all posts

Friday, August 20, 2021

Sleeping Pills and Alcohol - Not Always Fatal (Looking at the Code)

 


Here's a quick question I got asked:

Will mixing sleeping pills and alcohol kill you?

It takes a minimum of 6 sleeping pills to kill you if you are drunk.  


Here is how I researched that:

First, let's talk about Sleeping Pill overdoses.  Starting in the BodyDamage class.

    private float getDamageFromPills() {
        if (this.getParentChar() instanceof IsoPlayer) {
            IsoPlayer isoPlayer = (IsoPlayer)this.getParentChar();
            if (isoPlayer.getSleepingPillsTaken() == 10) {
                return 40.0f;
            }
            if (isoPlayer.getSleepingPillsTaken() == 11) {
                return 80.0f;
            }
            if (isoPlayer.getSleepingPillsTaken() >= 12) {
                return 100.0f;
            }
        }
        return 0.0f;
    }

So you can see that if you take 10 pills you'll take damage, and at 12 you will take full damage (die).  So you wouldn't need any alcohol to die from sleeping pills, even if alcohol were harmless.

Also in BodyDamage, once you take a pill you come across this code:

        } else if ("PillsSleepingTablets".equals(inventoryItem.getType())) {
            inventoryItem.Use();
            this.getParentChar().SleepingTablet(0.1f);
            if (this.getParentChar() instanceof IsoPlayer) {
                ((IsoPlayer)this.getParentChar()).setSleepingPillsTaken(((IsoPlayer)this.getParentChar()).getSleepingPillsTaken() + 1);
            }

and that leads us to the IsoPlayer class, because that's where setSleepingPillsTaken is defined

    public void setSleepingPillsTaken(int n) {
        this.sleepingPillsTaken = n;
        if (this.getStats().Drunkenness > 10.0f) {
            ++this.sleepingPillsTaken;
        }
        this.lastPillsTaken = GameTime.instance.Calender.getTimeInMillis();
    }

So if your Drunkenness > 10 (not very drunk), then when you take a sleeping pill you get 1 pill for taking the pill, and another pill for being drunk.  So you will get to the fatal number of 12 twice as quickly!

By the way, DON'T MIX SLEEPING PILLS AND ALCOHOL IN REAL LIFE

Thanks for reading!  If you see a mistake, or if you have a question you'd like me to answer (by looking at code), let me know!

Wednesday, August 18, 2021

Bug - Immunity From Wound Infections

 



Update:  Build 41.71 fixes this bug!

Hey, I think I found a bug!  Details are in the 7 minute video, but here are the basics:

Disinfecting a body part once prevents wounds from ever infecting that body part.  That would be a bug.

When you disinfect a body part (to tend to a wound), it sets an alcohol level on that part.

function ISDisinfect:perform()
    -- needed to remove from queue / start next.
    ISBaseTimedAction.perform(self);
    self.bodyPart:setAlcoholLevel(self.bodyPart:getAlcoholLevel() + self.alcohol:getAlcoholPower());

AlcoholLevel is set in a few places in the code: When you disinfect, on initialization, and when to fully restore health (or God mode).

I found only one place in the code where AlcoholLevel is reduced, in BodyPart.class:

        } else if (this.isInfectedWound()) {
            boolean bl = false;
            if (this.getAlcoholLevel() > 0.0f) {
                this.setAlcoholLevel(this.getAlcoholLevel() - 2.0E-4f * GameTime.getInstance().getMultiplier());
                this.setWoundInfectionLevel(this.getWoundInfectionLevel() - 2.0E-4f * GameTime.getInstance().getMultiplier());
                if (this.getAlcoholLevel() < 0.0f) {
                    this.setAlcoholLevel(0.0f);
                }
                bl = true;
            }


That only applies to infected wounds.  If you put alcohol on an infected wound it will help you recover from the infection more quickly. 

In order a wound to become infected, it must get past this conditional:

        if (!this.isInfectedWound() && !this.IsInfected && !this.alcoholicBandage && this.getAlcoholLevel() <= 0.0f && (this.getDeepWoundTime() > 0.0f || this.getScratchTime() > 0.0f || this.getCutTime() > 0.0f || this.getStitchTime() > 0.0f)) {

The AlcoholLevel has to be 0 in order for your wound to get infected.  But since alcohol level doesn't go down, that body part can't get infected once you've disinfected it.

You may also notice that if you have an alcoholic bandage you also can't get infected.  Alcoholic bandages are bandages sterilized by either HOT water or alcohol/disinfectant, and the life of those bandages actually does go down.

Not that it really matters - infected wounds only have minor consequences.  But that's a discussion for another time.


If you see a mistake in what I've posted or have any questions you'd like me to tackle, please let me know!

Do Gloves Protect You From Broken Glass?

Yes, gloves protect you from handling broken glass - any pair of gloves.  But gloves are not needed when removing broken glass from a smashe...