Example #1
0
        public static void MoveOnGround(int source, int amount, int x, int y, int z)
        {
            Assistant.Item item = Assistant.World.FindItem(source);

            if (item == null)
            {
                Scripts.SendMessageScriptError("Script Error: MoveOnGround: Source Item  not found");
                return;
            }

            Assistant.Point3D loc = Assistant.Point3D.MinusOne;
            if (x != -1 && y != -1)
            {
                loc = new Assistant.Point3D(x, y, z);
            }

            int amounttodrop = amount;

            if ((item.Amount < amount) || (amount == 0))
            {
                amounttodrop = item.Amount;
            }

            DragDropManager.HoldingItem = true;
            Assistant.ClientCommunication.SendToServerWait(new LiftRequest(item.Serial, amounttodrop));
            Thread.Sleep(80);
            Assistant.ClientCommunication.SendToServerWait(new DropRequest(item.Serial, loc, Assistant.Serial.MinusOne));
            DragDropManager.HoldingItem = false;
        }
Example #2
0
        public static void Move(int source, int destination, int amount, int x, int y)
        {
            Assistant.Item bag  = Assistant.World.FindItem(destination);
            Assistant.Item item = Assistant.World.FindItem(source);
            int            serialdestination = 0;

            if (item == null)
            {
                Scripts.SendMessageScriptError("Script Error: Move: Source Item  not found");
                return;
            }

            if (bag != null)
            {
                serialdestination = bag.Serial;
            }
            else
            {
                Assistant.Mobile mbag = Assistant.World.FindMobile(destination);
                if (mbag != null)
                {
                    serialdestination = mbag.Serial;
                }
            }

            if (serialdestination == 0)
            {
                Scripts.SendMessageScriptError("Script Error: Move: Destination not found");
                return;
            }

            Assistant.Point3D loc = Assistant.Point3D.MinusOne;
            if (x != -1 && y != -1)
            {
                loc = new Assistant.Point3D(x, y, 0);
            }

            if (amount == 0)
            {
                DragDropManager.HoldingItem = true;
                Assistant.ClientCommunication.SendToServerWait(new LiftRequest(item.Serial, item.Amount));
                Thread.Sleep(80);
                Assistant.ClientCommunication.SendToServerWait(new DropRequest(item.Serial, loc, serialdestination));
                DragDropManager.HoldingItem = false;
            }
            else
            {
                if (item.Amount < amount)
                {
                    amount = item.Amount;
                }
                DragDropManager.HoldingItem = true;
                Assistant.ClientCommunication.SendToServerWait(new LiftRequest(item.Serial, amount));
                Thread.Sleep(80);
                Assistant.ClientCommunication.SendToServerWait(new DropRequest(item.Serial, loc, serialdestination));
                DragDropManager.HoldingItem = false;
            }
        }
Example #3
0
 public static void Interrupt()
 {
     Assistant.Item item = FindUsedLayer();
     if (item != null)
     {
         Assistant.Point3D loc = Assistant.Point3D.MinusOne;
         Assistant.Client.Instance.SendToServerWait(new LiftRequest(item, 1));
         Assistant.Client.Instance.SendToServerWait(new EquipRequest(item.Serial, Assistant.World.Player, item.Layer));                 // Equippa
     }
 }
Example #4
0
        /// <summary>
        /// Execute target on specific land point with offset distance from Mobile. Distance is calculated by target Mobile.Direction.
        /// </summary>
        /// <param name="mobile">Mobile object to target.</param>
        /// <param name="offset">Distance from the target.</param>
        public static void TargetExecuteRelative(Mobile mobile, int offset)
        {
            Assistant.Point2D relpos = new Assistant.Point2D();
            switch (mobile.Direction)
            {
            case "North":
                relpos.X = mobile.Position.X;
                relpos.Y = mobile.Position.Y - offset;
                break;

            case "South":
                relpos.X = mobile.Position.X;
                relpos.Y = mobile.Position.Y + offset;
                break;

            case "West":
                relpos.X = mobile.Position.X - offset;
                relpos.Y = mobile.Position.Y;
                break;

            case "East":
                relpos.X = mobile.Position.X + offset;
                relpos.Y = mobile.Position.Y;
                break;

            case "Up":
                relpos.X = mobile.Position.X - offset;
                relpos.Y = mobile.Position.Y - offset;
                break;

            case "Down":
                relpos.X = mobile.Position.X + offset;
                relpos.Y = mobile.Position.Y + offset;
                break;

            case "Left":
                relpos.X = mobile.Position.X - offset;
                relpos.Y = mobile.Position.Y + offset;
                break;

            case "Right":
                relpos.X = mobile.Position.X + offset;
                relpos.Y = mobile.Position.Y - offset;
                break;
            }
            Assistant.Point3D location = new Assistant.Point3D(relpos.X, relpos.Y, Statics.GetLandZ(relpos.X, relpos.Y, Player.Map));
            Assistant.Targeting.Target(location, true);
        }
Example #5
0
		public static void Walk( string[] args )
		{
			Point3D loc = new Point3D( Point3D.Zero );

			try
			{
				loc.X = Utility.ToInt32( args[0], 0 );
				loc.Y = Utility.ToInt32( args[1], 0 );
				loc.Z = Utility.ToInt32( args[2], 0 );
				
				ClientCommunication.SendToClient( new PathFindTo( loc ) );
				World.Player.SendMessage( "Going... {0}", loc );
			}
			catch
			{
			}
		}
 private static void ContainerContentUpdate1(PacketReader p, PacketHandlerEventArgs args)
 {
     Serial serial = p.ReadUInt32();
     if (containers.ContainsKey(serial))
     {
         Item item = World.FindItem(serial);
         if (item == null || item.Deleted || item != containers[serial])
             args.Block = true;
         else
         {
             ushort itemID = (ushort)(p.ReadUInt16() + p.ReadSByte());
             ushort amount = p.ReadUInt16();
             if (amount == 0)
                 amount = 1;
             Point3D position = new Point3D(p.ReadUInt16(), p.ReadUInt16(), 0);
             p.ReadUInt32();
             ushort hue = p.ReadUInt16();
             args.Block = item.ItemID == itemID && item.Amount == amount && item.Position == position && item.Hue == hue;
         }
     }
 }
Example #7
0
        public static void MoveOnGround(int source, int amount, int x, int y, int z)
        {
            Assistant.Item item = Assistant.World.FindItem(source);

            if (item == null)
            {
                Scripts.SendMessageScriptError("Script Error: MoveOnGround: Source Item  not found");
                return;
            }

            Assistant.Point3D loc = new Assistant.Point3D(x, y, z);

            int amounttodrop = amount;

            if ((item.Amount < amount) || (amount == 0))
            {
                amounttodrop = item.Amount;
            }

            Assistant.DragDropManager.DragDrop(item, loc, amounttodrop);
            //Assistant.Client.Instance.SendToServerWait(new LiftRequest(item.Serial, amounttodrop));
            //Assistant.Client.Instance.SendToServerWait(new DropRequest(item.Serial, loc, Assistant.Serial.MinusOne));
        }
