Sunday, October 3, 2021

How Strong Are My Walls? (How Wall Health is Calculated in Build 41.55)

Build 41.55 changed how wall health is calculated.  There are three main differences:

  • The health increase per level was reduced from 40 to 20 (under default settings)
  • The level at which the wall could first be built is no longer a factor in calculating health
  • Upgraded walls no longer have more health than originally built walls

If you want more details about how wall health was calculated in 41.54 and earlier, check out my old blog post.

Here are the factors that influence wall health:

  • Wall Type
  • Character Skill Level
  • Handy Trait (only for log walls)
  • For upgrades, the health of the original wall
  • Sandbox Option: Player-Built Construction Strength

For the purposes of this entire post, let's assume the Sandbox Options are all set to default.

The strongest wall is the Level 2 Metal Wall, built with a metal frame, but considering the scarcity of the resources required to build them, I think most people will stick with wooden walls.  Log walls (without the handy trait) are only sometimes stronger than wooden walls, and require much more wood (but fewer nails).

How Wall Health is Determined in the Code

As in older builds, the code for wood (and log) walls starts in ISBuildMenu.lua.  Metal walls are handled in ISBlacksmithMenu.lua.  Metal walls are handled similarly to wood walls in lua, and use the same code when we get to the java, so we'll only look at the wood wall code here.

Once we get past determining the skills and materials required to build the wall, the stats for the wall frame gets set in onWoodenWallFrame:

ISBuildMenu.onWoodenWallFrame = function(worldobjects, sprite, player)
-- sprite, northSprite, corner
    local wall = ISWoodenWall:new(sprite.sprite, sprite.northSprite, sprite.corner, ISBuildMenu.isNailsBoxNeededOpening(2));
    wall.canBarricade = false
    wall.name = "WoodenWallFrame";
    -- set up the required material
    wall.modData["xp:Woodwork"] = 5;
    wall.modData["need:Base.Plank"] = "2";
    wall.modData["need:Base.Nails"] = "2";
    wall.health = 50;
    wall.player = player;
    getCell():setDrag(wall, player);
end

So the frame's health is 50.  

Wall frames are built in ISBuildMenu like a lot of constructions (stairs, crates, rain collectors).  Unlike in older builds, there is no health difference between upgrading a wall and building the wall outright.  They are handled in ISBuildMenu:

ISBuildMenu.onMultiStageBuild = function(worldobjects, stage, item, player)

The definitions of these are in the scripts, in multistagebuild.txt.

Here is the definition of a level 1 wall:

    multistagebuild CreateWoodenWall_1
    {
        PreviousStage:WoodenWallFrame;MetalWallFrame,
        Name:WoodenWallLvl1,
        TimeNeeded:250,
        BonusHealth:400,
        SkillRequired:Woodwork=2,
        ItemsRequired:Base.Plank=2;Base.Nails=4,
        ItemsToKeep:Base.Hammer,
        Sprite:walls_exterior_wooden_01_44,
        NorthSprite:walls_exterior_wooden_01_45,
        CraftingSound:Hammering,
        ID:Create Wooden Wall Lvl 1,
        XP:Woodwork=10,
    }

It's pretty clear what most of the items in this definition means.  BonusHealth is what is important for this discussion.

You can look at multistagebuild.txt if you want to see all the values, but here are the health values for the walls and upgrades:

Bonus Health

Level 1 Wall: 400
Level 2 Wall: 500
Level 3 Wall: 600
Level 1 Metal Wall: 650
Level 2 Metal Wall: 750

Upgrade from L1 Wall to L2 Wall: +100
Upgrade from L1 Wall to L3 Wall: +200
Upgrade from L2 Wall to L3 Wall: +100
Upgrade from L1 Metal Wall to L2 Metal Wall: +100

