Skip to content

Commit

Permalink
improve: boss mechanics Outburst (opentibiabr#2130)
Browse files Browse the repository at this point in the history
Using BossLever system.
More clean core.

---------

Co-authored-by: Eduardo Dantas <[email protected]>
  • Loading branch information
luanluciano93 and dudantas authored Jan 27, 2024
1 parent 84ec236 commit 57b3fb4
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 182 deletions.
7 changes: 4 additions & 3 deletions data-otservbr-global/lib/core/storages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3065,10 +3065,11 @@ GlobalStorage = {
},
},
HeartOfDestruction = {
-- Reserved storage from 60172 - 60180
-- Reserved storage from 60172 - 60190
ChargedAnomaly = 60172,
EradicatorWeak = 60178,
EradicatorReleaseT = 60179,
OutburstStage = 60180,
OutburstHealth = 60181,
OutburstChargingKilled = 60182,
},
FuryGates = 65000,
Yakchal = 65001,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,134 +1,41 @@
-- FUNCTIONS
local function doCheckArea()
local upConer = { x = 32223, y = 31273, z = 14 } -- upLeftCorner
local downConer = { x = 32246, y = 31297, z = 14 } -- downRightCorner

for i = upConer.x, downConer.x do
for j = upConer.y, downConer.y do
for k = upConer.z, downConer.z do
local room = { x = i, y = j, z = k }
local tile = Tile(room)
if tile then
local creatures = tile:getCreatures()
if creatures and #creatures > 0 then
for _, creature in pairs(creatures) do
local player = Player(creature)
if player then
return true
end
end
end
end
end
end
end
return false
end

local function clearArea()
local upConer = { x = 32223, y = 31273, z = 14 } -- upLeftCorner
local downConer = { x = 32246, y = 31297, z = 14 } -- downRightCorner

for i = upConer.x, downConer.x do
for j = upConer.y, downConer.y do
for k = upConer.z, downConer.z do
local room = { x = i, y = j, z = k }
local tile = Tile(room)
if tile then
local creatures = tile:getCreatures()
if creatures and #creatures > 0 then
for _, creatureUid in pairs(creatures) do
local creature = Creature(creatureUid)
if creature then
if creature:isPlayer() then
creature:teleportTo({ x = 32208, y = 31372, z = 14 })
elseif creature:isMonster() then
creature:remove()
end
end
end
end
end
end
end
end
stopEvent(areaOutburst1)
end
-- FUNCTIONS END

local heartDestructionOutburst = Action()
function heartDestructionOutburst.onUse(player, item, fromPosition, itemEx, toPosition)
local config = {
playerPositions = {
Position(32207, 31284, 14),
Position(32207, 31285, 14),
Position(32207, 31286, 14),
Position(32207, 31287, 14),
Position(32207, 31288, 14),
},

newPos = { x = 32234, y = 31292, z = 14 },
}

local pushPos = { x = 32207, y = 31284, z = 14 }

