示例#1
0
        public override void OnDoubleClick( Mobile from )
        {
            PlayerMobile pm = from as PlayerMobile;

            if ( pm == null )
                return;

            if ( !from.InLOS( this.GetWorldLocation() ) )
            {
                from.SendLocalizedMessage( 502800 ); // You can't see that.
                return;
            }

            if ( from.GetDistanceToSqrt( this.GetWorldLocation() ) > 2 )
            {
                from.SendLocalizedMessage( 500446 ); // That is too far away.
                return;
            }

            if ( pm.Bedlam )
            {
                BaseCreature.TeleportPets( pm, BedlamEntrance, from.Map );
                pm.MoveToWorld( BedlamEntrance, Map );
            }
            else
            {
                pm.SendLocalizedMessage( 1074276 ); // You press and push on the iron maiden, but nothing happens.
            }
        }
示例#2
0
        public static void FireWall( Mobile from, Mobile target )
        {
            Effects.SendPacket( from.Location, from.Map, new FlashEffect( FlashType.LightFlash ) );
            Effects.PlaySound( from.Location, from.Map, 0x44B );

            Direction d = from.GetDirectionTo( target );

            int dx, dy;
            bool diagonal;

            GetDirectionOffset( d, out dx, out dy, out diagonal );

            int length = 1 + (int) Math.Min( from.GetDistanceToSqrt( target ), 10 );

            for ( int i = 0; i < length; i++ )
            {
                int x = from.Location.X + ( dx * i );
                int y = from.Location.Y + ( dy * i );

                Point3D loc = new Point3D( x, y, from.Location.Z );

                TimeSpan duration = TimeSpan.FromSeconds( 100.0 - ( i * 9.0 ) );

                if ( d == Direction.West || d == Direction.East || diagonal )
                    new FireFieldItem( from, loc, from.Map, 0x398C, duration );

                if ( d == Direction.North || d == Direction.South || diagonal )
                    new FireFieldItem( from, loc, from.Map, 0x3996, duration );
            }
        }
示例#3
0
		public override void OnHit(Mobile attacker, Mobile defender, int damage)
		{
			if (!Validate(attacker) || !CheckMana(attacker, true))
				return;

			ClearCurrentAbility(attacker);


			attacker.SendMessage("You poisoned your target.");
			defender.SendMessage("You've been poisoned.");

			int level;

			if (Core.AOS)
			{
				if (attacker.InRange(defender, 2))
				{
					int total = (attacker.Skills.Poisoning.Fixed) / 2;

					if (total >= 1000)
						level = 3;
					else if (total > 850)
						level = 2;
					else if (total > 650)
						level = 1;
					else
						level = 0;
				}
				else
				{
					level = 0;
				}
			}
			else
			{
				double total = attacker.Skills[SkillName.Poisoning].Value;

				double dist = attacker.GetDistanceToSqrt(defender);

				if (dist >= 3.0)
					total -= (dist - 3.0) * 10.0;

				if (total >= 200.0 && 1 > Utility.Random(10))
					level = 3;
				else if (total > (Core.AOS ? 170.1 : 170.0))
					level = 2;
				else if (total > (Core.AOS ? 130.1 : 130.0))
					level = 1;
				else
					level = 0;
			}

			defender.ApplyPoison(attacker, Poison.GetPoison(level));

			defender.FixedParticles(0x374A, 10, 15, 5021, EffectLayer.Waist);
			defender.PlaySound(0x474);
		}
示例#4
0
        public void OnTarget(Mobile from, object targeted)
        {
            if (targeted is BattleChickenLizard && !((BattleChickenLizard)targeted).Controlled)
            {
                BattleChickenLizard bcl = (BattleChickenLizard)targeted;

                int chance = 50 / (int)Math.Max(1, from.GetDistanceToSqrt(bcl.Location));

                if (chance > Utility.Random(100))
                {
                    bcl.Frozen = true;

                    m_Timer = new InternalTimer(this, bcl, from);
                    from.SendLocalizedMessage(1112484); //You successfully ensnare the chicken! You best hurry before it frees itself from it!
                }
                else
                    from.SendLocalizedMessage(1112483); //The collar falls to the ground as the chicken deftly avoids it.
            }
        }
示例#5
0
        public override void OnDoubleClick( Mobile from )
        {
            if ( !from.InLOS( this.GetWorldLocation() ) )
            {
                from.SendLocalizedMessage( 502800 ); // You can't see that.
                return;
            }

            if ( from.GetDistanceToSqrt( this.GetWorldLocation() ) > 2 )
            {
                from.SendLocalizedMessage( 500446 ); // That is too far away.
                return;
            }

            Point3D dest = new Point3D( 330, 1973, 0 );
            Map map = Map.Malas;

            BaseCreature.TeleportPets( from, dest, map );
            from.MoveToWorld( dest, map );
        }
示例#6
0
        private static bool CheckArtifactChance( Mobile from, BaseCreature bc )
        {
            if ( !from.Alive )
                return false;

            Region r = from.Region;

            if ( r.Name != "Covetous" && r.Name != "Deceit" && r.Name != "Despise" && r.Name != "Destard" && r.Name != "Hythloth" && r.Name != "Shame" && r.Name != "Wrong" )
                return false;

            if ( from.GetDistanceToSqrt( bc ) > 16 )
                return false;

            double fame = (double) bc.Fame;

            PlayerMobile pm = from as PlayerMobile;

            int luck = pm.Luck;

            double chance = fame / 1000000000;

            if ( from.Hidden )
                chance /= 2;

            pm.TenthAnniversaryCredits += chance;

            chance = pm.TenthAnniversaryCredits;

            if ( luck > 0 )
            {
                double luckmodifier = ( (double) luck / 600 );

                if ( luckmodifier < 1 )
                    luckmodifier = 1;

                chance *= luckmodifier;
            }

            return chance > Utility.RandomDouble();
        }
        public override int AbsorbDamage( Mobile attacker, Mobile defender, int damage )
        {
            damage = base.AbsorbDamage( attacker, defender, damage );

            if ( defender.MeleeDamageAbsorb > 0 && attacker.GetDistanceToSqrt( defender ) <= 1 )
            {
                double absorb = (double)(damage * defender.MeleeDamageAbsorb) / 100.0;
                if ( absorb > damage )
                    absorb = damage;

                attacker.PlaySound( 0x1F1 );
                attacker.FixedEffect( 0x374A, 10, 16 );

                if ( absorb >= 1 )
                {
                    attacker.Damage( ((int)absorb + 1) / 2 ); // since damage is havled before its applied... halve it here too
                    damage -= (int)absorb;
                }
            }

            return damage;
        }
示例#8
0
        public override void OnDoubleClick( Mobile from )
        {
            if ( !from.Alive )
                return;

            if ( !from.InLOS( this.GetWorldLocation() ) )
            {
                from.SendLocalizedMessage( 502800 ); // You can't see that.
            }
            else if ( from.GetDistanceToSqrt( this.GetWorldLocation() ) > 2 )
            {
                from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
            }
            else
            {
                Point3D dest = new Point3D( 107, 1883, 0 );

                BaseCreature.TeleportPets( from, dest, Map.Malas );
                from.MoveToWorld( dest, Map.Malas );

                from.SendLocalizedMessage( 1072730 ); // The manor lord is unavailable. Please use the teleporter on your right.
            }
        }
