-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathPlayerCharacter.cs
105 lines (90 loc) · 4.67 KB
/
PlayerCharacter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Memory;
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using FFXIVClientStructs.FFXIV.Client.Game.Fate;
using FFXIVClientStructs.FFXIV.Client.Game.Group;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.FFXIV.Client.UI;
using System.Linq;
using WrathCombo.Combos.PvE;
using Action = Lumina.Excel.Sheets.Action;
using GameMain = FFXIVClientStructs.FFXIV.Client.Game.GameMain;
namespace WrathCombo.CustomComboNS.Functions
{
internal abstract partial class CustomComboFunctions
{
/// <summary> Gets the player or null. </summary>
public static IPlayerCharacter? LocalPlayer => Svc.ClientState.LocalPlayer;
/// <summary> Find if the player has a certain condition. </summary>
/// <param name="flag"> Condition flag. </param>
/// <returns> A value indicating whether the player is in the condition. </returns>
public static bool HasCondition(ConditionFlag flag) => Svc.Condition[flag];
/// <summary> Find if the player is in combat. </summary>
/// <returns> A value indicating whether the player is in combat. </returns>
public static bool InCombat() => Svc.Condition[ConditionFlag.InCombat];
/// <summary> Find if the player is bound by duty. </summary>
/// <returns> A value indicating whether the player is bound by duty. </returns>
public unsafe static bool InDuty() => GameMain.Instance()->CurrentContentFinderConditionId > 0;
/// <summary> Find if the player has a pet present. </summary>
/// <returns> A value indicating whether the player has a pet (fairy/carbuncle) present. </returns>
public static bool HasPetPresent() => Svc.Buddies.PetBuddy != null;
/// <summary> Find if the player has a companion (chocobo) present. </summary>
/// <returns> A value indicating whether the player has a companion (chocobo). </returns>
public static bool HasCompanionPresent() => Svc.Buddies.CompanionBuddy != null;
/// <summary> Checks if the player is in a PVP enabled zone. </summary>
/// <returns> A value indicating whether the player is in a PVP enabled zone. </returns>
public static bool InPvP() => GameMain.IsInPvPArea() || GameMain.IsInPvPInstance();
/// <summary> Checks if the player has completed the required job quest for the ability. </summary>
/// <returns> A value indicating a quest has been completed for a job action.</returns>
public static unsafe bool IsActionUnlocked(uint id)
{
var unlockLink = Svc.Data.GetExcelSheet<Action>().GetRow(id).UnlockLink.RowId;
if (unlockLink == 0) return true;
return UIState.Instance()->IsUnlockLinkUnlockedOrQuestCompleted(unlockLink);
}
public unsafe static bool InFATE() => FateManager.Instance()->CurrentFate is not null && LocalPlayer.Level <= FateManager.Instance()->CurrentFate->MaxLevel;
public unsafe static bool PlayerHasTankStance()
{
return LocalPlayer.ClassJob.RowId switch
{
PLD.JobID or PLD.ClassID => HasEffect(PLD.Buffs.IronWill),
WAR.JobID or WAR.ClassID => HasEffect(WAR.Buffs.Defiance),
DRK.JobID => HasEffect(DRK.Buffs.Grit),
GNB.JobID => HasEffect(GNB.Buffs.RoyalGuard),
BLU.JobID => HasEffect(BLU.Buffs.TankMimicry),
_ => false
};
}
public unsafe static bool InBossEncounter()
{
if (NearbyBosses.Count() == 0)
return false;
foreach (var boss in NearbyBosses)
{
if (boss.Struct()->InCombat && boss.GetNameplateKind() == NameplateKind.HostileEngagedSelfDamaged)
return true;
}
return false;
}
public unsafe static AllianceGroup GetAllianceGroup()
{
if (GroupManager.Instance()->MainGroup.IsAlliance)
{
var array = UIModule.Instance()->GetRaptureAtkModule()->AtkModule.AtkArrayDataHolder.StringArrays[3]->StringArray[4];
var str = MemoryHelper.ReadSeStringNullTerminated(new System.IntPtr(array));
var lastChar = str.TextValue.Last();
return lastChar switch
{
'A' => AllianceGroup.GroupA,
'B' => AllianceGroup.GroupB,
'C' => AllianceGroup.GroupC,
_ => throw new ArgumentOutOfRangeException()
};
}
return AllianceGroup.NotInAlliance;
}
}
}