コード例 #1
0
ファイル: Mobile.cs プロジェクト: BackupTheBerlios/sunuo-svn
        public virtual void Lift( Item item, int amount, out bool rejected, out LRReason reject )
        {
            rejected = true;
            reject = LRReason.Inspecific;

            if ( item == null )
                return;

            Mobile from = this;
            NetState state = m_NetState;

            if ( from.AccessLevel >= AccessLevel.GameMaster || Core.Now >= from.NextActionTime )
            {
                if ( from.CheckAlive() )
                {
                    from.DisruptiveAction();

                    if ( from.Holding != null )
                    {
                        reject = LRReason.AreHolding;
                    }
                    else if ( from.AccessLevel < AccessLevel.GameMaster && !from.InRange( item.GetWorldLocation(), 2 ) )
                    {
                        reject = LRReason.OutOfRange;
                    }
                    else if ( !from.CanSee( item ) || !from.InLOS( item ) )
                    {
                        reject = LRReason.OutOfSight;
                    }
                    else if ( !item.VerifyMove( from ) )
                    {
                        reject = LRReason.CannotLift;
                    }
                    else if ( item.InSecureTrade || !item.IsAccessibleTo( from ) )
                    {
                        reject = LRReason.CannotLift;
                    }
                    else if ( !item.CheckLift( from, item ) )
                    {
                        reject = LRReason.Inspecific;
                    }
                    else
                    {
                        object root = item.RootParent;

                        if ( root != null && root is Mobile && !((Mobile)root).CheckNonlocalLift( from, item ) )
                        {
                            reject = LRReason.TryToSteal;
                        }
                        else if ( !from.OnDragLift( item ) || !item.OnDragLift( from ) )
                        {
                            reject = LRReason.Inspecific;
                        }
                        else if ( !from.CheckAlive() )
                        {
                            reject = LRReason.Inspecific;
                        }
                        else
                        {
                            item.SetLastMoved();

                            if ( amount == 0 )
                                amount = 1;

                            if ( amount > item.Amount )
                                amount = item.Amount;

                            int oldAmount = item.Amount;
                            item.Amount = amount;

                            if ( amount < oldAmount )
                                item.Dupe( oldAmount - amount );

                            Map map = from.Map;

                            if ( Mobile.DragEffects && map != null && (root == null || root is Item))
                            {
                                IPooledEnumerable eable = map.GetClientsInRange( from.Location );
                                Packet p = null;

                                foreach ( NetState ns in eable )
                                {
                                    if ( ns.Mobile != from && ns.Mobile.CanSee( from ) )
                                    {
                                        if ( p == null )
                                        {
                                            IEntity src;

                                            if ( root == null )
                                                src = new Entity( Serial.Zero, item.Location, map );
                                            else
                                                src = new Entity( ((Item)root).Serial, ((Item)root).Location, map );

                                            p = new DragEffect( src, from, item.ItemID, item.Hue, amount );
                                        }

                                        ns.Send( p );
                                    }
                                }

                                eable.Free();
                            }

                            Point3D fixLoc = item.Location;
                            Map fixMap = item.Map;
                            bool shouldFix = ( item.Parent == null );

                            item.RecordBounce();
                            item.OnItemLifted( from, item );
                            item.Internalize();

                            from.Holding = item;

                            int liftSound = item.GetLiftSound( from );

                            if ( liftSound != -1 )
                                from.Send( new PlaySound( liftSound, from ) );

                            from.NextActionTime = Core.Now + TimeSpan.FromSeconds( 0.5 );

                            if ( fixMap != null && shouldFix )
                                fixMap.FixColumn( fixLoc.m_X, fixLoc.m_Y );

                            reject = LRReason.Inspecific;
                            rejected = false;
                        }
                    }
                }
                else
                {
                    reject = LRReason.Inspecific;
                }
            }
            else
            {
                SendActionMessage();
                reject = LRReason.Inspecific;
            }

            if ( rejected && state != null )
            {
                state.Send( new LiftRej( reject ) );

                if( item.Parent is Item ) {
                    if ( state.IsPost6017 )
                        state.Send( new ContainerContentUpdate6017( item ) );
                    else
                        state.Send( new ContainerContentUpdate( item ) );
                } else if( item.Parent is Mobile )
                    state.Send( new EquipUpdate( item ) );
                else
                    item.SendInfoTo( state );

                if ( ObjectPropertyList.Enabled && item.Parent != null )
                    state.Send( item.OPLPacket );
            }
        }
