Showing posts with label sleepingpills. Show all posts
Showing posts with label sleepingpills. 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!

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...