From b6af793fb3862b649634797caea00b245ee8af22 Mon Sep 17 00:00:00 2001 From: Luan Santos Date: Mon, 20 Nov 2023 12:39:51 -0800 Subject: [PATCH 1/8] fix: type safety around const "Thing" (#1854) Addresses the issue in const member functions where the getContainer method may return a nullptr --- src/creatures/creature.hpp | 12 ++++++++++++ src/creatures/monsters/monster.hpp | 3 +++ src/creatures/npcs/npc.hpp | 3 +++ src/creatures/players/player.hpp | 3 +++ src/items/containers/container.hpp | 4 ++++ src/items/item.hpp | 3 +++ src/items/thing.hpp | 6 +++--- src/lua/global/shared_object.hpp | 5 +++++ 8 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/creatures/creature.hpp b/src/creatures/creature.hpp index 45e2dbe6a45..2052e7a2866 100644 --- a/src/creatures/creature.hpp +++ b/src/creatures/creature.hpp @@ -76,15 +76,27 @@ class Creature : virtual public Thing, public SharedObject { std::shared_ptr getCreature() override final { return static_self_cast(); } + std::shared_ptr getCreature() const override final { + return static_self_cast(); + } virtual std::shared_ptr getPlayer() { return nullptr; } + virtual std::shared_ptr getPlayer() const { + return nullptr; + } virtual std::shared_ptr getNpc() { return nullptr; } + virtual std::shared_ptr getNpc() const { + return nullptr; + } virtual std::shared_ptr getMonster() { return nullptr; } + virtual std::shared_ptr getMonster() const { + return nullptr; + } virtual const std::string &getName() const = 0; // Real creature name, set on creature creation "createNpcType(typeName) and createMonsterType(typeName)" diff --git a/src/creatures/monsters/monster.hpp b/src/creatures/monsters/monster.hpp index 2422ae7679b..b6194543099 100644 --- a/src/creatures/monsters/monster.hpp +++ b/src/creatures/monsters/monster.hpp @@ -32,6 +32,9 @@ class Monster final : public Creature { std::shared_ptr getMonster() override { return static_self_cast(); } + std::shared_ptr getMonster() const override { + return static_self_cast(); + } void setID() override { if (id == 0) { diff --git a/src/creatures/npcs/npc.hpp b/src/creatures/npcs/npc.hpp index 993934374d5..5f118360528 100644 --- a/src/creatures/npcs/npc.hpp +++ b/src/creatures/npcs/npc.hpp @@ -40,6 +40,9 @@ class Npc final : public Creature { std::shared_ptr getNpc() override { return static_self_cast(); } + std::shared_ptr getNpc() const override { + return static_self_cast(); + } void setID() override { if (id == 0) { diff --git a/src/creatures/players/player.hpp b/src/creatures/players/player.hpp index 45611aaf9ec..5000f1ccf6e 100644 --- a/src/creatures/players/player.hpp +++ b/src/creatures/players/player.hpp @@ -121,6 +121,9 @@ class Player final : public Creature, public Cylinder, public Bankable { std::shared_ptr getPlayer() override { return static_self_cast(); } + std::shared_ptr getPlayer() const override { + return static_self_cast(); + } static std::shared_ptr createPlayerTask(uint32_t delay, std::function f, std::string context); diff --git a/src/items/containers/container.hpp b/src/items/containers/container.hpp index 56d048f3b10..70d4571bafd 100644 --- a/src/items/containers/container.hpp +++ b/src/items/containers/container.hpp @@ -55,6 +55,10 @@ class Container : public Item, public Cylinder { return static_self_cast(); } + std::shared_ptr getContainer() const override final { + return static_self_cast(); + } + std::shared_ptr getRootContainer(); virtual std::shared_ptr getDepotLocker() { diff --git a/src/items/item.hpp b/src/items/item.hpp index b8db280dea8..b1847b47d5c 100644 --- a/src/items/item.hpp +++ b/src/items/item.hpp @@ -235,6 +235,9 @@ class Item : virtual public Thing, public ItemProperties, public SharedObject { std::shared_ptr getItem() override final { return static_self_cast(); } + std::shared_ptr getItem() const override final { + return static_self_cast(); + } virtual std::shared_ptr getTeleport() { return nullptr; } diff --git a/src/items/thing.hpp b/src/items/thing.hpp index 5b75e716cae..05f961ec9a1 100644 --- a/src/items/thing.hpp +++ b/src/items/thing.hpp @@ -54,19 +54,19 @@ class Thing { virtual std::shared_ptr getContainer() { return nullptr; } - virtual std::shared_ptr getContainer() const { + virtual std::shared_ptr getContainer() const { return nullptr; } virtual std::shared_ptr getItem() { return nullptr; } - virtual std::shared_ptr getItem() const { + virtual std::shared_ptr getItem() const { return nullptr; } virtual std::shared_ptr getCreature() { return nullptr; } - virtual std::shared_ptr getCreature() const { + virtual std::shared_ptr getCreature() const { return nullptr; } diff --git a/src/lua/global/shared_object.hpp b/src/lua/global/shared_object.hpp index 62cc26b33f5..3370bb022c1 100644 --- a/src/lua/global/shared_object.hpp +++ b/src/lua/global/shared_object.hpp @@ -29,6 +29,11 @@ class SharedObject : public std::enable_shared_from_this { return std::static_pointer_cast(shared_from_this()); } + template + std::shared_ptr static_self_cast() const { + return std::static_pointer_cast(shared_from_this()); + } + template std::shared_ptr dynamic_self_cast() { return std::dynamic_pointer_cast(shared_from_this()); From e27545511730372dad850156d3c79481d20a55ac Mon Sep 17 00:00:00 2001 From: Luan Santos Date: Mon, 20 Nov 2023 13:23:05 -0800 Subject: [PATCH 2/8] fix: warzone IV-VI cooldown (#1851) --- .../bosses_mission_depths.lua | 13 ++----- .../quests/dangerous_depth/boss_entrance.lua | 39 ++++++++++--------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/data-otservbr-global/scripts/creaturescripts/quests/dangerous_depths/bosses_mission_depths.lua b/data-otservbr-global/scripts/creaturescripts/quests/dangerous_depths/bosses_mission_depths.lua index 63ffa3c6ffd..9880d96626e 100644 --- a/data-otservbr-global/scripts/creaturescripts/quests/dangerous_depths/bosses_mission_depths.lua +++ b/data-otservbr-global/scripts/creaturescripts/quests/dangerous_depths/bosses_mission_depths.lua @@ -1,7 +1,7 @@ local bosses = { - ["the count of the core"] = { storage = Storage.DangerousDepths.Bosses.TheCountOfTheCore, value = os.time() + configManager.getNumber(configKeys.BOSS_DEFAULT_TIME_TO_FIGHT_AGAIN), teleportPosition = Position(33681, 32340, 15), toPosition = Position(33682, 32315, 15), toPositionBack = Position(33324, 32111, 15) }, - ["the duke of the depths"] = { storage = Storage.DangerousDepths.Bosses.TheDukeOfTheDepths, value = os.time() + configManager.getNumber(configKeys.BOSS_DEFAULT_TIME_TO_FIGHT_AGAIN), teleportPosition = Position(33719, 32302, 15), toPosition = Position(33691, 32301, 15), toPositionBack = Position(33275, 32318, 15) }, - ["the baron from below"] = { storage = Storage.DangerousDepths.Bosses.TheBaronFromBelow, value = os.time() + configManager.getNumber(configKeys.BOSS_DEFAULT_TIME_TO_FIGHT_AGAIN), teleportPosition = Position(33650, 32312, 15), toPosition = Position(33668, 32301, 15), toPositionBack = Position(33462, 32267, 15) }, + ["the count of the core"] = { teleportPosition = Position(33681, 32340, 15), toPosition = Position(33682, 32315, 15), toPositionBack = Position(33324, 32111, 15) }, + ["the duke of the depths"] = { teleportPosition = Position(33719, 32302, 15), toPosition = Position(33691, 32301, 15), toPositionBack = Position(33275, 32318, 15) }, + ["the baron from below"] = { teleportPosition = Position(33650, 32312, 15), toPosition = Position(33668, 32301, 15), toPositionBack = Position(33462, 32267, 15) }, } local function revert(position, toPosition) @@ -14,15 +14,10 @@ end local bossesMissionDepth = CreatureEvent("DepthWarzoneBossDeath") function bossesMissionDepth.onDeath(creature) - local boss = bosses[player:getName():lower()] + local boss = bosses[creature:getName():lower()] if not boss then return true end - onDeathForDamagingPlayers(creature, function(player, _value) - if player:getStorageValue(boss.storage) < boss.value then - player:setStorageValue(boss.storage, boss.value) - end - end) local teleport = Tile(boss.teleportPosition):getItemById(1949) if teleport then diff --git a/data-otservbr-global/scripts/movements/quests/dangerous_depth/boss_entrance.lua b/data-otservbr-global/scripts/movements/quests/dangerous_depth/boss_entrance.lua index 30af7f7676b..20300f3ac5f 100644 --- a/data-otservbr-global/scripts/movements/quests/dangerous_depth/boss_entrance.lua +++ b/data-otservbr-global/scripts/movements/quests/dangerous_depth/boss_entrance.lua @@ -1,4 +1,5 @@ local bossEntrance = MoveEvent() +local timeToFightAgain = 10 -- hours function bossEntrance.onStepIn(creature, item, position, fromPosition, toPosition) local player = creature:getPlayer() @@ -15,33 +16,35 @@ function bossEntrance.onStepIn(creature, item, position, fromPosition, toPositio local WarzoneVI = Position(33275, 32316, 15) local WarzoneVI_b = Position(33717, 32302, 15) + local bossName = "The Count of the Core" + local destination = WarzoneV_b + if item:getPosition() == WarzoneIV then -- Warzone IV - if player:getStorageValue(Storage.DangerousDepths.Bosses.TheBaronFromBelow) > os.time() then - player:teleportTo(fromPosition) - player:say("You have to wait to challenge this enemy again!", TALKTYPE_MONSTER_SAY) - else - player:teleportTo(WarzoneIV_b) - end + bossName = "The Baron from Below" + destination = WarzoneIV_b end if item:getPosition() == WarzoneV then -- Warzone V - if player:getStorageValue(Storage.DangerousDepths.Bosses.TheCountOfTheCore) > os.time() then - player:teleportTo(fromPosition) - player:say("You have to wait to challenge this enemy again!", TALKTYPE_MONSTER_SAY) - else - player:teleportTo(WarzoneV_b) - end + bossName = "The Count of the Core" + destination = WarzoneV_b end if item:getPosition() == WarzoneVI then -- Warzone VI - if player:getStorageValue(Storage.DangerousDepths.Bosses.TheDukeOfTheDepths) > os.time() then - player:teleportTo(fromPosition) - player:say("You have to wait to challenge this enemy again!", TALKTYPE_MONSTER_SAY) - else - player:teleportTo(WarzoneVI_b) - end + bossName = "The Duke of the Depths" + destination = WarzoneVI_b + end + local timeLeft = player:getBossCooldown(bossName) - os.time() + if timeLeft > 0 then + player:teleportTo(fromPosition, true) + player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have to wait " .. getTimeInWords(timeLeft) .. " to face " .. bossName .. " again!") + player:getPosition():sendMagicEffect(CONST_ME_POFF) + return true end + + player:teleportTo(destination) player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) + player:setBossCooldown(bossName, os.time() + timeToFightAgain * 3600) return true end From ed0c52c3a0654e8cf3339fff2437c04598183b2c Mon Sep 17 00:00:00 2001 From: Luan Santos Date: Mon, 20 Nov 2023 13:32:20 -0800 Subject: [PATCH 3/8] fix: the primal menace hazard issues and primal pack monsters (#1849) --- data-otservbr-global/lib/core/storages.lua | 4 - data-otservbr-global/lib/quests/quest.lua | 1 + .../lib/quests/the_primal_ordeal.lua | 14 +++ .../monster/birds/headpecker.lua | 2 + .../monster/giants/hulking_prehemoth.lua | 2 + .../monster/mammals/beast_gore_horn.lua | 94 ------------------ .../monster/mammals/beast_gorerilla.lua | 95 ------------------- .../monster/mammals/beast_sabretooth.lua | 94 ------------------ .../monster/mammals/gore_horn.lua | 2 + .../monster/mammals/gorerilla.lua | 2 + .../monster/mammals/nighthunter.lua | 2 + .../monster/mammals/sabretooth.lua | 2 + .../monster/plants/stalking_stalk.lua | 2 + .../primal_ordeal_quest/the_primal_menace.lua | 32 +++---- .../monster/reptiles/emerald_tortoise.lua | 2 + .../monster/reptiles/mantosaurus.lua | 2 + .../monster/reptiles/noxious_ripptor.lua | 2 + .../monster/vermins/sulphider.lua | 2 + .../quests/dangerous_depth/using_crystals.lua | 2 +- .../ferumbras_ascendant/mazoran_lever.lua | 1 - .../ferumbras_ascendant/plagirath_lever.lua | 1 - .../ferumbras_ascendant/ragiaz_lever.lua | 1 - .../ferumbras_ascendant/razzagorn_lever.lua | 1 - .../ferumbras_ascendant/shulgrax_lever.lua | 1 - .../ferumbras_ascendant/tarbaz_lever.lua | 1 - .../ferumbras_ascendant/zamulosh_lever.lua | 1 - .../quests/secret_library/ghulosh_lever.lua | 1 - .../quests/secret_library/gorzindel_lever.lua | 1 - .../quests/secret_library/lokathmor_lever.lua | 1 - .../quests/secret_library/mazzinor_lever.lua | 1 - .../scourge_of_oblivion_lever.lua | 1 - .../nightmare_beast_lever.lua | 1 - .../scripts/hazard/primal.lua | 2 - .../scripts/movements/teleport/gnomprona.lua | 4 +- .../the_primal_manace_lever.lua | 1 - data/libs/hazard_lib.lua | 4 +- 36 files changed, 59 insertions(+), 323 deletions(-) create mode 100644 data-otservbr-global/lib/quests/the_primal_ordeal.lua delete mode 100644 data-otservbr-global/monster/mammals/beast_gore_horn.lua delete mode 100644 data-otservbr-global/monster/mammals/beast_gorerilla.lua delete mode 100644 data-otservbr-global/monster/mammals/beast_sabretooth.lua diff --git a/data-otservbr-global/lib/core/storages.lua b/data-otservbr-global/lib/core/storages.lua index 78ff883881a..bd0a1c135f5 100644 --- a/data-otservbr-global/lib/core/storages.lua +++ b/data-otservbr-global/lib/core/storages.lua @@ -2791,10 +2791,6 @@ Storage = { U12_90 = { -- update 12.90 - Reserved Storages 47851 - 47900 PrimalOrdeal = { QuestLine = 47851, - Hazard = { - Current = 47856, - Max = 47857, - }, Bosses = { MagmaBubbleKilled = 47853, ThePrimalMenaceKilled = 47855, diff --git a/data-otservbr-global/lib/quests/quest.lua b/data-otservbr-global/lib/quests/quest.lua index 3919c962ffd..21b1744fec6 100644 --- a/data-otservbr-global/lib/quests/quest.lua +++ b/data-otservbr-global/lib/quests/quest.lua @@ -6,3 +6,4 @@ dofile(DATA_DIRECTORY .. "/lib/quests/svargrond_arena.lua") dofile(DATA_DIRECTORY .. "/lib/quests/the_cursed_crystal.lua") dofile(DATA_DIRECTORY .. "/lib/quests/the_queen_of_the_banshees.lua") dofile(DATA_DIRECTORY .. "/lib/quests/their_masters_voice.lua") +dofile(DATA_DIRECTORY .. "/lib/quests/the_primal_ordeal.lua") diff --git a/data-otservbr-global/lib/quests/the_primal_ordeal.lua b/data-otservbr-global/lib/quests/the_primal_ordeal.lua new file mode 100644 index 00000000000..4b1dfdae2e3 --- /dev/null +++ b/data-otservbr-global/lib/quests/the_primal_ordeal.lua @@ -0,0 +1,14 @@ +function RegisterPrimalPackBeast(template) + local name = template.name or template.description:gsub("an ", ""):gsub("a ", ""):titleCase() + local primal = Game.createMonsterType(name .. " (Primal)") + local primalMonster = table.copy(template) + primalMonster.experience = 0 + primalMonster.loot = {} + primalMonster.name = "Primal Pack Beast" + primalMonster.description = "a primal pack beast" + + primalMonster.raceId = nil + primalMonster.Bestiary = nil + + primal:register(primalMonster) +end diff --git a/data-otservbr-global/monster/birds/headpecker.lua b/data-otservbr-global/monster/birds/headpecker.lua index 2694021b76b..c5a686633be 100644 --- a/data-otservbr-global/monster/birds/headpecker.lua +++ b/data-otservbr-global/monster/birds/headpecker.lua @@ -121,3 +121,5 @@ monster.immunities = { } mType:register(monster) + +RegisterPrimalPackBeast(monster) diff --git a/data-otservbr-global/monster/giants/hulking_prehemoth.lua b/data-otservbr-global/monster/giants/hulking_prehemoth.lua index 24adf51b948..aa9ed9b1774 100644 --- a/data-otservbr-global/monster/giants/hulking_prehemoth.lua +++ b/data-otservbr-global/monster/giants/hulking_prehemoth.lua @@ -119,3 +119,5 @@ monster.immunities = { } mType:register(monster) + +RegisterPrimalPackBeast(monster) diff --git a/data-otservbr-global/monster/mammals/beast_gore_horn.lua b/data-otservbr-global/monster/mammals/beast_gore_horn.lua deleted file mode 100644 index c77c16564fb..00000000000 --- a/data-otservbr-global/monster/mammals/beast_gore_horn.lua +++ /dev/null @@ -1,94 +0,0 @@ -local mType = Game.createMonsterType("Beast Gore Horn") -local monster = {} - -monster.description = "a beast gore horn" -monster.experience = 0 -monster.outfit = { - lookType = 1548, - lookHead = 85, - lookBody = 1, - lookLegs = 85, - lookFeet = 105, - lookAddons = 3, - lookMount = 0, -} - -monster.health = 20620 -monster.maxHealth = 20620 -monster.race = "blood" -monster.corpse = 0 -monster.speed = 192 -monster.manaCost = 0 -monster.maxSummons = 0 - -monster.changeTarget = { - interval = 4000, - chance = 10, -} - -monster.strategiesTarget = { - nearest = 100, -} - -monster.flags = { - summonable = false, - attackable = true, - hostile = true, - convinceable = false, - pushable = false, - rewardBoss = false, - illusionable = false, - canPushItems = true, - canPushCreatures = true, - staticAttackChance = 90, - targetDistance = 1, - runHealth = 0, - healthHidden = false, - isBlockable = false, - canWalkOnEnergy = true, - canWalkOnFire = true, - canWalkOnPoison = true, -} - -monster.light = { - level = 0, - color = 0, -} - -monster.voices = { - interval = 5000, - chance = 10, - { text = "Rraaaaa!", yell = false }, -} - -monster.attacks = { - { name = "melee", interval = 2000, chance = 100, minDamage = 300, maxDamage = -400 }, - { name = "combat", interval = 2000, chance = 15, type = COMBAT_PHYSICALDAMAGE, minDamage = 0, maxDamage = -400, range = 7, shootEffect = CONST_ANI_SUDDENDEATH, target = true }, -} - -monster.defenses = { - defense = 78, - armor = 78, -} - -monster.elements = { - { type = COMBAT_PHYSICALDAMAGE, percent = 20 }, - { type = COMBAT_ENERGYDAMAGE, percent = -5 }, - { type = COMBAT_EARTHDAMAGE, percent = -5 }, - { type = COMBAT_FIREDAMAGE, percent = 10 }, - { type = COMBAT_LIFEDRAIN, percent = 0 }, - { type = COMBAT_MANADRAIN, percent = 0 }, - { type = COMBAT_DROWNDAMAGE, percent = 0 }, - { type = COMBAT_ICEDAMAGE, percent = 10 }, - { type = COMBAT_HOLYDAMAGE, percent = -20 }, - { type = COMBAT_DEATHDAMAGE, percent = 10 }, -} - -monster.immunities = { - { type = "paralyze", condition = false }, - { type = "outfit", condition = false }, - { type = "invisible", condition = true }, - { type = "bleed", condition = false }, -} - -mType:register(monster) diff --git a/data-otservbr-global/monster/mammals/beast_gorerilla.lua b/data-otservbr-global/monster/mammals/beast_gorerilla.lua deleted file mode 100644 index 31fbaf99814..00000000000 --- a/data-otservbr-global/monster/mammals/beast_gorerilla.lua +++ /dev/null @@ -1,95 +0,0 @@ -local mType = Game.createMonsterType("Beast Gorerilla") -local monster = {} - -monster.description = "a beast gorerilla" -monster.experience = 0 -monster.outfit = { - lookType = 1559, - lookHead = 85, - lookBody = 1, - lookLegs = 85, - lookFeet = 105, - lookAddons = 3, - lookMount = 0, -} - -monster.health = 16850 -monster.maxHealth = 16850 -monster.race = "blood" -monster.corpse = 0 -monster.speed = 215 -monster.manaCost = 0 -monster.maxSummons = 0 - -monster.changeTarget = { - interval = 4000, - chance = 10, -} - -monster.strategiesTarget = { - nearest = 100, -} - -monster.flags = { - summonable = false, - attackable = true, - hostile = true, - convinceable = false, - pushable = false, - rewardBoss = false, - illusionable = false, - canPushItems = true, - canPushCreatures = true, - staticAttackChance = 90, - targetDistance = 1, - runHealth = 0, - healthHidden = false, - isBlockable = false, - canWalkOnEnergy = true, - canWalkOnFire = true, - canWalkOnPoison = true, -} - -monster.light = { - level = 0, - color = 0, -} - -monster.voices = { - interval = 5000, - chance = 10, - { text = "The Moon Goddess is ashamed of you!", yell = false }, -} - -monster.attacks = { - { name = "melee", interval = 2000, chance = 100, minDamage = 300, maxDamage = -801 }, - { name = "combat", interval = 2000, chance = 15, type = COMBAT_PHYSICALDAMAGE, minDamage = 250, maxDamage = -360, range = 7, shootEffect = CONST_ANI_LARGEROCK, target = true }, - { name = "combat", interval = 2000, chance = 40, type = COMBAT_FIREDAMAGE, minDamage = -1, maxDamage = -1, range = 5, radius = 3, shootEffect = CONST_ANI_FIRE, effect = CONST_ME_FIREATTACK, target = true }, -} - -monster.defenses = { - defense = 76, - armor = 76, -} - -monster.elements = { - { type = COMBAT_PHYSICALDAMAGE, percent = 20 }, - { type = COMBAT_ENERGYDAMAGE, percent = -5 }, - { type = COMBAT_EARTHDAMAGE, percent = -5 }, - { type = COMBAT_FIREDAMAGE, percent = 10 }, - { type = COMBAT_LIFEDRAIN, percent = 0 }, - { type = COMBAT_MANADRAIN, percent = 0 }, - { type = COMBAT_DROWNDAMAGE, percent = 0 }, - { type = COMBAT_ICEDAMAGE, percent = 10 }, - { type = COMBAT_HOLYDAMAGE, percent = -20 }, - { type = COMBAT_DEATHDAMAGE, percent = 10 }, -} - -monster.immunities = { - { type = "paralyze", condition = false }, - { type = "outfit", condition = false }, - { type = "invisible", condition = true }, - { type = "bleed", condition = false }, -} - -mType:register(monster) diff --git a/data-otservbr-global/monster/mammals/beast_sabretooth.lua b/data-otservbr-global/monster/mammals/beast_sabretooth.lua deleted file mode 100644 index 19602511bf8..00000000000 --- a/data-otservbr-global/monster/mammals/beast_sabretooth.lua +++ /dev/null @@ -1,94 +0,0 @@ -local mType = Game.createMonsterType("Beast Sabretooth") -local monster = {} - -monster.description = "a beast sabretooth" -monster.experience = 0 -monster.outfit = { - lookType = 1549, - lookHead = 85, - lookBody = 1, - lookLegs = 85, - lookFeet = 105, - lookAddons = 3, - lookMount = 0, -} - -monster.health = 17300 -monster.maxHealth = 17300 -monster.race = "blood" -monster.corpse = 0 -monster.speed = 182 -monster.manaCost = 0 -monster.maxSummons = 0 - -monster.changeTarget = { - interval = 4000, - chance = 10, -} - -monster.strategiesTarget = { - nearest = 100, -} - -monster.flags = { - summonable = false, - attackable = true, - hostile = true, - convinceable = false, - pushable = false, - rewardBoss = false, - illusionable = false, - canPushItems = true, - canPushCreatures = true, - staticAttackChance = 90, - targetDistance = 1, - runHealth = 0, - healthHidden = false, - isBlockable = false, - canWalkOnEnergy = true, - canWalkOnFire = true, - canWalkOnPoison = true, -} - -monster.light = { - level = 0, - color = 0, -} - -monster.voices = { - interval = 5000, - chance = 10, - { text = "The Moon Goddess is ashamed of you!", yell = false }, -} - -monster.attacks = { - { name = "melee", interval = 2000, chance = 100, minDamage = 300, maxDamage = -450, effect = CONST_ME_ORANGE_ENERGY_SPARK }, - { name = "combat", interval = 1000, chance = 10, type = COMBAT_PHYSICALDAMAGE, minDamage = -260, maxDamage = -300, length = 4, spread = 1, effect = CONST_ME_EXPLOSIONAREA, target = false }, -} - -monster.defenses = { - defense = 110, - armor = 120, -} - -monster.elements = { - { type = COMBAT_PHYSICALDAMAGE, percent = 20 }, - { type = COMBAT_ENERGYDAMAGE, percent = -5 }, - { type = COMBAT_EARTHDAMAGE, percent = -5 }, - { type = COMBAT_FIREDAMAGE, percent = 10 }, - { type = COMBAT_LIFEDRAIN, percent = 0 }, - { type = COMBAT_MANADRAIN, percent = 0 }, - { type = COMBAT_DROWNDAMAGE, percent = 0 }, - { type = COMBAT_ICEDAMAGE, percent = 10 }, - { type = COMBAT_HOLYDAMAGE, percent = -20 }, - { type = COMBAT_DEATHDAMAGE, percent = 10 }, -} - -monster.immunities = { - { type = "paralyze", condition = false }, - { type = "outfit", condition = false }, - { type = "invisible", condition = true }, - { type = "bleed", condition = false }, -} - -mType:register(monster) diff --git a/data-otservbr-global/monster/mammals/gore_horn.lua b/data-otservbr-global/monster/mammals/gore_horn.lua index bfe77ca9ecf..37ca6c70b2b 100644 --- a/data-otservbr-global/monster/mammals/gore_horn.lua +++ b/data-otservbr-global/monster/mammals/gore_horn.lua @@ -120,3 +120,5 @@ monster.immunities = { } mType:register(monster) + +RegisterPrimalPackBeast(monster) diff --git a/data-otservbr-global/monster/mammals/gorerilla.lua b/data-otservbr-global/monster/mammals/gorerilla.lua index b3ce0f064c1..58b8758208f 100644 --- a/data-otservbr-global/monster/mammals/gorerilla.lua +++ b/data-otservbr-global/monster/mammals/gorerilla.lua @@ -121,3 +121,5 @@ monster.immunities = { } mType:register(monster) + +RegisterPrimalPackBeast(monster) diff --git a/data-otservbr-global/monster/mammals/nighthunter.lua b/data-otservbr-global/monster/mammals/nighthunter.lua index 434efa99993..c83d387c30a 100644 --- a/data-otservbr-global/monster/mammals/nighthunter.lua +++ b/data-otservbr-global/monster/mammals/nighthunter.lua @@ -120,3 +120,5 @@ monster.immunities = { } mType:register(monster) + +RegisterPrimalPackBeast(monster) diff --git a/data-otservbr-global/monster/mammals/sabretooth.lua b/data-otservbr-global/monster/mammals/sabretooth.lua index a1398dc2d74..91fe1151653 100644 --- a/data-otservbr-global/monster/mammals/sabretooth.lua +++ b/data-otservbr-global/monster/mammals/sabretooth.lua @@ -119,3 +119,5 @@ monster.immunities = { } mType:register(monster) + +RegisterPrimalPackBeast(monster) diff --git a/data-otservbr-global/monster/plants/stalking_stalk.lua b/data-otservbr-global/monster/plants/stalking_stalk.lua index 3565dcc26d1..2415168d0a6 100644 --- a/data-otservbr-global/monster/plants/stalking_stalk.lua +++ b/data-otservbr-global/monster/plants/stalking_stalk.lua @@ -120,3 +120,5 @@ monster.immunities = { } mType:register(monster) + +RegisterPrimalPackBeast(monster) diff --git a/data-otservbr-global/monster/quests/primal_ordeal_quest/the_primal_menace.lua b/data-otservbr-global/monster/quests/primal_ordeal_quest/the_primal_menace.lua index b81e83f7af7..f233c41680b 100644 --- a/data-otservbr-global/monster/quests/primal_ordeal_quest/the_primal_menace.lua +++ b/data-otservbr-global/monster/quests/primal_ordeal_quest/the_primal_menace.lua @@ -26,17 +26,17 @@ local thePrimalMenaceConfig = { HpRateOnSpawn = 0.7, MonsterPool = { - "Emerald Tortoise", - "Beast Gore Horn", - "Beast Gorerilla", - "Headpecker", - "Beast Hulking Prehemoth", - "Mantosaurus", - "Nighthunter", - "Noxious Ripptor", - "Beast Sabretooth", - "Stalking Stalk", - "Sulphider", + "Emerald Tortoise (Primal)", + "Gore Horn (Primal)", + "Gorerilla (Primal)", + "Headpecker (Primal)", + "Hulking Prehemoth (Primal)", + "Mantosaurus (Primal)", + "Nighthunter (Primal)", + "Noxious Ripptor (Primal)", + "Sabretooth (Primal)", + "Stalking Stalk (Primal)", + "Sulphider (Primal)", }, }, @@ -117,11 +117,11 @@ monster.loot = { monster.attacks = { { name = "melee", interval = 2000, chance = 85, minDamage = -0, maxDamage = -763 }, - { name = "combat", interval = 4000, chance = 35, type = COMBAT_EARTHDAMAGE, minDamage = -1500, maxDamage = -2200, length = 10, spread = 3, effect = CONST_ME_CARNIPHILA, target = false }, - { name = "combat", interval = 2500, chance = 45, type = COMBAT_FIREDAMAGE, minDamage = -700, maxDamage = -1000, length = 10, spread = 3, effect = CONST_ME_HITBYFIRE, target = false }, - { name = "big death wave", interval = 3500, chance = 35, minDamage = -250, maxDamage = -300, target = false }, - { name = "combat", interval = 5000, chance = 40, type = COMBAT_ENERGYDAMAGE, effect = CONST_ME_ENERGYHIT, minDamage = -1200, maxDamage = -1300, range = 4, target = false }, - { name = "combat", interval = 2700, chance = 45, type = COMBAT_EARTHDAMAGE, shootEffect = CONST_ANI_POISON, effect = CONST_ANI_EARTH, minDamage = -600, maxDamage = -1800, range = 4, target = false }, + { name = "combat", interval = 4000, chance = 15, type = COMBAT_EARTHDAMAGE, minDamage = -1500, maxDamage = -2200, length = 10, spread = 3, effect = CONST_ME_CARNIPHILA, target = false }, + { name = "combat", interval = 2500, chance = 25, type = COMBAT_FIREDAMAGE, minDamage = -700, maxDamage = -1000, length = 10, spread = 3, effect = CONST_ME_HITBYFIRE, target = false }, + { name = "big death wave", interval = 3500, chance = 20, minDamage = -250, maxDamage = -300, target = false }, + { name = "combat", interval = 5000, chance = 15, type = COMBAT_ENERGYDAMAGE, effect = CONST_ME_ENERGYHIT, minDamage = -1200, maxDamage = -1300, range = 4, target = false }, + { name = "combat", interval = 2700, chance = 30, type = COMBAT_EARTHDAMAGE, shootEffect = CONST_ANI_POISON, effect = CONST_ANI_EARTH, minDamage = -600, maxDamage = -1800, range = 4, target = true }, } monster.defenses = { diff --git a/data-otservbr-global/monster/reptiles/emerald_tortoise.lua b/data-otservbr-global/monster/reptiles/emerald_tortoise.lua index e2375af210e..d2b1a88246d 100644 --- a/data-otservbr-global/monster/reptiles/emerald_tortoise.lua +++ b/data-otservbr-global/monster/reptiles/emerald_tortoise.lua @@ -128,3 +128,5 @@ monster.immunities = { } mType:register(monster) + +RegisterPrimalPackBeast(monster) diff --git a/data-otservbr-global/monster/reptiles/mantosaurus.lua b/data-otservbr-global/monster/reptiles/mantosaurus.lua index f0484558c77..96a24cbaf06 100644 --- a/data-otservbr-global/monster/reptiles/mantosaurus.lua +++ b/data-otservbr-global/monster/reptiles/mantosaurus.lua @@ -121,3 +121,5 @@ monster.immunities = { } mType:register(monster) + +RegisterPrimalPackBeast(monster) diff --git a/data-otservbr-global/monster/reptiles/noxious_ripptor.lua b/data-otservbr-global/monster/reptiles/noxious_ripptor.lua index 13740d55851..2a7031598b5 100644 --- a/data-otservbr-global/monster/reptiles/noxious_ripptor.lua +++ b/data-otservbr-global/monster/reptiles/noxious_ripptor.lua @@ -118,3 +118,5 @@ monster.immunities = { } mType:register(monster) + +RegisterPrimalPackBeast(monster) diff --git a/data-otservbr-global/monster/vermins/sulphider.lua b/data-otservbr-global/monster/vermins/sulphider.lua index 7346eb4c687..ad42af1cda7 100644 --- a/data-otservbr-global/monster/vermins/sulphider.lua +++ b/data-otservbr-global/monster/vermins/sulphider.lua @@ -119,3 +119,5 @@ monster.immunities = { } mType:register(monster) + +RegisterPrimalPackBeast(monster) diff --git a/data-otservbr-global/scripts/actions/quests/dangerous_depth/using_crystals.lua b/data-otservbr-global/scripts/actions/quests/dangerous_depth/using_crystals.lua index 68a348fc08f..74a3db1ae17 100644 --- a/data-otservbr-global/scripts/actions/quests/dangerous_depth/using_crystals.lua +++ b/data-otservbr-global/scripts/actions/quests/dangerous_depth/using_crystals.lua @@ -405,7 +405,7 @@ function dangerousDepthCrystals.onUse(player, item, fromPosition, target, toPosi return true end - if not target or not target:isItem() then + if not target or not target.isItem or not target:isItem() then return false end diff --git a/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/mazoran_lever.lua b/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/mazoran_lever.lua index cc973b7ee4c..b43f674af30 100644 --- a/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/mazoran_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/mazoran_lever.lua @@ -17,7 +17,6 @@ local config = { to = Position(33597, 32700, 14), }, exit = Position(33319, 32318, 13), - storage = Storage.FerumbrasAscension.MazoranTimer, } local lever = BossLever(config) diff --git a/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/plagirath_lever.lua b/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/plagirath_lever.lua index d288c964a02..65207dae0b4 100644 --- a/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/plagirath_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/plagirath_lever.lua @@ -17,7 +17,6 @@ local config = { to = Position(33190, 31515, 13), }, exit = Position(33319, 32318, 13), - storage = Storage.FerumbrasAscension.PlagirathTimer, } local lever = BossLever(config) diff --git a/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/ragiaz_lever.lua b/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/ragiaz_lever.lua index 95461abb6a0..bf24a598d81 100644 --- a/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/ragiaz_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/ragiaz_lever.lua @@ -17,7 +17,6 @@ local config = { to = Position(33495, 32347, 13), }, exit = Position(33319, 32318, 13), - storage = Storage.FerumbrasAscension.RagiazTimer, } local deathDragons = { diff --git a/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/razzagorn_lever.lua b/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/razzagorn_lever.lua index 11586fcc350..6e6f9348b87 100644 --- a/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/razzagorn_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/razzagorn_lever.lua @@ -17,7 +17,6 @@ local config = { to = Position(33439, 32481, 14), }, exit = Position(33319, 32318, 13), - storage = Storage.FerumbrasAscension.RazzagornTimer, } local lever = BossLever(config) diff --git a/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/shulgrax_lever.lua b/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/shulgrax_lever.lua index 83e8b16663f..2a2305bfd52 100644 --- a/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/shulgrax_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/shulgrax_lever.lua @@ -17,7 +17,6 @@ local config = { to = Position(33496, 32798, 13), }, exit = Position(33319, 32318, 13), - storage = Storage.FerumbrasAscension.ShulgraxTimer, } local lever = BossLever(config) diff --git a/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/tarbaz_lever.lua b/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/tarbaz_lever.lua index 0ceb1fc87b9..13cdb5766f8 100644 --- a/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/tarbaz_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/tarbaz_lever.lua @@ -17,7 +17,6 @@ local config = { to = Position(33473, 32856, 11), }, exit = Position(33319, 32318, 13), - storage = Storage.FerumbrasAscension.TarbazTimer, } local lever = BossLever(config) diff --git a/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/zamulosh_lever.lua b/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/zamulosh_lever.lua index 545edd1f35a..f59534879e3 100644 --- a/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/zamulosh_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/ferumbras_ascendant/zamulosh_lever.lua @@ -17,7 +17,6 @@ local config = { to = Position(33654, 32765, 11), }, exit = Position(33319, 32318, 13), - storage = Storage.FerumbrasAscension.ZamuloshTimer, } local zamuloshSummons = { diff --git a/data-otservbr-global/scripts/actions/quests/secret_library/ghulosh_lever.lua b/data-otservbr-global/scripts/actions/quests/secret_library/ghulosh_lever.lua index 7e7e3d57c3c..aaa1e1cd9da 100644 --- a/data-otservbr-global/scripts/actions/quests/secret_library/ghulosh_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/secret_library/ghulosh_lever.lua @@ -17,7 +17,6 @@ local config = { to = Position(32763, 32729, 10), }, exit = Position(32660, 32713, 13), - storage = Storage.Quest.U11_80.TheSecretLibrary.GhuloshTimer, } local lever = BossLever(config) diff --git a/data-otservbr-global/scripts/actions/quests/secret_library/gorzindel_lever.lua b/data-otservbr-global/scripts/actions/quests/secret_library/gorzindel_lever.lua index fe2fcd74cda..ad191a2287c 100644 --- a/data-otservbr-global/scripts/actions/quests/secret_library/gorzindel_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/secret_library/gorzindel_lever.lua @@ -17,7 +17,6 @@ local config = { to = Position(32695, 32726, 10), }, exit = Position(32660, 32734, 12), - storage = Storage.Quest.U11_80.TheSecretLibrary.GorzindelTimer, } local lever = BossLever(config) diff --git a/data-otservbr-global/scripts/actions/quests/secret_library/lokathmor_lever.lua b/data-otservbr-global/scripts/actions/quests/secret_library/lokathmor_lever.lua index d63560f6fca..d70154ca142 100644 --- a/data-otservbr-global/scripts/actions/quests/secret_library/lokathmor_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/secret_library/lokathmor_lever.lua @@ -17,7 +17,6 @@ local config = { to = Position(32758, 32696, 10), }, exit = Position(32466, 32654, 12), - storage = Storage.Quest.U11_80.TheSecretLibrary.LokathmorTimer, } local lever = BossLever(config) diff --git a/data-otservbr-global/scripts/actions/quests/secret_library/mazzinor_lever.lua b/data-otservbr-global/scripts/actions/quests/secret_library/mazzinor_lever.lua index eb7afac5509..266a2917f6c 100644 --- a/data-otservbr-global/scripts/actions/quests/secret_library/mazzinor_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/secret_library/mazzinor_lever.lua @@ -17,7 +17,6 @@ local config = { to = Position(32732, 32728, 10), }, exit = Position(32616, 32531, 13), - storage = Storage.Quest.U11_80.TheSecretLibrary.MazzinorTimer, } local lever = BossLever(config) diff --git a/data-otservbr-global/scripts/actions/quests/secret_library/scourge_of_oblivion_lever.lua b/data-otservbr-global/scripts/actions/quests/secret_library/scourge_of_oblivion_lever.lua index 0739407172d..11265f1589c 100644 --- a/data-otservbr-global/scripts/actions/quests/secret_library/scourge_of_oblivion_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/secret_library/scourge_of_oblivion_lever.lua @@ -22,7 +22,6 @@ local config = { to = Position(32738, 32748, 11), }, exit = Position(32480, 32599, 15), - storage = Storage.Quest.U11_80.TheSecretLibrary.ScourgeOfOblivionTimer, } local lever = BossLever(config) diff --git a/data-otservbr-global/scripts/actions/quests/the_dream_courts/nightmare_beast_lever.lua b/data-otservbr-global/scripts/actions/quests/the_dream_courts/nightmare_beast_lever.lua index fc47fe72006..2c30247b915 100644 --- a/data-otservbr-global/scripts/actions/quests/the_dream_courts/nightmare_beast_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/the_dream_courts/nightmare_beast_lever.lua @@ -22,7 +22,6 @@ local config = { to = Position(32220, 32055, 15), }, exit = Position(32211, 32084, 15), - storage = Storage.Quest.U12_00.TheDreamCourts.NightmareBeastTimer, } local lever = BossLever(config) diff --git a/data-otservbr-global/scripts/hazard/primal.lua b/data-otservbr-global/scripts/hazard/primal.lua index e4309b78f67..2b8fd67a25d 100644 --- a/data-otservbr-global/scripts/hazard/primal.lua +++ b/data-otservbr-global/scripts/hazard/primal.lua @@ -3,8 +3,6 @@ local hazard = Hazard.new({ from = Position(33502, 32740, 13), to = Position(33796, 32996, 15), maxLevel = 12, - storageMax = Storage.Quest.U12_90.PrimalOrdeal.Hazard.Max, - storageCurrent = Storage.Quest.U12_90.PrimalOrdeal.Hazard.Current, crit = true, dodge = true, diff --git a/data-otservbr-global/scripts/movements/teleport/gnomprona.lua b/data-otservbr-global/scripts/movements/teleport/gnomprona.lua index f4a56cbb4ac..e9b52a5e6c2 100644 --- a/data-otservbr-global/scripts/movements/teleport/gnomprona.lua +++ b/data-otservbr-global/scripts/movements/teleport/gnomprona.lua @@ -2,7 +2,7 @@ local teleports = { { position = Position(33660, 32895, 14), destination = Position(33669, 32933, 15) }, { position = Position(33671, 32933, 15), destination = Position(33660, 32897, 14) }, { position = Position(33658, 32919, 15), destination = Position(33669, 32933, 15) }, - { position = Position(33714, 32797, 14), destination = Position(33555, 32752, 14), access = Storage.Quest.U12_90.PrimalOrdeal.Bosses.MagmaBubbleKilled }, + { position = Position(33714, 32797, 14), destination = Position(33556, 32754, 14), access = Storage.Quest.U12_90.PrimalOrdeal.Bosses.MagmaBubbleKilled }, { position = Position(33558, 32754, 14), destination = Position(33714, 32799, 14) }, { position = Position(33567, 32758, 15), destination = Position(33555, 32752, 14) }, } @@ -23,7 +23,9 @@ function gnomprona.onStepIn(creature, item, position, fromPosition) player:teleportTo(teleports[c].destination) player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) else + player:getPosition():sendMagicEffect(CONST_ME_POFF) player:teleportTo(fromPosition) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You don't have access to this teleport yet.") end else player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) diff --git a/data-otservbr-global/scripts/quests/primal_ordeal_quest/the_primal_manace_lever.lua b/data-otservbr-global/scripts/quests/primal_ordeal_quest/the_primal_manace_lever.lua index 64c6785e364..bb01eb8da7d 100644 --- a/data-otservbr-global/scripts/quests/primal_ordeal_quest/the_primal_manace_lever.lua +++ b/data-otservbr-global/scripts/quests/primal_ordeal_quest/the_primal_manace_lever.lua @@ -16,7 +16,6 @@ local config = { to = Position(33570, 32769, 15), }, exit = Position(33520, 32871, 15), - storage = Storage.Quest.U12_90.PrimalOrdeal.Bosses.ThePrimalMenaceTimer, } lever = BossLever(config) diff --git a/data/libs/hazard_lib.lua b/data/libs/hazard_lib.lua index dc8ec0a0d44..d10650a81b6 100644 --- a/data/libs/hazard_lib.lua +++ b/data/libs/hazard_lib.lua @@ -110,8 +110,8 @@ function Hazard:levelUp(player) end function Hazard:setPlayerMaxLevel(player, level) - if level > self.maxLevel then - level = self.maxLevel + if level > self.maxLevelLevel then + level = self.maxLevelLevel end if self.storageMax then From 08e40dbd0a76862f03a55d7564ccd912142300c7 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Mon, 20 Nov 2023 18:53:32 -0300 Subject: [PATCH 4/8] fix: store inbox items only can be moved to house tile (#1857) Resolves #1855 --- src/game/game.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/game/game.cpp b/src/game/game.cpp index 8d16fd624e6..0ff4a08e6e3 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -1654,11 +1654,9 @@ ReturnValue Game::checkMoveItemToCylinder(std::shared_ptr player, std::s } } - if (item->isStoreItem() && !toHouseTile) { + if (item->isStoreItem() && !house) { return RETURNVALUE_NOTPOSSIBLE; } - - return RETURNVALUE_NOERROR; } } From 7554fc63f3984df41032a7dad972ea5e8a52a80a Mon Sep 17 00:00:00 2001 From: Luan Santos Date: Mon, 20 Nov 2023 14:22:02 -0800 Subject: [PATCH 5/8] fix: expiring market offers (#1850) --- src/io/iomarket.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/io/iomarket.cpp b/src/io/iomarket.cpp index d6b6109309c..6aa25e65f1b 100644 --- a/src/io/iomarket.cpp +++ b/src/io/iomarket.cpp @@ -132,12 +132,9 @@ void IOMarket::processExpiredOffers(DBResult_ptr result, bool) { continue; } - std::shared_ptr player = g_game().getPlayerByGUID(playerId); + std::shared_ptr player = g_game().getPlayerByGUID(playerId, true); if (!player) { - player = std::make_shared(nullptr); - if (!IOLoginData::loadPlayerById(player, playerId)) { - continue; - } + continue; } if (itemType.stackable) { From 232baa8b7d1ec10cc9b0d5d41a7d0862381ff664 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Tue, 21 Nov 2023 00:23:10 -0300 Subject: [PATCH 6/8] fix: drop item with charges from monsters (#1858) Resolves #1843 --- data/libs/functions/monstertype.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/data/libs/functions/monstertype.lua b/data/libs/functions/monstertype.lua index b51744cf8fd..bd86b38a439 100644 --- a/data/libs/functions/monstertype.lua +++ b/data/libs/functions/monstertype.lua @@ -34,7 +34,10 @@ function MonsterType:generateLootRoll(config, resultTable) end local count = 0 - if iType:isStackable() then + local charges = iType:getCharges() + if charges > 0 then + count = charges + elseif iType:isStackable() then local maxc, minc = item.maxCount or 1, item.minCount or 1 count = math.max(0, randValue % (maxc - minc + 1)) + minc else From cf1963aebed0adde53372fdf6f725d377a1f3360 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Tue, 21 Nov 2023 00:32:41 -0300 Subject: [PATCH 7/8] improve: added monster count to create monster talkaction (#1861) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This introduces an improved algorithm for spawning monsters around the player. The enhanced function createCreaturesAround now generates creatures in a concentric pattern, starting from the player's position and expanding outwards up to a specified radius. This mechanism ensures a more balanced and controlled distribution of monsters. Key Features: • Monsters are spawned in a pattern that expands from 1x1 to a maximum of defined tiles around the player. • The function supports customization of the monster type, count, and specific forge options. • Incorporates an option to force spawn monsters, even on occupied tiles. • Ensures game playability by respecting immovable and solid property checks on tiles. This update aims to provide a more dynamic and better testing environment. --- .../talkactions/god/create_monster.lua | 100 ++++++++++++++++-- 1 file changed, 89 insertions(+), 11 deletions(-) diff --git a/data/scripts/talkactions/god/create_monster.lua b/data/scripts/talkactions/god/create_monster.lua index 6e5c4a4ffbf..924a0d0906d 100644 --- a/data/scripts/talkactions/god/create_monster.lua +++ b/data/scripts/talkactions/god/create_monster.lua @@ -1,36 +1,114 @@ +local function createCreaturesAround(player, maxRadius, creatureName, creatureCount, creatureForge, boolForceCreate) + local position = player:getPosition() + local createdCount = 0 + local sendMessage = false + local canSetFiendish, canSetInfluenced, influencedLevel = CheckDustLevel(creatureForge, player) + for radius = 1, maxRadius do + if createdCount >= creatureCount then + break + end + + local minX = position.x - radius + local maxX = position.x + radius + local minY = position.y - radius + local maxY = position.y + radius + for dx = minX, maxX do + for dy = minY, maxY do + if (dx == minX or dx == maxX or dy == minY or dy == maxY) and createdCount < creatureCount then + local checkPosition = Position(dx, dy, position.z) + local tile = Tile(checkPosition) + if tile and not tile:hasProperty(CONST_PROP_IMMOVABLEBLOCKSOLID) then + local monster = Game.createMonster(creatureName, checkPosition, false, boolForceCreate) + if monster then + createdCount = createdCount + 1 + monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT) + position:sendMagicEffect(CONST_ME_MAGIC_RED) + if creatureForge ~= nil and monster:isForgeable() then + local monsterType = monster:getType() + if canSetFiendish then + SetFiendish(monsterType, position, player, monster) + end + if canSetInfluenced then + SetInfluenced(monsterType, monster, player, influencedLevel) + end + elseif notSendMessage then + sendMessage = true + end + end + end + end + end + end + end + if sendMessage == true then + player:sendCancelMessage("Only allowed monsters can be fiendish or influenced.") + end + + logger.info("Player {} created '{}' monsters", player:getName(), createdCount) +end + local createMonster = TalkAction("/m") +-- @function createMonster.onSay +-- @desc TalkAction to create monsters with multiple options. +-- @param player: The player executing the command. +-- @param words: Command words. +-- @param param: String containing the command parameters. +-- Format: "/m monstername, monstercount, [fiendish/influenced level], spawnRadius, [forceCreate]" +-- Example: "/m rat, 10, fiendish, 5, true" +-- @param: the last param is by default "false", if add "," or any value i'ts set to true +-- @return true if the command is executed successfully, false otherwise. function createMonster.onSay(player, words, param) -- create log logCommand(player, words, param) - - -- Usage: "/m monstername, fiendish" for create a fiendish monster (/m rat, fiendish) - -- Usage: "/m monstername, [1-5]" for create a influenced monster with specific level (/m rat, 2) if param == "" then player:sendCancelMessage("Monster name param required.") logger.error("[createMonster.onSay] - Monster name param not found.") return true end + local position = player:getPosition() + local split = param:split(",") local monsterName = split[1] - local monsterForge = nil + local monsterCount = 0 if split[2] then split[2] = split[2]:gsub("^%s*(.-)$", "%1") --Trim left - monsterForge = split[2] + monsterCount = tonumber(split[2]) + end + + local monsterForge = nil + if split[3] then + split[3] = split[3]:gsub("^%s*(.-)$", "%1") --Trim left + monsterForge = split[3] + end + + if monsterCount > 1 then + local spawnRadius = 5 + if split[4] then + split[4] = split[4]:gsub("^%s*(.-)$", "%1") --Trim left + spawnRadius = split[4] + print(spawnRadius) + end + + local forceCreate = false + if split[5] then + forceCreate = true + end + + createCreaturesAround(player, spawnRadius, monsterName, monsterCount, monsterForge, forceCreate) + return true end - -- Check dust level - local canSetFiendish, canSetInfluenced, influencedLevel = CheckDustLevel(monsterForge, player) - local position = player:getPosition() local monster = Game.createMonster(monsterName, position) if monster then - if not monster:isForgeable() then + local canSetFiendish, canSetInfluenced, influencedLevel = CheckDustLevel(monsterForge, player) + monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT) + position:sendMagicEffect(CONST_ME_MAGIC_RED) + if monsterForge ~= nil and not monster:isForgeable() then player:sendCancelMessage("Only allowed monsters can be fiendish or influenced.") return true end - monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT) - position:sendMagicEffect(CONST_ME_MAGIC_RED) local monsterType = monster:getType() if canSetFiendish then From 24c702d981b10b4ec3f7f916afc79c1b07685b79 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Tue, 21 Nov 2023 02:12:50 -0300 Subject: [PATCH 8/8] fix: ensure loot over stack size drops in multiple stacks (#1862) Resolves #1838 --- data/libs/functions/container.lua | 16 ++++++++++++---- .../monster/ondroploot_wealth_duplex.lua | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/data/libs/functions/container.lua b/data/libs/functions/container.lua index 30131fec934..5b85e297872 100644 --- a/data/libs/functions/container.lua +++ b/data/libs/functions/container.lua @@ -13,10 +13,18 @@ function Container:addLoot(loot) goto continue end if iType:isStackable() or iType:getCharges() ~= 0 then - local tmpItem = self:addItem(itemId, item.count, INDEX_WHEREEVER, FLAG_NOLIMIT) - if not tmpItem then - logger.warn("Container:addLoot: failed to add item: {}, to corpse {} with id {}", ItemType(itemId):getName(), self:getName(), self:getId()) - goto continue + local stackSize = iType:getStackSize() + local remainingCount = item.count + + while remainingCount > 0 do + local countToAdd = math.min(remainingCount, stackSize) + local tmpItem = self:addItem(itemId, countToAdd, INDEX_WHEREEVER, FLAG_NOLIMIT) + if not tmpItem then + logger.warn("Container:addLoot: failed to add stackable item: {}, to corpse {} with id {}", ItemType(itemId):getName(), self:getName(), self:getId()) + goto continue + end + + remainingCount = remainingCount - countToAdd end else for i = 1, item.count do diff --git a/data/scripts/eventcallbacks/monster/ondroploot_wealth_duplex.lua b/data/scripts/eventcallbacks/monster/ondroploot_wealth_duplex.lua index add4273dad7..008352174f4 100644 --- a/data/scripts/eventcallbacks/monster/ondroploot_wealth_duplex.lua +++ b/data/scripts/eventcallbacks/monster/ondroploot_wealth_duplex.lua @@ -29,7 +29,7 @@ function callback.monsterOnDropLoot(monster, corpse) local wealthDuplex = Concoction.find(Concoction.Ids.WealthDuplex) if not wealthDuplex then - logger.warn("[Monster:onDropLoot] - Could not find WealthDuplex concoction.") + logger.debug("[Monster:onDropLoot] - Could not find WealthDuplex concoction.") return end local chance = 0