예제 #1
0
        /// <summary>
        /// Handler for NPC_REPLY packet, when NPC takes damage from an attack (spell cast or weapon) but is still alive
        /// </summary>
        private void _handleNPCReply(OldPacket pkt)
        {
            if (OnNPCTakeDamage == null)
            {
                return;
            }

            short spellID = -1;

            if (pkt.Family == PacketFamily.Cast)
            {
                spellID = pkt.GetShort();
            }

            short       fromPlayerID  = pkt.GetShort();
            EODirection fromDirection = (EODirection)pkt.GetChar();
            short       npcIndex      = pkt.GetShort();
            int         damageToNPC   = pkt.GetThree();
            int         npcPctHealth  = pkt.GetShort();

            short fromTP = -1;

            if (pkt.Family == PacketFamily.Cast)
            {
                fromTP = pkt.GetShort();
            }
            else if (pkt.GetChar() != 1) //some constant 1 in EOSERV
            {
                return;
            }

            OnNPCTakeDamage((byte)npcIndex, fromPlayerID, fromDirection, damageToNPC, npcPctHealth, spellID, fromTP);
        }
예제 #2
0
        private void _handleItemDrop(OldPacket pkt)
        {
            if (OnDropItem == null)
            {
                return;
            }
            short      _id             = pkt.GetShort();
            int        _amount         = pkt.GetThree();
            int        characterAmount = pkt.GetInt(); //amount remaining for the character
            OldMapItem item            = new OldMapItem
            {
                ItemID   = _id,
                Amount   = _amount,
                UniqueID = pkt.GetShort(),
                X        = pkt.GetChar(),
                Y        = pkt.GetChar(),
                //turn off drop protection since main player dropped it
                DropTime       = DateTime.Now.AddSeconds(-5),
                IsNPCDrop      = false,
                OwningPlayerID = 0                                                    //id of 0 means the currently logged in player owns it
            };
            byte characterWeight = pkt.GetChar(), characterMaxWeight = pkt.GetChar(); //character adjusted weights

            OnDropItem(characterAmount, characterWeight, characterMaxWeight, item);
        }
예제 #3
0
 //potion effect (only known use based on eoserv code)
 private void _handleEffectPlayer(OldPacket pkt)
 {
     if (OnEffectPotion != null)
     {
         OnEffectPotion(playerID: pkt.GetShort(),
                        effectID: pkt.GetThree());
     }
 }
예제 #4
0
        /// <summary>
        /// Handles LOCKER_GET from server for taking an item from locker
        /// </summary>
        private void _handleLockerGet(OldPacket pkt)
        {
            if (OnLockerItemChange == null)
            {
                return;
            }

            short itemID    = pkt.GetShort();
            int   amount    = pkt.GetThree();
            byte  weight    = pkt.GetChar();
            byte  maxWeight = pkt.GetChar();

            List <InventoryItem> items = new List <InventoryItem>();

            while (pkt.ReadPos != pkt.Length)
            {
                items.Add(new InventoryItem(pkt.GetShort(), pkt.GetThree()));
            }

            OnLockerItemChange(itemID, amount, weight, maxWeight, true, items);
        }
예제 #5
0
        private void _handleItemKick(OldPacket pkt)
        {
            if (OnItemChange == null)
            {
                return;
            }

            short id     = pkt.GetShort();
            int   amount = pkt.GetThree();
            byte  weight = pkt.GetChar();

            OnItemChange(false, id, amount, weight);
        }
예제 #6
0
        private void _handleItemJunk(OldPacket pkt)
        {
            short id              = pkt.GetShort();
            int   amountRemoved   = pkt.GetThree();//don't really care - just math it
            int   amountRemaining = pkt.GetInt();
            byte  weight          = pkt.GetChar();
            byte  maxWeight       = pkt.GetChar();

            if (OnJunkItem != null)
            {
                OnJunkItem(id, amountRemoved, amountRemaining, weight, maxWeight);
            }
        }
예제 #7
0
        private void _handleItemGet(OldPacket pkt)
        {
            if (OnGetItemFromMap == null)
            {
                return;
            }
            short uid         = pkt.GetShort();
            short id          = pkt.GetShort();
            int   amountTaken = pkt.GetThree();
            byte  weight      = pkt.GetChar();
            byte  maxWeight   = pkt.GetChar();

            OnGetItemFromMap(uid, id, amountTaken, weight, maxWeight);
        }
예제 #8
0
        //sent to players around a player taking spike damage
        private void _handleEffectAdmin(OldPacket pkt)
        {
            if (OnOtherPlayerTakeSpikeDamage == null)
            {
                return;
            }

            short playerID            = pkt.GetShort();
            byte  playerPercentHealth = pkt.GetChar();
            bool  playerIsDead        = pkt.GetChar() != 0;
            int   damageAmount        = pkt.GetThree();

            OnOtherPlayerTakeSpikeDamage(playerID, playerPercentHealth, playerIsDead, damageAmount);
        }
