-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AutoTargetCrystal Script and fix bugs (#219)
* [add] auto target crystal scripts * [fix] some bugs * [add] description about autotargetcrystal script --------- Co-authored-by: Limiana <[email protected]>
- Loading branch information
Showing
3 changed files
with
76 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
SplatoonScripts/Duties/Dawntrail/The Futures Rewritten/P2 AutoTargetCrystal.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Numerics; | ||
using Dalamud.Game.ClientState.Objects.Types; | ||
using ECommons.DalamudServices; | ||
using ECommons.DalamudServices.Legacy; | ||
using ECommons.GameHelpers; | ||
using ECommons.Throttlers; | ||
using ImGuiNET; | ||
using Splatoon.SplatoonScripting; | ||
|
||
namespace SplatoonScriptsOfficial.Duties.Dawntrail.The_Futures_Rewritten; | ||
|
||
public class P2_AutoTargetCrystal : SplatoonScript | ||
{ | ||
public override HashSet<uint>? ValidTerritories => [1238]; | ||
public override Metadata? Metadata => new(1, "Garume"); | ||
|
||
private IEnumerable<IBattleNpc> LightCrystals => Svc.Objects.Where(x => x.DataId == 0x45A3).OfType<IBattleNpc>(); | ||
private IBattleNpc? IceCrystal => Svc.Objects.FirstOrDefault(x => x.DataId == 0x45A5) as IBattleNpc; | ||
|
||
public override void OnSettingsDraw() | ||
{ | ||
ImGui.Text("Light Crystals"); | ||
foreach (var crystal in LightCrystals) ImGui.Text(crystal.Name.ToString()); | ||
} | ||
|
||
public override void OnUpdate() | ||
{ | ||
if (EzThrottler.Throttle("AutoTargetCrystal", 200)) SetNearTarget(); | ||
} | ||
|
||
private void SetNearTarget() | ||
{ | ||
if (LightCrystals.Where(x => x.CurrentHp != 0) | ||
.MinBy(x => Vector3.Distance(x.Position, Player.Position)) is { } target) | ||
Svc.Targets.SetTarget(target); | ||
else if (IceCrystal is { } ice) | ||
Svc.Targets.SetTarget(ice); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters