feat: api13, remove ecommon

This commit is contained in:
VeeverSW
2025-09-19 15:21:51 +08:00
parent f744cca396
commit 2d1a945a9b
75 changed files with 5122 additions and 614 deletions

View File

@@ -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 MainScenario_Roulette;
[ScriptType(guid: "84c15eea-2a19-4477-ad21-cd43d1263cfa", name: "随机任务:主线任务", territorys: [1043, 1044, 1048],
version: "0.0.0.2", author: "Tetora", note: noteStr)]
version: "0.0.0.3", author: "Tetora", note: noteStr)]
public class MainScenario_Roulette
{

View File

@@ -3,24 +3,18 @@ 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;
namespace Bahamute_NormalRaid_for_BLU;
[ScriptType(guid: "8d41b5f9-0ab6-404a-9572-aabb390023f0", name: "巴哈姆特大迷宫(青魔专用)", territorys: [196,245,358],
version: "0.0.0.2", author: "Tetora", note: noteStr)]
version: "0.0.0.3", author: "Tetora", note: noteStr)]
public class Bahamute_NormalRaid_for_BLU
{

View File

@@ -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 Garuda_Extreme;
[ScriptType(guid: "3e4685ed-1425-4ddc-8222-a2c15dcc9ad5", name: "迦楼罗歼殛战", territorys: [297],
version: "0.0.0.1", author: "Tetora", note: noteStr)]
version: "0.0.0.2", author: "Tetora", note: noteStr)]
public class Garuda_Extreme
{
@@ -289,4 +283,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

View File

@@ -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 Thornmarch_Extreme;
[ScriptType(guid: "fc6a6125-4a1d-4669-be4c-9b375dc70ae0", name: "莫古力贤王歼殛战", territorys: [364],
version: "0.0.0.3", author: "Tetora", note: noteStr)]
version: "0.0.0.4", author: "Tetora", note: noteStr)]
public class ThornmarchExtreme
{
@@ -693,3 +687,112 @@ public static class DirectionCalc
return v2.Length();
}
}
#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

View File