示例#9
0
        public static ArrayList GetAllAttackers( Mobile m, int range )
        {
            ArrayList targets = new ArrayList();

            if ( m.Combatant != null && m.InLOS( m.Combatant ) )
            {
                if ( m.GetDistanceToSqrt( m.Combatant ) <= range )
                {
                    targets.Add( m.Combatant );
                }
            }

            // Current combatant has double chance to get an attack because of the above code

            foreach ( Mobile t in m.GetMobilesInRange( range ) )
            {
                if ( t.Combatant == m && m.InLOS( t ) && !t.Hidden )
                {
                    targets.Add( t );
                }
            }

            return targets;
        }
示例#10
0
        public override void OnDoubleClick( Mobile from )
        {
            ArrayList list = StrongBox.Table[from] as ArrayList;
            if ( list != null && list.Count > 1 )
            {
                from.SendAsciiMessage( "You already own a strong box, you cannot place another!" );
                return;
            }

            BaseHouse h = BaseHouse.FindHouseAt( from );
            if ( h != null && h.IsOwner( from ) && !(h is Tent) && h.IsInside( from ) )
            {
                IPooledEnumerable eable = h.GetItemsInRange( 18 );
                foreach ( Item i in eable )
                {
                    if ( h.IsInside( i ) )
                    {
                        if ( i is BaseDoor && ( i.X == from.X || i.Y == from.Y ) && from.GetDistanceToSqrt( i ) < 2 && i.Z-5 < from.Z && i.Z+5 > from.Z )
                        {
                            from.SendAsciiMessage( "You cannot place this in front of a door." );
                            eable.Free();
                            return;
                        }
                        else if ( i is StrongBox )
                        {
                            from.SendAsciiMessage( "There is already a strong box in this house." );
                            eable.Free();
                            return;
                        }
                    }
                }
                eable.Free();

                StrongBox s = new StrongBox( from, h );
                s.MoveToWorld( from.Location, from.Map );
                this.Delete();
            }
            else
            {
                from.SendAsciiMessage( "You must be in a house you own in order to place a strong box." );
            }
        }
示例#11
0
        public override void OnDoubleClick( Mobile from )
        {
            if ( !from.InRange( GetWorldLocation(), 2 ) )
            {
                from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
                return;
            }

            Point2D[] banks;
            PMList moongates;
            if ( from.Map == Map.Trammel )
            {
                banks = m_TrammelBanks;
                moongates = PMList.Trammel;
            }
            else if ( from.Map == Map.Felucca )
            {
                banks = m_FeluccaBanks;
                moongates = PMList.Felucca;
            }
            else if ( from.Map == Map.Ilshenar )
            {
            #if false
                banks = m_IlshenarBanks;
                moongates = PMList.Ilshenar;
            #else
                from.Send( new MessageLocalized( Serial, ItemID, MessageType.Label, 0x482, 3, 1061684, "", "" ) ); // The magic of the sextant fails...
                return;
            #endif
            }
            else if ( from.Map == Map.Malas )
            {
                banks = m_MalasBanks;
                moongates = PMList.Malas;
            }
            else
            {
                banks = null;
                moongates = null;
            }

            Point3D closestMoongate = Point3D.Zero;
            double moongateDistance = double.MaxValue;
            if ( moongates != null )
            {
                foreach ( PMEntry entry in moongates.Entries )
                {
                    double dist = from.GetDistanceToSqrt( entry.Location );
                    if ( moongateDistance > dist )
                    {
                        closestMoongate = entry.Location;
                        moongateDistance = dist;
                    }
                }
            }

            Point2D closestBank = Point2D.Zero;
            double bankDistance = double.MaxValue;
            if ( banks != null )
            {
                foreach ( Point2D p in banks )
                {
                    double dist = from.GetDistanceToSqrt( p );
                    if ( bankDistance > dist )
                    {
                        closestBank = p;
                        bankDistance = dist;
                    }
                }
            }

            int moonMsg;
            if ( moongateDistance == double.MaxValue )
                moonMsg = 1048021; // The sextant fails to find a Moongate nearby.
            else if ( moongateDistance > m_LongDistance )
                moonMsg = 1046449 + (int)from.GetDirectionTo( closestMoongate ); // A moongate is * from here
            else if ( moongateDistance > m_ShortDistance )
                moonMsg = 1048010 + (int)from.GetDirectionTo( closestMoongate ); // There is a Moongate * of here.
            else
                moonMsg = 1048018; // You are next to a Moongate at the moment.

            from.Send( new MessageLocalized( Serial, ItemID, MessageType.Label, 0x482, 3, moonMsg, "", "" ) );

            int bankMsg;
            if ( bankDistance == double.MaxValue )
                bankMsg = 1048020; // The sextant fails to find a Bank nearby.
            else if ( bankDistance > m_LongDistance )
                bankMsg = 1046462 + (int)from.GetDirectionTo( closestBank ); // A town is * from here
            else if ( bankDistance > m_ShortDistance )
                bankMsg = 1048002 + (int)from.GetDirectionTo( closestBank ); // There is a city Bank * of here.
            else
                bankMsg = 1048019; // You are next to a Bank at the moment.

            from.Send( new MessageLocalized( Serial, ItemID, MessageType.Label, 0x5AA, 3, bankMsg, "", "" ) );
        }
