Skip to content

Commit

Permalink
fix: summons inheriting boss abilities and some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
phacUFPE committed Dec 5, 2024
1 parent d081da2 commit 19ad890
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
11 changes: 11 additions & 0 deletions data-otservbr-global/lib/others/soulpit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ SoulPit = {
bossPosition = Position(32372, 31135, 8),
exit = Position(32371, 31164, 8),
zone = Zone("soulpit"),

getMonsterVariationNameBySoulCore = function(searchName)
for mTypeName, soulCoreName in pairs(SoulPit.SoulCoresConfiguration.monsterVariationsSoulCore) do
if soulCoreName == searchName then
return mTypeName
end
end

return nil
end,
}

SoulPit.zone:addArea(Position(32365, 31134, 8), Position(32382, 31152, 8))
SoulPit.zone:setRemoveDestination(SoulPit.exit)
23 changes: 9 additions & 14 deletions data-otservbr-global/scripts/actions/soulpit/soulpit_fight.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SoulPit.zone:blockFamiliars()

local zoneEvent = ZoneEvent(SoulPit.zone)
function zoneEvent.afterLeave(zone, creature)
local player = creature:getPlayer()
Expand Down Expand Up @@ -27,6 +29,10 @@ zoneEvent:register()
local soulPitAction = Action()
function soulPitAction.onUse(player, item, fromPosition, target, toPosition, isHotkey)
logger.warn(item:getName())
if target and target:getId() == SoulPit.obeliskActive then
creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting in the soulpit!")
return false
end
if not target or target:getId() ~= SoulPit.obeliskInactive then
return false
end
Expand All @@ -49,12 +55,6 @@ function soulPitAction.onUse(player, item, fromPosition, target, toPosition, isH
return true
end

if not table.empty(SoulPit.zone:getPlayers()) then
local message = "Someone is fighting in the arena!"
creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
return false
end

local isAccountNormal = creature:getAccountType() < ACCOUNT_TYPE_GAMEMASTER
if isAccountNormal and creature:getLevel() < SoulPit.requiredLevel then
local message = string.format("All players need to be level %s or higher.", SoulPit.requiredLevel)
Expand All @@ -72,8 +72,8 @@ function soulPitAction.onUse(player, item, fromPosition, target, toPosition, isH
end

local monsterName = string.gsub(item:getName(), " soul core", "")

logger.warn("monster name: " .. monsterName)
local monsterVariationName = SoulPit.getMonsterVariationNameBySoulCore(item:getName())
monsterName = monsterVariationName and monsterVariationName or monsterName

SoulPit.zone:removeMonsters()

Expand All @@ -95,9 +95,7 @@ function soulPitAction.onUse(player, item, fromPosition, target, toPosition, isH

SoulPit.kickEvent = addEvent(function()
SoulPit.encounter = nil
for _, player in pairs(SoulPit.zone:getPlayers()) do
player:teleportTo(SoulPit.exit)
end
SoulPit.zone:removePlayers()
SoulPit.obeliskPosition:transformItem(SoulPit.obeliskActive, SoulPit.obeliskInactive)
end, SoulPit.timeToKick)
end
Expand All @@ -106,8 +104,6 @@ function soulPitAction.onUse(player, item, fromPosition, target, toPosition, isH

local function waveStart()
for stack, amount in pairs(SoulPit.waves[encounter.currentStage].stacks) do
logger.warn("stack: " .. stack)
logger.warn("amount: " .. amount)
for i = 1, amount do
local position = stack ~= 40 and SoulPit.zone:randomPosition() or SoulPit.bossPosition
for i = 1, SoulPit.timeToSpawnMonsters / 1000 do
Expand All @@ -125,7 +121,6 @@ function soulPitAction.onUse(player, item, fromPosition, target, toPosition, isH
return false
end
if stack == 40 then
logger.warn("ability name: {}", bossAbilityName)
if bossAbility.monster then
monster:registerEvent(bossAbilityName)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local enrage = CreatureEvent("enrageSoulPit")
function enrage.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType)
if not creature or not creature:isMonster() then
if not creature or not creature:isMonster() and creature:getMaster() then
return true
end

Expand All @@ -26,7 +26,7 @@ enrage:register()

local overpower = CreatureEvent("overpowerSoulPit")
function overpower.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType)
if creature and attacker and attacker:isMonster() and attacker:getForgeStack() == 40 then
if creature and attacker and attacker:isMonster() and attacker:getForgeStack() == 40 and not attacker:getMaster() then
primaryDamage = primaryDamage * 1.1
secondaryDamage = secondaryDamage * 1.1
creature:getPosition():sendMagicEffect(CONST_ME_CRITICAL_DAMAGE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local spell = Spell("instant")

function spell.onCastSpell(creature, var)
local monster = creature:getMonster()
if monster and monster:soulPit() and table.contains(creature:getEvents(CREATURE_EVENT_THINK), "opressorSoulPit") then
if monster and monster:soulPit() and not monster:getMaster() and table.contains(creature:getEvents(CREATURE_EVENT_THINK), "opressorSoulPit") then
return combat:execute(creature, var)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ local combats = { combatRoot, combatFear }

function spell.onCastSpell(creature, var)
local monster = creature:getMonster()
if monster and monster:soulPit() and table.contains(creature:getEvents(CREATURE_EVENT_THINK), "opressorSoulPit") then
if monster and monster:soulPit() and not monster:getMaster() and table.contains(creature:getEvents(CREATURE_EVENT_THINK), "opressorSoulPit") then
for _, combat in pairs(combats) do
combat:execute(creature, var)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local spell = Spell("instant")

function spell.onCastSpell(creature, var)
local monster = creature:getMonster()
if monster and monster:soulPit() and table.contains(creature:getEvents(CREATURE_EVENT_THINK), "opressorSoulPit") then
if monster and monster:soulPit() and not monster:getMaster() and table.contains(creature:getEvents(CREATURE_EVENT_THINK), "opressorSoulPit") then
return combat:execute(creature, var)
end

Expand Down

0 comments on commit 19ad890

Please sign in to comment.