Skip to content

Commit e278e2e

Browse files
committed
Add snake script
1 parent b818e21 commit e278e2e

File tree

1 file changed

+166
-0
lines changed

1 file changed

+166
-0
lines changed
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
using Dalamud.Bindings.ImGui;
2+
using Dalamud.Game.ClientState.Objects.SubKinds;
3+
using Dalamud.Game.ClientState.Objects.Types;
4+
using ECommons;
5+
using ECommons.Configuration;
6+
using ECommons.DalamudServices;
7+
using ECommons.GameFunctions;
8+
using ECommons.GameHelpers;
9+
using Splatoon.SplatoonScripting;
10+
using System.Collections.Generic;
11+
using System.Linq;
12+
using System.Numerics;
13+
using Element = Splatoon.Element;
14+
using static Splatoon.Splatoon;
15+
16+
namespace SplatoonScriptsOfficial.Duties.Dawntrail;
17+
18+
public class M12S_P1_Snake : SplatoonScript
19+
{
20+
public override Metadata Metadata { get; } = new(1, "NightmareXIV");
21+
public override HashSet<uint>? ValidTerritories { get; } = [1327];
22+
23+
public enum Debuff
24+
{
25+
Pos1 = 3004,
26+
Pos2 = 3005,
27+
Pos3 = 3006,
28+
Pos4 = 3451,
29+
Alpha = 4752,
30+
Beta = 4754,
31+
}
32+
33+
public override void OnSetup()
34+
{
35+
Controller.RegisterElementFromCode("TowerWaiting", """{"Name":"","refX":96.0,"refY":96.0,"radius":4.5,"Donut":0.5,"color":3355508719,"fillIntensity":0.281}""");
36+
Controller.RegisterElementFromCode("TowerGet", """
37+
{"Name":"","refX":96.0,"refY":96.0,"radius":4.5,"Donut":0.5,"color":3357277952,"fillIntensity":1.0,"thicc":5.0,"tether":true}
38+
""");
39+
}
40+
41+
bool MechanicActive => Controller.GetPartyMembers().Any(x => x.StatusList.Any(s => HasStatus(x, Debuff.Pos4)));
42+
List<Vector3> Towers = [];
43+
Debuff? MyDebuff = null;
44+
45+
public override void OnReset()
46+
{
47+
Towers.Clear();
48+
MyDebuff = null;
49+
}
50+
51+
public override void OnUpdate()
52+
{
53+
Controller.Hide();
54+
foreach(var x in Svc.Objects.OfType<IBattleNpc>())
55+
{
56+
if(x.NameId == 14378 && x.IsCasting(46262) && !Towers.Any(a => a.ApproximatelyEquals(x.Position, 0.5f)))
57+
{
58+
Towers.Add(x.Position);
59+
}
60+
if(x.NameId == 14381 && x.IsCasting(46263) && x.CurrentCastTime >= 2.5f)
61+
{
62+
for(int i = 0; i < Towers.Count; i++)
63+
{
64+
Vector3 t = Towers[i];
65+
if(t.ApproximatelyEquals(x.Position, 0.5f))
66+
{
67+
Towers[i] = default;
68+
}
69+
}
70+
}
71+
}
72+
73+
if(MechanicActive && (HasStatus(Debuff.Alpha) || MyDebuff != null))
74+
{
75+
var close = Controller.GetElementByName("Close");
76+
var far = Controller.GetElementByName("Far");
77+
var exit = Controller.GetElementByName("Exit");
78+
Element? e = null;
79+
if(HasStatus(Debuff.Pos1) || MyDebuff == Debuff.Pos1)
80+
{
81+
MyDebuff = Debuff.Pos1;
82+
if(Towers.SafeSelect(2) != default)
83+
{
84+
e = Controller.GetElementByName("TowerWaiting");
85+
if(GetRemainingTime(Debuff.Alpha) <= 0)
86+
{
87+
e = Controller.GetElementByName("TowerGet");
88+
}
89+
e?.SetRefPosition(Towers.SafeSelect(2));
90+
}
91+
}
92+
if(HasStatus(Debuff.Pos2) || MyDebuff == Debuff.Pos2)
93+
{
94+
MyDebuff = Debuff.Pos2;
95+
if(Towers.SafeSelect(3) != default)
96+
{
97+
e = Controller.GetElementByName("TowerWaiting");
98+
if(GetRemainingTime(Debuff.Alpha) <= 0)
99+
{
100+
e = Controller.GetElementByName("TowerGet");
101+
}
102+
e?.SetRefPosition(Towers.SafeSelect(3));
103+
}
104+
}
105+
if(HasStatus(Debuff.Pos3))
106+
{
107+
MyDebuff = Debuff.Pos3;
108+
if(Towers.SafeSelect(0) != default)
109+
{
110+
e = Controller.GetElementByName("TowerWaiting");
111+
if(GetRemainingTime(Debuff.Alpha) < 10f)
112+
{
113+
e = Controller.GetElementByName("TowerGet");
114+
}
115+
e?.SetRefPosition(Towers.SafeSelect(0));
116+
}
117+
else if(GetRemainingTime(Debuff.Alpha) < 10f)
118+
{
119+
close.refActorObjectID = Controller.GetPartyMembers().FirstOrDefault(x => HasStatus(x, Debuff.Pos3) && HasStatus(x, Debuff.Beta))?.EntityId ?? 0;
120+
}
121+
}
122+
if(HasStatus(Debuff.Pos4))
123+
{
124+
MyDebuff = Debuff.Pos4;
125+
if(Towers.SafeSelect(1) != default)
126+
{
127+
e = Controller.GetElementByName("TowerWaiting");
128+
if(GetRemainingTime(Debuff.Alpha) < 10f)
129+
{
130+
e = Controller.GetElementByName("TowerGet");
131+
}
132+
e?.SetRefPosition(Towers.SafeSelect(1));
133+
}
134+
}
135+
136+
e?.Enabled = true;
137+
}
138+
}
139+
140+
bool HasStatus(Debuff d)
141+
{
142+
return BasePlayer.StatusList.Any(x => x.StatusId == (uint)d);
143+
}
144+
145+
float GetRemainingTime(Debuff d)
146+
{
147+
return BasePlayer.StatusList.TryGetFirst(x => x.StatusId == (uint)d, out var status)?status.RemainingTime:0f;
148+
}
149+
150+
bool HasStatus(IBattleChara b, Debuff d)
151+
{
152+
return b.StatusList.Any(x => x.StatusId == (uint)d);
153+
}
154+
155+
public override void OnSettingsDraw()
156+
{
157+
if(ImGui.CollapsingHeader("Debug"))
158+
{
159+
}
160+
}
161+
162+
Config C => Controller.GetConfig<Config>();
163+
public class Config : IEzConfig
164+
{
165+
}
166+
}

0 commit comments

Comments
 (0)