示例#12
0
		public override void OnDoubleClick( Mobile from )
		{
			from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1008155 ); // You peer into the heavens, seeking the moons...

			from.Send( new MessageLocalizedAffix( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 1008146 + (int)Clock.GetMoonPhase( Map.Trammel, from.X, from.Y ), "", AffixType.Prepend, "Trammel : ", "" ) );
			
            // Scriptiz : on ne joue pas sur felucca
            //from.Send( new MessageLocalizedAffix( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 1008146 + (int)Clock.GetMoonPhase( Map.Felucca, from.X, from.Y ), "", AffixType.Prepend, "Felucca : ", "" ) );

			PlayerMobile player = from as PlayerMobile;

            /* Scriptiz : Code pour repérer les autres bateaux (source : Alambik) */
            // Get the maximum range the player can see
            // A cartograph master with a tracking master experience lead to see to 125 tiles: A true captain!
            int MinimumRange = 25; //Regular 800x600 screen + "normal" extra
            int MaximumExtraRange = 100;
            int ExtraRange = MaximumExtraRange *
                  ((int)(from.Skills[SkillName.Cartography].Value) +
                   (int)(from.Skills[SkillName.Tracking].Value)) / 200;
            int range = MinimumRange + ExtraRange;

            foreach (Item item in from.GetItemsInRange(range))
            {
                if (item is BaseBoat)
                {
                    // Player can see the boat
                    BaseBoat baseboat = (BaseBoat)item;
                    if (!(baseboat.Contains(from))) // On va éviter de répeter qu'on voit son propre bateau
                    {
                        /* Scriptiz : implémentation du tracking */
                        // If the player is good at tracking, let him track a mobile on the boat
                        if(from.Skills[SkillName.Tracking].Value * 2 >= from.GetDistanceToSqrt(baseboat.Location))
                        {
                            foreach (Mobile m in baseboat.GetMobilesInRange(15))
                            {
                                if (m == null) continue;
                                if (baseboat.Contains(m))
                                {
                                    from.QuestArrow = new TrackArrow(from, m, range);
                                    break;
                                }
                            }
                        }

                        // Get the name if not too far
                        string name = "un navire";
                        if (from.InRange(item.Location, MinimumRange + MaximumExtraRange / 5))
                            if (baseboat.ShipName != null)
                                name = "le" + baseboat.ShipName;

                        // Is it far?
                        string distance = "à l'horizon";
                        if (from.InRange(item.Location, MinimumRange + MaximumExtraRange * 1 / 5))
                            distance = "à côté";
                        else if (from.InRange(item.Location, MinimumRange + MaximumExtraRange * 2 / 5))
                            distance = "proche";
                        else if (from.InRange(item.Location, MinimumRange + MaximumExtraRange * 3 / 5))
                            distance = "loin";
                        else if (from.InRange(item.Location, MinimumRange + MaximumExtraRange * 4 / 5))
                            distance = "très loin";

                        // Get the relative direction of the seen boat
                        string direction;
                        // north/south
                        if (from.Y < baseboat.Y)
                            direction = "Sud";
                        else
                            direction = "Nord";
                        // east/west (Scriptiz : correction est <> ouest)
                        if (from.X < baseboat.X)
                            direction = direction + " Est";
                        else
                            direction = direction + " Ouest";

                        //Does the boat is moving?
                        string mobility = "est immobile";
                        if (baseboat.IsMoving)
                        {
                            mobility = "bouge vers ";
                            switch (baseboat.Moving)
                            {
                                case Direction.North: mobility += "le nord"; break;
                                case Direction.South: mobility += "le sud"; break;
                                case Direction.East: mobility += "l'est"; break;
                                case Direction.West: mobility += "l'ouest"; break;
                                case Direction.Up: mobility += "le nord-ouest"; break;
                                case Direction.Down: mobility += "le sud-est"; break;
                                case Direction.Left: mobility += "le sud-ouest"; break;
                                case Direction.Right: mobility += "le nord-est"; break;
                                default: break;
                            }
                        }
                        from.SendMessage("Vous voyez {0} au {1}. Il est {2} et {3}.", name, direction, distance, mobility);
                    }
                }
            }
            /* Scriptiz : fin du code de Alambik */

			if ( player != null )
			{
				QuestSystem qs = player.Quest;

				if ( qs is WitchApprenticeQuest )
				{
					FindIngredientObjective obj = qs.FindObjective( typeof( FindIngredientObjective ) ) as FindIngredientObjective;

					if ( obj != null && !obj.Completed && obj.Ingredient == Ingredient.StarChart )
					{
						int hours, minutes;
						Clock.GetTime( from.Map, from.X, from.Y, out hours, out minutes );

						if ( hours < 5 || hours > 17 )
						{
							player.SendLocalizedMessage( 1055040 ); // You gaze up into the glittering night sky.  With great care, you compose a chart of the most prominent star patterns.

							obj.Complete();
						}
						else
						{
							player.SendLocalizedMessage( 1055039 ); // You gaze up into the sky, but it is not dark enough to see any stars.
						}
					}
				}
			}
		}
示例#13
0
		public override void OnDoubleClick( Mobile from )
		{
			UpdateTeam();
			if ( from.AccessLevel >= AccessLevel.GameMaster )
			{
				if ( m_Game == null || m_Team == null )
					from.SendGump( new PropertiesGump( from, this ) );
				else
					from.SendGump( new PropertiesGump( from, m_Team ) );
			}
			else if ( m_Team != null && m_Game != null )
			{
				if ( !m_Game.Running )
				{
					from.SendMessage( "The game is currently closed." );
					return;
				}

				CTFTeam team = m_Game.GetTeam( from );
				if ( team != null )
				{
					if ( !from.InLOS( this.GetWorldLocation() ) )
					{
						from.SendLocalizedMessage( 502800 ); // You can't see that.
						return;
					}
					else if ( from.GetDistanceToSqrt( this.GetWorldLocation() ) > 2 )
					{
						from.SendLocalizedMessage( 500446 ); // That is too far away.
						return;
					}

					if ( RootParent is Mobile )
					{
						if ( RootParent == from )
						{
							from.Target = new CaptureTarget( this );
							from.SendMessage( "Target your flag to capture, or target a team-mate to pass the flag." );//"What do you wish to do with the flag?" );
						}
					}
					else
					{
						if ( team != m_Team )
						{
							if ( from.Backpack != null )
							{
								from.RevealingAction();
								from.Backpack.DropItem( this );
								from.SendMessage( "You got the enemy flag!" );
								BeginCapture();
								m_Game.PlayerMessage( "{0} ({1}) got the {2} flag!", from.Name, team.Name, m_Team.Name );
							}
							else
							{
								from.SendMessage( "You have no backpack to carry that flag!" );
							}
						}
						else
						{
							if ( !m_Home )
							{
								CTFScoreBoard.Returned( from );
								if (m_Game.IsLeagueGame) CTFLScoreBoard.Returned(from);
								m_Game.PlayerMessage( "{0} has returned the {1} flag!", from.Name, m_Team.Name );
								ReturnToHome();
							}
						}
					}
				}
				else
				{
					from.SendMessage( "You are not part of the game." );
				}
			}
		}
示例#14
0
        public bool MoveToNearestDockOrLand(Mobile from)
        {
            if ((m_Boat != null && !m_Boat.Contains(from)) || !ValidateDockOrLand())
                return false;

            Map map = Map;

            if (map == null)
                return false;

            Rectangle2D rec;
            Point3D nearest = Point3D.Zero;
            Point3D p = Point3D.Zero;

            if (m_Boat is RowBoat)
                rec = new Rectangle2D(m_Boat.X - 8, m_Boat.Y - 8, 16, 16);
            else
            {
                switch (m_Boat.Facing)
                {
                    default:
                    case Direction.North:
                    case Direction.South:
                        if (X < m_Boat.X)
                        {
                            rec = new Rectangle2D(X - 8, Y - 8, 8, 16);
                        }
                        else
                        {
                            rec = new Rectangle2D(X, Y - 8, 8, 16);
                        }
                        break;
                    case Direction.West:
                    case Direction.East:
                        if (Y < m_Boat.Y)
                        {
                            rec = new Rectangle2D(X - 8, Y - 8, 16, 8);
                        }
                        else
                        {
                            rec = new Rectangle2D(X - 8, Y, 16, 8);
                        }
                        break;
                }
            }

            for (int x = rec.X; x <= rec.X + rec.Width; x++)
            {
                for(int y = rec.Y; y <= rec.Y + rec.Height; y++)
                {
                    p = new Point3D(x, y, map.GetAverageZ(x, y));

                    if (ValidateTile(from, ref p))
                    {
                        if (nearest == Point3D.Zero || from.GetDistanceToSqrt(p) < from.GetDistanceToSqrt(nearest))
                            nearest = p;
                    }
                }
            }

            if (nearest != Point3D.Zero)
            {
                BaseCreature.TeleportPets(from, nearest, this.Map);
                from.MoveToWorld(nearest, this.Map);

                if (m_Boat != null)
                    m_Boat.Refresh();

                return true;
            }
            
            return false;
        }
