Exemple #1
0
        public static BandageContext BeginHeal(Mobile healer, Mobile patient, Bandage bandage)
        {
            bool isDeadPet = (patient is BaseCreature && ((BaseCreature)patient).IsDeadPet);

            if (patient is BaseCreature && ((BaseCreature)patient).IsGolem)
            {
                // Bandages cannot be used on that.
                healer.SendLocalizedMessage(500970);
            }
            else if (patient is BaseCreature && ((BaseCreature)patient).IsAnimatedDead)
            {
                // You cannot heal that.
                healer.SendLocalizedMessage(500951);
            }
            else if (!patient.Poisoned && patient.Hits == patient.HitsMax && !BleedAttack.IsBleeding(patient) && !isDeadPet)
            {
                // That being is not damaged!
                healer.SendLocalizedMessage(500955);
            }
            else if (!patient.Alive && (patient.Map == null || !patient.Map.CanFit(patient.Location, 16, false, false)))
            {
                // Target cannot be resurrected at that location.
                healer.SendLocalizedMessage(501042);
            }
            else if (healer.CanBeBeneficial(patient, true, true))
            {
                healer.DoBeneficial(patient);

                bool onSelf = (healer == patient);
                int  dex    = healer.Dex;

                double seconds;
                double resDelay = (patient.Alive ? 0.0 : 5.0);

                if (onSelf)
                {
                    seconds = 5 + (0.5 * ((double)(120 - dex) / 10));                            // TODO: Verify algorithm
                }
                else
                {
                    if (GetPrimarySkill(patient, healer) == SkillName.Veterinary)
                    {
                        seconds = 2;
                    }
                    else
                    {
                        seconds = 4 - ((double)(dex / 60)) + resDelay;
                    }
                }

                if (seconds < 1)
                {
                    seconds = 1;
                }

                if (seconds > 8)
                {
                    seconds = 8;
                }

                BandageContext context = GetContext(healer);

                if (context != null)
                {
                    context.RefreshTimer(TimeSpan.FromSeconds(seconds));
                }
                else
                {
                    m_Table[healer] = context = new BandageContext(healer, patient, TimeSpan.FromSeconds(seconds), bandage);
                }

                if (!onSelf)
                {
                    patient.SendLocalizedMessage(1008078, false, healer.Name);                       //  : Attempting to heal you.
                }
                if (healer.Client != null)
                {
                    healer.Client.Send(new CooldownInfo(bandage, (int)seconds));
                }

                BuffInfo.AddBuff(healer, new BuffInfo(BuffIcon.Healing, 1151311, 1151400, TimeSpan.FromSeconds(seconds), healer, patient.Name));

                healer.SendLocalizedMessage(500956);                   // You begin applying the bandages.
                return(context);
            }

            return(null);
        }