public static void Postfix(Projectile __instance, ref int __result) { var verbCache = __instance.TryGetComp <CompProjectileVerbCache>(); if (verbCache != null && verbCache.cachedVerbClass is Type t && t.IsAssignableFrom(typeof(Verb_ShootShotgun))) { var shotgunExtension = ShotgunExtension.Get(__instance.def); float adjustedDamage = (float)__result / shotgunExtension.pelletCount; // Determine pellet damage switch (ProperShotgunsSettings.damageRoundMode) { case ShotgunDamageRoundMode.Standard: __result = Mathf.RoundToInt(adjustedDamage); break; case ShotgunDamageRoundMode.Random: __result = GenMath.RoundRandom(adjustedDamage); break; case ShotgunDamageRoundMode.Ceil: __result = Mathf.CeilToInt(adjustedDamage); break; case ShotgunDamageRoundMode.Floor: __result = Mathf.FloorToInt(adjustedDamage); break; default: throw new NotImplementedException(); } } }
protected override bool TryCastShot() { bool castedShot = base.TryCastShot(); if (castedShot && CasterIsPawn) { CasterPawn.records.Increment(RecordDefOf.ShotsFired); } var shotgunExtension = ShotgunExtension.Get(verbProps.defaultProjectile); if (castedShot && shotgunExtension.pelletCount - 1 > 0) { for (int i = 0; i < shotgunExtension.pelletCount - 1; i++) { base.TryCastShot(); } } return(castedShot); }