示例#15
0
        public override void OnDoubleClick( Mobile from )
        {
            if ( !from.InLOS( this.GetWorldLocation() ) )
            {
                from.SendLocalizedMessage( 502800 ); // You can't see that.
                return;
            }

            if ( from.GetDistanceToSqrt( this.GetWorldLocation() ) > 1 )
            {
                from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
                return;
            }

            if ( ItemID == 0x108F )
                ItemID = 0x1090;
            else if ( ItemID == 0x1090 )
                ItemID = 0x108F;
            else if ( ItemID == 0x1091 )
                ItemID = 0x1092;
            else if ( ItemID == 0x1092 )
                ItemID = 0x1091;

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

            from.SendLocalizedMessage( 1072739 ); // You hear a click behind the wall.
        }
        public void CheckGuardCandidate(Mobile m)
        {
            if (IsDisabled())
                return;

            if (IsGuardCandidate(m))
            {
                GuardTimer timer = (GuardTimer)m_GuardCandidates[m];

                if (timer == null)
                {
                    timer = new GuardTimer(m, m_GuardCandidates);
                    timer.Start();

                    m_GuardCandidates[m] = timer;
                    m.SendLocalizedMessage(502275); // Guards can now be called on you!

                    Map map = m.Map;

                    if (map != null)
                    {
                        Mobile fakeCall = null;
                        double prio = 0.0;

                        foreach (Mobile v in m.GetMobilesInRange(8))
                        {
                            if (!v.Player && v != m && !IsGuardCandidate(v) && IsInTownNPC(v))
                            {
                                double dist = m.GetDistanceToSqrt(v);

                                if (fakeCall == null || dist < prio)
                                {
                                    fakeCall = v;
                                    prio = dist;
                                }
                            }
                        }

                        if (fakeCall != null)
                        {
                            fakeCall.Say(Utility.RandomList(1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, 1013043, 1013052));
                            MakeGuard(m);
                            m_GuardCandidates.Remove(m);
                            m.SendLocalizedMessage(502276); // Guards can no longer be called on you.
                        }
                    }
                }
                else
                {
                    timer.Stop();
                    timer.Start();
                }
            }
        }
示例#17
0
        public void FireCannon(ShipCannon shipCannon, Mobile from, Point3D targetLocation, Map map, bool hit, bool showSmoke)
        {
            if (shipCannon == null)
            {
                return;
            }

            int cannonballItemID = 0xE73;
            int cannonballHue    = 0;
            int smokeHue         = 0;

            bool fixedDirection = false;

            double shotDelay = .04;
            int    shotSpeed = 6;

            Point3D smokeLocation = shipCannon.Location;

            switch (shipCannon.Facing)
            {
            case Direction.North: { } break;

            case Direction.East: { smokeLocation.X++; } break;

            case Direction.South: { smokeLocation.Y++; } break;

            case Direction.West: { smokeLocation.X--; } break;
            }

            if (m_Ship != null)
            {
                double gunsPercent   = (double)((float)m_Ship.GunPoints / (float)m_Ship.MaxGunPoints);
                double misfireChance = BaseShip.CannonMaxMisfireChance * (1 - gunsPercent);

                double chance = Utility.RandomDouble();

                double distance     = Utility.GetDistanceToSqrt(shipCannon.Location, targetLocation);
                double flatDistance = Utility.GetDistance(shipCannon.Location, targetLocation);

                //Misfire
                if (chance < misfireChance)
                {
                    List <Mobile> m_MobilesOnShip = m_Ship.GetMobilesOnShip(true, true);

                    foreach (Mobile mobile in m_MobilesOnShip)
                    {
                        if (m_Ship.IsOwner(mobile) || m_Ship.IsCoOwner(mobile) || m_Ship.IsFriend(mobile))
                        {
                            mobile.SendMessage("Misfire!");
                        }
                    }

                    Effects.SendLocationEffect(shipCannon.Location, map, 0x3735, 10);
                    Effects.PlaySound(shipCannon.Location, map, 0x475);

                    return;
                }

                if (m_Ship.MobileFactionType == MobileFactionType.Undead)
                {
                    cannonballItemID = Utility.RandomList(6880, 6881, 6882, 6883, 6884);
                    smokeHue         = 2630;
                }

                //Hit
                if (hit)
                {
                    m_Ship.LastCombatTime = DateTime.UtcNow;

                    Effects.PlaySound(shipCannon.Location, map, 0x664);

                    if (showSmoke)
                    {
                        Effects.SendLocationEffect(smokeLocation, map, 0x36CB, 10, smokeHue, 0);
                    }

                    SpellHelper.AdjustField(ref targetLocation, map, 12, false);

                    IEntity startLocation = new Entity(Serial.Zero, new Point3D(shipCannon.Location.X, shipCannon.Location.Y, shipCannon.Location.Z + 10), map);
                    IEntity endLocation   = new Entity(Serial.Zero, new Point3D(targetLocation.X, targetLocation.Y, targetLocation.Z + 5), map);

                    Effects.SendMovingEffect(startLocation, endLocation, cannonballItemID, shotSpeed, 0, fixedDirection, false, cannonballHue, 0);
                    double effectDelay = distance * shotDelay;

                    Timer.DelayCall(TimeSpan.FromSeconds(effectDelay), delegate
                    {
                        ResolveCannon(from, targetLocation, map, hit);
                    });
                }

                //Miss
                else
                {
                    int xOffset = 0;
                    int yOffset = 0;

                    double effectiveDistance = distance;

                    int distanceOffset = (int)(Math.Floor(effectiveDistance / 2));

                    if (distance >= 2)
                    {
                        xOffset = Utility.RandomMinMax(0, distanceOffset);

                        if (Utility.RandomDouble() > .5)
                        {
                            xOffset *= -1;
                        }

                        yOffset = Utility.RandomMinMax(0, distanceOffset);

                        if (Utility.RandomDouble() > .5)
                        {
                            yOffset *= -1;
                        }
                    }

                    Effects.PlaySound(shipCannon.Location, map, 0x664);
                    Effects.SendLocationEffect(smokeLocation, map, 0x36CB, 10, smokeHue, 0);

                    IEntity startLocation = new Entity(Serial.Zero, new Point3D(shipCannon.Location.X, shipCannon.Location.Y, shipCannon.Location.Z + 10), map);
                    IEntity endLocation   = new Entity(Serial.Zero, new Point3D(targetLocation.X + xOffset, targetLocation.Y + yOffset, targetLocation.Z + 5), map);

                    Effects.SendMovingEffect(startLocation, endLocation, cannonballItemID, shotSpeed, 0, fixedDirection, false, cannonballHue, 0);

                    Point3D splashLocation = new Point3D(targetLocation.X + xOffset, targetLocation.Y + yOffset, +targetLocation.Z);

                    double newDistance = from.GetDistanceToSqrt(splashLocation);
                    double effectDelay = newDistance * shotDelay;

                    Timer.DelayCall(TimeSpan.FromSeconds(effectDelay), delegate
                    {
                        ResolveCannon(from, splashLocation, map, hit);
                    });
                }
            }
        }
示例#18
0
        public void CheckGuardCandidate(Mobile m)
        {
            if (IsDisabled())
                return;

            if (IsGuardCandidate(m))
            {
                GuardTimer timer = null;
                m_GuardCandidates.TryGetValue(m, out timer);

                if (timer == null)
                {
                    timer = new GuardTimer(m, m_GuardCandidates);
                    timer.Start();

                    m_GuardCandidates[m] = timer;

                    Map map = m.Map;

                    if (map != null)
                    {
                        Mobile fakeCall = null;
                        double prio = 0.0;

                        foreach (Mobile v in m.GetMobilesInRange(8))
                        {
                            if (!v.Player && v.Body.IsHuman && v != m && !IsGuardCandidate(v))
                            {
                                double dist = m.GetDistanceToSqrt(v);

                                if (fakeCall == null || dist < prio)
                                {
                                    fakeCall = v;
                                    prio = dist;
                                }
                            }
                        }

                        if (fakeCall != null)
                        {
                            if (fakeCall is BaseVendor && !(fakeCall is BaseGuard))
                                fakeCall.Say(Utility.RandomList(1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, 1013043, 1013052));

                            MakeGuard(m);
                            timer.Stop();
                            m_GuardCandidates.Remove(m);
                        }
                    }
                }
                else
                {
                    timer.Stop();
                    timer.Start();
                }
            }
        }
