Skip to content

Commit

Permalink
normal witch hunt
Browse files Browse the repository at this point in the history
  • Loading branch information
Limiana committed Aug 3, 2024
1 parent 1aa1bbe commit e34f5cc
Showing 1 changed file with 56 additions and 3 deletions.
59 changes: 56 additions & 3 deletions SplatoonScripts/Duties/Dawntrail/R4S Witch Hunt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using ECommons;
using ECommons.Configuration;
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using ECommons.GameHelpers;
using ECommons.Hooks;
using ECommons.Hooks.ActionEffectTypes;
using ECommons.ImGuiMethods;
Expand All @@ -20,7 +22,7 @@ namespace SplatoonScriptsOfficial.Duties.Dawntrail;
public class R4S_Witch_Hunt : SplatoonScript
{
public override HashSet<uint>? ValidTerritories { get; } = [1232];
public override Metadata? Metadata => new(2, "NightmareXIV");
public override Metadata? Metadata => new(3, "NightmareXIV");

uint CastNarrowing = 38369;
uint CastWidening = 38368;
Expand All @@ -32,6 +34,7 @@ public class R4S_Witch_Hunt : SplatoonScript
bool? IsInitialClose = null;
int NumSwitches = 0;
long ForceResetAt = long.MaxValue;
uint CastStandard = 38366;

IBattleNpc? WickedThunder => Svc.Objects.OfType<IBattleNpc>().FirstOrDefault(x => x.NameId == 13057 && x.IsTargetable);

Expand All @@ -42,7 +45,7 @@ public override void OnSetup()

for(int i = 0; i < 4; i++)
{
Controller.RegisterElementFromCode($"Target{i}", "{\"Name\":\"Hunted\",\"type\":1,\"radius\":6.0,\"color\":3355508712,\"fillIntensity\":0.05,\"originFillColor\":1677721855,\"endFillColor\":1677721855,\"thicc\":5.0,\"refActorComparisonType\":2,\"refActorTetherTimeMin\":0.0,\"refActorTetherTimeMax\":0.0,\"refActorTetherConnectedWithPlayer\":[]}");
Controller.RegisterElementFromCode($"Target{i}", "{\"Name\":\"Hunted\",\"type\":1,\"radius\":6.0,\"color\":3355508712,\"fillIntensity\":0.05,\"originFillColor\":1677721855,\"endFillColor\":1677721855,\"thicc\":3.0,\"refActorComparisonType\":2,\"refActorTetherTimeMin\":0.0,\"refActorTetherTimeMax\":0.0,\"refActorTetherConnectedWithPlayer\":[]}");
}

Controller.RegisterElementFromCode("InClose", "{\"Name\":\"BaitersAreaInClose\",\"type\":1,\"Enabled\":false,\"radius\":7.0,\"color\":3355508490,\"fillIntensity\":0.4,\"originFillColor\":1677721855,\"endFillColor\":1677721855,\"refActorNPCNameID\":13057,\"refActorComparisonType\":6,\"onlyTargetable\":true,\"refActorTetherTimeMin\":0.0,\"refActorTetherTimeMax\":0.0,\"refActorTetherConnectedWithPlayer\":[]}");
Expand All @@ -53,10 +56,18 @@ public override void OnSetup()
Controller.RegisterElementFromCode("Warning", "{\"Name\":\"\",\"type\":1,\"Enabled\":false,\"overlayBGColor\":4278190080,\"overlayTextColor\":4278255360,\"overlayFScale\":2.0,\"overlayVOffset\":1.5,\"radius\":0,\"thicc\":0,\"overlayText\":\"GO GREEN\",\"refActorType\":1,\"refActorTetherTimeMin\":0.0,\"refActorTetherTimeMax\":0.0,\"refActorTetherConnectedWithPlayer\":[]}");

Controller.RegisterElementFromCode("Prepare", "{\"Name\":\"\",\"type\":1,\"Enabled\":false,\"overlayBGColor\":4278190080,\"overlayTextColor\":4278255360,\"overlayFScale\":1.0,\"overlayVOffset\":1.5,\"radius\":0,\"thicc\":0,\"overlayText\":\"Prepare...\",\"refActorType\":1,\"refActorTetherTimeMin\":0.0,\"refActorTetherTimeMax\":0.0,\"refActorTetherConnectedWithPlayer\":[]}");

Controller.RegisterElementFromCode("NormalMid", "{\"Name\":\"\",\"type\":2,\"refX\":120.0,\"refY\":100.0,\"offX\":80.0,\"offY\":100.0,\"radius\":12.0,\"color\":3355508223,\"fillIntensity\":0.2,\"originFillColor\":1157628159,\"endFillColor\":1157628159,\"refActorTetherTimeMin\":0.0,\"refActorTetherTimeMax\":0.0}");
Controller.RegisterElementFromCode("NormalSide1", "{\"Name\":\"\",\"type\":2,\"refX\":120.0,\"refY\":85.0,\"offX\":80.0,\"offY\":85.0,\"radius\":7.0,\"color\":3355508223,\"fillIntensity\":0.2,\"originFillColor\":1157628159,\"endFillColor\":1157628159,\"refActorTetherTimeMin\":0.0,\"refActorTetherTimeMax\":0.0}");
Controller.RegisterElementFromCode("NormalSide2", "{\"Name\":\"\",\"type\":2,\"refX\":120.0,\"refY\":115.0,\"offX\":80.0,\"offY\":115.0,\"radius\":7.0,\"color\":3355508223,\"fillIntensity\":0.2,\"originFillColor\":1157628159,\"endFillColor\":1157628159,\"refActorTetherTimeMin\":0.0,\"refActorTetherTimeMax\":0.0}");
}

