Beispiel #1
0
        public virtual void Open( Mobile from, bool checkSelfLoot )
        {
            if ( from.AccessLevel > AccessLevel.Player || from.InRange( this.GetWorldLocation(), 2 ) )
            {

                #region Self Looting
                bool selfLoot = ( checkSelfLoot && ( from == m_Owner ) );

                if ( selfLoot )
                {
                    List<Item> items = new List<Item>( this.Items );

                    bool gathered = false;
                    bool didntFit = false;

                    Container pack = from.Backpack;

                    bool checkRobe = true;

                    for ( int i = 0; !didntFit && i < items.Count; ++i )
                    {
                        Item item = items[i];
                        Point3D loc = item.Location;

                        if ( (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair) || !item.Movable || !GetRestoreInfo( item, ref loc ) )
                            continue;

                        if ( checkRobe )
                        {
                            DeathRobe robe = from.FindItemOnLayer( Layer.OuterTorso ) as DeathRobe;

                            if ( robe != null )
                            {
                                if ( Core.SE )
                                {
                                    robe.Delete();
                                }
                                else
                                {
                                    Map map = from.Map;

                                    if ( map != null && map != Map.Internal )
                                        robe.MoveToWorld( from.Location, map );
                                }
                            }
                        }

                        if ( m_EquipItems.Contains( item ) && from.EquipItem( item ) )
                        {
                            gathered = true;
                        }
                        else if ( pack != null && pack.CheckHold( from, item, false, true ) )
                        {
                            item.Location = loc;
                            pack.AddItem( item );
                            gathered = true;
                        }
                        else
                        {
                            didntFit = true;
                        }
                    }

                    if ( gathered && !didntFit )
                    {
                        SetFlag( CorpseFlag.Carved, true );

                        if ( ItemID == 0x2006 )
                        {
                            ProcessDelta();
                            SendRemovePacket();
                            ItemID = Utility.Random( 0xECA, 9 ); // bone graphic
                            Hue = 0;
                            ProcessDelta();
                        }

                        from.PlaySound( 0x3E3 );
                        from.SendLocalizedMessage( 1062471 ); // You quickly gather all of your belongings.
                        return;
                    }

                    if ( gathered && didntFit )
                        from.SendLocalizedMessage( 1062472 ); // You gather some of your belongings. The rest remain on the corpse.
                }

                #endregion

                if ( !CheckLoot( from, null ) )
                    return;

                #region Quests
                PlayerMobile player = from as PlayerMobile;

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

                    if ( qs is UzeraanTurmoilQuest )
                    {
                        GetDaemonBoneObjective obj = qs.FindObjective( typeof( GetDaemonBoneObjective ) ) as GetDaemonBoneObjective;

                        if ( obj != null && obj.CorpseWithBone == this && ( !obj.Completed || UzeraanTurmoilQuest.HasLostDaemonBone( player ) ) )
                        {
                            Item bone = new QuestDaemonBone();

                            if ( player.PlaceInBackpack( bone ) )
                            {
                                obj.CorpseWithBone = null;
                                player.SendLocalizedMessage( 1049341, "", 0x22 ); // You rummage through the bones and find a Daemon Bone!  You quickly place the item in your pack.

                                if ( !obj.Completed )
                                    obj.Complete();
                            }
                            else
                            {
                                bone.Delete();
                                player.SendLocalizedMessage( 1049342, "", 0x22 ); // Rummaging through the bones you find a Daemon Bone, but can't pick it up because your pack is too full.  Come back when you have more room in your pack.
                            }

                            return;
                        }
                    }
                    else if ( qs is TheSummoningQuest )
                    {
                        VanquishDaemonObjective obj = qs.FindObjective( typeof( VanquishDaemonObjective ) ) as VanquishDaemonObjective;

                        if ( obj != null && obj.Completed && obj.CorpseWithSkull == this )
                        {
                            GoldenSkull sk = new GoldenSkull();

                            if ( player.PlaceInBackpack( sk ) )
                            {
                                obj.CorpseWithSkull = null;
                                player.SendLocalizedMessage( 1050022 ); // For your valor in combating the devourer, you have been awarded a golden skull.
                                qs.Complete();
                            }
                            else
                            {
                                sk.Delete();
                                player.SendLocalizedMessage( 1050023 ); // You find a golden skull, but your backpack is too full to carry it.
                            }
                        }
                    }
                }

                #endregion

                base.OnDoubleClick( from );
            }
            else
            {
                from.SendLocalizedMessage( 500446 ); // That is too far away.
                return;
            }
        }
