示例#1
0
        public void EndHeal()
        {
            StopHeal();

            int healerNumber;
            int patientNumber;

            bool playSound = true;
            bool checkRes  = false;
            bool checkPois = false;

            SkillName primarySkill   = GetPrimarySkill(m_Patient);
            SkillName secondarySkill = GetSecondarySkill(m_Patient);

            var petPatient = m_Patient as BaseCreature;

            if (!m_Healer.Alive)
            {
                healerNumber  = 500962;                // You were unable to finish your work before you died.
                patientNumber = -1;
                playSound     = false;
            }
            else if (!m_Healer.InRange(m_Patient, Bandage.GetRange(m_Healer.Expansion)))
            {
                healerNumber  = 500963;                // You did not stay close enough to heal your target.
                patientNumber = -1;
                playSound     = false;
            }
            else if (!m_Patient.Alive || (petPatient != null && petPatient.IsDeadPet))
            {
                double healing = m_Healer.Skills[primarySkill].Value;
                double anatomy = m_Healer.Skills[secondarySkill].Value;
                double chance  = ((healing - 68.0) / 50.0) - (m_Slips * 0.02);

                //TODO: Dbl check doesn't check for faction of the horse here?
                if (((checkRes = (healing >= 80.0 && anatomy >= 80.0)) && chance > Utility.RandomDouble()) ||
                    (m_Patient.EraSE && petPatient is FactionWarHorse && petPatient.ControlMaster == m_Healer))
                {
                    if (m_Patient.Map == null || !m_Patient.Map.CanFit(m_Patient.Location, 16, false, false))
                    {
                        healerNumber  = 501042;                        // Target can not be resurrected at that location.
                        patientNumber = 502391;                        // Thou can not be resurrected there!
                    }
                    else if (m_Patient.Region != null && m_Patient.Region.IsPartOf("Khaldun"))
                    {
                        healerNumber  = 1010395;                        // The veil of death in this area is too strong and resists thy efforts to restore life.
                        patientNumber = -1;
                    }
                    else
                    {
                        healerNumber  = 500965;                        // You are able to resurrect your patient.
                        patientNumber = -1;

                        m_Patient.PlaySound(0x214);
                        m_Patient.FixedEffect(0x376A, 10, 16);

                        if (petPatient != null && petPatient.IsDeadPet)
                        {
                            Mobile master = petPatient.ControlMaster;

                            if (master != null && m_Healer == master)
                            {
                                petPatient.ResurrectPet();

                                foreach (Skill s in petPatient.Skills)
                                {
                                    double skillloss = s.Base * 0.01;
                                    s.Base -= skillloss;
                                }
                                Conquests.CheckProgress <ResConquest>(m_Healer as PlayerMobile, petPatient);
                            }
                            else if (master != null && master.InRange(petPatient, 3))
                            {
                                healerNumber = 503255;                                 // You are able to resurrect the creature.

                                master.CloseGump(typeof(PetResurrectGump));
                                master.SendGump(new PetResurrectGump(m_Healer, petPatient));

                                Conquests.CheckProgress <ResConquest>(m_Healer as PlayerMobile, petPatient);
                            }
                            else
                            {
                                bool found = false;

                                List <Mobile> friends = petPatient.Friends;

                                for (int i = 0; friends != null && i < friends.Count; ++i)
                                {
                                    Mobile friend = friends[i];

                                    if (!friend.InRange(petPatient, 3))
                                    {
                                        continue;
                                    }

                                    healerNumber = 503255;                                     // You are able to resurrect the creature.

                                    friend.CloseGump(typeof(PetResurrectGump));
                                    friend.SendGump(new PetResurrectGump(m_Healer, petPatient));

                                    found = true;
                                    Conquests.CheckProgress <ResConquest>(m_Healer as PlayerMobile, petPatient);
                                    break;
                                }

                                if (!found)
                                {
                                    healerNumber = 1049670;                                     // The pet's owner must be nearby to attempt resurrection.
                                }
                            }
                        }
                        else
                        {
                            m_Patient.CloseGump(typeof(ResurrectGump));

                            /*PlayerMobile pres = m_Patient as PlayerMobile;
                             *
                             * if (pres.MurderBounty > 0)
                             *      m_Patient.SendGump( new ResurrectGump( m_Patient, m_Healer, pres.MurderBounty ) );
                             * else*/
                            m_Patient.SendGump(new ResurrectGump(m_Patient, m_Healer));
                            Conquests.CheckProgress <ResConquest>(m_Healer as PlayerMobile, petPatient);
                        }
                    }
                }
                else
                {
                    if (petPatient != null && petPatient.IsDeadPet)
                    {
                        healerNumber = 503256;                         // You fail to resurrect the creature.
                    }
                    else
                    {
                        healerNumber = 500966;                         // You are unable to resurrect your patient.
                    }

                    patientNumber = -1;
                }
            }
            else if (m_Patient.Poisoned)
            {
                m_Healer.SendLocalizedMessage(500969);                 // You finish applying the bandages.

                double healing = m_Healer.Skills[primarySkill].Value;
                double anatomy = m_Healer.Skills[secondarySkill].Value;
                double chance  = ((healing - 30.0) / 50.0) - (m_Patient.Poison.Level * 0.1) - (m_Slips * 0.02);

                if ((checkPois = (healing >= 60.0 && anatomy >= 60.0)) && chance > Utility.RandomDouble())
                {
                    if (m_Patient.CurePoison(m_Healer))
                    {
                        healerNumber  = (m_Healer == m_Patient) ? -1 : 1010058; // You have cured the target of all poisons.
                        patientNumber = 1010059;                                // You have been cured of all poisons.
                    }
                    else
                    {
                        healerNumber  = -1;
                        patientNumber = -1;
                    }
                }
                else
                {
                    healerNumber  = 1010060;                    // You have failed to cure your target!
                    patientNumber = -1;
                }
            }
            else if (BleedAttack.IsBleeding(m_Patient))
            {
                healerNumber  = 1060088;                // You bind the wound and stop the bleeding
                patientNumber = 1060167;                // The bleeding wounds have healed, you are no longer bleeding!

                BleedAttack.EndBleed(m_Patient, false);
            }
            else if (MortalStrike.IsWounded(m_Patient))
            {
                healerNumber  = (m_Healer == m_Patient ? 1005000 : 1010398);
                patientNumber = -1;
                playSound     = false;
            }
            else if (m_Patient.Hits == m_Patient.HitsMax)
            {
                healerNumber  = 500967;                // You heal what little damage your patient had.
                patientNumber = -1;
            }
            else
            {
                patientNumber = -1;

                double healing = m_Healer.Skills[primarySkill].Value;
                double anatomy = m_Healer.Skills[secondarySkill].Value;
                double chance  = ((healing + 10.0) / 100.0) - (m_Slips * 0.02);

                if (chance > Utility.RandomDouble())
                {
                    healerNumber = 500969;                     // You finish applying the bandages.

                    double min = (anatomy / 5.5) + (healing / 5.5) + 4.0;
                    double max = (anatomy / 5.0) + (healing / 2.5) + 10.0;

                    double toHeal = min + (Utility.RandomDouble() * (max - min));

                    if ((m_Patient.Body.IsMonster || m_Patient.Body.IsAnimal) && m_Patient.NetState == null)
                    // Alan Mod: player-controlled mobs heal like regular players
                    {
                        toHeal += m_Patient.HitsMax / 100;
                    }

                    toHeal -= m_Slips * 4;

                    if (toHeal < 1)
                    {
                        toHeal       = 1;
                        healerNumber = 500968;                         // You apply the bandages, but they barely help.
                    }

                    var healfinal = (int)toHeal;

                    int healmessage = Math.Min(m_Patient.HitsMax - m_Patient.Hits, healfinal);

                    m_Patient.Heal(healfinal, m_Healer, false);

                    if (healmessage > 0)
                    {
                        m_Patient.PrivateOverheadMessage(
                            MessageType.Regular, 0x42, false, healmessage.ToString(CultureInfo.InvariantCulture), m_Patient.NetState);
                        if (m_Healer != m_Patient)
                        {
                            m_Patient.PrivateOverheadMessage(
                                MessageType.Regular, 0x42, false, healmessage.ToString(CultureInfo.InvariantCulture), m_Healer.NetState);
                        }
                    }
                }
                else
                {
                    healerNumber = 500968;                     // You apply the bandages, but they barely help.
                    playSound    = false;
                }
            }

            if (healerNumber != -1)
            {
                m_Healer.SendLocalizedMessage(healerNumber);
            }

            if (patientNumber != -1)
            {
                m_Patient.SendLocalizedMessage(patientNumber);
            }

            if (playSound)
            {
                m_Patient.PlaySound(0x57);
            }

            double minSkill = 0.0;
            double maxSkill = 90.0;

            if (checkRes)
            {
                minSkill = 65.0;
                maxSkill = 120.0;
            }
            else if (checkPois)
            {
                minSkill = 45.0;
                maxSkill = 120.0;
            }

            m_Healer.CheckSkill(secondarySkill, minSkill, maxSkill);
            m_Healer.CheckSkill(primarySkill, minSkill, maxSkill);
        }