diff --git a/data-otservbr-global/monster/quests/grave_danger/bosses/sir_baeloc.lua b/data-otservbr-global/monster/quests/grave_danger/bosses/sir_baeloc.lua index 7e05cbdb61d..385c25eb48a 100644 --- a/data-otservbr-global/monster/quests/grave_danger/bosses/sir_baeloc.lua +++ b/data-otservbr-global/monster/quests/grave_danger/bosses/sir_baeloc.lua @@ -21,9 +21,7 @@ monster.speed = 125 monster.manaCost = 0 monster.events = { - "sir_baeloc_health", - "brothers_summon", - "grave_danger_death", + "BossHealthCheck", } monster.changeTarget = { @@ -80,6 +78,7 @@ monster.voices = { monster.loot = { { name = "platinum coin", minCount = 1, maxCount = 5, chance = 100000 }, { name = "crystal coin", minCount = 0, maxCount = 2, chance = 50000 }, + { name = "silver token", minCount = 0, maxCount = 3, chance = 40000 }, { name = "supreme health potion", minCount = 0, maxCount = 6, chance = 35000 }, { name = "ultimate mana potion", minCount = 0, maxCount = 20, chance = 32000 }, { name = "ultimate spirit potion", minCount = 0, maxCount = 20, chance = 32000 }, @@ -87,7 +86,6 @@ monster.loot = { { name = "berserk potion", minCount = 0, maxCount = 10, chance = 12000 }, { name = "piece of draconian steel", minCount = 0, maxCount = 4, chance = 9000 }, { id = 3039, minCount = 0, maxCount = 1, chance = 12000 }, -- red gem - { name = "silver token", minCount = 0, maxCount = 2, chance = 9500 }, { id = 23542, chance = 5200 }, -- collar of blue plasma { id = 23544, chance = 5200 }, -- collar of red plasma { name = "knight legs", chance = 11000 }, diff --git a/data-otservbr-global/monster/quests/grave_danger/bosses/sir_nictros.lua b/data-otservbr-global/monster/quests/grave_danger/bosses/sir_nictros.lua index 60b14f17b24..87652425b0b 100644 --- a/data-otservbr-global/monster/quests/grave_danger/bosses/sir_nictros.lua +++ b/data-otservbr-global/monster/quests/grave_danger/bosses/sir_nictros.lua @@ -20,16 +20,15 @@ monster.corpse = 31599 monster.speed = 125 monster.manaCost = 0 -monster.events = { - "sir_nictros_health", - "brothers_summon", -} - monster.changeTarget = { interval = 4000, chance = 10, } +monster.events = { + "BossHealthCheck", +} + monster.bosstiary = { bossRaceId = 1754, bossRace = RARITY_ARCHFOE, diff --git a/data-otservbr-global/scripts/quests/grave_danger_quest/actions_baeloc_nictros.lua b/data-otservbr-global/scripts/quests/grave_danger_quest/actions_baeloc_nictros.lua index b7e6bd0725c..8c14edba969 100644 --- a/data-otservbr-global/scripts/quests/grave_danger_quest/actions_baeloc_nictros.lua +++ b/data-otservbr-global/scripts/quests/grave_danger_quest/actions_baeloc_nictros.lua @@ -1,12 +1,32 @@ local nictrosPosition = Position(33427, 31428, 13) local baelocPosition = Position(33422, 31428, 13) +local healthStates = { + nictros85 = false, + baeloc85 = false, +} + local config = { boss = { name = "Sir Nictros", createFunction = function() local nictros = Game.createMonster("Sir Nictros", nictrosPosition, true, true) local baeloc = Game.createMonster("Sir Baeloc", baelocPosition, true, true) + + if nictros then + nictros:registerEvent("BossHealthCheck") + -- Start with Nictros active + nictros:setMoveLocked(false) + end + if baeloc then + -- Start with Baeloc locked + baeloc:setMoveLocked(true) + baeloc:registerEvent("BossHealthCheck") + end + + healthStates.nictros85 = false + healthStates.baeloc85 = false + return nictros and baeloc end, }, @@ -42,10 +62,11 @@ local config = { local nictros = Creature("Sir Nictros") if baeloc then baeloc:say("Oh, man! You always get the fun!") - if nictros then - nictros:teleportTo(Position(33426, 31437, 13)) - nictros:setMoveLocked(false) - end + baeloc:setMoveLocked(true) + end + if nictros then + nictros:teleportTo(Position(33426, 31437, 13)) + nictros:setMoveLocked(false) end end, 12 * 1000) end, 4 * 1000) @@ -56,3 +77,55 @@ local config = { local lever = BossLever(config) lever:position(Position(33423, 31413, 13)) lever:register() + +-- Health Trigger Logic +local BossHealthCheck = CreatureEvent("BossHealthCheck") + +function BossHealthCheck.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin) + if not creature or not creature:isMonster() then + return primaryDamage, primaryType, secondaryDamage, secondaryType + end + + local name = creature:getName() + + local function getHealthPercentage(creature) + local health = creature:getHealth() + local maxHealth = creature:getMaxHealth() + return (health / maxHealth) * 100 + end + + local healthPercent = getHealthPercentage(creature) + + if name == "Sir Nictros" and not healthStates.nictros85 and healthPercent <= 85 then + healthStates.nictros85 = true + + creature:say("I'll step back now. Let's see how you handle my brother!") + creature:teleportTo(nictrosPosition) + creature:setMoveLocked(true) + + -- Release Baeloc to fight + local baeloc = Creature("Sir Baeloc") + if baeloc then + baeloc:teleportTo(Position(33426, 31435, 13)) + baeloc:setDirection(DIRECTION_SOUTH) + baeloc:setMoveLocked(false) + baeloc:say("My turn! Let me show you my skills!") + end + elseif name == "Sir Baeloc" and healthStates.nictros85 and not healthStates.baeloc85 and healthPercent <= 85 then + healthStates.baeloc85 = true + + creature:say("Brother! I need your assistance!") + + -- Release Nictros to join the fight + local nictros = Creature("Sir Nictros") + if nictros then + nictros:setMoveLocked(false) + nictros:teleportTo(Position(33424, 31435, 13)) + nictros:say("Now we fight together, brother!") + end + end + + return primaryDamage, primaryType, secondaryDamage, secondaryType +end + +BossHealthCheck:register() diff --git a/data-otservbr-global/scripts/quests/grave_danger_quest/creaturescripts_baeloc_nictros.lua b/data-otservbr-global/scripts/quests/grave_danger_quest/creaturescripts_baeloc_nictros.lua deleted file mode 100644 index 2bebddca492..00000000000 --- a/data-otservbr-global/scripts/quests/grave_danger_quest/creaturescripts_baeloc_nictros.lua +++ /dev/null @@ -1,119 +0,0 @@ -local config = { - centerRoom = Position(33424, 31439, 13), - newPosition = Position(33425, 31431, 13), - exitPos = Position(33290, 32474, 9), - x = 12, - y = 12, - baelocPos = Position(33422, 31428, 13), - nictrosPos = Position(33427, 31428, 13), - timer = Storage.Quest.U12_20.GraveDanger.Bosses.BaelocNictros.Timer, - room = Storage.Quest.U12_20.GraveDanger.Bosses.BaelocNictros.Room, - fromPos = Position(33418, 31434, 13), - toPos = Position(33431, 31445, 13), -} - -local brothers_summon = CreatureEvent("brothers_summon") - -function brothers_summon.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType) - local chance = math.random(1, 100) - local position = Position(math.random(config.fromPos.x, config.toPos.x), math.random(config.fromPos.y, config.toPos.y), config.fromPos.z) - local tile = Tile(position) - - if chance >= 90 then - if tile:isWalkable(false, false, false, true, false) then - local summon = creature:getName():lower() == "sir nictros" and "Squire Of Nictros" or "Retainer Of Baeloc" - Game.createMonster(summon, position, false, true) - end - end - - return primaryDamage, primaryType, -secondaryDamage, secondaryType -end - -brothers_summon:register() - -local sir_nictros_health = CreatureEvent("sir_nictros_health") - -function sir_nictros_health.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType) - local players = Game.getSpectators(config.centerRoom, false, true, config.x, config.x, config.y, config.y) - for _, player in pairs(players) do - if player:isPlayer() then - if player:getStorageValue(config.timer) < os.time() then - player:setStorageValue(config.timer, os.time() + 20 * 3600) - end - if player:getStorageValue(config.room) < os.time() then - player:setStorageValue(config.room, os.time() + 30 * 60) - end - end - end - - if primaryType == COMBAT_HEALING then - return primaryDamage, primaryType, -secondaryDamage, secondaryType - end - - local health = creature:getMaxHealth() * 0.60 - local brother_diff = (creature:getHealth() / creature:getMaxHealth()) * 100 - local brother = Creature("Sir Baeloc") - - if brother then - if brother_diff < 55 then - local brother_percent = (brother:getHealth() / brother:getMaxHealth()) * 100 - if (brother_percent - brother_diff) > 5 then - creature:addHealth(28000) - end - end - end - - creature:setStorageValue(1, creature:getStorageValue(1) + primaryDamage + secondaryDamage) - if creature:getStorageValue(2) < 1 and creature:getStorageValue(1) >= health then - creature:setStorageValue(2, 1) - creature:say("Now it's your chance for entertaiment, dear brother!") - creature:teleportTo(config.nictrosPos) - creature:setMoveLocked(true) - local baeloc = Creature("Sir Baeloc") - if baeloc then - baeloc:teleportTo(Position(33424, 31436, 13)) - baeloc:setMoveLocked(false) - end - end - - return primaryDamage, primaryType, -secondaryDamage, secondaryType -end - -sir_nictros_health:register() - -local sir_baeloc_health = CreatureEvent("sir_baeloc_health") - -function sir_baeloc_health.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType) - if primaryType == COMBAT_HEALING then - return primaryDamage, primaryType, -secondaryDamage, secondaryType - end - - local health = creature:getMaxHealth() * 0.60 - local brother_diff = (creature:getHealth() / creature:getMaxHealth()) * 100 - local brother = Creature("Sir Nictros") - - if brother then - if brother_diff < 55 then - local brother_percent = (brother:getHealth() / brother:getMaxHealth()) * 100 - if (brother_percent - brother_diff) > 5 then - creature:addHealth(28000) - end - end - end - - creature:setStorageValue(1, creature:getStorageValue(1) + primaryDamage + secondaryDamage) - - if creature:getStorageValue(2) < 1 and creature:getStorageValue(1) >= health then - creature:setStorageValue(2, 1) - creature:say("Join me in battle my brother. Let's share the fun!") - local nictros = Creature("Sir Nictros") - if nictros then - nictros:teleportTo(Position(33426, 31438, 13)) - nictros:setMoveLocked(false) - end - end - - return primaryDamage, primaryType, -secondaryDamage, secondaryType -end - -sir_baeloc_health:register()