The code that handles setting the stats of these walls isn't in the lua, it is in the java.  It is in the MultiStageBuilding class.  This is used for both wood and metal walls:

        public void doStage(IsoGameCharacter isoGameCharacter, IsoThumpable isoThumpable, boolean bl) {
            int n = isoThumpable.getHealth();
            int n2 = isoThumpable.getMaxHealth();
            String string = this.sprite;
            if (isoThumpable.north) {
                string = this.northSprite;
            }
            IsoThumpable isoThumpable2 = new IsoThumpable(IsoWorld.instance.getCell(), isoThumpable.square, string, isoThumpable.north, isoThumpable.getTable());
            isoThumpable2.setCanBePlastered(this.canBePlastered);
            if ("doorframe".equals(this.wallType)) {
                isoThumpable2.setIsDoorFrame(true);
                isoThumpable2.setCanPassThrough(true);
                isoThumpable2.setIsThumpable(isoThumpable.isThumpable());
            }
            int n3 = this.bonusHealth;
            switch (SandboxOptions.instance.ConstructionBonusPoints.getValue()) {
                // Code edited out by Ed because we are using default values
            }
            Iterator<String> iterator = this.perks.keySet().iterator();
            int n4 = 20;
            switch (SandboxOptions.instance.ConstructionBonusPoints.getValue()) {
                // Code edited out by Ed because we are using default values
            }
            int n5 = 0;
            if (this.bonusHealthSkill) {
                while (iterator.hasNext()) {
                    String string2 = iterator.next();
                    n5 += isoGameCharacter.getPerkLevel(PerkFactory.Perks.FromString(string2)) * n4;
                }
            }
            isoThumpable2.setMaxHealth(n2 + n3 + n5);
            isoThumpable2.setHealth(n + n3 + n5);

When you build a level 1 wood wall from a wood frame here are the steps for setting the health:

  • Get the health of the wood frame (this includes any damage taken)
  • Get the maximum health of the wood frame (we know this is 50)
  • Get the Bonus Health value of the level 1 wall (we know this is 400)

Then we look at the "perks" which is basically the skills required to build this wall.  In this case, it is carpentry.  We take the character's level, multiplied by 20.  

Then for the maximum health we add up the max health, bonus health, and multiplied level modifier.

And for the current health, we add up health, bonus health, and multiplied level modifier.

Remember that when you are upgrading a wall, it is starting with the health of the original wall.  So if you build a L1 wall when you have L2 Carpentry, it will start out at 490 HP.  If you wait til L10 to upgrade the wall to L2, it will still only have 590 HP.

Note that except for log walls, the handy trait does not factor in calculating wall health.

What About Metal Walls and Log Walls?

Although metal walls get their start in the ISBlacksmithMenu.lua code, they also end up in the MultiStageBuilding class so they have the same calculations, with different numbers.  

By the way, metal frames have a health of 120 compared to the wood frame health of 50.  And you can build wood walls over metal frames.  So if you want to build strongest wall, start with the strongest frame.

Log walls fall under what appears to be the old system of calculating health.  Much of the code for the old system of constructing wood walls is still there, just unreachable because of comments.  When we want to calculate a log wall's health:

-- return the health of the new wall, it's 200 + 100 per carpentry lvl
function ISWoodenWall:getHealth()
    if self.sprite == "carpentry_02_80" then -- log walls are stronger
	    return 400 + buildUtil.getWoodHealth(self);
    else
        return 200 + buildUtil.getWoodHealth(self);
    end
end

The comment there is in the 41.55 version of the file, and is wrong.

-- give the health of the item, depending on you're carpentry level + if you're a construction worker
buildUtil.getWoodHealth = function(ISItem)
	if not ISItem or not ISItem.player then
		return 100;
	end
	local playerObj = getSpecificPlayer(ISItem.player)
	local health = (playerObj:getPerkLevel(Perks.Woodwork) * 50);
	if playerObj:HasTrait("Handy") then
		health = health + 100;
	end
	return health;
end

We can see here that for the log walls, 50 per carpentry level gets added to the health, with an additional 100 if the character is handy.  So a handy character with level 10 carpentry makes 1000 health log walls.  

Although handy isn't currently being used to calculate wall health, maybe they'll add it back in in the future.

Mod: How Strong Is That Wall?



After my first post on wall health, I created a mod that lets you see how strong your walls are.  Look at the mod through this link!


Thanks for reading this!  If you see any mistakes, or if you have any questions that I might be able to answer by looking at the code, let me know!

13 comments:

  1. Wow, this is detailed! I wish I understand how to read this, but I'm grateful I found you.

    How do I know my level, is the 'unlocked' one or the one I'm gaining XP in currently?

    Am I interpreting this correctly? - at lower skill levels, it's better to build the Lv1 wall and upgrade it later > build a log wall. The wood wall will eventually be stronger than the log wall? But log walls beceome better at skill levels 9 and 10.

    ReplyDelete
  2. Thanks for the blog post buddy! Keep them coming... greek yogurt tampon

    ReplyDelete
  3. Whenever you have had your LASIK surgery, you will perhaps need to recommence your ordinary exercises in a split second, yet all the same be careful.
    https://www.visualaidscentre.com/lasik-surgery-in-ghaziabad/

    ReplyDelete
  4. Thanks for a very interesting blog. What else may I get that kind of info written in such a perfect approach? I’ve a undertaking that I am simply now operating on, and I have been at the look out for such info. cavity wall Insulation

    ReplyDelete
  5. Your work is very good and I appreciate you and hopping for some more informative posts. Thank you for sharing great information to us. nehézgépek szállítása olcsón

    ReplyDelete
  6. It targets engaging them to assume command of their own health and their family's health considering natural, way of life, word related and social health determinants and nature of health care.
    Therapists in Durham

    ReplyDelete
  7. As I have called attention to in past articles, health generally precedes wellness and wellness should be achieved to keep up with health. Sounds somewhat aggravating, right? As a matter of fact, seems like a figure of speech, with a smidgen of gibberish tossed in just in case I envision.
    click here

    ReplyDelete
  8. Try not to be deceived by health tension and dread.
    The blog

    ReplyDelete
  9. He involves his insight for assisting individuals with finding the best cocaine detox focus.
    buy colombian cocaine online

    ReplyDelete
  10. Mental health issues affect people from all walks of life and should be taken seriously. http://bwtherapy.ca/

    ReplyDelete
  11. Truly - when appropriately regulated - Botox will safeguard your ordinary looks, just streamlining the grimace lines and kinks.
    desirial plus

    ReplyDelete
  12. Find a workout buddy to make exercise more enjoyable and hold you accountable. Weight Loss Clinic

    ReplyDelete
  13. Health insurance should cover travel vaccines for those going abroad. health insurance coverage options

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