Beispiel #2
0
		public virtual void Open( Mobile from, bool checkSelfLoot )
		{
            //You can not loot as soon as you open the bones, you have to wait 1.5 secs.
            //This is used to stop people from looting their own items right after they
            //die and get cut and should not interfer with normal players to much
            //Taran: This caused too much annoyance so I removed it

            //if (m_ViewedBy != null && from.AccessLevel == AccessLevel.Player && Owner is PlayerMobile && Carved && !m_ViewedBy.Contains(from))
            //    from.NextActionTime = DateTime.Now + TimeSpan.FromSeconds(1.5);

			if ( from.AccessLevel > AccessLevel.Player || (from.InRange( GetWorldLocation(), 2 ) && from.InLOS(this)) )
			{
                #region Self Looting
                if (checkSelfLoot && from == m_Owner && !GetFlag(CorpseFlag.SelfLooted) && Items.Count != 0 && !GetFlag(CorpseFlag.Carved) && m_Looters.Count == 0)
                {
                    DeathRobe robe = from.FindItemOnLayer(Layer.OuterTorso) as DeathRobe;

                    if (robe != null)
                    {
                        Map map = from.Map;

                        if (map != null && map != Map.Internal)
                        {
                            robe.MoveToWorld(from.Location, map);
                            robe.BeginDecay();
                        }
                    }

                    Container pack = from.Backpack;

                    if (m_RestoreEquip != null && pack != null)
                    {
                        List<Item> packItems = new List<Item>(pack.Items); // Only items in the top-level pack are re-equipped

                        for (int i = 0; i < packItems.Count; i++)
                        {
                            Item packItem = packItems[i];

                            if (m_RestoreEquip.Contains(packItem) && packItem.Movable)
                                from.EquipItem(packItem);
                        }
                    }

                    List<Item> items = new List<Item>(this.Items);

                    bool didntFit = false;

                    for (int i = 0; !didntFit && i < items.Count; ++i)
                    {
                        Item item = items[i];
                        Point3D loc = item.Location;

                        if ((item.Layer == Layer.Hair || item.Layer == Layer.FacialHair) || !item.Movable || !GetRestoreInfo(item, ref loc))
                            continue;

                        if (pack != null && pack.CheckHold(from, item, false, true))
                        {
                            item.Location = loc;
                            pack.AddItem(item);

                            if (m_RestoreEquip != null && m_RestoreEquip.Contains(item))
                                from.EquipItem(item);
                        }
                        else
                        {
                            didntFit = true;
                        }
                    }

                    from.PlaySound(0x3E3);

                    if (this.Items.Count != 0)
                    {
                        from.SendLocalizedMessage(1062472); // You gather some of your belongings. The rest remain on the corpse.
                    }
                    else
                    {
                        SetFlag(CorpseFlag.Carved, true);

                        if (ItemID == 0x2006)
                        {
                            ProcessDelta();
                            SendRemovePacket();
                            ItemID = Utility.Random(0xECA, 9); // bone graphic
                            Hue = 0;
                            ProcessDelta();
                        }

                        from.SendLocalizedMessage(1062471); // You quickly gather all of your belongings.
                    }

                    SetFlag(CorpseFlag.SelfLooted, true);

                    if (!m_Looters.Contains(from)) //Add looter flag when self looting
                        m_Looters.Add(from);
                }
                #endregion

                if (!CheckLoot(from, null))
					return;

				#region Quests
				PlayerMobile player = from as PlayerMobile;

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

					if ( qs is UzeraanTurmoilQuest )
					{
						GetDaemonBoneObjective obj = qs.FindObjective( typeof( GetDaemonBoneObjective ) ) as GetDaemonBoneObjective;

						if ( obj != null && obj.CorpseWithBone == this && ( !obj.Completed || UzeraanTurmoilQuest.HasLostDaemonBone( player ) ) )
						{
							Item bone = new QuestDaemonBone();

							if ( player.PlaceInBackpack( bone ) )
							{
								obj.CorpseWithBone = null;
								player.SendLocalizedMessage( 1049341, "", 0x22 ); // You rummage through the bones and find a Daemon Bone!  You quickly place the item in your pack.

								if ( !obj.Completed )
									obj.Complete();
							}
							else
							{
								bone.Delete();
								player.SendLocalizedMessage( 1049342, "", 0x22 ); // Rummaging through the bones you find a Daemon Bone, but can't pick it up because your pack is too full.  Come back when you have more room in your pack.
							}

							return;
						}
					}
					else if ( qs is TheSummoningQuest )
					{
						VanquishDaemonObjective obj = qs.FindObjective( typeof( VanquishDaemonObjective ) ) as VanquishDaemonObjective;

						if ( obj != null && obj.Completed && obj.CorpseWithSkull == this )
						{
							GoldenSkull sk = new GoldenSkull();

							if ( player.PlaceInBackpack( sk ) )
							{
								obj.CorpseWithSkull = null;
								player.SendLocalizedMessage( 1050022 ); // For your valor in combating the devourer, you have been awarded a golden skull.
								qs.Complete();
							}
							else
							{
								sk.Delete();
								player.SendLocalizedMessage( 1050023 ); // You find a golden skull, but your backpack is too full to carry it.
							}
						}
					}
				}

				#endregion

				base.OnDoubleClick( from );
			}
			else
			{
                from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
				return;
			}
		}