• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Action [TFS 1.x] Special foods

Nottinghster

Tibia World RPG Developer
Joined
Oct 24, 2007
Messages
1,565
Solutions
6
Reaction score
430
Location
Brazil - Rio de Janeiro
GitHub
Nottinghster
Well, since the original repository of TFS didn't have the special foods until today, I decided to convert them to TFS 1.x.

They are from OTServ_SVN 0.6.4 (opentibia/server (https://github.com/opentibia/server/tree/legacy/src/data/actions/scripts/foods))

I know it can be shortened to a single file, but I was too lazy for it :p

In folder actions > lib > actions.lua, paste this
Lua:
SPECIAL_FOODS = {
    [9992] = {"Gulp."}, [9993] = {"Chomp."}, [9994] = {"Chomp."}, [9995] = {"Chomp."}, [9997] = {"Yum."},
    [9998] = {"Munch."}, [9999] = {"Chomp."}, [10000] = {"Mmmm."}, [10001] = {"Smack."}
}

In actions.xml, paste this:
XML:
    <!-- Special Foods -->
    <action itemid="9992" script="special_foods/rotworm_stew.lua"/>
    <action itemid="9993" script="special_foods/hydra_tongue_salad.lua"/>
    <action itemid="9994" script="special_foods/roasted_dragon_wings.lua"/>
    <action itemid="9995" script="special_foods/fried_tropical_terrorbird.lua"/>
    <action itemid="9997" script="special_foods/veggie_casserole.lua"/>
    <action itemid="9998" script="special_foods/filled_jalapeno_peppers.lua"/>
    <action itemid="9999" script="special_foods/blessed_steak.lua"/>
    <action itemid="10000" script="special_foods/carrot_cake.lua"/>
    <action itemid="10001" script="special_foods/northern_fishburger.lua"/>

Now in folder actions > scripts, create a folder called special_foods and then, create those files inside it:

blessed_steak.lua
Lua:
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, getConfigInfo('timeBetweenActions'))

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if SPECIAL_FOODS[item.itemid] == nil then
        return false
    end

    local sound = SPECIAL_FOODS[item.itemid][1]

    local playerMaxMana = player:getMaxMana()
    local playerMana = player:getMana()

    if not (player:addCondition(exhaust)) then
        return false
    end

    player:addManaSpent(playerMaxMana - playerMana)
    item:remove(1)
    player:say(sound, TALKTYPE_MONSTER_SAY)
    return true
end

carrot_cake.lua
Lua:
local condition = Condition(CONDITION_ATTRIBUTES)
condition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000)
condition:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 10)

local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, getConfigInfo('timeBetweenActions'))

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if SPECIAL_FOODS[item.itemid] == nil then
        return false
    end

    local sound = SPECIAL_FOODS[item.itemid][1]

    if not (player:addCondition(condition) or player:addCondition(exhaust)) then
        return false
    end

    item:remove(1)
    player:say(sound, TALKTYPE_MONSTER_SAY)
    return true
end

filled_jalapeno_peppers.lua
Lua:
local condition = Condition(CONDITION_HASTE)
condition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000)
condition:setParameter(CONDITION_PARAM_SPEED, 40)

local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, getConfigInfo('timeBetweenActions'))

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if SPECIAL_FOODS[item.itemid] == nil then
        return false
    end

    local sound = SPECIAL_FOODS[item.itemid][1]

    if not (player:addCondition(condition) or player:addCondition(exhaust)) then
        return false
    end

    item:remove(1)
    player:say(sound, TALKTYPE_MONSTER_SAY)
    return true
end

hydra_tongue_salad.lua
Lua:
local conditions = {CONDITION_POISON, CONDITION_FIRE, CONDITION_ENERGY, CONDITION_PARALYZE, CONDITION_DRUNK, CONDITION_DROWN, CONDITION_FREEZING, CONDITION_DAZZLED, CONDITION_CURSED}
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, getConfigInfo('timeBetweenActions'))

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if SPECIAL_FOODS[item.itemid] == nil then
        return false
    end

    local sound = SPECIAL_FOODS[item.itemid][1]

    if not (player:addCondition(exhaust)) then
        return false
    end

    for i, v in ipairs(conditions) do
        if (player:hasCondition(v) ) then
            player:removeCondition(v)
        end
    end

    item:remove(1)
    player:say(sound, TALKTYPE_MONSTER_SAY)
    return true
