private void Power_OnTarget(Mobile fromMobile, object obj, object state) { Player from = state as Player; Item item = obj as Item; if (item == null || item.Deleted) { return; } if (item is IEthicsItem) { EthicsItem ethicItem = EthicsItem.Find(item); if (item.Parent != fromMobile) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "You may only imbue items you are wearing."); } else if (ethicItem != null && ethicItem.Ethic != Ethic.Find(fromMobile)) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "The magic surrounding this item repels your attempts to imbue."); } else if (item is IFactionItem && ((IFactionItem)item).FactionItemState != null) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "The magic surrounding this item is too chaotic to imbue."); } else if (item.LootType != LootType.Regular || item.BlessedFor != null) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "The magic surrounding this item is too strong to imbue."); } //else if ( fromMobile.Map == Map.Felucca && !fromMobile.InRange( new Point3D( 2492, 3930, 5 ), 6 ) ) // fromMobile.LocalOverheadMessage( MessageType.Regular, 0x3B2, false, "You require the power of a heroic shrine to imbue this item." ); else if (!fromMobile.Backpack.ConsumeTotal(typeof(Gold), GoldRequired)) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, String.Format("You must sacrifice {0} gold piece{1} to imbue this item.", GoldRequired, (GoldRequired != 1) ? "s" : String.Empty)); } else if (CheckInvoke(from)) { if (ethicItem != null) { ethicItem.StartExpiration(); } else { EthicsItem.Imbue(item, Ethic.Hero, true, Ethic.Hero.Definition.PrimaryHue); } fromMobile.FixedEffect(0x375A, 10, 20); fromMobile.PlaySound(0x209); fromMobile.SendMessage("The item is now blessed against evil for 24 real world hours."); FinishInvoke(from); } } else { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "That cannot be imbued!"); } }
public override void OnDoubleClick(Mobile from) { if (Ethic.Find(from) != Ethic.Evil) { from.SendMessage("You may not ride this steed."); } else { base.OnDoubleClick(from); } }
public override DeathMoveResult OnInventoryDeath(Mobile parent) { DeathMoveResult result = base.OnParentDeath(parent); Ethic parentState = Ethic.Find(parent); if (parentState != null && result == DeathMoveResult.MoveToCorpse && m_EthicState != null && parentState == m_EthicState.Ethic) { return(DeathMoveResult.MoveToBackpack); } else { return(result); } }
private void Power_OnTarget(Mobile fromMobile, object obj, object state) { Player from = state as Player; Item item = obj as Item; if (item == null || item.Deleted) { return; } if (item is BaseArmor || item is BaseWeapon) { EthicsItem ethicItem = EthicsItem.Find(item); if (item.Parent != fromMobile) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "You may only imbue items you are wearing."); } else if (ethicItem == null) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "This item has not been imbued with an unholy curse."); } else if (ethicItem.Ethic != Ethic.Find(fromMobile)) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "The magic surrounding this item repels your attempts to imbue."); } else if (!fromMobile.Backpack.ConsumeTotal(typeof(Emerald), EmeraldsRequired)) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, String.Format("You must sacrifice {0} emerald{1} to imbue this item.", EmeraldsRequired, (EmeraldsRequired != 1) ? "s" : String.Empty)); } else if (CheckInvoke(from)) { ethicItem.MakeRunic(); fromMobile.FixedEffect(0x375A, 10, 20, 1156, 0); fromMobile.PlaySound(0x209); FinishInvoke(from); } } else { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500352); // This is neither weapon nor armor. } }
public override void OnDoubleClick(Mobile @from) { Ethic hero = Ethic.Find(from); if (!(hero is HeroEthic) && from.AccessLevel == AccessLevel.Player) { from.SendMessage(54, "You must follow the path of the hero to use this mount!"); return; } if (BoundMobile != from as PlayerMobile && from.AccessLevel == AccessLevel.Player) { from.SendMessage(54, "You cannot use this item as it is not bound to you!"); return; } base.OnDoubleClick(@from); }
private void Power_OnTarget(Mobile fromMobile, object obj, object state) { var from = state as Player; var item = obj as Item; if (item == null || item.Deleted) { return; } if (item is IEthicsItem) { EthicsItem ethicItem = EthicsItem.Find(item); if (item.Parent != fromMobile) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "You may only imbue items you are wearing."); } else if (ethicItem != null) { fromMobile.LocalOverheadMessage(MessageType.Regular, 32, false, "This item has already been imbued with an evil essence."); } else if (ethicItem != null && ethicItem.Ethic != Ethic.Find(fromMobile)) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "The magic surrounding this item repels your attempts to imbue."); } else if (item is IFactionItem && ((IFactionItem)item).FactionItemState != null) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "The magic surrounding this item is too chaotic to imbue."); } else if (item.LootType == LootType.Cursed) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "The magic surrounding this item resists your attempts to imbue."); } else if (item.LootType == LootType.Blessed && !(item is Spellbook) || item.BlessedFor != null) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "The magic surrounding this item is too strong to imbue."); } else if (!fromMobile.Backpack.ConsumeTotal(typeof(Gold), GoldRequired)) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, String.Format("You must sacrifice {0} gold piece{1} to imbue this item.", GoldRequired, (GoldRequired != 1) ? "s" : String.Empty)); } else if (CheckInvoke(from)) { /*if ( ethicItem != null ) * ethicItem.StartExpiration(); * else*/ EthicsItem.Imbue(item, Ethic.Evil, Ethic.Evil.Definition.PrimaryHue); fromMobile.FixedEffect(0x375A, 10, 20); fromMobile.PlaySound(0x209); fromMobile.LocalOverheadMessage(MessageType.Regular, 32, false, "You have imbued this item with an evil essence."); FinishInvoke(from); } } else { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "That cannot be imbued!"); } }
public PlayerDetailGump(PlayerMobile from, PlayerMobile mobile) { _from = from; _mobile = mobile; Width = 320; int n = Notoriety.Compute(from, mobile); int notoColor = _notorietyColors[n]; AddBorderedText(20, 18, Width - 40, 20, Center(mobile.Name ?? "Unknown"), notoColor, BlackColor32); AddSeperator(30, 40, Width - 60); const int LabelOffset = 20; const int LabelWidth = 55; const int ValueOffset = 25 + LabelWidth; int ValueWidth = Width - (20 + ValueOffset); int y = 44; PlayerMobile pm = mobile as PlayerMobile; Guild guild = mobile.Guild as Guild; if (guild != null) { AddBorderedText(LabelOffset, y, LabelWidth, 20, Right("Guild:"), LabelColor32, BlackColor32); AddBorderedText(ValueOffset, y, ValueWidth, 20, guild.Name ?? "Unknown", WhiteColor32, BlackColor32); y += 20; } if (mobile.PublicMyRunUO && mobile.Kills >= 5) { AddBorderedText(LabelOffset, y, LabelWidth, 20, Right("Kills:"), LabelColor32, BlackColor32); AddBorderedText(ValueOffset, y, ValueWidth, 20, mobile.Kills.ToString("N0"), WhiteColor32, BlackColor32); y += 20; } Account acct = mobile.Account as Account; if (acct != null) { TimeSpan age = DateTime.UtcNow - acct.Created; int ageInDays = ( int )age.TotalDays; int ageInYears = ((ageInDays + 162) / 365); int ageInMonths = ((ageInDays + 15) / 30); int ageInWeeks = ((ageInDays + 3) / 7); string ageString; if (ageInYears > 0) { ageString = String.Format("{0:N0} year{1}", ageInYears, ageInYears == 1?"":"s"); } else if (ageInMonths > 1) { ageString = String.Format("{0:N0} month{1}", ageInMonths, ageInMonths == 1?"":"s"); } else if (ageInWeeks > 1) { ageString = String.Format("{0:N0} week{1}", ageInWeeks, ageInWeeks == 1?"":"s"); } else { ageString = String.Format("Newbie", ageInDays, ageInDays == 1?"":"s"); } AddBorderedText(LabelOffset, y, LabelWidth, 20, Right("Age:"), LabelColor32, BlackColor32); AddBorderedText(ValueOffset, y, ValueWidth, 20, ageString, WhiteColor32, BlackColor32); y += 20; } PlayerState ps = PlayerState.Find(mobile); if (ps != null) { Faction fac = ps.Faction; //AddItem( Width - 51, 7, 5535, (fac.Definition.HueSecondary ^ 0x0000) - 1 ); AddItem(7, 7, 5534, (fac.Definition.HuePrimary ^ 0x0000) - 1); y += 8; AddBorderedText(LabelOffset, y, LabelWidth + ValueWidth, 20, fac.Definition.FriendlyName, WhiteColor32, BlackColor32); y += 21; AddSeperator(30, y, Width - 60); y += 3; string rank = String.Format( "Level {0} {1}", ps.Rank.Rank, ps.Rank.Title.String ); AddBorderedText(LabelOffset, y, LabelWidth, 20, Right("Rank:"), LabelColor32, BlackColor32); AddBorderedText(ValueOffset, y, ValueWidth, 20, rank, WhiteColor32, BlackColor32); y += 20; AddBorderedText(LabelOffset, y, LabelWidth, 20, Right("Points:"), LabelColor32, BlackColor32); AddBorderedText(ValueOffset, y, ValueWidth, 20, String.Format("{0:N0}", ps.KillPoints), WhiteColor32, BlackColor32); y += 20; } Ladder instance = Ladder.Instance; if (instance != null) { LadderEntry entry = instance.Find(mobile); if (entry != null && (entry.Wins + entry.Losses) > 0) { y += 8; AddBorderedText(LabelOffset, y, LabelWidth + ValueWidth, 20, "Duelist", WhiteColor32, BlackColor32); y += 21; AddSeperator(30, y, Width - 60); y += 3; string rank = LadderGump.Rank(entry.Index + 1); AddBorderedText(LabelOffset, y, LabelWidth, 20, Right("Rank:"), LabelColor32, BlackColor32); AddBorderedText(ValueOffset, y, ValueWidth, 20, rank, WhiteColor32, BlackColor32); y += 20; AddBorderedText(LabelOffset, y, LabelWidth, 20, Right("Level:"), LabelColor32, BlackColor32); AddBorderedText(ValueOffset, y, ValueWidth, 20, Ladder.GetLevel(entry.Experience).ToString("N0"), WhiteColor32, BlackColor32); y += 20; AddBorderedText(LabelOffset, y, LabelWidth, 20, Right("Matches:"), LabelColor32, BlackColor32); AddBorderedText(ValueOffset, y, ValueWidth, 20, String.Format("{0:N0}", (entry.Wins + entry.Losses)), WhiteColor32, BlackColor32); y += 20; } } Height = y + 12; Ethic ethic = Ethic.Find(mobile); if (ethic == Ethic.Hero) { AddItem(Width - 36, Height - 26, 7188); } else if (ethic == Ethic.Evil) { AddItem(Width - 35, Height - 36, 6232); } }
private void Power_OnTarget(Mobile fromMobile, object obj, object state) { var from = state as Player; var item = obj as Item; if (item == null || item.Deleted) { return; } if (item is BaseArmor || item is BaseWeapon) { EthicsItem ethicItem = EthicsItem.Find(item); if (item.Parent != fromMobile) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "You may only imbue items you are wearing."); } else if (ethicItem == null) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "This item has not been imbued with a holy blessing."); } else if (ethicItem.Ethic != Ethic.Find(fromMobile)) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "The magic surrounding this item repels your attempts to imbue."); } else if (item is BaseWeapon && ((BaseWeapon)item).DamageLevel != WeaponDamageLevel.Regular || item is BaseArmor && ((BaseArmor)item).ProtectionLevel != ArmorProtectionLevel.Regular) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "You cannot imbue magic items!"); } else if (!fromMobile.Backpack.ConsumeTotal(typeof(Sapphire), SapphiresRequired)) { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, String.Format("You must sacrifice {0} sapphire{1} to imbue this item.", SapphiresRequired, (SapphiresRequired != 1) ? "s" : String.Empty)); } else if (CheckInvoke(from)) { if (!ethicItem.IsRunic) { ethicItem.StartExpiration(); ethicItem.MakeRunic(); fromMobile.FixedEffect(0x375A, 10, 20, 1153, 0); fromMobile.PlaySound(0x209); FinishInvoke(from); fromMobile.LocalOverheadMessage(MessageType.Regular, 90, false, "You have sanctified this item."); } else { fromMobile.LocalOverheadMessage(MessageType.Regular, 90, false, "You have already sanctified this item."); } } } else { fromMobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500352); // This is neither weapon nor armor. } }
public override void PopulateGump() { bool isLeader = IsLeader(player, guild); base.PopulateGump(); AddHtmlLocalized(96, 43, 110, 26, 1063014, 0xF, false, false); // My Guild AddImageTiled(65, 80, 160, 26, 0xA40); AddImageTiled(67, 82, 156, 22, 0xBBC); AddHtmlLocalized(70, 83, 150, 20, 1062954, 0x0, false, false); // <i>Guild Name</i> AddHtml(233, 84, 320, 26, guild.Name, false, false); AddImageTiled(65, 114, 160, 26, 0xA40); AddImageTiled(67, 116, 156, 22, 0xBBC); AddHtmlLocalized(70, 117, 150, 20, 1063025, 0x0, false, false); // <i>Alliance</i> if (guild.Alliance != null && guild.Alliance.IsMember(guild)) { AddHtml(233, 118, 320, 26, guild.Alliance.Name, false, false); AddButton(40, 120, 0x4B9, 0x4BA, 6, GumpButtonType.Reply, 0); //Alliance Roster } if (Faction.Enabled || Ethic.Enabled) { AddImageTiled(65, 148, 160, 26, 0xA40); AddImageTiled(67, 150, 156, 22, 0xBBC); AddHtmlLocalized(70, 151, 150, 20, 1063084, 0x0, false, false); // <i>Guild Faction</i> if (Faction.Enabled) { Faction f = Faction.Find(guild.Leader); if (f != null) { AddHtml(233, 152, 320, 26, f.ToString(), false, false); } } else { Ethic e = Ethic.Find(guild.Leader); if (e != null) { AddHtml(233, 152, 320, 26, e.Definition.Title, false, false); } } } if (isLeader) { bool neutral = true; bool order = false; bool chaos = false; if (guild.Type != GuildType.Regular) { neutral = false; if (guild.Type == GuildType.Chaos) { chaos = true; } else { order = true; } } //Begin Order/Chaos AddRadio(440, 75, 9727, 9730, neutral, 1); //neutral AddLabel(480, 80, 2622, @"Neutral"); AddRadio(440, 105, 9727, 9730, order, 2); //order AddLabel(480, 110, 90, @"Order"); AddRadio(440, 135, 9727, 9730, chaos, 3); //chaos AddLabel(480, 140, 32, @"Chaos"); AddButton(465, 175, 247, 248, 8, GumpButtonType.Reply, 0); //accept } AddImageTiled(65, 196, 480, 4, 0x238D); string s = guild.Charter; if (String.IsNullOrEmpty(s)) { s = "The guild leader has not yet set the guild charter."; } AddHtml(65, 216, 480, 80, s, true, true); if (isLeader) { AddButton(40, 251, 0x4B9, 0x4BA, 4, GumpButtonType.Reply, 0); //Charter Edit button } s = guild.Website; if (string.IsNullOrEmpty(s)) { s = "Guild website not yet set."; } AddHtml(65, 306, 480, 30, s, true, false); if (isLeader) { AddButton(40, 313, 0x4B9, 0x4BA, 5, GumpButtonType.Reply, 0); //Website Edit button } AddCheck(65, 370, 0xD2, 0xD3, player.DisplayGuildTitle, 0); AddHtmlLocalized(95, 370, 150, 26, 1063085, 0x0, false, false); // Show Guild Title AddBackground(450, 370, 100, 26, 0x2486); AddButton(455, 375, 0x845, 0x846, 7, GumpButtonType.Reply, 0); AddHtmlLocalized(480, 373, 60, 26, 3006115, (m_IsResigning) ? 0x5000 : 0, false, false); // Resign }
public void InvitePlayer_Callback(Mobile from, object targeted, object state) { PlayerMobile pm = from as PlayerMobile; PlayerMobile targ = targeted as PlayerMobile; Guild g = state as Guild; PlayerState guildState = PlayerState.Find(g.Leader); PlayerState targetState = PlayerState.Find(targ); Faction guildFaction = (guildState == null ? null : guildState.Faction); Faction targetFaction = (targetState == null ? null : targetState.Faction); Ethic guildEthic = Ethic.Find(g.Leader); Ethic targetEthic = Ethic.Find(targ); if (pm == null || !IsMember(pm, guild) || !pm.GuildRank.GetFlag(RankFlags.CanInvitePlayer)) { pm.SendLocalizedMessage(503301); // You don't have permission to do that. } else if (targ == null) { pm.SendLocalizedMessage(1063334); // That isn't a valid player. } else if (!targ.AcceptGuildInvites) { pm.SendLocalizedMessage(1063049, targ.Name); // ~1_val~ is not accepting guild invitations. } else if (g.IsMember(targ)) { pm.SendLocalizedMessage(1063050, targ.Name); // ~1_val~ is already a member of your guild! } else if (targ.Guild != null) { pm.SendLocalizedMessage(1063051, targ.Name); // ~1_val~ is already a member of a guild. } else if (targ.HasGump(typeof(BaseGuildGump)) || targ.HasGump(typeof(CreateGuildGump))) //TODO: Check message if CreateGuildGump Open { pm.SendLocalizedMessage(1063052, targ.Name); // ~1_val~ is currently considering another guild invitation. } #region Factions else if (targ.Young && guildFaction != null) { pm.SendLocalizedMessage(1070766); // You cannot invite a young player to your faction-aligned guild. } else if (guildFaction != targetFaction) { if (guildFaction == null) { pm.SendLocalizedMessage(1013027); // That player cannot join a non-faction guild. } else if (targetFaction == null) { pm.SendLocalizedMessage(1013026); // That player must be in a faction before joining this guild. } else { pm.SendLocalizedMessage(1013028); // That person has a different faction affiliation. } } else if (guildEthic != targetEthic) { if (guildEthic == null) { pm.SendMessage("That player cannot join a non-ethic guild."); } else if (targetEthic == null) { pm.SendMessage("That player must be {0} {1} before joining this guild.", guildEthic.Definition.ArticleAn ? "an" : "a", guildEthic.Definition.Title); } else { pm.SendMessage("That player is {0} {1}! You cannot recruit {2}!", targetEthic.Definition.ArticleAn ? "an" : "a", targetEthic.Definition.Title, targ.Female ? "her" : "him"); } } else if (targetState != null && targetState.IsLeaving) { // OSI does this quite strangely, so we'll just do it this way pm.SendMessage("That person is quitting their faction and so you may not recruit them."); } #endregion else { pm.SendLocalizedMessage(1063053, targ.Name); // You invite ~1_val~ to join your guild. targ.SendGump(new GuildInvitationRequest(targ, guild, pm)); } }
public static void EventSink_PlayerDeath(PlayerDeathEventArgs e) { Mobile m = e.Mobile; List <Mobile> killers = new List <Mobile>(); List <Mobile> toGive = new List <Mobile>(); foreach (AggressorInfo ai in m.Aggressors) { if (Ethic.Find(ai.Attacker) == null || Ethic.Find(m) == null) { //Allow people of the same ethic to flag each other as murderers? Factioners can? if (ai.Attacker.Player && ai.CanReportMurder && !ai.Reported && (!Core.SE || !((PlayerMobile)m).RecentlyReported.Contains(ai.Attacker))) { killers.Add(ai.Attacker); ai.Reported = true; ai.CanReportMurder = false; } if (ai.Attacker.Player && (DateTime.Now - ai.LastCombatTime) < TimeSpan.FromSeconds(30.0) && !toGive.Contains(ai.Attacker)) { toGive.Add(ai.Attacker); } } } foreach (AggressorInfo ai in m.Aggressed) { if (ai.Defender.Player && (DateTime.Now - ai.LastCombatTime) < TimeSpan.FromSeconds(30.0) && !toGive.Contains(ai.Defender)) { toGive.Add(ai.Defender); } } foreach (Mobile g in toGive) { int n = Notoriety.Compute(g, m); int theirKarma = m.Karma, ourKarma = g.Karma; bool innocent = (n == Notoriety.Innocent); bool criminal = (n == Notoriety.Criminal || n == Notoriety.Murderer); int fameAward = m.Fame / 200; int karmaAward = 0; if (innocent) { karmaAward = (ourKarma > -2500 ? -850 : -110 - (m.Karma / 100)); } else if (criminal) { karmaAward = 50; } Titles.AwardFame(g, fameAward, false); Titles.AwardKarma(g, karmaAward, true); } if (m is PlayerMobile && ((PlayerMobile)m).NpcGuild == NpcGuild.ThievesGuild) { return; } if (killers.Count > 0) { new GumpTimer(m, killers, m.Location, m.Map).Start(); } }