Пример #1
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            NetState sender = state;

            m_From = state.Mobile;

            // some anti crash/abuse checks
            if (sender == null ||
                sender.Mobile == null || sender.Mobile.Deleted ||
                sender.Mobile.Backpack == null ||
                info == null)
            {
                return;
            }

            if (!m_SkillBall.IsChildOf(sender.Mobile.Backpack))
            {
                sender.Mobile.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
                return;
            }

            // a skill was chosen
            if (info.ButtonID >= 1 && info.ButtonID <= numSkills)
            {
                if (GMsSelected < 7)
                {
                    GMSkills[info.ButtonID - 1] = true;
                }

                sender.Mobile.SendGump(new SevenGMSkillBallGump(m_SkillBall, sender.Mobile, m_GumpHeadline, GMSkills));
            }

            // Clear
            if (info.ButtonID == -1)
            {
                sender.Mobile.SendGump(new SevenGMSkillBallGump(m_SkillBall, sender.Mobile, m_GumpHeadline, new bool[numSkills]));
            }

            // Set the Skills
            if (info.ButtonID == -2)
            {
                if (!m_SkillBall.IsValidSkillBallUse(sender.Mobile) ||
                    m_SkillBall.Deleted || m_SkillBall == null ||
                    m_From.Deleted || m_From == null ||
                    m_From.Backpack == null ||
                    !m_SkillBall.IsChildOf(sender.Mobile.Backpack))
                {
                    return;
                }

                m_SkillBall.Delete();
                ((PlayerMobile)m_From).Young = false;

                // set the new skills
                for (int cnt = 0; cnt < numSkills; cnt++)
                {
                    if (GMSkills[cnt] && !m_SkillBall.IsRestrictedSkill((SkillName)cnt))
                    {
                        m_From.Skills[cnt].Base = m_SkillBall.SkillValue;
                    }
                    else
                    {
                        m_From.Skills[cnt].Base = 0;
                    }
                }
            }

            // Reset - nothing to do
        }