[Finished] [1.0] Survival Tools

Started by XeoNovaDan, September 30, 2018, 01:37:35 PM

Previous topic - Next topic


This mod has now been completed and can be found on...
Ludeon: https://ludeon.com/forums/index.php?topic=29503.msg445544#msg445544
Steam: https://steamcommunity.com/sharedfiles/filedetails/?id=1566269698

Thanks to everybody for playtesting and providing feedback and bug reports!

Hey, so this has been a mod I've been working on-and-off with for the past few weeks but found the motivation to put a playable version together. While I've enjoyed the concept of a tool mod, there isn't a single tool mod out there that cuts it for my taste so I've decided to take things into my own hands and get something going. I'm no stranger to the modding scene, but this is my first time actually taking the public test approach, so this is something new for me.

I have somewhat white box tested this so there shouldn't be any major bugs as it stands. That being said, this has only been tested with Pick Up & Haul; the game was otherwise completely vanilla while whiteboxing. There shouldn't be any incompatibilities though. This should work with existing saves, but I'd highly recommend this with a new save.

GitHub Releases Page (downloads)
Source Code

I highly recommend using tammybee's Cut Plants Before Building (Dropbox / Steam) because that auto-designates certain plants and trees to be cut by plant cutters, which helps when you have constructors without axes who'd otherwise take a long time to chop down trees that are in the way of their blueprints.

Screenshots (RC1):

Splits the following vanilla work stats

  • Mining Speed -> Mining Speed (vanilla def) and Digging Speed
  • Mining Yield -> Mining Yield (other) (vanilla def) and Mining Yield (digging)
  • Plant Work Speed -> Plant Sowing Speed (vanilla def), Plant Harvesting Speed and Tree Felling Speed
Adds 5 tools to the game

  • Axe - affects tree felling speed
  • Pickaxe - affects digging speed and mining yield (digging)
  • Hammer - affects construction speed
  • Sickle - affects plant harvesting speed
  • Glitterworld Multitool - affects all of the above, doesn't have quality levels
Tools are acquirable through various different ways

  • At the beginning of a new game (varies by scenario; no tools for naked brutality)
  • Production at crafting spots or smithies (all except multitool)
  • Ancient ruined buildings (40% chance per building, all except multitool, typically low quality and in poor condition)
  • Tribal/outlander bulk goods traders and settlements (all except multitool)
  • Outlander/orbital exotic goods traders (only multitool)
  • Ancient dangers (60% chance per danger, only multitool)
Colonists can use tools from their inventories (added functionality to allow for picking up items anywhere) as well as what they have equipped

  • If a colonist has multiple tools that affect the same task, they use the fastest tool of the lot. If there's still a tie, they use what's most immediately available out of the tied lot
  • Colonists are limited to 3 tools in their inventory other than when caravanning - this can be toggled via mod settings
  • Since this uses the inventory system, even non-violents can use tools
  • If a colonist somehow gets a tool that's worse than working toolless, they will continue working toolless
Colonists get work speed penalties if they don't have tools for tasks that need them

  • Animals aren't affected by this
  • For now, AI humanlikes also aren't affected by this due to design implications. I hope to solve this at some point
  • Construction speed - x30% speed if working toolless (x0% with hardcore mode enabled)
  • Digging speed - x30% speed if working toolless (x0% with hardcore mode enabled)
  • Mining yield (digging) - x50% if working toolless (x0% with hardcore mode enabled)
  • Tree felling speed - x30% speed if working toolless (x0% with hardcore mode enabled)
  • Plant harvesting speed - x50% speed if working toolless (x50% with hardcore mode enabled)
Different materials affect a tool's effectiveness in different ways

  • You can view each material's effect on certain aspects of tools by viewing their info cards
  • Tool lifespan is generally directly proportional to their max HP modifiers
Tools will actually degrade over use

  • 1 HP lost per 0.75 ingame hours of use (0.5 with hardcore mode)
  • Also significantly influenced by the quality of the tool

Design purposes of this mod:

  • Removing much of the Minecraft logic that RimWorld ends up having (e.g. punching trees)
  • Add tools that fulfil core niches - not going into nitty-gritty territory (e.g. knives for cooking, scalpels for surgery etc.)
  • Not aiming for hyper realism; tools are still slightly abstracted in terms of gameplay


  • Auto-optimiser for colonist tool selection, or at least a sidebar alert - alert implemented in v0.3. Auto-optimiser probably won't happen
  • Allow AI to be utilise tools - On hold
  • Pawns to auto-equip tools that they're using instead of an 'In-use' tag (very low priority, may not make it to v1.0 for this mod)