Example #8
0
        internal static List <Assistant.Point3D> CoordsToMobile(Assistant.Mobile mobile)
        {
            List <Assistant.Point3D> coords = new List <Assistant.Point3D>();

            Assistant.Point3D playerPosition = World.Player.Position;
            Assistant.Point3D mobPosition    = mobile.Position;

            // player is x0 mob is x1 in m = (y1?y0)/(x1?x0)
            float slope = (float)((float)mobPosition.Y - playerPosition.Y) / ((float)mobPosition.X - playerPosition.X);

            // for every x compute the y
            for (int x = Math.Min(playerPosition.X, mobPosition.X); x <= Math.Max(playerPosition.X, mobPosition.X); x++)
            {
                // formula for y is y = m* (x-x0) + y0
                if (x != playerPosition.X)
                {
                    int y = (int)(slope * ((float)x - playerPosition.X) + playerPosition.Y);
                    coords.Add(new Assistant.Point3D(x, y, Statics.GetLandZ(x, y, Player.Map)));
                }
            }

            // for every y compute the x
            for (int y = Math.Min(playerPosition.Y, mobPosition.Y); y <= Math.Max(playerPosition.Y, mobPosition.Y); y++)
            {
                // formula for x is  x = ((y?y0)/m) + x0
                if (y != playerPosition.Y)
                {
                    int x = (int)((((float)y - playerPosition.Y) / slope) + playerPosition.X);
                    coords.Add(new Assistant.Point3D(x, y, Statics.GetLandZ(x, y, Player.Map)));
                }
            }

            //coords.Add(new Assistant.Point3D(playerPosition.X, playerPosition.Y, Statics.GetLandZ(playerPosition.X, playerPosition.Y, Player.Map)));

            return(coords);
        }
Example #9
0
        /*public static void Move(int source, int destination, int amount, int x, int y)
         * {
         *      Assistant.Item bag = Assistant.World.FindItem(destination);
         *      Assistant.Item item = Assistant.World.FindItem(source);
         *      int serialdestination = 0;
         *
         *      if (item == null)
         *      {
         *              Scripts.SendMessageScriptError("Script Error: Move: Source Item  not found");
         *              return;
         *      }
         *
         *      if (bag != null)
         *      {
         *              serialdestination = bag.Serial;
         *      }
         *      else
         *      {
         *              Assistant.Mobile mbag = Assistant.World.FindMobile(destination);
         *              if (mbag != null)
         *              {
         *                      serialdestination = mbag.Serial;
         *              }
         *              else
         *              {
         *                      Scripts.SendMessageScriptError("Script Error: Move: Destination not found");
         *                      return;
         *              }
         *      }
         *
         *      Assistant.Point3D loc = Assistant.Point3D.MinusOne;
         *      if (x != -1 && y != -1)
         *              loc = new Assistant.Point3D(x, y, 0);
         *
         *      if (amount == 0)
         *      {
         *              Assistant.Client.Instance.SendToServerWait(new LiftRequest(item.Serial, item.Amount));
         *              Assistant.Client.Instance.SendToServerWait(new DropRequest(item.Serial, loc, serialdestination));
         *      }
         *      else
         *      {
         *              if (item.Amount < amount)
         *              {
         *                      amount = item.Amount;
         *              }
         *              Assistant.Client.Instance.SendToServerWait(new LiftRequest(item.Serial, amount));
         *              Assistant.Client.Instance.SendToServerWait(new DropRequest(item.Serial, loc, serialdestination));
         *      }
         * }*/

        public static void Move(int source, int destination, int amount, int x, int y)
        {
            Assistant.Item   bag  = Assistant.World.FindItem(destination);
            Assistant.Item   item = Assistant.World.FindItem(source);
            Assistant.Mobile mbag = null;

            int  serialdestination = 0;
            bool isMobile          = false;
            bool onLocation        = false;
            int  newamount         = 0;

            if (item == null)
            {
                Scripts.SendMessageScriptError("Script Error: Move: Source Item  not found");
                return;
            }

            if (bag != null)
            {
                serialdestination = bag.Serial;
            }
            else
            {
                mbag = Assistant.World.FindMobile(destination);
                if (mbag != null)
                {
                    isMobile          = true;
                    serialdestination = mbag.Serial;
                }
            }

            if (serialdestination == 0)
            {
                Scripts.SendMessageScriptError("Script Error: Move: Destination not found");
                return;
            }

            Assistant.Point3D loc = Assistant.Point3D.MinusOne;
            if (x != -1 && y != -1)
            {
                onLocation = true;
                loc        = new Assistant.Point3D(x, y, 0);
            }

            // calcolo amount
            if (amount == 0)
            {
                newamount = item.Amount;
            }
            else
            {
                if (item.Amount < amount)
                {
                    newamount = item.Amount;
                }
                else
                {
                    newamount = amount;
                }
            }

            if (isMobile)
            {
                Assistant.DragDropManager.DragDrop(item, newamount, mbag.Serial);
            }
            else if (onLocation)
            {
                Assistant.DragDropManager.DragDrop(item, newamount, bag, loc);
            }
            else
            {
                Assistant.DragDropManager.DragDrop(item, newamount, bag);
            }
        }
Example #10
0
 private void PromptGroundTargetExex_Callback(bool loc, Assistant.Serial serial, Assistant.Point3D pt, ushort itemid)
 {
     if (!loc)
     {
         Mobile target = Mobiles.FindBySerial(serial);
         if (target == null)
         {
             m_pgtarget = Point3D.MinusOne;
         }
         else
         {
             m_pgtarget = target.Position;
         }
     }
     else
     {
         m_pgtarget = new Point3D(pt.X, pt.Y, pt.Z);
     }
 }
Example #11
0
        private static void DropRequest( PacketReader p, PacketHandlerEventArgs args )
        {
            Serial iser = p.ReadUInt32();
            int x = p.ReadInt16();
            int y = p.ReadInt16();
            int z = p.ReadSByte();
            if ( Engine.UsePostKRPackets )
                /* grid num */p.ReadByte();
            Point3D newPos = new Point3D( x, y, z );
            Serial dser = p.ReadUInt32();

            if ( Macros.MacroManager.AcceptActions )
                MacroManager.Action( new DropAction( dser, newPos ) );

            Item i = World.FindItem( iser );
            if ( i == null )
                return;

            Item dest = World.FindItem( dser );
            if ( dest != null && dest.IsContainer && World.Player != null && ( dest.IsChildOf( World.Player.Backpack ) || dest.IsChildOf( World.Player.Quiver ) ) )
                i.IsNew = true;

            if ( Config.GetBool( "QueueActions" ) )
                args.Block = DragDropManager.Drop( i, dser, newPos );
        }
Example #12
0
        public static byte[] HandleRPVContainerContentUpdate( Packet p )
        {
            // This function will ignore the item if the container item has not been sent to the client yet.
            // We can do this because we can't really count on getting all of the container info anyway.
            // (So we'd need to request the container be updated, so why bother with the extra stuff required to find the container once its been sent?)
            bool isPostKR = false, decided = false;

            Serial serial = p.ReadUInt32();
            ushort itemid = p.ReadUInt16();
            itemid = (ushort)(itemid + p.ReadSByte()); // signed, itemID offset
            ushort amount = p.ReadUInt16();
            if ( amount == 0 )
                amount = 1;
            Point3D pos = new Point3D( p.ReadUInt16(), p.ReadUInt16(), 0 );
            byte gridPos = 0;
            if ( !decided )
            {
                byte nextByte = p.ReadByte();

                isPostKR = ( (nextByte & 0x40) == 0 );
                decided = true;

                if ( isPostKR == Engine.UsePostKRPackets )
                    return p.Compile(); // not need to change anything

                p.Seek( -1, SeekOrigin.Current );
            }

            if ( isPostKR )
                gridPos = p.ReadByte();

            Serial cser = p.ReadUInt32();
            ushort hue = p.ReadUInt16();

            Item i = World.FindItem( serial );
            if ( i == null  )
            {
                if ( !serial.IsItem )
                    return p.Compile();

                World.AddItem( i = new Item( serial ) );
                i.IsNew = i.AutoStack = true;
            }

            i.ItemID = itemid;
            i.Amount = amount;
            i.Position = pos;
            i.GridNum = gridPos;
            i.Hue = hue;
            i.Container = cser;

            if ( i.IsNew )
                Item.UpdateContainers();
            if ( !SearchExemptionAgent.IsExempt( i ) && ( i.IsChildOf( World.Player.Backpack ) || i.IsChildOf( World.Player.Quiver ) ) )
                Counter.Count( i );

            return new ContainerItem( i, Engine.UsePostKRPackets ).Compile();
        }