if item.actionid == 14331 then
if item.itemid == 8911 then
if player:getPosition().x == pushPos.x and player:getPosition().y == pushPos.y and player:getPosition().z == pushPos.z then
local storePlayers = {}
for i = 1, #config.playerPositions do
local tile = Tile(Position(config.playerPositions[i]))
if tile then
local playerTile = tile:getTopCreature()
if playerTile and playerTile:isPlayer() then
storePlayers[#storePlayers + 1] = playerTile
end
end
end

if doCheckArea() == false then
clearArea()

local players

for i = 1, #storePlayers do
players = storePlayers[i]
if not player:canFightBoss("Outburst") then
return players:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need wait to fight again")
end
config.playerPositions[i]:sendMagicEffect(CONST_ME_POFF)
players:teleportTo(config.newPos)
players:setBossCooldown("Outburst", os.time() + configManager.getNumber(configKeys.BOSS_DEFAULT_TIME_TO_FIGHT_AGAIN))
end
Position(config.newPos):sendMagicEffect(11)

areaOutburst1 = addEvent(clearArea, 15 * 60000)

Game.createMonster("Spark of Destruction", { x = 32229, y = 31282, z = 14 }, false, true)
Game.createMonster("Spark of Destruction", { x = 32230, y = 31287, z = 14 }, false, true)
Game.createMonster("Spark of Destruction", { x = 32237, y = 31287, z = 14 }, false, true)
Game.createMonster("Spark of Destruction", { x = 32238, y = 31282, z = 14 }, false, true)
Game.createMonster("Outburst", { x = 32234, y = 31284, z = 14 }, false, true)

outburstStage = 0
outburstHealth = 290000

local vortex = Tile({ x = 32225, y = 31285, z = 14 }):getItemById(23482)
if vortex then
vortex:transform(23483)
vortex:setActionId(14350)
end
else
player:sendTextMessage(19, "Someone is in the area.")
end
else
return true
local config = {
boss = {
name = "Outburst",
position = Position(32234, 31284, 14),
},
playerPositions = {
{ pos = Position(32207, 31284, 14), teleport = Position(32234, 31292, 14), effect = CONST_ME_TELEPORT },
{ pos = Position(32207, 31285, 14), teleport = Position(32234, 31292, 14), effect = CONST_ME_TELEPORT },
{ pos = Position(32207, 31286, 14), teleport = Position(32234, 31292, 14), effect = CONST_ME_TELEPORT },
{ pos = Position(32207, 31287, 14), teleport = Position(32234, 31292, 14), effect = CONST_ME_TELEPORT },
{ pos = Position(32207, 31288, 14), teleport = Position(32234, 31292, 14), effect = CONST_ME_TELEPORT },
},
specPos = {
from = Position(32223, 31273, 14),
to = Position(32246, 31297, 14),
},
monsters = {
{ name = "Spark of Destruction", pos = Position(32229, 31282, 14) },
{ name = "Spark of Destruction", pos = Position(32230, 31287, 14) },
{ name = "Spark of Destruction", pos = Position(32237, 31287, 14) },
{ name = "Spark of Destruction", pos = Position(32238, 31282, 14) },
},
onUseExtra = function()
Game.setStorageValue(GlobalStorage.HeartOfDestruction.OutburstStage, 0)
Game.setStorageValue(GlobalStorage.HeartOfDestruction.OutburstHealth, 290000)

local tile = Tile(Position(32225, 31285, 14))
if tile then
local vortex = tile:getItemById(23482)
if vortex then
vortex:transform(23483)
vortex:setActionId(14350)
end
end
item:transform(item.itemid == 8911 and 8912 or 8911)
end
return true
end
end,
exit = Position(32208, 31372, 14),
}

heartDestructionOutburst:aid(14331)
heartDestructionOutburst:register()
local lever = BossLever(config)
lever:aid(14331)
lever:register()
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
local chargingOutDeath = CreatureEvent("ChargingOutDeath")

function chargingOutDeath.onDeath(creature)
if chargingOutKilled == false then
local monster = Game.createMonster("outburst", { x = 32234, y = 31285, z = 14 }, false, true)
monster:addHealth(-monster:getHealth() + outburstHealth, COMBAT_PHYSICALDAMAGE)
local chargingOutKilled = Game.getStorageValue(GlobalStorage.HeartOfDestruction.OutburstChargingKilled)
if chargingOutKilled < 1 then
local monster = Game.createMonster("Outburst", Position(32234, 31285, 14), false, true)
if monster then
local outburstHealth = Game.getStorageValue(GlobalStorage.HeartOfDestruction.OutburstHealth) > 0 and Game.getStorageValue(GlobalStorage.HeartOfDestruction.OutburstHealth) or 0
monster:addHealth(-monster:getHealth() + outburstHealth, COMBAT_PHYSICALDAMAGE)
end
end
return true
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,50 +1,37 @@
local function createSpawnChargingOutburst(stage)
Game.createMonster("Spark of Destruction", Position(32229, 31282, 14), false, true)
Game.createMonster("Spark of Destruction", Position(32230, 31287, 14), false, true)
Game.createMonster("Spark of Destruction", Position(32237, 31287, 14), false, true)
Game.createMonster("Spark of Destruction", Position(32238, 31282, 14), false, true)
Game.createMonster("Charging Outburst", Position(32234, 31284, 14), false, true)

Game.setStorageValue(GlobalStorage.HeartOfDestruction.OutburstStage, stage)
Game.setStorageValue(GlobalStorage.HeartOfDestruction.OutburstChargingKilled, -1)
end

local outburstCharge = CreatureEvent("OutburstCharge")

function outburstCharge.onThink(creature)
if not creature or not creature:isMonster() then
return false
end

local hp = (creature:getHealth() / creature:getMaxHealth()) * 100
if hp <= 80 and outburstStage == 0 then
outburstHealth = creature:getHealth()
local outburstStage = Game.getStorageValue(GlobalStorage.HeartOfDestruction.OutburstStage) > 0 and Game.getStorageValue(GlobalStorage.HeartOfDestruction.OutburstStage) or 0
Game.setStorageValue(GlobalStorage.HeartOfDestruction.OutburstHealth, creature:getHealth())

local hpPercent = (creature:getHealth() / creature:getMaxHealth()) * 100
if hpPercent <= 80 and outburstStage == 0 then
creature:remove()
Game.createMonster("spark of destruction", { x = 32229, y = 31282, z = 14 }, false, true)
Game.createMonster("spark of destruction", { x = 32230, y = 31287, z = 14 }, false, true)
Game.createMonster("spark of destruction", { x = 32237, y = 31287, z = 14 }, false, true)
Game.createMonster("spark of destruction", { x = 32238, y = 31282, z = 14 }, false, true)
Game.createMonster("charging outburst", { x = 32234, y = 31284, z = 14 }, false, true)
outburstStage = 1
chargingOutKilled = false
elseif hp <= 60 and outburstStage == 1 then
outburstHealth = creature:getHealth()
createSpawnChargingOutburst(1)
elseif hpPercent <= 60 and outburstStage == 1 then
creature:remove()
Game.createMonster("spark of destruction", { x = 32229, y = 31282, z = 14 }, false, true)
Game.createMonster("spark of destruction", { x = 32230, y = 31287, z = 14 }, false, true)
Game.createMonster("spark of destruction", { x = 32237, y = 31287, z = 14 }, false, true)
Game.createMonster("spark of destruction", { x = 32238, y = 31282, z = 14 }, false, true)
Game.createMonster("charging outburst", { x = 32234, y = 31284, z = 14 }, false, true)
outburstStage = 2
chargingOutKilled = false
elseif hp <= 40 and outburstStage == 2 then
outburstHealth = creature:getHealth()
createSpawnChargingOutburst(2)
elseif hpPercent <= 40 and outburstStage == 2 then
creature:remove()
Game.createMonster("spark of destruction", { x = 32229, y = 31282, z = 14 }, false, true)
Game.createMonster("spark of destruction", { x = 32230, y = 31287, z = 14 }, false, true)
Game.createMonster("spark of destruction", { x = 32237, y = 31287, z = 14 }, false, true)
Game.createMonster("spark of destruction", { x = 32238, y = 31282, z = 14 }, false, true)
Game.createMonster("charging outburst", { x = 32234, y = 31284, z = 14 }, false, true)
outburstStage = 3
chargingOutKilled = false
elseif hp <= 20 and outburstStage == 3 then
outburstHealth = creature:getHealth()
createSpawnChargingOutburst(3)
elseif hpPercent <= 20 and outburstStage == 3 then
creature:remove()
Game.createMonster("spark of destruction", { x = 32229, y = 31282, z = 14 }, false, true)
Game.createMonster("spark of destruction", { x = 32230, y = 31287, z = 14 }, false, true)
Game.createMonster("spark of destruction", { x = 32237, y = 31287, z = 14 }, false, true)
Game.createMonster("spark of destruction", { x = 32238, y = 31282, z = 14 }, false, true)
Game.createMonster("charging outburst", { x = 32234, y = 31284, z = 14 }, false, true)
outburstStage = 4
chargingOutKilled = false
createSpawnChargingOutburst(4)
end
return true
end
Expand Down
16 changes: 8 additions & 8 deletions data-otservbr-global/scripts/spells/monster/outburst_explode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_PURPLEENERGY)