The oft-mentioned hardcore mode of this mod can be seamlessly toggled via mod settings. As this mod is somewhat of a WIP (though most stuff at this point is concrete), feedback and any suggestions that fit within this mod's design purposes would be much-appreciated.

Credits so far
Brrainz - Harmony
Mehni - Allowing me to directly use code from Pick Up And Haul (namely the 'Pick Up' part)
Why_is_that - SettingsHelper (not actually utilised yet)
Shotgunfrenzy - Artwork
erdelf - erdelf


will mods that rely on the plant work speed stat, just use the plant sowing speed stat instead, and have (hopefully) minimal compatability issues? same with mining speed?


Why limit it as "three tools in the inventory"? It's weird.
A human should be able to carry as many tools as he can, normally.
And, what if a pawn is just needed to carry many tools, eg, many tools founded somewhere or bought from trade.


@123nick - Yeah, they will.
@temple_wing - Good catch actually. It's mainly just a balance thing so that colonists can't just use stupid amounts of tools, but I'll add a mod setting to disable the limit altogether.


Yes, it's inefficient, but it's less micro management.
If you can program it to choose automatically( pick up necessary tool from stockpile just like doc pick up med before tending ), will be perfect.


Alright, pushed v0.2 with a bunch of minor changes:
* Split mining yield into mining yield (digging) and mining yield (other) - affected by pickaxe and multitool
* 3-tool carry limit now only applies to hardcore mode
* Bugfix regarding the tool carry limit when caravanning
* Added new sprite for glitterworld multitool by Shotgunfrenzy

I also tried and failed to add a QoL feature that shows which tools a colonist's actually using in their inventory. The commented-out code is still present in the source code in SurvivalTool.cs and SurvivalToolUtility.cs

@temple_wing - Hmm, tool optimisation will be a tricky one to do, but I may give it a shot. Since there can be specific use-cases and that's something I've never done before, there's no guarantees I'll actually get an auto-optimiser in. However, something like an alert (similar to 'Low food' or 'Hunter lacks ranged weapon') will probably be much more doable and non-intrusive to player optimisation. Liking the feedback by the way!


Do you have a GitHub with the 0.1 version with 3-max tools?
EDIT: Nevermind


Alright, pushed v0.3 which mostly improves on the QoL side of things but does tweak a few things too. Copypasted changelog from GitHub:

NOTE: Although this release is for unstable 1.0, it has been quickly tested and shown to work fine with B19

General Changes

  • 3-tool limit is now an independent toggle in mod settings
  • Renamed Estimated lifespan to Estimated tool lifespan
  • Tools generated in ruined buildings are now only made from cheap materials (max material market value of 3, cheaper materials are more common)
  • It's now easier to see which tools a colonist's using
  • Added alert for colonists that are missing tools
  • Added learning helper entry regarding the use of tools


  • Roof removal, blueprint clearing and growing zone sowing will now correctly use the tree felling job when appropriate