Example #13
0
 public DropRequest( Item item, Point3D pt, Serial destSer )
     : this(item.Serial, pt, destSer)
 {
 }
Example #14
0
 public PathFindTo( Point3D loc )
     : base(0x38, 7*20)
 {
     for(int i=0;i<20;i++)
     {
         if ( i != 0 )
             Write( (byte)0x38 );
         Write( (ushort)loc.X );
         Write( (ushort)loc.Y );
         Write( (short)loc.Z );
     }
 }
Example #15
0
 public virtual void OnPositionChanging(Point3D newPos)
 {
 }
Example #16
0
        private void OnAddTarget( bool location, Serial serial, Point3D loc, ushort gfx )
        {
            Engine.MainWindow.ShowMe();

            if ( !location && serial.IsMobile && serial != World.Player.Serial )
            {
                World.Player.SendMessage( MsgLevel.Force, LocString.FriendAdded );
                if ( !m_Chars.Contains( serial ) )
                {
                    m_Chars.Add( serial );

                    Add2List( serial );

                    Mobile m = World.FindMobile( serial );
                    if ( m != null )
                    {
                        m.ObjPropList.Add( Language.GetString( LocString.RazorFriend ) );
                        m.OPLChanged();
                    }
                }
            }
        }
Example #17
0
        private void OnTargetRemove( bool location, Serial serial, Point3D loc, ushort gfx )
        {
            Engine.MainWindow.ShowMe();
            if ( !location && serial.IsItem )
            {
                for(int i=0;i<m_Items.Count;i++)
                {
                    bool rem = false;
                    if ( m_Items[i] is Item )
                    {
                        if ( ((Item)m_Items[i]).Serial == serial )
                        {
                            ((Item)m_Items[i]).ObjPropList.Remove( Language.GetString( LocString.UseOnce ) );
                            ((Item)m_Items[i]).OPLChanged();

                            rem = true;
                        }
                    }
                    else if ( m_Items[i] is Serial )
                    {
                        if ( ((Serial)m_Items[i]) == serial )
                            rem = true;
                    }

                    if ( rem )
                    {
                        m_Items.RemoveAt( i );
                        m_SubList.Items.RemoveAt( i );
                        World.Player.SendMessage( MsgLevel.Force, LocString.ItemRemoved );
                        return;
                    }
                }

                World.Player.SendMessage( MsgLevel.Force, LocString.ItemNotFound );
            }
        }
Example #18
0
 internal EnhancedStaticInspector(Assistant.Point3D loc)
 {
     InitializeComponent();
     m_loc       = loc;
     MaximizeBox = false;
 }
Example #19
0
 public static void DragDrop( Item i, Point3D dest )
 {
     Drag( i, i.Amount );
     Drop( i, Serial.MinusOne, dest );
 }
Example #20
0
 public Point3D GetWorldPosition()
 {
     Assistant.Point3D     assistantPoint = m_AssistantItem.GetWorldPosition();
     RazorEnhanced.Point3D enhancedPoint  = new RazorEnhanced.Point3D(assistantPoint);
     return(enhancedPoint);
 }
Example #21
0
 public override void PathFindTo(Assistant.Point3D Location)
 {
     Assistant.Client.Instance.SendToClientWait(new PathFindTo(Location));
 }
Example #22
0
 public static void TargetExecute(int x, int y, int z, int gfx)
 {
     Assistant.Point3D location = new Assistant.Point3D(x, y, z);
     Assistant.Targeting.TargetByScript(location, gfx);
 }
Example #23
0
 public static bool Drop( Item i, Item to, Point3D pt )
 {
     return Drop( i, to == null ? Serial.MinusOne : to.Serial, pt );
 }
Example #24
0
 private static void FriendPlayerTarget_Callback(bool loc, Assistant.Serial serial, Assistant.Point3D pt, ushort itemid)
 {
     Assistant.Mobile friendplayer = World.FindMobile(serial);
     if (friendplayer != null && friendplayer.Serial.IsMobile && friendplayer.Serial != World.Player.Serial)
     {
         Engine.MainWindow.SafeAction(s => { Friend.AddPlayerToList(friendplayer.Name, friendplayer.Serial); });
     }
     else
     {
         if (Engine.MainWindow.ShowAgentMessageCheckBox.Checked)
         {
             Misc.SendMessage("Invalid target", false);
         }
         Friend.AddLog("Invalid target");
     }
 }
Example #25
0
        private void OnTargetBag( bool location, Serial serial, Point3D loc, ushort gfx )
        {
            Engine.MainWindow.ShowMe();
            if ( !location && serial.IsItem )
            {
                Item i = World.FindItem( serial );
                if ( i != null && i.Contains.Count > 0 )
                {
                    for ( int ci=0;ci<i.Contains.Count;ci++ )
                    {
                        Item toAdd = i.Contains[ci] as Item;

                        if ( toAdd != null )
                        {
                            toAdd.ObjPropList.Add( Language.GetString( LocString.UseOnce ) );
                            toAdd.OPLChanged();
                            m_Items.Add( toAdd );
                            m_SubList.Items.Add( toAdd );
                        }
                    }

                    World.Player.SendMessage( MsgLevel.Force, LocString.ItemsAdded, i.Contains.Count );
                }
            }
        }
Example #26
0
        private void OnHBTarget( bool location, Serial serial, Point3D loc, ushort gfx )
        {
            Engine.MainWindow.ShowMe();

            Item hb = World.FindItem( m_HotBag );
            if ( hb != null )
            {
                if ( hb.ObjPropList.Remove( Language.Format( LocString.RestockHBA1, m_Num ) ) )
                    hb.OPLChanged();
            }

            if ( !location && serial.IsItem )
                m_HotBag = serial;
            else
                m_HotBag = Serial.Zero;

            hb = World.FindItem( m_HotBag );
            if ( hb != null )
            {
                hb.ObjPropList.Add( Language.Format( LocString.RestockHBA1, m_Num ) );
                hb.OPLChanged();
            }

            SetHBText();
        }
Example #27
0
        private void OnTarget( bool location, Serial serial, Point3D loc, ushort gfx )
        {
            Engine.MainWindow.ShowMe();

            if ( !location && !serial.IsMobile )
            {
                if ( InputBox.Show( Engine.MainWindow, Language.GetString( LocString.EnterAmount ), Language.GetString( LocString.InputReq ) ) )
                {
                    ushort count = (ushort)InputBox.GetInt( 0 );
                    if ( count <= 0 )
                        return;
                    BuyEntry be = new BuyEntry( gfx, count );
                    m_Items.Add( be );
                    if ( m_SubList != null )
                        m_SubList.Items.Add( be );
                }
            }
        }
Example #28
0
        private void OnItemTarget( bool location, Serial serial, Point3D loc, ushort gfx )
        {
            if ( location || serial.IsMobile )
                return;

            Item item = World.FindItem( serial );
            if ( item != null )
                gfx = item.ItemID;

            if ( gfx == 0 || gfx >= 0x4000 )
                return;

            if ( !InputBox.Show( Engine.MainWindow, Language.GetString( LocString.EnterAmount ), Language.GetString( LocString.InputReq ), "1" ) )
                return;

            RestockItem ri = new RestockItem( gfx, InputBox.GetInt( 1 ) );
            m_Items.Add( ri );
            m_SubList.Items.Add( ri );

            World.Player.SendMessage( MsgLevel.Force, LocString.ItemAdded );

            Engine.MainWindow.ShowMe();
        }
