public static bool Prefix(AttackDirector.AttackSequence __instance, Weapon weapon, int groupIdx, int weaponIdx, int numberOfShots, bool indirectFire, float dodgedDamage, ref WeaponHitInfo __result) { WeaponHitInfo hitInfo = new WeaponHitInfo(); hitInfo.attackerId = __instance.attacker.GUID; hitInfo.targetId = __instance.target.GUID; hitInfo.numberOfShots = numberOfShots; hitInfo.stackItemUID = __instance.stackItemUID; hitInfo.attackSequenceId = __instance.id; hitInfo.attackGroupIndex = groupIdx; hitInfo.attackWeaponIndex = weaponIdx; hitInfo.toHitRolls = new float[numberOfShots]; hitInfo.locationRolls = new float[numberOfShots]; hitInfo.dodgeRolls = new float[numberOfShots]; hitInfo.dodgeSuccesses = new bool[numberOfShots]; hitInfo.hitLocations = new int[numberOfShots]; hitInfo.hitPositions = new Vector3[numberOfShots]; hitInfo.hitVariance = new int[numberOfShots]; hitInfo.hitQualities = new AttackImpactQuality[numberOfShots]; if (AttackDirector.hitLogger.IsLogEnabled) { Vector3 collisionWorldPos; LineOfFireLevel lineOfFire = __instance.Director.Combat.LOS.GetLineOfFire(__instance.attacker, __instance.attackPosition, __instance.target, __instance.target.CurrentPosition, __instance.target.CurrentRotation, out collisionWorldPos); float allModifiers = __instance.Director.Combat.ToHit.GetAllModifiers(__instance.attacker, weapon, __instance.target, __instance.attackPosition + __instance.attacker.HighestLOSPosition, __instance.target.TargetPosition, lineOfFire, __instance.isMoraleAttack); string modifiersDescription = __instance.Director.Combat.ToHit.GetAllModifiersDescription(__instance.attacker, weapon, __instance.target, __instance.attackPosition + __instance.attacker.HighestLOSPosition, __instance.target.TargetPosition, lineOfFire, __instance.isMoraleAttack); Pilot pilot = __instance.attacker.GetPilot(); AttackDirector.hitLogger.Log((object)string.Format("======================================== Unit Firing: {0} | Weapon: {1} | Shots: {2}", (object)__instance.attacker.DisplayName, (object)weapon.Name, (object)numberOfShots)); AttackDirector.hitLogger.Log((object)string.Format("======================================== Hit Info: GROUP {0} | ID {1}", (object)groupIdx, (object)weaponIdx)); AttackDirector.hitLogger.Log((object)string.Format("======================================== MODIFIERS: {0}... FINAL: [[ {1} ]] ", (object)modifiersDescription, (object)allModifiers)); if (pilot != null) { AttackDirector.hitLogger.Log((object)__instance.Director.Combat.ToHit.GetBaseToHitChanceDesc(__instance.attacker)); } else { AttackDirector.hitLogger.Log((object)string.Format("======================================== Gunnery Check: NO PILOT")); } } float toHitChance = __instance.Director.Combat.ToHit.GetToHitChance(__instance.attacker, weapon, __instance.target, __instance.attackPosition, __instance.target.CurrentPosition, __instance.numTargets, __instance.meleeAttackType, __instance.isMoraleAttack); if (Mech.TEST_KNOCKDOWN) { toHitChance = 1f; } if (AttackDirector.hitLogger.IsLogEnabled) { AttackDirector.hitLogger.Log((object)string.Format("======================================== HIT CHANCE: [[ {0:P2} ]]", (object)toHitChance)); } hitInfo.attackDirection = __instance.Director.Combat.HitLocation.GetAttackDirection(__instance.attackPosition, __instance.target); hitInfo.attackDirectionVector = __instance.Director.Combat.HitLocation.GetAttackDirectionVector(__instance.attackPosition, __instance.target); object[] args = new object[6]; HitGeneratorType hitGenType = CustomAmmoCategories.getHitGenerator(weapon); switch (hitGenType) { case HitGeneratorType.Individual: args[0] = hitInfo; args[1] = groupIdx; args[2] = weaponIdx; args[3] = weapon; args[4] = toHitChance; args[5] = dodgedDamage; typeof(AttackDirector.AttackSequence).GetMethod("GetIndividualHits", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, args); hitInfo = (WeaponHitInfo)args[0]; break; case HitGeneratorType.Cluster: args[0] = hitInfo; args[1] = groupIdx; args[2] = weaponIdx; args[3] = weapon; args[4] = toHitChance; args[5] = dodgedDamage; typeof(AttackDirector.AttackSequence).GetMethod("GetClusteredHits", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, args); hitInfo = (WeaponHitInfo)args[0]; break; case HitGeneratorType.Streak: AttackSequence_GenerateHitInfo.GetStreakHits(__instance, ref hitInfo, groupIdx, weaponIdx, weapon, toHitChance, dodgedDamage); break; default: AttackDirector.attackLogger.LogError((object)string.Format("GenerateHitInfo found invalid weapon type: {0}, using basic hit info", (object)hitGenType)); args[0] = hitInfo; args[1] = groupIdx; args[2] = weaponIdx; args[3] = weapon; args[4] = toHitChance; args[5] = dodgedDamage; typeof(AttackDirector.AttackSequence).GetMethod("GetIndividualHits", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, args); hitInfo = (WeaponHitInfo)args[0]; break; } __result = hitInfo; return(false); //return hitInfo; }