Skip to content

Commit

Permalink
fix: Drume boss mechanic (#1836)
Browse files Browse the repository at this point in the history
- Fail the encounter if Lion commanders die
- Kesar is invulnerable
  • Loading branch information
Luan Luciano authored Nov 18, 2023
1 parent e17d77a commit 264efd5
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 33 deletions.
9 changes: 7 additions & 2 deletions data-otservbr-global/lib/core/storages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1705,8 +1705,6 @@ Storage = {
-- Reserved storage 52396-52410 (TheOrderOfTheLion)
Drume = {
Commander = 52396, -- Global
TotalLionCommanders = 52397, -- Global
TotalUsurperCommanders = 52398, -- Global
},
},
-- News quest development
Expand Down Expand Up @@ -3067,6 +3065,13 @@ GlobalStorage = {
DiprathSwitchesGlobalStorage = 60161,
AshmunrahSwitchesGlobalStorage = 60162,
},
TheOrderOfTheLion = {
-- Reserved storage from 60170 - 60171
Drume = {
TotalLionCommanders = 60170, -- Global
TotalUsurperCommanders = 60171, -- Global
},
},
FuryGates = 65000,
Yakchal = 65001,
PitsOfInfernoLevers = 65002,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ monster.strategiesTarget = {
nearest = 100,
}

monster.events = {
"KesarImmortal",
}

monster.flags = {
summonable = false,
attackable = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ monster.strategiesTarget = {
nearest = 100,
}

monster.events = {
"LionCommanderDeath",
}

monster.flags = {
summonable = false,
attackable = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ monster.speed = 125
monster.manaCost = 0

monster.faction = FACTION_LIONUSURPERS
monster.enemyFactions = { FACTION_LION, FACTION_PLAYER }
monster.enemyFactions = { FACTION_PLAYER, FACTION_LION }

monster.changeTarget = {
interval = 4000,
Expand All @@ -33,7 +33,7 @@ monster.strategiesTarget = {
}

monster.events = {
"usurperCommanderDeath",
"UsurperCommanderDeath",
}

monster.flags = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ local config = {

local currentEvent = nil

local function RoomIsOccupied(centerPosition, rangeX, rangeY)
local spectators = Game.getSpectators(config.centerPosition, false, true, config.rangeX, config.rangeX, config.rangeY, config.rangeY)
if #spectators ~= 0 then
return true
end

return false
end

local function clearRoomDrume(centerPosition, rangeX, rangeY, resetGlobalStorage)
local spectators, spectator = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
for i = 1, #spectators do
Expand All @@ -52,11 +43,14 @@ function drumeAction.onUse(player, item, fromPosition, target, toPosition, isHot
if player:getPosition() ~= config.firstPlayerPosition then
return false
end
if RoomIsOccupied(config.centerPosition, config.rangeX, config.rangeY) then

local spectators = Game.getSpectators(config.centerPosition, false, true, config.rangeX, config.rangeX, config.rangeY, config.rangeY)
if #spectators ~= 0 then
player:sendCancelMessage("There's someone already in the skirmish.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return true
end

local tempPos, tempTile, tempCreature
local players = {}
for x = config.firstPlayerPosition.x, config.firstPlayerPosition.x + 4 do
Expand Down Expand Up @@ -117,8 +111,8 @@ function drumeAction.onUse(player, item, fromPosition, target, toPosition, isHot
currentEvent = addEvent(clearRoomDrume, config.timeToKill * 60 * 1000, config.centerPosition, config.rangeX, config.rangeY, resetGlobalStorage)
config.newPosition:sendMagicEffect(CONST_ME_TELEPORT)
toPosition:sendMagicEffect(CONST_ME_POFF)
Game.setStorageValue(Storage.TheOrderOfTheLion.Drume.TotalLionCommanders, totalLion)
Game.setStorageValue(Storage.TheOrderOfTheLion.Drume.TotalUsurperCommanders, totalUsurper)
Game.setStorageValue(GlobalStorage.TheOrderOfTheLion.Drume.TotalLionCommanders, totalLion)
Game.setStorageValue(GlobalStorage.TheOrderOfTheLion.Drume.TotalUsurperCommanders, totalUsurper)
return true
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
local config = {
firstPlayerPosition = Position(32457, 32508, 6),
centerPosition = Position(32439, 32523, 7), -- Center Room
exitPosition = Position(32453, 32503, 7), -- Exit Position
newPosition = Position(32453, 32510, 7),
rangeX = 22,
rangeY = 16,
}

local lionCommanderDeath = CreatureEvent("lionCommanderDeath")
local lionCommanderDeath = CreatureEvent("LionCommanderDeath")
function lionCommanderDeath.onPrepareDeath(creature)
local totalCommanders = Game.getStorageValue(Storage.TheOrderOfTheLion.Drume.TotalLionCommanders)
local totalCommanders = Game.getStorageValue(GlobalStorage.TheOrderOfTheLion.Drume.TotalLionCommanders)
if totalCommanders > 1 then
Game.setStorageValue(Storage.TheOrderOfTheLion.Drume.TotalLionCommanders, totalCommanders - 1)
Game.setStorageValue(GlobalStorage.TheOrderOfTheLion.Drume.TotalLionCommanders, totalCommanders - 1)
else
local spectators = Game.getSpectators(config.centerPosition, false, false, config.rangeX, config.rangeX, config.rangeY, config.rangeY)
for _, cid in pairs(spectators) do
if cid:isMonster() and not cid:getMaster() then
cid:remove()
elseif cid:isPlayer() then
cid:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You lost the skirmish.")
cid:teleportTo(config.exitPosition)
for _, spectator in pairs(spectators) do
if spectator:isMonster() and not spectator:getMaster() then
spectator:remove()
elseif spectator:isPlayer() then
spectator:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You lost the skirmish.")
spectator:teleportTo(config.exitPosition)
end
end
config.exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
Expand All @@ -29,15 +27,24 @@ end

lionCommanderDeath:register()

local usurperCommanderDeath = CreatureEvent("usurperCommanderDeath")
local usurperCommanderDeath = CreatureEvent("UsurperCommanderDeath")
function usurperCommanderDeath.onPrepareDeath(creature)
local totalCommanders = Game.getStorageValue(Storage.TheOrderOfTheLion.Drume.TotalUsurperCommanders)
Game.setStorageValue(Storage.TheOrderOfTheLion.Drume.TotalUsurperCommanders, totalCommanders - 1)
if totalCommanders == 1 then
Game.createMonster("Kesar", Position(32444, 32515, 7), false, true)
Game.createMonster("Drume", Position(32444, 32516, 7), false, true)
local totalCommanders = Game.getStorageValue(GlobalStorage.TheOrderOfTheLion.Drume.TotalUsurperCommanders)
if totalCommanders > 0 then
Game.setStorageValue(GlobalStorage.TheOrderOfTheLion.Drume.TotalUsurperCommanders, totalCommanders - 1)
if totalCommanders == 1 then
Game.createMonster("Kesar", Position(32444, 32515, 7), false, true)
Game.createMonster("Drume", Position(32444, 32516, 7), false, true)
end
end
return true
end

usurperCommanderDeath:register()

local kesarHealthChange = CreatureEvent("KesarImmortal")
function kesarHealthChange.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
return 0, 0, 0, 0
end

kesarHealthChange:register()

0 comments on commit 264efd5

Please sign in to comment.