Skip to content

Commit

Permalink
Start of healing logic
Browse files Browse the repository at this point in the history
heal rotations now displayed in the ui
  • Loading branch information
DerpleMQ2 committed Jan 8, 2024
1 parent d225bb5 commit ff65820
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 87 deletions.
131 changes: 65 additions & 66 deletions class_configs/shm_class_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -591,58 +591,11 @@ local _ClassConfig = {
"Eradicate Poison",
},
},
['RotationOrder'] = {
-- Downtime doesn't have state because we run the whole rotation at once.
{ name = 'Downtime', targetId = function(self) return mq.TLO.Me.ID() end, cond = function(self, combat_state) return combat_state == "Downtime" and RGMercUtils.DoBuffCheck() end, },
-- [ Rotation only run in Heal Mode ] --
{
name = 'Splash',
state = 1,
steps = 1,
targetId = function(self) return RGMercUtils.GetMainAssistId() end,
cond = function(self, combat_state)
return combat_state == "Combat" and
self.ClassConfig.Modes[self.settings.Mode] == "Heal" and mq.TLO.Me.State():lower() ~= "feign"
end,
},
-- [ Rotation only run in Hybrid Mode ] --
{
name = 'Debuff',
state = 1,
steps = 1,
targetId = function(self) return RGMercConfig.Globals.AutoTargetID end,
cond = function(self, combat_state)
return combat_state == "Combat" and
self.ClassConfig.Modes[self.settings.Mode] == "Hybrid" and mq.TLO.Me.State():lower() ~= "feign"
end,
},
{
name = 'Burn',
state = 1,
steps = 1,
targetId = function(self) return RGMercConfig.Globals.AutoTargetID end,
cond = function(self, combat_state)
return combat_state == "Combat" and
RGMercUtils.BurnCheck() and self.ClassConfig.Modes[self.settings.Mode] == "Hybrid" and mq.TLO.Me.State():lower() ~= "feign"
end,
},
{
name = 'DPS',
state = 1,
steps = 1,
targetId = function(self) return RGMercConfig.Globals.AutoTargetID end,
cond = function(self, combat_state)
return combat_state == "Combat" and self.ClassConfig.Modes[self.settings.Mode] == "Hybrid" and mq.TLO.Me.State():lower() ~= "feign"
end,
},

},
-- These are handled differently from normal rotations in that we try to make some intelligent desicions about which spells to use instead
-- of just slamming through the base ordered list.
-- These will run in order and exit after the first valid spell to cast
['HealPoints'] = {
{
name = "LowLevelHealPoint",
['HealRotations'] = {
["LowLevelHealPoint"] = {
cond = function(self, target) return mq.TLO.Me.Level() < 65 and (target.PctHPs() or 999) < 80 end,
state = 1,
steps = 1,
Expand All @@ -669,8 +622,7 @@ local _ClassConfig = {
},
},
},
{
name = "GroupHealPoint",
["GroupHealPoint"] = {
cond = function(self, target) return mq.TLO.Group.Injured(RGMercConfig:GetSettings().GroupHealPoint) > RGMercConfig:GetSettings().GroupInjureCnt end,
state = 1,
steps = 1,
Expand All @@ -681,8 +633,7 @@ local _ClassConfig = {
},
},
},
{
name = "BigHealPoint",
["BigHealPoint"] = {
cond = function(self, target) return (target.PctHPs() or 999) < RGMercConfig:GetSettings().BigHealPoint end,
state = 1,
steps = 1,
Expand All @@ -697,57 +648,105 @@ local _ClassConfig = {
},
},
},
{
name = "MainHealPoint",
["MainHealPoint"] = {
cond = function(self, target) return (target.PctHPs() or 999) < RGMercConfig:GetSettings().MainHealPoint end,
state = 1,
steps = 1,
rotation = {
{
name = "RecourseHeal",
type = "Spell",
cond = function(self, _) return RGMercUtils.GetMainAssistPctHPs() <= RGMercConfig:GetSettings().MainHealPoint end,
cond = function(self, _, target)
return (target.ID() or 0) == RGMercUtils.GetMainAssistId()
end,
},
{
name = "AESpiritualHeal",
type = "Spell",
cond = function(self, _) return RGMercUtils.GetMainAssistPctHPs() <= RGMercConfig:GetSettings().MainHealPoint end,
cond = function(self, _, target)
return (target.ID() or 0) == RGMercUtils.GetMainAssistId()
end,
},
{
name = "GroupRenewalHoT",
type = "Spell",
cond = function(self, spell)
return RGMercUtils.GetMainAssistPctHPs() <= RGMercConfig:GetSettings().MainHealPoint and self.settings.DoHOT and spell.StacksTarget() and
not RGMercUtils.TargetHasBuff(spell)
cond = function(self, spell, target)
return self.settings.DoHOT and spell.StacksTarget() and not RGMercUtils.TargetHasBuff(spell)
end,
},
{
name = "Spirit Guardian",
type = "AA",
cond = function(self, aaName)
return RGMercUtils.GetMainAssistPctHPs() <= RGMercConfig:GetSettings().MainHealPoint
cond = function(self, _, target)
return (target.ID() or 0) == RGMercUtils.GetMainAssistId()
end,
},
{
name = "RecklessHeal1",
type = "Spell",
cond = function(self, _) return RGMercUtils.GetMainAssistPctHPs() <= self.settings.RecklessHealPct end,
cond = function(self, _, target) return (target.PctHPs() or 999) <= self.settings.RecklessHealPct end,
},
{
name = "RecklessHeal2",
type = "Spell",
cond = function(self, _) return RGMercUtils.GetMainAssistPctHPs() <= RGMercConfig:GetSettings().MainHealPoint end,
cond = function(self, _, target) return true end,
},
{
name = "Soothsayer's Intervention",
type = "AA",
cond = function(self, aaName)
return RGMercUtils.GetMainAssistPctHPs() <= RGMercConfig:GetSettings().MainHealPoint
cond = function(self, _, target)
return true
end,
},
},
},
},
['RotationOrder'] = {
-- Downtime doesn't have state because we run the whole rotation at once.
{ name = 'Downtime', targetId = function(self) return mq.TLO.Me.ID() end, cond = function(self, combat_state) return combat_state == "Downtime" and RGMercUtils.DoBuffCheck() end, },
-- [ Rotation only run in Heal Mode ] --
{
name = 'Splash',
state = 1,
steps = 1,
targetId = function(self) return RGMercUtils.GetMainAssistId() end,
cond = function(self, combat_state)
return combat_state == "Combat" and
self.ClassConfig.Modes[self.settings.Mode] == "Heal" and mq.TLO.Me.State():lower() ~= "feign"
end,
},
-- [ Rotation only run in Hybrid Mode ] --
{
name = 'Debuff',
state = 1,
steps = 1,
targetId = function(self) return RGMercConfig.Globals.AutoTargetID end,
cond = function(self, combat_state)
return combat_state == "Combat" and
self.ClassConfig.Modes[self.settings.Mode] == "Hybrid" and mq.TLO.Me.State():lower() ~= "feign"
end,
},
{
name = 'Burn',
state = 1,
steps = 1,
targetId = function(self) return RGMercConfig.Globals.AutoTargetID end,
cond = function(self, combat_state)
return combat_state == "Combat" and
RGMercUtils.BurnCheck() and self.ClassConfig.Modes[self.settings.Mode] == "Hybrid" and mq.TLO.Me.State():lower() ~= "feign"
end,
},
{
name = 'DPS',
state = 1,
steps = 1,
targetId = function(self) return RGMercConfig.Globals.AutoTargetID end,
cond = function(self, combat_state)
return combat_state == "Combat" and self.ClassConfig.Modes[self.settings.Mode] == "Hybrid" and mq.TLO.Me.State():lower() ~= "feign"
end,
},

},
['Rotations'] = {
['Splash'] = {
{
Expand Down
2 changes: 1 addition & 1 deletion extras/version.lua
Original file line number Diff line number Diff line change
@@ -1 +1 @@
return { commitId = 'b531869 2024-01-07' }
return { commitId = 'd225bb5 2024-01-07' }
50 changes: 36 additions & 14 deletions modules/class.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@ local RGMercUtils = require("utils.rgmercs_utils")
local Set = require("mq.Set")
require('utils.rgmercs_datatypes')

local Module = { _version = '0.1a', _name = "Class", _author = 'Derple', }
Module.__index = Module
Module.LastPetCmd = 0
Module.ModuleLoaded = false
Module.ShowFailedSpells = false
Module.ReloadingLoadouts = true
Module.SpellLoadOut = {}
Module.ResolvedActionMap = {}
Module.TempSettings = {}
Module.CombatState = "None"
Module.ClassConfig = nil
Module.DefaultCategories = nil
local Module = { _version = '0.1a', _name = "Class", _author = 'Derple', }
Module.__index = Module
Module.LastPetCmd = 0
Module.ModuleLoaded = false
Module.ShowFailedSpells = false
Module.ReloadingLoadouts = true
Module.SpellLoadOut = {}
Module.ResolvedActionMap = {}
Module.TempSettings = {}
Module.CombatState = "None"
Module.ClassConfig = nil
Module.DefaultCategories = nil

-- Track the state of rotations between frames
Module.TempSettings.RotationStates = {}
Module.TempSettings.RotationStates = {}
Module.TempSettings.HealingRotationStates = {}

local newCombatMode = false
local newCombatMode = false

local function getConfigFileName()
return mq.configDir ..
Expand Down Expand Up @@ -64,6 +65,10 @@ function Module:LoadSettings()
Module.TempSettings.RotationStates = {}
for i, m in ipairs(self.ClassConfig.RotationOrder or {}) do Module.TempSettings.RotationStates[i] = m end

-- these are different since they arent strickly ordered but based on conditions of the target.
Module.TempSettings.HealingRotationStates = {}
for n, m in pairs(self.ClassConfig.HealRotations or {}) do Module.TempSettings.HealingRotationStates[n] = m end

RGMercsLogger.log_info("\ar%s\ao Core Module Loading Settings for: %s.", RGMercConfig.Globals.CurLoadedClass, RGMercConfig.Globals.CurLoadedChar)
RGMercsLogger.log_info("\ayUsing Class Config by: \at%s\ay (\am%s\ay)", self.ClassConfig._author, self.ClassConfig._version)
local settings_pickle_path = getConfigFileName()
Expand Down Expand Up @@ -182,6 +187,23 @@ function Module:Render()
end
end

if not self.ReloadingLoadouts then
if ImGui.CollapsingHeader("Healing Rotations") then
ImGui.Indent()
RGMercUtils.RenderRotationTableKey()

for n, r in pairs(self.TempSettings.HealingRotationStates) do
if ImGui.CollapsingHeader(n) then
ImGui.Indent()
Module.ShowFailedSpells = RGMercUtils.RenderRotationTable(self, n, r.rotation,
self.ResolvedActionMap, r.state or 0, Module.ShowFailedSpells)
ImGui.Unindent()
end
end
ImGui.Unindent()
end
end

ImGui.Text(string.format("Combat State: %s", self.CombatState))
end
end
Expand Down
14 changes: 8 additions & 6 deletions utils/rgmercs_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,9 @@ function Utils.RunRotation(s, r, targetId, map, steps, start_step, bAllowMem)
lastStepIdx = idx
if entry.cond then
local condArg = Utils.GetEntryConditionArg(map, entry)
RGMercsLogger.log_verbose("\ay :: Testing Codition for entry(%s) type(%s) cond(s, %s)", entry.name, entry.type, condArg)
local pass = entry.cond(s, condArg)
local condTarg = mq.TLO.Spawn(targetId)
RGMercsLogger.log_verbose("\ay :: Testing Codition for entry(%s) type(%s) cond(s, %s, %s)", entry.name, entry.type, condArg, condTarg.CleanName() or "None")
local pass = entry.cond(s, condArg, condTarg)
if pass == true then
local res = Utils.ExecEntry(s, entry, targetId, map, bAllowMem)
if res == true then
Expand Down Expand Up @@ -938,7 +939,7 @@ function Utils.GetMainAssistId()
return mq.TLO.Spawn(string.format("PC =%s", RGMercConfig.Globals.MainAssist)).ID() or 0
end

function Utils.GetAssistPctHPs()
function Utils.GetMainAssistPctHPs()
return mq.TLO.Spawn(string.format("PC =%s", RGMercConfig.Globals.MainAssist)).PctHPs() or 0
end

Expand Down Expand Up @@ -2056,9 +2057,10 @@ function Utils.RenderRotationTable(s, n, t, map, rotationState, showFailed)
end
ImGui.TableNextColumn()
if entry.cond then
local condArg = Utils.GetEntryConditionArg(map, entry)
local pass = entry.cond(s, condArg)
local active = entry.active_cond and entry.active_cond(s, condArg) or false
local condArg = Utils.GetEntryConditionArg(map, entry)
local condTarg = mq.TLO.Target
local pass = entry.cond(s, condArg, condTarg)
local active = entry.active_cond and entry.active_cond(s, condArg) or false

if active == true then
ImGui.PushStyleColor(ImGuiCol.Text, 0.03, 1.0, 0.3, 1.0)
Expand Down

0 comments on commit ff65820

Please sign in to comment.