Esempio n. 1
0
        private void _handleSpellTargetOther(OldPacket pkt)
        {
            if (OnCastSpellTargetOther == null)
            {
                return;
            }

            short       targetPlayerID        = pkt.GetShort();
            short       sourcePlayerID        = pkt.GetShort();
            EODirection sourcePlayerDirection = (EODirection)pkt.GetChar();
            short       spellID             = pkt.GetShort();
            int         recoveredHP         = pkt.GetInt();
            byte        targetPercentHealth = pkt.GetChar();

            short targetPlayerCurrentHP = -1;

            if (pkt.ReadPos != pkt.Length) //include current hp for player if main player is the target
            {
                targetPlayerCurrentHP = pkt.GetShort();
            }

            OnCastSpellTargetOther(
                targetPlayerID,
                sourcePlayerID,
                sourcePlayerDirection,
                spellID,
                recoveredHP,
                targetPercentHealth,
                targetPlayerCurrentHP);
        }
Esempio n. 2
0
        /// <summary>
        /// Handles SHOP_CREATE from server, response to crafting an item
        /// </summary>
        private void _handleShopCreate(OldPacket pkt)
        {
            if (OnShopCraftItem == null)
            {
                return;
            }

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

            List <InventoryItem> inventoryItems = new List <InventoryItem>(4);

            while (pkt.ReadPos != pkt.Length)
            {
                if (pkt.PeekShort() <= 0)
                {
                    break;
                }

                inventoryItems.Add(new InventoryItem(pkt.GetShort(), pkt.GetInt()));
            }

            OnShopCraftItem(itemID, weight, maxWeight, inventoryItems);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        internal PaperdollDisplayData(OldPacket pkt)
        {
            //need to be applied to the character that is passed to the dialog
            name    = pkt.GetBreakString();
            home    = pkt.GetBreakString();
            partner = pkt.GetBreakString();
            title   = pkt.GetBreakString();
            guild   = pkt.GetBreakString();
            rank    = pkt.GetBreakString();

            playerID = pkt.GetShort();
            clas     = pkt.GetChar();
            gender   = pkt.GetChar();

            if (pkt.GetChar() != 0)
            {
                throw new ArgumentException("Invalid/malformed packet", nameof(pkt));
            }

            paperdoll = new short[(int)EquipLocation.PAPERDOLL_MAX];
            for (int i = 0; i < (int)EquipLocation.PAPERDOLL_MAX; ++i)
            {
                paperdoll[i] = pkt.GetShort();
            }

            iconType = (PaperdollIconType)pkt.GetChar();
        }
Esempio n. 6
0
        internal ItemUseData(OldPacket pkt)
        {
            type            = (ItemType)pkt.GetChar();
            itemID          = pkt.GetShort();
            characterAmount = pkt.GetInt();
            weight          = pkt.GetChar();
            maxWeight       = pkt.GetChar();

            hpGain    = hp = tp = 0;
            hairColor = 0;
            effect    = 0;

            curecurse_stats = null;
            expreward_stats = null;

            //format differs based on item type
            //(keeping this in order with how eoserv ITEM_USE handler is ordered
            switch (type)
            {
            case ItemType.Teleport: /*Warp packet handles the rest!*/ break;

            case ItemType.Heal:
            {
                hpGain = pkt.GetInt();
                hp     = pkt.GetShort();
                tp     = pkt.GetShort();
            }
            break;

            case ItemType.HairDye:
            {
                hairColor = pkt.GetChar();
            }
            break;

            case ItemType.Beer: /*No additional data*/ break;

            case ItemType.EffectPotion:
            {
                effect = pkt.GetShort();
            }
            break;

            case ItemType.CureCurse:
            {
                curecurse_stats = new CureCurseStats(pkt);
            }
            break;

            case ItemType.EXPReward:
            {
                //note: server packets may be incorrect at this point (src/handlers/Item.cpp) because of unused builder in eoserv
                //note: server also sends an ITEM_ACCEPT packet to surrounding players on level-up?
                expreward_stats = new LevelUpStats(pkt, true);
            }
            break;
            }
        }
Esempio n. 7
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);
            }
        }
Esempio n. 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);
        }
Esempio n. 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()));
            }
        }
