mirror of
https://github.com/Hibiya615/TetoraKAScript.git
synced 2026-11-05 22:37:04 +08:00
更新60植物园
This commit is contained in:
1 parent
3cef67c302
commit
e2af041a0b
1 file changed
+677
@@ -0,0 +1,677 @@
|
||||
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 KodakkuAssist.Extensions;
|
||||
using System.Threading.Tasks;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Object;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Character;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Intrinsics;
|
||||
using System.Collections.Generic;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Control;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.UI;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
|
||||
namespace SaintMociannesArboretum;
|
||||
|
||||
[ScriptType(guid: "3491ef10-6190-45e6-a3a7-b98fadc11948", name: "草木庭园圣茉夏娜植物园", territorys: [511],
|
||||
version: "0.0.0.1", author: "Tetora", note: noteStr)]
|
||||
|
||||
public class SaintMociannesArboretum
|
||||
{
|
||||
const string noteStr =
|
||||
"""
|
||||
v0.0.0.1:
|
||||
LV60 草木庭园圣茉夏娜植物园 初版绘制
|
||||
""";
|
||||
|
||||
#region 基础设置
|
||||
|
||||
[UserSetting("TTS开关(TTS请二选一开启)")] public bool isTTS { get; set; } = false;
|
||||
|
||||
[UserSetting("EdgeTTS开关(TTS请二选一开启)")] public bool isEdgeTTS { get; set; } = true;
|
||||
|
||||
[UserSetting("弹窗文本提示开关")] public bool isText { get; set; } = true;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 销毁绘制
|
||||
|
||||
[ScriptMethod(name: "咏唱中断销毁", eventType: EventTypeEnum.CancelAction, eventCondition: [], userControl: false)]
|
||||
public void 咏唱中断销毁(Event @event, ScriptAccessory accessory)
|
||||
{
|
||||
accessory.Method.RemoveDraw($".*{@event.SourceId()}");
|
||||
}
|
||||
|
||||
[ScriptMethod(name: "死亡销毁", eventType: EventTypeEnum.Death, eventCondition: [], userControl: false)]
|
||||
public void 死亡销毁(Event @event, ScriptAccessory accessory)
|
||||
{
|
||||
accessory.Method.RemoveDraw($".*{@event.TargetId()}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
[ScriptMethod(name: "小怪_叶小妖 灵水(顺劈高亮)", eventType: EventTypeEnum.StartCasting, eventCondition: ["ActionId:5355"])]
|
||||
public void 叶小妖_灵水(Event @event, ScriptAccessory accessory)
|
||||
{
|
||||
var dp = accessory.Data.GetDefaultDrawProperties();
|
||||
dp.Name = $"叶小妖_灵水{@event.SourceId}";
|
||||
dp.Color = accessory.Data.DefaultDangerColor.WithW(3f);
|
||||
dp.Owner = @event.SourceId();
|
||||
dp.Scale = new Vector2(6f); // 5m范围 + 1m目标圈
|
||||
dp.Radian = MathHelpers.DegToRad(60f);
|
||||
dp.DestoryAt = 4700;
|
||||
accessory.Method.SendDraw(DrawModeEnum.Default, DrawTypeEnum.Fan, dp);
|
||||
}
|
||||
|
||||
[ScriptMethod(name: "小怪_鹰蜂工蜂 未终针(直线高亮)", eventType: EventTypeEnum.StartCasting, eventCondition: ["ActionId:4526"])]
|
||||
public void 未终针(Event @event, ScriptAccessory accessory)
|
||||
{
|
||||
var dp = accessory.Data.GetDefaultDrawProperties();
|
||||
dp.Name = $"未终针{@event.SourceId}";
|
||||
dp.Owner = @event.SourceId();
|
||||
dp.Color = accessory.Data.DefaultDangerColor.WithW(2f);
|
||||
dp.Scale = new (3f, 9.1f); // 8m + 目标圈1.1m
|
||||
dp.DestoryAt = 2700;
|
||||
accessory.Method.SendDraw(DrawModeEnum.Default, DrawTypeEnum.Rect, dp);
|
||||
}
|
||||
|
||||
[ScriptMethod(name: "小怪_奥恩黄蜂 终极针 死刑提示", eventType: EventTypeEnum.StartCasting, eventCondition: ["ActionId:2482"])]
|
||||
public void 终极针(Event @event, ScriptAccessory accessory)
|
||||
{
|
||||
if (isText)accessory.Method.TextInfo($"眩晕终极针", duration: 3300, true);
|
||||
if (isTTS)accessory.Method.TTS($"眩晕终极针");
|
||||
if (isEdgeTTS)accessory.Method.EdgeTTS($"眩晕终极针");
|
||||
|
||||
var dp = accessory.Data.GetDefaultDrawProperties();
|
||||
dp.Name = $"终极针{@event.SourceId}";
|
||||
dp.Color = accessory.Data.DefaultDangerColor.WithW(2f);
|
||||
dp.Owner = @event.SourceId();
|
||||
dp.Scale = new Vector2(1.1f);
|
||||
dp.DestoryAt = 3700;
|
||||
accessory.Method.SendDraw(DrawModeEnum.Default, DrawTypeEnum.Circle, dp);
|
||||
}
|
||||
|
||||
#region BOSS1_玫瑰园 / The Rosehouse
|
||||
|
||||
[ScriptMethod(name: "BOSS1_玫瑰园 恶臭气(中间毒池)", eventType: EventTypeEnum.StartCasting, eventCondition: ["ActionId:5230"])]
|
||||
public void 恶臭气中间(Event @event, ScriptAccessory accessory)
|
||||
{
|
||||
var dp = accessory.Data.GetDefaultDrawProperties();
|
||||
dp.Name = $"恶臭气中间{@event.SourceId}";
|
||||
dp.Color = accessory.Data.DefaultDangerColor.WithW(1.2f);
|
||||
dp.Owner = @event.SourceId();
|
||||
dp.Scale = new Vector2(5f);
|
||||
dp.DestoryAt = 21000;
|
||||
accessory.Method.SendDraw(DrawModeEnum.Default, DrawTypeEnum.Circle, dp);
|
||||
}
|
||||
|
||||
[ScriptMethod(name: "BOSS1_玫瑰园 恶臭气(持续顺劈)", eventType: EventTypeEnum.StartCasting, eventCondition: ["ActionId:5224"])]
|
||||
public void 恶臭气扇形(Event @event, ScriptAccessory accessory)
|
||||
{
|
||||
// 5230虽然是伤害源,但是需要用无意义读条5224绑定BOSS实体 以跟随旋转
|
||||
|
||||
var dp = accessory.Data.GetDefaultDrawProperties();
|
||||
dp.Name = $"恶臭气扇形{@event.SourceId}";
|
||||
dp.Color = accessory.Data.DefaultDangerColor.WithW(1.5f);
|
||||
dp.Owner = @event.SourceId();
|
||||
dp.Scale = new Vector2(29.8f); // 24m范围 + 5.8m目标圈
|
||||
dp.Radian = 90f.DegToRad();
|
||||
dp.DestoryAt = 21000;
|
||||
accessory.Method.SendDraw(DrawModeEnum.Default, DrawTypeEnum.Fan, dp);
|
||||
}
|
||||
|
||||
[ScriptMethod(name: "BOSS1_玫瑰花蕾 腐臭气(持续顺劈)", eventType: EventTypeEnum.StartCasting, eventCondition: ["ActionId:5316"])]
|
||||
public void 腐臭气(Event @event, ScriptAccessory accessory)
|
||||
{
|
||||
var dp = accessory.Data.GetDefaultDrawProperties();
|
||||
dp.Name = $"腐臭气{@event.SourceId}";
|
||||
dp.Color = accessory.Data.DefaultDangerColor.WithW(1.5f);
|
||||
dp.Owner = @event.SourceId();
|
||||
dp.Scale = new Vector2(7.6f); // 7m范围 3m宽? 目标圈0.9 但应为不可见的0.5释放
|
||||
dp.Radian = 32f.DegToRad(); // 实体疑似有略微角度误差
|
||||
dp.DestoryAt = 21000;
|
||||
accessory.Method.SendDraw(DrawModeEnum.Default, DrawTypeEnum.Fan, dp);
|
||||
}
|
||||
|
||||
[ScriptMethod(name: "BOSS1_玫瑰园 播种 击杀小怪提示", eventType: EventTypeEnum.ActionEffect, eventCondition: ["ActionId:5226"])]
|
||||
public void 播种(Event @event, ScriptAccessory accessory)
|
||||
{
|
||||
// if (isText)accessory.Method.TextInfo($"击杀小怪", duration: 3000, false);
|
||||
if (isTTS)accessory.Method.TTS($"击杀小怪");
|
||||
if (isEdgeTTS)accessory.Method.EdgeTTS($"击杀小怪");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BOSS2_鹰蜂女王 / queen hawk
|
||||
|
||||
[ScriptMethod(name: "BOSS2_鹰蜂女王 防御指示 击杀小怪提示", eventType: EventTypeEnum.StatusAdd, eventCondition: ["StatusID:152"])]
|
||||
public void 防御指示(Event @event, ScriptAccessory accessory)
|
||||
{
|
||||
// 会同时附加 152、153、443 三种buff,ActionId为 5233
|
||||
// if (isText)accessory.Method.TextInfo($"击杀小怪", duration: 2400, false);
|
||||
if (isTTS)accessory.Method.TTS($"击杀小怪");
|
||||
if (isEdgeTTS)accessory.Method.EdgeTTS($"击杀小怪");
|
||||
}
|
||||
|
||||
[ScriptMethod(name: "BOSS2_鹰蜂女王 协作指示-交叉火力(直线)", eventType: EventTypeEnum.StartCasting, eventCondition: ["ActionId:5243"])]
|
||||
public void 交叉火力(Event @event, ScriptAccessory accessory)
|
||||
{
|
||||
var dp = accessory.Data.GetDefaultDrawProperties();
|
||||
dp.Name = $"交叉火力";
|
||||
dp.Owner = @event.SourceId();
|
||||
dp.Color = accessory.Data.DefaultDangerColor;
|
||||
dp.Scale = new (14f, 50f);
|
||||
dp.DestoryAt = 3700;
|
||||
accessory.Method.SendDraw(DrawModeEnum.Default, DrawTypeEnum.Rect, dp);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BOSS3_剧毒美人 / Belladonna
|
||||
|
||||
[ScriptMethod(name: "BOSS3_剧毒美人 阿托品孢子 靠近提示", eventType: EventTypeEnum.StartCasting, eventCondition: ["ActionId:5215"])]
|
||||
public void 阿托品孢子(Event @event, ScriptAccessory accessory)
|
||||
{
|
||||
// if (isText)accessory.Method.TextInfo($"靠近BOSS", duration: 3000, false);
|
||||
if (isTTS)accessory.Method.TTS($"靠近BOSS");
|
||||
if (isEdgeTTS)accessory.Method.EdgeTTS($"靠近BOSS");
|
||||
}
|
||||
|
||||
[ScriptMethod(name: "BOSS3_剧毒美人 真空吸魂 AOE提示", eventType: EventTypeEnum.StartCasting, eventCondition: ["ActionId:5221"])]
|
||||
public void 真空吸魂(Event @event, ScriptAccessory accessory)
|
||||
{
|
||||
// if (isText)accessory.Method.TextInfo($"AOE", duration: 3000, false);
|
||||
if (isTTS)accessory.Method.TTS($"AOE");
|
||||
if (isEdgeTTS)accessory.Method.EdgeTTS($"AOE");
|
||||
}
|
||||
|
||||
[ScriptMethod(name: "BOSS3_剧毒美人 肿胀球茎_霉菌", eventType: EventTypeEnum.AddCombatant, eventCondition: ["DataId:5173"])]
|
||||
public void 霉菌(Event @event, ScriptAccessory accessory)
|
||||
{
|
||||
var dp = accessory.Data.GetDefaultDrawProperties();
|
||||
dp.Name = $"霉菌{@event.SourceId}";
|
||||
dp.Color = accessory.Data.DefaultDangerColor.WithW(0.8f);
|
||||
dp.Owner = @event.SourceId();
|
||||
dp.Scale = new Vector2(6f);
|
||||
dp.Delay = 5000;
|
||||
dp.DestoryAt = 90000;
|
||||
accessory.Method.SendDraw(DrawModeEnum.Default, DrawTypeEnum.Circle, dp);
|
||||
}
|
||||
|
||||
[ScriptMethod(name: "肿胀球茎销毁", eventType: EventTypeEnum.RemoveCombatant, eventCondition: ["DataId:5173"],userControl: false)]
|
||||
public void 肿胀球茎销毁(Event @event, ScriptAccessory accessory)
|
||||
{
|
||||
accessory.Method.RemoveDraw($"霉菌{@event.SourceId}");
|
||||
}
|
||||
|
||||
[ScriptMethod(name: "BOSS3_剧毒美人 魅惑视线 背对提示", eventType: EventTypeEnum.StartCasting, eventCondition: ["ActionId:5216"])]
|
||||
public void 魅惑视线(Event @event, ScriptAccessory accessory)
|
||||
{
|
||||
// if (isText)accessory.Method.TextInfo($"背对BOSS", duration: 3000, false);
|
||||
if (isTTS)accessory.Method.TTS($"背对BOSS");
|
||||
if (isEdgeTTS)accessory.Method.EdgeTTS($"背对BOSS");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
|
||||
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<uint>(@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<uint>(@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<uint>(@event["DurationMilliseconds"]);
|
||||
}
|
||||
|
||||
public static float SourceRotation(this Event @event)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<float>(@event["SourceRotation"]);
|
||||
}
|
||||
|
||||
public static float TargetRotation(this Event @event)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<float>(@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<Vector3>(@event["SourcePosition"]);
|
||||
}
|
||||
|
||||
public static Vector3 TargetPosition(this Event @event)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<Vector3>(@event["TargetPosition"]);
|
||||
}
|
||||
|
||||
public static Vector3 EffectPosition(this Event @event)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<Vector3>(@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<uint>(@event["StatusId"]);
|
||||
}
|
||||
|
||||
public static uint StackCount(this Event @event)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<uint>(@event["StackCount"]);
|
||||
}
|
||||
|
||||
public static uint Param(this Event @event)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<uint>(@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;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EnumExtensions
|
||||
{
|
||||
public static string GetDescription(this Enum value)
|
||||
{
|
||||
var field = value.GetType().GetField(value.ToString());
|
||||
var attribute = field?.GetCustomAttributes(typeof(DescriptionAttribute), false)
|
||||
.FirstOrDefault() as DescriptionAttribute;
|
||||
return attribute?.Description ?? value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public static class MathTools
|
||||
{
|
||||
public static float DegToRad(this float deg) => (deg + 360f) % 360f / 180f * float.Pi;
|
||||
public static float RadToDeg(this float rad) => (rad + 2 * float.Pi) % (2 * float.Pi) / float.Pi * 180f;
|
||||
|
||||
/// <summary>
|
||||
/// 获得任意点与中心点的弧度值,以(0, 0, 1)方向为0,以(1, 0, 0)方向为pi/2。
|
||||
/// 即,逆时针方向增加。
|
||||
/// </summary>
|
||||
/// <param name="point">任意点</param>
|
||||
/// <param name="center">中心点</param>
|
||||
/// <returns></returns>
|
||||
public static float GetRadian(this Vector3 point, Vector3 center)
|
||||
=> MathF.Atan2(point.X - center.X, point.Z - center.Z);
|
||||
|
||||
/// <summary>
|
||||
/// 获得任意点与中心点的长度。
|
||||
/// </summary>
|
||||
/// <param name="point">任意点</param>
|
||||
/// <param name="center">中心点</param>
|
||||
/// <returns></returns>
|
||||
public static float GetLength(this Vector3 point, Vector3 center)
|
||||
=> new Vector2(point.X - center.X, point.Z - center.Z).Length();
|
||||
|
||||
/// <summary>
|
||||
/// 将任意点以中心点为圆心,逆时针旋转并延长。
|
||||
/// </summary>
|
||||
/// <param name="point">任意点</param>
|
||||
/// <param name="center">中心点</param>
|
||||
/// <param name="radian">旋转弧度</param>
|
||||
/// <param name="length">基于该点延伸长度</param>
|
||||
/// <returns></returns>
|
||||
public static Vector3 RotateAndExtend(this Vector3 point, Vector3 center, float radian, float length)
|
||||
{
|
||||
var baseRad = point.GetRadian(center);
|
||||
var baseLength = point.GetLength(center);
|
||||
var rotRad = baseRad + radian;
|
||||
return new Vector3(
|
||||
center.X + MathF.Sin(rotRad) * (length + baseLength),
|
||||
center.Y,
|
||||
center.Z + MathF.Cos(rotRad) * (length + baseLength)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得某角度所在划分区域
|
||||
/// </summary>
|
||||
/// <param name="radian">输入弧度</param>
|
||||
/// <param name="regionNum">区域划分数量</param>
|
||||
/// <param name="baseRegionIdx">0度所在区域的初始Idx</param>>
|
||||
/// <param name="isDiagDiv">是否为斜分割,默认为false</param>
|
||||
/// <param name="isCw">是否顺时针增加,默认为false</param>
|
||||
/// <returns></returns>
|
||||
public static int RadianToRegion(this float radian, int regionNum, int baseRegionIdx = 0, bool isDiagDiv = false, bool isCw = false)
|
||||
{
|
||||
var sepRad = float.Pi * 2 / regionNum;
|
||||
var inputAngle = radian * (isCw ? -1 : 1) + (isDiagDiv ? sepRad / 2 : 0);
|
||||
var rad = (inputAngle + 4 * float.Pi) % (2 * float.Pi);
|
||||
return ((int)Math.Floor(rad / sepRad) + baseRegionIdx + regionNum) % regionNum;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将输入点左右折叠
|
||||
/// </summary>
|
||||
/// <param name="point">待折叠点</param>
|
||||
/// <param name="centerX">中心折线坐标点</param>
|
||||
/// <returns></returns>
|
||||
public static Vector3 FoldPointHorizon(this Vector3 point, float centerX)
|
||||
=> point with { X = 2 * centerX - point.X };
|
||||
|
||||
/// <summary>
|
||||
/// 将输入点上下折叠
|
||||
/// </summary>
|
||||
/// <param name="point">待折叠点</param>
|
||||
/// <param name="centerZ">中心折线坐标点</param>
|
||||
/// <returns></returns>
|
||||
public static Vector3 FoldPointVertical(this Vector3 point, float centerZ)
|
||||
=> point with { Z = 2 * centerZ - point.Z };
|
||||
|
||||
/// <summary>
|
||||
/// 将输入点中心对称
|
||||
/// </summary>
|
||||
/// <param name="point">输入点</param>
|
||||
/// <param name="center">中心点</param>
|
||||
/// <returns></returns>
|
||||
public static Vector3 PointCenterSymmetry(this Vector3 point, Vector3 center)
|
||||
=> point.RotateAndExtend(center, float.Pi, 0);
|
||||
|
||||
/// <summary>
|
||||
/// 获取给定数的指定位数
|
||||
/// </summary>
|
||||
/// <param name="val">给定数值</param>
|
||||
/// <param name="x">对应位数,个位为1</param>
|
||||
/// <returns></returns>
|
||||
public static int GetDecimalDigit(this int val, int x)
|
||||
{
|
||||
var valStr = val.ToString();
|
||||
var length = valStr.Length;
|
||||
if (x < 1 || x > length) return -1;
|
||||
var digitChar = valStr[length - x]; // 从右往左取第x位
|
||||
return int.Parse(digitChar.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public enum MarkType
|
||||
{
|
||||
None = -1,
|
||||
Attack1 = 0,
|
||||
Attack2 = 1,
|
||||
Attack3 = 2,
|
||||
Attack4 = 3,
|
||||
Attack5 = 4,
|
||||
Bind1 = 5,
|
||||
Bind2 = 6,
|
||||
Bind3 = 7,
|
||||
Ignore1 = 8,
|
||||
Ignore2 = 9,
|
||||
Square = 10,
|
||||
Circle = 11,
|
||||
Cross = 12,
|
||||
Triangle = 13,
|
||||
Attack6 = 14,
|
||||
Attack7 = 15,
|
||||
Attack8 = 16,
|
||||
Count = 17
|
||||
}
|
||||
|
||||
public static class IbcHelper
|
||||
{
|
||||
public static IGameObject? GetById(this ScriptAccessory sa, ulong gameObjectId)
|
||||
{
|
||||
return sa.Data.Objects.SearchById(gameObjectId);
|
||||
}
|
||||
|
||||
public static IGameObject? GetMe(this ScriptAccessory sa)
|
||||
{
|
||||
return sa.Data.Objects.LocalPlayer;
|
||||
}
|
||||
|
||||
public static IEnumerable<IGameObject?> GetByDataId(this ScriptAccessory sa, uint dataId)
|
||||
{
|
||||
return sa.Data.Objects.Where(x => x.DataId == dataId);
|
||||
}
|
||||
|
||||
public static string GetPlayerJob(this ScriptAccessory sa, IPlayerCharacter? playerObject, bool fullName = false)
|
||||
{
|
||||
if (playerObject == null) return "None";
|
||||
return fullName ? playerObject.ClassJob.Value.Name.ToString() : playerObject.ClassJob.Value.Abbreviation.ToString();
|
||||
}
|
||||
|
||||
public static float GetStatusRemainingTime(this ScriptAccessory sa, IBattleChara? battleChara, uint statusId)
|
||||
{
|
||||
if (battleChara == null || !battleChara.IsValid()) return 0;
|
||||
unsafe
|
||||
{
|
||||
BattleChara* charaStruct = (BattleChara*)battleChara.Address;
|
||||
var statusIdx = charaStruct->GetStatusManager()->GetStatusIndex(statusId);
|
||||
return charaStruct->GetStatusManager()->GetRemainingTime(statusIdx);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool HasStatus(this ScriptAccessory sa, IBattleChara? battleChara, uint statusId)
|
||||
{
|
||||
if (battleChara == null || !battleChara.IsValid()) return false;
|
||||
unsafe
|
||||
{
|
||||
BattleChara* charaStruct = (BattleChara*)battleChara.Address;
|
||||
var statusIdx = charaStruct->GetStatusManager()->GetStatusIndex(statusId);
|
||||
return statusIdx != -1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定标记索引的对象EntityId
|
||||
/// </summary>
|
||||
public static unsafe ulong GetMarkerEntityId(uint markerIndex)
|
||||
{
|
||||
var markingController = MarkingController.Instance();
|
||||
if (markingController == null) return 0;
|
||||
if (markerIndex >= 17) return 0;
|
||||
|
||||
return markingController->Markers[(int)markerIndex];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取对象身上的标记
|
||||
/// </summary>
|
||||
/// <returns>MarkType</returns>
|
||||
public static MarkType GetObjectMarker(IGameObject? obj)
|
||||
{
|
||||
if (obj == null || !obj.IsValid()) return MarkType.None;
|
||||
|
||||
ulong targetEntityId = obj.EntityId;
|
||||
|
||||
for (uint i = 0; i < 17; i++)
|
||||
{
|
||||
var markerEntityId = GetMarkerEntityId(i);
|
||||
if (markerEntityId == targetEntityId)
|
||||
{
|
||||
return (MarkType)i;
|
||||
}
|
||||
}
|
||||
|
||||
return MarkType.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查对象是否有指定的标记
|
||||
/// </summary>
|
||||
public static bool HasMarker(IGameObject? obj, MarkType markType)
|
||||
{
|
||||
return GetObjectMarker(obj) == markType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查对象是否有任何标记
|
||||
/// </summary>
|
||||
public static bool HasAnyMarker(IGameObject? obj)
|
||||
{
|
||||
return GetObjectMarker(obj) != MarkType.None;
|
||||
}
|
||||
|
||||
private static ulong GetMarkerForObject(IGameObject? obj)
|
||||
{
|
||||
if (obj == null) return 0;
|
||||
unsafe
|
||||
{
|
||||
for (uint i = 0; i < 17; i++)
|
||||
{
|
||||
var markerEntityId = GetMarkerEntityId(i);
|
||||
if (markerEntityId == obj.EntityId)
|
||||
{
|
||||
return markerEntityId;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static MarkType GetMarkerTypeForObject(IGameObject? obj)
|
||||
{
|
||||
if (obj == null) return MarkType.None;
|
||||
unsafe
|
||||
{
|
||||
for (uint i = 0; i < 17; i++)
|
||||
{
|
||||
var markerEntityId = GetMarkerEntityId(i);
|
||||
if (markerEntityId == obj.EntityId)
|
||||
{
|
||||
return (MarkType)i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return MarkType.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取标记的名称
|
||||
/// </summary>
|
||||
public static string GetMarkerName(MarkType markType)
|
||||
{
|
||||
return markType switch
|
||||
{
|
||||
MarkType.Attack1 => "攻击1",
|
||||
MarkType.Attack2 => "攻击2",
|
||||
MarkType.Attack3 => "攻击3",
|
||||
MarkType.Attack4 => "攻击4",
|
||||
MarkType.Attack5 => "攻击5",
|
||||
MarkType.Bind1 => "止步1",
|
||||
MarkType.Bind2 => "止步2",
|
||||
MarkType.Bind3 => "止步3",
|
||||
MarkType.Ignore1 => "禁止1",
|
||||
MarkType.Ignore2 => "禁止2",
|
||||
MarkType.Square => "方块",
|
||||
MarkType.Circle => "圆圈",
|
||||
MarkType.Cross => "十字",
|
||||
MarkType.Triangle => "三角",
|
||||
MarkType.Attack6 => "攻击6",
|
||||
MarkType.Attack7 => "攻击7",
|
||||
MarkType.Attack8 => "攻击8",
|
||||
_ => "无标记"
|
||||
};
|
||||
}
|
||||
|
||||
public static float GetHitboxRadius(IGameObject obj)
|
||||
{
|
||||
if (obj == null || !obj.IsValid()) return -1;
|
||||
return obj.HitboxRadius;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class HelperExtensions
|
||||
{
|
||||
public static unsafe uint GetCurrentTerritoryId()
|
||||
{
|
||||
return AgentMap.Instance()->CurrentTerritoryId; // 额外进行地图ID判断
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user