コード例 #2
0
        public virtual void LoadWeapon(Mobile from, Item projectile)
        {
            if (projectile == null) return;

            // restrict allowed projectiles
            if (!CheckAllowedProjectile(projectile))
            {
                from.SendMessage("That cannot be loaded into this weapon");
                return;
            }

            if (m_Projectile != null && !m_Projectile.Deleted)
            {

                from.SendMessage("{0} unloaded", m_Projectile.Name);
                from.AddToBackpack(m_Projectile);
            }

            if (projectile.Amount > 1)
            {
                projectile.Amount--;
                Projectile = projectile.Dupe(1);
            }
            else
            {
                Projectile = projectile;
            }

            if (m_Projectile != null)
            {

                m_Projectile.Internalize();

                from.SendMessage("{0} loaded", m_Projectile.Name);
            }
        }
コード例 #3
0
			private Item TryStealItem( Item toSteal, ref bool caught )
			{
				Item stolen = null;

				object root = toSteal.RootParent;

				if ( !IsEmptyHanded( m_Thief ) )
				{
					m_Thief.SendLocalizedMessage( 1005584 ); // Both hands must be free to steal.
				}
				else if ( root is Mobile && ((Mobile)root).Player && IsInnocentTo( m_Thief, (Mobile)root ) && !IsInGuild( m_Thief ) )
				{
					m_Thief.SendLocalizedMessage( 1005596 ); // You must be in the thieves guild to steal from other players.
				}
				else if ( SuspendOnMurder && root is Mobile && ((Mobile)root).Player && IsInGuild( m_Thief ) && m_Thief.Kills > 0 )
				{
					m_Thief.SendLocalizedMessage( 502706 ); // You are currently suspended from the thieves guild.
				}
				else if ( root is BaseVendor && ((BaseVendor)root).IsInvulnerable )
				{
					m_Thief.SendLocalizedMessage( 1005598 ); // You can't steal from shopkeepers.
				}
				else if ( root is PlayerVendor )
				{
					m_Thief.SendLocalizedMessage( 502709 ); // You can't steal from vendors.
				}
				else if ( !m_Thief.CanSee( toSteal ) )
				{
					m_Thief.SendLocalizedMessage( 500237 ); // Target can not be seen.
				}
				else if ( m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold( m_Thief, toSteal, false, true ) )
				{
					m_Thief.SendLocalizedMessage( 1048147 ); // Your backpack can't hold anything else.
				}
				#region Sigils
				else if ( toSteal is Sigil )
				{
					PlayerState pl = PlayerState.Find( m_Thief );
					Faction faction = ( pl == null ? null : pl.Faction );

					Sigil sig = (Sigil) toSteal;

					if ( !m_Thief.InRange( toSteal.GetWorldLocation(), 1 ) )
					{
						m_Thief.SendLocalizedMessage( 502703 ); // You must be standing next to an item to steal it.
					}
					else if ( root != null ) // not on the ground
					{
						m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
					}
					else if ( faction != null )
					{
						if ( !m_Thief.CanBeginAction( typeof( IncognitoSpell ) ) )
						{
							m_Thief.SendLocalizedMessage( 1010581 ); //	You cannot steal the sigil when you are incognito
						}
						else if ( DisguiseGump.IsDisguised( m_Thief ) )
						{
							m_Thief.SendLocalizedMessage( 1010583 ); //	You cannot steal the sigil while disguised
						}
						else if ( !m_Thief.CanBeginAction( typeof( PolymorphSpell ) ) )
						{
							m_Thief.SendLocalizedMessage( 1010582 ); //	You cannot steal the sigil while polymorphed
						}
						else if ( TransformationSpell.UnderTransformation( m_Thief ) )
						{
							m_Thief.SendLocalizedMessage( 1061622 ); // You cannot steal the sigil while in that form.
						}
						else if ( pl.IsLeaving )
						{
							m_Thief.SendLocalizedMessage( 1005589 ); // You are currently quitting a faction and cannot steal the town sigil
						}
						else if ( sig.IsBeingCorrupted && sig.LastMonolith.Faction == faction )
						{
							m_Thief.SendLocalizedMessage( 1005590 ); //	You cannot steal your own sigil
						}
						else if ( sig.IsPurifying )
						{
							m_Thief.SendLocalizedMessage( 1005592 ); // You cannot steal this sigil until it has been purified
						}
						// jakob, added this to check control points
						else if ( sig.LastMonolith is TownMonolith && !((TownMonolith)sig.LastMonolith).HasAllControlPoints( pl.Faction ) )
						{
							m_Thief.SendMessage( "You cannot steal this sigil unless your faction is controlling all control points." );
						}
						// end
						else if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, 80.0, 80.0 ) )
						{
							if ( Sigil.ExistsOn( m_Thief ) )
							{
								m_Thief.SendLocalizedMessage( 1010258 ); //	The sigil has gone back to its home location because you already have a sigil.
							}
							else if ( m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold( m_Thief, sig, false, true ) )
							{
								m_Thief.SendLocalizedMessage( 1010259 ); //	The sigil has gone home because your backpack is full
							}
							else
							{
								if ( sig.IsBeingCorrupted )
									sig.GraceStart = DateTime.Now; // begin grace period

								m_Thief.SendLocalizedMessage( 1010586 ); // YOU STOLE THE SIGIL!!!   (woah, call down now)

								if ( sig.LastMonolith != null )
									sig.LastMonolith.Sigil = null;

								sig.LastStolen = DateTime.Now;

								return sig;
							}
						}
						else
						{
							m_Thief.SendLocalizedMessage( 1005594 ); //	You do not have enough skill to steal the sigil
						}
					}
					else
					{
						m_Thief.SendLocalizedMessage( 1005588 ); //	You must join a faction to do that
					}
				}
				#endregion
				else if ( toSteal.Parent == null || !toSteal.Movable || toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed( root ) )
				{
					m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
				}
				else if ( Core.AOS && toSteal is Container )
				{
					m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
				}
				else if ( !m_Thief.InRange( toSteal.GetWorldLocation(), 1 ) )
				{
					m_Thief.SendLocalizedMessage( 502703 ); // You must be standing next to an item to steal it.
				}
				else if ( toSteal.Parent is Mobile )
				{
					m_Thief.SendLocalizedMessage( 1005585 ); // You cannot steal items which are equiped.
				}
				else if ( root == m_Thief )
				{
					m_Thief.SendLocalizedMessage( 502704 ); // You catch yourself red-handed.
				}
				else if ( root is Mobile && ((Mobile)root).AccessLevel > AccessLevel.Player )
				{
					m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
				}
				else if ( root is Mobile && !m_Thief.CanBeHarmful( (Mobile)root ) )
				{
				}
				else if ( root is Corpse )
				{
					m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
				}
				else
				{
					double w = toSteal.Weight + toSteal.TotalWeight;

					if ( w > 10 )
					{
						m_Thief.SendMessage( "That is too heavy to steal." );
					}
					else
					{
						if ( toSteal.Stackable && toSteal.Amount > 1 )
						{
							int maxAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 10.0) / toSteal.Weight);

							if ( maxAmount < 1 )
								maxAmount = 1;
							else if ( maxAmount > toSteal.Amount )
								maxAmount = toSteal.Amount;

							int amount = Utility.RandomMinMax( 1, maxAmount );

							if ( amount >= toSteal.Amount )
							{
								int pileWeight = (int)Math.Ceiling( toSteal.Weight * toSteal.Amount );
								pileWeight *= 10;

								if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
									stolen = toSteal;
							}
							else
							{
								int pileWeight = (int)Math.Ceiling( toSteal.Weight * amount );
								pileWeight *= 10;

								if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
								{
									stolen = toSteal.Dupe( amount );
									toSteal.Amount -= amount;
								}
							}
						}
						else
						{
							int iw = (int)Math.Ceiling( w );
							iw *= 10;

							if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, iw - 22.5, iw + 27.5 ) )
								stolen = toSteal;
						}

						if ( stolen != null )
							m_Thief.SendLocalizedMessage( 502724 ); // You succesfully steal the item.
						else
							m_Thief.SendLocalizedMessage( 502723 ); // You fail to steal the item.

						caught = ( m_Thief.Skills[SkillName.Stealing].Value < Utility.Random( 150 ) );
					}
				}

				return stolen;
			}