Exception filling window for RimWorld.Dialog_Trade: System.NullReferenceException: Object reference not set to an instance of an object
  at SurvivalTools.SurvivalToolUtility.GetBestSurvivalTool (Verse.Pawn pawn, RimWorld.StatDef stat) [0x00000] in <filename unknown>:0
  at SurvivalTools.SurvivalToolUtility+<BestSurvivalToolsFor>d__11.MoveNext () [0x00000] in <filename unknown>:0
  at System.Linq.Enumerable.Contains[SurvivalTool] (IEnumerable`1 source, SurvivalTools.SurvivalTool value, IEqualityComparer`1 comparer) [0x00000] in <filename unknown>:0
  at System.Linq.Enumerable.Contains[SurvivalTool] (IEnumerable`1 source, SurvivalTools.SurvivalTool value) [0x00000] in <filename unknown>:0
  at SurvivalTools.SurvivalTool.get_InUse () [0x00000] in <filename unknown>:0
  at SurvivalTools.SurvivalTool.get_LabelNoCount () [0x00000] in <filename unknown>:0
  at RimWorld.Tradeable.get_Label () [0x00000] in <filename unknown>:0
  at RimWorld.Transferable.get_LabelCap () [0x00000] in <filename unknown>:0
  at RimWorld.TransferableUIUtility.DrawTransferableInfo (RimWorld.Transferable trad, Rect idRect, Color labelColor) [0x00000] in <filename unknown>:0
  at RimWorld.TradeUI.DrawTradeableRow (Rect rect, RimWorld.Tradeable trad, Int32 index) [0x00000] in <filename unknown>:0
  at RimWorld.Dialog_Trade.FillMainRect (Rect mainRect) [0x00000] in <filename unknown>:0
  at RimWorld.Dialog_Trade.DoWindowContents (Rect inRect) [0x00000] in <filename unknown>:0
  at Verse.Window+<WindowOnGUI>c__AnonStorey0.<>m__0 (Int32 x) [0x00000] in <filename unknown>:0
Verse.Log:Error(String, Boolean)
UnityEngine.GUI:CallWindowDelegate(WindowFunction, Int32, Int32, GUISkin, Int32, Single, Single, GUIStyle)

b19, possibly related to simple sidearms? Possibly related to a lot of mods I have enabled? It looks like whenever a axe showed up in a trader's inventory, it screws up the entire window. I could create them myself and they worked fine for me, but trader generated ones seem to cause issues. If I look in a caravan's inventory, it shows the axe icon, and then the rest is blank until the info button on the right. The info button brings up a transparent grey box where the info screen should be, but there is no info. This makes trading impossible.

Its unfortunate, I really like the concept. The integration with inventories is nice and otherwise worked fine with simple sidearms? Colonists seemed to swap to melee tools as appropriate for being in melee range with a gun.

I will mention one thing I find super annoying, but its a vanilla issue made worse by this mod - Builders/haulers to build run into an issue where they spend large amounts of time trying to fell trees in the way, since they have both low plants skill and now worse, no axe. I am not sure what an elegant solution to this is, or even if its within the scope of this mod. My only real suggestion is change the axe's bonus be harvest yield instead of speed, such that I dont need to micromanage cutting plants that are in the way of construction.


@Lancefighter - Thanks for the stacktrace; will look into it now. Looks like it gives enough info to pinpoint the cause.

Also yeah, the axe situation is a bit of a tough one. Harvest yield won't work because the harvest yield stat actually only affects the chance of successfully harvesting resources from plants in general, and it's literally impossible to fail harvesting trees for their wood - it'll only cause more problems. I guess one fix could be to add 'Tree Felling Speed' as a relevant stat for the ConstructFrames and ConstructFloor workGivers, though I will probably need to change the way that the 'Colonist needs tools' alert works.

Edit: Though OTOH, I could also list 'Cut plants before building' as a recommended mod as well, which'll also mostly address the issue of axeless level 0 plantwork constructors spending an eternity cutting down trees that are in the way of blueprints since that autodesignates.


Alright, bug has been squashed. Will push v0.4 shortly.

Also, it wasn't an SS issue, just a matter of bad coding on my behalf :P

        public static IEnumerable<SurvivalTool> BestSurvivalToolsFor(IThingHolder holder)
            Pawn pawn = (holder is Pawn_EquipmentTracker eq) ? eq.pawn : ((holder is Pawn_InventoryTracker inv) ? inv.pawn : null);
            // The following was the problematic code snippet:
            // if (pawn == null)
            if (pawn == null || !pawn.RaceProps.Humanlike || pawn.TraderKind != null)
                yield break;

            foreach (StatDef stat in SurvivalToolStats)
                SurvivalTool tool = pawn.GetBestSurvivalTool(stat);
                if (tool != null)
                    yield return tool;


Finally pushed v0.4 - I decided to change a couple of other things as well. This update's largely bugfixing, though some tweaking has been done too. No new features have been added. Just to re-iterate: v0.4 of Survival Tools is for 1.0.2045, but should also work fine with 0.19.2009 since there's very little in the way of code difference

Copypasted changelog from GitHub:

General Changes:

  • The game will now check whether a pawn can actually use the stats that a tool affects when determining if it shows that the tool is 'in use'
  • Lost Tribe now starts with slate sickles instead of wooden sickles since wooden sickles are barely better than working toolless
  • Tools degrade over use 50% quicker (once per 45/30 mins average -> 30/20)


  • Major: Attempting to trade with traders that carry tools will no longer completely break the trade UI
  • Tool degrade chance per tick is now calculated correctly, with new chances being significantly lower
  • Colonists will no longer drop in-use tools after a caravan journey

If all goes well, the next build will likely be the first release candidate since I plan to add AI tool use. Thanks for the testing and bug reports so far!


Ah, good call on the cut plants before building mod, I didnt know that one existed, Ill add that today... and then have to rebuild all my tools since I deleted them so I could trade. No big deal, they craft quickly enough.

If harvest yield wasnt limited by base game limitations (read: if youre modding base game limitations on harvest yield out), would you consider increased harvest yield to be within the scope of the tools?