Esempio n. 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);
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
        /// <summary>
        /// Handles SHOP_SELL from server, response to selling an item
        /// </summary>
        private void _handleShopSell(OldPacket pkt)
        {
            if (OnShopTradeItem == null)
            {
                return;
            }

            int   charNumLeft = pkt.GetInt();
            short itemID      = pkt.GetShort();
            int   charGold    = pkt.GetInt();
            byte  weight      = pkt.GetChar();
            byte  maxWeight   = pkt.GetChar();

            OnShopTradeItem(charGold, itemID, charNumLeft, weight, maxWeight, false);
        }
Esempio n. 13
0
        /// <summary>
        /// Handles SHOP_BUY from server, response to buying an item
        /// </summary>
        private void _handleShopBuy(OldPacket pkt)
        {
            if (OnShopTradeItem == null)
            {
                return;
            }

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

            OnShopTradeItem(charGoldLeft, itemID, amount, weight, maxWeight, true);
        }
Esempio n. 14
0
        /// <summary>
        /// Handler for CHEST_REPLY packet, sent in response to main player adding an item to a chest
        /// </summary>
        private void _handleChestReply(OldPacket pkt)
        {
            if (OnChestAddItem == null)
            {
                return;
            }

            short     remainingID        = pkt.GetShort();
            int       remainingAmount    = pkt.GetInt();
            byte      characterWeight    = pkt.GetChar();
            byte      characterMaxWeight = pkt.GetChar();
            ChestData data = new ChestData(pkt, false);

            OnChestAddItem(remainingID, remainingAmount, characterWeight, characterMaxWeight, data);
        }
Esempio n. 15
0
 private void _handleMusicPlayer(OldPacket pkt)
 {
     if (OnPlaySoundEffect != null)
     {
         OnPlaySoundEffect(pkt.GetChar());
     }
 }
Esempio n. 16
0
 /// <summary>
 /// Handles LOCKER_BUY from server when buying a locker unit upgrade
 /// </summary>
 /// <param name="pkt"></param>
 private void _handleLockerBuy(OldPacket pkt)
 {
     if (OnLockerUpgrade != null)
     {
         OnLockerUpgrade(pkt.GetInt(), pkt.GetChar()); //gold remaining, num upgrades
     }
 }
Esempio n. 17
0
        private void _handleSpellTargetSelf(OldPacket pkt)
        {
            short fromPlayerID  = pkt.GetShort();
            short spellID       = pkt.GetShort();
            int   spellHP       = pkt.GetInt();
            byte  percentHealth = pkt.GetChar();

            if (pkt.ReadPos == pkt.Length)
            {
                //another player was the source of this packet

                if (OnOtherPlayerCastSpellSelf != null)
                {
                    OnOtherPlayerCastSpellSelf(fromPlayerID, spellID, spellHP, percentHealth);
                }

                return;
            }

            short characterHP = pkt.GetShort();
            short characterTP = pkt.GetShort();

            if (pkt.GetShort() != 1) //malformed packet! eoserv sends '1' here
            {
                return;
            }

            //main player was source of this packet
            if (OnCastSpellSelf != null)
            {
                OnCastSpellSelf(fromPlayerID, spellID, spellHP, percentHealth, characterHP, characterTP);
            }
        }
Esempio n. 18
0
 //sent when your trade partner agrees
 private void _handleTradeAgree(OldPacket pkt)
 {
     if (OnTradeOtherPlayerAgree != null)
     {
         OnTradeOtherPlayerAgree(pkt.GetShort(), pkt.GetChar() != 0);
     }
 }
Esempio n. 19
0
 //sent in response to you agreeing
 private void _handleTradeSpec(OldPacket pkt)
 {
     if (OnTradeYouAgree != null)
     {
         OnTradeYouAgree(pkt.GetChar() != 0);
     }
 }
Esempio n. 20
0
        private void _handlePlayerList(OldPacket pkt, bool isFriendList)
        {
            short numTotal = pkt.GetShort();

            if (pkt.GetByte() != 255)
            {
                return;
            }

            m_init_onlinePlayerList = new List <OnlineEntry>();
            for (int i = 0; i < numTotal; ++i)
            {
                string name = pkt.GetBreakString();

                if (!isFriendList)
                {
                    string title = pkt.GetBreakString();
                    if (string.IsNullOrWhiteSpace(title))
                    {
                        title = "-";
                    }
                    if (pkt.GetChar() != 0)
                    {
                        return;
                    }

                    PaperdollIconType iconType = (PaperdollIconType)pkt.GetChar();

                    int clsId = pkt.GetChar();

                    string guild = pkt.GetBreakString();
                    if (string.IsNullOrWhiteSpace(guild))
                    {
                        guild = "-";
                    }

                    name  = char.ToUpper(name[0]) + name.Substring(1);
                    title = char.ToUpper(title[0]) + title.Substring(1);

                    m_init_onlinePlayerList.Add(new OnlineEntry(name, title, guild, clsId, iconType));
                }
                else
                {
                    m_init_onlinePlayerList.Add(new OnlineEntry(name, "", "", 0, PaperdollIconType.Normal));
                }
            }
        }
