Skip to content

Commit

Permalink
Merge branch 'main' into fix/support-outfit-crashs
Browse files Browse the repository at this point in the history
  • Loading branch information
elsongabriel authored Jun 23, 2024
2 parents 16cc2e5 + bfb3149 commit a61062c
Show file tree
Hide file tree
Showing 63 changed files with 901 additions and 401 deletions.
1 change: 1 addition & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"DEBUG_LOG": "ON",
"ASAN_ENABLED": "OFF",
"BUILD_STATIC_LIBRARY": "OFF",
"SPEED_UP_BUILD_UNITY": "OFF",
"VCPKG_TARGET_TRIPLET": "x64-windows"
}
},
Expand Down
9 changes: 9 additions & 0 deletions data-otservbr-global/lib/core/storages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3079,6 +3079,15 @@ GlobalStorage = {
DarashiaWest = 60193,
},
},
TheDreamCourts = {
-- Reserved storage from 60194 - 60196
FacelessBane = {
-- Global
StepsOn = 60194,
Deaths = 60195,
ResetSteps = 60196,
},
},
FuryGates = 65000,
Yakchal = 65001,
PitsOfInfernoLevers = 65002,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ monster.events = {
"GraveDangerBossDeath",
}

monster.health = 75000
monster.maxHealth = 75000
monster.health = 300000
monster.maxHealth = 300000
monster.race = "venom"
monster.corpse = 31599
monster.speed = 125
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Faceless Bane")
local monster = {}

monster.description = "Faceless Bane"
monster.experience = 30000
monster.experience = 20000
monster.outfit = {
lookType = 1119,
lookHead = 0,
Expand All @@ -22,7 +22,11 @@ monster.manaCost = 0

monster.changeTarget = {
interval = 4000,
chance = 10,
chance = 20,
}

monster.reflects = {
{ type = COMBAT_DEATHDAMAGE, percent = 90 },
}

monster.bosstiary = {
Expand Down Expand Up @@ -131,11 +135,7 @@ monster.elements = {
{ type = COMBAT_DROWNDAMAGE, percent = 0 },
{ type = COMBAT_ICEDAMAGE, percent = 0 },
{ type = COMBAT_HOLYDAMAGE, percent = 0 },
{ type = COMBAT_DEATHDAMAGE, percent = 99 },
}

monster.heals = {
{ type = COMBAT_DEATHDAMAGE, percent = 100 },
{ type = COMBAT_DEATHDAMAGE, percent = 50 },
}

monster.immunities = {
Expand All @@ -149,6 +149,11 @@ mType.onThink = function(monster, interval) end

mType.onAppear = function(monster, creature)
if monster:getType():isRewardBoss() then
-- reset global storage state to default / ensure sqm's reset for the next team
Game.setStorageValue(GlobalStorage.TheDreamCourts.FacelessBane.Deaths, -1)
Game.setStorageValue(GlobalStorage.TheDreamCourts.FacelessBane.StepsOn, -1)
Game.setStorageValue(GlobalStorage.TheDreamCourts.FacelessBane.ResetSteps, 1)
monster:registerEvent("facelessBaneImmunity")
monster:setReward(true)
end
end
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/npc/emael.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ local function creatureSayCallback(npc, creature, type, message)
npcHandler:say("Ah, I see you killed a lot of dangerous creatures. Here's your podium of vigour!", npc, creature)
local inbox = player:getStoreInbox()
local inboxItems = inbox:getItems()
if inbox and #inboxItems <= inbox:getMaxCapacity() then
if inbox and #inboxItems < inbox:getMaxCapacity() then
local decoKit = inbox:addItem(ITEM_DECORATION_KIT, 1)
if decoKit then
decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "Unwrap it in your own house to create a <" .. ItemType(38707):getName() .. ">.")
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/npc/emperor_kruzak.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ local function creatureSayCallback(npc, creature, type, message)
if player:getMoney() + player:getBankBalance() >= 500000000 then
local inbox = player:getStoreInbox()
local inboxItems = inbox:getItems()
if inbox and #inboxItems <= inbox:getMaxCapacity() then
if inbox and #inboxItems < inbox:getMaxCapacity() then
local decoKit = inbox:addItem(ITEM_DECORATION_KIT, 1)
local decoItemName = ItemType(31510):getName()
decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "You bought this item in the Store.\nUnwrap it in your own house to create a " .. decoItemName .. ".")
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/npc/hireling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ function createHirelingType(HirelingName)
local inboxItems = inbox:getItems()
if player:getFreeCapacity() < itType:getWeight(1) then
npcHandler:say("Sorry, but you don't have enough capacity.", npc, creature)
elseif not inbox or #inboxItems > inbox:getMaxCapacity() then
elseif not inbox or #inboxItems >= inbox:getMaxCapacity() then
player:getPosition():sendMagicEffect(CONST_ME_POFF)
npcHandler:say("Sorry, you don't have enough room on your inbox", npc, creature)
elseif not player:removeMoneyBank(15000) then
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/npc/king_tibianus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ local function creatureSayCallback(npc, creature, type, message)
if player:getMoney() + player:getBankBalance() >= 500000000 then
local inbox = player:getStoreInbox()
local inboxItems = inbox:getItems()
if inbox and #inboxItems <= inbox:getMaxCapacity() then
if inbox and #inboxItems < inbox:getMaxCapacity() then
local decoKit = inbox:addItem(ITEM_DECORATION_KIT, 1)
local decoItemName = ItemType(31510):getName()
decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "Unwrap it in your own house to create a " .. decoItemName .. ".")
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/npc/queen_eloise.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ local function creatureSayCallback(npc, creature, type, message)
if player:getMoney() + player:getBankBalance() >= 500000000 then
local inbox = player:getStoreInbox()
local inboxItems = inbox:getItems()
if inbox and #inboxItems <= inbox:getMaxCapacity() then
if inbox and #inboxItems < inbox:getMaxCapacity() then
local decoKit = inbox:addItem(ITEM_DECORATION_KIT, 1)
local decoItemName = ItemType(31510):getName()
decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "You bought this item in the Store.\nUnwrap it in your own house to create a " .. decoItemName .. ".")
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/npc/walter_jaeger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ local function processItemInboxPurchase(player, name, id)

