mirror of
https://github.com/Hibiya615/TetoraKAScript.git
synced 2025-12-23 02:04:42 +08:00
feat: api13, remove ecommon
This commit is contained in:
@@ -3,8 +3,6 @@ using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Collections.Generic;
|
||||
// using Dalamud.Game.ClientState.Objects.Subkinds;
|
||||
// using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Newtonsoft.Json;
|
||||
using Dalamud.Utility.Numerics;
|
||||
using KodakkuAssist.Script;
|
||||
@@ -12,16 +10,12 @@ using KodakkuAssist.Module.GameEvent;
|
||||
using KodakkuAssist.Module.Draw;
|
||||
using KodakkuAssist.Data;
|
||||
using KodakkuAssist.Extensions;
|
||||
using ECommons;
|
||||
using ECommons.DalamudServices;
|
||||
using ECommons.GameFunctions;
|
||||
using ECommons.MathHelpers;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace theTwinning;
|
||||
|
||||
[ScriptType(guid: "bfb00cd3-ccec-4b21-b3d7-e290f49e6a75", name: "异界遗构希尔科斯孪晶塔", territorys: [840],
|
||||
version: "0.0.0.2", author: "Tetora", note: noteStr)]
|
||||
version: "0.0.0.3", author: "Tetora", note: noteStr)]
|
||||
|
||||
public class theTwinning
|
||||
{
|
||||
@@ -346,4 +340,112 @@ public static class EventExtensions
|
||||
{
|
||||
return JsonConvert.DeserializeObject<uint>(@event["Param"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region 计算函数
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 计算函数
|
||||
@@ -3,8 +3,6 @@ using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Collections.Generic;
|
||||
// using Dalamud.Game.ClientState.Objects.Subkinds;
|
||||
// using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Newtonsoft.Json;
|
||||
using Dalamud.Utility.Numerics;
|
||||
using KodakkuAssist.Script;
|
||||
@@ -12,16 +10,12 @@ using KodakkuAssist.Module.GameEvent;
|
||||
using KodakkuAssist.Module.Draw;
|
||||
using KodakkuAssist.Data;
|
||||
using KodakkuAssist.Extensions;
|
||||
using ECommons;
|
||||
using ECommons.DalamudServices;
|
||||
using ECommons.GameFunctions;
|
||||
using ECommons.MathHelpers;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace E10n;
|
||||
|
||||
[ScriptType(guid: "038e00e8-d378-4f43-89ab-e27df5561d5a", name: "E10N", territorys: [943],
|
||||
version: "0.0.0.2", author: "Tetora", note: noteStr)]
|
||||
version: "0.0.0.3", author: "Tetora", note: noteStr)]
|
||||
|
||||
public class E10n
|
||||
{
|
||||
@@ -413,4 +407,113 @@ public static class Extensions
|
||||
accessory.Method.TTS(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region 计算函数
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 计算函数
|
||||
@@ -3,8 +3,6 @@ using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Collections.Generic;
|
||||
// using Dalamud.Game.ClientState.Objects.Subkinds;
|
||||
// using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Newtonsoft.Json;
|
||||
using Dalamud.Utility.Numerics;
|
||||
using KodakkuAssist.Script;
|
||||
@@ -12,16 +10,12 @@ using KodakkuAssist.Module.GameEvent;
|
||||
using KodakkuAssist.Module.Draw;
|
||||
using KodakkuAssist.Data;
|
||||
using KodakkuAssist.Extensions;
|
||||
using ECommons;
|
||||
using ECommons.DalamudServices;
|
||||
using ECommons.GameFunctions;
|
||||
using ECommons.MathHelpers;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace E12n;
|
||||
|
||||
[ScriptType(guid: "3f88ad9c-e7a7-4e00-b19e-546609b319ba", name: "E12N", territorys: [945],
|
||||
version: "0.0.0.2" , author: "Tetora", note: noteStr)]
|
||||
version: "0.0.0.3" , author: "Tetora", note: noteStr)]
|
||||
|
||||
public class E12n
|
||||
{
|
||||
@@ -290,3 +284,111 @@ public static class Extensions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region 计算函数
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 计算函数
|
||||
@@ -3,8 +3,6 @@ using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Collections.Generic;
|
||||
// using Dalamud.Game.ClientState.Objects.Subkinds;
|
||||
// using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Newtonsoft.Json;
|
||||
using Dalamud.Utility.Numerics;
|
||||
using KodakkuAssist.Script;
|
||||
@@ -12,16 +10,12 @@ using KodakkuAssist.Module.GameEvent;
|
||||
using KodakkuAssist.Module.Draw;
|
||||
using KodakkuAssist.Extensions;
|
||||
using KodakkuAssist.Data;
|
||||
using ECommons;
|
||||
using ECommons.DalamudServices;
|
||||
using ECommons.GameFunctions;
|
||||
using ECommons.MathHelpers;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace E1n;
|
||||
|
||||
[ScriptType(guid: "35c751e5-2958-4f55-b783-405b4acfde1b", name: "E1N", territorys: [849],
|
||||
version: "0.0.0.2", author: "Tetora", note: noteStr)]
|
||||
version: "0.0.0.3", author: "Tetora", note: noteStr)]
|
||||
|
||||
public class E1n
|
||||
{
|
||||
@@ -240,3 +234,112 @@ public static class Extensions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region 计算函数
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 计算函数
|
||||
@@ -11,16 +11,12 @@ using KodakkuAssist.Script;
|
||||
using KodakkuAssist.Module.GameEvent;
|
||||
using KodakkuAssist.Module.Draw;
|
||||
using KodakkuAssist.Data;
|
||||
using ECommons;
|
||||
using ECommons.DalamudServices;
|
||||
using ECommons.GameFunctions;
|
||||
using ECommons.MathHelpers;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace E2n;
|
||||
|
||||
[ScriptType(guid: "b59c7db9-1fba-4476-8701-1e3043cb7dc8", name: "E2N", territorys: [850],
|
||||
version: "0.0.0.1", author: "Tetora", note: noteStr)]
|
||||
version: "0.0.0.2", author: "Tetora", note: noteStr)]
|
||||
|
||||
public class E2n
|
||||
{
|
||||
|
||||
@@ -3,8 +3,6 @@ using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Collections.Generic;
|
||||
// using Dalamud.Game.ClientState.Objects.Subkinds;
|
||||
// using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Newtonsoft.Json;
|
||||
using Dalamud.Utility.Numerics;
|
||||
using KodakkuAssist.Script;
|
||||
@@ -12,16 +10,12 @@ using KodakkuAssist.Module.GameEvent;
|
||||
using KodakkuAssist.Module.Draw;
|
||||
using KodakkuAssist.Data;
|
||||
using KodakkuAssist.Extensions;
|
||||
using ECommons;
|
||||
using ECommons.DalamudServices;
|
||||
using ECommons.GameFunctions;
|
||||
using ECommons.MathHelpers;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace E8n;
|
||||
|
||||
[ScriptType(guid: "c4d533c8-8798-441d-b849-fc3cd5cf63d9", name: "E8N", territorys: [905],
|
||||
version: "0.0.0.3" , author: "Tetora", note: noteStr)]
|
||||
version: "0.0.0.4" , author: "Tetora", note: noteStr)]
|
||||
|
||||
public class E8n
|
||||
{
|
||||
@@ -386,3 +380,112 @@ public static class Extensions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region 计算函数
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 计算函数
|
||||
@@ -11,16 +11,12 @@ using KodakkuAssist.Script;
|
||||
using KodakkuAssist.Module.GameEvent;
|
||||
using KodakkuAssist.Module.Draw;
|
||||
using KodakkuAssist.Data;
|
||||
using ECommons;
|
||||
using ECommons.DalamudServices;
|
||||
using ECommons.GameFunctions;
|
||||
using ECommons.MathHelpers;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace E9n;
|
||||
|
||||
[ScriptType(guid: "e4b80c15-7885-46b7-8e3d-201a6a248c89", name: "E9N", territorys: [942],
|
||||
version: "0.0.0.1", author: "Tetora", note: noteStr)]
|
||||
version: "0.0.0.2", author: "Tetora", note: noteStr)]
|
||||
|
||||
public class E9n
|
||||
{
|
||||
@@ -218,4 +214,113 @@ public static class EventExtensions
|
||||
{
|
||||
return JsonConvert.DeserializeObject<uint>(@event["Param"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region 计算函数
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 计算函数
|
||||
@@ -3,8 +3,6 @@ using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Collections.Generic;
|
||||
// using Dalamud.Game.ClientState.Objects.Subkinds;
|
||||
// using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Newtonsoft.Json;
|
||||
using Dalamud.Utility.Numerics;
|
||||
using KodakkuAssist.Script;
|
||||
@@ -12,16 +10,12 @@ using KodakkuAssist.Module.GameEvent;
|
||||
using KodakkuAssist.Module.Draw;
|
||||
using KodakkuAssist.Data;
|
||||
using KodakkuAssist.Extensions;
|
||||
using ECommons;
|
||||
using ECommons.DalamudServices;
|
||||
using ECommons.GameFunctions;
|
||||
using ECommons.MathHelpers;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace E12S;
|
||||
|
||||
[ScriptType(guid: "f2ebc170-00af-415d-8dfe-30bc27f7fc06", name: "E12S", territorys: [949],
|
||||
version: "0.0.0.1", author: "Tetora", note: noteStr)]
|
||||
version: "0.0.0.2", author: "Tetora", note: noteStr)]
|
||||
|
||||
public class E12S
|
||||
{
|
||||
@@ -420,4 +414,112 @@ public static class EventExtensions
|
||||
{
|
||||
return JsonConvert.DeserializeObject<uint>(@event["Param"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region 计算函数
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 计算函数
|
||||
@@ -1,37 +1,33 @@
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using ECommons.DalamudServices;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Newtonsoft.Json;
|
||||
using Dalamud.Utility.Numerics;
|
||||
using KodakkuAssist.Script;
|
||||
using KodakkuAssist.Module.GameEvent;
|
||||
using FFXIVClientStructs;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Character;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
using KodakkuAssist.Module.Draw;
|
||||
using KodakkuAssist.Module.Draw.Manager;
|
||||
using ECommons.ExcelServices.TerritoryEnumeration;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Intrinsics.Arm;
|
||||
using KodakkuAssist.Module.GameEvent;
|
||||
using KodakkuAssist.Script;
|
||||
using Lumina.Data.Structs;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using ECommons.Reflection;
|
||||
using System.Windows;
|
||||
using ECommons;
|
||||
using ECommons.GameFunctions;
|
||||
using FFXIVClientStructs;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Numerics;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Intrinsics.Arm;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Xml.Linq;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
using Lumina.Data.Structs;
|
||||
|
||||
namespace E7S;
|
||||
|
||||
|
||||
[ScriptType(name: "E7S", territorys: [908], guid: "edb1e7fd-79cf-4bff-b134-7c55a1d31b36",
|
||||
version: "0.0.0.1", author: "Tetora", note: noteStr)]
|
||||
version: "0.0.0.2", author: "Tetora", note: noteStr)]
|
||||
|
||||
public class E7S
|
||||
{
|
||||
@@ -113,7 +109,7 @@ public class E7S
|
||||
[ScriptMethod(name: "debug", eventType: EventTypeEnum.Chat, eventCondition: ["Message:debug"])]
|
||||
public async void debug(Event @event, ScriptAccessory accessory)
|
||||
{
|
||||
var myself = IbcHelper.GetByEntityId(accessory.Data.Me);
|
||||
var myself = accessory.Data.Objects.SearchByEntityId(accessory.Data.Me) as IBattleChara;
|
||||
if (myself == null) return;
|
||||
var buffId = myself.HasStatus(2238) ? 2238 : 2239;
|
||||
DebugMsg($"buffId: {buffId}", accessory);
|
||||
@@ -297,7 +293,7 @@ public class E7S
|
||||
// 2238 Light //19516 & 19490 // 0x8BE
|
||||
// 2239 Darkness //19517 & 19491 // 0x8BF
|
||||
DebugMsg($"{LightsCourseCount}: {@event.ActionId()}", accessory);
|
||||
var myself = IbcHelper.GetByEntityId(accessory.Data.Me);
|
||||
var myself = accessory.Data.Objects.SearchByEntityId(accessory.Data.Me) as IBattleChara;
|
||||
if (myself == null) return;
|
||||
var buffId = myself.HasStatus(2238) ? 2238 : 2239;
|
||||
DebugMsg($"buffId: {buffId}", accessory);
|
||||
@@ -333,7 +329,7 @@ public class E7S
|
||||
// 2238 Light //19516 & 19490 // 0x8BE
|
||||
// 2239 Darkness //19517 & 19491 & 19521 // 0x8BF
|
||||
DebugMsg($"{LightsCourseCount}: {@event.ActionId()}", accessory);
|
||||
var myself = IbcHelper.GetByEntityId(accessory.Data.Me);
|
||||
var myself = accessory.Data.Objects.SearchByEntityId(accessory.Data.Me) as IBattleChara;
|
||||
if (myself == null) return;
|
||||
var buffId = myself.HasStatus(2238) ? 2238 : 2239;
|
||||
DebugMsg($"buffId: {buffId}", accessory);
|
||||
@@ -745,36 +741,47 @@ public static class Extensions
|
||||
|
||||
public static class IbcHelper
|
||||
{
|
||||
public static IBattleChara? GetById(uint id)
|
||||
public static KodakkuAssist.Data.IGameObject? GetById(ScriptAccessory accessory, uint id)
|
||||
{
|
||||
return (IBattleChara?)Svc.Objects.SearchByEntityId(id);
|
||||
return accessory.Data.Objects.SearchByEntityId(id);
|
||||
}
|
||||
|
||||
public static IBattleChara? GetMe()
|
||||
public static KodakkuAssist.Data.IGameObject? GetMe(ScriptAccessory accessory)
|
||||
{
|
||||
return Svc.ClientState.LocalPlayer;
|
||||
return accessory.Data.Objects.SearchByEntityId(accessory.Data.Me);
|
||||
}
|
||||
|
||||
public static IGameObject? GetFirstByDataId(uint dataId)
|
||||
public static KodakkuAssist.Data.IGameObject? GetFirstByDataId(ScriptAccessory accessory, uint dataId)
|
||||
{
|
||||
return Svc.Objects.Where(x => x.DataId == dataId).FirstOrDefault();
|
||||
return accessory.Data.Objects.Where(x => x.DataId == dataId).FirstOrDefault();
|
||||
}
|
||||
|
||||
public static IEnumerable<IGameObject?> GetByDataId(uint dataId)
|
||||
public static IEnumerable<KodakkuAssist.Data.IGameObject> GetByDataId(ScriptAccessory accessory, uint dataId)
|
||||
{
|
||||
return Svc.Objects.Where(x => x.DataId == dataId);
|
||||
}
|
||||
public static IBattleChara? GetByEntityId(uint id)
|
||||
{
|
||||
return (IBattleChara?)Svc.Objects.SearchByEntityId(id);
|
||||
}
|
||||
public static bool HasStatus(this IBattleChara chara, uint statusId)
|
||||
{
|
||||
return chara.StatusList.Any(x => x.StatusId == statusId);
|
||||
return accessory.Data.Objects.Where(x => x.DataId == dataId);
|
||||
}
|
||||
|
||||
public static bool HasStatus(this IBattleChara chara, uint[] statusIds)
|
||||
public static IEnumerable<KodakkuAssist.Data.IGameObject> GetParty(ScriptAccessory accessory)
|
||||
{
|
||||
return chara.StatusList.Any(x => statusIds.Contains(x.StatusId));
|
||||
foreach (var pid in accessory.Data.PartyList)
|
||||
{
|
||||
var obj = accessory.Data.Objects.SearchByEntityId(pid);
|
||||
if (obj != null) yield return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<KodakkuAssist.Data.IGameObject> GetPartyEntities(ScriptAccessory accessory)
|
||||
{
|
||||
return accessory.Data.Objects.Where(obj => accessory.Data.PartyList.Contains(obj.EntityId));
|
||||
}
|
||||
|
||||
public static bool HasStatus(this IBattleChara ibc, uint statusId)
|
||||
{
|
||||
return ibc.StatusList.Any(x => x.StatusId == statusId);
|
||||
}
|
||||
|
||||
public static bool HasStatusAny(this IBattleChara ibc, uint[] statusIds)
|
||||
{
|
||||
return ibc.StatusList.Any(x => statusIds.Contains(x.StatusId));
|
||||
}
|
||||
}
|
||||
@@ -3,25 +3,19 @@ using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Collections.Generic;
|
||||
// using Dalamud.Game.ClientState.Objects.Subkinds;
|
||||
// using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Newtonsoft.Json;
|
||||
using Dalamud.Utility.Numerics;
|
||||
using KodakkuAssist.Script;
|
||||
using KodakkuAssist.Module.GameEvent;
|
||||
using KodakkuAssist.Module.Draw;
|
||||
using KodakkuAssist.Data;
|
||||
using ECommons;
|
||||
using ECommons.DalamudServices;
|
||||
using ECommons.GameFunctions;
|
||||
using ECommons.MathHelpers;
|
||||
using System.Threading.Tasks;
|
||||
using KodakkuAssist.Extensions;
|
||||
|
||||
namespace Hades;
|
||||
|
||||
[ScriptType(guid: "ebcac22b-8a1d-49c4-ae1f-1470be15f7e3", name: "哈迪斯歼灭战", territorys: [847],
|
||||
version: "0.0.0.1", author: "Tetora", note: noteStr)]
|
||||
version: "0.0.0.2", author: "Tetora", note: noteStr)]
|
||||
|
||||
public class Hades
|
||||
{
|
||||
@@ -322,4 +316,115 @@ public static class EventExtensions
|
||||
{
|
||||
return JsonConvert.DeserializeObject<uint>(@event["Param"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#region 计算函数
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 计算函数
|
||||
@@ -3,8 +3,6 @@ using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Collections.Generic;
|
||||
// using Dalamud.Game.ClientState.Objects.Subkinds;
|
||||
// using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Newtonsoft.Json;
|
||||
using Dalamud.Utility.Numerics;
|
||||
using KodakkuAssist.Script;
|
||||
@@ -12,16 +10,12 @@ using KodakkuAssist.Module.GameEvent;
|
||||
using KodakkuAssist.Module.Draw;
|
||||
using KodakkuAssist.Data;
|
||||
using KodakkuAssist.Extensions;
|
||||
using ECommons;
|
||||
using ECommons.DalamudServices;
|
||||
using ECommons.GameFunctions;
|
||||
using ECommons.MathHelpers;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Titania;
|
||||
|
||||
[ScriptType(guid: "71a3a109-0ac3-4041-aa87-ff156f5aaeea", name: "缇坦妮雅歼灭战", territorys: [845],
|
||||
version: "0.0.0.1", author: "Tetora", note: noteStr)]
|
||||
version: "0.0.0.2", author: "Tetora", note: noteStr)]
|
||||
|
||||
public class Titania
|
||||
{
|
||||
@@ -331,4 +325,114 @@ public static class EventExtensions
|
||||
{
|
||||
return JsonConvert.DeserializeObject<uint>(@event["Param"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region 计算函数
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 计算函数
|
||||
Reference in New Issue
Block a user