コード例 #1
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                //reset from's swingtimer
                BaseWeapon weapon = from.Weapon as BaseWeapon;

                if (weapon != null)
                {
                    from.NextCombatTime = DateTime.Now + weapon.GetDelay(from);
                }

                if (m_Potion.Deleted || m_Potion.Map == Map.Internal)
                {
                    return;
                }

                IPoint3D p = targeted as IPoint3D;

                if (p == null)
                {
                    return;
                }

                Map map = from.Map;

                if (map == null)
                {
                    return;
                }

                SpellHelper.GetSurfaceTop(ref p);

                // erl: 04/27/05, spawn mobile check at target location
                if (!map.CanSpawnMobile(p.X, p.Y, p.Z) && !(p is Mobile))
                {
                    from.SendLocalizedMessage(501942);                          // That location is blocked.
                    return;
                }

                // adam: add target 'under house' exploit check
                if (!from.CanSee(p) || (p is Server.Targeting.LandTarget && Server.Multis.BaseHouse.FindHouseAt(((Server.Targeting.LandTarget)(p)).Location, from.Map, 16) != null))
                {
                    from.SendLocalizedMessage(500237);                     // Target can not be seen.
                    return;
                }

                // reveal on throw
                from.RevealingAction();

                // adam: criminal action on throw
                if (m_Potion.InTown(from))
                {
                    from.CriminalAction(true);
                }

                IEntity to;
                bool    bMobile = CoreAI.ExplosionPotionTargetMethod == CoreAI.EPTM.MobileBased;

                // IN TOWN
                // if we're in town and the town uses smart guards, and a guard is on us and they have hit us at least once, ...
                if (m_Potion.InTown(from) && (from.Region as Regions.GuardedRegion).IsSmartGuards && from.Hits < from.HitsMax && m_Potion.IsGuardAttacking(from))
                {
                    if (m_Potion.ChanceBasedOnAbility(from) >= Utility.RandomDouble())
                    {                           // cool, just throw as per normal
                        to = new Entity(Serial.Zero, new Point3D(p), map);
                        Effects.SendMovingEffect(from, to, m_Potion.ItemID & 0x3FFF, 7, 0, false, false, m_Potion.Hue, 0);
                        m_Potion.Internalize();
                        Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerStateCallback(m_Potion.Reposition_OnTick), new object[] { from, to, map });
                    }
                    else
                    {
                        switch (Utility.Random(3))
                        {
                        case 0:                                 // You fumble and drop the potion to your feet.
                            m_Potion.SetFlag(PotFlags.Dud1pt);  // minimize collateral damage
                            from.SendMessage("You fumble and drop the potion to your feet.");
                            to = from;
                            Effects.SendMovingEffect(from, to, m_Potion.ItemID & 0x3FFF, 7, 0, false, false, m_Potion.Hue, 0);
                            m_Potion.Internalize();
                            Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerStateCallback(m_Potion.Reposition_OnTick), new object[] { from, to, map });
                            break;

                        case 1:                                 // The guard blocks you and the potion remains in your backpack!
                            from.SendMessage("The guard blocks you and the potion remains in your backpack!");
                            break;

                        case 2:                                 // You attempt to toss the potion, but the guard bats it away.
                            m_Potion.SetFlag(PotFlags.Dud1pt);  // minimize collateral damage
                            from.SendMessage("You attempt to toss the potion, but the guard bats it away.");
                            to = new Entity(Serial.Zero, Server.Mobiles.Spawner.GetSpawnPosition(from.Map, from.Location, 7, false, m_Potion), map);
                            Effects.SendMovingEffect(from, to, m_Potion.ItemID & 0x3FFF, 7, 0, false, false, m_Potion.Hue, 0);
                            m_Potion.Internalize();
                            Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerStateCallback(m_Potion.Reposition_OnTick), new object[] { from, to, map });
                            break;
                        }
                    }
                }
                // OUT ON THE FIELD
                // Adam: You must be in top condition to target the player directly
                //if( bMobile && (from.Stam >= from.StamMax) && (from.Hits >= from.HitsMax) )
                else if (bMobile && m_Potion.CheckHealth(from.Stam, from.StamMax, CoreAI.ExplosionPotionThreshold) && m_Potion.CheckHealth(from.Hits, from.HitsMax, CoreAI.ExplosionPotionThreshold))
                {
                    if (p is Mobile)
                    {
                        to = (Mobile)p;
                    }
                    else
                    {
                        to = new Entity(Serial.Zero, new Point3D(p), map);
                    }
                    Effects.SendMovingEffect(from, to, m_Potion.ItemID & 0x3FFF, 7, 0, false, false, m_Potion.Hue, 0);
                    m_Potion.Internalize();
                    Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerStateCallback(m_Potion.Reposition_OnTick), new object[] { from, p, map });
                }
                else
                {
                    to = new Entity(Serial.Zero, new Point3D(p), map);
                    Effects.SendMovingEffect(from, to, m_Potion.ItemID & 0x3FFF, 7, 0, false, false, m_Potion.Hue, 0);
                    m_Potion.Internalize();
                    Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerStateCallback(m_Potion.Reposition_OnTick), new object[] { from, to, map });
                }
            }