@@ -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 Ifrit_Extreme;
[ScriptType(guid: "dbb7983a-d2c4-4621-9734-76772e3f206a", name: "伊弗利特歼殛战", territorys: [295],
version: "0.0.0.3", author: "Tetora", note: noteStr)]
version: "0.0.0.4", author: "Tetora", note: noteStr)]
public class Ifrit_Extreme
{

View File

@@ -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 the_Whorleater_Extreme;
[ScriptType(guid: "07f20e0e-9463-4a10-9dd1-956fde6a9c46", name: "利维亚桑歼殛战", territorys: [359],
version: "0.0.0.3", author: "Tetora", note: noteStr)]
version: "0.0.0.4", author: "Tetora", note: noteStr)]
public class the_Whorleater_Extreme
{

View File

@@ -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,17 +10,13 @@ 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;
using KodakkuAssist.Extensions;
namespace Battle_in_the_Big_Keep;
[ScriptType(guid: "90783a42-7947-4392-9c3e-f3162d52c248", name: "无限城的死斗", territorys: [396],
version: "0.0.0.2", author: "Tetora", note: noteStr)]
version: "0.0.0.3", author: "Tetora", note: noteStr)]
public class Battle_in_the_Big_Keep
{
@@ -310,4 +304,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

View File

@@ -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 BattleOnTheBigBridgen;
[ScriptType(guid: "3e4102cb-9410-44fd-85e8-d43a3bc25737", name: "大桥上的决斗", territorys: [366],
version: "0.0.0.3", author: "Tetora", note: noteStr)]
version: "0.0.0.4", author: "Tetora", note: noteStr)]
public class BattleOnTheBigBridge
{

View File

@@ -3,24 +3,18 @@ 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;
namespace DhormeChimera;
[ScriptType(guid: "e24bb311-704f-4f4c-8188-87eaa8da8b29", name: "死化奇美拉讨伐战", territorys: [368],
version: "0.0.0.3", author: "Tetora", note: noteStr)]
version: "0.0.0.4", author: "Tetora", note: noteStr)]
public class DhormeChimera
{

View File

@@ -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 Garuda_Hard;
[ScriptType(guid: "ef230d41-5fbf-413d-b745-7227efebec48", name: "迦楼罗歼灭战", territorys: [294],
version: "0.0.0.1", author: "Tetora", note: noteStr)]
version: "0.0.0.2", author: "Tetora", note: noteStr)]
public class Garuda_Hard_
{
@@ -240,4 +234,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

View File

@@ -3,24 +3,18 @@ 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;
namespace Garuda_Normal;
[ScriptType(guid: "0887dadc-e415-48c9-bab1-cb51554457a2", name: "迦楼罗讨伐战", territorys: [1047],
version: "0.0.0.1", author: "Tetora", note: noteStr)]
version: "0.0.0.2", author: "Tetora", note: noteStr)]
public class Garuda_Normal
{

View File

@@ -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 Thornmarch_Hard;
[ScriptType(guid: "cd81e178-12e6-4e53-9b81-63002cc51ecb", name: "莫古力贤王歼灭战(整活版)", territorys: [1067],
version: "0.0.0.2", author: "Tetora", note: noteStr)]
version: "0.0.0.3", author: "Tetora", note: noteStr)]
public class Thornmarch_Hard
{
@@ -687,4 +681,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

View File

@@ -3,24 +3,18 @@ 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;
namespace A_Relic_Reborn_the_Hydra;
[ScriptType(guid: "d32d7489-a1bb-4117-98dd-ee895390804d", name: "海德拉讨伐战", territorys: [369],
version: "0.0.0.2", author: "Tetora", note: noteStr)]
version: "0.0.0.3", author: "Tetora", note: noteStr)]
public class theBowlofEmbers_Hard
{
@@ -190,4 +184,114 @@ 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

View File

@@ -3,24 +3,18 @@ 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;
namespace theBowlofEmbers_Hard;
[ScriptType(guid: "d3d532f1-0707-427f-ac04-871a22022c11", name: "伊弗利特歼灭战", territorys: [292],
version: "0.0.0.2", author: "Tetora", note: noteStr)]
version: "0.0.0.3", author: "Tetora", note: noteStr)]
public class theBowlofEmbers_Hard
{
@@ -38,7 +32,7 @@ public class theBowlofEmbers_Hard
{
if (!) return;
var dp = accessory.Data.GetDefaultDrawProperties();
var ifrits = Svc.Objects.Where(x => x.DataId == 209);
var ifrits = accessory.Data.Objects.Where(x => x.DataId == 209);
foreach (var ifrit in ifrits)
{
if (ifrit.IsTargetable)
@@ -62,7 +56,7 @@ public class theBowlofEmbers_Hard
{
if (!) return;
var dp = accessory.Data.GetDefaultDrawProperties();
var ifrits = Svc.Objects.Where(x => x.DataId == 209);
var ifrits = accessory.Data.Objects.Where(x => x.DataId == 209);
foreach (var ifrit in ifrits)
{
if (ifrit.IsTargetable)
@@ -232,4 +226,114 @@ 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

View File

@@ -3,24 +3,18 @@ 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;
namespace Nabriales;
[ScriptType(guid: "64206b9e-cd0a-47ec-960d-15f39a888f9e", name: "那布里亚勒斯讨伐战", territorys: [426],
version: "0.0.0.3", author: "Tetora", note: noteStr)]
version: "0.0.0.4", author: "Tetora", note: noteStr)]
public class Nabriales
{

View File

@@ -3,24 +3,18 @@ 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;
namespace Urths_Fount;
[ScriptType(guid: "1a07440d-a7bd-4b67-b781-90d14087ee60", name: "奥丁歼灭战", territorys: [394],
version: "0.0.0.2", author: "Tetora", note: noteStr)]
version: "0.0.0.3", author: "Tetora", note: noteStr)]
public class Urths_Fount
{
const string noteStr =
@@ -207,3 +201,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

View File

@@ -3,24 +3,18 @@ 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;
namespace theStrikingTree_Hard;
[ScriptType(guid: "de6d6f10-775d-4c45-91ec-2bd4ed6762c7", name: "拉姆歼灭战", territorys: [374],
version: "0.0.0.2", author: "Tetora", note: noteStr)]
version: "0.0.0.3", author: "Tetora", note: noteStr)]
public class theStrikingTree_Hard_
{

View File

@@ -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 Shiva;
[ScriptType(guid: "cddb93a8-e01e-40fe-989c-5153ad62bfbc", name: "希瓦歼灭战", territorys: [377],
version: "0.0.0.1", author: "Tetora", note: noteStr)]
version: "0.0.0.2", author: "Tetora", note: noteStr)]
public class Shiva
{
@@ -285,4 +279,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