コード例 #4
0
ファイル: Stealing.cs プロジェクト: cynricthehun/UOLegends
            private Item TryStealItem( Item toSteal, ref bool caught )
            {
                Item stolen = null;

                object root = toSteal.RootParent;

                if ( !IsEmptyHanded( m_Thief ) )
                {
                    m_Thief.SendLocalizedMessage( 1005584 ); // Both hands must be free to steal.
                }
                else if ( root is Mobile && ((Mobile)root).Player && IsInnocentTo( m_Thief, (Mobile)root ) && !IsInGuild( m_Thief ) )
                {
                    m_Thief.SendLocalizedMessage( 1005596 ); // You must be in the thieves guild to steal from other players.
                }
                else if ( SuspendOnMurder && root is Mobile && ((Mobile)root).Player && IsInGuild( m_Thief ) && m_Thief.Kills > 0 )
                {
                    m_Thief.SendLocalizedMessage( 502706 ); // You are currently suspended from the thieves guild.
                }
                else if ( root is BaseVendor && ((BaseVendor)root).IsInvulnerable )
                {
                    m_Thief.SendLocalizedMessage( 1005598 ); // You can't steal from shopkeepers.
                }
                else if ( root is PlayerVendor )
                {
                    m_Thief.SendLocalizedMessage( 502709 ); // You can't steal from vendors.
                }
                else if ( !m_Thief.CanSee( toSteal ) )
                {
                    m_Thief.SendLocalizedMessage( 500237 ); // Target can not be seen.
                }
                else if ( m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold( m_Thief, toSteal, false, true ) )
                {
                    m_Thief.SendLocalizedMessage( 1048147 ); // Your backpack can't hold anything else.
                }
                #region Sigils
                else if ( toSteal is Sigil )
                {
                    PlayerState pl = PlayerState.Find( m_Thief );
                    Faction faction = ( pl == null ? null : pl.Faction );

                    Sigil sig = (Sigil) toSteal;

                    if ( !m_Thief.InRange( toSteal.GetWorldLocation(), 1 ) )
                    {
                        m_Thief.SendLocalizedMessage( 502703 ); // You must be standing next to an item to steal it.
                    }
                    else if ( root != null ) // not on the ground
                    {
                        m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
                    }
                    else if ( faction != null )
                    {
                        if ( !m_Thief.CanBeginAction( typeof( IncognitoSpell ) ) )
                        {
                            m_Thief.SendLocalizedMessage( 1010581 ); //	You cannot steal the sigil when you are incognito
                        }
                        else if ( DisguiseGump.IsDisguised( m_Thief ) )
                        {
                            m_Thief.SendLocalizedMessage( 1010583 ); //	You cannot steal the sigil while disguised
                        }
                        else if ( !m_Thief.CanBeginAction( typeof( PolymorphSpell ) ) )
                        {
                            m_Thief.SendLocalizedMessage( 1010582 ); //	You cannot steal the sigil while polymorphed
                        }
                        else if ( TransformationSpell.UnderTransformation( m_Thief ) )
                        {
                            m_Thief.SendLocalizedMessage( 1061622 ); // You cannot steal the sigil while in that form.
                        }
                        else if ( pl.IsLeaving )
                        {
                            m_Thief.SendLocalizedMessage( 1005589 ); // You are currently quitting a faction and cannot steal the town sigil
                        }
                        else if ( sig.IsBeingCorrupted && sig.LastMonolith.Faction == faction )
                        {
                            m_Thief.SendLocalizedMessage( 1005590 ); //	You cannot steal your own sigil
                        }
                        else if ( sig.IsPurifying )
                        {
                            m_Thief.SendLocalizedMessage( 1005592 ); // You cannot steal this sigil until it has been purified
                        }
                        else if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, 80.0, 80.0 ) )
                        {
                            if ( Sigil.ExistsOn( m_Thief ) )
                            {
                                m_Thief.SendLocalizedMessage( 1010258 ); //	The sigil has gone back to its home location because you already have a sigil.
                            }
                            else if ( m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold( m_Thief, sig, false, true ) )
                            {
                                m_Thief.SendLocalizedMessage( 1010259 ); //	The sigil has gone home because your backpack is full
                            }
                            else
                            {
                                if ( sig.IsBeingCorrupted )
                                    sig.GraceStart = DateTime.Now; // begin grace period

                                m_Thief.SendLocalizedMessage( 1010586 ); // YOU STOLE THE SIGIL!!!   (woah, call down now)

                                if ( sig.LastMonolith != null )
                                    sig.LastMonolith.Sigil = null;

                                sig.LastStolen = DateTime.Now;

                                return sig;
                            }
                        }
                        else
                        {
                            m_Thief.SendLocalizedMessage( 1005594 ); //	You do not have enough skill to steal the sigil
                        }
                    }
                    else
                    {
                        m_Thief.SendLocalizedMessage( 1005588 ); //	You must join a faction to do that
                    }
                }
                #endregion
                //ARTEGORDONMOD
                // allow stealing of rares on the ground or in containers
                else if ( (toSteal.Parent == null || !toSteal.Movable || toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed( root )) && !ItemFlags.GetStealable(toSteal))
                {
                    m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
                }
                //ARTEGORDONMOD
                // allow stealing of containers
                else if ( Core.AOS && toSteal is Container && !ItemFlags.GetStealable(toSteal))
                {
                    m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
                }
                else if ( !m_Thief.InRange( toSteal.GetWorldLocation(), 1 ) )
                {
                    m_Thief.SendLocalizedMessage( 502703 ); // You must be standing next to an item to steal it.
                }
                else if ( toSteal.Parent is Mobile )
                {
                    m_Thief.SendLocalizedMessage( 1005585 ); // You cannot steal items which are equiped.
                }
                else if ( root == m_Thief )
                {
                    m_Thief.SendLocalizedMessage( 502704 ); // You catch yourself red-handed.
                }
                else if ( root is Mobile && ((Mobile)root).AccessLevel > AccessLevel.Player )
                {
                    m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
                }
                else if ( root is Mobile && !m_Thief.CanBeHarmful( (Mobile)root ) )
                {
                }
                else if ( root is Corpse )
                {
                    m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
                }
                else
                {
                    double w = toSteal.Weight + toSteal.TotalWeight;

                    if ( w > 10 )
                    {
                        m_Thief.SendMessage( "That is too heavy to steal." );
                    }
                    else
                    {
                        if ( toSteal.Stackable && toSteal.Amount > 1 )
                        {
                            //ARTEGORDON
                            // fix for zero-weight stackables
                            int maxAmount = toSteal.Amount;
                            if(toSteal.Weight > 0)
                                maxAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 10.0) / toSteal.Weight);

                            if ( maxAmount < 1 )
                                maxAmount = 1;
                            else if ( maxAmount > toSteal.Amount )
                                maxAmount = toSteal.Amount;

                            int amount = Utility.RandomMinMax( 1, maxAmount );

                            if ( amount >= toSteal.Amount )
                            {
                                int pileWeight = (int)Math.Ceiling( toSteal.Weight * toSteal.Amount );
                                pileWeight *= 10;

                                if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
                                    stolen = toSteal;
                            }
                            else
                            {
                                int pileWeight = (int)Math.Ceiling( toSteal.Weight * amount );
                                pileWeight *= 10;

                                if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
                                {
                                    stolen = toSteal.Dupe( amount );
                                    toSteal.Amount -= amount;
                                }
                            }
                        }
                        else
                        {
                            int iw = (int)Math.Ceiling( w );
                            iw *= 10;

                            // ARTEGORDONMOD
                            // Begin mod for ArtifactRarity difficulty scaling
                            // add in an additional difficulty factor for objects with ArtifactRarity
                            // with rarity=1 requiring a minimum of 100 stealing, and rarity 12 requiring a minimum of 118
                            // Note, this is completely independent of weight
                            Type ptype;
                            string value = BaseXmlSpawner.GetBasicPropertyValue(toSteal,"ArtifactRarity", out ptype);

                            if(ptype == typeof(int) && value != null)
                            {
                                int rarity = 0;
                                try{
                                    rarity = int.Parse(value);
                                } catch{}

                                // rarity difficulty scaling
                                if(rarity > 0)
                                {
                                    iw = (int)Math.Ceiling(120 + rarity*1.5);
                                }
                            }
                            // End mod for ArtifactRarity difficulty scaling

                            if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, iw - 22.5, iw + 27.5 ) )
                                stolen = toSteal;
                        }

                        if ( stolen != null )
                        {
                            // ARTEGORDONMOD
                            // Begin mod for stealable rares and other locked down items

                            // set the taken flag to trigger release from any controlling spawner
                            ItemFlags.SetTaken(stolen, true);
                            // clear the stealable flag so that the item can only be stolen once if it is later locked down.
                            ItemFlags.SetStealable(stolen, false);
                            // release it if it was locked down
                            stolen.Movable = true;

                            // End mod for stealable rares and other locked down items

                            m_Thief.SendLocalizedMessage( 502724 ); // You succesfully steal the item.
                        }
                        else
                            m_Thief.SendLocalizedMessage( 502723 ); // You fail to steal the item.

                        caught = ( m_Thief.Skills[SkillName.Stealing].Value < Utility.Random( 150 ) );
                    }
                }

                return stolen;
            }
