示例#1
0
 public BonusItem(StoC_0x02_InventoryUpdate.Item item)
     : this()
 {
     this.slot       = item.slot;
     this.name       = item.name;
     this.objectType = item.objectType;
 }
        public StoC_0x02_InventoryUpdate.Item GetLeftHandWeapon()
        {
            StoC_0x02_InventoryUpdate.Item item = newitem;
            for (int i = 0; i < 4; i++)
            {
                if ((i == (VisibleSlots & 0x0F)) || (i == ((VisibleSlots >> 4) & 0x0F)))
                {
                    item = (StoC_0x02_InventoryUpdate.Item)weapons[i];
//					if (item.objectType == 42)//shield
//						str.AppendFormat("slot:{0,-2} level:{1,-2} size:{2} con:{3,-3} qual:{4,-3} bonus:{5,-2} model:0x{6:X4} \"{7}\"\n",
//						item.slot, item.level, item.value1, item.condition, item.quality, item.bonus, item.model, item.name);
//					else
//						str.AppendFormat("slot:{0,-2} level:{1,-2} dps:{2:0.00} spd:{3:0.00} damageType:{4} con:{5,-3} qual:{6,-3} bonus:{7,-2} model:0x{8:X4} \"{9}\"\n",
//						item.slot, item.level, 0.1 * item.value1, 0.1 * item.value2, item.damageType, item.condition, item.quality, item.bonus, item.model, item.name);
                }
            }
            return(item);
        }
        /// <summary>
        /// Activates a log action.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="selectedPacket">The selected packet.</param>
        /// <returns><c>true</c> if log data tab should be updated.</returns>
        public override bool Activate(IExecutionContext context, PacketLocation selectedPacket)
        {
            PacketLog  log              = context.LogManager.GetPacketLog(selectedPacket.LogIndex);
            int        selectedIndex    = selectedPacket.PacketIndex;
            SortedList m_inventoryItems = new SortedList();

            int preAction          = 0;
            int lastVaultPreAction = -1;
            int vaultNumber        = -1;
            int VisibleSlots       = 0xFF;

            for (int i = 0; i <= selectedIndex; i++)
            {
                Packet pak = log[i];
                if (pak is StoC_0x20_PlayerPositionAndObjectID_171)
                {
                    VisibleSlots = 0xFF;
                    m_inventoryItems.Clear();
                }
                else if (pak is StoC_0x02_InventoryUpdate)
                {
                    StoC_0x02_InventoryUpdate invPack = (StoC_0x02_InventoryUpdate)pak;
                    if (invPack.PreAction != 0 && invPack.PreAction != 10)
                    {
                        preAction = invPack.PreAction;                         // rememer last opened inventory action, if it not update
                    }
                    if (preAction > 10)
                    {
                        preAction -= 10;
                    }
                    if (invPack.PreAction == 1 || invPack.PreAction == 0 || invPack.PreAction == 11 || invPack.PreAction == 10)
                    {
                        VisibleSlots = invPack.VisibleSlots;
                    }
                    if (invPack.PreAction == 2)
                    {
                        for (byte j = 40; j < 80; j++)
                        {
                            if (m_inventoryItems.ContainsKey(j))
                            {
                                m_inventoryItems.Remove(j);
                            }
                        }
                    }
                    else if (invPack.PreAction == 7)
                    {
                        for (byte j = 80; j <= 95; j++)
                        {
                            if (m_inventoryItems.ContainsKey(j))
                            {
                                m_inventoryItems.Remove(j);
                            }
                        }
                    }
                    else if (invPack.PreAction == 3)
                    {
                        for (byte j = 110; j < 150; j++)
                        {
                            if (m_inventoryItems.ContainsKey(j))
                            {
                                m_inventoryItems.Remove(j);
                            }
                        }
                    }
                    else if (invPack.PreAction == 4 || invPack.PreAction == 5 || invPack.PreAction == 6)
                    {
                        lastVaultPreAction = invPack.PreAction;
                        vaultNumber        = invPack.VisibleSlots;
                        for (byte j = 150; j < 250; j++)
                        {
                            if (m_inventoryItems.ContainsKey(j))
                            {
                                m_inventoryItems.Remove(j);
                            }
                        }
                    }
                    for (int j = 0; j < invPack.SlotsCount; j++)
                    {
                        StoC_0x02_InventoryUpdate.Item item = (StoC_0x02_InventoryUpdate.Item)invPack.Items[j];
                        if (item.name == null || item.name == "")
                        {
                            if (m_inventoryItems.ContainsKey(item.slot))
                            {
                                m_inventoryItems.Remove(item.slot);
                            }
                        }
                        else
                        {
                            if (m_inventoryItems.ContainsKey(item.slot))
                            {
                                m_inventoryItems[item.slot] = item;
                            }
                            else
                            {
                                m_inventoryItems.Add(item.slot, item);
                            }
                        }
                    }
                }
            }
            StringBuilder str = new StringBuilder();

            str.AppendFormat("VisibleSlots:0x{0:X2} last initialized preAction:{1}({2})\n", VisibleSlots, preAction, (StoC_0x02_InventoryUpdate.ePreActionType)preAction);
            eWindowType prevWindowType = eWindowType.Unknown;
            eWindowType windowType     = eWindowType.Unknown;

            foreach (StoC_0x02_InventoryUpdate.Item item in m_inventoryItems.Values)
            {
//				if (item.slot > 95 /*&& item.slot < 1000*/)
                {
                    string selected = " ";
                    if (item.slot >= 7 && item.slot <= 9)
                    {
                        windowType = eWindowType.Horse;
                    }
                    else if (item.slot >= 10 && item.slot <= 13)
                    {
                        windowType = eWindowType.Weapon;
                        if (((item.slot - 10) == (VisibleSlots & 0x0F)) || ((item.slot - 10) == ((VisibleSlots >> 4) & 0x0F)))
                        {
                            selected = "*";
                        }
                    }
                    else if (item.slot >= 14 && item.slot <= 17)
                    {
                        windowType = eWindowType.Quiver;
                    }
                    else if (item.slot >= 21 && item.slot <= 37)
                    {
                        windowType = eWindowType.Doll;
                    }
                    else if (item.slot >= 40 && item.slot <= 79)
                    {
                        windowType = eWindowType.Backpack;
                    }
                    else if (item.slot >= 80 && item.slot <= 95)
                    {
                        windowType = eWindowType.Horsebag;
                    }
                    else if (item.slot >= 110 && item.slot <= 149)
                    {
                        windowType = eWindowType.Vault;
                    }
                    else if (item.slot >= 150 && item.slot <= 249)
                    {
                        windowType = eWindowType.HouseVault;
                    }
                    if (windowType != prevWindowType)
                    {
                        str.Append('\n');
                        str.Append(windowType);
                        if (windowType == eWindowType.HouseVault)
                        {
                            if (lastVaultPreAction == 4 && vaultNumber != -1)
                            {
                                str.Append(' ');
                                str.Append(vaultNumber);
                            }
                            str.AppendFormat(" ({0})", (StoC_0x02_InventoryUpdate.ePreActionType)lastVaultPreAction);
                        }
                    }
                    str.AppendFormat("\n{16}slot:{0,-3} level:{1,-2} value1:0x{2:X2} value2:0x{3:X2} hand:0x{4:X2} damageType:0x{5:X2} objectType:0x{6:X2} weight:{7,-4} con:{8,-3} dur:{9,-3} qual:{10,-3} bonus:{11,-2} model:0x{12:X4} color:0x{13:X4} effect:0x{14:X2} \"{15}\"",
                                     item.slot, item.level, item.value1, item.value2, item.hand, item.damageType, item.objectType, item.weight, item.condition, item.durability, item.quality, item.bonus, item.model, item.color, item.effect, item.name, selected);
                    if (item.name != null && item.name != "")
                    {
                        str.AppendFormat(" ({0})", (StoC_0x02_InventoryUpdate.eObjectType)item.objectType);
                    }
                    prevWindowType = windowType;
                }
            }

            InfoWindowForm infoWindow = new InfoWindowForm();

            infoWindow.Text   = "Player inventory info (right click to close)";
            infoWindow.Width  = 800;
            infoWindow.Height = 400;
            infoWindow.InfoRichTextBox.Text = str.ToString();
            infoWindow.StartWindowThread();

            return(false);
        }
