From 8c3842fb4abebc2430a95e88a96a8ba633822aa9 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Alves Cruz Date: Tue, 3 Dec 2024 20:46:11 -0300 Subject: [PATCH] improve: monsters soulpit creation --- data-otservbr-global/lib/others/soulpit.lua | 6 ++-- .../scripts/actions/soulpit/soulpit_fight.lua | 6 +++- src/creatures/monsters/monster.cpp | 32 +++++++++++++++---- src/creatures/monsters/monster.hpp | 6 ++++ .../functions/core/game/game_functions.cpp | 6 +--- 5 files changed, 42 insertions(+), 14 deletions(-) diff --git a/data-otservbr-global/lib/others/soulpit.lua b/data-otservbr-global/lib/others/soulpit.lua index 16c1e739872..3f17178354a 100644 --- a/data-otservbr-global/lib/others/soulpit.lua +++ b/data-otservbr-global/lib/others/soulpit.lua @@ -13,8 +13,7 @@ SoulPit = { waves = { [1] = { stacks = { - [1] = 6, - [40] = 1, + [1] = 7, }, }, [2] = { @@ -66,6 +65,9 @@ SoulPit = { checkMonstersDelay = 4.5 * 1000, -- 4.5 seconds | The check delay should never be less than the timeToSpawnMonsters. timeToSpawnMonsters = 4 * 1000, -- 4 seconds totalMonsters = 7, + obeliskActive = 49175, + obeliskInactive = 49174, + obeliskPosition = Position(32371, 31154, 8), bossPosition = Position(32372, 31135, 8), exit = Position(32371, 31164, 8), zone = Zone("soulpit"), diff --git a/data-otservbr-global/scripts/actions/soulpit/soulpit_fight.lua b/data-otservbr-global/scripts/actions/soulpit/soulpit_fight.lua index 9abcc28e8e9..0a803e4ec29 100644 --- a/data-otservbr-global/scripts/actions/soulpit/soulpit_fight.lua +++ b/data-otservbr-global/scripts/actions/soulpit/soulpit_fight.lua @@ -12,6 +12,7 @@ function zoneEvent.afterLeave(zone, creature) end if SoulPit.kickEvent then stopEvent(SoulPit.kickEvent) + SoulPit.obeliskPosition:transformItem(SoulPit.obeliskActive, SoulPit.obeliskInactive) end end @@ -25,7 +26,8 @@ zoneEvent:register() local soulPitAction = Action() function soulPitAction.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if not target or target:getId() ~= 49174 then + logger.warn(item:getName()) + if not target or target:getId() ~= SoulPit.obeliskInactive then return false end @@ -66,6 +68,7 @@ function soulPitAction.onUse(player, item, fromPosition, target, toPosition, isH lever:checkPositions() if lever:checkConditions() then lever:teleportPlayers() + SoulPit.obeliskPosition:transformItem(SoulPit.obeliskInactive, SoulPit.obeliskActive) end local monsterName = string.gsub(item:getName(), " soul core", "") @@ -95,6 +98,7 @@ function soulPitAction.onUse(player, item, fromPosition, target, toPosition, isH for _, player in pairs(SoulPit.zone:getPlayers()) do player:teleportTo(SoulPit.exit) end + SoulPit.obeliskPosition:transformItem(SoulPit.obeliskActive, SoulPit.obeliskInactive) end, SoulPit.timeToKick) end diff --git a/src/creatures/monsters/monster.cpp b/src/creatures/monsters/monster.cpp index d396bb47744..ae1f997076a 100644 --- a/src/creatures/monsters/monster.cpp +++ b/src/creatures/monsters/monster.cpp @@ -1324,13 +1324,15 @@ void Monster::onThinkDefense(uint32_t interval) { } const auto &summon = Monster::createMonster(summonName); - if (summon) { - if (g_game().placeCreature(summon, getPosition(), false, summonForce)) { - summon->setMaster(static_self_cast(), true); - g_game().addMagicEffect(getPosition(), CONST_ME_MAGIC_BLUE); - g_game().addMagicEffect(summon->getPosition(), CONST_ME_TELEPORT); - g_game().sendSingleSoundEffect(summon->getPosition(), SoundEffect_t::MONSTER_SPELL_SUMMON, getMonster()); + if (summon && g_game().placeCreature(summon, getPosition(), false, summonForce)) { + if (getSoulPit()) { + const auto stack = getForgeStack(); + summon->setSoulPitStack(stack, true); } + summon->setMaster(static_self_cast(), true); + g_game().addMagicEffect(getPosition(), CONST_ME_MAGIC_BLUE); + g_game().addMagicEffect(summon->getPosition(), CONST_ME_TELEPORT); + g_game().sendSingleSoundEffect(summon->getPosition(), SoundEffect_t::MONSTER_SPELL_SUMMON, getMonster()); } } } @@ -2218,6 +2220,24 @@ void Monster::setHazardSystemDefenseBoost(bool value) { hazardDefenseBoost = value; } +bool Monster::getSoulPit() const { + return soulPit; +} + +void Monster::setSoulPit(bool value) { + soulPit = value; +} + +void Monster::setSoulPitStack(uint8_t stack, bool isSummon /* = false */) { + const bool isBoss = stack == 40; + const CreatureIconModifications_t icon = isBoss ? CreatureIconModifications_t::ReducedHealthExclamation : CreatureIconModifications_t::ReducedHealth; + setForgeStack(stack); + setIcon("soulpit", CreatureIcon(icon, isBoss ? 0 : stack)); + setSoulPit(true); + setDropLoot(false); + setSkillLoss(isBoss && !isSummon); +} + bool Monster::canWalkTo(Position pos, Direction moveDirection) { pos = getNextPosition(moveDirection, pos); if (isInSpawnRange(pos)) { diff --git a/src/creatures/monsters/monster.hpp b/src/creatures/monsters/monster.hpp index c9e5745da69..4c9a2e6c308 100644 --- a/src/creatures/monsters/monster.hpp +++ b/src/creatures/monsters/monster.hpp @@ -175,6 +175,10 @@ class Monster final : public Creature { void setHazardSystemDefenseBoost(bool value); // Hazard end + bool getSoulPit() const; + void setSoulPit(bool value); + void setSoulPitStack(uint8_t stack, bool isSummon = false); + void updateTargetList(); void clearTargetList(); void clearFriendList(); @@ -285,6 +289,8 @@ class Monster final : public Creature { bool hazardDamageBoost = false; bool hazardDefenseBoost = false; + bool soulPit = false; + bool m_isDead = false; bool m_isImmune = false; diff --git a/src/lua/functions/core/game/game_functions.cpp b/src/lua/functions/core/game/game_functions.cpp index 97e97e996a2..8182811bd9e 100644 --- a/src/lua/functions/core/game/game_functions.cpp +++ b/src/lua/functions/core/game/game_functions.cpp @@ -569,12 +569,8 @@ int GameFunctions::luaGameCreateSoulPitMonster(lua_State* L) { const uint8_t stack = Lua::getNumber(L, 3, 1); const bool extended = Lua::getBoolean(L, 4, false); const bool force = Lua::getBoolean(L, 5, false); - const CreatureIconModifications_t icon = stack < 40 ? CreatureIconModifications_t::ReducedHealth : CreatureIconModifications_t::ReducedHealthExclamation; if (g_game().placeCreature(monster, position, extended, force)) { - monster->setSkillLoss(stack == 40); - monster->setForgeStack(stack); - monster->setDropLoot(false); - monster->setIcon("soulpit", CreatureIcon(icon, stack < 40 ? stack : 0)); + monster->setSoulPitStack(stack); monster->onSpawn(); const auto &mtype = monster->getMonsterType(); if (mtype && mtype->info.raceid > 0 && mtype->info.bosstiaryRace == BosstiaryRarity_t::RARITY_ARCHFOE) {