Skip to content

Commit

Permalink
- Added go2ggh command
Browse files Browse the repository at this point in the history
- Fixed Mounting
  • Loading branch information
DerpleMQ2 committed Jan 3, 2024
1 parent d9a02be commit a2f317d
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 64 deletions.
6 changes: 5 additions & 1 deletion modules/class.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ function Module:LoadSettings()
end
end


Module.TempSettings.RotationStates = {}
for _, m in ipairs(self.ClassConfig.Modes) do table.insert(Module.TempSettings.RotationStates, m) end

Expand All @@ -77,6 +76,11 @@ function Module:LoadSettings()
self.settings = config()
end

if not self.settings or not self.DefaultCategories or not self.DefaultConfig then
RGMercsLogger.log_error("Failed to Load Core Class Config for Classs: %s", RGMercConfig.Globals.CurLoadedClass)
return
end

-- Setup Defaults
self.settings = RGMercUtils.ResolveDefaults(self.ClassConfig.DefaultConfig, self.settings)

Expand Down
44 changes: 44 additions & 0 deletions modules/movement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Module.__index = Module
Module.ModuleLoaded = false
Module.TempSettings = {}
Module.TempSettings.CampZoneId = 0
Module.TempSettings.Go2GGH = 0

Module.Constants = {}
Module.Constants.GGHZones = Set.new({ "poknowledge", "potranquility", "stratos", "guildlobby", "moors", "crescent", "guildhalllrg_int", "guildhall", })

