Пример #1
0
        public static void GiveScrollTo(Mobile killer, SpecialScroll scroll)
        {
            if (scroll == null || killer == null)               //sanity
            {
                return;
            }

            if (scroll is ScrollofTranscendence)
            {
                killer.SendLocalizedMessage(1094936);                   // You have received a Scroll of Transcendence!
            }
            else
            {
                killer.SendLocalizedMessage(1049524);                   // You have received a scroll of power!
            }
            if (killer.Alive)
            {
                killer.AddToBackpack(scroll);
            }
            else
            {
                if (killer.Corpse != null && !killer.Corpse.Deleted)
                {
                    killer.Corpse.DropItem(scroll);
                }
                else
                {
                    killer.AddToBackpack(scroll);
                }
            }

            // Justice reward
            PlayerMobile pm = (PlayerMobile)killer;

            for (int j = 0; j < pm.JusticeProtectors.Count; ++j)
            {
                Mobile prot = (Mobile)pm.JusticeProtectors[j];

                if (prot.Map != killer.Map || prot.Kills >= 5 || prot.Criminal || !JusticeVirtue.CheckMapRegion(killer, prot))
                {
                    continue;
                }

                int chance = 0;

                switch (VirtueHelper.GetLevel(prot, VirtueName.Justice))
                {
                case VirtueLevel.Seeker: chance = 60; break;

                case VirtueLevel.Follower: chance = 80; break;

                case VirtueLevel.Knight: chance = 100; break;
                }

                if (chance > Utility.Random(100))
                {
                    try
                    {
                        prot.SendLocalizedMessage(1049368);                           // You have been rewarded for your dedication to Justice!

                        SpecialScroll scrollDupe = Activator.CreateInstance(scroll.GetType()) as SpecialScroll;

                        if (scrollDupe != null)
                        {
                            scrollDupe.Skill = scroll.Skill;
                            scrollDupe.Value = scroll.Value;
                            prot.AddToBackpack(scrollDupe);
                        }
                    }
                    catch {}
                }
            }
        }