Beispiel #1
0
            public EffectsTimer(XmlSiege siege, TimeSpan delay)
                : base(delay)
            {
                Priority = TimerPriority.OneSecond;

                m_Siege = siege;
            }
        public void BeginAttackTarget(Mobile from, Item target, Point3D targetloc)
        {
            if (from == null || target == null)
            {
                return;
            }

            // check the target line of sight
            Point3D adjustedloc = new Point3D(targetloc.X, targetloc.Y, targetloc.Z + target.ItemData.Height);
            Point3D fromloc     = new Point3D(from.Location.X, from.Location.Y, from.Location.Z + 14);

            if (!from.Map.LineOfSight(fromloc, adjustedloc))
            {
                from.SendMessage("Cannot see target.");
                return;
            }

            int distance = (int)XmlSiege.GetDistance(from.Location, targetloc);

            if (distance <= MaxDistance)
            {
                CurrentLoc = from.Location;
                CurrentMap = from.Map;
                TargetLoc  = target.Location;
                TargetMap  = target.Map;

                AttackTarget = target;
            }
            else
            {
                from.SendLocalizedMessage(500446);                 // That is too far away.
            }
        }
Beispiel #3
0
        public static void Attack(Mobile from, object target, int firedamage, int physicaldamage)
        {
            // find the XmlSiege attachment on the target
            XmlSiege a = (XmlSiege)XmlAttach.FindAttachment(target, typeof(XmlSiege));

            if (a != null && !a.Deleted)
            {
                a.ApplyScaledDamage(from, firedamage, physicaldamage);
            }
        }
Beispiel #4
0
        public static int GetHitsMax(object target)
        {
            // find the XmlSiege attachment on the target
            XmlSiege a = (XmlSiege)XmlAttach.FindAttachment(target, typeof(XmlSiege));

            if (a != null && !a.Deleted)
            {
                return(a.HitsMax);
            }

            return(-1);
        }