示例#19
0
        public static void SpillAcid( Mobile from, bool yamandon )
        {
            ArrayList targets = GetAllAttackers( from, 2 );

            if ( yamandon )
            {
                targets.Add( from );
            }

            Effects.SendLocationParticles( EffectItem.Create( from.Location, from.Map, EffectItem.DefaultDuration ), 0x3728, 8, 20, 76, 3, 5042, 0 );

            if ( targets.Count == 0 )
            {
                return;
            }

            foreach ( Mobile m in targets )
            {
                m.FixedParticles( 0x374A, 10, 15, 5021, EffectLayer.Waist );
                m.PlaySound( 0x474 );

                if ( yamandon )
                {
                    m.ApplyPoison( from, Poison.GetPoison( 4 ) );
                }
                else
                {
                    m.ApplyPoison( from, Poison.GetPoison( Utility.Random( 5 ) - ( from.GetDistanceToSqrt( m ) > 1 ? 1 : 0 ) ) );
                }

                m.SendLocalizedMessage( 1070820 ); // The creature spills a pool of acidic slime!
            }
        }
		public override bool HandlesOnSpeech( Mobile from )
		{
			return ( from.Alive && from.GetDistanceToSqrt( this ) <= 3 );
		}
示例#21
0
		public void CheckGuardCandidate( Mobile m )
		{
			if ( IsGuarded == false )
				return;

			if ( IsGuardCandidate( m ) )
			{
				GuardTimer timer = (GuardTimer)m_GuardCandidates[m];

				if ( timer == null )
				{
					timer = new GuardTimer( m, m_GuardCandidates );
					timer.Start();

					m_GuardCandidates[m] = timer;
					m.SendLocalizedMessage( 502275 ); // Guards can now be called on you!

					Map map = m.Map;

					if ( map != null )
					{
						Mobile fakeCall = null;
						double prio = 0.0;

						IPooledEnumerable eable = m.GetMobilesInRange( 8 );
						foreach ( Mobile v in eable)
						{
							if ( !v.Player &&
								  v.Body.IsHuman && 
								  v != m && 
								 !IsGuardCandidate( v ) )
							{
								//Pixie 10/28/04: checking whether v is in the region fixes the problem
								// where player1 recalls to a guardzone before player2's explosion hits ...
								if( this.Contains( v.Location ) )
								{
									double dist = m.GetDistanceToSqrt( v );

									if ( fakeCall == null || dist < prio )
									{
										fakeCall = v;
										prio = dist;
									}
								}
								else
								{
									//System.Console.WriteLine( "Mobile ({0}) isn't in this region, so skip him!", v.Name );
								}
							}
						}
						eable.Free();

						if ( fakeCall != null )
						{
							fakeCall.Say( Utility.RandomList( 1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, 1013043, 1013052 ) );
							MakeGuard( m );
							m_GuardCandidates.Remove( m );
							m.SendLocalizedMessage( 502276 ); // Guards can no longer be called on you.
						}
					}
				}
				else
				{
					timer.Stop();
					timer.Start();
				}
			}
		}
示例#22
0
        public static BaseBoat GetBoat(Mobile from)
        {
            List<BaseBoat> boats = new List<BaseBoat>();

            foreach (BaseBoat boat in BaseBoat.Boats) 
            {
                if (boat.Owner == from && !(boat is RowBoat))
                    boats.Add(boat);
            }

            BaseBoat closest = null;
            int range = 5000;
 
            foreach (BaseBoat boat in boats)
            {
                int dist = (int)from.GetDistanceToSqrt(boat.Location);
                if (closest == null || dist < range)
                {
                    closest = boat;
                    range = dist;
                }
            }

            return closest;
        }
示例#23
0
        public static bool CheckMapRegion( Mobile first, Mobile second )
        {
            Map map = first.Map;

            if ( second.Map != map )
                return false;

            if ( first.GetDistanceToSqrt( second ) > 90 )
                return false;

            return GetMapRegion( map, first.Location ) == GetMapRegion( map, second.Location );
        }
示例#24
0
文件: Poison.cs 项目: dpisanu/xrunuo
            protected override void OnTick()
            {
                if (CheckResistPoison())
                {
                    // Curing this way cause we don't want to trigger the PoisonCured event,
                    // so that the resistance timer is not refreshed.
                    m_Mobile.Poison = null;
                    BuffInfo.RemoveBuff(m_Mobile, BuffIcon.Poison);

                    m_Mobile.LocalOverheadMessage(MessageType.Emote, 0x3F, true, "* You feel yourself resisting the effects of the poison *");

                    m_Mobile.NonlocalOverheadMessage(MessageType.Emote, 0x3F, true, $"* {m_Mobile.Name} seems resistant to the poison *");

                    Stop();
                    return;
                }

                if (m_Index++ == m_Poison.m_Count)
                {
                    m_Mobile.SendLocalizedMessage(502136);                       // The poison seems to have worn off.
                    m_Mobile.Poison = null;

                    Stop();
                    return;
                }

                int damage = 1 + (int)(m_Mobile.Hits * m_Poison.m_Scalar);

                if (damage < m_Poison.m_Minimum)
                {
                    damage = m_Poison.m_Minimum;
                }
                else if (damage > m_Poison.m_Maximum)
                {
                    damage = m_Poison.m_Maximum;
                }

                #region Darkglow
                var poisoner = DarkglowPotion.GetPoisoner(m_Mobile);

                if (poisoner != null)
                {
                    int distance = (int)m_Mobile.GetDistanceToSqrt(poisoner.Location);

                    if (distance > 1)
                    {
                        if (distance > 20)
                        {
                            distance = 20;
                        }

                        damage += AOS.Scale(damage, distance * 5);
                        poisoner.SendLocalizedMessage(1072850);                           // Darkglow poison increases your damage!
                    }
                }
                #endregion

                var honorTarget = m_Mobile as IHonorTarget;

                if (honorTarget != null && honorTarget.ReceivedHonorContext != null)
                {
                    honorTarget.ReceivedHonorContext.OnTargetPoisoned();
                }

                AOS.Damage(m_Mobile, damage, 0, 0, 0, 100, 0);

                if ((m_Index % m_Poison.m_MessageInterval) == 0)
                {
                    m_Mobile.OnPoisoned(m_Mobile, m_Poison, m_Poison);
                }

                #region Parasitic
                poisoner = ParasiticPotion.GetPoisoner(m_Mobile);

                if (poisoner != null && m_Mobile.InRange(poisoner.Location, 1))
                {
                    int toHeal = Math.Min(damage, poisoner.HitsMax - poisoner.Hits);

                    if (toHeal > 0)
                    {
                        poisoner.SendLocalizedMessage(1060203, toHeal.ToString());                           // You have had ~1_HEALED_AMOUNT~ hit points of damage healed.
                        poisoner.Hits += toHeal;
                    }
                }
                #endregion
            }
        private static int ClosestDistance(Mobile m)
        {
            double dist = m.GetDistanceToSqrt(m_PlayerLocations[0]);

            for (int i = 1; i < m_PlayerLocations.Length; i++)
            {
                double b = m.GetDistanceToSqrt(m_PlayerLocations[i]);
                if (b < dist)
                    dist = b;
            }
            return (int)dist;
        }