コード例 #5
0
ファイル: XmlQuest.cs プロジェクト: cynricthehun/UOLegends
        public static bool CheckGiveObjective(IXmlQuest quest, Mobile mob, Item item, string objectivestr, string statestr, out string newstatestr, out bool givestatus)
        {
            // format for the objective string will be GIVE,mobname,itemtype[,count][,proptest] or GIVENAMED,mobname,itemname[,type][,count][,proptest]
            newstatestr = statestr;
            givestatus = false;
            if (objectivestr == null) return false;

            if (mob == null || mob.Name == null) return false;

            string[] arglist = BaseXmlSpawner.ParseString(objectivestr, 6, ",");
            int targetcount = 1;
            bool found = false;
            bool checkprop = true;
            string status_str = null;
            string typestr = null;

            CheckArgList(arglist, 3, item, out typestr, out targetcount, out checkprop, out status_str);

            if (status_str != null) quest.Status = status_str;

            if (arglist.Length > 1)
            {
                // the name of the mob must match the specified mobname
                if (mob.Name != arglist[1]) return false;
            }

            if (arglist.Length > 2)
            {
                // collect task objective
                if (arglist[0] == "GIVE")
                {
                    //Type targettype = SpawnerType.GetType( arglist[2] );

                    // test the requirements against the the given item
                    if (item != null && !item.Deleted && BaseXmlSpawner.CheckType(item, arglist[2]) /*(item.GetType() == targettype)*/ && checkprop)
                    {
                        // found a match
                        found = true;
                    }
                }
                else
                    if (arglist[0] == "GIVENAMED")
                    {
                        if (item != null && !item.Deleted && (arglist[2] == item.Name) && checkprop &&
                        (typestr == null || BaseXmlSpawner.CheckType(item, typestr))
                        )
                        {
                            // found a match
                            found = true;
                        }
                    }
            }
            // update the objective state
            if (found)
            {

                int current = 0;
                try
                {
                    current = int.Parse(statestr);
                }
                catch { }
                // get the current given count and update it
                int added = 0;

                if (item.Stackable)
                {
                    if (targetcount - current < item.Amount)
                    {
                        added = targetcount - current;

                        if (quest != null && quest.PlayerMade)
                        {
                            Item newitem = item.Dupe(added);
                            //if(newitem != null)
                            //newitem.Amount = added;
                            TakeGiven(mob, quest, newitem);
                        }

                        item.Amount -= added;
                    }
                    else
                    {
                        added = item.Amount;
                        TakeGiven(mob, quest, item);
                        //item.Delete();
                    }
                }
                else
                {
                    if (targetcount - current > 0)
                    {
                        added = 1;
                        TakeGiven(mob, quest, item);
                        //item.Delete();
                    }
                }

                int collected = current + added;

                newstatestr = String.Format("{0}", collected);

                if (collected >= targetcount)
                {
                    // givetask completed
                    givestatus = true;
                }

                return (added > 0);

            }
            else
            {
                // not a give task
                return false;
            }
        }