Beispiel #5
0
        public void BeginAttackTarget(Mobile from, Item target, Point3D targetloc)
        {
            if (from == null || target == null)
            {
                return;
            }

            // check the target line of sight
            Point3D adjustedloc = new Point3D(targetloc.X, targetloc.Y, targetloc.Z + target.ItemData.Height);
            Point3D fromloc     = new Point3D(from.Location.X, from.Location.Y, from.Location.Z + 14);

            if (!from.Map.LineOfSight(fromloc, adjustedloc))
            {
                from.SendMessage("Cannot see target.");
                return;
            }

            Item weapon = from.FindItemOnLayer(Layer.OneHanded);

            if (weapon == null)
            {
                weapon = from.FindItemOnLayer(Layer.TwoHanded);
            }

            int range = MaxDistance;

            if (weapon != null && weapon is BaseRanged)
            {
                range = ((BaseRanged)weapon).MaxRange;
            }

            int distance = (int)XmlSiege.GetDistance(from.Location, targetloc);

            if (distance <= range)
            {
                CurrentLoc = from.Location;
                CurrentMap = from.Map;
                TargetLoc  = target.Location;
                TargetMap  = target.Map;

                AttackTarget = target;
            }
            else
            {
                from.SendLocalizedMessage(500446);                 // That is too far away.
            }
        }
            protected override void OnTick()
            {
                if (m_attachment == null)
                {
                    return;
                }

                Item weapon = m_attachment.AttachedTo as Item;
                Item target = m_attachment.AttackTarget;

                if (weapon == null || weapon.Deleted || target == null || target.Deleted)
                {
                    Stop();
                    return;
                }

                // the weapon must be equipped
                Mobile attacker = weapon.Parent as Mobile;

                if (attacker == null || attacker.Deleted)
                {
                    Stop();
                    return;
                }

                // the attacker cannot be fighting

                if (attacker.Combatant != null)
                {
                    attacker.SendMessage("Cannot siege while fighting.");
                    Stop();
                    return;
                }

                // get the location of the attacker

                Point3D attackerloc = attacker.Location;
                Map     attackermap = attacker.Map;

                Point3D targetloc = target.Location;
                Map     targetmap = target.Map;

                if (targetmap == null || targetmap == Map.Internal || attackermap == null || attackermap == Map.Internal || targetmap != attackermap)
                {
                    // if the attacker or target has an invalid map, then stop
                    Stop();
                    return;
                }

                // compare it against previous locations.  If they have moved then break off the attack
                if (attackerloc != m_attachment.CurrentLoc || attackermap != m_attachment.CurrentMap)
                {
                    Stop();
                    return;
                }



                // attack the target
                // Animate( int action, int frameCount, int repeatCount, bool forward, bool repeat, int delay )
                int action = 26;                 // 1-H bash animation, 29=2-H mounted



                // get the layer
                switch (weapon.Layer)
                {
                case Layer.OneHanded:

                    if (attacker.Mount == null)
                    {
                        // unmounted animation
                        action = 9;
                    }
                    else
                    {
                        action = 26;
                    }
                    break;

                case Layer.TwoHanded:
                    if (attacker.Mount == null)
                    {
                        // unmounted animation
                        action = 12;
                    }
                    else
                    {
                        action = 29;
                    }
                    break;
                }

                // attack animation
                attacker.Animate(action, 7, 1, true, false, 0);

                int    basedamage = 1;
                double basedelay  = BaseWeaponDelay;

                if (weapon is BaseWeapon)
                {
                    BaseWeapon b = (BaseWeapon)weapon;
                    // calculate the siege damage based on the weapon min/max damage and the overall damage scale factor
                    basedamage = (int)(Utility.RandomMinMax(b.MinDamage, b.MaxDamage) * DamageScaleFactor);
                    // reduce the actual delay by the weapon speed
                    basedelay -= b.Speed / 10;
                }

                if (basedelay < 1)
                {
                    basedelay = 1;
                }
                if (basedamage < 1)
                {
                    basedamage = 1;
                }

                // apply siege damage, all physical
                XmlSiege.Attack(attacker, target, basedamage, 0);

                // prepare for the next attack
                m_attachment.DoTimer(TimeSpan.FromSeconds(basedelay), false);
            }
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (from == null || m_weapon == null || from.Map == null || m_attachment == null)
                {
                    return;
                }

                if (targeted is StaticTarget)
                {
                    int staticid = ((StaticTarget)targeted).ItemID;
                    int staticx  = ((StaticTarget)targeted).Location.X;
                    int staticy  = ((StaticTarget)targeted).Location.Y;

                    Item    multiitem = null;
                    Point3D tileloc   = Point3D.Zero;

                    // find the possible multi owner of the static tile
                    foreach (Item item in from.Map.GetItemsInRange(((StaticTarget)targeted).Location, 50))
                    {
                        if (item is BaseMulti)
                        {
                            // search the component list for a match
                            MultiComponentList mcl = ((BaseMulti)item).Components;
                            bool found             = false;
                            if (mcl != null && mcl.List != null)
                            {
                                for (int i = 0; i < mcl.List.Length; i++)
                                {
                                    MultiTileEntry t = mcl.List[i];

                                    int x      = t.m_OffsetX + item.X;
                                    int y      = t.m_OffsetY + item.Y;
                                    int z      = t.m_OffsetZ + item.Z;
                                    int itemID = t.m_ItemID & 0x3FFF;

                                    if (itemID == staticid && x == staticx && y == staticy)
                                    {
                                        found   = true;
                                        tileloc = new Point3D(x, y, z);
                                        break;
                                    }
                                }
                            }

                            if (found)
                            {
                                multiitem = item;
                                break;
                            }
                        }
                    }
                    if (multiitem != null)
                    {
                        //Console.WriteLine("attacking {0} at {1}:{2}", multiitem, tileloc, ((StaticTarget)targeted).Location);
                        // may have to reconsider the use tileloc vs target loc
                        //m_cannon.AttackTarget(from, multiitem, ((StaticTarget)targeted).Location);

                        //m_weapon.AttackTarget(from, multiitem, multiitem.Map.GetPoint(targeted, true), m_checklos);


                        m_attachment.BeginAttackTarget(from, multiitem, multiitem.Map.GetPoint(targeted, true));
                    }
                }
                else
                if (targeted is AddonComponent)
                {
                    // if the addon doesnt have an xmlsiege attachment, then attack the addon
                    XmlSiege a = (XmlSiege)XmlAttach.FindAttachment(targeted, typeof(XmlSiege));
                    if (a == null || a.Deleted)
                    {
                        m_attachment.BeginAttackTarget(from, ((AddonComponent)targeted).Addon, ((Item)targeted).Location);
                    }
                    else
                    {
                        m_attachment.BeginAttackTarget(from, (Item)targeted, ((Item)targeted).Location);
                    }
                }
                else
                if (targeted is Item)
                {
                    m_attachment.BeginAttackTarget(from, (Item)targeted, ((Item)targeted).Location);
                }
            }
Beispiel #8
0
 public AutoRepairTimer(XmlSiege attachment, TimeSpan delay)
     : base(delay)
 {
     Priority     = TimerPriority.FiveSeconds;
     m_attachment = attachment;
 }
Beispiel #9
0
			public EffectsTimer(XmlSiege siege, TimeSpan delay)
				: base(delay)
			{

				Priority = TimerPriority.OneSecond;

				m_Siege = siege;
			}
