Skip to content

Commit

Permalink
improvement: hireling foods and wall mirror (#2283)
Browse files Browse the repository at this point in the history
  • Loading branch information
omarcopires authored Feb 21, 2024
1 parent 530595a commit 1182710
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 92 deletions.
87 changes: 0 additions & 87 deletions data-otservbr-global/scripts/actions/other/hireling_food.lua

This file was deleted.

69 changes: 69 additions & 0 deletions data/scripts/actions/items/hireling_foods.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
local hasteCondition = Condition(CONDITION_HASTE)
hasteCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000)
hasteCondition:setParameter(CONDITION_PARAM_SPEED, 80)

local fishingCondition = Condition(CONDITION_ATTRIBUTES)
fishingCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000)
fishingCondition:setParameter(CONDITION_PARAM_SKILL_FISHING, 30)

local magicPointsCondition = Condition(CONDITION_ATTRIBUTES)
magicPointsCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000)
magicPointsCondition:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 3)

local meleeCondition = Condition(CONDITION_ATTRIBUTES)
meleeCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000)
meleeCondition:setParameter(CONDITION_PARAM_SKILL_MELEE, 3)

local shieldCondition = Condition(CONDITION_ATTRIBUTES)
shieldCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000)
shieldCondition:setParameter(CONDITION_PARAM_SKILL_SHIELD, 7)

local distanceCondition = Condition(CONDITION_ATTRIBUTES)
distanceCondition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000)
distanceCondition:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 7)

local gourmetDishes = {
[29408] = { condition = shieldCondition, message = "Chomp." },
[29409] = { condition = distanceCondition, message = "Yummm." },
[29410] = { condition = magicPointsCondition, message = "Munch." },
[29411] = { condition = meleeCondition, message = "Munch." },
[29412] = { condition = hasteCondition, message = "Yummm." },
[29413] = { condition = fishingCondition, message = "Mmmmm." },
[29414] = { healing = true, message = "Munch." },
[29415] = { manaRestore = true, message = "Chomp." },
[29416] = { message = "Blurg." },
}

local hirelingFoods = Action()

function hirelingFoods.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local dish = gourmetDishes[item.itemid]
if not dish then
return true
end

if player:hasExhaustion("hireling-foods-cooldown") then
player:sendCancelMessage("You're still too full to eat any gourmet dishes for a while.")
return true
end

if dish.condition then
player:addCondition(dish.condition)
elseif dish.healing then
player:addHealth(player:getMaxHealth() * 0.3)
elseif dish.manaRestore then
player:addMana(player:getMaxMana() * 0.3)
end

player:say(dish.message, TALKTYPE_MONSTER_SAY)
player:setExhaustion("hireling-foods-cooldown", 10 * 60)

item:remove(1)
return true
end

for index, value in pairs(gourmetDishes) do
hirelingFoods:id(index)
end

hirelingFoods:register()
10 changes: 5 additions & 5 deletions data/scripts/actions/objects/wall_mirror.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ local setting = {
local wallMirror = Action()

function wallMirror.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local hasExhaustion = player:kv():get("delay-wall-mirror") or 0
if hasExhaustion > os.time() then
if player:hasExhaustion("delay-wall-mirror") then
player:say("Don't be so vain about your appearance.", TALKTYPE_MONSTER_SAY)
else
player:kv():set("delay-wall-mirror", os.time() + 20 * 60 * 60)
player:say(setting[math.random(1, #setting)], TALKTYPE_MONSTER_SAY)
return true
end

player:say(setting[math.random(1, #setting)], TALKTYPE_MONSTER_SAY)
player:setExhaustion("delay-wall-mirror", 20 * 60 * 60)
return true
end

Expand Down

0 comments on commit 1182710

Please sign in to comment.