Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/PunishXIV/Splatoon
Browse files Browse the repository at this point in the history
  • Loading branch information
Limiana committed Dec 21, 2024
2 parents a06e094 + 49cd3d5 commit aa8e116
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,33 @@ public override void OnSettingsDraw()
C.SecondFixIndex == C.ThirdFixIndex)
ImGuiEx.Text(EColor.RedBright, "Indexes must be different");
}

ImGui.Checkbox("Enabled Flex Priority", ref C.FlexEnabled);

ImGui.Unindent();
}

if (C.FlexEnabled)
{
ImGui.Indent();
if (C.PriorityData.PriorityLists.First().IsRole)
{
ImGuiEx.EnumCombo("1st Flex Role", ref C.FirstFlexRole);
ImGuiEx.EnumCombo("2nd Flex Role", ref C.SecondFlexRole);
ImGuiEx.EnumCombo("3rd Flex Role", ref C.ThirdFlexRole);
}
else
{
ImGui.SliderInt("1st Flex Index", ref C.FirstFlexIndex, 0, 5);
ImGui.SliderInt("2nd Flex Index", ref C.SecondFlexIndex, 0, 5);
ImGui.SliderInt("3rd Flex Index", ref C.ThirdFlexIndex, 0, 5);

if (C.FirstFlexIndex == C.SecondFlexIndex || C.FirstFlexIndex == C.ThirdFlexIndex ||
C.SecondFlexIndex == C.ThirdFlexIndex)
ImGuiEx.Text(EColor.RedBright, "Indexes must be different");
}
ImGui.Unindent();
}

