コード例 #1
0
        public override void OnThink()
        {
            base.OnThink();

            if (Hidden)
            {
                m_NextDaggerAllowed = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(5, 10));
            }

            if (Alive && Controlled && ControlMaster is PlayerMobile && ControlOrder != OrderType.Stop)
            {
                if (Hidden || Combatant != null)
                {
                    m_NextStealthCheckAllowed = DateTime.UtcNow + StealthDelay;
                }

                else if (DateTime.UtcNow > m_NextStealthCheckAllowed)
                {
                    bool stealthValid = true;

                    if (Combatant != null)
                    {
                        stealthValid = false;
                    }

                    if (stealthValid)
                    {
                        IPooledEnumerable eable = Map.GetMobilesInRange(Location, RangePerception);

                        foreach (Mobile mobile in eable)
                        {
                            if (mobile.InLOS(this) && mobile.CanSee(this))
                            {
                                if (mobile.Combatant == this)
                                {
                                    stealthValid = false;
                                    break;
                                }

                                bool aggressive = false;

                                foreach (AggressorInfo aggressorInfo in mobile.Aggressors)
                                {
                                    if (aggressorInfo.Attacker == this || aggressorInfo.Defender == this)
                                    {
                                        aggressive = true;
                                        break;
                                    }
                                }

                                if (aggressive)
                                {
                                    stealthValid = false;
                                    break;
                                }
                            }
                        }

                        eable.Free();
                    }

                    if (stealthValid)
                    {
                        AIMiscAction.DoStealth(this);
                        m_NextStealthCheckAllowed = DateTime.UtcNow + StealthDelay;
                    }
                }
            }

            if (DateTime.UtcNow > m_NextDaggerAllowed && !CantWalk && !Frozen && !Hidden && Alive)
            {
                Mobile combatant = Combatant;

                if (combatant != null)
                {
                    if (combatant.Alive && CanBeHarmful(combatant) && InLOS(combatant) && GetDistanceToSqrt(combatant) <= 8)
                    {
                        SpecialAbilities.HinderSpecialAbility(1.0, null, this, 1, 1.5, true, Utility.RandomList(0x5D2, 0x5D3), false, "", "", "-1");

                        m_NextDaggerAllowed = DateTime.UtcNow + NextDaggerDelay;

                        Animate(31, 7, 1, true, false, 0);

                        Timer.DelayCall(TimeSpan.FromSeconds(.475), delegate
                        {
                            if (this == null)
                            {
                                return;
                            }
                            if (!Alive || Deleted)
                            {
                                return;
                            }
                            if (Combatant == null)
                            {
                                return;
                            }
                            if (!Combatant.Alive || Combatant.Deleted)
                            {
                                return;
                            }

                            MovingEffect(combatant, 3921, 18, 1, false, false);

                            double distance         = this.GetDistanceToSqrt(combatant.Location);
                            double destinationDelay = (double)distance * .08;

                            Timer.DelayCall(TimeSpan.FromSeconds(destinationDelay), delegate
                            {
                                if (this == null)
                                {
                                    return;
                                }
                                if (!Alive || Deleted)
                                {
                                    return;
                                }
                                if (Combatant == null)
                                {
                                    return;
                                }
                                if (!Combatant.Alive || Combatant.Deleted)
                                {
                                    return;
                                }
                                if (!CanBeHarmful(Combatant))
                                {
                                    return;
                                }

                                Effects.PlaySound(Location, Map, 0x145);

                                double baseDamage = (double)DamageMax;

                                if (Combatant is PlayerMobile)
                                {
                                    baseDamage *= BaseCreature.BreathDamageToPlayerScalar * PvPAbilityDamageScalar;
                                }

                                if (Combatant is BaseCreature)
                                {
                                    baseDamage *= BaseCreature.BreathDamageToCreatureScalar;
                                }

                                int finalDamage = (int)baseDamage;

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

                                DoHarmful(combatant);

                                int finalAdjustedDamage = AOS.Damage(combatant, this, finalDamage, 100, 0, 0, 0, 0);
                                new Blood().MoveToWorld(combatant.Location, combatant.Map);
                            });
                        });
                    }
                }
            }
        }
コード例 #2
0
        public override void OnThink()
        {
            base.OnThink();

            if (Alive && Controlled && ControlMaster is PlayerMobile && ControlOrder != OrderType.Stop)
            {
                if (Hidden || Combatant != null)
                {
                    m_NextStealthCheckAllowed = DateTime.UtcNow + StealthDelay;
                }

                else if (DateTime.UtcNow > m_NextStealthCheckAllowed)
                {
                    bool stealthValid = true;

                    if (Combatant != null)
                    {
                        stealthValid = false;
                    }

                    if (stealthValid)
                    {
                        IPooledEnumerable eable = Map.GetMobilesInRange(Location, RangePerception);

                        foreach (Mobile mobile in eable)
                        {
                            if (mobile.InLOS(this) && mobile.CanSee(this))
                            {
                                if (mobile.Combatant == this)
                                {
                                    stealthValid = false;
                                    break;
                                }

                                bool aggressive = false;

                                foreach (AggressorInfo aggressorInfo in mobile.Aggressors)
                                {
                                    if (aggressorInfo.Attacker == this || aggressorInfo.Defender == this)
                                    {
                                        aggressive = true;
                                        break;
                                    }
                                }

                                if (aggressive)
                                {
                                    stealthValid = false;
                                    break;
                                }
                            }
                        }

                        eable.Free();
                    }

                    if (stealthValid)
                    {
                        AIMiscAction.DoStealth(this);
                        m_NextStealthCheckAllowed = DateTime.UtcNow + StealthDelay;
                    }
                }
            }
        }