private void _sharedTradeDataProcess(OldPacket pkt, TradeUpdateEvent handler) { if (handler == null) { return; } short player1ID = pkt.GetShort(); List <InventoryItem> player1Items = new List <InventoryItem>(); while (pkt.PeekByte() != 255) { player1Items.Add(new InventoryItem(pkt.GetShort(), pkt.GetInt())); } pkt.Skip(1); short player2ID = pkt.GetShort(); List <InventoryItem> player2Items = new List <InventoryItem>(); while (pkt.PeekByte() != 255) { player2Items.Add(new InventoryItem(pkt.GetShort(), pkt.GetInt())); } pkt.Skip(1); handler(player1ID, player1Items, player2ID, player2Items); }
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; } }
/// <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); }
/// <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); }
/// <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 } }
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); } }
/// <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); }
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); }
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); }
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 } }
//success learning a skill private void _handleStatSkillTake(OldPacket pkt) { //short - spell id //int - character gold remaining if (OnSpellLearnSuccess != null) { OnSpellLearnSuccess(pkt.GetShort(), pkt.GetInt()); } }
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(); }
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); } }
/// <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); }
internal CharacterLoginData(OldPacket pkt) { name = pkt.GetBreakString(); id = pkt.GetInt(); level = pkt.GetChar(); gender = pkt.GetChar(); hairstyle = pkt.GetChar(); haircolor = pkt.GetChar(); race = pkt.GetChar(); admin = (AdminLevel)pkt.GetChar(); boots = pkt.GetShort(); armor = pkt.GetShort(); hat = pkt.GetShort(); shield = pkt.GetShort(); weapon = pkt.GetShort(); }
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(); }
/// <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); }
private void _handleRecoverReply(OldPacket pkt) { if (OnRecoverReply == null) { return; } int exp = pkt.GetInt(); short karma = pkt.GetShort(); byte level = pkt.GetChar(); if (pkt.ReadPos == pkt.Length) { OnRecoverReply(exp, karma, level); } else { short statpoints = pkt.GetShort(); short skillpoints = pkt.GetShort(); OnRecoverReply(exp, karma, level, statpoints, skillpoints); } }