Module.DefaultConfig = {
['AutoCampRadius'] = { DisplayName = "Auto Camp Radius", Category = "Camp", Tooltip = "Return to camp after you get this far away", Default = 60, Min = 10, Max = 150, },
Expand Down Expand Up @@ -282,6 +286,14 @@ function Module:ShouldFollow()
(RGMercUtils.GetXTHaterCount() == 0 or (assistSpawn() and assistSpawn.Distance() > self.settings.ChaseDistance))
end

function Module:Go2GGH()
if not mq.TLO.Me.GuildID() or mq.TLO.Me.GuildID() == 0 then
RGMercsLogger.log_warning("\awNOTICE:\ax You're not in a guild!")
return
end
self.TempSettings.Go2GGH = 1
end

function Module:GiveTime(combat_state)
if mq.TLO.Me.Dead() and self.settings.ChaseOn then
RGMercsLogger.log_warning("\awNOTICE:\ax You're dead. I'm not chasing \am%s\ax anymore.",
Expand All @@ -291,6 +303,35 @@ function Module:GiveTime(combat_state)
return
end

if self.TempSettings.Go2GGH >= 1 then
if self.TempSettings.Go2GGH == 1 then
if not self.Constants.GGHZones:contains(mq.TLO.Zone.ShortName():lower()) then
if not RGMercUtils.UseOrigin() then
RGMercsLogger.log_warning("\awNOTICE:\ax Go2GGH Failed.")
self.TempSettings.Go2GGH = 0
else
self.TempSettings.Go2GGH = 2
end
else
-- in a known zone.
self.TempSettings.Go2GGH = 2
end
end

if self.TempSettings.Go2GGH == 2 then
if mq.TLO.Zone.ShortName():lower() == "guildhalllrg_int" or mq.TLO.Zone.ShortName():lower() == "guildhall" then
RGMercsLogger.log_debug("\a\ag--\atGoing to Pool \ag--")
mq.cmdf("/squelch /moveto loc 1 1 3")
RGMercsLogger.log_debug("\ag --> \atYou made it \ag<--")
self.TempSettings.Go2GGH = 0
elseif mq.TLO.Zone.ShortName():lower() ~= "guildlobby" and not mq.TLO.Navigation.Active() then
mq.cmdf("/squelch /travelto guildlobby")
elseif mq.TLO.Zone.ShortName():lower() == "guildlobby" and not mq.TLO.Navigation.Active() then
mq.cmdf("/squelch /nav door id 1 click")
end
end
end

if combat_state == "Downtime" then
if RGMercUtils.ShouldShrink() then
RGMercUtils.UseItem(RGMercConfig:GetSettings().ShrinkItem, mq.TLO.Me.ID())
Expand Down Expand Up @@ -389,6 +430,9 @@ function Module:HandleBind(cmd, ...)
elseif cmd:lower() == "campoff" then
self:ChaseOff()
handled = true
elseif cmd:lower() == "go2ggh" then
self:Go2GGH()
handled = true
end

return handled
Expand Down
162 changes: 100 additions & 62 deletions utils/rgmercs_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,71 @@ function Utils.ActionPrep()
end
end

---@param aaName string
---@param targetId integer
function Utils.UseAA(aaName, targetId)
local me = mq.TLO.Me
local oldTargetId = mq.TLO.Target.ID()

local aaAbility = mq.TLO.Me.AltAbility(aaName)

if not aaAbility() then
RGMercsLogger.log_verbose("\arYou dont have the AA: %s!", aaName)
return
end

if not mq.TLO.Me.AltAbilityReady(aaName) then
RGMercsLogger.log_verbose("\ayAbility %s is not ready!", aaName)
return
end

if mq.TLO.Window("CastingWindow").Open() or me.Casting.ID() then
if me.Class.ShortName():lower() == "brd" then
mq.delay("3s", function() return (not mq.TLO.Window("CastingWindow").Open()) end)
mq.delay(10)
mq.cmdf("/stopsong")
else
RGMercsLogger.log_debug("\ayCANT CAST AA - Casting Window Open")
return
end
end

local target = mq.TLO.Spawn(targetId)

-- If we're combat casting we need to both have the same swimming status
if target() and target.FeetWet() ~= me.FeetWet() then
return
end

Utils.ActionPrep()

if Utils.GetTargetID() ~= targetId and target() then
if me.Combat() and target.Type():lower() == "pc" then
RGMercsLogger.log_info("\awNOTICE:\ax Turning off autoattack to cast on a PC.")
mq.cmdf("/attack off")
mq.delay("2s", function() return not me.Combat() end)
end

Utils.SetTarget(targetId)
end

local cmd = string.format("/alt act %d", aaAbility.ID())

RGMercsLogger.log_debug("\ayActivating AA: '%s' [t: %d]", cmd, aaAbility.Spell.MyCastTime.TotalSeconds())
mq.cmdf(cmd)

mq.delay(5)

if aaAbility.Spell.MyCastTime.TotalSeconds() > 0 then
mq.delay(string.format("%ds", aaAbility.Spell.MyCastTime.TotalSeconds()))
end

RGMercsLogger.log_debug("switching target back to old target after casting aa")
Utils.SetTarget(oldTargetId)

return
end

function Utils.UseItem(itemName, targetId)
local me = mq.TLO.Me

Expand Down Expand Up @@ -356,7 +421,7 @@ function Utils.UseItem(itemName, targetId)

mq.delay(2)

if not item.CastTime() then
if not item.CastTime() or item.CastTime() == 0 then
-- slight delay for instant casts
mq.delay(4)
else
Expand Down Expand Up @@ -449,64 +514,7 @@ function Utils.ExecEntry(e, targetId, map, bAllowMem)
end

if e.type:lower() == "aa" then
local oldTarget = Utils.GetTargetID()

local s = mq.TLO.Me.AltAbility(e.name)

if not s then
RGMercsLogger.log_warning("\ayYou do not have the AA Ability: %s!", s.RankName())
return
end

if mq.TLO.Window("CastingWindow").Open() or me.Casting.ID() then
if me.Class.ShortName():lower() == "brd" then
mq.delay("3s", function() return (not mq.TLO.Window("CastingWindow").Open()) end)
mq.delay(10)
mq.cmdf("/stopsong")
else
RGMercsLogger.log_debug("\ayCANT CAST AA - Casting Window Open")
return
end
end

if not mq.TLO.Me.AltAbilityReady(e.name)() then
RGMercsLogger.log_verbose("\ayAbility %s is not ready!", e.name)
return
end

local target = mq.TLO.Spawn(targetId)

-- If we're combat casting we need to both have the same swimming status
if target() and target.FeetWet() ~= me.FeetWet() then
return
end

Utils.ActionPrep()

if Utils.GetTargetID() ~= targetId and target() then
if me.Combat() and target.Type():lower() == "pc" then
RGMercsLogger.log_info("\awNOTICE:\ax Turning off autoattack to cast on a PC.")
mq.cmdf("/attack off")
mq.delay("2s", function() return not me.Combat() end)
end

Utils.SetTarget(targetId)
end

cmd = string.format("/alt act %d", s.ID())

RGMercsLogger.log_debug("\ayActivating AA: '%s' [t: %d]", cmd, me.AltAbility(e.name).Spell.MyCastTime.TotalSeconds())
mq.cmdf(cmd)

mq.delay(5)

if me.AltAbility(e.name).Spell.MyCastTime.TotalSeconds() > 0 then
mq.delay(string.format("%ds", me.AltAbility(e.name).Spell.MyCastTime.TotalSeconds()))
end

RGMercsLogger.log_debug("switching target back to old target after casting aa")
Utils.SetTarget(oldTarget)

Utils.UseAA(e.name, targetId)
return
end

Expand Down Expand Up @@ -746,9 +754,13 @@ function Utils.ShouldShrink()
end

function Utils.ShouldMount()
return not RGMercConfig:GetSettings().DoMelee and RGMercConfig:GetSettings().MountItem:len() > 0 and mq.TLO.Zone.Outdoor() and
((RGMercConfig:GetSettings().DoMount == 1 and (mq.TLO.Me.Mount.ID() or 0) == 0) or
((RGMercConfig:GetSettings().DoMount == 2 and mq.TLO.Me.Buff("Mount Blessing").ID() or 0) == 0))
if RGMercConfig:GetSettings().DoMount == 0 then return end

local passBasicChecks = not RGMercConfig:GetSettings().DoMelee and RGMercConfig:GetSettings().MountItem:len() > 0 and mq.TLO.Zone.Outdoor()

local passCheckMountOne = ((RGMercConfig:GetSettings().DoMount == 1 and (mq.TLO.Me.Mount.ID() or 0) == 0))
local passCheckMountTwo = ((RGMercConfig:GetSettings().DoMount == 2 and (mq.TLO.Me.Buff("Mount Blessing").ID() or 0) == 0))
return passBasicChecks and passCheckMountOne or passCheckMountTwo
end

function Utils.ShouldDismount()
Expand Down Expand Up @@ -879,6 +891,32 @@ function Utils.DoBuffCheck()
return true
end

function Utils.UseOrigin()
if mq.TLO.FindItem("=Drunkard's Stein").ID() or 0 > 0 and mq.TLO.Me.ItemReady("=Drunkard's Stein") then
RGMercsLogger.log_debug("\ag--\atFound a Drunkard's Stein, using that to get to PoK\ag--")
Utils.UseItem("Drunkard's Stein")
return true
end

if Utils.AAReady("Throne of Heroes") then
RGMercsLogger.log_debug("\ag--\atUsing Throne of Heroes to get to Guild Lobby\ag--")
RGMercsLogger.log_debug("\ag--\atAs you not within a zone we know\ag--")

Utils.UseAA("Throne of Heroes", mq.TLO.Me.ID())
return true
end

if Utils.AAReady("Origin") then
RGMercsLogger.log_debug("\ag--\atUsing Origin to get to Guild Lobby\ag--")
RGMercsLogger.log_debug("\ag--\atAs you not within a zone we know\ag--")

Utils.UseAA("Origin", mq.TLO.Me.ID())
return true
end

return false
end

function Utils.DoCamp()
return Utils.GetXTHaterCount() == 0 and RGMercConfig.Globals.AutoTargetID == 0
end
Expand Down
2 changes: 1 addition & 1 deletion version.lua
Original file line number Diff line number Diff line change
@@ -1 +1 @@
return { commitId = '28cc54d 2024-01-02' }
return { commitId = 'd9a02be 2024-01-02' }

0 comments on commit a2f317d

Please sign in to comment.