public static int ComputeExperienceGain(this CharacterInstance ch, CharacterInstance victim) { var xp = victim.GetExperienceWorth() * 0.GetNumberThatIsBetween(victim.Level - ch.Level + 10, 13) / 10; var align = ch.CurrentAlignment - victim.CurrentAlignment; if (align > 990 || align < -990) { xp = ModifyXPForAttackingOppositeAlignment(xp); } else if (ch.CurrentAlignment > 300 && align < 250) { xp = ModifyXPForGoodPlayerAttackingSameAlignment(xp); } xp = SmaugRandom.Between((xp * 3) >> 2, (xp * 5) >> 2); if (!victim.IsNpc()) { xp /= 4; } else if (!ch.IsNpc()) { xp = ReduceXPForKillingSameMobRepeatedly(ch, (MobileInstance)victim, xp); } if (!ch.IsNpc() && ch.Level > 5) { xp = ModifyXPForExperiencedVsNovicePlayer(ch, xp); } //// Level based experience gain cap. Cannot get more experience for //// a kill than the amount for your current experience level return(0.GetNumberThatIsBetween(xp, ch.GetExperienceLevel(ch.Level + 1) - ch.GetExperienceLevel(ch.Level))); }
/// <summary> /// /// </summary> /// <param name="gch"></param> /// <param name="victim"></param> /// <returns></returns> public static int CalculateXP(this CharacterInstance gch, CharacterInstance victim) { int xp = victim.GetExperienceWorth() * Macros.URANGE(0, victim.Level - gch.Level + 10, 13) / 10; int align = gch.CurrentAlignment - victim.CurrentAlignment; // Bonus for opposite alignment if (align > 990 || align < -990) { xp = (xp * 5) >> 2; } else { // Penalty for good attacking same alignment if (gch.CurrentAlignment > 300 && align < 250) { xp = (xp * 3) >> 2; } } xp = SmaugRandom.Between((xp * 3) >> 2, (xp * 5) >> 2); // 1/4 XP for players if (!victim.IsNpc()) { xp /= 4; } else { // Reduce XP for killing the same mob repeatedly if (!gch.IsNpc()) { int times = handler.times_killed(gch, victim); if (times >= 20) { xp = 0; } else if (times > 0) { xp = (xp * (20 - times)) / 20; if (times > 15) { xp /= 3; } else if (times > 10) { xp >>= 1; } } } } // Semi-intelligent experienced player vs notice player if (!gch.IsNpc() && gch.Level > 5) { var xp_ratio = (int)((PlayerInstance)gch).TotalPlayedTime / gch.Level; if (xp_ratio > 20000) { xp = (xp * 5) >> 2; } else if (xp_ratio > 16000) { xp = (xp * 3) >> 2; } else if (xp_ratio > 10000) { xp >>= 1; } else if (xp_ratio > 5000) { xp >>= 2; } else if (xp_ratio > 3500) { xp >>= 3; } else if (xp_ratio > 2000) { xp >>= 4; } } // Level based xp gain cap return(Macros.URANGE(0, xp, handler.exp_level(gch, gch.Level + 1) - handler.exp_level(gch, gch.Level))); }