From abe3ffa7dd8d3f7d16056895bee69fc3d0c92663 Mon Sep 17 00:00:00 2001 From: 9451589 <109340072+9451589@users.noreply.github.com> Date: Sat, 13 Aug 2022 23:00:06 -0700 Subject: [PATCH 1/3] fix a couple fields actually not 100% sure on u64_1 and InstanceId in StatusEffectData.cs --- LostArkLogger/Packets/Steam/NpcStruct.cs | 8 ++++---- LostArkLogger/Packets/Steam/StatusEffectData.cs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/LostArkLogger/Packets/Steam/NpcStruct.cs b/LostArkLogger/Packets/Steam/NpcStruct.cs index 01bc89bf..c6bb9ec6 100644 --- a/LostArkLogger/Packets/Steam/NpcStruct.cs +++ b/LostArkLogger/Packets/Steam/NpcStruct.cs @@ -6,10 +6,10 @@ public partial class NpcStruct { public void SteamDecode(BitReader reader) { - u64_0 = reader.ReadUInt64(); + NpcId = reader.ReadUInt64(); b_0 = reader.ReadByte(); if (b_0 == 1) - NpcType = reader.ReadUInt32(); + u32_2 = reader.ReadUInt32(); b_11 = reader.ReadByte(); if (b_11 == 1) b_12 = reader.ReadByte(); @@ -40,7 +40,7 @@ public void SteamDecode(BitReader reader) b_6 = reader.ReadByte(); if (b_6 == 1) u32_0 = reader.ReadUInt32(); - NpcId = reader.ReadUInt64(); + u64_0 = reader.ReadUInt64(); b_7 = reader.ReadByte(); if (b_7 == 1) u16_0 = reader.ReadUInt16(); @@ -63,7 +63,7 @@ public void SteamDecode(BitReader reader) b_17 = reader.ReadByte(); if (b_17 == 1) u32_1 = reader.ReadUInt32(); - u32_2 = reader.ReadUInt32(); + NpcType = reader.ReadUInt32(); b_18 = reader.ReadByte(); u16_2 = reader.ReadUInt16(); statPair = reader.Read(); diff --git a/LostArkLogger/Packets/Steam/StatusEffectData.cs b/LostArkLogger/Packets/Steam/StatusEffectData.cs index 0a23cbbf..c4cc4c5b 100644 --- a/LostArkLogger/Packets/Steam/StatusEffectData.cs +++ b/LostArkLogger/Packets/Steam/StatusEffectData.cs @@ -6,7 +6,7 @@ public partial class StatusEffectData { public void SteamDecode(BitReader reader) { - SourceId = reader.ReadSimpleInt(); + u64_1 = reader.ReadSimpleInt(); bytearraylist_0 = reader.ReadList(7); hasValue = reader.ReadByte(); if (hasValue == 1) @@ -18,8 +18,8 @@ public void SteamDecode(BitReader reader) u64_0 = reader.ReadUInt64(); u32_0 = reader.ReadUInt32(); StatusEffectId = reader.ReadUInt32(); - u64_1 = reader.ReadUInt64(); InstanceId = reader.ReadUInt64(); + SourceId = reader.ReadUInt64(); SkillLevel = reader.ReadByte(); } } From 4f139ecf6950683ca8e195ffdf0c4aa6be68a2ad Mon Sep 17 00:00:00 2001 From: 9451589 <109340072+9451589@users.noreply.github.com> Date: Sat, 13 Aug 2022 23:05:53 -0700 Subject: [PATCH 2/3] Add Battle Item tracking --- LostArkLogger/Data/BattleItem.cs | 47 ++++++++++++++++++++++++++++++++ LostArkLogger/Data/Encounter.cs | 12 ++++++++ LostArkLogger/Data/LogInfo.cs | 1 + LostArkLogger/GUI/Overlay.cs | 2 ++ LostArkLogger/Parser.cs | 31 +++++++++++++++++++++ 5 files changed, 93 insertions(+) create mode 100644 LostArkLogger/Data/BattleItem.cs diff --git a/LostArkLogger/Data/BattleItem.cs b/LostArkLogger/Data/BattleItem.cs new file mode 100644 index 00000000..a3936ae4 --- /dev/null +++ b/LostArkLogger/Data/BattleItem.cs @@ -0,0 +1,47 @@ +using System.Collections.Generic; + +namespace LostArkLogger +{ + public class BattleItem + { + public static Dictionary Projectiles = new Dictionary() + { + {33200, "Pheromone Bomb" }, + {32000, "Flash Grenade" }, {32004, "Splendid Flash Grenade"}, + {32010, "Flame Grenade" }, {32016, "Splendid Flame Grenade"}, + {32020, "Frost Grenade" }, {23025, "Splendid Frost Grenade"}, + {32030, "Electric Grenade"}, {32035, "Splendid Lightening Grenade"}, + {32240, "Dark Grenade" }, {32244, "Splendid Dark Grenade" }, + {32260, "Corrosive Bomb" }, {32262, "Splendid Corrosive Bomb"}, + {32310, "Whirlwind Grenade"}, {32313, "Splendid Whirlwind Greande"}, + {32320, "Clay Grenade" }, {32325, "Splendid Clay Grenade"}, + {32350, "Sleep Bomb" }, {32352, "Splendid Sleep Bomb"}, + {32360, "Sacred Bomb" }, {32363, "Splendid Sleep Bomb"}, + {32140, "Destruction Bomb" }, {32142, "Splendid Destruction Bomb"} + }; + public static Dictionary Buffs = new Dictionary() + { + {32380, "Atropine Potion" }, + {32100, "Marching Flag" }, {32102, "Splendid Marching Flag"}, + {32270, "Protective Potion"}, {32271, "Splendid Protective Potion"}, + {32300, "Sprinter's Robe" }, {32301, "Splendid Sprinter's Robe" }, + {33500, "Time Stop Potion" }, + {32402, "Thunder Potion" }, {32403, "Splendid Thunder Potion"} + }; + + public static bool IsBattleItem(uint id, string type) + { + if (type == "projectile") return Projectiles.ContainsKey(id); + if (type == "buff") return Buffs.ContainsKey(id); + else return false; + } + + public static string GetBattleItemName(uint id) + { + if (Projectiles.ContainsKey(id)) + return Projectiles[id]; + else + return Buffs[id]; + } + } +} diff --git a/LostArkLogger/Data/Encounter.cs b/LostArkLogger/Data/Encounter.cs index b6f8a7ee..88d4f29d 100644 --- a/LostArkLogger/Data/Encounter.cs +++ b/LostArkLogger/Data/Encounter.cs @@ -89,5 +89,17 @@ public Dictionary> GetStatusEffect return grouped.Select(i => new KeyValuePair>(i.Key, Tuple.Create((UInt64)i.Sum(sum), (UInt32)i.Count(), (UInt32)i.Count(log => log.Crit), (UInt64)i.Sum(j => (Single)j.TimeAlive)))).ToDictionary(x => x.Key, x => x.Value); //return grouped.Select(i => new KeyValuePair(i.Key, (UInt64)i.Sum(j => (Single)j.Damage))).ToDictionary(x => x.Key, x => x.Value); } + + public Dictionary> GetBattleItems(Func sum, Entity entity = default(Entity)) + { + var baseSearch = Infos.Where(i => i.SourceEntity.Type == Entity.EntityType.Player).Where(i => i.BattleItem); + + IEnumerable> grouped; + if (entity != default(Entity)) + grouped = baseSearch.Where(i => i.SourceEntity == entity).GroupBy(i => i.SkillName); + else + grouped = baseSearch.GroupBy(i => i.SourceEntity.VisibleName); + return grouped.Select(i => new KeyValuePair>(i.Key, Tuple.Create((UInt64)i.Sum(sum), (UInt32)i.Count(), (UInt32)i.Count(log => log.Crit), (UInt64)i.Sum(j => (Single)j.TimeAlive)))).ToDictionary(x => x.Key, x => x.Value); + } } } diff --git a/LostArkLogger/Data/LogInfo.cs b/LostArkLogger/Data/LogInfo.cs index 07dd4781..e210cc6a 100644 --- a/LostArkLogger/Data/LogInfo.cs +++ b/LostArkLogger/Data/LogInfo.cs @@ -20,6 +20,7 @@ public class LogInfo public Boolean Counter { get; set; } public Boolean Death { get; set; } public TimeSpan Duration { get; set; } + public Boolean BattleItem { get; set; } public override string ToString() { return Time.ToString("yy:MM:dd:HH:mm:ss.f") + "," + diff --git a/LostArkLogger/GUI/Overlay.cs b/LostArkLogger/GUI/Overlay.cs index f5f24ad9..8c0176af 100644 --- a/LostArkLogger/GUI/Overlay.cs +++ b/LostArkLogger/GUI/Overlay.cs @@ -22,6 +22,7 @@ enum Level // need better state, suboverlay type/etc. TimeAlive, RaidTimeAlive, RaidDamage, + BattleItems, Max } enum Scope // need better state, suboverlay type/etc. @@ -197,6 +198,7 @@ protected override void OnPaint(PaintEventArgs e) else if (level == Level.Counterattacks) rows = encounter.Counterattacks.ToDictionary(x => x.Key, x => Tuple.Create(x.Value, 0u, 0u, 0ul)); else if (level == Level.Stagger) rows = encounter.Stagger.ToDictionary(x => x.Key, x => Tuple.Create(x.Value, 0u, 0u, 0ul)); else if (level == Level.TimeAlive) rows = encounter.TimeAlive.ToDictionary(x => x.Key, x => Tuple.Create(x.Value, 0u, 0u, 0ul)); + else if (level == Level.BattleItems) rows = encounter.GetBattleItems((i => i.BattleItem ? 1 : 0), SubEntity); else if (level == Level.RaidTimeAlive) { rows = encounter.RaidTimeAlive.ToDictionary(x => x.Key, x => Tuple.Create(x.Value, 0u, 0u, 0ul)); diff --git a/LostArkLogger/Parser.cs b/LostArkLogger/Parser.cs index b7daeac2..f9458d81 100644 --- a/LostArkLogger/Parser.cs +++ b/LostArkLogger/Parser.cs @@ -288,6 +288,22 @@ void ProcessPacket(List data) EntityId = projectile.ProjectileId, Type = Entity.EntityType.Projectile }); + var battleitem = BattleItem.IsBattleItem(projectile.SkillId, "projectile"); + if (battleitem) + { + Entity entity = currentEncounter.Entities.GetOrAdd(projectile.OwnerId); + var log = new LogInfo + { + Time = DateTime.Now, + SourceEntity = entity, + DestinationEntity = entity, //projectiles don't have destination, but can't be null causes exception getting encounter name + SkillName = BattleItem.GetBattleItemName(projectile.SkillId), + SkillId = projectile.SkillId, + BattleItem = battleitem + }; + currentEncounter.Infos.Add(log); + Logger.AppendLog(15, projectile.OwnerId.ToString("X"), entity.Name, projectile.SkillId.ToString(), Skill.GetSkillName(projectile.SkillId)); + } } else if (opcode == OpCodes.PKTInitEnv) { @@ -523,6 +539,21 @@ 5 on suc 6 on fail else if (opcode == OpCodes.PKTStatusEffectAddNotify) // shields included { var statusEffect = new PKTStatusEffectAddNotify(new BitReader(payload)); + var battleItem = BattleItem.IsBattleItem(statusEffect.statusEffectData.StatusEffectId, "buff"); + if (battleItem) + { + var log = new LogInfo + { + Time = DateTime.Now, + SourceEntity = currentEncounter.Entities.GetOrAdd(statusEffect.statusEffectData.SourceId), + DestinationEntity = currentEncounter.Entities.GetOrAdd(statusEffect.ObjectId), + SkillId = statusEffect.statusEffectData.StatusEffectId, + SkillName = BattleItem.GetBattleItemName(statusEffect.statusEffectData.StatusEffectId), + BattleItem = battleItem + }; + currentEncounter.Infos.Add(log); + Logger.AppendLog(15, statusEffect.statusEffectData.SourceId.ToString("X"), currentEncounter.Entities.GetOrAdd(statusEffect.statusEffectData.SourceId).Name, statusEffect.statusEffectData.StatusEffectId.ToString(), SkillBuff.GetSkillBuffName(statusEffect.statusEffectData.StatusEffectId)); + } statusEffectTracker.Add(statusEffect); var amount = statusEffect.statusEffectData.hasValue == 1 ? BitConverter.ToUInt32(statusEffect.statusEffectData.Value, 0) : 0; } From c8650bd22b1a5abece32b4ddb2fa9f2045d481ca Mon Sep 17 00:00:00 2001 From: 9451589 <109340072+9451589@users.noreply.github.com> Date: Sat, 13 Aug 2022 23:34:41 -0700 Subject: [PATCH 3/3] fix battle item names in log --- LostArkLogger/Parser.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LostArkLogger/Parser.cs b/LostArkLogger/Parser.cs index f9458d81..96df611f 100644 --- a/LostArkLogger/Parser.cs +++ b/LostArkLogger/Parser.cs @@ -302,7 +302,7 @@ void ProcessPacket(List data) BattleItem = battleitem }; currentEncounter.Infos.Add(log); - Logger.AppendLog(15, projectile.OwnerId.ToString("X"), entity.Name, projectile.SkillId.ToString(), Skill.GetSkillName(projectile.SkillId)); + Logger.AppendLog(15, projectile.OwnerId.ToString("X"), entity.Name, projectile.SkillId.ToString(), BattleItem.GetBattleItemName(projectile.SkillId)); } } else if (opcode == OpCodes.PKTInitEnv) @@ -552,7 +552,7 @@ 5 on suc 6 on fail BattleItem = battleItem }; currentEncounter.Infos.Add(log); - Logger.AppendLog(15, statusEffect.statusEffectData.SourceId.ToString("X"), currentEncounter.Entities.GetOrAdd(statusEffect.statusEffectData.SourceId).Name, statusEffect.statusEffectData.StatusEffectId.ToString(), SkillBuff.GetSkillBuffName(statusEffect.statusEffectData.StatusEffectId)); + Logger.AppendLog(15, statusEffect.statusEffectData.SourceId.ToString("X"), currentEncounter.Entities.GetOrAdd(statusEffect.statusEffectData.SourceId).Name, statusEffect.statusEffectData.StatusEffectId.ToString(), BattleItem.GetBattleItemName(statusEffect.statusEffectData.StatusEffectId)); } statusEffectTracker.Add(statusEffect); var amount = statusEffect.statusEffectData.hasValue == 1 ? BitConverter.ToUInt32(statusEffect.statusEffectData.Value, 0) : 0;