Esempio n. 1
0
        public override void OnThink()
        {
            base.OnThink();

            Point3D location = Location;
            Map     map      = Map;

            //Outside of Guard Area
            if (GuardsHome && !(ControlMaster is PlayerMobile))
            {
                if (Utility.GetDistance(Home, location) > MaxDistanceAllowedFromHome)
                {
                    TimedStatic dirt = new TimedStatic(Utility.RandomList(7681, 7682), 5);
                    dirt.Name = "dirt";
                    dirt.MoveToWorld(location, map);

                    dirt.PublicOverheadMessage(MessageType.Regular, 0, false, ReturnHomeString);

                    Effects.PlaySound(location, map, 0x657);

                    int projectiles   = 6;
                    int particleSpeed = 4;

                    for (int a = 0; a < projectiles; a++)
                    {
                        Point3D newLocation = new Point3D(location.X + Utility.RandomList(-5, -4, -3, -2, -1, 1, 2, 3, 4, 5), location.Y + Utility.RandomList(-5, -4, -3, -2, -1, 1, 2, 3, 4, 5), location.Z);
                        SpellHelper.AdjustField(ref newLocation, map, 12, false);

                        IEntity effectStartLocation = new Entity(Serial.Zero, new Point3D(location.X, location.Y, location.Z + 5), map);
                        IEntity effectEndLocation   = new Entity(Serial.Zero, new Point3D(newLocation.X, newLocation.Y, newLocation.Z + 5), map);

                        Effects.SendMovingEffect(effectStartLocation, effectEndLocation, Utility.RandomList(0x3728), particleSpeed, 0, false, false, 0, 0);
                    }

                    Location  = Home;
                    Combatant = null;

                    return;
                }
            }

            if (m_NeedWaypoint && m_CanTeleportToBaseNode && !(ControlMaster is PlayerMobile))
            {
                Dictionary <UOACZWayPoint, int> DictWaypoints = new Dictionary <UOACZWayPoint, int>();

                foreach (UOACZWayPoint waypoint in UOACZWayPoint.m_UOACZWaypoints)
                {
                    if (!UOACZRegion.ContainsItem(waypoint))
                    {
                        continue;
                    }
                    if (!waypoint.IsBaseNode)
                    {
                        continue;
                    }

                    int distanceToWaypoint = (Utility.GetDistance(Location, waypoint.Location));

                    if (distanceToWaypoint >= UOACZSystem.UndeadMaxDynamicWaypointRange)
                    {
                        continue;
                    }

                    int distanceWeight = (int)(Math.Round(((double)UOACZSystem.UndeadMaxDynamicWaypointRange - (double)distanceToWaypoint) * .05));

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

                    DictWaypoints.Add(waypoint, distanceWeight);
                }

                if (DictWaypoints.Count > 0)
                {
                    int TotalValues = 0;

                    foreach (KeyValuePair <UOACZWayPoint, int> pair in DictWaypoints)
                    {
                        TotalValues += pair.Value;
                    }

                    double ItemCheck = Utility.RandomDouble();

                    double CumulativeAmount = 0.0;
                    double AdditionalAmount = 0.0;

                    foreach (KeyValuePair <UOACZWayPoint, int> pair in DictWaypoints)
                    {
                        AdditionalAmount = (double)pair.Value / (double)TotalValues;

                        if (ItemCheck >= CumulativeAmount && ItemCheck < (CumulativeAmount + AdditionalAmount))
                        {
                            UOACZWayPoint waypoint = pair.Key;

                            if (waypoint != null)
                            {
                                if (!waypoint.Deleted)
                                {
                                    CurrentWaypoint = pair.Key;
                                    m_NeedWaypoint  = false;

                                    return;
                                }
                            }

                            break;
                        }

                        CumulativeAmount += AdditionalAmount;
                    }
                }

                else
                {
                    m_NeedWaypoint = false;
                }
            }

            if ((DateTime.UtcNow >= m_LastActivity + InactivityThreshold) && !(ControlMaster is PlayerMobile))
            {
                //Send to Random Town Waypoint BaseNode
                if (m_CanTeleportToBaseNode)
                {
                    List <UOACZWayPoint> m_ValidBaseNodes = new List <UOACZWayPoint>();

                    foreach (UOACZWayPoint waypoint in UOACZWayPoint.m_UOACZWaypoints)
                    {
                        if (waypoint == null)
                        {
                            continue;
                        }
                        if (waypoint.Deleted)
                        {
                            continue;
                        }
                        if (!UOACZRegion.ContainsItem(waypoint))
                        {
                            continue;
                        }
                        if (!waypoint.IsBaseNode)
                        {
                            continue;
                        }
                        if (waypoint.WaypointType == UOACZWayPoint.UOACZWaypointType.UndeadWilderness)
                        {
                            continue;
                        }

                        m_ValidBaseNodes.Add(waypoint);
                    }

                    if (m_ValidBaseNodes.Count > 0)
                    {
                        UOACZWayPoint targetWaypoint = m_ValidBaseNodes[Utility.RandomMinMax(0, m_ValidBaseNodes.Count - 1)];

                        MoveToWorld(targetWaypoint.Location, targetWaypoint.Map);
                        CurrentWaypoint = targetWaypoint;
                        m_LastActivity  = DateTime.UtcNow;

                        m_NeedWaypoint = false;
                        return;
                    }
                }

                m_NeedWaypoint = true;
                return;
            }

            if (Utility.RandomDouble() < 0.005)
            {
                if (Combatant == null)
                {
                    Say(idleSpeech[Utility.Random(idleSpeech.Length - 1)]);
                }

                else
                {
                    Say(combatSpeech[Utility.Random(combatSpeech.Length - 1)]);
                }
            }

            bool ignoreBreakableStatics = false;

            if (Hidden && ControlMaster is PlayerMobile)
            {
                ignoreBreakableStatics = true;
            }

            if (DateTime.UtcNow >= m_NextBreakableStaticCheckAllowed && DateTime.UtcNow >= m_NextBreakableStaticAttackAllowed && !ignoreBreakableStatics)
            {
                m_NextBreakableStaticCheckAllowed = DateTime.UtcNow + BreakableStaticCheckDelay;

                BreakableStatic targetBreakableStatic = null;
                Dictionary <BreakableStatic, int> DictBreakableStatics = new Dictionary <BreakableStatic, int>();

                IPooledEnumerable nearbyItems = Map.GetItemsInRange(Location, 1);

                foreach (Item item in nearbyItems)
                {
                    if (item.Deleted)
                    {
                        continue;
                    }

                    if (item is BreakableStatic)
                    {
                        if (!Map.InLOS(Location, item.Location))
                        {
                            continue;
                        }

                        BreakableStatic breakableStatic = item as BreakableStatic;

                        if (breakableStatic is UOACZBreakableStatic)
                        {
                            UOACZBreakableStatic uoaczBreakableStatic = breakableStatic as UOACZBreakableStatic;

                            if (uoaczBreakableStatic.AllowHumanDamage)
                            {
                                continue;
                            }
                        }

                        if (breakableStatic.DamageState == BreakableStatic.DamageStateType.Broken)
                        {
                            continue;
                        }

                        int weight = 5;

                        if (breakableStatic == m_LastBreakableStaticAttacked)
                        {
                            weight += 10;
                        }

                        int damageBonus = (int)Math.Round((10 * (1 - (double)breakableStatic.HitPoints / (double)breakableStatic.MaxHitPoints)));

                        weight += damageBonus;

                        DictBreakableStatics.Add(breakableStatic, weight);
                    }
                }

                nearbyItems.Free();

                int TotalValues = 0;

                foreach (KeyValuePair <BreakableStatic, int> pair in DictBreakableStatics)
                {
                    TotalValues += pair.Value;
                }

                double ItemCheck = Utility.RandomDouble();

                double CumulativeAmount = 0.0;
                double AdditionalAmount = 0.0;

                foreach (KeyValuePair <BreakableStatic, int> pair in DictBreakableStatics)
                {
                    AdditionalAmount = (double)pair.Value / (double)TotalValues;

                    if (ItemCheck >= CumulativeAmount && ItemCheck < (CumulativeAmount + AdditionalAmount))
                    {
                        targetBreakableStatic = pair.Key;
                        break;
                    }

                    CumulativeAmount += AdditionalAmount;
                }

                if (targetBreakableStatic != null)
                {
                    double minHinder = 1;
                    double maxHinder = 1;

                    double weaponUsageDelay = 3;

                    BaseWeapon weapon = Weapon as BaseWeapon;

                    if (weapon != null)
                    {
                        weaponUsageDelay = weapon.GetDelay(this, false).TotalSeconds;
                    }

                    bool stockpileNearby = false;

                    if (targetBreakableStatic is UOACZStockpile)
                    {
                        stockpileNearby = true;
                    }

                    else
                    {
                        switch (targetBreakableStatic.DamageState)
                        {
                        case BreakableStatic.DamageStateType.Normal:
                            minHinder = weaponUsageDelay * .5;
                            maxHinder = weaponUsageDelay;
                            break;

                        case BreakableStatic.DamageStateType.LightlyDamaged:
                            minHinder = weaponUsageDelay * .65;
                            maxHinder = weaponUsageDelay;
                            break;

                        case BreakableStatic.DamageStateType.HeavilyDamaged:
                            minHinder = weaponUsageDelay * .8;
                            maxHinder = weaponUsageDelay;
                            break;
                        }
                    }

                    double delay = minHinder + ((maxHinder - minHinder) * Utility.RandomDouble());

                    if (ControlMaster is PlayerMobile)
                    {
                        delay = 1;
                        SpecialAbilities.EntangleSpecialAbility(1.0, null, this, 1, delay, 0, false, "", "", "-1");
                    }

                    else
                    {
                        if (stockpileNearby)
                        {
                            delay = 10;

                            SpecialAbilities.EntangleSpecialAbility(1.0, null, this, 1, delay, 0, false, "", "", "-1");
                            m_NextBreakableStaticAttackAllowed = DateTime.UtcNow + BreakableStaticAttackDelay;
                        }

                        else
                        {
                            if (Utility.RandomDouble() <= .5)
                            {
                                SpecialAbilities.HinderSpecialAbility(1.0, null, this, 1, delay, true, 0, false, "", "", "-1");
                            }

                            else
                            {
                                SpecialAbilities.EntangleSpecialAbility(1.0, null, this, 1, delay, 0, false, "", "", "-1");
                            }

                            m_NextBreakableStaticAttackAllowed = DateTime.UtcNow + BreakableStaticAttackDelay;
                        }
                    }

                    targetBreakableStatic.Interact(this, BreakableStatic.InteractionType.Weapon);
                }
            }
        }