示例#26
0
        public void Shoot( Mobile from, Mobile target )
        {
            if ( from == target )
                return;

            if ( m_UsesRemaining < 1 )
            {
                // You have no fukiya darts!
                from.SendLocalizedMessage( 1063325 );
            }
            else if ( m_Using.Contains( from ) )
            {
                // You are already using that fukiya.
                from.SendLocalizedMessage( 1063326 );
            }
            else if ( !HasFreeHand( from ) )
            {
                // You must have a free hand to use a fukiya.
                from.SendLocalizedMessage( 1063327 );
            }
            else if ( from.GetDistanceToSqrt( target ) > 5 )
            {
                // Your target is too far!
                from.SendLocalizedMessage( 1063304 );
            }
            else if ( from.CanBeHarmful( target ) )
            {
                m_Using.Add( from );

                from.Direction = from.GetDirectionTo( target );

                from.RevealingAction();

                from.PlaySound( 0x223 );
                from.MovingEffect( target, 0x2804, 5, 0, false, false );

                if ( CheckHitChance( from, target ) )
                    Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), new TimerStateCallback( OnDartHit ), new object[] { from, target } );
                else
                    ConsumeUse();

                // Shooting a fukiya dart restarts your weapon swing delay
                from.NextCombatTime = DateTime.Now + from.Weapon.GetDelay( from );

                Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), () => m_Using.Remove( from ) );
            }
        }
示例#27
0
        public override void OnDoubleClick( Mobile from )
        {
            if ( !from.InLOS( this.GetWorldLocation() ) )
            {
                from.SendLocalizedMessage( 502800 ); // You can't see that.
                return;
            }

            if ( from.GetDistanceToSqrt( this.GetWorldLocation() ) > 2 )
            {
                from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
                return;
            }

            if ( !Unlocked && from.AccessLevel == AccessLevel.Player )
            {
                this.PublicOverheadMessage( MessageType.Regular, 0x3B2, 500788 ); // This door appears to be locked.
                return;
            }

            BaseCreature.TeleportPets( from, m_Destination, Map.Malas );
            from.MoveToWorld( m_Destination, Map.Malas );

            from.SendLocalizedMessage( 1072790 ); // The wall becomes transparent, and you push your way through it.
        }
示例#28
0
        public override void OnDoubleClick( Mobile from )
        {
            Faction faction = Faction.Find( from );

            if ( !IsChildOf( from.Backpack ) )
            {
                // That is not in your backpack.
                from.SendLocalizedMessage( 1042593 );
            }
            else if ( faction == null )
            {
                // You may not use this unless you are a faction member!
                from.SendLocalizedMessage( 1010376, null, 0x25 );
            }
            else if ( m_CooldownTable.ContainsKey( from ) )
            {
                Timer cooldownTimer = m_CooldownTable[from];

                // You must wait ~1_seconds~ seconds before you can use this item.
                from.SendLocalizedMessage( 1079263, ( cooldownTimer.Next - DateTime.Now ).Seconds.ToString() );
            }
            else
            {
                for ( int x = -5; x <= 5; x++ )
                {
                    for ( int y = -5; y <= 5; y++ )
                    {
                        Point3D p = new Point3D( from.Location.X + x, from.Location.Y + y, from.Location.Z );
                        int dist = (int) Utility.GetDistanceToSqrt( from.Location, p );

                        if ( dist <= 5 )
                        {
                            Timer.DelayCall( TimeSpan.FromSeconds( 0.2 * dist ), new TimerCallback(
                                delegate
                                {
                                    Effects.SendPacket( from, from.Map, new HuedEffect( EffectType.FixedXYZ, Serial.Zero, Serial.Zero, 0x3709, p, p, 20, 30, true, false, 1502, 4 ) );
                                }
                            ) );
                        }
                    }
                }

                double alchemy = from.Skills[SkillName.Alchemy].Value;

                int damage = (int) BasePotion.Scale( from, 19 + alchemy / 5 );

                foreach ( Mobile to in from.GetMobilesInRange( 5 ).ToArray() )
                {
                    int distance = (int) from.GetDistanceToSqrt( to );

                    if ( to != from && distance <= 5 && from.CanSee( to ) && from.InLOS( to ) && SpellHelper.ValidIndirectTarget( from, to ) && from.CanBeHarmful( to ) && !to.Hidden )
                        AOS.Damage( to, from, damage - distance, 0, 100, 0, 0, 0 );
                }

                Consume();

                m_CooldownTable[from] = Timer.DelayCall( Cooldown, new TimerCallback( delegate { m_CooldownTable.Remove( from ); } ) );
            }
        }
示例#29
0
            protected override void OnTarget( Mobile from, object targeted )
            {
                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 );

                from.RevealingAction();

                IEntity to;

                if ( p is Mobile )
                    to = (Mobile)p;
                else
                    to = new Entity( Serial.Zero, new Point3D( p ), map );

                /* Based on Throwing skill
                at 0.0 skill:
                    0-250: success
                    250-550: 1-2 deviation
                    550-850: 2-3 deviation
                    850-1000: 3-4 deviation
                at 75.0 skill:
                    0-775: success
                    775-865: 1-2 deviation
                    865-955: 2-3 deviation
                    955-1000: 3-4 deviation
                at 100.0 skill:
                    0-950: success
                    950-970: chance for 1-2 deviation
                    970-990: chance for 2-3 deviation
                    990-1000: chance for 3-4 deviation
                */
                Point3D positionMod = new Point3D( 0, 0, 0);
                if ( from.GetDistanceToSqrt( p ) > 1 ) // no point in failing a 1 tile "throw"
                {
                    int success = 250 + (int)(from.Skills[(SkillName)15].Value*7);
                    int failPart = (1000 - success) / 5;
                    int slightDeviation = success + failPart*2;
                    int mediumDeviation = slightDeviation + failPart*2;

                    int random = Utility.Random( 1000 );
                    int changeType = Utility.Random( 3 );
                    int changeAmount = 0;

                    if ( random >= mediumDeviation ) // severe dev
                        changeAmount = Utility.Random( 2 ) + 3;
                    else if ( random >= slightDeviation ) // medium dev
                        changeAmount = Utility.Random( 2 ) + 2;
                    else if ( random >= success ) // slight dev
                        changeAmount = Utility.Random( 2 ) + 1;

                    if ( changeType == 0 ) // x
                        positionMod.X = ( Utility.RandomBool() ? 1 : -1 ) * changeAmount;
                    else if ( changeType == 1 ) // y
                        positionMod.Y = ( Utility.RandomBool() ? 1 : -1 ) * changeAmount;
                    else // both
                    {
                        positionMod.X = ( Utility.RandomBool() ? 1 : -1 ) * changeAmount;
                        positionMod.Y = ( Utility.RandomBool() ? 1 : -1 ) * changeAmount;
                    }
                }

                Point3D p3d = new Point3D( to.Location.X + positionMod.X, to.Location.Y + positionMod.Y, to.Location.Z );
                if ( !from.InLOS( p3d ) ) // if the miss was supposed to go out of line of sight, don't miss.
                    p3d = new Point3D( to.Location.X, to.Location.Y, to.Location.Z );
                IEntity newEnt = new Entity( Serial.Zero, p3d, map );
                p = newEnt as IPoint3D;

                Server.Effects.SendMovingEffect( from, newEnt, 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 } );
            }
