diff --git a/Languages/English/Keyed/BulkAndWeight.xml b/Languages/English/Keyed/BulkAndWeight.xml index 5fd61cc803..aa306e91fb 100644 --- a/Languages/English/Keyed/BulkAndWeight.xml +++ b/Languages/English/Keyed/BulkAndWeight.xml @@ -14,7 +14,7 @@ drug policy loadout Current weight: {1}\nCapacity: {0}\n\nMove speed factor: {2}\nMelee dodge chance factor: {3}\nEncumbrance penalty: {4} - Current bulk: {1}\nCapacity: {0}\n\nWork speed factor: {2}\nMelee hit chance factor: {3}\nMelee dodge chance factor: {4} + Current bulk: {1}\nCapacity: {0}\nWorn bulk: {5}\n\nWork speed factor: {2}\nMelee hit chance factor: {3}\nMelee dodge chance factor: {4} Current weight: {1}\nBase capacity: {0}\n\nMove speed factor: {2}\nMelee dodge chance factor: {3}\nEncumbrance penalty: {4} Current bulk: {1}\nBase capacity: {0}\n\nWork speed factor: {2}\nMelee hit chance factor: {3}\nMelee dodge chance factor: {4} Nothing diff --git a/Source/CombatExtended/CombatExtended/Comps/CompInventory.cs b/Source/CombatExtended/CombatExtended/Comps/CompInventory.cs index e9e660cba9..0b78c92206 100755 --- a/Source/CombatExtended/CombatExtended/Comps/CompInventory.cs +++ b/Source/CombatExtended/CombatExtended/Comps/CompInventory.cs @@ -18,6 +18,7 @@ public class CompInventory : ThingComp private const int CLEANUPTICKINTERVAL = 2100; private float currentWeightCached; private float currentBulkCached; + private float currentWornBulkCached; private List ammoListCached = new List(); private List meleeWeaponListCached = new List(); private List rangedWeaponListCached = new List(); @@ -47,6 +48,15 @@ public float currentBulk return currentBulkCached; } } + + public float currentWornBulk + { + get + { + return currentWornBulkCached; + } + } + private float availableWeight { get @@ -97,28 +107,28 @@ public float dodgeChanceFactorWeight { get { - return MassBulkUtility.DodgeWeightFactor(currentWeight, capacityWeight); + return MassBulkUtility.DodgeWeightFactor(currentWeight, capacityWeight) - (1 - MassBulkUtility.DodgeWeightFactor(currentWornBulk, CE_StatDefOf.CarryBulk.defaultBaseValue)); } } public float meleeHitChanceFactorBulk { get { - return MassBulkUtility.HitChanceBulkFactor(currentBulk, capacityBulk); + return MassBulkUtility.HitChanceBulkFactor(currentBulk, capacityBulk) - (1 - MassBulkUtility.HitChanceBulkFactor(currentWornBulk, CE_StatDefOf.CarryBulk.defaultBaseValue)); } } public float dodgeChanceFactorBulk { get { - return MassBulkUtility.DodgeChanceFactor(currentBulk, capacityBulk); + return MassBulkUtility.DodgeChanceFactor(currentBulk + currentWornBulkCached, capacityBulk) - (1 - MassBulkUtility.DodgeChanceFactor(currentWornBulk, CE_StatDefOf.CarryBulk.defaultBaseValue)); } } public float workSpeedFactor { get { - return MassBulkUtility.WorkSpeedFactor(currentBulk, capacityBulk); + return MassBulkUtility.WorkSpeedFactor(currentBulk, capacityBulk) - (1 - MassBulkUtility.WorkSpeedFactor(currentWornBulk, CE_StatDefOf.CarryBulk.defaultBaseValue)); } } public float encumberPenalty @@ -223,6 +233,7 @@ public void UpdateInventory() return; } float newBulk = 0f; + float newWornBulk = 0f; float newWeight = 0f; // Add equipped weapon @@ -238,7 +249,7 @@ public void UpdateInventory() { float apparelBulk = apparel.GetStatValue(CE_StatDefOf.WornBulk); float apparelWeight = apparel.GetStatValue(StatDefOf.Mass); - newBulk += apparelBulk; + newWornBulk += apparelBulk; newWeight += apparelWeight; if (age > CLEANUPTICKINTERVAL && apparelBulk > 0 && (parentPawn?.Spawned ?? false) && (parentPawn.factionInt?.IsPlayer ?? false)) { @@ -299,6 +310,7 @@ public void UpdateInventory() } } currentBulkCached = newBulk; + currentWornBulkCached = newWornBulk; currentWeightCached = newWeight; } @@ -313,20 +325,18 @@ public void UpdateInventory() public bool CanFitInInventory(ThingDef thingDef, out int count, bool ignoreEquipment = false, bool useApparelCalculations = false) { float thingWeight; - float thingBulk; + float thingBulk = 0f; if (useApparelCalculations) { thingWeight = thingDef.GetStatValueAbstract(StatDefOf.Mass); - thingBulk = thingDef.GetStatValueAbstract(CE_StatDefOf.WornBulk); - if (thingWeight <= 0 && thingBulk <= 0) + if (thingWeight <= 0) { count = 1; return true; } // Subtract the stat offsets we get from wearing this thingWeight -= thingDef.equippedStatOffsets.GetStatOffsetFromList(CE_StatDefOf.CarryWeight); - thingBulk -= thingDef.equippedStatOffsets.GetStatOffsetFromList(CE_StatDefOf.CarryBulk); } else { @@ -360,12 +370,11 @@ public bool CanFitInInventory(ThingDef thingDef, out int count, bool ignoreEquip public bool CanFitInInventory(Thing thing, out int count, bool ignoreEquipment = false, bool useApparelCalculations = false) { float thingWeight; - float thingBulk; + float thingBulk = 0f; if (useApparelCalculations) { thingWeight = thing.GetStatValue(StatDefOf.Mass); - thingBulk = thing.GetStatValue(CE_StatDefOf.WornBulk); if (thingWeight <= 0 && thingBulk <= 0) { count = 1; @@ -373,7 +382,6 @@ public bool CanFitInInventory(Thing thing, out int count, bool ignoreEquipment = } // Subtract the stat offsets we get from wearing this thingWeight -= thing.def.equippedStatOffsets.GetStatOffsetFromList(CE_StatDefOf.CarryWeight); - thingBulk -= thing.def.equippedStatOffsets.GetStatOffsetFromList(CE_StatDefOf.CarryBulk); } else { diff --git a/Source/CombatExtended/CombatExtended/Loadouts/Utility_Loadouts.cs b/Source/CombatExtended/CombatExtended/Loadouts/Utility_Loadouts.cs index 82aad6776f..f0c097b0ef 100755 --- a/Source/CombatExtended/CombatExtended/Loadouts/Utility_Loadouts.cs +++ b/Source/CombatExtended/CombatExtended/Loadouts/Utility_Loadouts.cs @@ -137,7 +137,8 @@ public static string GetBulkTip(this Pawn pawn) CE_StatDefOf.CarryBulk.ValueToString(comp.currentBulk, CE_StatDefOf.CarryBulk.toStringNumberSense), comp.workSpeedFactor.ToStringPercent(), comp.meleeHitChanceFactorBulk.ToStringPercent(), - comp.dodgeChanceFactorBulk.ToStringPercent()); + comp.dodgeChanceFactorBulk.ToStringPercent(), + CE_StatDefOf.WornBulk.ValueToString(comp.currentWornBulk)); } else {