public static bool Prefix(AbstractActor __instance) { CustomAmmoCategoriesLog.Log.LogWrite("CalcAndSetAlphaStrikesRemaining " + __instance.DisplayName + "\n"); if (__instance.ammoBoxes.Count < 1) { CustomAmmoCategoriesLog.Log.LogWrite(" no ammo boxes\n"); return(true); } ; Dictionary <string, int> ammoUsed = new Dictionary <string, int>(); for (int index1 = 0; index1 < __instance.Weapons.Count; ++index1) { CustomAmmoCategoriesLog.Log.LogWrite(" weapon " + __instance.Weapons[index1].defId + "\n"); string ammoId = CustomAmmoCategories.getWeaponAmmoId(__instance.Weapons[index1]); CustomAmmoCategoriesLog.Log.LogWrite(" ammoId " + ammoId + "\n"); if (string.IsNullOrEmpty(ammoId)) { continue; } ; if (ammoUsed.ContainsKey(ammoId)) { ammoUsed[ammoId] += __instance.Weapons[index1].ShotsWhenFired; } else { ammoUsed[ammoId] = __instance.Weapons[index1].ShotsWhenFired; } CustomAmmoCategoriesLog.Log.LogWrite(" ammoUsed[" + ammoId + "] = " + ammoUsed[ammoId] + "\n"); } Dictionary <string, int> ammoAvaible = new Dictionary <string, int>(); for (int index1 = 0; index1 < __instance.ammoBoxes.Count; ++index1) { CustomAmmoCategoriesLog.Log.LogWrite(" ammo box " + __instance.ammoBoxes[index1].defId + "\n"); string ammoId = __instance.ammoBoxes[index1].ammoDef.Description.Id; CustomAmmoCategoriesLog.Log.LogWrite(" ammoId " + ammoId + "\n"); if (ammoAvaible.ContainsKey(ammoId)) { ammoAvaible[ammoId] += __instance.ammoBoxes[index1].CurrentAmmo; } else { ammoAvaible[ammoId] = __instance.ammoBoxes[index1].CurrentAmmo; } CustomAmmoCategoriesLog.Log.LogWrite(" ammoAvaible[" + ammoId + "] = " + ammoAvaible[ammoId] + "\n"); } for (int index = 0; index < __instance.Weapons.Count; ++index) { CustomAmmoCategoriesLog.Log.LogWrite(" weapon " + __instance.Weapons[index].defId + "\n"); string ammoId = CustomAmmoCategories.getWeaponAmmoId(__instance.Weapons[index]); CustomAmmoCategoriesLog.Log.LogWrite(" ammoId " + ammoId + "\n"); if (string.IsNullOrEmpty(ammoId)) { continue; } ; int ammoCountAvaible = 0; if (ammoAvaible.ContainsKey(ammoId)) { ammoCountAvaible = ammoAvaible[ammoId]; } ; int ammoCountUsed = 0; if (ammoUsed.ContainsKey(ammoId)) { ammoCountUsed = ammoUsed[ammoId]; } ; if (ammoCountUsed == 0) { continue; } ; __instance.Weapons[index].AlphaStrikesRemaining = (float)ammoCountAvaible / (float)ammoCountUsed + (float)__instance.Weapons[index].InternalAmmo / (float)__instance.Weapons[index].ShotsWhenFired; } CustomAmmoCategoriesLog.Log.LogWrite(" done\n"); return(false); }