public void Grant() { if (m_Mobile is PlayerMobile) { RankDefinition[] defs = m_Ethic.Definition.Ranks; TitleProfile p = CustomTitles.EnsureProfile(m_Mobile as PlayerMobile); Title title = null; TitleHue hue = null; if (CustomTitles.TryGetTitle(defs[0].Title, out title) && !p.Contains((title))) { p.Add(title); } if (CustomTitles.TryGetHue(m_Ethic.Definition.TitleHue, out hue) && !p.Contains(hue)) { p.Add(hue); } m_Mobile.SendMessage(54, "You have decided to follow the path of {0}!", m_Ethic.Definition.Title); m_Mobile.SendMessage(54, "You have been granted the title {0} and the title hue {1}.", defs[0].Title, m_Ethic.Definition.TitleHue); m_Mobile.SendMessage(54, "You have been granted an ethic spellbook."); if (m_Mobile.Backpack != null) { Item spellbook; if (m_Ethic == Ethic.Evil) { spellbook = new Evilspellbook(); m_Mobile.AddToBackpack(spellbook); } else if (m_Ethic == Ethic.Hero) { spellbook = new Herospellbook(); m_Mobile.AddToBackpack(spellbook); } } } }
public override void GiveSpecialItems(List <Mobile> eligibleMobs, List <double> eligibleMobScores, double totalScores) { double currentTestValue = 0.0; double roll = Utility.RandomDouble() * totalScores; if (0.50 >= Utility.RandomDouble()) { for (int i = 0; i < eligibleMobScores.Count; i++) { currentTestValue += eligibleMobScores[i]; if (roll > currentTestValue) { continue; } if (!(eligibleMobs[i] is PlayerMobile) || eligibleMobs[i].Backpack == null) { continue; } var statue = new HydraStatue(); eligibleMobs[i].Backpack.DropItem(statue); eligibleMobs[i].SendMessage(54, "You have received a Hydra statue!"); break; } } TitleHue titlehue; if (!CustomTitles.TryGetHue(1259, out titlehue) || titlehue == null) { return; } PlayerMobile titleWinner = Scores.OrderByDescending(kv => kv.Value).Select(kv => kv.Key).OfType <PlayerMobile>().FirstOrDefault(); if (titleWinner == null) { return; } TitleProfile p = CustomTitles.EnsureProfile(titleWinner); if (p == null || p.Contains(titlehue)) { return; } p.Add(titlehue); titleWinner.SendMessage(titlehue.Hue, "You have been granted the title hue: " + titlehue.Hue); }
public void Detach() { if (m_Mobile is PlayerMobile) { RankDefinition[] defs = m_Ethic.Definition.Ranks; (m_Mobile as PlayerMobile).EthicPlayer = null; TitleProfile p = CustomTitles.EnsureProfile(m_Mobile as PlayerMobile); TitleHue hue = null; if (CustomTitles.TryGetHue(m_Ethic.Definition.TitleHue, out hue) && p.Contains(hue)) { if (p.SelectedHue != null && p.SelectedHue.Hue == hue.Hue) { p.SelectedHue = null; } p.Remove(hue); } foreach (var rank in defs) { Title title; if (CustomTitles.TryGetTitle(rank.Title, out title) && p.Contains(title)) { if (p.SelectedTitle != null && p.SelectedTitle.MaleTitle == title.MaleTitle) { p.SelectedTitle = null; } p.Remove(title); } } m_Ethic.Players.Remove(this); m_Mobile.SendMessage(54, "You have departed from the path of {0}!", m_Ethic.Definition.Title); m_Mobile.SendMessage(54, "For your abandonment of this ethic, you have been stripped of all ethic titles and the title hue {0}.", m_Ethic.Definition.TitleHue); } }
public override void GivePowerScrolls() { if (ChampSpawn == null && !AlwaysDropScrolls) { return; } var scores = new Dictionary <Mobile, double>(Scores); var toReceiveScroll = new List <Mobile>(); // first find all eligible receivers var eligibleMobs = new List <Mobile>(); var eligibleMobScores = new List <double>(); List <KeyValuePair <Mobile, double> > orderedscores = scores.ToList(); orderedscores.Sort((firstPair, nextPair) => firstPair.Value.CompareTo(nextPair.Value)); orderedscores.Reverse(); double totalScores = 0.0; var sb = new StringBuilder(); sb.Append("========== " + DateTime.Now + " Champion " + GetType() + " Report ==============\r\n"); sb.Append( "Score\tEligible\tName\tAccount\tAddress\tStr\tInt\tDex\tTaming\tProvocation\tMagery\tArchery\tMace\tFencing\tSwords\tLumberjack\tWrestling\tAnatomy\r\n"); foreach (KeyValuePair <Mobile, double> pair in scores) { Mobile mob = pair.Key; if (mob == null) { continue; } bool eligible = IsEligible(mob); sb.Append( pair.Value + "\t" + eligible + "\t" + mob + "\t" + mob.Account + "\t" + mob.Address + "\t" + mob.Str + "\t" + mob.Int + "\t" + mob.Dex + "\t" + mob.Skills.AnimalTaming.Value + "\t" + mob.Skills.Provocation.Value + "\t" + mob.Skills.Magery.Value + "\t" + mob.Skills.Archery.Value + "\t" + mob.Skills.Macing.Value + "\t" + mob.Skills.Fencing.Value + "\t" + mob.Skills.Swords.Value + "\t" + mob.Skills.Lumberjacking.Value + "\t" + mob.Skills.Wrestling.Value + "\t" + mob.Skills.Anatomy.Value + "\r\n"); if (!eligible) { continue; } eligibleMobs.Add(mob); eligibleMobScores.Add(pair.Value); totalScores += pair.Value; } for (int powerScrollIndex = 0; powerScrollIndex < ChampionGlobals.CSOptions.PowerScrollsToGive; powerScrollIndex++) { double currentTestValue = 0.0; double roll = Utility.RandomDouble() * totalScores; for (int i = 0; i < eligibleMobScores.Count; i++) { currentTestValue += eligibleMobScores[i]; if (roll > currentTestValue) { continue; } toReceiveScroll.Add(eligibleMobs[i]); totalScores -= eligibleMobScores[i]; // remove them from eligible list now eligibleMobs.RemoveAt(i); eligibleMobScores.RemoveAt(i); break; } } foreach (PlayerMobile mobile in scores.Keys.OfType <PlayerMobile>()) { PlayerMobile mobile1 = mobile; Timer.DelayCall( TimeSpan.FromMinutes(1), () => { var scrollgump = new PlayerScoresScrollGump(mobile1, onAccept: x => { var scoreboard = new PlayerScoreResultsGump(mobile1, this, scores, toReceiveScroll). Send <PlayerScoreResultsGump>(); }).Send <PlayerScoresScrollGump>(); }); } foreach (Mobile luckyPlayer in toReceiveScroll) { PowerScroll ps = CreateRandomPowerScroll(Expansion); if (ps == null) { continue; } GivePowerScrollTo(luckyPlayer, ps); sb.Append(luckyPlayer + " received powerScoll " + ps.Skill + " " + ps.Value + "\r\n"); } foreach (PlayerMobile pm in orderedscores.Select(kvp => kvp.Key as PlayerMobile)) { TitleHue titlehue; CustomTitles.TryGetHue(1196, out titlehue); TitleProfile p = CustomTitles.EnsureProfile(pm); if (pm != null && titlehue != null && p != null && !p.Contains(titlehue)) { p.Add(titlehue); pm.SendMessage(titlehue.Hue, "You have been granted the title hue: " + titlehue.Hue); sb.Append(pm + " received titlehue " + titlehue.Hue + "\r\n"); break; } } LoggingCustom.Log("ChampionScores/" + IOUtility.GetSafeFileName(GetType().FullName) + ".log", sb.ToString()); }