public static int DoWhileLevelUp(StatObject stat) { int gainedLevels = 0; do { if (stat.Level >= stat.MaxLevel) { break; } gainedLevels++; stat.Level++; stat.XP -= stat.XPToNextLevel; if (stat.XP < 0) { stat.XP = 0; } stat.XPToNextLevel = XP_Handler.CalcXPToNextLevel(stat.XPToNextLevel, stat.Modifier); }while (stat.XP >= stat.XPToNextLevel); return(gainedLevels); }
public static void ApplyUndefinedResist(Player __instance, DamageInfo damageInfo) { saveData.UndefinedResist_XP = AddXP(saveData.UndefinedResist_XP, damageInfo.damage); StatObject stat = new StatObject() { Name = "Undefined-Damage Resistance", Level = saveData.UndefinedResistLevel, MaxLevel = cfg.MaxUndefinedResistLevel, XP = saveData.UndefinedResist_XP, XPToNextLevel = saveData.UndefinedResist_XPToNextLevel, Modifier = cfg.UndefinedResist_XPNextLevel_Multiplier }; if (!StatMgr.CanLevelUp(stat)) { IgnoreDamage(__instance, damageInfo, StatMgr.CalcResistance(stat.Level)); return; } int gainedLevels = StatMgr.DoWhileLevelUp(stat); saveData.UndefinedResistLevel = stat.Level; saveData.UndefinedResist_XP = stat.XP; saveData.UndefinedResist_XPToNextLevel = stat.XPToNextLevel; Notify_ResistanceLevelUp(stat, gainedLevels, StatMgr.CalcResistance(stat.Level)); IgnoreDamage(__instance, damageInfo, StatMgr.CalcResistance(stat.Level)); }
public static bool CanLevelUp(StatObject stat) { if (stat.Level >= stat.MaxLevel) { return(false); } if (!XP_Handler.DoesHaveLevelUp(stat.XP, stat.XPToNextLevel)) { return(false); } LevelingSystem.PlayLevelUpSound(); return(true); }
public static void NotifyLevelUp(StatObject stat, int gainedLevels) { Random random = new Random(); StatMgr mgr = new StatMgr(); int responseNum = random.Next(0, mgr.singleLevelNotifs.Count - 1); if (gainedLevels == 1) { Logger.Log(String.Format(mgr.singleLevelNotifs[responseNum], stat.Name, stat.Level)); } else { Logger.Log(String.Format(mgr.multiLevelNotifs[responseNum], stat.Name, gainedLevels, stat.Level)); } if (stat.Level >= stat.MaxLevel) { int maxRandom = random.Next(0, mgr.maxLevelNotifs.Count - 1); Logger.Log(String.Format(mgr.maxLevelNotifs[maxRandom], stat.Name)); } }
public static void Notify_ResistanceLevelUp(StatObject stat, int gainedLevels, float currentResistance) { Random random = new Random(); DamageResistance d = new DamageResistance(); StatMgr mgr = new StatMgr(); int responseNum = random.Next(0, d.singleLevelNotifs.Count - 1); if (gainedLevels == 1) { Logger.Log(String.Format(d.singleLevelNotifs[responseNum], stat.Name, currentResistance)); } else { Logger.Log(String.Format(d.multiLevelNotifs[responseNum], stat.Name, gainedLevels, currentResistance)); } if (stat.Level >= stat.MaxLevel) { int maxRandom = random.Next(0, mgr.maxLevelNotifs.Count - 1); Logger.Log(String.Format(mgr.maxLevelNotifs[maxRandom], stat.Name) + ". Current resistance is at " + currentResistance + "%"); } }