Esempio n. 2
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Item.Deleted)
                {
                    return;
                }

                if (targeted is BreakableContainer)
                {
                    BreakableContainer breakableContainer = targeted as BreakableContainer;

                    if (breakableContainer.LockpickDamageScalar > 0)
                    {
                        breakableContainer.Interact(from, BreakableContainer.InteractionType.Lockpick);
                    }
                    else
                    {
                        breakableContainer.Interact(from, BreakableContainer.InteractionType.None);
                    }

                    return;
                }

                if (targeted is BreakableStatic)
                {
                    BreakableStatic breakableStatic = targeted as BreakableStatic;

                    if (breakableStatic.LockpickDamageScalar > 0)
                    {
                        breakableStatic.Interact(from, BreakableStatic.InteractionType.Lockpick);
                    }
                    else
                    {
                        breakableStatic.Interact(from, BreakableStatic.InteractionType.None);
                    }

                    return;
                }

                if (targeted is Hold)
                {
                    Hold hold = targeted as Hold;
                    hold.LockpickHold(from, m_Item);

                    return;
                }

                if (targeted is ILockpickable)
                {
                    Item item = (Item)targeted;
                    from.Direction = from.GetDirectionTo(item);

                    from.BeginAction(typeof(Lockpick));

                    Timer.DelayCall(TimeSpan.FromSeconds(SkillCooldown.LockpickingCooldown), delegate
                    {
                        if (from != null)
                        {
                            from.EndAction(typeof(Lockpick));
                        }
                    });

                    if (((ILockpickable)targeted).Locked)
                    {
                        from.PlaySound(0x241);
                        new InternalTimer(from, (ILockpickable)targeted, m_Item).Start();
                    }

                    else
                    {
                        // The door is not locked
                        from.SendLocalizedMessage(502069); // This does not appear to be locked
                    }
                }

                else
                {
                    from.SendLocalizedMessage(501666); // You can't unlock that!
                }
            }
