public static bool Prefix(AttackDirector.AttackSequence __instance, ref MessageCenterMessage message) { AttackSequenceImpactMessage impactMessage = (AttackSequenceImpactMessage)message; if (impactMessage.hitInfo.attackSequenceId != __instance.id) { return(true); } int attackGroupIndex = impactMessage.hitInfo.attackGroupIndex; int attackWeaponIndex = impactMessage.hitInfo.attackWeaponIndex; Weapon weapon = __instance.GetWeapon(attackGroupIndex, attackWeaponIndex); float rawDamage = impactMessage.hitDamage; float realDamage = rawDamage; CustomAmmoCategoriesLog.Log.LogWrite("OnAttackSequenceImpact\n"); CustomAmmoCategoriesLog.Log.LogWrite(" attacker = " + __instance.attacker.DisplayName + "\n"); CustomAmmoCategoriesLog.Log.LogWrite(" target = " + __instance.target.DisplayName + "\n"); CustomAmmoCategoriesLog.Log.LogWrite(" weapon = " + weapon.UIName + "\n"); CustomAmmoCategoriesLog.Log.LogWrite(" damage = " + rawDamage + "\n"); if (realDamage >= 1.0f) { if (CustomAmmoCategories.getWeaponDamageVariance(weapon) > CustomAmmoCategories.Epsilon) { realDamage = CustomAmmoCategories.WeaponDamageSimpleVariance(weapon, rawDamage); } if (CustomAmmoCategories.getWeaponDistantVariance(weapon) > CustomAmmoCategories.Epsilon) { if (CustomAmmoCategories.getWeaponDistantVarianceReversed(weapon)) { realDamage = CustomAmmoCategories.WeaponDamageDistance(__instance.attacker, __instance.target, weapon, realDamage, rawDamage); } else { realDamage = CustomAmmoCategories.WeaponDamageRevDistance(__instance.attacker, __instance.target, weapon, realDamage, rawDamage); } } } else { CustomAmmoCategoriesLog.Log.LogWrite("WARNING! raw damage is less than 1.0f. Variance calculation is forbidden with this damage value\n", true); } CustomAmmoCategoriesLog.Log.LogWrite(" real damage = " + realDamage + "\n"); if (realDamage < CustomAmmoCategories.Epsilon) { CustomAmmoCategoriesLog.Log.LogWrite("WARNING! real damage is less than epsilon. May be negative. That is sad. Rounding to zero\n", true); realDamage = 0.0f; } impactMessage.hitDamage = realDamage; return(true); }