コード例 #6
0
ファイル: XmlQuest.cs プロジェクト: cynricthehun/UOLegends
        public static bool CheckCollectObjective(IXmlQuest quest, Item item, string objectivestr, string statestr, out string newstatestr, out bool collectstatus)
        {
            // format for the objective string will be COLLECT,itemtype[,count][,proptest] or COLLECTNAMED,itemname[,itemtype][,count][,proptest]
            newstatestr = statestr;
            collectstatus = false;
            if (objectivestr == null) return false;

            string[] arglist = BaseXmlSpawner.ParseString(objectivestr, 5, ",");
            int targetcount = 1;
            bool found = false;
            bool checkprop = true;
            string status_str = null;

            string typestr = null;

            CheckArgList(arglist, 2, item, out typestr, out targetcount, out checkprop, out status_str);

            if (status_str != null) quest.Status = status_str;

            if (arglist.Length > 1)
            {
                // collect task objective
                if (arglist[0] == "COLLECT")
                {
                    //Type targettype = SpawnerType.GetType( arglist[1] );
                    // test the collect requirements against the the collected item
                    if (item != null && !item.Deleted && BaseXmlSpawner.CheckType(item, arglist[1])/*(item.GetType() == targettype)*/ && checkprop)
                    {
                        // found a match
                        found = true;
                    }
                }
                else
                    if (arglist[0] == "COLLECTNAMED")
                    {
                        if (item != null && !item.Deleted && (arglist[1] == item.Name) && checkprop &&
                        (typestr == null || BaseXmlSpawner.CheckType(item, typestr))
                        )
                        {
                            // found a match
                            found = true;
                        }
                    }
            }
            // update the objective state
            if (found)
            {

                int current = 0;
                try
                {
                    current = int.Parse(statestr);
                }
                catch { }
                // get the current collect count and update it
                int added = 0;
                if (item.Stackable)
                {
                    if (targetcount - current < item.Amount)
                    {
                        added = targetcount - current;

                        if (quest != null && quest.PlayerMade)
                        {
                            Item newitem = item.Dupe(added);
                            //if(newitem != null)
                            //newitem.Amount = added;
                            ReturnCollected(quest, newitem);
                        }

                        item.Amount -= added;
                    }
                    else
                    {
                        added = item.Amount;
                        // if it is a playermade quest then give the item to the creator, otherwise just delete it
                        ReturnCollected(quest, item);
                        //item.Delete();
                    }
                }
                else
                {
                    if (targetcount - current > 0)
                    {
                        added = 1;
                        ReturnCollected(quest, item);
                        //item.Delete();
                    }
                }

                int collected = current + added;

                newstatestr = String.Format("{0}", collected);

                if (collected >= targetcount)
                {
                    // collecttask completed
                    collectstatus = true;
                }
                return true;
            }
            else
                // not a collect task
                return false;
        }
