Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Jailer of Faith QM every 30 minutes #4552

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions scripts/zones/The_Garden_of_RuHmet/Zone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ zoneObject.onInitialize = function(zone)
qmDrk:setPos(unpack(ID.npc.QM_IXAERN_DRK_POS[qmDrkPos]))
qmDrk:setLocalVar('hatedPlayer', 0)

-- Give the Faith ??? a random spawn
local qmFaith = GetNPCByID(ID.npc.QM_JAILER_OF_FAITH)
qmFaith:setPos(unpack(ID.npc.QM_JAILER_OF_FAITH_POS[math.random(1, 5)]))

-- Give Ix'DRG a random placeholder by picking one of the four groups at random, then adding a random number of 0-2 for the specific mob.
local groups = ID.mob.AWAERN_DRG_GROUPS
SetServerVariable('[SEA]IxAernDRG_PH', groups[math.random(1, #groups)] + math.random(0, 2))
Expand All @@ -83,14 +79,6 @@ end
zoneObject.onGameHour = function(zone)
local vanadielHour = VanadielHour()
local qmDrk = GetNPCByID(ID.npc.QM_IXAERN_DRK) -- Ix'aern drk
local s = math.random(6, 12) -- wait time till change to next spawn pos, random 15~30 mins.

-- Jailer of Faith spawn randomiser
if vanadielHour % s == 0 then
local qmFaith = GetNPCByID(ID.npc.QM_JAILER_OF_FAITH) -- Jailer of Faith
qmFaith:hideNPC(60) -- Hide it for 60 seconds
qmFaith:setPos(unpack(ID.npc.QM_JAILER_OF_FAITH_POS[math.random(1, 5)])) -- Set the new position
end

-- Ix'DRK spawn randomiser
if vanadielHour % 12 == 0 and qmDrk:getStatus() ~= xi.status.DISAPPEAR then -- Change ??? position every 12 hours Vana'diel time (30 mins)
Expand Down
44 changes: 44 additions & 0 deletions scripts/zones/The_Garden_of_RuHmet/globals.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
-- Zone: The_Garden_of_RuHmet (35)
-----------------------------------
local ID = zones[xi.zone.THE_GARDEN_OF_RUHMET]
-----------------------------------

local moveJailerOfFaithQM
moveJailerOfFaithQM = function(qmFaith, respawnDelay)
local timersRunning = qmFaith:getLocalVar('timersRunning')
local shouldMove = true

-- If respawnDelay is not set, this is a timer callback. An extra timer may be
-- running if JoF is spawned and killed before the previous timer triggers
if respawnDelay == nil then
timersRunning = timersRunning - 1
-- Only move the QM if the QM is not hidden and there's no other timers running
shouldMove = qmFaith:getStatus() ~= xi.status.DISAPPEAR and timersRunning == 0
end

if shouldMove then
-- Move to a random predefined position
qmFaith:setPos(unpack(ID.npc.QM_JAILER_OF_FAITH_POS[math.random(1, 5)]))

-- Base delay before next move is 30 minutes
local delay = utils.minutes(30)

if respawnDelay ~= nil then
-- If this was triggered from a JoF despawn, add the QM respawn time to the delay
delay = delay + respawnDelay
else
-- For a regular move, hide the QM for 60s and add that to the delay
qmFaith:hideNPC(60)
delay = delay + 60
end

timersRunning = timersRunning + 1
qmFaith:timer(delay * 1000, moveJailerOfFaithQM)
end

qmFaith:setLocalVar('timersRunning', timersRunning)
end

local ruhmetGlobal = {}
ruhmetGlobal.moveJailerOfFaithQM = moveJailerOfFaithQM
return ruhmetGlobal
4 changes: 2 additions & 2 deletions scripts/zones/The_Garden_of_RuHmet/mobs/Jailer_of_Faith.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
-- NM: Jailer of Faith
-----------------------------------
local ID = zones[xi.zone.THE_GARDEN_OF_RUHMET]
local ruhmetGlobal = require('scripts/zones/The_Garden_of_RuHmet/globals')
mixins = { require('scripts/mixins/job_special') }
-----------------------------------
local entity = {}
Expand Down Expand Up @@ -33,8 +34,7 @@ entity.onMobDeath = function(mob)
end

entity.onMobDespawn = function(mob)
-- Move QM to random location
GetNPCByID(ID.npc.QM_JAILER_OF_FAITH):setPos(unpack(ID.npc.QM_JAILER_OF_FAITH_POS[math.random(1, 5)]))
ruhmetGlobal.moveJailerOfFaithQM(GetNPCByID(ID.npc.QM_JAILER_OF_FAITH), xi.settings.main.FORCE_SPAWN_QM_RESET_TIME)
end

return entity
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@
-- NW / Mithra tower !pos -683 0 -340 35
-----------------------------------
local ID = zones[xi.zone.THE_GARDEN_OF_RUHMET]
local ruhmetGlobal = require('scripts/zones/The_Garden_of_RuHmet/globals')
-----------------------------------
local entity = {}

entity.onSpawn = function(npc)
-- Move QM with a respawnDelay of 0 to mimic as if this was
-- triggered from the QM reapparing after JoF despawns
ruhmetGlobal.moveJailerOfFaithQM(npc, 0)
end

entity.onTrade = function(player, npc, trade)
if
npcUtil.tradeHas(trade, xi.item.HIGH_QUALITY_EUVHI_ORGAN) and
Expand Down