public static void RecordVehicleDamage(Vehicle __instance, VehicleChassisLocations vLoc, float totalDamage) { if (vLoc == VehicleChassisLocations.None || vLoc == VehicleChassisLocations.Invalid) { return; } RecordUnitDamage(vLoc.ToString(), totalDamage, __instance.GetCurrentArmor(vLoc), __instance.GetCurrentStructure(vLoc)); }
private static float PercentForLocation(Vehicle v, VehicleChassisLocations location) { if (v != null) { var maxs = MaxStructureForLocation(v, (int)location); var maxa = MaxArmorForLocation(v, (int)location); var cs = maxs; var ca = maxa; if (maxs == 0 || maxa == 0) { LogDebug($"Invalid location in vehicle {location.ToString()}"); return(1); } switch (location) { case VehicleChassisLocations.Turret: cs = v.TurretStructure; ca = v.TurretArmor; break; case VehicleChassisLocations.Left: cs = v.LeftSideStructure; ca = v.LeftSideArmor; break; case VehicleChassisLocations.Right: cs = v.RightSideStructure; ca = v.RightSideArmor; break; case VehicleChassisLocations.Front: cs = v.FrontStructure; ca = v.FrontArmor; break; case VehicleChassisLocations.Rear: cs = v.RearStructure; ca = v.RearArmor; break; default: LogDebug($"Invalid location {location}"); break; } float percentArmor = ca / maxa; float percentStructure = cs / maxs; //since its easy to kill vehicles once past armor use the armor instead of structure unless structure is damaged. //this is reverse of mechs. //Remember the vehicle pilot motto - in armor we trust , structure is for the dead and defeated. float percentLocation = percentArmor; float numAdditions = 2; // Use the minimum percentage between structure and armor // This emphasizes internal damage from a blow through (back armor gone or tandem weapons) percentLocation += Math.Min(percentArmor, percentStructure); percentLocation /= numAdditions; LogReport($"{location.ToString(),-20} | A:{ca:F3}/{maxa:F3} = {percentArmor * 100,10}% , S:{cs:F3}/{maxs:F3} = {percentStructure * 100,10:F3}%"); return(percentLocation); } LogDebug($"Vehicle null"); return(0); }