コード例 #7
0
ファイル: Stealing.cs プロジェクト: FreeReign/Rebirth-Repack
            private Item TryStealItem( Item toSteal, object root, int difficulty, ref bool ok, ref bool caught )
            {
                Item stolen = null;

                //if ( toSteal is KeyRing )
                //	toSteal.Weight = toSteal.TotalWeight = 1;

                if ( root is BaseVendor || root is PlayerVendor )
                {
                    m_Thief.SendLocalizedMessage( 1005598 ); // You can't steal from shopkeepers.
                }
                else if ( !m_Thief.CanSee( toSteal ) || ( root != null && !m_Thief.CanSee( root ) ) )
                {
                    m_Thief.SendLocalizedMessage( 500237 ); // Target can not be seen.
                }
                else if ( !toSteal.Movable || toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed( root ) )
                {
                    m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
                }
                else if ( !m_Thief.InRange( toSteal.GetWorldLocation(), 1 ) )
                {
                    m_Thief.SendLocalizedMessage( 502703 ); // You must be standing next to an item to steal it.
                }
                else if ( toSteal.Parent is Mobile )
                {
                    m_Thief.SendLocalizedMessage( 1005585 ); // You cannot steal items which are equiped.
                }
                else if ( root == m_Thief )
                {
                    m_Thief.SendLocalizedMessage( 502704 ); // You catch yourself red-handed.
                }
                else if ( root is Mobile && ( ((Mobile)root).AccessLevel > AccessLevel.Player || !m_Thief.CanBeHarmful( (Mobile)root ) ) )
                {
                    m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
                }
                else
                {
                    for(Item p = toSteal.Parent as Item;p != null;p=p.Parent as Item)
                    {
                        if ( p is LockableContainer && ((LockableContainer)p).Locked )
                        {
                            m_Thief.SendAsciiMessage( "That is not accessable." );
                            return null;
                        }
                    }

                    if ( toSteal.Weight + toSteal.TotalWeight > 10 )
                    {
                        m_Thief.SendAsciiMessage( "That is too heavy to steal from someone's backpack." );
                    }
                    else
                    {
                        ok = true;

                        double w = toSteal.PileWeight + toSteal.TotalWeight;
                        double check;
                        if ( w >= 10 )
                        {
                            check = 10 * 3.0 * difficulty + 10.0;
                            caught = CheckDetect( ( 10 * 5.0 * difficulty ) / ( m_Thief.Skills.Stealing.Value + 100.0 ), root as Mobile );
                        }
                        else
                        {
                            check = w * 3.0 * difficulty + 10.0;
                            if ( toSteal is Key || toSteal is Multis.Deeds.HouseDeed || toSteal is KeyRing )
                                w += 5;
                            caught = CheckDetect( ( w * 5.0 * difficulty ) / ( m_Thief.Skills.Stealing.Value + 100.0 ), root as Mobile );
                        }

                        if ( m_Thief.CheckSkill( SkillName.Stealing, check-25, check+25 ) )
                        {
                            m_Thief.SendLocalizedMessage( 502724 ); // You succesfully steal the item.
                            if ( toSteal.Stackable && toSteal.Amount > 1 )
                            {
                                int amount;
                                /*int maxAmount = (int)( (m_Thief.Skills[SkillName.Stealing].Value / 10.0) / toSteal.Weight );

                                if ( maxAmount < 1 )
                                    maxAmount = 1;
                                else if ( maxAmount > toSteal.Amount )
                                    maxAmount = toSteal.Amount;
                                amount = Utility.Random( maxAmount ) + 1;*/

                                amount = Utility.Random( 10 ) + 1;

                                if ( amount > w )
                                    amount = toSteal.Amount;
                                else
                                    amount = (toSteal.Amount * amount) / ( toSteal.PileWeight + toSteal.TotalWeight );

                                if ( amount < 1 )
                                    amount = 1;

                                if ( amount >= toSteal.Amount )
                                {
                                    stolen = toSteal;
                                }
                                else
                                {
                                    stolen = toSteal.Dupe( amount );
                                    toSteal.Amount -= amount;
                                }
                            }
                            else
                            {
                                stolen = toSteal;
                            }
                        }
                        else
                        {
                            m_Thief.SendLocalizedMessage( 502723 ); // You fail to steal the item.
                        }
                    }
                }

                return stolen;
            }
