Beispiel #1
0
        /// <summary>
        /// Process when a player uses an item.
        /// </summary>
        /// <param name="player">The player who uses the item.</param>
        /// <param name="world">A reference to the gameworld.</param>
        private void ProcessUseItem(Player player, GameWorld world)
        {
            byte     itemType = netmsg.GetByte(); //1 = regular, 2 = usable with
            Position pos      = netmsg.GetPosition();
            ushort   itemID   = netmsg.GetU16();
            byte     stackpos = netmsg.GetByte();

            byte unknownByte = netmsg.GetByte(); //unknown?? TODO: Figure out

#if DEBUG
            Log.WriteDebug("In ProcessUseItem()");
            Log.WriteDebug("itemType: " + itemType);
            Log.WriteDebug("pos: " + pos);
            Log.WriteDebug("itemID: " + itemID);
            Log.WriteDebug("stackpos: " + stackpos);
            Log.WriteDebug("unknownbyte: " + unknownByte);
#endif

            if (itemType == Constants.ITEM_TYPE_USE)
            {
                world.HandleUseItem(player, itemType, pos, itemID, stackpos);
            }
            else if (itemType == Constants.ITEM_TYPE_USE_WITH)
            {
                Position posWith      = netmsg.GetPosition();
                ushort   spriteIDWith = netmsg.GetU16();
                byte     stackposWith = netmsg.GetByte();
#if DEBUG
                Log.WriteDebug("posWith: " + posWith);
                Log.WriteDebug("spriteid with: " + spriteIDWith);
                Log.WriteDebug("stackPos: " + stackposWith);
#endif
                world.HandleUseItemWith(player, itemType, pos, itemID,
                                        stackpos, posWith, stackposWith);
            }



            /*if (Item.CreateItem(itemID).IsOfType(Constants.TYPE_USEABLE_WITH)) {
             *  Position posWith = netmsg.GetPosition();
             *  world.SendPlayerUseItem(p, pos, itemID, stackpos, posWith);
             * } else {
             *  world.SendPlayerUseItem(p, pos, itemID, stackpos, null);
             * }*/
        }
Beispiel #2
0
 public void DoAction(GameWorld world)
 {
     world.HandleUseItem(player, itemType, pos, itemID, stackpos);
     player.CurrentDelayedAction = null;
 }
Beispiel #3
0
 public void DoAction(GameWorld world)
 {
     world.HandleUseItem(player, itemType, pos, itemID, stackpos);
     player.CurrentDelayedAction = null;
 }
Beispiel #4
0
        /// <summary>
        /// Process when a player uses an item.
        /// </summary>
        /// <param name="player">The player who uses the item.</param>
        /// <param name="world">A reference to the gameworld.</param>
        private void ProcessUseItem(Player player, GameWorld world)
        {
            byte itemType = netmsg.GetByte(); //1 = regular, 2 = usable with
            Position pos = netmsg.GetPosition();
            ushort itemID = netmsg.GetU16();
            byte stackpos = netmsg.GetByte();

            byte unknownByte = netmsg.GetByte(); //unknown?? TODO: Figure out

            #if DEBUG
            Log.WriteDebug("In ProcessUseItem()");
            Log.WriteDebug("itemType: " + itemType);
            Log.WriteDebug("pos: " + pos);
            Log.WriteDebug("itemID: " + itemID);
            Log.WriteDebug("stackpos: " + stackpos);
            Log.WriteDebug("unknownbyte: " + unknownByte);
            #endif

            if (itemType == Constants.ITEM_TYPE_USE) {
                world.HandleUseItem(player, itemType, pos, itemID, stackpos);
            } else if (itemType == Constants.ITEM_TYPE_USE_WITH) {
                Position posWith = netmsg.GetPosition();
                ushort spriteIDWith = netmsg.GetU16();
                byte stackposWith = netmsg.GetByte();
            #if DEBUG
                Log.WriteDebug("posWith: " + posWith);
                Log.WriteDebug("spriteid with: " + spriteIDWith);
                Log.WriteDebug("stackPos: " + stackposWith);

            #endif
                world.HandleUseItemWith(player, itemType, pos, itemID,
                    stackpos, posWith, stackposWith);
            }

            /*if (Item.CreateItem(itemID).IsOfType(Constants.TYPE_USEABLE_WITH)) {
                Position posWith = netmsg.GetPosition();
                world.SendPlayerUseItem(p, pos, itemID, stackpos, posWith);
            } else {
                world.SendPlayerUseItem(p, pos, itemID, stackpos, null);
            }*/
        }