Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
Removed creature events from monsters script interface (#353)
Browse files Browse the repository at this point in the history
Scripts cannot be placed inside the monsters folder, as it is the monsters only interface, all other types of scripts need to be in the scripts folder.
  • Loading branch information
dudantas authored Jan 17, 2022
1 parent 73d4d10 commit 5f004ad
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 94 deletions.
23 changes: 0 additions & 23 deletions data/monster/quests/soul_war/mirror_image.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Original file line number Diff line number Diff line change
@@ -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 = {}
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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()
22 changes: 22 additions & 0 deletions data/scripts/creaturescripts/monster/mirror_image_transform.lua
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 5f004ad

Please sign in to comment.