try thisjust for formula with vocation like knight have one formula and sorcerer have another one formula
local config = {
-- [{min_level, max_level}] = regen per second
[{100, 250}] = {
-- [vocation id] = {formula}
[1] = {lvl = 1, mlvl = 0.7},
[2] = {lvl = 1, mlvl = 0.5},
[3] = {lvl = 1, distance = 0.7},
[4] = {lvl = 1, sword = 0.3, axe = 0.3, club = 0.3}
},
-- last max_level must be math.huge
[{250, math.huge}] = {
-- [vocation id] = {formula}
[1] = {lvl = 1, mlvl = 0.7},
[2] = {lvl = 1, mlvl = 0.5},
[3] = {lvl = 1, distance = 0.7},
[4] = {lvl = 1, sword = 0.3, axe = 0.3, club = 0.3}
},
}
function onThink(interval...
add this in data/lib/core/player.luawork, thanks one question how to check if player food > 0 ?
function Player.getFood(self)
local condition = self:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
if condition then
return condition:getTicks()
end
return 0
end
if player:getFood() > 0 then
-- do something
end
thanks!! one more question how to add there also magiclevel?add this in data/lib/core/player.lua
to check if player food is > 0:Lua:function Player.getFood(self) local condition = self:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT) if condition then return condition:getTicks() end return 0 end
Lua:if player:getFood() > 0 then -- do something end
for regeneration?thanks!! one more question how to add there also magiclevel?
like formule = (1 * level) + (3 * maglevel)
just for formula with vocation like knight have one formula and sorcerer have another one formulafor regeneration?
i thought you wanted it to be a flat rate
do you want it to be the config value + formula or just the formula?
try thisjust for formula with vocation like knight have one formula and sorcerer have another one formula
local config = {
-- [{min_level, max_level}] = regen per second
[{100, 250}] = {
-- [vocation id] = {formula}
[1] = {lvl = 1, mlvl = 0.7},
[2] = {lvl = 1, mlvl = 0.5},
[3] = {lvl = 1, distance = 0.7},
[4] = {lvl = 1, sword = 0.3, axe = 0.3, club = 0.3}
},
-- last max_level must be math.huge
[{250, math.huge}] = {
-- [vocation id] = {formula}
[1] = {lvl = 1, mlvl = 0.7},
[2] = {lvl = 1, mlvl = 0.5},
[3] = {lvl = 1, distance = 0.7},
[4] = {lvl = 1, sword = 0.3, axe = 0.3, club = 0.3}
},
}
function onThink(interval, lastExecution)
for _, player in pairs(Game.getPlayers()) do
for range, formulas in pairs(config) do
local level = player:getLevel()
-- level matches between range found from config
if level >= range[1] and level < range[2] then
local formula = formulas[player:getVocationId()]
if formula then
local value = player:getLevel() * formula.lvl
if formula.mlvl then
value = value + (player:getMagicLevel() * formula.mlvl)
end
if formula.distance then
value = value + (player:getSkillLevel(SKILL_DISTANCE) * formula.distance)
end
if formula.sword then
value = value + (player:getSkillLevel(SKILL_SWORD) * formula.sword)
end
if formula.axe then
value = value + (player:getSkillLevel(SKILL_AXE) * formula.axe)
end
if formula.club then
value = value + (player:getSkillLevel(SKILL_CLUB) * formula.club)
end
end
break
end
end
end
return true
end
thanks very muchtry this
Lua:local config = { -- [{min_level, max_level}] = regen per second [{100, 250}] = { -- [vocation id] = {formula} [1] = {lvl = 1, mlvl = 0.7}, [2] = {lvl = 1, mlvl = 0.5}, [3] = {lvl = 1, distance = 0.7}, [4] = {lvl = 1, sword = 0.3, axe = 0.3, club = 0.3} }, -- last max_level must be math.huge [{250, math.huge}] = { -- [vocation id] = {formula} [1] = {lvl = 1, mlvl = 0.7}, [2] = {lvl = 1, mlvl = 0.5}, [3] = {lvl = 1, distance = 0.7}, [4] = {lvl = 1, sword = 0.3, axe = 0.3, club = 0.3} }, } function onThink(interval, lastExecution) for _, player in pairs(Game.getPlayers()) do for range, formulas in pairs(config) do local level = player:getLevel() -- level matches between range found from config if level >= range[1] and level < range[2] then local formula = formulas[player:getVocationId()] if formula then local value = player:getLevel() * formula.lvl if formula.mlvl then value = value + (player:getMagicLevel() * formula.mlvl) end if formula.distance then value = value + (player:getSkillLevel(SKILL_DISTANCE) * formula.distance) end if formula.sword then value = value + (player:getSkillLevel(SKILL_SWORD) * formula.sword) end if formula.axe then value = value + (player:getSkillLevel(SKILL_AXE) * formula.axe) end if formula.club then value = value + (player:getSkillLevel(SKILL_CLUB) * formula.club) end end break end end end return true end
Strange.. It's still not working for me. =/my bad, edited the script in my previous post and it works now (i tested it)
you added it in globalevents.xml?Strange.. It's still not working for me. =/
Oh silly me, I only recopied the script, not the xml for globalevents.xml. Thanks! its working .you added it in globalevents.xml?
using tfs 1.2 or 1.3?
logic isn't tfs-based, it's lua-basedOh silly me, I only recopied the script, not the xml for globalevents.xml. Thanks! its working .
Do you know where can I find a logic script guide by the way? Someone showed me this one: otland/forgottenserver
But it doesn't have everything. It's not fully updated I think.
otland/forgottenserverThanks. I understand the logic a lot more now and some lua regular.
I still would like to know the full TFS part though because I don't see "game." instruction anywhere and that seems to be what to use for a lot of code. and the player:addHealth otland/forgottenserver doesn't have all the commands apparently.. -.- where's :addHealth there? I had to learn it from you lol. I want the full list. Should I request a full list on a separate request thread?
try this
Lua:local config = { -- [{min_level, max_level}] = regen per second [{100, 250}] = { -- [vocation id] = {formula} [1] = {lvl = 1, mlvl = 0.7}, [2] = {lvl = 1, mlvl = 0.5}, [3] = {lvl = 1, distance = 0.7}, [4] = {lvl = 1, sword = 0.3, axe = 0.3, club = 0.3} }, -- last max_level must be math.huge [{250, math.huge}] = { -- [vocation id] = {formula} [1] = {lvl = 1, mlvl = 0.7}, [2] = {lvl = 1, mlvl = 0.5}, [3] = {lvl = 1, distance = 0.7}, [4] = {lvl = 1, sword = 0.3, axe = 0.3, club = 0.3} }, } function onThink(interval, lastExecution) for _, player in pairs(Game.getPlayers()) do for range, formulas in pairs(config) do local level = player:getLevel() -- level matches between range found from config if level >= range[1] and level < range[2] then local formula = formulas[player:getVocationId()] if formula then local value = player:getLevel() * formula.lvl if formula.mlvl then value = value + (player:getMagicLevel() * formula.mlvl) end if formula.distance then value = value + (player:getSkillLevel(SKILL_DISTANCE) * formula.distance) end if formula.sword then value = value + (player:getSkillLevel(SKILL_SWORD) * formula.sword) end if formula.axe then value = value + (player:getSkillLevel(SKILL_AXE) * formula.axe) end if formula.club then value = value + (player:getSkillLevel(SKILL_CLUB) * formula.club) end end break end end end return true end
local config = {
-- [{min_level, max_level}] = regen per second
[{1, 250}] = {
-- [vocation id] = {formula}
[1] = {lvl = 1, mlvl = 0.7},
[2] = {lvl = 1, mlvl = 0.5},
[3] = {lvl = 1, distance = 0.7},
[4] = {lvl = 1, sword = 0.3, axe = 0.3, club = 0.3}
},
-- last max_level must be math.huge
[{250, math.huge}] = {
-- [vocation id] = {formula}
[1] = {lvl = 1, mlvl = 0.7},
[2] = {lvl = 1, mlvl = 0.5},
[3] = {lvl = 1, distance = 0.7},
[4] = {lvl = 1, sword = 0.3, axe = 0.3, club = 0.3}
},
}
function onThink(interval, lastExecution)
for _, player in pairs(Game.getPlayers()) do
for range, formulas in pairs(config) do
local level = player:getLevel()
-- level matches between range found from config
if level >= range[1] and level < range[2] then
local formula = formulas[player:getVocationId()]
if formula then
local value = player:getLevel() * formula.lvl
if formula.mlvl then
value = value + (player:getMagicLevel() * formula.mlvl)
end
if formula.distance then
value = value + (player:getSkillLevel(SKILL_DISTANCE) * formula.distance)
end
if formula.sword then
value = value + (player:getSkillLevel(SKILL_SWORD) * formula.sword)
end
if formula.axe then
value = value + (player:getSkillLevel(SKILL_AXE) * formula.axe)
end
if formula.club then
value = value + (player:getSkillLevel(SKILL_CLUB) * formula.club)
end
end
break
end
end
end
return true
end
local config = {
-- [{min_level, max_level}] = regen per second
[{1, 250}] = {
-- [vocation id] = {formula}
[1] = {min = 5, max = 10, lvlmul = 1, mlvlmul = 17},
[2] = {min = 5, max = 10, lvlmul = 1, mlvlmul = 17},
[3] = {min = 3, max = 7, lvlmul = 1, mlvlmul = 5},
[4] = {min = 1, max = 5, lvlmul = 1, mlvlmul = 1}
},
-- last max_level must be math.huge
[{250, math.huge}] = {
-- [vocation id] = {formula}
[1] = {lvl = 1, mlvl = 0.7},
[2] = {lvl = 1, mlvl = 0.5},
[3] = {lvl = 1, distance = 0.7},
[4] = {lvl = 1, sword = 0.3, axe = 0.3, club = 0.3}
},
}
function onThink(interval, lastExecution)
for _, player in pairs(Game.getPlayers()) do
for range, formulas in pairs(config) do
local level = player:getLevel()
-- level matches between range found from config
if level >= range[1] and level < range[2] then
local formula = formulas[player:getVocationId()]
if formula then
local value = player:getLevel() * formula.lvl
if formula.mlvl then
value = value + (player:getMagicLevel() * formula.mlvl)
end
if formula.distance then
value = value + (player:getSkillLevel(SKILL_DISTANCE) * formula.distance)
end
if formula.sword then
value = value + (player:getSkillLevel(SKILL_SWORD) * formula.sword)
end
if formula.axe then
value = value + (player:getSkillLevel(SKILL_AXE) * formula.axe)
end
if formula.club then
value = value + (player:getSkillLevel(SKILL_CLUB) * formula.club)
end
end
break
end
end
end
return true
end
add_min = voc.min +(voc.lvmul*player:level)+(voc.mlvlmul* player:maglevel)
add_max = voc.max +(voc.lvmul*player:level)+(voc.mlvlmul*player:maglevel)
add = math.random(add_min,add_max)