Beispiel #1
0
 // A check to see if the seen mobile meets all the conditions for identifying criminal activity.
 public static bool VisionCheck(Mobile m, BaseCreature s, int range)
 {
     if ((m.Combatant != s) && s.CanSee(m) && s.InLOS(m) && (m.AccessLevel < AccessLevel.Counselor))
     {
         if (m.Hidden)
             return (s.InFieldOfVision(m) && m.InRange(s, range));
         else
             return m.InRange(s, range);
     }
     else
         return false;
 }
        public static void EndBandageHeal(object state)
        {
            object[] states = (object[])state;

            BaseCreature creature = (BaseCreature)states[0];
            Mobile       target   = creature.HealTarget as Mobile;

            if (creature.Deleted)
            {
                return;
            }

            //If Heal Target Isn't Valid
            if (target == null || target.Deleted || !target.Alive || target.Map != creature.Map || target.Deleted || target.IsDeadBondedFollower || !creature.CanSee(target))
            {
                creature.DoingBandage = false;
                target.BeingBandaged  = false;

                creature.NextCombatHealActionAllowed = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(creature.CombatHealActionMinDelay, creature.CombatHealActionMaxDelay));

                return;
            }

            //If Target is More Than 2 Spaces Away: We Are Being Generous With Proximity
            else if (creature.GetDistanceToSqrt(target) > 2)
            {
                creature.DoingBandage = false;
                target.BeingBandaged  = false;

                creature.NextCombatHealActionAllowed = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(creature.CombatHealActionMinDelay, creature.CombatHealActionMaxDelay));

                return;
            }

            int healingSkill     = creature.Skills[SkillName.Healing].BaseFixedPoint;
            int maxHealingAmount = healingSkill / 10; //100 At Healing Skill 100

            double healingPercent = (double)healingSkill / 1000 / 4;

            double lowPercent  = healingPercent * .90;
            double highPercent = healingPercent * 1.10;

            double healingAmount = (double)target.HitsMax * (lowPercent + ((highPercent - lowPercent) * Utility.RandomDouble()));

            //Bandage Cure
            double cureChance = .5 + ((creature.Skills[SkillName.Healing].Value / 2) / 100);

            if (target.Poisoned)
            {
                cureChance -= (5 * target.Poison.Level);

                if (Utility.RandomDouble() < cureChance)
                {
                    target.CurePoison(creature);
                }

                healingAmount /= 2;
            }

            int amountToHeal = (int)healingAmount;

            if (amountToHeal > maxHealingAmount)
            {
                amountToHeal = maxHealingAmount;
            }

            target.Heal(amountToHeal, creature);

            creature.PlaySound(0x57);

            creature.DoingBandage = false;
            target.BeingBandaged  = false;

            creature.NextCombatHealActionAllowed = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(creature.CombatHealActionMinDelay, creature.CombatHealActionMaxDelay));
        }
        public static bool IsTargetValidHealTarget(BaseCreature creature, Mobile target, bool healOther)
        {
            //Ignore If Deleted or Blessed
            if (target.Deleted || target.Blessed)
            {
                return(false);
            }

            //Ignore If Dead
            if (!target.Alive || target.IsDeadBondedFollower)
            {
                return(false);
            }

            //Ignore ServerStaff
            if (target.AccessLevel > AccessLevel.Player)
            {
                return(false);
            }

            //Target Self (Always Allowed)
            if (healOther && creature == target)
            {
                return(false);
            }

            //Ignore If Target out of Immediate Area
            if (!creature.CanSee(target))
            {
                return(false);
            }

            //Ignore If Target out of LOS
            if (!creature.InLOS(target))
            {
                return(false);
            }

            //Controlled Creatures
            BaseCreature bc_Target = target as BaseCreature;

            if (bc_Target != null)
            {
                if (bc_Target.Controlled && bc_Target.ControlMaster != null)
                {
                    //Controller of Target is This Creature
                    if (bc_Target.ControlMaster == creature)
                    {
                        return(true);
                    }

                    //Controller of Target is Teammate
                    //if (AITeamList.CheckTeam(creature, bc_Target.ControlMaster))
                    //return true;
                }
            }

            //if (!AITeamList.CheckTeam(creature, target))
            //return false;

            return(true);
        }
        public static bool DoBandageHeal(BaseCreature creature, Mobile target)
        {
            if (target == null || !target.Alive || target.Map != creature.Map || target.Deleted || target.IsDeadBondedFollower || !creature.CanSee(target))
            {
                return(false);
            }

            creature.DoingBandage = true;
            creature.HealTarget   = target;

            //If Healing Self
            if (creature.HealTarget == creature)
            {
                StartBandageHeal(creature);
            }

            //Bandaging Someone Else:
            else
            {
                creature.BandageOtherReady = true;

                //m_Mobile Will Run Towards Target, and When In Proximity Begin Heal and Timer
                creature.BandageTimeout = DateTime.UtcNow + TimeSpan.FromSeconds(creature.BandageTimeoutLength);
            }

            return(true);
        }