Saturday, August 21, 2021

Quick PZ Code Questions



Here are quick answers to some PZ questions, without much code context.  Let me know if you want me to do deeper looks into some of these systems!

1. How far away do house alarms alert zombies?

700 tiles

From the AmbientSoundManager class

            Ambient ambient = new Ambient("burglar2", roomDef.x + roomDef.getW() / 2, roomDef.y + roomDef.getH() / 2, 700.0f, f);


2. How frequently do foraging zones refresh themselves?

50,000 game seconds, or close to 14 in-game hours.

From ISScavengeAction.lua

        if getGametimeTimestamp() - zone:getLastActionTimestamp() > 50000 then
            --            print("refill zone");
            zone:setName(tostring(scavengeZoneNumber));
            zone:setOriginalName(tostring(scavengeZoneNumber));


3. Can wound infections kill you?

No.  It's hard to prove that something can't happen in code (because maybe I'm not looking at the right place to see the code that does something), but you can try searching for related terms in the code.  If I wanted to show my evidence, I'd list all the terms I searched, and show that the hits did not lead to any damage or deaths.

I found that at their worst, wound infections cause up to 10 pain (and pain goes up to 100).  So don't worry too much about wound infections, but take care of them if you can.  Multiple infections add up.

From the BodyPart class, WoundInfectionLevel is part of the getPain calculation:

        if (this.getWoundInfectionLevel() > 0.0f) {
            f += this.getWoundInfectionLevel();

And you can see here that WoundInfectionLevel is 10 at worst.

                if (this.getWoundInfectionLevel() > 10.0f) {
                    this.setWoundInfectionLevel(10.0f);
                }


4. Does being an axe man increase your swing speed in combat?

Yes.  By 25%.

Here is some code from calculateCombatSpeed, in the IsoGameCharacter class, showing that an Axeman using an Axe has a multipler on the chop tree speed.

        if (handWeapon != null && this.Traits.Axeman.isSet() && handWeapon.getCategories().contains("Axe")) {
            f *= this.getChopTreeSpeed();
        }

And you can see here in the same class that ChopTreeSpeed is 1.25 if you have AxeMan, but only 1.0 if you don't.

    public float getChopTreeSpeed() {
        return (this.Traits.Axeman.isSet() ? 1.25f : 1.0f) * GameTime.getAnimSpeedFix();
    }


5. Can you OD on pills besides sleeping pills?

No.  Again, I can't really prove the code doesn't exist, but the code I examined for overdosing on sleeping pills doesn't have an equivalent for the other pills (pain, vitamins, antidepressants, betablockers).  Antibiotics are considered to be food, and you also can't OD on them.


6. Do zombies hear the large vehicle backup alert?

No.  I should do a post on the sound system in the future to go into detail, but I can demonstrate this by comparing it to how the car horn is handled.  Both sounds are generated in the BaseVehicle class:

WorldSoundManager.instance.addSound((Object)this, (int)this.getX(), (int)this.getY(), (int)this.getZ(), 150, 150, false);

That is a line from when the car horn sounds.  The 150, 150 describes the radius the sound carries, and the volume.  FYI car horns can be heard by zombies for 150 tiles.

The backup sound does something different:

        if (this.script.getSounds().backSignalEnable) {
            this.soundBackMoveSignal = this.emitter.playSoundLoopedImpl(this.script.getSounds().backSignal);
            this.emitter.set3D(this.soundBackMoveSignal, !this.isAnyListenerInside());
        }

No radius or volume, because this sound is only for the player.  Like music or the level-up sound.  Zombies can't hear it.


Thanks for reading!  If you notice a mistake or if you have any questions, please let me know!

2 comments:

  1. you're the best man about explaining PZ codes as I know
    thank you for help me to understand how is it work correctly!!

    ReplyDelete
  2. Ah, so that's how axeman broke.

    The GameTime.getAnimSpeedFix() seems to applied after all speed calculations, and turns out to be a constant 0.8f, which perfectly cancels out the axeman bonus.

    ReplyDelete

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