Esempio n. 3
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Item.Deleted)
                {
                    return;
                }

                if (targeted is BreakableContainer)
                {
                    BreakableContainer breakableContainer = targeted as BreakableContainer;

                    if (breakableContainer.LockpickDamageScalar > 0)
                    {
                        breakableContainer.Interact(from, BreakableContainer.InteractionType.Lockpick);
                    }
                    else
                    {
                        breakableContainer.Interact(from, BreakableContainer.InteractionType.None);
                    }

                    return;
                }

                if (targeted is BreakableStatic)
                {
                    BreakableStatic breakableStatic = targeted as BreakableStatic;

                    if (breakableStatic.LockpickDamageScalar > 0)
                    {
                        breakableStatic.Interact(from, BreakableStatic.InteractionType.Lockpick);
                    }
                    else
                    {
                        breakableStatic.Interact(from, BreakableStatic.InteractionType.None);
                    }

                    return;
                }

                if (targeted is Hold)
                {
                    Hold hold = targeted as Hold;
                    hold.LockpickHold(from, m_Item);

                    return;
                }

                if (targeted is ILockpickable)
                {
                    if (targeted is BaseTreasureChest)
                    {
                        PlayerMobile player = from as PlayerMobile;

                        if (player != null)
                        {
                            CaptchaPersistance.CheckAndCreateCaptchaAccountEntry(player);

                            if (!player.m_CaptchaAccountData.Attempt(player, CaptchaSourceType.DungeonChest))
                            {
                                return;
                            }
                        }
                    }

                    Item item = (Item)targeted;
                    from.Direction = from.GetDirectionTo(item);

                    from.BeginAction(typeof(Lockpick));

                    Timer.DelayCall(TimeSpan.FromSeconds(SkillCooldown.LockpickingCooldown), delegate
                    {
                        if (from != null)
                        {
                            from.EndAction(typeof(Lockpick));
                        }
                    });

                    if (((ILockpickable)targeted).Locked)
                    {
                        from.PlaySound(0x241);
                        new InternalTimer(from, (ILockpickable)targeted, m_Item).Start();
                    }

                    else
                    {
                        // The door is not locked
                        from.SendLocalizedMessage(502069); // This does not appear to be locked
                    }
                }

                else
                {
                    from.SendLocalizedMessage(501666); // You can't unlock that!
                }
            }