Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve: updating files with old functions #1974

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions data-otservbr-global/lib/compat/compat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,17 @@ function getCreatureName(cid)
end

function getCreatureHealth(cid)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("The function 'getCreatureHealth(cid)' is old and its new format is 'c:getHealth()', where the 'c' refers to a Creature (player or monster), adjust it to: {}, {}.", line, source)
local c = Creature(cid)
return c and c:getHealth() or false
end

function getCreatureMaxHealth(cid)
local line = debug.getinfo(2).currentline
local source = debug.getinfo(2).source:match("@?(.*)")
logger.warn("The function 'getCreatureMaxHealth(cid)' is old and its new format is 'c:getMaxHealth()', where the 'c' refers to a Creature (player or monster), adjust it to: {}, {}.", line, source)
luanluciano93 marked this conversation as resolved.
Show resolved Hide resolved
local c = Creature(cid)
return c and c:getMaxHealth() or false
end
Expand Down
17 changes: 8 additions & 9 deletions data-otservbr-global/scripts/actions/other/hireling_food.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,45 +30,44 @@ carrotPie:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 7)
local hirelingFood = Action()

function hirelingFood.onUse(player, item, frompos, item2, topos)
local cid = player:getId()
if player:getStorageValue(config.storage) <= os.time() then
if item.itemid == 29408 then
player:say("Chomp.", TALKTYPE_MONSTER_SAY)
Creature(cid):addCondition(roastedWyvernWings)
player:addCondition(roastedWyvernWings)
item:remove(1)
player:setStorageValue(config.storage, os.time() + config.exhaust)
elseif item.itemid == 29409 then
player:say("Yummm.", TALKTYPE_MONSTER_SAY)
Creature(cid):addCondition(carrotPie)
player:addCondition(carrotPie)
item:remove(1)
player:setStorageValue(config.storage, os.time() + config.exhaust)
elseif item.itemid == 29410 then
player:say("Munch.", TALKTYPE_MONSTER_SAY)
Creature(cid):addCondition(tropicalMarinatedTiger)
player:addCondition(tropicalMarinatedTiger)
item:remove(1)
player:setStorageValue(config.storage, os.time() + config.exhaust)
elseif item.itemid == 29411 then
player:say("Munch.", TALKTYPE_MONSTER_SAY)
Creature(cid):addCondition(delicatessenSalad)
player:addCondition(delicatessenSalad)
item:remove(1)
player:setStorageValue(config.storage, os.time() + config.exhaust)
elseif item.itemid == 29412 then
player:say("Yummm.", TALKTYPE_MONSTER_SAY)
Creature(cid):addCondition(chilliConCarniphila)
player:addCondition(chilliConCarniphila)
item:remove(1)
player:setStorageValue(config.storage, os.time() + config.exhaust)
elseif item.itemid == 29413 then
player:say("Mmmmm.", TALKTYPE_MONSTER_SAY)
Creature(cid):addCondition(svargrondSalmonFilet)
player:addCondition(svargrondSalmonFilet)
item:remove(1)
player:setStorageValue(config.storage, os.time() + config.exhaust)
elseif item.itemid == 29414 then
Creature(cid):addHealth(getCreatureMaxHealth(cid) * 0.3)
player:addHealth(player:getMaxHealth() * 0.3)
player:say("Munch.", TALKTYPE_MONSTER_SAY)
item:remove(1)
player:setStorageValue(config.storage, os.time() + config.exhaust)
elseif item.itemid == 29415 then
Creature(cid):addMana(Creature(cid):getMaxMana() * 0.3)
player:addMana(player:getMaxMana() * 0.3)
player:say("Chomp.", TALKTYPE_MONSTER_SAY)
item:remove(1)
player:setStorageValue(config.storage, os.time() + config.exhaust)
Expand Down
26 changes: 13 additions & 13 deletions data-otservbr-global/scripts/actions/other/jean_pierre_food.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function jeanPierreFood.onUse(player, item, frompos, item2, topos)

if item.itemid == 9079 then
item:remove(1)
Creature(cid):addHealth(getCreatureMaxHealth(cid) - getCreatureHealth(cid))
player:addHealth(player:getMaxHealth() - player:getHealth())
player:say("Gulp.", TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your health has been refilled.")
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
Expand All @@ -79,14 +79,14 @@ function jeanPierreFood.onUse(player, item, frompos, item2, topos)
return true
elseif item.itemid == 9081 then
item:remove(1)
Creature(cid):addCondition(condition_shield)
player:addCondition(condition_shield)
player:say("Chomp.", TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel less vulnerable.")
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
return true
elseif item.itemid == 9082 then
item:remove(1)
Creature(cid):addCondition(condition_ml)
player:addCondition(condition_ml)
player:say("Chomp.", TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel smarter.")
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
Expand All @@ -99,35 +99,35 @@ function jeanPierreFood.onUse(player, item, frompos, item2, topos)
return true
elseif item.itemid == 9084 then
item:remove(1)
Creature(cid):addCondition(condition_melee)
player:addCondition(condition_melee)
player:say("Yum.", TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel stronger.")
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
return true
elseif item.itemid == 9085 then
item:remove(1)
Creature(cid):addCondition(condition_speed)
player:addCondition(condition_speed)
player:say("Munch.", TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your speed has been increased.")
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
return true
elseif item.itemid == 9086 then
item:remove(1)
Creature(cid):addMana(Creature(cid):getMaxMana() - Creature(cid):getMana())
player:addMana(Cplayer:getMaxMana() - player:getMana())
player:say("Chomp.", TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your mana has been refilled.")
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
return true
elseif item.itemid == 9087 then
item:remove(1)
Creature(cid):addCondition(condition_dist)
player:addCondition(condition_dist)
player:say("Mmmm.", TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel more focused.")
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
return true
elseif item.itemid == 9088 then
item:remove(1)
Creature(cid):addCondition(condition_f)
player:addCondition(condition_f)
player:say("Smack.", TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You felt fishing inspiration.")
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
Expand All @@ -146,7 +146,7 @@ function jeanPierreFood.onUse(player, item, frompos, item2, topos)
else
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You take a gulp from the large bowl, but there's still some blackjack in it.")
end
Creature(cid):addHealth(getCreatureMaxHealth(cid) - getCreatureHealth(cid))
player:addHealth(player:getMaxHealth() - player:getHealth())
player:say("Gulp.", TALKTYPE_MONSTER_SAY)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
return true
Expand All @@ -155,17 +155,17 @@ function jeanPierreFood.onUse(player, item, frompos, item2, topos)
local c = { condition_shield, condition_ml, condition_melee, condition_dist, condition_speed }
local r = math.random(1, 4)
if r == 1 then
Creature(cid):addCondition(c[math.random(1, #c)])
player:addCondition(c[math.random(1, #c)])
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel stronger, but you have no idea what was increased.")
elseif r == 2 then
doSetCreatureLight(cid, 15, 154, 60 * 60 * 1000)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You feel enlightened.")
elseif r == 3 then
Creature(cid):addCondition(condition_i)
player:addCondition(condition_i)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You became invisible.")
elseif r == 4 then
Creature(cid):addHealth(getCreatureMaxHealth(cid) - getCreatureHealth(cid))
Creature(cid):addMana(Creature(cid):getMaxMana() - Creature(cid):getMana())
player:addHealth(player:getMaxHealth() - player:getHealth())
player:addMana(player:getMaxMana() - player:getMana())
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your vitality has been restored.")
end
player:say("Smack.", TALKTYPE_MONSTER_SAY)
Expand Down