示例#4
0
        private void CheckItemsHitsBonus(PacketLog log, int selectedIndex, StringBuilder str, ref int bonusHits, ref int bonusHitCap, ref int bonusPower, ref int bonusPowerPool, ref int bonusPowerPoolCap)
        {
            SortedList m_inventoryItems = new SortedList();
            int        VisibleSlots     = 0xFF;

            for (int i = 0; i <= selectedIndex; i++)
            {
                Packet pak = log[i];
                if (pak is StoC_0x20_PlayerPositionAndObjectID_171)
                {
                    VisibleSlots = 0xFF;
                    m_inventoryItems.Clear();
                }
                else if (pak is StoC_0x02_InventoryUpdate)
                {
                    StoC_0x02_InventoryUpdate invPack = (StoC_0x02_InventoryUpdate)pak;
                    if ((invPack.PreAction >= 0 && invPack.PreAction <= 1) || (invPack.PreAction >= 10 && invPack.PreAction <= 11))
                    {
                        VisibleSlots = invPack.VisibleSlots;
                    }
                    if ((invPack.PreAction >= 0 && invPack.PreAction <= 2) || (invPack.PreAction >= 10 && invPack.PreAction <= 12))
                    {
                        for (int j = 0; j < invPack.SlotsCount; j++)
                        {
                            StoC_0x02_InventoryUpdate.Item item = (StoC_0x02_InventoryUpdate.Item)invPack.Items[j];
                            if (item.slot >= 10 && item.slot < 40)                             // Only equiped slot
                            {
                                if (item.name == null || item.name == "")
                                {
                                    if (m_inventoryItems.ContainsKey(item.slot))
                                    {
                                        m_inventoryItems.Remove(item.slot);
                                    }
                                }
                                else
                                {
                                    m_inventoryItems[item.slot] = new BonusItem(item);
                                }
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < log.Count; i++)
            {
                Packet pak = log[i];
                if (pak is StoC_0xC4_CustomTextWindow)
                {
                    foreach (BonusItem item in m_inventoryItems.Values)
                    {
                        if (item.slot < 40)
                        {
                            if (item.slot >= 10 && item.slot <= 13)
                            {
                                if (!(((item.slot - 10) == (VisibleSlots & 0x0F)) || ((item.slot - 10) == ((VisibleSlots >> 4) & 0x0F))))
                                {
                                    continue;
                                }
                            }
                            if (item.delvePack == null && item.name == (pak as StoC_0xC4_CustomTextWindow).Caption)
                            {
                                item.delvePack = pak as StoC_0xC4_CustomTextWindow;
                            }
                        }
                    }
                }
            }
            foreach (BonusItem item in m_inventoryItems.Values)
            {
                if (item.slot < 40)
                {
                    if (item.slot >= 10 && item.slot <= 13)
                    {
                        if (!(((item.slot - 10) == (VisibleSlots & 0x0F)) || ((item.slot - 10) == ((VisibleSlots >> 4) & 0x0F))))
                        {
                            continue;
                        }
                    }
                    str.AppendFormat("\nslot:{0,-3} objectType:0x{1:X2} \"{2}\" ({3})",
                                     item.slot, item.objectType, item.name, (StoC_0x02_InventoryUpdate.eObjectType)item.objectType);
                    if (item.delvePack == null)
                    {
                        str.Append(" - delve not found");
                    }
                    else
                    {
                        int  flagDelveShowed = 0;
                        bool flagArtifact    = false;
                        for (int i = 0; i < item.delvePack.Lines.Length; i++)
                        {
                            StoC_0xC4_CustomTextWindow.LineEntry line = item.delvePack.Lines[i];
                            string text = line.text;
                            if (flagArtifact)
                            {
                                int artLevelDescBegin = line.text.IndexOf("[L");
                                if (artLevelDescBegin >= 0)
                                {
                                    text = line.text.Substring(0, artLevelDescBegin) + line.text.Substring(line.text.IndexOf("]: ") + 3);
                                }
                            }
                            if (line.text.StartsWith("Artifact (Current level:"))
                            {
                                flagArtifact = true;
                            }
                            else if (text.StartsWith("- Hits: "))
                            {
                                if (flagDelveShowed++ > 0)
                                {
                                    str.Append(',');
                                }
                                str.Append(' ');
                                str.Append(line.text);
                                bonusHits += int.Parse(text.Substring(8, text.IndexOf(" pts") - 8));
                            }
                            else if (text.StartsWith("Bonus to hit points bonus cap:"))
                            {
                                if (flagDelveShowed++ > 0)
                                {
                                    str.Append(',');
                                }
                                str.Append(' ');
                                str.Append(line.text);
                                bonusHitCap += int.Parse(text.Substring(31));
                            }
                            else if (text.StartsWith("- Power: "))
                            {
                                if (flagDelveShowed++ > 0)
                                {
                                    str.Append(',');
                                }
                                str.Append(' ');
                                str.Append(line.text);
                                if (text.IndexOf(" % of power pool") >= 0)
                                {
                                    bonusPowerPool += int.Parse(text.Substring(9, text.IndexOf(" % of power pool") - 9));
                                }
                                else if (text.IndexOf(" pts") >= 0)
                                {
                                    bonusPower += int.Parse(text.Substring(9, text.IndexOf(" pts") - 9));
                                }
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Writes the log.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="stream">The stream.</param>
        /// <param name="callback">The callback for UI updates.</param>
        public void WriteLog(IExecutionContext context, Stream stream, ProgressCallback callback)
        {
            SortedList oidInfo           = new SortedList();
            IList      CombatWaitMessage = new ArrayList();
            Hashtable  styleIcons        = new Hashtable();
            Hashtable  plrInfo           = new Hashtable();

            weapons = new StoC_0x02_InventoryUpdate.Item[4];
            PlayerInfo playerInfo = null;            // = new PlayerInfo();

            int    playerOid = -1;
            string nameKey   = "";
            string statKey   = "";
            string plrName   = "";
            string plrClass  = "";
            int    plrLevel  = 0;
            int    countBC   = 0;

            using (StreamWriter s = new StreamWriter(stream))
            {
                foreach (PacketLog log in context.LogManager.Logs)
                {
                    for (int i = 0; i < log.Count; i++)
                    {
                        if (callback != null && (i & 0xFFF) == 0)                         // update progress every 4096th packet
                        {
                            callback(i, log.Count - 1);
                        }

                        Packet pak = log[i];
                        // Enter region (get new self OID)
                        if (pak is StoC_0x20_PlayerPositionAndObjectID)
                        {
                            StoC_0x20_PlayerPositionAndObjectID plr = (StoC_0x20_PlayerPositionAndObjectID)pak;
                            playerOid = plr.PlayerOid;
                            oidInfo.Clear();
                            oidInfo[plr.PlayerOid] = new ObjectInfo(eObjectType.player, "You", 0);
                            s.WriteLine("{0, -16} playerOid:0x{1:X4}", pak.Time.ToString(), playerOid);
                        }
                        // Fill objects OID
                        else if (pak is StoC_0xD4_PlayerCreate)
                        {
                            StoC_0xD4_PlayerCreate player = (StoC_0xD4_PlayerCreate)pak;
                            oidInfo[player.Oid] = new ObjectInfo(eObjectType.player, player.Name, player.Level);
                        }
                        else if (pak is StoC_0x4B_PlayerCreate_172)
                        {
                            StoC_0x4B_PlayerCreate_172 player = (StoC_0x4B_PlayerCreate_172)pak;
                            oidInfo[player.Oid] = new ObjectInfo(eObjectType.player, player.Name, player.Level);
                        }
                        else if (pak is StoC_0x12_CreateMovingObject)
                        {
                            StoC_0x12_CreateMovingObject obj = (StoC_0x12_CreateMovingObject)pak;
                            oidInfo[obj.ObjectOid] = new ObjectInfo(eObjectType.movingObject, obj.Name, 0);
                        }
                        else if (pak is StoC_0x6C_KeepComponentOverview)
                        {
                            StoC_0x6C_KeepComponentOverview keep = (StoC_0x6C_KeepComponentOverview)pak;
                            oidInfo[keep.Uid] =
                                new ObjectInfo(eObjectType.keep, string.Format("keepId:0x{0:X4} componentId:{1}", keep.KeepId, keep.ComponentId),
                                               0);
                        }
                        else if (pak is StoC_0xDA_NpcCreate)
                        {
                            StoC_0xDA_NpcCreate npc = (StoC_0xDA_NpcCreate)pak;
                            oidInfo[npc.Oid] = new ObjectInfo(eObjectType.npc, npc.Name, npc.Level);
                        }
                        else if (pak is StoC_0xD9_ItemDoorCreate)
                        {
                            StoC_0xD9_ItemDoorCreate item = (StoC_0xD9_ItemDoorCreate)pak;
                            eObjectType type = eObjectType.staticObject;
                            if (item.ExtraBytes > 0)
                            {
                                type = eObjectType.door;
                            }
                            oidInfo[item.Oid] = new ObjectInfo(type, item.Name, 0);
                        }
                        // Fill current weapons
                        else if (pak is StoC_0x02_InventoryUpdate)
                        {
                            StoC_0x02_InventoryUpdate invPack = (StoC_0x02_InventoryUpdate)pak;
                            if (invPack.PreAction == 1 || invPack.PreAction == 0)
                            {
                                VisibleSlots = invPack.VisibleSlots;
                                for (int j = 0; j < invPack.SlotsCount; j++)
                                {
                                    StoC_0x02_InventoryUpdate.Item item = (StoC_0x02_InventoryUpdate.Item)invPack.Items[j];
                                    switch (item.slot)
                                    {
                                    case 10:
                                        weapons[0] = item;
                                        break;

                                    case 11:
                                        weapons[1] = item;
                                        break;

                                    case 12:
                                        weapons[2] = item;
                                        break;

                                    case 13:
                                        weapons[3] = item;
                                        break;

                                    default:
                                        break;
                                    }
                                }
                            }
                        }
                        // Fill character stats
                        else if (pak is StoC_0x16_VariousUpdate)
                        {
                            // name, level, class
                            StoC_0x16_VariousUpdate stat = (StoC_0x16_VariousUpdate)pak;
                            if (stat.SubCode == 3)
                            {
                                StoC_0x16_VariousUpdate.PlayerUpdate subData = (StoC_0x16_VariousUpdate.PlayerUpdate)stat.SubData;
                                nameKey  = "N:" + subData.playerName + "L:" + subData.playerLevel;
                                statKey  = "";
                                plrName  = subData.playerName;
                                plrLevel = subData.playerLevel;
                                plrClass = subData.className;
                                s.WriteLine("{0, -16} 0x16:3 nameKey:{1} plrName:{2} {3} {4}", pak.Time.ToString(), nameKey, plrName, plrLevel,
                                            plrClass);
                            }
                            // mainhand spec, mainhand DPS
                            else if (stat.SubCode == 5)
                            {
                                StoC_0x16_VariousUpdate.PlayerStateUpdate subData = (StoC_0x16_VariousUpdate.PlayerStateUpdate)stat.SubData;
                                string key =
                                    string.Format("WD:{0}.{1}WS:{2}", subData.weaponDamageHigh, subData.weaponDamageLow,
                                                  (subData.weaponSkillHigh << 8) + subData.weaponSkillLow);
                                if (nameKey != "")
                                {
                                    if (plrInfo.ContainsKey(nameKey + key))
                                    {
                                        playerInfo = (PlayerInfo)plrInfo[nameKey + key];
                                    }
                                    else
                                    {
                                        playerInfo              = new PlayerInfo();
                                        playerInfo.name         = plrName;
                                        playerInfo.level        = plrLevel;
                                        playerInfo.className    = plrClass;
                                        playerInfo.weaponDamage = string.Format("{0,2}.{1,-3}", subData.weaponDamageHigh, subData.weaponDamageLow);
                                        playerInfo.weaponSkill  = (subData.weaponSkillHigh << 8) + subData.weaponSkillLow;
                                        plrInfo.Add(nameKey + key, playerInfo);
                                    }
                                    plrInfo[nameKey + key] = playerInfo;
                                }
                                statKey = key;
                                s.WriteLine("{0, -16} 0x16:5 S:{1} {2} {3} {4} {5}", pak.Time.ToString(), statKey, playerInfo.name,
                                            playerInfo.level, playerInfo.weaponDamage, playerInfo.weaponSkill);
                            }
                            // Fill styles
                            if (stat.SubCode == 1)
                            {
                                StoC_0x16_VariousUpdate.SkillsUpdate subData = (StoC_0x16_VariousUpdate.SkillsUpdate)stat.SubData;
                                styleIcons.Clear();
                                if (log.Version < 186)
                                {
                                    styleIcons.Add((ushort)0x01F4, "Bow prepare");
                                    styleIcons.Add((ushort)0x01F5, "Lefthand hit");
                                    styleIcons.Add((ushort)0x01F6, "Bothhands hit");
                                    styleIcons.Add((ushort)0x01F7, "Bow shoot");
//									styleIcons.Add((ushort)0x01F9, "Volley aim ?");
//									styleIcons.Add((ushort)0x01FA, "Volley ready ?");
//									styleIcons.Add((ushort)0x01FB, "Volley shoot ?");
                                }
                                else
                                {
                                    styleIcons.Add((ushort)0x3E80, "Bow prepare");
                                    styleIcons.Add((ushort)0x3E81, "Lefthand hit");
                                    styleIcons.Add((ushort)0x3E82, "Bothhands hit");
                                    styleIcons.Add((ushort)0x3E83, "Bow shoot");
//									styleIcons.Add((ushort)0x3E85, "Volley aim ?");
//									styleIcons.Add((ushort)0x3E86, "Volley ready ?");
//									styleIcons.Add((ushort)0x3E87, "Volley shoot ?");
                                }
                                foreach (StoC_0x16_VariousUpdate.Skill skill in subData.data)
                                {
                                    if (skill.page == StoC_0x16_VariousUpdate.eSkillPage.Styles)
                                    {
                                        styleIcons[skill.icon] = skill.name;
//										s.WriteLine("{0, -16} 0x16:1 icon:0x{1:X4} name:{2}", pak.Time.ToString(), skill.icon, styleIcons[skill.icon]);
                                    }
                                }

/*                              foreach (DictionaryEntry entry in styleIcons)
 *                                                              {
 *                                                                      ushort icon = (ushort)entry.Key;
 *                                                                      s.WriteLine("{0, -16} 0x16:1 icon:0x{1:X4} name:{2}", pak.Time.ToString(), icon, entry.Value);
 *                                                              }*/
                            }
                        }
                        // Combat animation
                        else if (pak is StoC_0xBC_CombatAnimation && (playerInfo != null))
                        {
                            StoC_0xBC_CombatAnimation combat = (StoC_0xBC_CombatAnimation)pak;
                            CombatWaitMessage.Clear();
                            ObjectInfo targetObj = oidInfo[combat.DefenderOid] as ObjectInfo;
                            string     styleName = (combat.StyleId == 0 /*  || (combat.Result & 0x7F) != 0x0B)*/)
                                                                                ? ""
                                                                                : (styleIcons[combat.StyleId] == null
                                                                                        ? "not found " + combat.StyleId.ToString()
                                                                                        : (styleIcons[combat.StyleId]).ToString());
                            string targetName = targetObj == null ? "" : " target:" + targetObj.name + " (" + targetObj.type + ")";
                            if (combat.Stance == 0 && combat.AttackerOid == playerOid /* && combat.DefenderOid != 0*/)
                            {
                                switch (combat.Result & 0x7F)
                                {
                                case 0:
                                    CombatWaitMessage.Add(new WaitMessage(0x11, "You miss!"));
                                    CombatWaitMessage.Add(new WaitMessage(0x11, "You were strafing in combat and miss!"));
                                    break;

                                case 1:
                                    if (targetObj != null)
                                    {
                                        CombatWaitMessage.Add(new WaitMessage(0x11, targetObj.GetFirstFullName + " parries your attack!"));
                                    }
                                    break;

                                case 2:
//										if (targetObj != null)//TODO
//											CombatWaitMessage.Add(new WaitMessage(0x11, targetObj.GetFirstFullName + " The Midgardian Assassin attacks you and you block the blow!"));
                                    break;

                                case 3:
                                    if (targetObj != null)
                                    {
                                        CombatWaitMessage.Add(new WaitMessage(0x11, targetObj.GetFirstFullName + " evades your attack!"));
                                    }
                                    break;

                                case 4:
                                    CombatWaitMessage.Add(new WaitMessage(0x11, "You fumble the attack and take time to recover!"));
                                    break;

                                case 0xA:
                                    if (targetObj != null)
                                    {
                                        CombatWaitMessage.Add(
                                            new WaitMessage(0x11, "You attack " + targetObj.GetFullName + " with your % and hit for % damage!"));
                                    }
                                    break;

                                case 0xB:
                                    CombatWaitMessage.Add(new WaitMessage(0x11, "You perform your " + styleName + " perfectly. %"));
                                    if (targetObj != null)
                                    {
                                        CombatWaitMessage.Add(
                                            new WaitMessage(0x11, "You attack " + targetObj.GetFullName + " with your % and hit for % damage!"));
                                    }
                                    break;

                                case 0x14:
                                    if (targetObj != null)
                                    {
                                        CombatWaitMessage.Add(new WaitMessage(0x11, "You hit " + targetObj.GetFullName + " for % damage!"));
                                    }
                                    break;

                                default:
                                    break;
                                }
                            }
                            if (combat.AttackerOid == playerOid)
                            {
                                s.WriteLine("{0, -16} 0xBC attackerOid:0x{1:X4}(You) defenderOid:0x{2:X4} style:0x{4:X4} result:0x{3:X2}{5}{6}",
                                            pak.Time.ToString(), combat.AttackerOid, combat.DefenderOid, combat.Result, combat.StyleId,
                                            styleName == "" ? "" : " styleName:" + styleName, targetName);
                                foreach (WaitMessage msg in CombatWaitMessage)
                                {
                                    s.WriteLine("         WAITING 0xAF 0x{0:X2} {1}", msg.msgType, msg.message);
                                }
                                countBC++;
                            }
                        }
                        // Messages
                        else if (pak is StoC_0xAF_Message)
                        {
                            StoC_0xAF_Message msg = (StoC_0xAF_Message)pak;
                            switch (msg.Type)
                            {
//								case 0x10: // Your cast combat
                            case 0x11:                                     // Your Melee combat
//								case 0x1B: // resist
//								case 0x1D: // X hits you
//								case 0x1E: // X miss you
                                s.WriteLine("{0, -16} 0xAF 0x{1:X2} {2} ", pak.Time.ToString(), msg.Type, msg.Text);
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
                if (nameKey != "" && statKey != "")
                {
                    plrInfo[nameKey + statKey] = playerInfo;
                }
            }
        }
        /// <summary>
        /// Activates a log action.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="selectedPacket">The selected packet.</param>
        /// <returns><c>true</c> if log data tab should be updated.</returns>
        public bool Activate(IExecutionContext context, PacketLocation selectedPacket)
        {
            PacketLog log           = context.LogManager.GetPacketLog(selectedPacket.LogIndex);
            int       selectedIndex = selectedPacket.PacketIndex;

            Packet originalPak = log[selectedIndex];

            if (!(originalPak is CtoS_0xDD_PlayerMoveItemRequest || originalPak is CtoS_0x79_SellItem || originalPak is CtoS_0xE0_AppraiseItem || originalPak is CtoS_0x71_UseItem || originalPak is CtoS_0x80_DestroyInventoryItem || originalPak is CtoS_0x41_UseNewQuestItem || originalPak is CtoS_0x0C_HouseItemPlacementRequest || originalPak is CtoS_0xEB_ModifyTradeWindow || originalPak is StoC_0xEA_TradeWindow || originalPak is CtoS_0xD8_DetailDisplayRequest))             // activate condition
            {
                return(false);
            }
            IList slots = new ArrayList();

            if (originalPak is CtoS_0xDD_PlayerMoveItemRequest)
            {
                if ((originalPak as CtoS_0xDD_PlayerMoveItemRequest).FromSlot < 1000)
                {
                    slots.Add((ushort)(originalPak as CtoS_0xDD_PlayerMoveItemRequest).FromSlot);
                }
                if ((originalPak as CtoS_0xDD_PlayerMoveItemRequest).ToSlot <= 250 && (originalPak as CtoS_0xDD_PlayerMoveItemRequest).ToSlot > 1)
                {
                    slots.Add((ushort)(originalPak as CtoS_0xDD_PlayerMoveItemRequest).ToSlot);
                }
            }
            else if (originalPak is CtoS_0x0C_HouseItemPlacementRequest)
            {
                slots.Add((ushort)(originalPak as CtoS_0x0C_HouseItemPlacementRequest).Slot);
            }
            else if (originalPak is CtoS_0x41_UseNewQuestItem)
            {
                slots.Add((ushort)(originalPak as CtoS_0x41_UseNewQuestItem).GoalIndex);
            }
            else if (originalPak is CtoS_0x71_UseItem)
            {
                slots.Add((ushort)(originalPak as CtoS_0x71_UseItem).Slot);
            }
            else if (originalPak is CtoS_0x79_SellItem)
            {
                slots.Add((ushort)(originalPak as CtoS_0x79_SellItem).Slot);
            }
            else if (originalPak is CtoS_0x80_DestroyInventoryItem)
            {
                slots.Add((ushort)(originalPak as CtoS_0x80_DestroyInventoryItem).Slot);
            }
            else if (originalPak is CtoS_0xE0_AppraiseItem)
            {
                slots.Add((ushort)(originalPak as CtoS_0xE0_AppraiseItem).Slot);
            }
            else if (originalPak is StoC_0xEA_TradeWindow)
            {
                foreach (byte slot in ((byte[])(originalPak as StoC_0xEA_TradeWindow).Slots))
                {
                    if (slot != 0)
                    {
                        slots.Add((ushort)slot);
                    }
                }
            }
            else if (originalPak is CtoS_0xEB_ModifyTradeWindow)
            {
                foreach (byte slot in ((byte[])(originalPak as CtoS_0xEB_ModifyTradeWindow).Slots))
                {
                    if (slot != 0)
                    {
                        slots.Add((ushort)slot);
                    }
                }
            }
            else if (originalPak is CtoS_0xD8_DetailDisplayRequest)
            {
                if ((originalPak as CtoS_0xD8_DetailDisplayRequest).ObjectType == 1)
                {
                    slots.Add((ushort)(originalPak as CtoS_0xD8_DetailDisplayRequest).ObjectId);
                }
            }
            if (slots.Count == 0)
            {
                return(false);
            }
            TimeSpan      zeroTimeSpan = new TimeSpan(0);
            StringBuilder str          = new StringBuilder();

//			int additionStringCount = 0;
            str.Append(originalPak.ToHumanReadableString(zeroTimeSpan, true));
            str.Append('\n');
            for (int i = selectedIndex; i >= 0; i--)
            {
                Packet pak = log[i];
                if ((originalPak is CtoS_0xDD_PlayerMoveItemRequest || originalPak is CtoS_0x79_SellItem || originalPak is CtoS_0xE0_AppraiseItem || originalPak is CtoS_0x71_UseItem || originalPak is CtoS_0x80_DestroyInventoryItem || originalPak is CtoS_0x0C_HouseItemPlacementRequest || originalPak is CtoS_0xEB_ModifyTradeWindow || originalPak is StoC_0xEA_TradeWindow || originalPak is CtoS_0xD8_DetailDisplayRequest))
                {
                    if (pak is StoC_0x02_InventoryUpdate)
                    {
                        StoC_0x02_InventoryUpdate itemsPak = (pak as StoC_0x02_InventoryUpdate);
                        for (int j = 0; j < itemsPak.SlotsCount; j++)
                        {
                            StoC_0x02_InventoryUpdate.Item item = itemsPak.Items[j];
                            int slotIndex = 0;
                            do
                            {
                                if (slotIndex < slots.Count)
                                {
                                    ushort slot = (ushort)slots[slotIndex];
                                    if (item.slot == slot)
                                    {
                                        str.AppendFormat("\nslot:{0,-3} level:{1,-2} value1:0x{2:X2} value2:0x{3:X2} hand:0x{4:X2} damageType:0x{5:X2} objectType:0x{6:X2} weight:{7,-4} con:{8,-3} dur:{9,-3} qual:{10,-3} bonus:{11,-2} model:0x{12:X4} color:0x{13:X4} effect:0x{14:X2} \"{15}\"",
                                                         item.slot, item.level, item.value1, item.value2, item.hand, item.damageType, item.objectType, item.weight, item.condition, item.durability, item.quality, item.bonus, item.model, item.color, item.effect, item.name);
                                        if (item.name != null && item.name != "")
                                        {
                                            str.AppendFormat(" ({0})", (StoC_0x02_InventoryUpdate.eObjectType)item.objectType);
                                        }
                                        str.Append("\n");
                                        slots.RemoveAt(slotIndex);
                                        break;
                                    }
                                }
                                slotIndex++;
                            }while (slotIndex < slots.Count);
                            if (slots.Count == 0)
                            {
                                break;
                            }
                        }
                        if (slots.Count == 0)
                        {
                            break;
                        }
                    }
                }
                else if (originalPak is CtoS_0x41_UseNewQuestItem)
                {
                    if (pak is StoC_0x83_QuestUpdate_186)
                    {
                        StoC_0x83_QuestUpdate_186.NewQuestUpdate_186 newQuest = (pak as StoC_0x83_QuestUpdate_186).SubData as StoC_0x83_QuestUpdate_186.NewQuestUpdate_186;
                        if (newQuest != null && newQuest.index == (originalPak as CtoS_0x41_UseNewQuestItem).QuestIndex && newQuest.goalsCount > (ushort)slots[0])
                        {
                            StoC_0x02_InventoryUpdate.Item item = newQuest.goalItems[(ushort)slots[0]];
                            str.AppendFormat("\nslot:{0,-2} level:{1,-2} value1:0x{2:X2} value2:0x{3:X2} hand:0x{4:X2} damageType:0x{5:X2} objectType:0x{6:X2} weight:{7,-4} con:{8,-3} dur:{9,-3} qual:{10,-3} bonus:{11,-2} model:0x{12:X4} color:0x{13:X4} effect:0x{14:X2} flag:0x{15:X2} extension:{16} \"{17}\"",
                                             item.slot, item.level, item.value1, item.value2, item.hand, item.damageType, item.objectType, item.weight, item.condition, item.durability, item.quality, item.bonus, item.model, item.color, item.effect, item.flag, item.extension, item.name);
                            if (item.name != null && item.name != "")
                            {
                                str.AppendFormat(" ({0})", (StoC_0x02_InventoryUpdate.eObjectType)item.objectType);
                            }
                            if ((item.flag & 0x08) == 0x08)
                            {
                                str.AppendFormat("\n\t\teffectIcon:0x{0:X4}  effectName:\"{1}\"",
                                                 item.effectIcon, item.effectName);
                            }
                            if ((item.flag & 0x10) == 0x10)
                            {
                                str.AppendFormat("\n\t\teffectIcon2:0x{0:X4}  effectName2:\"{1}\"",
                                                 item.effectIcon2, item.effectName2);
                            }
                            break;
                        }
                    }
                }
            }

            InfoWindowForm infoWindow = new InfoWindowForm();

            infoWindow.Text   = "Use skill/Cast spell info (right click to close)";
            infoWindow.Width  = 800;
            infoWindow.Height = 200;
            infoWindow.InfoRichTextBox.Text = str.ToString();
            infoWindow.StartWindowThread();

            return(false);
        }
示例#7
0
        /// <summary>
        /// Activates a log action.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="selectedPacket">The selected packet.</param>
        /// <returns><c>true</c> if log data tab should be updated.</returns>
        public bool Activate(IExecutionContext context, PacketLocation selectedPacket)
        {
            PacketLog log           = context.LogManager.GetPacketLog(selectedPacket.LogIndex);
            int       selectedIndex = selectedPacket.PacketIndex;

            int    VisibleSlots = 0xFF;
            int    weaponSkill  = -1;
            double DPS          = -1;

            StoC_0x02_InventoryUpdate.Item[] weapons = new StoC_0x02_InventoryUpdate.Item[4];
            Packet charStats = null;

            for (int i = 0; i < selectedIndex; i++)
            {
                Packet pak = log[i];
                if (pak is StoC_0x16_VariousUpdate)
                {
                    StoC_0x16_VariousUpdate stat = (StoC_0x16_VariousUpdate)pak;
                    if (stat.SubCode == 5)
                    {
                        StoC_0x16_VariousUpdate.PlayerStateUpdate subData = (StoC_0x16_VariousUpdate.PlayerStateUpdate)stat.SubData;
                        DPS         = subData.weaponDamageHigh + 0.01 * subData.weaponDamageLow;
                        weaponSkill = (subData.weaponSkillHigh << 8) + subData.weaponSkillLow;
                    }
                }
                else if (pak is StoC_0xFB_CharStatsUpdate_175)
                {
                    if ((pak as StoC_0xFB_CharStatsUpdate_175).Flag != 0xFF)
                    {
                        charStats = pak;
                    }
                }
                else if (pak is StoC_0xFB_CharStatsUpdate)
                {
                    charStats = pak;
                }
                else if (pak is StoC_0x02_InventoryUpdate)
                {
                    StoC_0x02_InventoryUpdate invPack = (StoC_0x02_InventoryUpdate)pak;
                    if (invPack.PreAction == 1 || invPack.PreAction == 0)
                    {
                        VisibleSlots = invPack.VisibleSlots;
                        for (int j = 0; j < invPack.SlotsCount; j++)
                        {
                            StoC_0x02_InventoryUpdate.Item item = (StoC_0x02_InventoryUpdate.Item)invPack.Items[j];
                            switch (item.slot)
                            {
                            case 10:
                                weapons[0] = item;
//									Logger.Say(string.Format("{16:X2}\tslot:{0,-2} level:{1,-2} value1:0x{2:X2} value2:0x{3:X2} hand:0x{4:X2} damageType:0x{5:X2} objectType:0x{6:X2} weight:{7,-4} con:{8,-3} dur:{9,-3} qual:{10,-3} bonus:{11,-2} model:0x{12:X4} color:0x{13:X4} effect:0x{14:X2} \"{15}\"",
//									item.slot, item.level, item.value1, item.value2, item.hand, item.damageType, item.objectType, item.weight, item.condition, item.durability, item.quality, item.bonus, item.model, item.color, item.effect, item.name, invPack.VisibleSlots));
                                break;

                            case 11:
                                weapons[1] = item;
                                break;

                            case 12:
                                weapons[2] = item;
                                break;

                            case 13:
                                weapons[3] = item;
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }

            StringBuilder str = new StringBuilder();

            str.AppendFormat("Weapon damage = {0:0.00}\n", DPS);
            str.AppendFormat("Weapon skill  = {0}\n", weaponSkill);
            if (charStats != null)
            {
                str.Append(charStats.GetPacketDataString(true));
                str.AppendFormat("\n");
            }
            str.AppendFormat("\n");
            str.AppendFormat("Visible slots = 0x{0:X2}", VisibleSlots);
            str.AppendFormat("\n");
            //((VisibleSlots & 0x0F) == 0)
            string weaponName1 = "";
            string weaponName2 = "";

            for (int i = 0; i < 4; i++)
            {
                if ((i == (VisibleSlots & 0x0F)) || (i == ((VisibleSlots >> 4) & 0x0F)))
                {
                    StoC_0x02_InventoryUpdate.Item item = (StoC_0x02_InventoryUpdate.Item)weapons[i];
//					str.AppendFormat("slot:{0,-2} level:{1,-2} value1:0x{2:X2} value2:0x{3:X2} hand:0x{4:X2} damageType:0x{5:X2} objectType:0x{6:X2} weight:{7,-4} con:{8,-3} dur:{9,-3} qual:{10,-3} bonus:{11,-2} model:0x{12:X4} color:0x{13:X4} effect:0x{14:X2} \"{15}\"\n",
//					item.slot, item.level, item.value1, item.value2, item.hand, item.damageType, item.objectType, item.weight, item.condition, item.durability, item.quality, item.bonus, item.model, item.color, item.effect, item.name);
                    if (item.objectType == 42)                    //shield
                    {
                        str.AppendFormat("slot:{0,-2} level:{1,-2} size:{2} con:{3,-3} qual:{4,-3} bonus:{5,-2} model:0x{6:X4} \"{7}\"",
                                         item.slot, item.level, item.value1, item.condition, item.quality, item.bonus, item.model, item.name);
                    }
                    else
                    {
                        str.AppendFormat("slot:{0,-2} level:{1,-2} dps:{2:0.00} spd:{3:0.00} damageType:{4} con:{5,-3} qual:{6,-3} bonus:{7,-2} model:0x{8:X4} \"{9}\"",
                                         item.slot, item.level, 0.1 * item.value1, 0.1 * item.value2, item.damageType, item.condition, item.quality, item.bonus, item.model, item.name);
                    }
                    str.AppendFormat(" ({0})\n", (StoC_0x02_InventoryUpdate.eObjectType)item.objectType);
                    if (weaponName1 == "")
                    {
                        weaponName1 = item.name;
                    }
                    else if (item.name != weaponName1)
                    {
                        weaponName2 = item.name;
                    }
                }
            }

            for (int i = 0; i < log.Count; i++)
            {
                if (weaponName1 == "" && weaponName2 == "")
                {
                    break;
                }
                Packet pak = log[i];
                if (pak is StoC_0xC4_CustomTextWindow)
                {
                    if (weaponName1 != "" && (pak as StoC_0xC4_CustomTextWindow).Caption == weaponName1)
                    {
                        str.Append('\n');
                        str.Append(pak.GetPacketDataString(true));
                        weaponName1 = "";
                    }
                    else if (weaponName2 != "" && (pak as StoC_0xC4_CustomTextWindow).Caption == weaponName2)
                    {
                        str.Append('\n');
                        str.Append(pak.GetPacketDataString(true));
                        weaponName2 = "";
                    }
                }
            }

            InfoWindowForm infoWindow = new InfoWindowForm();

            infoWindow.Text  = "Player weapon info (right click to close)";
            infoWindow.Width = 800;
            if (charStats == null)
            {
                infoWindow.Height = 300;
            }
            else
            {
                infoWindow.Height = 400;
            }
            infoWindow.InfoRichTextBox.Text = str.ToString();
            infoWindow.StartWindowThread();

            return(false);
        }