Example #29
0
        private void OnRemoveTarget( bool location, Serial serial, Point3D loc, ushort gfx )
        {
            Engine.MainWindow.ShowMe();

            if ( !location && serial.IsMobile && serial != World.Player.Serial )
            {
                m_Chars.Remove( serial );
                m_Names.Remove( serial );

                World.Player.SendMessage( MsgLevel.Force, LocString.FriendRemoved );

                m_SubList.BeginUpdate();
                m_SubList.Items.Clear();
                for(int i=0;i<m_Chars.Count;i++)
                    Add2List( (Serial)m_Chars[i] );
                m_SubList.EndUpdate();

                Mobile m = World.FindMobile( serial );
                if ( m != null )
                {
                    if ( m.ObjPropList.Remove( Language.GetString( LocString.RazorFriend ) ) )
                        m.OPLChanged();
                }
            }
        }
Example #30
0
        private void OnRestockTarget( bool location, Serial serial, Point3D loc, ushort gfx )
        {
            if ( serial == World.Player.Serial )
            {
                m_Cont = World.Player.GetItemOnLayer( Layer.Bank );
            }
            else if ( serial.IsItem )
            {
                m_Cont = World.FindItem( serial );
                if ( m_Cont != null )
                {
                    object root = m_Cont.RootContainer ;
                    if ( root is Mobile && root != World.Player )
                        m_Cont = null;
                }
            }

            if ( m_Cont == null || m_Cont.IsCorpse )
            {
                World.Player.SendMessage( MsgLevel.Force, LocString.InvalidCont );
                return;
            }

            if ( Utility.Distance( World.Player.Position, m_Cont.GetWorldPosition() ) > 3 )
            {
                World.Player.SendMessage( MsgLevel.Error, LocString.TooFar );
            }
            else
            {
                if ( m_Cont.IsContainer && m_Cont.Layer != Layer.Bank )
                {
                    PlayerData.DoubleClick( m_Cont );
                    Timer.DelayedCallback( TimeSpan.FromMilliseconds( Config.GetInt( "ObjectDelay" ) + 200 ), new TimerCallback( DoRestock ) ).Start();
                    World.Player.SendMessage( LocString.RestockQueued );
                }
                else
                {
                    DoRestock();
                }
            }
        }