arr = {
local spellArea = {
{ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 },
Expand All @@ -47,7 +47,7 @@ arr = {
{ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
}

local area = createCombatArea(arr)
local area = createCombatArea(spellArea)
combat:setArea(area)

local function delayedCastSpell(creature, var)
Expand All @@ -68,16 +68,16 @@ end
local spell = Spell("instant")

function spell.onCastSpell(creature, var)
local from = creature:getId()

outExplode()
delayedCastSpell(creature, var)
chargingOutKilled = true
Game.setStorageValue(GlobalStorage.HeartOfDestruction.OutburstChargingKilled, 1)
addEvent(removeOutburst, 1000, creature.uid)

local monster = Game.createMonster("Outburst", { x = 32234, y = 31284, z = 14 }, false, true)
monster:addHealth(-monster:getHealth() + outburstHealth, COMBAT_PHYSICALDAMAGE)
transferBossPoints(from, monster:getId())
local monster = Game.createMonster("Outburst", Position(32234, 31284, 14), false, true)
if monster then
local outburstHealth = Game.getStorageValue(GlobalStorage.HeartOfDestruction.OutburstHealth) > 0 and Game.getStorageValue(GlobalStorage.HeartOfDestruction.OutburstHealth) or 0
monster:addHealth(-monster:getHealth() + outburstHealth, COMBAT_PHYSICALDAMAGE)
end
return true
end

Expand Down

0 comments on commit 57b3fb4

Please sign in to comment.