public override void OnSettingsDraw()
{
ImGui.Checkbox("Resolve normal witch hunt", ref C.Normal);
ImGui.Separator();
ImGui.Checkbox("Always show baits", ref C.Uncond);

ImGui.SetNextItemWidth(150f);
ImGui.InputInt("Your turn to bait (close first or both if far first isn't set)", ref C.MyTurn.ValidateRange(1, 4));

Expand Down Expand Up @@ -96,6 +107,42 @@ public override void OnUpdate()
}
ForceResetAt = Environment.TickCount64 + 30 * 1000;
}
if(C.Normal && w.IsCasting && w.CastActionId.EqualsAny(this.CastStandard))
{
var players = Svc.Objects.OfType<IPlayerCharacter>().OrderBy(x => Vector3.Distance(x.Position, this.WickedThunder!.Position)).ToList();
if(w.StatusList.Any(x => x.StatusId == this.StatusCloseFar && x.Param == this.StatusParamClose))
{
if(Player.Object.StatusList.Any(x => x.StatusId == 587))
{
Controller.GetElementByName("NormalMid")!.Enabled = true;
}
else
{
Controller.GetElementByName("NormalSide1")!.Enabled = true;
Controller.GetElementByName("NormalSide2")!.Enabled = true;
}
}
else
{
players.Reverse();
if(Player.Object.StatusList.Any(x => x.StatusId == 587))
{

Controller.GetElementByName("NormalSide1")!.Enabled = true;
Controller.GetElementByName("NormalSide2")!.Enabled = true;
}
else
{
Controller.GetElementByName("NormalMid")!.Enabled = true;
}
}
for(int i = 0; i < 4; i++)
{
var e = Controller.GetElementByName($"Target{i}");
e.Enabled = true;
e.refActorObjectID = players[i].EntityId;
}
}
}
var myTurn = IsInitialClose == false ? C.MyTurn : (C.MyTurnFarFirst ?? C.MyTurn);
if(IsUnsafeMiddle != null)
Expand All @@ -109,7 +156,7 @@ public override void OnUpdate()
baiterZone.Enabled = true;


if(myTurn - 1 == this.NumSwitches)
if(C.Uncond || myTurn - 1 == this.NumSwitches)
{
var players = Svc.Objects.OfType<IPlayerCharacter>().OrderBy(x => Vector3.Distance(x.Position, this.WickedThunder!.Position)).ToList();
if(!baitsClose) players.Reverse();
Expand All @@ -119,6 +166,10 @@ public override void OnUpdate()
e.Enabled = true;
e.refActorObjectID = players[i].EntityId;
}
}

if(myTurn - 1 == this.NumSwitches)
{
var warning = Controller.GetElementByName("Warning")!;
warning.Enabled = true;
warning.color = GradientColor.Get(EColor.GreenBright, EColor.White, 500).ToUint();
Expand Down Expand Up @@ -161,6 +212,8 @@ void Reset()
Config C => Controller.GetConfig<Config>();
public class Config : IEzConfig
{
public bool Uncond = false;
public bool Normal = true;
public int MyTurn = 1;
public int? MyTurnFarFirst = null;
}
Expand Down

0 comments on commit e34f5cc

Please sign in to comment.