Example #31
0
        public static void TestRoute(int startx, int starty, int startz, int endx, int endy, int endz)
        {
            if (!m_loaded)
            {
                LoadTileLandData();
            }

            multidata = Assistant.World.Multis.Values.ToList();

            //Calcolo l'asse più lungo
            int xAxis    = Math.Abs(startx - endx);
            int yAxis    = Math.Abs(starty - endy);
            int range    = xAxis > yAxis ? xAxis + 20 : yAxis + 20;
            int gridSize = range * 2;
            Dictionary <int, int> coordsX = new Dictionary <int, int>();
            Dictionary <int, int> coordsY = new Dictionary <int, int>();
            Dictionary <int, int> coordsZ = new Dictionary <int, int>();

            //Crea la griglia 3D
            WorldGrid walkgrid = new WorldGrid(gridSize, gridSize, 256);

            Misc.SendMessage("Grid dim: " + gridSize + "x" + gridSize);

            int minx = startx > endx ? endx : startx;
            int maxx = startx > endx ? startx : endx;
            int miny = starty > endy ? starty : endy;
            int maxy = starty > endy ? endy : starty;

            Misc.SendMessage("Min x: " + minx + " Max x: " + maxx);
            Misc.SendMessage("Min y: " + miny + " Max y: " + maxy);

            int mediumXPoint = (startx + endx) / 2;
            int mediumYPoint = (starty + endy) / 2;

            for (int x = 0, xx = mediumXPoint - range; x < walkgrid.Right; x++, xx++)
            {
                coordsX.Add(x, xx);
            }
            for (int y = 0, yy = mediumYPoint - range; y < walkgrid.Top; y++, yy++)
            {
                coordsY.Add(y, yy);
            }
            for (int z = 0, zz = -127; z < walkgrid.Back; z++, zz++)
            {
                coordsZ.Add(z, zz);
            }

            //Riempie la griglia
            for (int x = 0, xx = mediumXPoint - range; x < walkgrid.Right; x++, xx++)
            {
                for (int y = 0, yy = mediumYPoint - range; y < walkgrid.Top; y++, yy++)
                {
                    //Controllo che non sia una casa
                    if (CheckHouse(xx, yy))
                    {
                        //Se in queste x-y c'è una casa, setta tutta la Z a False
                        for (int z = 0; z < walkgrid.Back; z++)
                        {
                            walkgrid.MarkPosition(new PathFinderAStar3D.Point3D(x, y, z), true);
                        }
                    }
                    else
                    {
                        Dictionary <int, bool> zResults = CheckStatic(xx, yy);

                        if (zResults.Count > 0)
                        {
                            //Se in queste x-y c'è roba statica, setta tutta la Z a False
                            for (int z = 0, zz = -127; z < walkgrid.Back; z++, zz++)
                            {
                                if (zResults.ContainsKey(zz))
                                {
                                    walkgrid.MarkPosition(new PathFinderAStar3D.Point3D(x, y, z), zResults[zz]);
                                }
                                else
                                {
                                    walkgrid.MarkPosition(new PathFinderAStar3D.Point3D(x, y, z), true);
                                }
                            }
                        }
                        else
                        {
                            //Se in queste x-y c'è roba statica, setta tutta la Z a False
                            for (int z = 0; z < walkgrid.Back; z++)
                            {
                                walkgrid.MarkPosition(new PathFinderAStar3D.Point3D(x, y, z), true);
                            }
                        }

                        zResults = CheckDynamic(xx, yy);

                        if (zResults.Count > 0)
                        {
                            //Se in queste x-y c'è roba statica, setta tutta la Z a False
                            for (int z = 0, zz = -127; z < walkgrid.Back; z++, zz++)
                            {
                                if (zResults.ContainsKey(zz))
                                {
                                    walkgrid.MarkPosition(new PathFinderAStar3D.Point3D(x, y, z), zResults[zz]);
                                }
                                else
                                {
                                    walkgrid.MarkPosition(new PathFinderAStar3D.Point3D(x, y, z), true);
                                }
                            }
                        }
                    }
                }
            }

            var StartX = coordsX.First(x => x.Value == startx).Key;
            var StartY = coordsY.First(y => y.Value == starty).Key;
            var StartZ = coordsZ.First(z => z.Value == startz).Key;

            PathFinderAStar3D.Point3D startPos = new PathFinderAStar3D.Point3D(StartX, StartY, StartZ);

            var EndX = coordsX.First(x => x.Value == endx).Key;
            var EndY = coordsY.First(y => y.Value == endy).Key;
            var EndZ = coordsZ.First(z => z.Value == endz).Key;

            PathFinderAStar3D.Point3D endPos = new PathFinderAStar3D.Point3D(EndX, EndY, EndZ);

            //Calcola il percorso
            SearchNode PathList = PathFinder.FindPath(walkgrid, startPos, endPos);

            Console.WriteLine("Posizione Corrente - X: " + PathList.position.X + " - Y:  " + PathList.position.Y);

            PathFinderAStar3D.Point3D oldstep = PathList.position;

            bool skippedMovement = false;

            while (PathList.next != null)
            {
                PathFinderAStar3D.Point3D step = PathList.next.position;

                int newStepX = step.X - oldstep.X;
                int newStepY = step.Y - oldstep.Y;


                for (int x = 0, xx = mediumXPoint - range; x < walkgrid.Right; x++, xx++)
                {
                    for (int y = 0, yy = mediumYPoint - range; y < walkgrid.Top; y++, yy++)
                    {
                        Dictionary <int, bool> zResult = CheckDynamic(xx, yy);
                        if (zResult.Count > 0)
                        {
                            //Se in queste x-y c'è roba statica, setta tutta la Z a False
                            for (int z = 0, zz = -127; z < walkgrid.Back; z++, zz++)
                            {
                                if (zResult.ContainsKey(zz))
                                {
                                    walkgrid.MarkPosition(new PathFinderAStar3D.Point3D(x, y, z), zResult[zz]);
                                }
                                else
                                {
                                    walkgrid.MarkPosition(new PathFinderAStar3D.Point3D(x, y, z), true);
                                }
                            }

                            PathList = PathFinder.FindPath(walkgrid, oldstep, endPos);
                        }
                    }
                }


                if (oldstep.X != step.X && oldstep.Y != step.Y && IsSurrounded(walkgrid, oldstep, newStepX, newStepY))
                {
                    //Movimento diagonale

                    Assistant.Point3D   pp2 = Assistant.World.Player.Position;
                    Assistant.Direction dd2 = Assistant.World.Player.Direction;

                    //SE
                    if (newStepX == 1 && newStepY == 1)
                    {
                        if (walkgrid.PositionIsFree(new PathFinderAStar3D.Point3D(oldstep.X + 1, oldstep.Y,
                                                                                  coordsZ.First(z => z.Value == World.Player.Position.Z).Key)))
                        {
                            Console.WriteLine("East e' libera!");

                            //Switcha la direzione
                            if (RazorEnhanced.Player.Direction != "East")
                            {
                                RazorEnhanced.Player.Walk("East");
                                while (RazorEnhanced.Player.Direction != "East")
                                {
                                    Misc.Pause(10);
                                }
                            }

                            //Si muove
                            RazorEnhanced.Player.Run("East");
                            while (pp2 == Assistant.World.Player.Position)
                            {
                                Misc.Pause(10);
                            }

                            //Reset della posizione corrente
                            pp2 = Assistant.World.Player.Position;

                            //Switcha la direzione
                            if (RazorEnhanced.Player.Direction != "South")
                            {
                                RazorEnhanced.Player.Walk("South");
                                while (RazorEnhanced.Player.Direction != "South")
                                {
                                    Misc.Pause(10);
                                }
                            }

                            //Si muove
                            RazorEnhanced.Player.Run("South");
                            while (pp2 == Assistant.World.Player.Position)
                            {
                                Misc.Pause(10);
                            }
                        }
                        else if (walkgrid.PositionIsFree(new PathFinderAStar3D.Point3D(oldstep.X, oldstep.Y + 1,
                                                                                       coordsZ.First(z => z.Value == World.Player.Position.Z).Key)))
                        {
                            Console.WriteLine("South e' libera!");

                            //Switcha la direzione
                            if (RazorEnhanced.Player.Direction != "South")
                            {
                                RazorEnhanced.Player.Walk("South");
                                while (RazorEnhanced.Player.Direction != "South")
                                {
                                    Misc.Pause(10);
                                }
                            }

                            //Si muove
                            RazorEnhanced.Player.Run("South");
                            while (pp2 == Assistant.World.Player.Position)
                            {
                                Misc.Pause(10);
                            }

                            //Reset della posizione corrente
                            pp2 = Assistant.World.Player.Position;

                            //Switcha la direzione
                            if (RazorEnhanced.Player.Direction != "East")
                            {
                                RazorEnhanced.Player.Walk("East");
                                while (RazorEnhanced.Player.Direction != "East")
                                {
                                    Misc.Pause(10);
                                }
                            }

                            //Si muove
                            RazorEnhanced.Player.Run("East");
                            while (pp2 == Assistant.World.Player.Position)
                            {
                                Misc.Pause(10);
                            }
                        }
                        else
                        {
                            walkgrid.MarkPosition(new PathFinderAStar3D.Point3D(step.X, step.Y, step.Z), true);
                            PathList        = PathFinder.FindPath(walkgrid, oldstep, endPos);
                            skippedMovement = true;
                        }
                    }
                    //NW
                    else if (newStepX == -1 && newStepY == -1)
                    {
                        if (
                            walkgrid.PositionIsFree(new PathFinderAStar3D.Point3D(oldstep.X - 1, oldstep.Y,
                                                                                  coordsZ.First(z => z.Value == World.Player.Position.Z).Key)))
                        {
                            Console.WriteLine("West e' libera!");

                            //Switcha la direzione
                            if (RazorEnhanced.Player.Direction != "West")
                            {
                                RazorEnhanced.Player.Walk("West");
                                while (RazorEnhanced.Player.Direction != "West")
                                {
                                    Misc.Pause(10);
                                }
                            }

                            //Si muove
                            RazorEnhanced.Player.Run("West");
                            while (pp2 == Assistant.World.Player.Position)
                            {
                                Misc.Pause(10);
                            }

                            //Reset della posizione corrente
                            pp2 = Assistant.World.Player.Position;

                            //Switcha la direzione
                            if (RazorEnhanced.Player.Direction != "North")
                            {
                                RazorEnhanced.Player.Walk("North");
                                while (RazorEnhanced.Player.Direction != "North")
                                {
                                    Misc.Pause(10);
                                }
                            }

                            //Si muove
                            RazorEnhanced.Player.Run("North");
                            while (pp2 == Assistant.World.Player.Position)
                            {
                                Misc.Pause(10);
                            }
                        }
                        else if (
                            walkgrid.PositionIsFree(new PathFinderAStar3D.Point3D(oldstep.X, oldstep.Y - 1,
                                                                                  coordsZ.First(z => z.Value == World.Player.Position.Z).Key)))
                        {
                            Console.WriteLine("North e' libera!");

                            //Switcha la direzione
                            if (RazorEnhanced.Player.Direction != "North")
                            {
                                RazorEnhanced.Player.Walk("North");
                                while (RazorEnhanced.Player.Direction != "North")
                                {
                                    Misc.Pause(10);
                                }
                            }

                            //Si muove
                            RazorEnhanced.Player.Run("North");
                            while (pp2 == Assistant.World.Player.Position)
                            {
                                Misc.Pause(10);
                            }

                            //Reset della posizione corrente
                            pp2 = Assistant.World.Player.Position;

                            //Switcha la direzione
                            if (RazorEnhanced.Player.Direction != "West")
                            {
                                RazorEnhanced.Player.Walk("West");
                                while (RazorEnhanced.Player.Direction != "West")
                                {
                                    Misc.Pause(10);
                                }
                            }

                            //Si muove
                            RazorEnhanced.Player.Run("West");
                            while (pp2 == Assistant.World.Player.Position)
                            {
                                Misc.Pause(10);
                            }
                        }
                        else
                        {
                            walkgrid.MarkPosition(new PathFinderAStar3D.Point3D(step.X, step.Y, step.Z), true);
                            PathList        = PathFinder.FindPath(walkgrid, oldstep, endPos);
                            skippedMovement = true;
                        }
                    }
                    //NE
                    else if (newStepX == 1 && newStepY == -1)
                    {
                        if (
                            walkgrid.PositionIsFree(new PathFinderAStar3D.Point3D(oldstep.X + 1, oldstep.Y,
                                                                                  coordsZ.First(z => z.Value == World.Player.Position.Z).Key)))
                        {
                            Console.WriteLine("East e' libera!");

                            //Switcha la direzione
                            if (RazorEnhanced.Player.Direction != "East")
                            {
                                RazorEnhanced.Player.Walk("East");
                                while (RazorEnhanced.Player.Direction != "East")
                                {
                                    Misc.Pause(10);
                                }
                            }

                            //Si muove
                            RazorEnhanced.Player.Run("East");
                            while (pp2 == Assistant.World.Player.Position)
                            {
                                Misc.Pause(10);
                            }

                            //Reset della posizione corrente
                            pp2 = Assistant.World.Player.Position;

                            //Switcha la direzione
                            if (RazorEnhanced.Player.Direction != "North")
                            {
                                RazorEnhanced.Player.Walk("North");
                                while (RazorEnhanced.Player.Direction != "North")
                                {
                                    Misc.Pause(10);
                                }
                            }

                            //Si muove
                            RazorEnhanced.Player.Run("North");
                            while (pp2 == Assistant.World.Player.Position)
                            {
                                Misc.Pause(10);
                            }
                        }
                        else if (
                            walkgrid.PositionIsFree(new PathFinderAStar3D.Point3D(oldstep.X, oldstep.Y - 1,
                                                                                  coordsZ.First(z => z.Value == World.Player.Position.Z).Key)))
                        {
                            Console.WriteLine("North e' libera!");

                            //Switcha la direzione
                            if (RazorEnhanced.Player.Direction != "North")
                            {
                                RazorEnhanced.Player.Walk("North");
                                while (RazorEnhanced.Player.Direction != "North")
                                {
                                    Misc.Pause(10);
                                }
                            }

                            //Si muove
                            RazorEnhanced.Player.Run("North");
                            while (pp2 == Assistant.World.Player.Position)
                            {
                                Misc.Pause(10);
                            }

                            //Reset della posizione corrente
                            pp2 = Assistant.World.Player.Position;

                            //Switcha la direzione
                            if (RazorEnhanced.Player.Direction != "East")
                            {
                                RazorEnhanced.Player.Walk("East");
                                while (RazorEnhanced.Player.Direction != "East")
                                {
                                    Misc.Pause(10);
                                }
                            }

                            //Si muove
                            RazorEnhanced.Player.Run("East");
                            while (pp2 == Assistant.World.Player.Position)
                            {
                                Misc.Pause(10);
                            }
                        }
                        else
                        {
                            walkgrid.MarkPosition(new PathFinderAStar3D.Point3D(step.X, step.Y, step.Z), true);
                            PathList        = PathFinder.FindPath(walkgrid, oldstep, endPos);
                            skippedMovement = true;
                        }
                    }
                    //SW
                    else if (newStepX == -1 && newStepY == 1)
                    {
                        if (
                            walkgrid.PositionIsFree(new PathFinderAStar3D.Point3D(oldstep.X - 1, oldstep.Y,
                                                                                  coordsZ.First(z => z.Value == World.Player.Position.Z).Key)))
                        {
                            Console.WriteLine("West e' libera!");

                            //Switcha la direzione
                            if (RazorEnhanced.Player.Direction != "West")
                            {
                                RazorEnhanced.Player.Walk("West");
                                while (RazorEnhanced.Player.Direction != "West")
                                {
                                    Misc.Pause(10);
                                }
                            }

                            //Si muove
                            RazorEnhanced.Player.Run("West");
                            while (pp2 == Assistant.World.Player.Position)
                            {
                                Misc.Pause(10);
                            }

                            //Reset della posizione corrente
                            pp2 = Assistant.World.Player.Position;

                            //Switcha la direzione
                            if (RazorEnhanced.Player.Direction != "South")
                            {
                                RazorEnhanced.Player.Walk("South");
                                while (RazorEnhanced.Player.Direction != "South")
                                {
                                    Misc.Pause(10);
                                }
                            }

                            //Si muove
                            RazorEnhanced.Player.Run("South");
                            while (pp2 == Assistant.World.Player.Position)
                            {
                                Misc.Pause(10);
                            }
                        }
                        else if (
                            walkgrid.PositionIsFree(new PathFinderAStar3D.Point3D(oldstep.X, oldstep.Y + 1,
                                                                                  coordsZ.First(z => z.Value == World.Player.Position.Z).Key)))
                        {
                            Console.WriteLine("South e' libera!");

                            //Switcha la direzione
                            if (RazorEnhanced.Player.Direction != "South")
                            {
                                RazorEnhanced.Player.Walk("South");
                                while (RazorEnhanced.Player.Direction != "South")
                                {
                                    Misc.Pause(10);
                                }
                            }

                            //Si muove
                            RazorEnhanced.Player.Run("South");
                            while (pp2 == Assistant.World.Player.Position)
                            {
                                Misc.Pause(10);
                            }

                            //Reset della posizione corrente
                            pp2 = Assistant.World.Player.Position;

                            //Switcha la direzione
                            if (RazorEnhanced.Player.Direction != "West")
                            {
                                RazorEnhanced.Player.Walk("West");
                                while (RazorEnhanced.Player.Direction != "West")
                                {
                                    Misc.Pause(10);
                                }
                            }

                            //Si muove
                            RazorEnhanced.Player.Run("West");
                            while (pp2 == Assistant.World.Player.Position)
                            {
                                Misc.Pause(10);
                            }
                        }
                        else
                        {
                            walkgrid.MarkPosition(new PathFinderAStar3D.Point3D(step.X, step.Y, step.Z), true);
                            PathList        = PathFinder.FindPath(walkgrid, oldstep, endPos);
                            skippedMovement = true;
                        }
                    }
                    else
                    {
                        int xx1 = step.X - oldstep.X;
                        int yy1 = step.Y - oldstep.Y;
                        Assistant.Point3D oldplayerpos = Assistant.World.Player.Position;

                        while (Assistant.World.Player.Position.X != oldplayerpos.X + xx1 ||
                               Assistant.World.Player.Position.Y != oldplayerpos.Y + yy1)
                        {
                            pp2 = Assistant.World.Player.Position;
                            dd2 = Assistant.World.Player.Direction;

                            if (xx1 <= -1 && yy1 <= -1)
                            {
                                RazorEnhanced.Player.Run("Up");
                            }
                            else if (xx1 <= -1 && yy1 == 0)
                            {
                                RazorEnhanced.Player.Run("West");
                            }
                            else if (xx1 <= -1 && yy1 >= 1)
                            {
                                RazorEnhanced.Player.Run("Left");
                            }
                            else if (xx1 == 0 && yy1 >= 1)
                            {
                                RazorEnhanced.Player.Run("South");
                            }
                            else if (xx1 >= 1 && yy1 >= 1)
                            {
                                RazorEnhanced.Player.Run("Down");
                            }
                            else if (xx1 >= 1 && yy1 == 0)
                            {
                                RazorEnhanced.Player.Run("East");
                            }
                            else if (xx1 >= 1 && yy1 <= -1)
                            {
                                RazorEnhanced.Player.Run("Right");
                            }
                            else if (xx1 == 0 && yy1 <= -1)
                            {
                                RazorEnhanced.Player.Run("North");
                            }

                            while (pp2 == Assistant.World.Player.Position && dd2 == Assistant.World.Player.Direction)
                            {
                                Misc.Pause(10);
                            }
                        }
                    }
                }
                else
                {
                    int xx1 = step.X - oldstep.X;
                    int yy1 = step.Y - oldstep.Y;
                    Assistant.Point3D oldplayerpos = Assistant.World.Player.Position;

                    while (Assistant.World.Player.Position.X != oldplayerpos.X + xx1 ||
                           Assistant.World.Player.Position.Y != oldplayerpos.Y + yy1)
                    {
                        Assistant.Point3D   pp2 = Assistant.World.Player.Position;
                        Assistant.Direction dd2 = Assistant.World.Player.Direction;

                        if (xx1 <= -1 && yy1 <= -1)
                        {
                            RazorEnhanced.Player.Run("Up");
                        }
                        else if (xx1 <= -1 && yy1 == 0)
                        {
                            RazorEnhanced.Player.Run("West");
                        }
                        else if (xx1 <= -1 && yy1 >= 1)
                        {
                            RazorEnhanced.Player.Run("Left");
                        }
                        else if (xx1 == 0 && yy1 >= 1)
                        {
                            RazorEnhanced.Player.Run("South");
                        }
                        else if (xx1 >= 1 && yy1 >= 1)
                        {
                            RazorEnhanced.Player.Run("Down");
                        }
                        else if (xx1 >= 1 && yy1 == 0)
                        {
                            RazorEnhanced.Player.Run("East");
                        }
                        else if (xx1 >= 1 && yy1 <= -1)
                        {
                            RazorEnhanced.Player.Run("Right");
                        }
                        else if (xx1 == 0 && yy1 <= -1)
                        {
                            RazorEnhanced.Player.Run("North");
                        }

                        while (pp2 == Assistant.World.Player.Position && dd2 == Assistant.World.Player.Direction)
                        {
                            Misc.Pause(10);
                        }
                    }
                }

                Console.WriteLine("Prossimo Step - X: " + step.X + " - Y:  " + step.Y);

                if (!skippedMovement)
                {
                    oldstep  = step;
                    PathList = PathList.next;
                }
                else
                {
                    skippedMovement = false;
                }

                //Controllo se è cambiato il multidata
                if (multidata != Assistant.World.Multis.Values.ToList())
                {
                    multidata = Assistant.World.Multis.Values.ToList();

                    for (int x = 0, xx = mediumXPoint - range; x < walkgrid.Right; x++, xx++)
                    {
                        for (int y = 0, yy = mediumYPoint - range; y < walkgrid.Top; y++, yy++)
                        {
                            //Controllo che non sia una casa
                            if (CheckHouse(xx, yy))
                            {
                                //Se in queste x-y c'è una casa, setta tutta la Z a False
                                for (int z = 0; z < walkgrid.Back; z++)
                                {
                                    walkgrid.MarkPosition(new PathFinderAStar3D.Point3D(x, y, z), true);
                                }
                            }
                        }
                    }

                    PathList = PathFinder.FindPath(walkgrid, oldstep, endPos);
                }
            }


            Console.WriteLine("Posizione Finale - X: " + PathList.position.X + " - Y:  " + PathList.position.Y);
        }