Esempio n. 21
0
        //this is only ever sent to MainPlayer (avatar handles other players)
        private void _handlePaperdollRemove(OldPacket pkt)
        {
            if (OnPlayerPaperdollChange == null)
            {
                return;
            }

            //the $strip command does this wrong (adding 0's in), somehow the original client is smart enough to figure it out
            //normally would put this block in the _handleAvatarAgree
            short      playerID = pkt.GetShort();
            AvatarSlot slot     = (AvatarSlot)pkt.GetChar();
            bool       sound    = pkt.GetChar() == 0; //sound : 0

            short boots = pkt.GetShort();

            if (pkt.Length != 45)
            {
                pkt.Skip(sizeof(short) * 3);                   //three 0s
            }
            short armor = pkt.GetShort();

            if (pkt.Length != 45)
            {
                pkt.Skip(sizeof(short));                   // one 0
            }
            short hat = pkt.GetShort();
            short shield, weapon;

            if (pkt.Length != 45)
            {
                shield = pkt.GetShort();
                weapon = pkt.GetShort();
            }
            else
            {
                weapon = pkt.GetShort();
                shield = pkt.GetShort();
            }

            AvatarData renderData = new AvatarData(playerID, slot, sound, boots, armor, hat, weapon, shield);
            //if (OnPlayerAvatarChange != null) //see PlayerAvatarChangeHandler
            //    OnPlayerAvatarChange(renderData);

            PaperdollEquipData data = new PaperdollEquipData(pkt, true);

            OnPlayerPaperdollChange(data);
        }
Esempio n. 22
0
 private void _handleRecoverAgree(OldPacket pkt)
 {
     //when a heal item is used by another player
     if (OnPlayerHeal != null)
     {
         OnPlayerHeal(pkt.GetShort(), pkt.GetInt(), pkt.GetChar()); //player id - hp gain - percent heal
     }
 }
Esempio n. 23
0
 //timed spikes
 private void _handleEffectReport(OldPacket pkt)
 {
     pkt.GetChar(); //always 83 - sent from eoserv when Map::TimedSpikes is called
     //as of rev 487 this is not sent anywhere else. May need to update event handler if this changes.
     if (OnTimedSpike != null)
     {
         OnTimedSpike();
     }
 }
Esempio n. 24
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);
        }
Esempio n. 25
0
        private void _handleEmotePlayer(OldPacket pkt)
        {
            short playerID = pkt.GetShort();
            Emote emote    = (Emote)pkt.GetChar();

            if (OnOtherPlayerEmote != null)
            {
                OnOtherPlayerEmote(playerID, emote);
            }
        }
Esempio n. 26
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);
        }
Esempio n. 27
0
 internal Skill(OldPacket pkt)
 {
     m_id       = pkt.GetShort();
     m_levelReq = pkt.GetChar();
     m_classReq = pkt.GetChar();
     m_goldCost = pkt.GetInt();
     m_skillReq = new[]
     {
         pkt.GetShort(),
             pkt.GetShort(),
             pkt.GetShort(),
             pkt.GetShort()
     };
     m_strReq = pkt.GetShort();
     m_intReq = pkt.GetShort();
     m_wisReq = pkt.GetShort();
     m_agiReq = pkt.GetShort();
     m_conReq = pkt.GetShort();
     m_chaReq = pkt.GetShort();
 }
Esempio n. 28
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);
        }
Esempio n. 29
0
 internal LevelUpStats(OldPacket pkt, bool includeExp)
 {
     //includeExp will be false when leveling up from NPC, true from EXPReward
     //NPC handler happens slightly differently
     exp   = includeExp ? pkt.GetInt() : 0;
     level = pkt.GetChar();
     stat  = pkt.GetShort();
     skill = pkt.GetShort();
     maxhp = pkt.GetShort();
     maxtp = pkt.GetShort();
     maxsp = pkt.GetShort();
 }
Esempio n. 30
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);
        }