From 5e8509c62a7f917a2f145090ecc0c7a217da9424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=97=E6=B2=A2=E5=93=8D=E4=B9=9F?= <72963826+Hibiya615@users.noreply.github.com> Date: Wed, 26 Nov 2025 03:34:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=88=9E=E8=80=85=E8=88=9E?= =?UTF-8?q?=E6=AD=A5=E6=8A=80=E8=83=BD=E8=8C=83=E5=9B=B4=E7=BB=98=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 00-Other/ActionArea.cs | 229 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 229 insertions(+) diff --git a/00-Other/ActionArea.cs b/00-Other/ActionArea.cs index 0e4f947..d905787 100644 --- a/00-Other/ActionArea.cs +++ b/00-Other/ActionArea.cs @@ -1,6 +1,235 @@ +using System; +using System.ComponentModel; +using System.Linq; +using System.Numerics; +using System.Collections.Generic; +using Newtonsoft.Json; +using Dalamud.Utility.Numerics; +using KodakkuAssist.Script; +using KodakkuAssist.Module.GameEvent; +using KodakkuAssist.Module.Draw; +using KodakkuAssist.Data; +using System.Threading.Tasks; + namespace TetoraKodakkuScript._00_Other; +[ScriptType(guid: "f85df3b8-baa4-42b7-8196-bc26c58fa251", name: "技能范围", territorys: [], + version: "0.0.0.1", author: "Tetora", note: noteStr)] + public class ActionArea { + const string noteStr = + """ + v0.0.0.1: + 技能范围绘制,全场景可用 + 请先自行设置合适亮度并用任意技能测试 + """; + #region 用户控制 + + [UserSetting("常驻AOE技能绘制一键开关")] + public bool isPersistentAoEs { get; set; } = true; + + [UserSetting("常驻AOE技能颜色")] + public ScriptColor PersistentAoEsColor { get; set; } = new() { V4 = new(0f, 1f, 1f, 2f) }; + + [UserSetting("常驻AOE描边亮度(推荐10以上)")] + public float PersistentOutlineBrightness { get; set; } = 15; + + [UserSetting("常驻AOE填充亮度(推荐小于1)")] + public double PersistentFillBrightness { get; set; } = 0.3; + + [UserSetting("其它AOE技能颜色")] + public ScriptColor ActionAoEsColor { get; set; } = new() { V4 = new(0f, 1f, 0f, 1f) }; + + [UserSetting("其它AOE描边亮度(推荐10以上)")] + public float ActionOutlineBrightness { get; set; } = 15; + + [UserSetting("其它AOE填充亮度(推荐小于1)")] + public float ActionFillBrightness { get; set; } = 0.3f; + + [UserSetting("选择描边绘制类型")] + public BlendModeEnum BlendMode { get; set; } = BlendModeEnum.Default; + + private static List _BlendMode = ["VFX", "Imgui"]; + + public enum BlendModeEnum + { + Default = 0, + VFX = 1, + Imgui = 2, + } + + #endregion + + [ScriptMethod(name: "[描边] 标准舞步", eventType: EventTypeEnum.StatusAdd, eventCondition: ["StatusID:1818"])] + public void 标准舞步描边 (Event @event, ScriptAccessory accessory) + { + if (@event.TargetId() != accessory.Data.Me) return; + var dp = accessory.Data.GetDefaultDrawProperties(); + dp.Name = "标准舞步描边"; + dp.Color = ActionAoEsColor.V4.WithW(ActionOutlineBrightness); + dp.Owner = @event.SourceId(); + dp.Scale = new Vector2(15f); + dp.InnerScale = new Vector2(14.97f); + dp.Radian = float.Pi * 2; + dp.DestoryAt = 15000; + accessory.Method.SendDraw(DrawModeEnum.Default, DrawTypeEnum.Donut, dp); + } + + [ScriptMethod(name: "[填充] 标准舞步", eventType: EventTypeEnum.StatusAdd, eventCondition: ["StatusID:1818"])] + public void 标准舞步填充 (Event @event, ScriptAccessory accessory) + { + if (@event.TargetId() != accessory.Data.Me) return; + var dp = accessory.Data.GetDefaultDrawProperties(); + dp.Name = "标准舞步填充"; + dp.Color = ActionAoEsColor.V4.WithW(ActionFillBrightness); + dp.Owner = @event.SourceId(); + dp.Scale = new Vector2(15f); + dp.DestoryAt = 15000; + accessory.Method.SendDraw(DrawModeEnum.Default, DrawTypeEnum.Circle, dp); + } + + [ScriptMethod(name: "标准舞步销毁", eventType: EventTypeEnum.StatusRemove, eventCondition: ["StatusID:1818"],userControl: false)] + public void 标准舞步销毁 (Event @event, ScriptAccessory accessory) + { + accessory.Method.RemoveDraw($"标准舞步.*"); + } + +} + +public static class EventExtensions +{ + private static bool ParseHexId(string? idStr, out uint id) + { + id = 0; + if (string.IsNullOrEmpty(idStr)) return false; + try + { + var idStr2 = idStr.Replace("0x", ""); + id = uint.Parse(idStr2, System.Globalization.NumberStyles.HexNumber); + return true; + } + catch (Exception) + { + return false; + } + } + + public static uint ActionId(this Event @event) + { + return JsonConvert.DeserializeObject(@event["ActionId"]); + } + + public static uint SourceId(this Event @event) + { + return ParseHexId(@event["SourceId"], out var id) ? id : 0; + } + + public static uint SourceDataId(this Event @event) + { + return JsonConvert.DeserializeObject(@event["SourceDataId"]); + } + + public static uint Command(this Event @event) + { + return ParseHexId(@event["Command"], out var cid) ? cid : 0; + } + + public static uint DurationMilliseconds(this Event @event) + { + return JsonConvert.DeserializeObject(@event["DurationMilliseconds"]); + } + + public static float SourceRotation(this Event @event) + { + return JsonConvert.DeserializeObject(@event["SourceRotation"]); + } + + public static float TargetRotation(this Event @event) + { + return JsonConvert.DeserializeObject(@event["TargetRotation"]); + } + + public static byte Index(this Event @event) + { + return (byte)(ParseHexId(@event["Index"], out var index) ? index : 0); + } + + public static uint State(this Event @event) + { + return ParseHexId(@event["State"], out var state) ? state : 0; + } + + public static string SourceName(this Event @event) + { + return @event["SourceName"]; + } + + public static string TargetName(this Event @event) + { + return @event["TargetName"]; + } + + public static uint TargetId(this Event @event) + { + return ParseHexId(@event["TargetId"], out var id) ? id : 0; + } + + public static Vector3 SourcePosition(this Event @event) + { + return JsonConvert.DeserializeObject(@event["SourcePosition"]); + } + + public static Vector3 TargetPosition(this Event @event) + { + return JsonConvert.DeserializeObject(@event["TargetPosition"]); + } + + public static Vector3 EffectPosition(this Event @event) + { + return JsonConvert.DeserializeObject(@event["EffectPosition"]); + } + + public static uint DirectorId(this Event @event) + { + return ParseHexId(@event["DirectorId"], out var id) ? id : 0; + } + + public static uint StatusId(this Event @event) + { + return JsonConvert.DeserializeObject(@event["StatusId"]); + } + + public static uint StackCount(this Event @event) + { + return JsonConvert.DeserializeObject(@event["StackCount"]); + } + + public static uint Param(this Event @event) + { + return JsonConvert.DeserializeObject(@event["Param"]); + } +} +public static class MathHelpers +{ + public static float DegToRad(float degrees) + { + return degrees * (float)(Math.PI / 180.0); + } + + public static double DegToRad(double degrees) + { + return degrees * Math.PI / 180.0; + } + + public static float RadToDeg(float radians) + { + return radians * (float)(180.0 / Math.PI); + } + + public static double RadToDeg(double radians) + { + return radians * 180.0 / Math.PI; + } } \ No newline at end of file