Example #32
0
        private void OnTarget( bool location, Serial serial, Point3D loc, ushort gfx )
        {
            Engine.MainWindow.ShowMe();

            if ( location || !serial.IsItem )
                return;

            Item item = World.FindItem( serial );
            if ( item == null )
                return;

            m_Items.Add( item.ItemID );
            m_SubList.Items.Add( item.ItemID );

            DebugLog( "Added item {0}", item );

            World.Player.SendMessage( MsgLevel.Force, LocString.ItemAdded );
        }
Example #33
0
        public DropRequest( Serial item, Point3D pt, Serial dest )
            : base(0x08, 14)
        {
            if ( Engine.UsePostKRPackets )
                EnsureCapacity( 15 );

            Write( item );
            Write( (ushort)pt.X );
            Write( (ushort)pt.Y );
            Write( (sbyte)pt.Z );
            if ( Engine.UsePostKRPackets )
                Write( (byte)0 );
            Write( dest );
        }
Example #34
0
        private void OnTargetBag( bool location, Serial serial, Point3D loc, ushort gfx )
        {
            Engine.MainWindow.ShowMe();

            if ( location || !serial.IsItem )
                return;

            if ( m_BagRef == null )
                m_BagRef = World.FindItem( m_Bag );
            if ( m_BagRef != null )
            {
                m_BagRef.ObjPropList.Remove( Language.GetString( LocString.ScavengerHB ) );
                m_BagRef.OPLChanged();
            }

            DebugLog( "Set bag to {0}", serial );
            m_Bag = serial;
            m_BagRef = World.FindItem( m_Bag );
            if ( m_BagRef != null )
            {
                m_BagRef.ObjPropList.Add( Language.GetString( LocString.ScavengerHB ) );
                m_BagRef.OPLChanged();
            }

            World.Player.SendMessage( MsgLevel.Force, LocString.ContSet, m_Bag );
        }
