コード例 #1
0
        public override void OnDoubleClick(Mobile from)
        {
            if (IsChildOf(from.Backpack))
            {
                if (Title != null && (Title.String != null || Title.Number > 0))
                {
                    PlayerMobile pm = from as PlayerMobile;

                    if (pm != null)
                    {
                        if ((Title.Number > 0 && pm.AddCollectionTitle(Title.Number)) ||
                            Title.String != null && pm.AddCollectionTitle(Title.String))
                        {
                            pm.SendLocalizedMessage(1155605, Title.ToString());  //Thou hath been bestowed the title ~1_TITLE~!
                            Delete();
                        }
                        else
                        {
                            pm.SendLocalizedMessage(1073626); // You already have that title!
                        }
                    }
                }
            }
            else
            {
                from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
            }
        }
コード例 #2
0
        public void IncrementSlayerCount(PlayerMobile player)
        {
            SlayerTitleAttachment attachment = SlayerTitleSystem.FindAttachment(player);

            if (attachment != null)
            {
                SlayerSystemTracker tracker = attachment.FindSystemName(SlayerTitleName);

                if (tracker != null)
                {
                    tracker.SlayerCount += 1;

                    string newTitle = GetTitleAwarded(tracker.SlayerCount);

                    if (newTitle != null)
                    {
                        if (tracker.LastTitleAwarded == null || tracker.LastTitleAwarded != newTitle)
                        {
                            if (tracker.LastTitleAwarded != null && tracker.LastTitleAwarded != newTitle)
                            {
                                try { player.CollectionTitles.Remove(tracker.LastTitleAwarded); }
                                catch { }
                            }

                            player.AddCollectionTitle(newTitle);
                            tracker.LastTitleAwarded = newTitle;
                            player.SendSound(0x3D);
                            player.SendMessage(0xC8, String.Format("Your have been awarded the title of '{0}' for {1} kills.", newTitle, tracker.SlayerCount));
                        }
                    }
                }
            }
        }
コード例 #3
0
        public override void OnDoubleClick(Mobile from)
        {
            if (IsChildOf(from.Backpack) && Title != null && (Title.String != null || Title.Number > 0))
            {
                PlayerMobile pm = from as PlayerMobile;

                if (pm != null)
                {
                    if (Title.Number > 0)
                    {
                        pm.AddCollectionTitle(Title.Number);
                    }
                    else if (Title.String != null)
                    {
                        pm.AddCollectionTitle(Title.String);
                    }

                    pm.SendLocalizedMessage(1155605, Title.ToString());  //Thou hath been bestowed the title ~1_TITLE~!

                    Delete();
                }
            }
        }
コード例 #4
0
 public override void OnGiveReward(PlayerMobile to, IComunityCollection collection, int hue)
 {
     if (to.AddCollectionTitle(m_Title))
     {
         if (m_Title is int)
         {
             to.SendLocalizedMessage(1073625, "#" + (int)m_Title);                        // The title "~1_TITLE~" has been bestowed upon you.
         }
         else if (m_Title is string)
         {
             to.SendLocalizedMessage(1073625, (string)m_Title);                        // The title "~1_TITLE~" has been bestowed upon you.
         }
         to.AddCollectionPoints(collection.CollectionID, (int)Points * -1);
     }
     else
     {
         to.SendLocalizedMessage(1073626);                   // You already have that title!
     }
 }
コード例 #5
0
ファイル: SlayerTitleCore.cs プロジェクト: sadmoody/ServUO
        private void EventSink_OnKilledBy(OnKilledByEventArgs e)
        {
            if (!this.Enabled)
            {
                return;
            }

            BaseCreature creature = null;
            PlayerMobile player   = null;

            if (e.Killed is BaseCreature)
            {
                creature = (BaseCreature)e.Killed;
            }

            if (e.KilledBy is PlayerMobile)
            {
                player = (PlayerMobile)e.KilledBy;
            }

            SlayerModule module = player.GetModule(typeof(SlayerModule)) as SlayerModule;

            if (module == null)
            {
                module = new SlayerModule(player);
            }

            if (m_CrossReference.ContainsKey(creature.GetType()))
            {
                foreach (Int32 index in m_CrossReference[creature.GetType()])
                {
                    if (index < m_TitleDefinitions.Count && m_TitleDefinitions[index].CreatureRegistry.Contains(creature.GetType()))
                    {
                        TitleDefinition def = m_TitleDefinitions[index];

                        module.IncrementCounter(def.DefinitionName);

                        Int32      value      = module.GetSlayerCount(def.DefinitionName);
                        TitleEntry titleToSet = null;

                        foreach (TitleEntry entry in def.TitleRegistry)
                        {
                            if (entry.CountNeeded == value)
                            {
                                titleToSet = entry;
                            }
                        }

                        if (titleToSet != null)
                        {
                            foreach (TitleEntry entry in def.TitleRegistry)
                            {
                                if (player.CollectionTitles.Contains(entry.Title) && entry != titleToSet)
                                {
                                    player.CollectionTitles.Remove(entry.Title);
                                }
                            }

                            player.AddCollectionTitle(titleToSet.Title);
                            player.SendSound(0x3D);
                            player.SendMessage(0xC8, String.Format("Your have been awarded the title of '{0}' for {1} kills.", titleToSet.Title, value));

                            if (TitleAwarded != null)
                            {
                                TitleAwarded(player, def.DefinitionName, titleToSet.Title);
                            }

                            if (IsMaxTitle(titleToSet.Title, def.TitleRegistry) && MaximumTitleAchieved != null)
                            {
                                MaximumTitleAchieved(player, def.DefinitionName, titleToSet.Title);
                            }
                        }
                    }
                }
            }
        }