local inbox = player:getStoreInbox()
local inboxItems = inbox:getItems()
if inbox and #inboxItems <= inbox:getMaxCapacity() then
if inbox and #inboxItems < inbox:getMaxCapacity() then
local decoKit = inbox:addItem(ITEM_DECORATION_KIT, 1)
if decoKit then
decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "You bought this item with the Walter Jaeger.\nUnwrap it in your own house to create a <" .. name .. ">.")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
local bossName = "Faceless Bane"

local function healBoss(creature)
if creature then
creature:addHealth(creature:getMaxHealth())
creature:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
end
end

local function createSummons(creature)
if creature then
local pos = creature:getPosition()
Game.createMonster("Gazer Spectre", pos, true, false, creature)
Game.createMonster("Ripper Spectre", pos, true, false, creature)
Game.createMonster("Burster Spectre", pos, true, false, creature)
end
end

local function resetBoss(creature, deaths)
if creature then
healBoss(creature)
createSummons(creature)
Game.setStorageValue(GlobalStorage.TheDreamCourts.FacelessBane.Deaths, deaths + 1)
Game.setStorageValue(GlobalStorage.TheDreamCourts.FacelessBane.StepsOn, 0)
Game.setStorageValue(GlobalStorage.TheDreamCourts.FacelessBane.ResetSteps, 1)
end
end

local facelessBaneImmunity = CreatureEvent("facelessBaneImmunity")

function facelessBaneImmunity.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType)
if creature and creature:isMonster() and creature:getName() == bossName then
local creatureHealthPercent = (creature:getHealth() * 100) / creature:getMaxHealth()
local facelessBaneDeathsStorage = Game.getStorageValue(GlobalStorage.TheDreamCourts.FacelessBane.Deaths)

if creatureHealthPercent <= 20 and facelessBaneDeathsStorage < 1 then
resetBoss(creature, facelessBaneDeathsStorage)
return true
elseif Game.getStorageValue(GlobalStorage.TheDreamCourts.FacelessBane.StepsOn) < 1 then
healBoss(creature)
return true
end
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end

facelessBaneImmunity:register()
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
local walkedPositions = {}
local lastResetTime = os.time()
local checkTime = false

local function resetWalkedPositions(checkLastResetTime)
if lastResetTime > os.time() and checkLastResetTime then
return true
end

walkedPositions = {}
Game.setStorageValue(GlobalStorage.TheDreamCourts.FacelessBane.StepsOn, 0)
lastResetTime = os.time() + (1 * 60)
end

local pipePositions = {
Position(33612, 32568, 13),
Position(33612, 32567, 13),
Position(33612, 32566, 13),
Position(33612, 32565, 13),
Position(33612, 32564, 13),
Position(33612, 32563, 13),
Position(33612, 32562, 13),
Position(33612, 32561, 13),
Position(33612, 32560, 13),
Position(33612, 32559, 13),
Position(33612, 32558, 13),
Position(33612, 32557, 13),
Position(33612, 32556, 13),
Position(33622, 32556, 13),
Position(33622, 32557, 13),
Position(33622, 32558, 13),
Position(33622, 32559, 13),
Position(33622, 32560, 13),
Position(33622, 32561, 13),
Position(33622, 32562, 13),
Position(33622, 32563, 13),
Position(33622, 32564, 13),
Position(33622, 32565, 13),
Position(33622, 32566, 13),
Position(33622, 32567, 13),
Position(33622, 32568, 13),
}

local function sendEnergyEffect()
for _, position in ipairs(pipePositions) do
position:sendMagicEffect(CONST_ME_PURPLEENERGY)
position:sendSingleSoundEffect(SOUND_EFFECT_TYPE_SPELL_GREAT_ENERGY_BEAM)
end

return true
end

local facelessBaneStepPositions = MoveEvent()

function facelessBaneStepPositions.onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return true
end

