Skip to content

Commit

Permalink
improvement: cobras spawn and removal of invalid script
Browse files Browse the repository at this point in the history
ops..

Update cobra_flask.lua

Lua code format - (Stylua)
  • Loading branch information
omarcopires committed Feb 19, 2024
1 parent 1c4bea7 commit 833824b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 43 deletions.
1 change: 0 additions & 1 deletion data-otservbr-global/lib/core/storages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3089,7 +3089,6 @@ GlobalStorage = {
OberonEventTime = 65009,
PrinceDrazzakEventTime = 65010,
ScarlettEtzelEventTime = 65011,
CobraBastionFlask = 65012,
Inquisition = 65013,
Yasir = 65014,
IceCrack = 65016,
Expand Down
19 changes: 0 additions & 19 deletions data-otservbr-global/scripts/actions/other/cobra_flask.lua

This file was deleted.

14 changes: 0 additions & 14 deletions data-otservbr-global/scripts/globalevents/cobra_flask.lua

This file was deleted.

1 change: 1 addition & 0 deletions data/libs/core/global_storage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ Global = {
Storage = {
FamiliarSummonEvent10 = 30054,
FamiliarSummonEvent60 = 30055,
CobraFlask = 30055,
},
}
30 changes: 30 additions & 0 deletions data/scripts/actions/items/cobra_flask.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
local applyCobraFlaskEffectOnMonsterSpawn = EventCallback()

applyCobraFlaskEffectOnMonsterSpawn.monsterOnSpawn = function(monster, position)
if table.contains({ "cobra scout", "cobra vizier", "cobra assassin" }, monster:getName():lower()) then
if Game.getStorageValue(Global.Storage.CobraFlask) >= os.time() then
monster:setHealth(monster:getMaxHealth() * 0.75)
monster:getPosition():sendMagicEffect(CONST_ME_GREEN_RINGS)
else
Game.setStorageValue(Global.Storage.CobraFlask, -1)
end
end
return true
end

applyCobraFlaskEffectOnMonsterSpawn:register()

local cobraFlask = Action()

function cobraFlask.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if table.contains({ 31284, 31285, 31286, 31287 }, target:getId()) then
target:getPosition():sendMagicEffect(CONST_ME_GREENSMOKE)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You carefully pour just a tiny, little, finely dosed... and there goes the whole content of the bottle. Stand back!")
item:transform(31297)
Game.setStorageValue(Global.Storage.CobraFlask, os.time() + 30 * 60)
end
return true
end

cobraFlask:id(31296)
cobraFlask:register()
10 changes: 1 addition & 9 deletions data/scripts/eventcallbacks/monster/on_spawn.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
local function handleCobra(monster)
if monster:getName():lower() == "cobra scout" or monster:getName():lower() == "cobra vizier" or monster:getName():lower() == "cobra assassin" then
if getGlobalStorageValue(GlobalStorage.CobraBastionFlask) >= os.time() then
monster:setHealth(monster:getMaxHealth() * 0.75)
end
end
end

local function handleIronServantReplica(monster)
if monster:getName():lower() ~= "iron servant replica" then
return
Expand Down Expand Up @@ -39,13 +31,13 @@ function callback.monsterOnSpawn(monster, position)
if not monster then
return
end

HazardMonster.onSpawn(monster, position)

if monster:getType():isRewardBoss() then
monster:setReward(true)
end

handleCobra(monster)
handleIronServantReplica(monster)

if not monster:getType():canSpawn(position) then
Expand Down

0 comments on commit 833824b

Please sign in to comment.