Example #35
0
        private static void MobileIncoming( Packet p, PacketHandlerEventArgs args )
        {
            if ( World.Player == null )
                return;

            Serial serial = p.ReadUInt32();
            ushort body =  p.ReadUInt16();
            Point3D position = new Point3D( p.ReadUInt16(), p.ReadUInt16(), p.ReadSByte() );

            if ( World.Player.Position != Point3D.Zero && !Utility.InRange( World.Player.Position, position, World.Player.VisRange ) )
                return;

            Mobile m = World.FindMobile( serial );
            if ( m == null )
                World.AddMobile( m = new Mobile( serial ) );

            bool wasHidden = !m.Visible;

            if ( m != World.Player && Config.GetBool( "ShowMobNames" ) )
                ClientCommunication.SendToServer( new SingleClick( m ) );
            if ( Config.GetBool( "LastTargTextFlags" ) )
                Targeting.CheckTextFlags( m );

            int ltHue = Config.GetInt( "LTHilight" );
            bool isLT;
            if ( ltHue != 0 )
                isLT = Targeting.IsLastTarget( m );
            else
                isLT = false;

            m.Body = body;
            if ( m != World.Player || World.Player.OutstandingMoveReqs == 0 )
                m.Position = position;
            m.Direction = (Direction)p.ReadByte();
            m.Hue = p.ReadUInt16();
            if ( isLT )
            {
                p.Seek( -2, SeekOrigin.Current );
                p.Write( (short)(ltHue|0x8000) );
            }

            bool wasPoisoned = m.Poisoned;
            m.ProcessPacketFlags( p.ReadByte() );
            byte oldNoto = m.Notoriety;
            m.Notoriety = p.ReadByte();

            if ( m == World.Player )
            {
                ClientCommunication.BeginCalibratePosition();

                if ( !wasHidden && !m.Visible )
                {
                    if ( Config.GetBool( "AlwaysStealth" ) )
                        StealthSteps.Hide();
                }
                else if ( wasHidden && m.Visible )
                {
                    StealthSteps.Unhide();
                }

                if ( wasPoisoned != m.Poisoned || ( oldNoto != m.Notoriety && Config.GetBool( "ShowNotoHue" ) ) )
                    ClientCommunication.RequestTitlebarUpdate();
            }

            while ( true )
            {
                serial = p.ReadUInt32();
                if ( !serial.IsItem )
                    break;

                Item item = World.FindItem( serial );
                bool isNew = false;
                if ( item == null )
                {
                    isNew = true;
                    World.AddItem( item = new Item( serial ) );
                }

                if ( !DragDropManager.EndHolding( serial ) )
                    continue;

                item.Container = m;

                ushort id = p.ReadUInt16();

                if (Engine.UseNewMobileIncoming)
                    item.ItemID = (ushort)(id & 0xFFFF);
                else if (Engine.UsePostSAChanges)
                    item.ItemID = (ushort)(id & 0x7FFF);
                else
                    item.ItemID = (ushort)(id & 0x3FFF);

                item.Layer = (Layer)p.ReadByte();

                if (Engine.UseNewMobileIncoming)
                {
                    item.Hue = p.ReadUInt16();
                    if (isLT)
                    {
                        p.Seek(-2, SeekOrigin.Current);
                        p.Write((short)(ltHue & 0x3FFF));
                    }
                }
                else
                {
                    if ((id & 0x8000) != 0)
                    {
                        item.Hue = p.ReadUInt16();
                        if (isLT)
                        {
                            p.Seek(-2, SeekOrigin.Current);
                            p.Write((short)(ltHue & 0x3FFF));
                        }
                    }
                    else
                    {
                        item.Hue = 0;
                        if (isLT)
                            ClientCommunication.SendToClient(new EquipmentItem(item, (ushort)(ltHue & 0x3FFF), m.Serial));
                    }
                }

                if ( item.Layer == Layer.Backpack && isNew && Config.GetBool( "AutoSearch" ) && m == World.Player && m != null )
                {
                    m_IgnoreGumps.Add( item );
                    PlayerData.DoubleClick( item );
                }
            }

            Item.UpdateContainers();
        }