示例#30
0
        public override void OnDoubleClick( Mobile from )
        {
            if ( !from.InLOS( this.GetWorldLocation() ) )
            {
                from.SendLocalizedMessage( 502800 ); // You can't see that.
                return;
            }

            if ( from.GetDistanceToSqrt( this.GetWorldLocation() ) > 4 )
            {
                from.SendLocalizedMessage( 500446 ); // That is too far away.
                return;
            }

            from.SendMessage( "You have been given some supplies based on your skills." );

            //4 pouches
            for (int i=0;i<4;++i)
            {
                Pouch p = new Pouch();
                p.TrapType = TrapType.MagicTrap;
                p.TrapPower = 1;
                p.Hue = 0x25;
                PackItem( from, p );
            }

            PackItem( from, new GreaterExplosionPotion() );
            PackItem( from, new TotalRefreshPotion() );
            PackItem( from, new GreaterCurePotion() );
            GiveLeatherArmor( from );

            if ( from.Skills[SkillName.Magery].Value >= 50.0 )
            {
                PackItem( from, new BagOfReagents( 100 ) );
                Spellbook book = Spellbook.FindRegular( from );//Spellbook book = from.GetSpellbook( typeof( Spellbook ) ) as Spellbook;
                if ( book != null )
                {
                    if ( book.Content != ulong.MaxValue )
                        book.Content = ulong.MaxValue;
                }
                else
                {
                    book = new Spellbook();
                    book.Content = ulong.MaxValue;//all spells
                    GiveItem( from, book );
                }
            }
            else
            {
                for(int i=0;i<3;i++)
                    PackItem( from, new GreaterHealPotion() );
            }

            if ( from.Skills[SkillName.Healing].Value >= 50.0 )
                PackItem( from, new Bandage( 100 ) );

            if ( from.Skills[SkillName.Fencing].Value >= 50.0 )
            {
                PackItem( from, new ShortSpear() );
                if ( from.Skills[SkillName.Parry].Value >= 50.0 )
                {
                    GiveItem( from, new Kryss() );
                    GiveItem( from, new MetalKiteShield() );
                }
                else
                {
                    GiveItem( from, new Spear() );
                }
            }

            if ( from.Skills[SkillName.Swords].Value >= 50.0 )
            {
                if ( from.Skills[SkillName.Parry].Value >= 50.0 )
                {
                    GiveItem( from, new MetalKiteShield() );
                }

                if ( from.Skills[SkillName.Lumberjacking].Value >= 50.0 )
                {
                    GiveItem( from, new Hatchet() );
                    PackItem( from, new LargeBattleAxe() );
                }

                PackItem( from, new Halberd() );
                GiveItem( from, new Katana() );
            }

            if ( from.Skills[SkillName.Macing].Value >= 50.0 )
            {
                if ( from.Skills[SkillName.Parry].Value >= 50.0 )
                    GiveItem( from, new MetalKiteShield() );
                GiveItem( from, new WarAxe() );
                PackItem( from, new WarHammer() );
            }

            if ( from.Skills[SkillName.Archery].Value >= 50.0 )
            {
                GiveItem( from, new Bow() );
                PackItem( from, new Crossbow() );
                PackItem( from, new HeavyCrossbow() );

                PackItem( from, new Bolt( 100 ) );
                PackItem( from, new Arrow( 100 ) );
            }

            if ( from.Skills[SkillName.Tailoring].Value >= 50.0 )
            {
                PackItem( from, new SewingKit() );
                PackItem( from, new Cloth( 25 ) );
                PackItem( from, new Leather( 100 ) );
            }

            if ( from.Skills[SkillName.Blacksmith].Value >= 50.0 )
            {
                PackItem( from, new Tongs() );
                PackItem( from, new IronIngot( 300 ) );
            }

            if ( from.Skills[SkillName.Poisoning].Value >= 50.0 )
            {
                for (int i=0;i<5;i++)
                    PackItem( from, new GreaterPoisonPotion() );
            }
        }
