Mass carried stat

Started by bublebree, January 08, 2019, 11:40:56 AM

Previous topic - Next topic

bublebree

Hello,

I have question for which I can not find answer. Where is defined or located the max "mass carried" statistic? I mean the "inventory" size, how much pawn can carry in caravan. Humans can carry 35 kg, muffalo more. I want to change this value and possibly make items or implants be able to change this value as well, but I cannot find it. Its not defined in stats.

I hope I am in right section :-)

Thank in advance for any advice.

O Negative

I've tried messing with that also, but with no luck. The only way I've been able to increase that value is by increasing the bodySize or a pawn, which also makes that pawn easier to hit while in combat, and also yield more butcher products...

Sorry my answer wasn't super helpful, but wanted you to know that you're not alone! Haha

Razuhl

You can add a new stat that's essentially a copy of the mass carried stat and then apply a simple harmony patch that replaces the constant 35 with a stat value.


<StatDef>
<defName>CarryingCapacityLongHaul</defName>
<label>carrying capacity long haul</label>
<description>The amount of cargo this creature can carry on long cross-world trips.</description>
<category>BasicsPawn</category>
<defaultBaseValue>35</defaultBaseValue>
<minValue>1</minValue>
<toStringStyle>Integer</toStringStyle>
<parts>
  <li Class="StatPart_BodySize" />
</parts>
<capacityFactors>
  <li>
<capacity>Manipulation</capacity>
<weight>1.0</weight>
  </li>
</capacityFactors>
</StatDef>



[HarmonyPatch(typeof(RimWorld.MassUtility))]
[HarmonyPatch("Capacity")]
static class UseStatForCargoMass
{
static bool Prefix(Pawn p, StringBuilder explanation, ref float __result) {
if (!MassUtility.CanEverCarryAnything(p))
{
__result = 0f;
return false;
}
//the next line is the only change to default behaviour
float num = p.GetStatValue(DefDatabase<StatDef>.GetNamed("CarryingCapacityLongHaul"));//p.BodySize * 35f;
if (explanation != null)
{
if (explanation.Length > 0)
{
explanation.AppendLine();
}
explanation.Append("  - " + p.LabelShortCap + ": " + num.ToStringMassOffset());
}
return false;
}
}


Now manipulation contributes and you can add the stat to gear to change the base 35 further.