if Game.getStorageValue(GlobalStorage.TheDreamCourts.FacelessBane.ResetSteps) == 1 then
Game.setStorageValue(GlobalStorage.TheDreamCourts.FacelessBane.ResetSteps, 0)
lastResetTime = os.time()
resetWalkedPositions(true)
end

if not checkTime then
checkTime = addEvent(resetWalkedPositions, 15 * 1000, false)
end

if Game.getStorageValue(GlobalStorage.TheDreamCourts.FacelessBane.StepsOn) < 1 then
if #walkedPositions > 0 then
for _, walkedPos in ipairs(walkedPositions) do
if walkedPos == position then
return true
end
end
end

position:sendSingleSoundEffect(SOUND_EFFECT_TYPE_SPELL_BUZZ)
position:sendMagicEffect(CONST_ME_YELLOWENERGY)
table.insert(walkedPositions, position)

if #walkedPositions == 13 then
Game.setStorageValue(GlobalStorage.TheDreamCourts.FacelessBane.StepsOn, 1)
addEvent(resetWalkedPositions, 60 * 1000, true)
sendEnergyEffect()
checkTime = nil
end
end
return true
end

local facelessBaneSteps = {
Position(33615, 32567, 13),
Position(33613, 32567, 13),
Position(33611, 32563, 13),
Position(33610, 32561, 13),
Position(33611, 32558, 13),
Position(33614, 32557, 13),
Position(33617, 32558, 13),
Position(33620, 32557, 13),
Position(33623, 32558, 13),
Position(33624, 32561, 13),
Position(33623, 32563, 13),
Position(33621, 32567, 13),
Position(33619, 32567, 13),
}

for _, pos in ipairs(facelessBaneSteps) do
facelessBaneStepPositions:position(pos)
end

facelessBaneStepPositions:register()
32 changes: 22 additions & 10 deletions data/libs/functions/boss_lever.lua
Original file line number Diff line number Diff line change
Expand Up @@ -174,24 +174,36 @@ function BossLever:onUse(player)
end

if creature:getLevel() < self.requiredLevel then
creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "All the players need to be level " .. self.requiredLevel .. " or higher.")
local message = "All players need to be level " .. self.requiredLevel .. " or higher."
creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
return false
end

if self:lastEncounterTime(creature) > os.time() then
local info = lever:getInfoPositions()
for _, v in pairs(info) do
local newPlayer = v.creature
if newPlayer then
local timeLeft = self:lastEncounterTime(newPlayer) - os.time()
newPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You or a member in your team have to wait " .. getTimeInWords(timeLeft) .. " to face " .. self.name .. " again!")
if self:lastEncounterTime(newPlayer) > os.time() then
newPlayer:getPosition():sendMagicEffect(CONST_ME_POFF)
if creature:getGroup():getId() < GROUP_TYPE_GOD and self:lastEncounterTime(creature) > os.time() then
local infoPositions = lever:getInfoPositions()
for _, posInfo in pairs(infoPositions) do
local currentPlayer = posInfo.creature
if currentPlayer then
local lastEncounter = self:lastEncounterTime(currentPlayer)
local currentTime = os.time()
if lastEncounter and currentTime < lastEncounter then
local timeLeft = lastEncounter - currentTime
local timeMessage = getTimeInWords(timeLeft) .. " to face " .. self.name .. " again!"
local message = "You have to wait " .. timeMessage

if currentPlayer ~= player then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "A member in your team has to wait " .. timeMessage)
end

currentPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
currentPlayer:getPosition():sendMagicEffect(CONST_ME_POFF)
end
end
end
return false
end

self.onUseExtra(creature)
return true
end)
Expand Down
4 changes: 2 additions & 2 deletions data/libs/systems/hireling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ function Hireling:returnToLamp(player_id)

local inbox = owner:getStoreInbox()
local inboxItems = inbox:getItems()
if not inbox or #inboxItems > inbox:getMaxCapacity() then
if not inbox or #inboxItems >= inbox:getMaxCapacity() then
owner:getPosition():sendMagicEffect(CONST_ME_POFF)
return owner:sendTextMessage(MESSAGE_FAILURE, "You don't have enough room in your inbox.")
end
Expand Down Expand Up @@ -556,7 +556,7 @@ function Player:addNewHireling(name, sex)

local inbox = self:getStoreInbox()
local inboxItems = inbox:getItems()
if not inbox or #inboxItems > inbox:getMaxCapacity() then
if not inbox or #inboxItems >= inbox:getMaxCapacity() then
self:getPosition():sendMagicEffect(CONST_ME_POFF)
self:sendTextMessage(MESSAGE_FAILURE, "You don't have enough room in your inbox.")
return false
Expand Down
2 changes: 1 addition & 1 deletion data/modules/scripts/daily_reward/daily_reward.lua
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ function Player.selectDailyReward(self, msg)
-- Adding items to store inbox
local inbox = self:getStoreInbox()
local inboxItems = inbox:getItems()
if not inbox or #inboxItems > inbox:getMaxCapacity() then
if not inbox or #inboxItems >= inbox:getMaxCapacity() then
self:sendError("You do not have enough space in your store inbox.")
return false
end
Expand Down
Loading

0 comments on commit a61062c

Please sign in to comment.