if (ImGui.CollapsingHeader("Debug"))
{
Expand Down Expand Up @@ -155,22 +179,30 @@ public override void OnStartingCast(uint source, uint castId)
_state = State.Split;
var list = C.PriorityData.GetFirstValidList();
var players = C.PriorityData.GetPlayers(x => true);
var towers = _currentTowers.Where(x => x != null).Select(x => x!).ToList();
if (list is null || players is null)
{
DuoLog.Warning("[P1 Burn Strike Tower] Priority list is not setup");
return;
}

if (towers.Count != 3)
{
DuoLog.Warning("[P1 Burn Strike Tower] Tower is null");
return;
}

var roleList = list.List
.Select(x =>
x.IsInParty(list.IsRole, out var upm) ? (upm.Name, x.Role) : ("", RolePosition.Not_Selected))
.ToDictionary(x => x.Item1, x => x.Item2);


if (C.FixEnabled)
{
List<string> nonFixed;
if (list.IsRole)
{
var roleList = list.List
.Select(x =>
x.IsInParty(list.IsRole, out var upm) ? (upm.Name, x.Role) : ("", RolePosition.Not_Selected))
.ToDictionary(x => x.Item1, x => x.Item2);
var myRole = roleList[Player.Name];
if (C.FirstFixRole == myRole)
_myTower = _currentTowers[0];
Expand All @@ -191,45 +223,90 @@ public override void OnStartingCast(uint source, uint castId)
_myTower = _currentTowers[1];
else if (myIndex == C.ThirdFixIndex)
_myTower = _currentTowers[2];

nonFixed = players
.Where((_, i) => i != C.FirstFixIndex && i != C.SecondFixIndex && i != C.ThirdFixIndex)
.Select(x => x.Name).ToList();
}

foreach (var tower in _currentTowers)
if (C.FlexEnabled)
{
if (tower is null)
Queue<string> nonDecided = [];
List<string> flexPlayers;
if (list.IsRole)
{
DuoLog.Warning("[P1 Burn Strike Tower] Tower is null");
continue;
flexPlayers = roleList
.Where(x => x.Value == C.FirstFlexRole || x.Value == C.SecondFlexRole ||
x.Value == C.ThirdFlexRole).Select(x => x.Key).ToList();
}
else
{
flexPlayers = players
.Where((_, i) => i == C.FirstFlexIndex || i == C.SecondFlexIndex || i == C.ThirdFlexIndex)
.Select(x => x.Name).ToList();
}

var towerCount = TowerCastIds.First(x => x.Value.Contains(tower.CastActionId)).Key;
var remaining = towerCount - 1;

if (remaining == 0) continue;
for (int i = 0; i < towers.Count; i++)
{
var tower = towers[i];
var player = flexPlayers[i];

var towerCount = TowerCastIds.First(x => x.Value.Contains(tower.CastActionId)).Key;
if (towerCount == 2)
{
if (player == Player.Name)
_myTower = tower;
}
else
{
nonDecided.Enqueue(player);
}
}

for (var i = 0; i < remaining; i++)
foreach (var tower in towers)
{
if (nonFixed.First() == Player.Name)
_myTower = tower;
nonFixed.RemoveAt(0);

var towerCount = TowerCastIds.First(x => x.Value.Contains(tower.CastActionId)).Key;
switch (towerCount)
{
case 3:
{
var first = nonDecided.Dequeue();
if (first == Player.Name)
_myTower = tower;
break;
}
case 4:
{
var first = nonDecided.Dequeue();
var second = nonDecided.Dequeue();
if (first == Player.Name || second == Player.Name)
_myTower = tower;
break;
}
}
}
}
else
{
foreach (var tower in towers)
{
var towerCount = TowerCastIds.First(x => x.Value.Contains(tower.CastActionId)).Key;
var remaining = towerCount - 1;
if (remaining == 0) continue;
for (var i = 0; i < remaining; i++)
{
if (nonFixed.First() == Player.Name)
_myTower = tower;
nonFixed.RemoveAt(0);
}
}
}
}

else
{
var index = 0;
foreach (var tower in _currentTowers)
foreach (var tower in towers)
{
if (tower is null)
{
DuoLog.Warning("[P1 Burn Strike Tower] Tower is null");
continue;
}

var towerCount = TowerCastIds.First(x => x.Value.Contains(tower.CastActionId)).Key;
var lastIndex = index;
index += towerCount;
Expand Down Expand Up @@ -260,15 +337,22 @@ private class Config : IEzConfig
public readonly Vector4 BaitColor1 = 0xFFFF00FF.ToVector4();
public readonly Vector4 BaitColor2 = 0xFFFFFF00.ToVector4();

public int FirstFixIndex;
public int FirstFixIndex = 0;
public RolePosition FirstFixRole = RolePosition.H1;

public bool FixEnabled;
public bool FlexEnabled;
public PriorityData6 PriorityData = new();
public int SecondFixIndex = 1;
public RolePosition SecondFixRole = RolePosition.H2;
public int ThirdFixIndex = 5;
public RolePosition ThirdFixRole = RolePosition.R2;

public int FirstFlexIndex = 2;
public RolePosition FirstFlexRole = RolePosition.M1;
public int SecondFlexIndex = 3;
public RolePosition SecondFlexRole = RolePosition.M2;
public int ThirdFlexIndex = 4;
public RolePosition ThirdFlexRole = RolePosition.R1;
}

private class PriorityData6 : PriorityData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.ClientState.Statuses;
Expand Down Expand Up @@ -74,7 +75,7 @@ public enum Mode
private State _state = State.None;

public override HashSet<uint>? ValidTerritories => [1238];
public override Metadata? Metadata => new(8, "Garume");
public override Metadata? Metadata => new(9, "Garume");

private Config C => Controller.GetConfig<Config>();

Expand Down Expand Up @@ -168,7 +169,7 @@ public override void OnGainBuffEffect(uint sourceId, Status Status)
var myKindFire = GetKindFire(Player.Status);
var random = 0;
if (C.ShouldUseRandomWait)
random = new Random().Next((int)(C.WaitRange.X * 1000), (int)(C.WaitRange.Y * 1000));
random = RandomNumberGenerator.GetInt32((int)(C.WaitRange.X * 1000), (int)(C.WaitRange.Y * 1000));
Controller.Schedule(() =>
{
switch (myKindFire)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.ClientState.Objects.Types;
Expand Down Expand Up @@ -85,7 +86,7 @@ private IPlayerCharacter BasePlayer
private bool IsActive => Svc.Objects.Any(x => x.DataId == 17837) && !BasePlayer.IsDead;

public override HashSet<uint>? ValidTerritories => [1238];
public override Metadata? Metadata => new(6, "Garume, NightmareXIV");
public override Metadata? Metadata => new(7, "Garume, NightmareXIV");

private Config C => Controller.GetConfig<Config>();

Expand Down Expand Up @@ -255,7 +256,7 @@ public override void OnGainBuffEffect(uint sourceId, Status Status)
{
var random = 0;
if (C.ShouldUseRandomWait)
random = new Random().Next((int)(C.WaitRange.X * 1000), (int)(C.WaitRange.Y * 1000));
random = RandomNumberGenerator.GetInt32((int)(C.WaitRange.X * 1000), (int)(C.WaitRange.Y * 1000));
Controller.Schedule(() => { Chat.Instance.ExecuteCommand(C.CommandWhenBlueDebuff); }, random);
}

Expand Down
Loading

0 comments on commit aa8e116

Please sign in to comment.