예제 #9
0
        internal ChestData(OldPacket pkt, bool containsCoords)
            : this()
        {
            X = containsCoords ? pkt.GetChar() : byte.MinValue;
            Y = containsCoords ? pkt.GetChar() : byte.MinValue;

            var numRemaining = pkt.PeekEndString().Length / 5;

            _items = new List <InventoryItem>(numRemaining);
            for (var i = 0; i < numRemaining; ++i)
            {
                _items.Add(new InventoryItem(pkt.GetShort(), pkt.GetThree()));
            }
        }
예제 #10
0
        /// <summary>
        /// Handler for CHEST_GET packet, sent as confirmation to character that item is being taken
        /// </summary>
        private void _handleChestGet(OldPacket pkt)
        {
            if (OnChestGetItem == null)
            {
                return;
            }
            short     takenID            = pkt.GetShort();
            int       takenAmount        = pkt.GetThree();
            byte      characterWeight    = pkt.GetChar();
            byte      characterMaxWeight = pkt.GetChar();
            ChestData data = new ChestData(pkt, false);

            OnChestGetItem(takenID, takenAmount, characterWeight, characterMaxWeight, data);
        }
예제 #11
0
        /// <summary>
        /// Handles SHOP_OPEN from server, contains shop data for a shop dialog
        /// </summary>
        private void _handleShopOpen(OldPacket pkt)
        {
            if (OnShopOpen == null)
            {
                return;
            }

            int    shopKeeperID = pkt.GetShort();
            string shopName     = pkt.GetBreakString();

            List <ShopItem> tradeItems = new List <ShopItem>();

            while (pkt.PeekByte() != 255)
            {
                ShopItem nextItem = new ShopItem(pkt.GetShort(), pkt.GetThree(), pkt.GetThree(), pkt.GetChar());
                tradeItems.Add(nextItem);
            }
            pkt.GetByte();

            List <CraftItem> craftItems = new List <CraftItem>();

            while (pkt.PeekByte() != 255)
            {
                int ID = pkt.GetShort();
                List <Tuple <int, int> > ingreds = new List <Tuple <int, int> >();

                for (int i = 0; i < 4; ++i)
                {
                    ingreds.Add(new Tuple <int, int>(pkt.GetShort(), pkt.GetChar()));
                }
                craftItems.Add(new CraftItem(ID, ingreds));
            }
            pkt.GetByte();

            OnShopOpen(shopKeeperID, shopName, tradeItems, craftItems);
        }
예제 #12
0
        /// <summary>
        /// Handles LOCKER_OPEN from server for opening a locker
        /// </summary>
        private void _handleLockerOpen(OldPacket pkt)
        {
            if (OnLockerOpen == null)
            {
                return;
            }

            byte x = pkt.GetChar();
            byte y = pkt.GetChar();

            List <InventoryItem> items = new List <InventoryItem>();

            while (pkt.ReadPos != pkt.Length)
            {
                items.Add(new InventoryItem(pkt.GetShort(), pkt.GetThree()));
            }

            OnLockerOpen(x, y, items);
        }
예제 #13
0
        private void _handleItemAdd(OldPacket pkt)
        {
            if (OnDropItem == null)
            {
                return;
            }
            OldMapItem item = new OldMapItem
            {
                ItemID         = pkt.GetShort(),
                UniqueID       = pkt.GetShort(),
                Amount         = pkt.GetThree(),
                X              = pkt.GetChar(),
                Y              = pkt.GetChar(),
                DropTime       = DateTime.Now,
                IsNPCDrop      = false,
                OwningPlayerID = -1 //another player dropped. drop protection says "Item protected" w/o player name
            };

            OnDropItem(-1, 0, 0, item);
        }
예제 #14
0
        internal PaperdollEquipData(OldPacket pkt, bool itemUnequipped)
        {
            itemRemoved = itemUnequipped;

            itemID          = pkt.GetShort();
            characterAmount = itemUnequipped ? 1 : pkt.GetThree();
            subLoc          = pkt.GetChar();

            maxhp    = pkt.GetShort();
            maxtp    = pkt.GetShort();
            disp_str = pkt.GetShort();
            disp_int = pkt.GetShort();
            disp_wis = pkt.GetShort();
            disp_agi = pkt.GetShort();
            disp_con = pkt.GetShort();
            disp_cha = pkt.GetShort();
            mindam   = pkt.GetShort();
            maxdam   = pkt.GetShort();
            accuracy = pkt.GetShort();
            evade    = pkt.GetShort();
            armor    = pkt.GetShort();
        }
예제 #15
0
        /// <summary>
        /// Handles LOCKER_REPLY from server for adding an item to locker
        /// </summary>
        private void _handleLockerReply(OldPacket pkt)
        {
            if (OnLockerItemChange == null)
            {
                return;
            }
            //inventory info for amount remaining for character
            short itemID    = pkt.GetShort();
            int   amount    = pkt.GetInt();
            byte  weight    = pkt.GetChar();
            byte  maxWeight = pkt.GetChar();

            //items in the locker
            List <InventoryItem> items = new List <InventoryItem>();

            while (pkt.ReadPos != pkt.Length)
            {
                items.Add(new InventoryItem(pkt.GetShort(), pkt.GetThree()));
            }

            OnLockerItemChange(itemID, amount, weight, maxWeight, false, items);
        }