示例#31
0
		public static void HandleDeath( Mobile victim, Mobile killer )
		{
			if ( killer == null )
				killer = victim.FindMostRecentDamager( true );

			PlayerState killerState = PlayerState.Find( killer );

			Container pack = victim.Backpack;

			if ( pack != null )
			{
				Container killerPack = ( killer == null ? null : killer.Backpack );
				Item[] sigils = pack.FindItemsByType( typeof( Sigil ) );

				for ( int i = 0; i < sigils.Length; ++i )
				{
					Sigil sigil = (Sigil)sigils[i];

					if ( killerState != null && killerPack != null )
					{
						if ( killer.GetDistanceToSqrt( victim ) > 64 ) {
							sigil.ReturnHome();
							killer.SendLocalizedMessage( 1042230 ); // The sigil has gone back to its home location.
						}
						else if ( Sigil.ExistsOn( killer ) )
						{
							sigil.ReturnHome();
							killer.SendLocalizedMessage( 1010258 ); // The sigil has gone back to its home location because you already have a sigil.
						}
						else if ( !killerPack.TryDropItem( killer, sigil, false ) )
						{
							sigil.ReturnHome();
							killer.SendLocalizedMessage( 1010259 ); // The sigil has gone home because your backpack is full.
						}
					}
					else
					{
						sigil.ReturnHome();
					}
				}
			}

			if ( killerState == null )
				return;

			if ( victim is BaseCreature )
			{
				BaseCreature bc = (BaseCreature)victim;
				Faction victimFaction = bc.FactionAllegiance;

				if ( bc.Map == Faction.Facet && victimFaction != null && killerState.Faction != victimFaction )
				{
					int silver = killerState.Faction.AwardSilver( killer, bc.FactionSilverWorth );

					if ( silver > 0 )
						killer.SendLocalizedMessage( 1042748, silver.ToString( "N0" ) ); // Thou hast earned ~1_AMOUNT~ silver for vanquishing the vile creature.
				}

				#region Ethics
				if ( bc.Map == Faction.Facet && bc.GetEthicAllegiance( killer ) == BaseCreature.Allegiance.Enemy )
				{
					Ethics.Player killerEPL = Ethics.Player.Find( killer );

					if ( killerEPL != null && ( 100 - killerEPL.Power ) > Utility.Random( 100 ) )
					{
						++killerEPL.Power;
						++killerEPL.History;
					}
				}
				#endregion

				return;
			}

			PlayerState victimState = PlayerState.Find( victim );

			if ( victimState == null )
				return;

			if ( killer == victim || killerState.Faction != victimState.Faction )
				ApplySkillLoss( victim );

			if ( killerState.Faction != victimState.Faction )
			{
				if ( victimState.KillPoints <= -6 )
				{
					killer.SendLocalizedMessage( 501693 ); // This victim is not worth enough to get kill points from. 

					#region Ethics
					Ethics.Player killerEPL = Ethics.Player.Find( killer );
					Ethics.Player victimEPL = Ethics.Player.Find( victim );

					if ( killerEPL != null && victimEPL != null && victimEPL.Power > 0 && victimState.CanGiveSilverTo( killer ) )
					{
						int powerTransfer = Math.Max( 1, victimEPL.Power / 5 );

						if ( powerTransfer > ( 100 - killerEPL.Power ) )
							powerTransfer = 100 - killerEPL.Power;

						if ( powerTransfer > 0 )
						{
							victimEPL.Power -= ( powerTransfer + 1 ) / 2;
							killerEPL.Power += powerTransfer;

							killerEPL.History += powerTransfer;

							victimState.OnGivenSilverTo( killer );
						}
					}
					#endregion
				}
				else
				{
					int award = Math.Max( victimState.KillPoints / 10, 1 );

					if ( award > 40 )
						award = 40;

					if ( victimState.CanGiveSilverTo( killer ) )
					{
						if ( victimState.KillPoints > 0 )
						{
							victimState.IsActive = true;

							if ( 1 > Utility.Random( 3 ) )
								killerState.IsActive = true;
							
							int silver = 0;

							silver = killerState.Faction.AwardSilver( killer, award * 40 );

							if ( silver > 0 )
								killer.SendLocalizedMessage( 1042736, String.Format( "{0:N0} silver\t{1}", silver, victim.Name ) ); // You have earned ~1_SILVER_AMOUNT~ pieces for vanquishing ~2_PLAYER_NAME~!
						}

						victimState.KillPoints -= award;
						killerState.KillPoints += award;

						int offset = ( award != 1 ? 0 : 2 ); // for pluralization

						string args = String.Format( "{0}\t{1}\t{2}", award, victim.Name, killer.Name );

						killer.SendLocalizedMessage( 1042737 + offset, args ); // Thou hast been honored with ~1_KILL_POINTS~ kill point(s) for vanquishing ~2_DEAD_PLAYER~!
						victim.SendLocalizedMessage( 1042738 + offset, args ); // Thou has lost ~1_KILL_POINTS~ kill point(s) to ~3_ATTACKER_NAME~ for being vanquished!

						#region Ethics
						Ethics.Player killerEPL = Ethics.Player.Find( killer );
						Ethics.Player victimEPL = Ethics.Player.Find( victim );

						if ( killerEPL != null && victimEPL != null && victimEPL.Power > 0 )
						{
							int powerTransfer = Math.Max( 1, victimEPL.Power / 5 );

							if ( powerTransfer > ( 100 - killerEPL.Power ) )
								powerTransfer = 100 - killerEPL.Power;

							if ( powerTransfer > 0 )
							{
								victimEPL.Power -= ( powerTransfer + 1 ) / 2;
								killerEPL.Power += powerTransfer;

								killerEPL.History += powerTransfer;
							}
						}
						#endregion

						victimState.OnGivenSilverTo( killer );
					}
					else
					{
						killer.SendLocalizedMessage( 1042231 ); // You have recently defeated this enemy and thus their death brings you no honor.
					}
				}
			}
		}
        public void CheckGuardCandidate( Mobile m )
        {
            if ( IsDisabled() )
                return;

            if ( IsGuardCandidate( m ) )
            {
                GuardTimer timer = null;
                m_GuardCandidates.TryGetValue( m, out timer );

                if ( timer == null )
                {
                    timer = new GuardTimer( m, m_GuardCandidates );
                    timer.Start();

                    m_GuardCandidates[m] = timer;
                    m.SendLocalizedMessage( 502275 ); // Guards can now be called on you!

                    Map map = m.Map;

                    if ( map != null )
                    {
                        Mobile fakeCall = null;
                        double prio = 0.0;

                        foreach ( Mobile v in m.GetMobilesInRange( 8 ) )
                        {
                            if( !v.Player && v != m  && !IsGuardCandidate( v ) && !(v is CharacterStatue) && ((v is BaseCreature)? ((BaseCreature)v).IsHumanInTown() : (v.Body.IsHuman && v.Region.IsPartOf( this ))) )
                            {
                                double dist = m.GetDistanceToSqrt( v );

                                if ( fakeCall == null || dist < prio )
                                {
                                    fakeCall = v;
                                    prio = dist;
                                }
                            }
                        }

                        if ( fakeCall != null )
                        {
                            fakeCall.Say( Utility.RandomList( 1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, 1013043, 1013052 ) );
                            MakeGuard( m );
                            timer.Stop();
                            m_GuardCandidates.Remove( m );
                            m.SendLocalizedMessage( 502276 ); // Guards can no longer be called on you.
                        }
                    }
                }
                else
                {
                    timer.Stop();
                    timer.Start();
                }
            }
        }
示例#33
0
        public static void DrunkardThrowBottle(Mobile from)
        {
            if (from == null)
            {
                return;
            }

            Point3D location = from.Location;
            Map     map      = from.Map;

            int throwSound = 0x5D3;
            int itemId     = Utility.RandomList(2459, 2463, 2503);
            int itemHue    = 0;
            int hitSound   = Utility.RandomList(0x38D, 0x38E, 0x38F, 0x390);

            bool    foundLocation  = false;
            Point3D targetLocation = new Point3D();

            List <Point3D> m_ValidLocations = SpecialAbilities.GetSpawnableTiles(from.Location, true, false, from.Location, from.Map, 1, 25, 2, 8, true);

            if (m_ValidLocations.Count > 0)
            {
                targetLocation = m_ValidLocations[Utility.RandomMinMax(0, m_ValidLocations.Count - 1)];
                foundLocation  = true;

                from.Direction = from.GetDirectionTo(targetLocation);

                Timer.DelayCall(TimeSpan.FromSeconds(.25), delegate
                {
                    if (from == null)
                    {
                        return;
                    }
                    if (!from.Alive)
                    {
                        return;
                    }

                    from.Animate(31, 7, 1, true, false, 0); //Throw Bottle
                    from.PublicOverheadMessage(MessageType.Regular, 0, false, "*drunkenly throws bottle*");
                });
            }

            if (!foundLocation)
            {
                from.PublicOverheadMessage(MessageType.Regular, 0, false, "*drops bottle*");

                TimedStatic bottle = new TimedStatic(Utility.RandomList(0x38D, 0x38E, 0x38F, 0x390), 1);
                bottle.Name = "a drunkard's bottle";
                bottle.MoveToWorld(from.Location, from.Map);

                Effects.PlaySound(targetLocation, map, hitSound);

                return;
            }

            Timer.DelayCall(TimeSpan.FromSeconds(.75), delegate
            {
                if (from == null)
                {
                    return;
                }
                if (!from.Alive)
                {
                    return;
                }

                if (foundLocation)
                {
                    Effects.PlaySound(from.Location, from.Map, throwSound);

                    IEntity startLocation = new Entity(Serial.Zero, new Point3D(from.Location.X, from.Location.Y, from.Location.Z + 10), from.Map);
                    IEntity endLocation   = new Entity(Serial.Zero, new Point3D(targetLocation.X, targetLocation.Y, targetLocation.Z + 5), from.Map);

                    Direction direction = from.GetDirectionTo(targetLocation);

                    double speedModifier = .66;

                    Effects.SendMovingEffect(startLocation, endLocation, itemId, (int)(15 * speedModifier), 0, true, false, itemHue, 0);

                    double distance         = from.GetDistanceToSqrt(targetLocation);
                    double destinationDelay = (double)distance * .08 * (.5 / speedModifier);

                    Timer.DelayCall(TimeSpan.FromSeconds(destinationDelay), delegate
                    {
                        Effects.PlaySound(targetLocation, map, hitSound);
                    });
                }
            });
        }