Example #36
0
        private void OnTarget( bool location, Serial serial, Point3D loc, ushort gfx )
        {
            Engine.MainWindow.ShowMe();
            if ( !location && serial.IsItem )
            {
                m_Items.Add( serial );

                Item item = World.FindItem( serial );
                if ( item != null )
                {
                    ClientCommunication.SendToClient( new ContainerItem( item ) );
                    m_SubList.Items.Add( item.ToString() );
                }
                else
                {
                    m_SubList.Items.Add( serial.ToString() );
                }

                World.Player.SendMessage( MsgLevel.Force, LocString.ItemAdded );
            }
        }
Example #37
0
        private static void ContainerContentUpdate( Packet p, PacketHandlerEventArgs args )
        {
            // This function will ignore the item if the container item has not been sent to the client yet.
            // We can do this because we can't really count on getting all of the container info anyway.
            // (So we'd need to request the container be updated, so why bother with the extra stuff required to find the container once its been sent?)
            Serial serial = p.ReadUInt32();
            ushort itemid = p.ReadUInt16();
            itemid = (ushort)(itemid + p.ReadSByte()); // signed, itemID offset
            ushort amount = p.ReadUInt16();
            if ( amount == 0 )
                amount = 1;
            Point3D pos = new Point3D( p.ReadUInt16(), p.ReadUInt16(), 0 );
            byte gridPos = 0;
            if ( Engine.UsePostKRPackets )
                gridPos = p.ReadByte();
            Serial cser = p.ReadUInt32();
            ushort hue = p.ReadUInt16();

            Item i = World.FindItem( serial );
            if ( i == null  )
            {
                if ( !serial.IsItem )
                    return;

                World.AddItem( i = new Item( serial ) );
                i.IsNew = i.AutoStack = true;
            }
            else
            {
                i.CancelRemove();
            }

            if ( serial != DragDropManager.Pending )
            {
                if ( !DragDropManager.EndHolding( serial ) )
                    return;
            }

            i.ItemID = itemid;
            i.Amount = amount;
            i.Position = pos;
            i.GridNum = gridPos;
            i.Hue = hue;

            if ( SearchExemptionAgent.Contains( i ) )
            {
                p.Seek( -2, System.IO.SeekOrigin.Current );
                p.Write( (short)Config.GetInt( "ExemptColor" ) );
            }

            i.Container = cser;
            if ( i.IsNew )
                Item.UpdateContainers();
            if ( !SearchExemptionAgent.IsExempt( i ) && ( i.IsChildOf( World.Player.Backpack ) || i.IsChildOf( World.Player.Quiver ) ) )
                Counter.Count( i );
        }
Example #38
0
        private void OnTargetRemove( bool location, Serial serial, Point3D loc, ushort gfx )
        {
            Engine.MainWindow.ShowMe();
            if ( !location && serial.IsItem )
            {
                for(int i=0;i<m_Items.Count;i++)
                {
                    if ( m_Items[i] is Serial && (Serial)m_Items[i] == serial )
                    {
                        m_Items.RemoveAt( i );
                        m_SubList.Items.RemoveAt( i );
                        World.Player.SendMessage( MsgLevel.Force, LocString.ItemRemoved );

                        Item item = World.FindItem( serial );
                        if ( item != null )
                            ClientCommunication.SendToClient( new ContainerItem( item ) );
                        return;
                    }
                }

                World.Player.SendMessage( MsgLevel.Force, LocString.ItemNotFound );
            }
        }
Example #39
0
 private void PromptTargetExex_Callback(bool loc, Assistant.Serial serial, Assistant.Point3D pt, ushort itemid)
 {
     m_ptarget = serial;
 }
Example #40
0
        private void OnTargetType( bool location, Serial serial, Point3D loc, ushort gfx )
        {
            Engine.MainWindow.ShowMe();

            if ( !serial.IsItem ) return;

            m_Items.Add( (ItemID)gfx );
            m_SubList.Items.Add( ((ItemID)gfx).ToString() );
            World.Player.SendMessage( MsgLevel.Force, LocString.ItemAdded );
        }
Example #41
0
 public static void TargetExecute(int x, int y, int z)
 {
     Assistant.Point3D location = new Assistant.Point3D(x, y, z);
     Assistant.Targeting.Target(location, true);
 }
Example #42
0
        private void OnHBTarget( bool location, Serial serial, Point3D loc, ushort gfx )
        {
            Engine.MainWindow.ShowMe();
            if ( !location && serial.IsItem )
            {
                m_HotBag = serial;
                SetHBText();

                Item hb = World.FindItem( m_HotBag );
                if ( hb != null )
                {
                    hb.ObjPropList.Add( Language.GetString( LocString.SellHB ) );
                    hb.OPLChanged();
                }
            }
        }
Example #43
0
 private static void OnCommand(bool location, Serial serial, Point3D p, ushort gfxid)
 {
     new StatusBar(serial == World.Player.Serial || !serial.IsValid || !serial.IsMobile ? Serial.MinusOne : serial).Show();
 }
Example #44
0
 private void OnTarget( bool location, Serial serial, Point3D loc, ushort gfx )
 {
     Engine.MainWindow.ShowMe();
     if ( !location && serial.IsItem )
     {
         m_Items.Add( gfx );
         m_SubList.Items.Add( (ItemID)gfx );
     }
 }
Example #45
0
        public static bool Drop( Item i, Serial dest, Point3D pt )
        {
            if ( m_Pending == i.Serial )
            {
                Log( "Dropping {0} to {1} (@{2})", i, dest, pt );

                ClientCommunication.SendToServer( new DropRequest( i.Serial, pt, dest ) );
                m_Pending = Serial.Zero;
                m_Lifted = DateTime.MinValue;
                return true;
            }
            else
            {
                bool add = false;

                for(byte j=m_Front;j!=m_Back && !add;j++)
                {
                    if ( m_LiftReqs[j] != null && m_LiftReqs[j].Serial == i.Serial )
                    {
                        add = true;
                        break;
                    }
                }

                if ( add )
                {
                    Log( "Queuing Drop {0} (to {1} (@{2}))", i, dest, pt );

                    Queue q = m_DropReqs[i.Serial] as Queue;
                    if ( q == null )
                        m_DropReqs[i.Serial] = q = new Queue();
                    q.Enqueue( new DropReq( dest, pt ) );
                    return true;
                }
                else
                {
                    Log( "Drop for {0} (to {1} (@{2})) not found, skipped", i, dest, pt );
                    return false;
                }
            }
        }
Example #46
0
        private void OnTarget( bool location, Serial serial, Point3D loc, ushort gfx )
        {
            if ( Config.GetBool("AlwaysOnTop") )
                Engine.MainWindow.ShowMe();

            if ( !location && serial.IsItem )
            {
                Item item = World.FindItem( serial );
                if ( item == null )
                {
                    World.Player.SendMessage( MsgLevel.Force, LocString.ItemNotFound );
                    return;
                }

                item.ObjPropList.Add( Language.GetString( LocString.UseOnce ) );
                item.OPLChanged();

                m_Items.Add( item );
                if ( m_SubList != null )
                    m_SubList.Items.Add( item );

                World.Player.SendMessage( MsgLevel.Force, LocString.ItemAdded );
            }
        }
Example #47
0
 public DropReq( Serial s, Point3D pt )
 {
     Serial = s; Point = pt;
 }
Example #48
0
 public DropRequest(Item item, Point3D pt, Serial destSer) : this(item.Serial, pt, destSer)
 {
 }