Beispiel #10
0
			public AutoRepairTimer(XmlSiege attachment, TimeSpan delay)
				: base(delay)
			{
				Priority = TimerPriority.FiveSeconds;
				m_attachment = attachment;
			}
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (from == null || _Weapon == null || _Attachment == null || from.Map == null)
                {
                    return;
                }

                if (targeted is StaticTarget)
                {
                    int staticID = ((StaticTarget)targeted).ItemID;
                    int staticx  = ((StaticTarget)targeted).Location.X;
                    int staticy  = ((StaticTarget)targeted).Location.Y;

                    Item multiItem = null;

                    // find the possible multi owner of the static tile
                    foreach (Item item in from.Map.GetItemsInRange(((StaticTarget)targeted).Location, 50))
                    {
                        if (!(item is BaseMulti))
                        {
                            continue;
                        }

                        // search the component list for a match
                        MultiComponentList mcl = ((BaseMulti)item).Components;
                        bool found             = false;

                        if (mcl != null && mcl.List != null)
                        {
                            // ReSharper disable LoopCanBeConvertedToQuery
                            foreach (MultiTileEntry t in mcl.List)
                            // ReSharper restore LoopCanBeConvertedToQuery
                            {
                                int x = t.m_OffsetX + item.X;
                                int y = t.m_OffsetY + item.Y;
                                //int z = t.m_OffsetZ + item.Z;
                                int itemID = t.m_ItemID & 0x3FFF;

                                if (itemID != staticID || x != staticx || y != staticy)
                                {
                                    continue;
                                }

                                found = true;
                                break;
                            }
                        }

                        if (!found)
                        {
                            continue;
                        }

                        multiItem = item;
                        break;
                    }

                    if (multiItem != null)
                    {
                        //Console.WriteLine("attacking {0} at {1}:{2}", multiitem, tileloc, ((StaticTarget)targeted).Location);
                        // may have to reconsider the use tileloc vs target loc
                        //m_cannon.AttackTarget(from, multiitem, ((StaticTarget)targeted).Location);
                        //m_weapon.AttackTarget(from, multiitem, multiitem.Map.GetPoint(targeted, true), m_checklos);
                        _Attachment.BeginAttackTarget(from, multiItem, multiItem.Map.GetPoint(targeted, true));
                    }
                }
                else if (targeted is AddonComponent)
                {
                    // if the addon doesnt have an xmlsiege attachment, then attack the addon
                    XmlSiege a = (XmlSiege)XmlAttach.FindAttachment(targeted, typeof(XmlSiege));

                    if (a == null || a.Deleted)
                    {
                        _Attachment.BeginAttackTarget(from, ((AddonComponent)targeted).Addon, ((Item)targeted).Location);
                    }
                    else
                    {
                        _Attachment.BeginAttackTarget(from, (Item)targeted, ((Item)targeted).Location);
                    }
                }
                else if (targeted is Item)
                {
                    _Attachment.BeginAttackTarget(from, (Item)targeted, ((Item)targeted).Location);
                }
            }
Beispiel #12
0
            protected override void OnTick()
            {
                if (m_attachment == null)
                {
                    return;
                }

                Item weapon = m_attachment.AttachedTo as Item;
                Item target = m_attachment.AttackTarget;

                if (weapon == null || weapon.Deleted || target == null || target.Deleted)
                {
                    Stop();
                    return;
                }

                // the weapon must be equipped
                Mobile attacker = weapon.Parent as Mobile;

                if (attacker == null || attacker.Deleted)
                {
                    Stop();
                    return;
                }

                // the attacker cannot be fighting

                if (attacker.Combatant != null)
                {
                    attacker.SendMessage("Cannot siege while fighting.");
                    Stop();
                    return;
                }

                // get the location of the attacker

                Point3D attackerloc = attacker.Location;
                Map     attackermap = attacker.Map;

                Point3D targetloc = target.Location;
                Map     targetmap = target.Map;

                if (targetmap == null || targetmap == Map.Internal || attackermap == null || attackermap == Map.Internal || targetmap != attackermap)
                {
                    // if the attacker or target has an invalid map, then stop
                    Stop();
                    return;
                }

                // compare it against previous locations.  If they have moved then break off the attack
                int maxRange = 2;

                if (weapon is BaseRanged)
                {
                    maxRange = ((BaseRanged)weapon).MaxRange;
                }

                int distance = (int)XmlSiege.GetDistance(attackerloc, targetloc);

                if (distance > maxRange || attackermap != m_attachment.CurrentMap)
                {
                    target.LabelTo(attacker, "You are too far to keep attacking.");
                    Stop();
                    return;
                }

                int    basedamage = 1;
                double basedelay  = BaseWeaponDelay;

                if (weapon is BaseWeapon)
                {
                    BaseWeapon b = (BaseWeapon)weapon;
                    b.PlaySwingAnimation(attacker);
                    // calculate the siege damage based on the weapon min/max damage and the overall damage scale factor
                    basedamage = (int)(Utility.RandomMinMax(b.MinDamage, b.MaxDamage) * DamageScaleFactor);
                    // reduce the actual delay by the weapon speed
                    basedelay -= b.Speed / 10.0;
                }

                if (basedelay < 1)
                {
                    basedelay = 1;
                }
                if (basedamage < 1)
                {
                    basedamage = 1;
                }

                XmlSiege.Attack(attacker, target, basedamage, 0);

                m_attachment.DoTimer(TimeSpan.FromSeconds(basedelay), false);
            }