/// <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_0xBB_UseSkill || originalPak is CtoS_0x7D_UseSpellList || originalPak is CtoS_0xD8_DetailDisplayRequest)) // activate condition { return(false); } int spellIndex = -1; int spellLineIndex = -1; if (originalPak is CtoS_0xBB_UseSkill) { spellIndex = (originalPak as CtoS_0xBB_UseSkill).Index; } else if (originalPak is CtoS_0x7D_UseSpellList) { spellLineIndex = (originalPak as CtoS_0x7D_UseSpellList).SpellLineIndex; spellIndex = (originalPak as CtoS_0x7D_UseSpellList).SpellLevel; } else if (originalPak is CtoS_0xD8_DetailDisplayRequest) { switch ((originalPak as CtoS_0xD8_DetailDisplayRequest).ObjectType) { case 2: spellLineIndex = (originalPak as CtoS_0xD8_DetailDisplayRequest).ObjectId / 100; spellIndex = (originalPak as CtoS_0xD8_DetailDisplayRequest).ObjectId % 100; break; default: return(false); } } else { return(false); } StringBuilder str = new StringBuilder(); IList skillList = new ArrayList(); int additionStringCount = 0; ushort spellIcon = 0xFFFF; string spellName = "UNKNOWN"; bool searchInSpellEffects = false; str.Append(originalPak.ToHumanReadableString(TimeSpan.Zero, true)); str.Append('\n'); for (int i = selectedIndex; i >= 0; i--) { Packet pak = log[i]; if (pak is StoC_0x16_VariousUpdate) { StoC_0x16_VariousUpdate variousPak = (pak as StoC_0x16_VariousUpdate); if (originalPak is CtoS_0xBB_UseSkill) { if (variousPak.SubCode == 1) { StoC_0x16_VariousUpdate.SkillsUpdate data = (variousPak.SubData as StoC_0x16_VariousUpdate.SkillsUpdate); for (int j = variousPak.SubCount - 1; j >= 0; j--) { StoC_0x16_VariousUpdate.Skill skill = data.data[j]; if ((originalPak as CtoS_0xBB_UseSkill).Type == 0 && (int)skill.page == 0) { skillList.Add(skill); } else if ((originalPak as CtoS_0xBB_UseSkill).Type == 1 && (int)skill.page > 0) { skillList.Add(skill); } } if (variousPak.StartIndex == 0) { int index = skillList.Count; int lineIndex = -1; string skillInfo = ""; foreach (StoC_0x16_VariousUpdate.Skill skill in skillList) { index--; if (index == spellIndex) { if (skill.page == StoC_0x16_VariousUpdate.eSkillPage.Spells && skill.stlOpen != 0xFE) { lineIndex = skill.stlOpen; } if (log.Version >= 180) { if (skill.page == StoC_0x16_VariousUpdate.eSkillPage.Styles) { str.AppendFormat("\nSpec:\"{0}\"", GetSpecNameFromInternalIndex(skill.bonus)); } } skillInfo = string.Format("\nlevel:{0,-2} type:{1}({2,-14}) stlOpen:0x{3:X4} bonus:{4,-2} icon:0x{5:X4} name:\"{6}\"\n", skill.level, (int)skill.page, skill.page.ToString().ToLower(), skill.stlOpen, skill.bonus, skill.icon, skill.name); spellIcon = skill.icon; spellName = skill.name; additionStringCount += 2; searchInSpellEffects = skill.page == StoC_0x16_VariousUpdate.eSkillPage.RealmAbilities || skill.page == StoC_0x16_VariousUpdate.eSkillPage.Spells || skill.page == StoC_0x16_VariousUpdate.eSkillPage.Songs; break; } } if (lineIndex >= 0) { index = 0; foreach (StoC_0x16_VariousUpdate.Skill skill in data.data) { if (skill.page == StoC_0x16_VariousUpdate.eSkillPage.Specialization) { if (index++ == lineIndex) { str.AppendFormat("\nSpec:\"{0}\"", skill.name); // str.AppendFormat("\nlevel:{0,-2} type:{1}({2,-14}) stlOpen:0x{3:X4} bonus:{4,-2} icon:0x{5:X4} name:\"{6}\"\n", // skill.level, (int)skill.page, skill.page.ToString().ToLower(), skill.stlOpen, skill.bonus, skill.icon, skill.name); break; } } else { break; } } } str.Append(skillInfo); break; } } } else if (spellLineIndex >= 0) { if (variousPak.SubCode == 2) { StoC_0x16_VariousUpdate.SpellsListUpdate data = (variousPak.SubData as StoC_0x16_VariousUpdate.SpellsListUpdate); if (variousPak.StartIndex == spellLineIndex) { string spellLineName = ""; for (int j = 0; j < variousPak.SubCount; j++) { StoC_0x16_VariousUpdate.Spell spell = data.list[j]; if (spell.level == spellIndex) { str.AppendFormat("\nspellLineIndex:{0}(\"{4}\") spellLevel:{1,-2} icon:0x{2:X4} name:\"{3}\"\n", spellLineIndex, spell.level, spell.icon, spell.name, spellLineName); spellIcon = spell.icon; spellName = spell.name; searchInSpellEffects = true; additionStringCount += 2; break; } else if (spell.level == 0) { spellLineName = spell.name; } } } if (variousPak.SubType == 2 && variousPak.StartIndex == 0) // not this spell found in spellList { break; } } } } } if (searchInSpellEffects) { bool spellEffectFound = false; bool concEffectFound = false; for (int i = selectedIndex; i < log.Count; i++) { Packet pak = log[i]; if (pak is StoC_0x7F_UpdateIcons) { if (spellEffectFound) { continue; } StoC_0x7F_UpdateIcons effectsPak = (pak as StoC_0x7F_UpdateIcons); if (effectsPak != null) { for (int j = 0; j < effectsPak.EffectsCount; j++) { if (effectsPak.Effects[j].name == spellName) { StoC_0x7F_UpdateIcons.Effect effect = effectsPak.Effects[j]; str.Append('\n'); str.Append(pak.ToHumanReadableString(TimeSpan.Zero, true)); str.Append('\n'); spellIcon = effect.icon; additionStringCount += (2 + effectsPak.EffectsCount); spellEffectFound = true; break; } } if (spellEffectFound && concEffectFound) { break; } } } else if (pak is StoC_0x75_SetConcentrationList) { if (concEffectFound) { continue; } if (spellIcon != 0xFFFF) { StoC_0x75_SetConcentrationList concPak = (pak as StoC_0x75_SetConcentrationList); if (concPak != null) { for (int j = 0; j < concPak.EffectsCount; j++) { if (concPak.Effects[j].icon == spellIcon) { // if (concPak.Effects[j].effectName.Substring(10) != spellName.Substring(10)) continue; StoC_0x75_SetConcentrationList.ConcentrationEffect effect = concPak.Effects[j]; str.AppendFormat("\nCONC index:{0,-2} conc:{1,-2} icon:0x{2:X4} ownerName:\"{3}\" effectName:\"{4}\"", effect.index, effect.concentration, effect.icon, effect.ownerName, effect.effectName); str.Append('\n'); additionStringCount += (2 + concPak.EffectsCount); concEffectFound = true; break; } } if (/*spellEffectFound && */ concEffectFound) // conc packet always after effect packet, so we can break on conc packet { break; } } } } } } if (spellName != "UNKNOWN") { additionStringCount += FormInfoString(log, selectedIndex, str, spellIcon, spellName); } InfoWindowForm infoWindow = new InfoWindowForm(); infoWindow.Text = "Use skill/Cast spell info (right click to close)"; infoWindow.Width = 800; infoWindow.Height = 100; infoWindow.Height += 14 * additionStringCount; infoWindow.InfoRichTextBox.Text = str.ToString(); infoWindow.StartWindowThread(); return(false); }
/// <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; StoC_0x7F_UpdateIcons.Effect[] effects = new StoC_0x7F_UpdateIcons.Effect[40]; StoC_0x75_SetConcentrationList concPak = null; for (int i = 0; i <= selectedIndex; i++) { Packet pak = log[i]; if (pak is StoC_0x7F_UpdateIcons) { StoC_0x7F_UpdateIcons.Effect[] listeffects = (pak as StoC_0x7F_UpdateIcons).Effects; for (int j = 0; j < listeffects.Length; j++) { effects[listeffects[j].iconIndex] = listeffects[j]; } } else if (pak is StoC_0x75_SetConcentrationList) { concPak = pak as StoC_0x75_SetConcentrationList; } } StringBuilder str = new StringBuilder(); for (int i = 0; i < effects.Length; i++) { StoC_0x7F_UpdateIcons.Effect effect = effects[i]; if (effect.name != null && effect.name != "") { str.AppendFormat("iconIndex:{0,-2} {6} immunity:0x{1:X2} icon:0x{2:X4} remainingTime:{3,-4} internalId:{4,-5} name:\"{5}\"\n", effect.iconIndex, effect.immunity, effect.icon, (short)effect.remainingTime, effect.internalId, effect.name, effect.unk1 == 0xFF ? "SKL" : "SPL"); } } if (concPak != null && concPak.EffectsCount > 0) { str.Append("\n"); str.Append(concPak.ToString()); str.Append(concPak.GetPacketDataString(true)); } StoC_0x16_VariousUpdate.Skill[] Skills = null; for (int i = selectedIndex; i >= 0; i--) { Packet pak = log[i]; if (pak is StoC_0x16_VariousUpdate) { StoC_0x16_VariousUpdate skills = (pak as StoC_0x16_VariousUpdate); if (skills.SubCode == 1) { if (Skills == null) { Skills = new StoC_0x16_VariousUpdate.Skill[skills.StartIndex + skills.SubCount]; } int j = skills.StartIndex; foreach (StoC_0x16_VariousUpdate.Skill skill in skills.InSkillsUpdate.data) { Skills[j++] = skill; } if (skills.StartIndex == 0) { break; } } } } int index = -1; if (effects.Length > 0) { str.Append("\n"); } if (Skills != null) { if (Skills.Length > 0) { str.Append("Skills:"); } foreach (StoC_0x16_VariousUpdate.Skill skill in Skills) { str.Append("\n"); if (skill.page == StoC_0x16_VariousUpdate.eSkillPage.Styles && skill.stlOpen >= 0x6400) // 0x6400 = 100 << 8 { str.AppendFormat("*({0,-2})", (skill.stlOpen >> 8) - 100); } str.Append("\t"); if ((int)skill.page > 0) { index++; } str.AppendFormat("[{0,-2}] ", index); str.AppendFormat("level:{0,-2} type:{1}({2,-14}) stlOpen:0x{3:X4} bonus:{4,-3} icon:0x{5:X4} name:\"{6}\"", skill.level, (int)skill.page, skill.page.ToString().ToLower(), skill.stlOpen, skill.bonus, skill.icon, skill.name); } } InfoWindowForm infoWindow = new InfoWindowForm(); infoWindow.Text = "Player effects info (right click to close)"; infoWindow.Width = 820; infoWindow.Height = 320; infoWindow.InfoRichTextBox.Text = str.ToString(); infoWindow.StartWindowThread(); return(false); }