end

fried_tropical_terrorbird.lua
Lua:
local condition = Condition(CONDITION_ATTRIBUTES)
condition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000)
condition:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 5)

local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, getConfigInfo('timeBetweenActions'))

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if SPECIAL_FOODS[item.itemid] == nil then
        return false
    end

    local sound = SPECIAL_FOODS[item.itemid][1]

    if not (player:addCondition(condition) or player:addCondition(exhaust)) then
        return false
    end

    item:remove(1)
    player:say(sound, TALKTYPE_MONSTER_SAY)
    return true
end

northem_fishburguer.lua
Lua:
local condition = Condition(CONDITION_ATTRIBUTES)
condition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000)
condition:setParameter(CONDITION_PARAM_SKILL_FISHING, 50)

local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, getConfigInfo('timeBetweenActions'))

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if SPECIAL_FOODS[item.itemid] == nil then
        return false
    end

    local sound = SPECIAL_FOODS[item.itemid][1]

    if not (player:addCondition(condition) or player:addCondition(exhaust)) then
        return false
    end

    item:remove(1)
    player:say(sound, TALKTYPE_MONSTER_SAY)
    return true
end

roasted_dragon_wings.lua
Lua:
local condition = Condition(CONDITION_ATTRIBUTES)
condition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000)
condition:setParameter(CONDITION_PARAM_SKILL_SHIELD, 10)

local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, getConfigInfo('timeBetweenActions'))

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if SPECIAL_FOODS[item.itemid] == nil then
        return false
    end

    local sound = SPECIAL_FOODS[item.itemid][1]

    if not (player:addCondition(condition) or player:addCondition(exhaust)) then
        return false
    end

    item:remove(1)
    player:say(sound, TALKTYPE_MONSTER_SAY)
    return true
end

rotworm_stew.lua
Lua:
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, getConfigInfo('timeBetweenActions'))

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if SPECIAL_FOODS[item.itemid] == nil then
        return false
    end

    local sound = SPECIAL_FOODS[item.itemid][1]

    local playerMaxHealth = player:getMaxHealth()
    local playerHealth = player:getHealth()

    if not (player:addCondition(exhaust)) then
        return false
    end

    player:addHealth(playerMaxHealth - playerHealth)
    item:remove(1)
    player:say(sound, TALKTYPE_MONSTER_SAY)
    return true
end

veggie_casserole.lua
Lua:
local condition = Condition(CONDITION_ATTRIBUTES)
condition:setParameter(CONDITION_PARAM_TICKS, 60 * 60 * 1000)
condition:setParameter(CONDITION_PARAM_SKILL_MELEEPERCENT, 150)

local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, getConfigInfo('timeBetweenActions'))

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if SPECIAL_FOODS[item.itemid] == nil then
        return false
    end

    local sound = SPECIAL_FOODS[item.itemid][1]

    if not (player:addCondition(condition) or player:addCondition(exhaust)) then
        return false
    end

    item:remove(1)
    player:say(sound, TALKTYPE_MONSTER_SAY)
    return true
end

Hope you all enjoy it![/B][/B]
 

Attachments

Last edited:
This works for me, only thing I changed is this part:
Lua:
SPECIAL_FOODS = {
    [9992] = {"Gulp."}, [9993] = {"Chomp."}, [9994] = {"Chomp."}, [9995] = {"Chomp."}, [9997] = {"Yum."},
    [9998] = {"Munch."}, [9999] = {"Chomp."}, [10000] = {"Mmmm."}, [10001] = {"Smack."}
}
Since I use 1.3 I had to put it in global.lua
 
can you mix them in just one script? I think it would be better to use only one file for food like its how it is for doors and other stuff :p
 
Lua:
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(condition:setParameter(CONDITION_PARAM_TICKS, 60 * 1000)

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if SPECIAL_FOODS[item.itemid] == nil then
        return false
    end

    local sound = SPECIAL_FOODS[item.itemid][1]

    local playerMaxHealth = player:getMaxHealth()
    local playerHealth = player:getHealth()

    if not (player:addCondition(exhaust)) then
        return false
    end

    player:addHealth(playerMaxHealth - playerHealth)
    item:remove(1)
    player:say(sound, TALKTYPE_MONSTER_SAY)
    return true
end

dont work in this script
tfs 1.3
 
Last edited:
Back
Top