Skip to content

Commit

Permalink
improve: monsters soulpit creation
Browse files Browse the repository at this point in the history
  • Loading branch information
phacUFPE committed Dec 3, 2024
1 parent 2c68216 commit 8c3842f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 14 deletions.
6 changes: 4 additions & 2 deletions data-otservbr-global/lib/others/soulpit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ SoulPit = {
waves = {
[1] = {
stacks = {
[1] = 6,
[40] = 1,
[1] = 7,
},
},
[2] = {
Expand Down Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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", "")
Expand Down Expand Up @@ -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

Expand Down
32 changes: 26 additions & 6 deletions src/creatures/monsters/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Monster>(), 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<Monster>(), 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());
}
}
}
Expand Down Expand Up @@ -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)) {
Expand Down
6 changes: 6 additions & 0 deletions src/creatures/monsters/monster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 1 addition & 5 deletions src/lua/functions/core/game/game_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,8 @@ int GameFunctions::luaGameCreateSoulPitMonster(lua_State* L) {
const uint8_t stack = Lua::getNumber<uint8_t>(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) {
Expand Down

0 comments on commit 8c3842f

Please sign in to comment.