コード例 #1
0
        public void FollowSubject(Mobile from)
        {
            Mobile subject = this.Subject;

            if (Deleted || subject == null)
            {
                return;
            }

            if (Charges == 0)
            {
                SendLocalizedMessageTo(from, 1054122); // The Crystal Ball darkens. It must be charged before it can be used again.
            }
            else if (!from.Alive || from.Hidden)
            {
                from.SendMessage("The Tracking Ball fills with an orange mist. You must be alive and unhidden to begin following.");
            }
            else if (m_State != MagicBallState.Idle)
            {
                from.SendMessage("The Tracking Ball shimmers. It is not ready to be used yet.");
            }
            else if (subject.Map == Map.Internal || subject.Deleted)
            {
                from.SendMessage("The Tracking Ball fills with a purple mist. Your subject cannot be found!");
            }
            else if (subject.AccessLevel > from.AccessLevel)
            {
                from.SendMessage("The Tracking Ball fills with a yellow mist. Your subject cannot be followed by you.");
            }
            else if (subject is BaseCreature && ((BaseCreature)subject).Summoned && ((BaseCreature)subject).SummonMaster != from)
            {
                from.SendMessage("The Tracking Ball vibrates. You cannot follow a summoned creature that you did not summon.");
            }
            else if (NeedSkillToFollow && !from.CheckSkill(FollowSkill.Name, FollowSkill.Value, 120))
            {
                from.SendMessage("The Tracking Ball darkens. You lacked enough {0} for the attempt. Try again.", FollowSkill.Name);
            }
            else if (NeedSecondSkillToFollow && !from.CheckSkill(FollowSecondSkill.Name, FollowSecondSkill.Value, 120))
            {
                from.SendMessage("The Tracking Ball darkens. You lacked enough {0} for the attempt. Try again.", FollowSkill.Name);
            }
            else
            {
                Charges--;

                double duration = 10.0;
                duration += 2.0 * ((from.Skills[RemainSkill.Name].Value - subject.Skills[ResistSkill].Value) / 10);
                if (duration < 2.0)
                {
                    duration = 2.0;
                }

                UserLocation   = from.Location;
                UserMap        = from.Map;
                from.Hidden    = true;
                from.Paralyzed = true;
                State          = MagicBallState.Following;
                CurrentUser    = from;

                CountDown = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(2.0), (int)(duration / 2),
                                            new TimerStateCallback(Tick), new object[] { from, duration });

                Timer t = new MagicBallIdleTimer(from, this, TimeSpan.FromSeconds(duration));
                t.Start();

                from.MoveToWorld(subject.Location, subject.Map);
                from.SendMessage("The Tracking Ball fills with a green mist. You begin following your subject.");
            }
        }
コード例 #2
0
        public void FollowSubject(Mobile from)
        {
            Mobile subject = this.Subject;

            if (Deleted || subject == null)
                return;

            if (Charges == 0)
            {
                SendLocalizedMessageTo(from, 1054122); // The Crystal Ball darkens. It must be charged before it can be used again.
            }
            else if (!from.Alive || from.Hidden)
            {
                from.SendMessage("The Crystal Ball fills with an orange mist. You must be alive and unhidden to begin following.");
            }
            else if (m_State != MagicBallState.Idle)
            {
                from.SendMessage("The Crystal Ball shimmers. It is not ready to be used yet.");
            }
            else if (subject.Map == Map.Internal || subject.Deleted)
            {
                from.SendMessage("The Crystal Ball fills with a purple mist. Your subject cannot be found!");
            }
            else if (subject.AccessLevel > from.AccessLevel)
            {
                from.SendMessage("The Crystal Ball fills with a yellow mist. Your subject cannot be followed by you.");
            }
            else if (subject is BaseCreature && ((BaseCreature)subject).Summoned && ((BaseCreature)subject).SummonMaster != from)
            {
                from.SendMessage("The Crystal Ball vibrates. You cannot follow a summoned creature that you did not summon.");
            }
            else if (NeedSkillToFollow && !from.CheckSkill(FollowSkill.Name, FollowSkill.Value, 120))
            {
                from.SendMessage("The Crystal Ball darkens. You lacked enough {0} for the attempt. Try again.", FollowSkill.Name);
            }
            else if (NeedSecondSkillToFollow && !from.CheckSkill(FollowSecondSkill.Name, FollowSecondSkill.Value, 120))
            {
                from.SendMessage("The Crystal Ball darkens. You lacked enough {0} for the attempt. Try again.", FollowSkill.Name);
            }
            else
            {
                Charges--;

                double duration = 10.0;
                duration += 2.0 * ((from.Skills[RemainSkill.Name].Value - subject.Skills[ResistSkill].Value) / 10);
                if (duration < 2.0) duration = 2.0;

                UserLocation = from.Location;
                UserMap = from.Map;
                from.Hidden = true;
                from.Paralyzed = true;
                State = MagicBallState.Following;
                CurrentUser = from;

                CountDown = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(2.0), (int)(duration / 2),
                    new TimerStateCallback(Tick), new object[] { from, duration });

                Timer t = new MagicBallIdleTimer(from, this, TimeSpan.FromSeconds(duration));
                t.Start();

                from.MoveToWorld(subject.Location, subject.Map);
                from.SendMessage("The Crystal Ball fills with a green mist. You begin following your subject.");
            }
        }