From 804f5b767b9f25984b49b726e0f7c9df7d381327 Mon Sep 17 00:00:00 2001 From: goaaats Date: Thu, 31 Mar 2022 14:29:53 +0200 Subject: [PATCH] feat: more april fools work --- Dalamud/Dalamud.cs | 1 + Dalamud/Fools22.cs | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/Dalamud/Dalamud.cs b/Dalamud/Dalamud.cs index 4ad19e5fa..691a541ef 100644 --- a/Dalamud/Dalamud.cs +++ b/Dalamud/Dalamud.cs @@ -274,6 +274,7 @@ namespace Dalamud try { + Log.Information("Loading fools22"); this.fools22 = new Fools22(); } catch (Exception ex) diff --git a/Dalamud/Fools22.cs b/Dalamud/Fools22.cs index c384f3641..2de81bc1a 100644 --- a/Dalamud/Fools22.cs +++ b/Dalamud/Fools22.cs @@ -3,12 +3,14 @@ using System.Diagnostics; using System.IO; using System.Media; using System.Numerics; +using System.Threading.Tasks; using Dalamud.Configuration.Internal; using Dalamud.Data; using Dalamud.Game; using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.Gui; +using Dalamud.Game.Network; using Dalamud.Game.Text; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Interface; @@ -20,6 +22,7 @@ using ImGuiNET; using ImGuiScene; using Lumina.Excel.GeneratedSheets; using Serilog; + using Condition = Dalamud.Game.ClientState.Conditions.Condition; namespace Dalamud; @@ -29,6 +32,7 @@ public class Fools22 : IDisposable private readonly TextureWrap erDeathBgTexture; private readonly TextureWrap erNormalDeathTexture; private readonly TextureWrap erCraftFailedTexture; + private readonly TextureWrap erEnemyFelledTexture; private readonly string synthesisFailsMessage; @@ -53,6 +57,7 @@ public class Fools22 : IDisposable { DeathType.Death => this.erNormalDeathTexture, DeathType.CraftFailed => this.erCraftFailedTexture, + DeathType.EnemyFelled => this.erEnemyFelledTexture, }; private enum AnimationState @@ -67,6 +72,7 @@ public class Fools22 : IDisposable { Death, CraftFailed, + EnemyFelled, } public Fools22() @@ -76,10 +82,12 @@ public class Fools22 : IDisposable var framework = Service.Get(); var chatGui = Service.Get(); var dataMgr = Service.Get(); + var gameNetwork = Service.Get(); this.erDeathBgTexture = interfaceManager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "fools22", "er_death_bg.png"))!; this.erNormalDeathTexture = interfaceManager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "fools22", "er_normal_death.png"))!; this.erCraftFailedTexture = interfaceManager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "fools22", "er_craft_failed.png"))!; + this.erEnemyFelledTexture = interfaceManager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "fools22", "er_enemy_felled.png"))!; var soundBytes = File.ReadAllBytes(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "fools22", "snd_death_er.wav")); this.player = new SoundPlayer(new MemoryStream(soundBytes)); @@ -97,6 +105,24 @@ public class Fools22 : IDisposable interfaceManager.Draw += this.Draw; framework.Update += this.FrameworkOnUpdate; chatGui.ChatMessage += this.ChatGuiOnChatMessage; + gameNetwork.NetworkMessage += this.GameNetworkOnNetworkMessage; + } + + private unsafe void GameNetworkOnNetworkMessage(IntPtr dataptr, ushort opcode, uint sourceactorid, uint targetactorid, NetworkMessageDirection direction) + { + if (opcode != 0x301) + return; + + var cat = *(ushort*)(dataptr + 0x00); + var updateType = *(uint*)(dataptr + 0x08); + + if (cat == 0x6D && updateType == 0x40000003) + { + Task.Delay(1000).ContinueWith(t => + { + this.PlayAnimation(DeathType.EnemyFelled); + }); + } } private void ChatGuiOnChatMessage(XivChatType type, uint senderid, ref SeString sender, ref SeString message, ref bool ishandled) @@ -137,6 +163,14 @@ public class Fools22 : IDisposable this.PlayAnimation(DeathType.CraftFailed); } + if (ImGui.Button("play enemy felled")) + { + Task.Delay(1000).ContinueWith(t => + { + this.PlayAnimation(DeathType.EnemyFelled); + }); + } + ImGui.InputInt("fade in time", ref this.msFadeInTime); ImGui.InputInt("fade out time", ref this.msFadeOutTime); ImGui.InputInt("wait time", ref this.msWaitTime);