diff --git a/data/monster/quests/soul_war/mirror_image.lua b/data/monster/quests/soul_war/mirror_image.lua index ec83986a1..ade3cb5a5 100644 --- a/data/monster/quests/soul_war/mirror_image.lua +++ b/data/monster/quests/soul_war/mirror_image.lua @@ -109,26 +109,3 @@ monster.events = { } mType:register(monster) - -local mirrorImageTransform = CreatureEvent("MirrorImageTransform") - -function mirrorImageTransform.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType) - if attacker:isPlayer() then - local newForm = nil - if attacker:isSorcerer() then - newForm = "Sorcerer's Apparition" - elseif attacker:isDruid() then - newForm = "Druid's Apparition" - elseif attacker:isPaladin() then - newForm = "Paladin's Apparition" - elseif attacker:isKnight() then - newForm = "Knight's Apparition" - end - if newForm then - creature:setType(newForm) - end - end - return primaryDamage, primaryType, secondaryDamage, secondaryType -end - -mirrorImageTransform:register() diff --git a/data/monster/quests/the_secret_library/bosses/grand_master_oberon.lua b/data/monster/quests/the_secret_library/bosses/grand_master_oberon.lua index 0727c10ac..4f1ed707a 100644 --- a/data/monster/quests/the_secret_library/bosses/grand_master_oberon.lua +++ b/data/monster/quests/the_secret_library/bosses/grand_master_oberon.lua @@ -1,66 +1,4 @@ -local asking = { - [1] = {msg = "You appear like a worm among men!"}, - [2] = {msg = "The world will suffer for its iddle laziness!"}, - [3] = {msg = "People fall at my feet when they see me coming!"}, - [4] = {msg = "This will be the end of mortal man!"}, - [5] = {msg = "I will remove you from this plane of existence!"}, - [6] = {msg = "Dragons will soon rule this world, I am their herald!"}, - [7] = {msg = "The true virtue of chivalry are my belief!"}, - [8] = {msg = "I lead the most honourable and formidable following of knights!"}, - [9] = {msg = "ULTAH SALID'AR, ESDO LO!"}, -} - -local responses = { - [1] = {msg = "How appropriate, you look like something worms already got the better of!"}, - [2] = {msg = "Are you ever going to fight or do you prefer talking!"}, - [3] = {msg = "Even before they smell your breath?"}, - [4] = {msg = "Then let me show you the concept of mortality before it!"}, - [5] = {msg = "Too bad you barely exist at all!"}, - [6] = {msg = "Excuse me but I still do not get the message!"}, - [7] = {msg = "Dare strike up a Minnesang and you will receive your last accolade!"}, - [8] = {msg = "Then why are we fighting alone right now?"}, - [9] = {msg = "SEHWO ASIMO, TOLIDO ESD!"}, -} - -local config = { - storage = { - asking = 1, - life = 2, - exhaust = 3, - }, - monster = { - "Falcon Knight", - "Falcon Paladin" - }, - amount_life = 3 -} - -local function heal(monster) - local storage = monster:getStorageValue(config.storage.life) - monster:setStorageValue(config.storage.life, storage + 1) - monster:addHealth(monster:getMaxHealth()) - -end - -local function sendAsking(monster) - monster:registerEvent('OberonImmunity') - local random = math.random(#asking) - monster:say(asking[random].msg, TALKTYPE_MONSTER_SAY) - monster:setStorageValue(config.storage.asking, random) - heal(monster) - Game.createMonster(config.monster[math.random(#config.monster)], monster:getPosition(), true, true) -end - -local immunity = CreatureEvent("OberonImmunity") - -function immunity.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin) - if creature:isMonster() then - creature:getPosition():sendMagicEffect(CONST_ME_HOLYAREA) - end - return true -end - -immunity:register() +dofile("data/monster/quests/the_secret_library/bosses/grand_master_oberon_functions.lua") local mType = Game.createMonsterType("Grand Master Oberon") local monster = {} @@ -177,18 +115,18 @@ monster.immunities = { } mType.onThink = function(monster, interval) - if monster:getStorageValue(config.storage.life) <= config.amount_life then + if monster:getStorageValue(GrandMasterOberonConfig.Storage.Life) <= GrandMasterOberonConfig.AmountLife then local percentageHealth = (monster:getHealth()*100)/monster:getMaxHealth() if percentageHealth <= 20 then - sendAsking(monster) + SendOberonAsking(monster) end end end mType.onAppear = function(monster, creature) if monster:getId() == creature:getId() then - monster:setStorageValue(config.storage.asking, 1) - monster:setStorageValue(config.storage.life, 1) + monster:setStorageValue(GrandMasterOberonConfig.Storage.Asking, 1) + monster:setStorageValue(GrandMasterOberonConfig.Storage.Life, 1) end if monster:getType():isRewardBoss() then monster:setReward(true) @@ -202,14 +140,14 @@ mType.onMove = function(monster, creature, fromPosition, toPosition) end mType.onSay = function(monster, creature, type, message) - local exhaust = config.storage.exhaust + local exhaust = GrandMasterOberonConfig.Storage.Exhaust if creature:isPlayer() and monster:getStorageValue(exhaust) <= os.time() then message = message:lower() monster:setStorageValue(exhaust, os.time() + 1) - for i, v in pairs(responses) do + for i, v in pairs(GrandMasterOberonResponses) do if message == v.msg:lower() then - local asking_storage = monster:getStorageValue(config.storage.asking) - if asking[i].msg:lower() == asking[asking_storage].msg:lower() then + local asking_storage = monster:getStorageValue(GrandMasterOberonConfig.Storage.Asking) + if GrandMasterOberonAsking[i].msg:lower() == GrandMasterOberonAsking[asking_storage].msg:lower() then monster:unregisterEvent('OberonImmunity') end end diff --git a/data/monster/quests/the_secret_library/bosses/grand_master_oberon_functions.lua b/data/monster/quests/the_secret_library/bosses/grand_master_oberon_functions.lua new file mode 100644 index 000000000..3a2624a4b --- /dev/null +++ b/data/monster/quests/the_secret_library/bosses/grand_master_oberon_functions.lua @@ -0,0 +1,54 @@ +GrandMasterOberonAsking = { + [1] = {msg = "You appear like a worm among men!"}, + [2] = {msg = "The world will suffer for its iddle laziness!"}, + [3] = {msg = "People fall at my feet when they see me coming!"}, + [4] = {msg = "This will be the end of mortal man!"}, + [5] = {msg = "I will remove you from this plane of existence!"}, + [6] = {msg = "Dragons will soon rule this world, I am their herald!"}, + [7] = {msg = "The true virtue of chivalry are my belief!"}, + [8] = {msg = "I lead the most honourable and formidable following of knights!"}, + [9] = {msg = "ULTAH SALID'AR, ESDO LO!"}, +} + +GrandMasterOberonResponses = { + [1] = {msg = "How appropriate, you look like something worms already got the better of!"}, + [2] = {msg = "Are you ever going to fight or do you prefer talking!"}, + [3] = {msg = "Even before they smell your breath?"}, + [4] = {msg = "Then let me show you the concept of mortality before it!"}, + [5] = {msg = "Too bad you barely exist at all!"}, + [6] = {msg = "Excuse me but I still do not get the message!"}, + [7] = {msg = "Dare strike up a Minnesang and you will receive your last accolade!"}, + [8] = {msg = "Then why are we fighting alone right now?"}, + [9] = {msg = "SEHWO ASIMO, TOLIDO ESD!"}, +} + +GrandMasterOberonConfig = { + Storage = { + Asking = 1, + Life = 2, + Exhaust = 3, + }, + Monster = { + "Falcon Knight", + "Falcon Paladin" + }, + AmountLife = 3 +} + +local function healOberon(monster) + local storage = monster:getStorageValue(GrandMasterOberonConfig.Storage.Life) + monster:setStorageValue(GrandMasterOberonConfig.Storage.Life, storage + 1) + monster:addHealth(monster:getMaxHealth()) + +end + +function SendOberonAsking(monster) + monster:registerEvent('OberonImmunity') + local random = math.random(#GrandMasterOberonAsking) + monster:say(GrandMasterOberonAsking[random].msg, TALKTYPE_MONSTER_SAY) + monster:setStorageValue(GrandMasterOberonConfig.Storage.Asking, random) + + healOberon(monster) + + Game.createMonster(GrandMasterOberonConfig.Monster[math.random(#GrandMasterOberonConfig.Monster)], monster:getPosition(), true, true) +end diff --git a/data/scripts/creaturescripts/monster/grand_master_oberon_immunity.lua b/data/scripts/creaturescripts/monster/grand_master_oberon_immunity.lua new file mode 100644 index 000000000..5f90f29c1 --- /dev/null +++ b/data/scripts/creaturescripts/monster/grand_master_oberon_immunity.lua @@ -0,0 +1,10 @@ +local grandMasterOberonImmunity = CreatureEvent("OberonImmunity") + +function grandMasterOberonImmunity.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin) + if creature and creature:isMonster() then + creature:getPosition():sendMagicEffect(CONST_ME_HOLYAREA) + end + return true +end + +grandMasterOberonImmunity:register() diff --git a/data/scripts/creaturescripts/monster/mirror_image_transform.lua b/data/scripts/creaturescripts/monster/mirror_image_transform.lua new file mode 100644 index 000000000..14259511c --- /dev/null +++ b/data/scripts/creaturescripts/monster/mirror_image_transform.lua @@ -0,0 +1,22 @@ +local mirrorImageTransform = CreatureEvent("MirrorImageTransform") + +function mirrorImageTransform.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType) + if attacker and attacker:isPlayer() then + local newForm = nil + if attacker:isSorcerer() then + newForm = "Sorcerer's Apparition" + elseif attacker:isDruid() then + newForm = "Druid's Apparition" + elseif attacker:isPaladin() then + newForm = "Paladin's Apparition" + elseif attacker:isKnight() then + newForm = "Knight's Apparition" + end + if newForm and creature then + creature:setType(newForm) + end + end + return primaryDamage, primaryType, secondaryDamage, secondaryType +end + +mirrorImageTransform:register()