-
Notifications
You must be signed in to change notification settings - Fork 656
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
[lua] rewrite logic to spawn skull NMs in Eldieme Necropolis #7011
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,57 +4,61 @@ | |
----------------------------------- | ||
local ID = zones[xi.zone.THE_ELDIEME_NECROPOLIS] | ||
----------------------------------- | ||
local spawnSkulls = function() | ||
-- Spawn all 7 Skulls | ||
for skull = 1, 7 do | ||
SpawnMob(ID.mob.LICH_C_MAGNUS + skull) -- IDs based off Lich C Magnus | ||
end | ||
|
||
-- Handle 7 Sins Skeleton NMs Spawns | ||
local skullTrade = function(player, npc) | ||
local candleCount = | ||
{ | ||
ID.text.SKULL_FIVE_REMAIN, | ||
ID.text.SKULL_FOUR_REMAIN, | ||
ID.text.SKULL_THREE_REMAIN, | ||
ID.text.SKULL_TWO_REMAIN, | ||
ID.text.SKULL_ONE_REMAIN, | ||
ID.text.SKULL_SPAWN, | ||
} | ||
|
||
local tradeCount = GetNPCByID(ID.npc.CANDLE_OFFSET):getLocalVar('SkullTradeCount') -- Track how many candles have been lit | ||
local tradeWindow = GetNPCByID(ID.npc.CANDLE_OFFSET):getLocalVar('SkullTradeTimer') -- Track how much time before candles reset | ||
local active = npc:getLocalVar('candleActive') -- Track if current candle has already been lit | ||
|
||
for i = 1, 5 do | ||
if tradeCount == 6 and os.time() < tradeWindow and os.time() > active then -- Final candle, spawn Skulls | ||
GetNPCByID(ID.npc.CANDLE_OFFSET):setLocalVar('SkullTradeCount', 0) | ||
GetNPCByID(ID.npc.CANDLE_OFFSET):setLocalVar('SkullRespawn', os.time() + 3600) -- 1 hour cooldown to respawn skulls | ||
player:messageSpecial(ID.text.SKULL_SPAWN) | ||
player:confirmTrade() | ||
|
||
-- Spawn all 7 Skulls | ||
for skull = 1, 7 do | ||
SpawnMob(ID.mob.LICH_C_MAGNUS + skull) -- IDs based off Lich C Magnus | ||
end | ||
-- Used to stop Skulls from being spawned until an hour from being spawned | ||
SetServerVariable('[ELDIEME]TimeToRespawnSkulls', os.time() + 3600) | ||
end | ||
|
||
local brazierMessages = | ||
{ | ||
ID.text.SKULL_SPAWN, | ||
ID.text.SKULL_ONE_REMAIN, | ||
ID.text.SKULL_TWO_REMAIN, | ||
ID.text.SKULL_THREE_REMAIN, | ||
ID.text.SKULL_FOUR_REMAIN, | ||
ID.text.SKULL_FIVE_REMAIN, | ||
ID.text.SKULL_SIX_REMAIN, | ||
} | ||
|
||
break | ||
elseif tradeCount == i and os.time() < tradeWindow and os.time() > active then -- Candle trades 2 through 6 | ||
GetNPCByID(ID.npc.CANDLE_OFFSET):setLocalVar('SkullTradeCount', i + 1) | ||
npc:setLocalVar('candleActive', os.time() + 10) | ||
player:messageSpecial(ID.text.THE_BRAZIER_IS_LIT) | ||
player:messageSpecial(candleCount[i]) | ||
player:confirmTrade() | ||
break | ||
elseif os.time() > tradeWindow and os.time() > active then -- First candle trade to start timer | ||
GetNPCByID(ID.npc.CANDLE_OFFSET):setLocalVar('SkullTradeCount', 1) | ||
GetNPCByID(ID.npc.CANDLE_OFFSET):setLocalVar('SkullTradeTimer', os.time() + 40) | ||
npc:setLocalVar('candleActive', os.time() + 10) | ||
player:messageSpecial(ID.text.THE_BRAZIER_IS_LIT) | ||
player:messageSpecial(ID.text.SKULL_SIX_REMAIN) | ||
player:confirmTrade() | ||
break | ||
local countUnlitBraziers = function() | ||
local numberNotLit = 7 | ||
|
||
for i = 0, 6 do | ||
local brazier = GetNPCByID(ID.npc.CANDLE_OFFSET + i) | ||
if brazier and brazier:getAnimation() == xi.anim.OPEN_DOOR then | ||
numberNotLit = numberNotLit - 1 | ||
end | ||
end | ||
|
||
return numberNotLit | ||
end | ||
|
||
local eldiemeGlobal = | ||
{ | ||
local lightBrazier = function(player, npc) | ||
npc:setAnimation(xi.anim.OPEN_DOOR) | ||
|
||
--unlight brazier after five minutes | ||
npc:timer(300000, function() | ||
npc:setAnimation(xi.anim.CLOSE_DOOR) | ||
end) | ||
|
||
player:messageSpecial(ID.text.THE_BRAZIER_IS_LIT) | ||
|
||
local numberNotLit = countUnlitBraziers() | ||
local messageAfterLightingBrazier = brazierMessages[numberNotLit + 1] | ||
|
||
player:messageSpecial(messageAfterLightingBrazier) | ||
|
||
if numberNotLit == 0 then | ||
spawnSkulls() | ||
end | ||
end | ||
|
||
local eldiemeGlobal = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. local nameOfTheTable =
{ This applies for all tables and such There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry about that |
||
-- Click on any of the intersection gates | ||
gateOnTrigger = function(player, npc) | ||
if npc:getAnimation() == xi.anim.CLOSE_DOOR then | ||
|
@@ -87,30 +91,25 @@ local eldiemeGlobal = | |
end, | ||
|
||
handleCandleTrade = function(player, npc, trade) | ||
local timer = GetNPCByID(ID.npc.CANDLE_OFFSET):getLocalVar('SkullRespawn') -- 1 hour cooldown to respawn skulls | ||
|
||
if | ||
npcUtil.tradeHasExactly(trade, xi.item.FLINT_STONE) and | ||
os.time() > timer | ||
os.time() > GetServerVariable('[ELDIEME]TimeToRespawnSkulls') and | ||
npcUtil.tradeHasExactly(trade, xi.item.FLINT_STONE) | ||
then | ||
skullTrade(player, npc) | ||
elseif os.time() < timer then | ||
player:messageSpecial(ID.text.BRAZIER_COOLDOWN) | ||
lightBrazier(player, npc) | ||
else | ||
player:messageSpecial(ID.text.NOTHING_HAPPENED) | ||
end | ||
end, | ||
|
||
handleCandleTrigger = function(player, npc) | ||
local timer = GetNPCByID(ID.npc.CANDLE_OFFSET):getLocalVar('SkullRespawn') -- 1 hour cooldown to respawn skulls | ||
local active = npc:getLocalVar('candlesActive') | ||
|
||
if os.time() < active then | ||
if npc:getAnimation() == xi.anim.OPEN_DOOR then | ||
player:messageSpecial(ID.text.BRAZIER_ACTIVE) | ||
elseif os.time() > timer and os.time() > active then | ||
elseif os.time() > GetServerVariable('[ELDIEME]TimeToRespawnSkulls') then | ||
player:messageSpecial(ID.text.BRAZIER_OUT, 0, xi.item.FLINT_STONE) | ||
else | ||
player:messageSpecial(ID.text.BRAZIER_COOLDOWN) | ||
end | ||
end | ||
end, | ||
} | ||
|
||
return eldiemeGlobal |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just so you are aware in the future, there is literally a function specifically to open a door, wait a specified number of seconds, and then close the same door, performing all 3 of these functions with one invocation without any seconds to milliseconds conversion or potential snags you can hit by invoking
timer()
directly. There is also a matching function to do a the reverse (closing a default open door, and then reopening it after a timeout).npc:openDoor(300)
would have done exactly what you did here in a single line.