コード例 #8
0
ファイル: Stealing.cs プロジェクト: zerodowned/angelisland
			private Item TryStealItem( Item toSteal, ref bool caught )
			{
				//Zen make bankbox close when stealing!
				BankBox box = m_Thief.FindBankNoCreate();

				if ( box != null && box.Opened )
				{
					box.Close();
					m_Thief.Send( new MobileUpdate(m_Thief) );
				}

				Item stolen = null;

				object root = toSteal.RootParent;

				if ( !IsEmptyHanded( m_Thief ) )
				{
					m_Thief.SendLocalizedMessage( 1005584 ); // Both hands must be free to steal.
				}
				// stealing off a corpse is looting
				else if (root is Corpse && CheckStealing(root as Corpse) == false)
				{
					m_Thief.SendMessage("You can't steal that!"); // You can't steal that!
				}
				else if ( root is Mobile 
					&& ((Mobile)root).Player 
					/*&& IsInnocentTo( m_Thief, (Mobile)root )*/
					&& !IsInGuild( m_Thief ) )
				{
					m_Thief.SendLocalizedMessage( 1005596 ); // You must be in the thieves guild to steal from other players.
				}
				else if ( SuspendOnMurder && root is Mobile && ((Mobile)root).Player && IsInGuild( m_Thief ) && m_Thief.Kills > 0 )
				{
					m_Thief.SendLocalizedMessage( 502706 ); // You are currently suspended from the thieves guild.
				}
				else if ( root is BaseVendor && ((BaseVendor)root).IsInvulnerable )
				{
					m_Thief.SendLocalizedMessage( 1005598 ); // You can't steal from shopkeepers.
				}
				else if ( root is PlayerVendor )
				{
					m_Thief.SendLocalizedMessage( 502709 ); // You can't steal from vendors.
				}
				else if ( !m_Thief.CanSee( toSteal ) )
				{
					m_Thief.SendLocalizedMessage( 500237 ); // Target can not be seen.
				}
				else if ( toSteal.Parent == null || !toSteal.Movable || toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed( root ) )
				{
					m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
				}
				else if ( !m_Thief.InRange( toSteal.GetWorldLocation(), 1 ) )
				{
					m_Thief.SendLocalizedMessage( 502703 ); // You must be standing next to an item to steal it.
				}
				else if ( toSteal.Parent is Mobile )
				{
					m_Thief.SendLocalizedMessage( 1005585 ); // You cannot steal items which are equiped.
				}
				else if ( root == m_Thief )
				{
					m_Thief.SendLocalizedMessage( 502704 ); // You catch yourself red-handed.
				}
				else if ( root is Mobile && ((Mobile)root).AccessLevel > AccessLevel.Player )
				{
					m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
				}
				else if ( root is Mobile && !m_Thief.CanBeHarmful( (Mobile)root ) )
				{
					m_Thief.SendMessage("You can't steal from them.");
				}
				else
				{
					double w = toSteal.Weight + toSteal.TotalWeight;

					if ( w > 10 )
					{
						m_Thief.SendMessage( "That is too heavy to steal." );
					}
					else
					{
						if ( toSteal.Stackable && toSteal.Amount > 1 )
						{
							int minAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 25.0) / toSteal.Weight);
							int maxAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 10.0) / toSteal.Weight);

							if ( minAmount < 1 )
								minAmount = 1;

							if ( maxAmount < 1 )
								maxAmount = 1;
							else if ( maxAmount > toSteal.Amount )
								maxAmount = toSteal.Amount;

							int amount = Utility.RandomMinMax( minAmount, maxAmount );

							if ( amount >= toSteal.Amount )
							{
								int pileWeight = (int)Math.Ceiling( toSteal.Weight * toSteal.Amount );
								pileWeight *= 10;

								if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
									stolen = toSteal;
							}
							else
							{
								int pileWeight = (int)Math.Ceiling( toSteal.Weight * amount );
								pileWeight *= 10;

								if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
								{
									stolen = toSteal.Dupe( amount );
									toSteal.Amount -= amount;
								}
							}
						}
						else
						{
							int iw = (int)Math.Ceiling( w );
							iw *= 10;

							if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, iw - 22.5, iw + 27.5 ) )
								stolen = toSteal;
						}

						if ( stolen != null )
							m_Thief.SendLocalizedMessage( 502724 ); // You succesfully steal the item.
							if (m_Thief.Player == true)
							{
								((PlayerMobile)m_Thief).LastStoleAt = DateTime.Now;
							}
						if ( stolen == null ) //change from else to if - Pigpen						
							m_Thief.SendLocalizedMessage( 502723 ); // You fail to steal the item.
						
						caught = ( m_Thief.Skills[SkillName.Stealing].Value < Utility.Random( 150 ) );
					}
				}

				// wea: reset next skill time
				m_Thief.NextSkillTime = DateTime.Now + TimeSpan.FromSeconds(10.0);
                
				// adam: reset the LootType.Special to LootType.Regular 
				if (stolen != null && stolen.LootType == LootType.Special)
					stolen.LootType = LootType.Regular;

				return stolen;
			}