Peonso
Godly Member
- Joined
- Jan 14, 2008
- Messages
- 1,752
- Solutions
- 30
- Reaction score
- 1,542
That's it:
Code:
-- <event type="login" name="SkillStagesLogin" event="script" value="skills_stages_login.lua"/>
-- skills_stages_login.lua
function onLogin(cid)
local stagesVocation = getPlayerVocation(cid)
if stagesVocation > 4 then
stagesVocation = stagesVocation - 4
end
local targetVocation = skillStagesConfig[stagesVocation]
if targetVocation then
for skill, targetSkillStage in pairs(targetVocation) do
if skill == SKILL_MAGLEVEL then
nowSkill = getPlayerMagLevel(cid, true)
else
nowSkill = getPlayerSkill(cid, skill)
end
local skillRate = 1
for level, rate in pairs(targetSkillStage) do
if nowSkill >= level[1] and nowSkill <= level[2] then
skillRate = rate
end
end
doPlayerSetRate(cid, skill, skillRate)
end
end
registerCreatureEvent(cid, "SkillStagesAdvance")
return true
end
-- <event type="advance" name="SkillStagesAdvance" event="script" value="skills_stages_advance.lua"/>
-- skills_stages_advance.lua
function onAdvance(cid, skill, oldLevel, newLevel)
local stagesVocation = getPlayerVocation(cid)
if stagesVocation > 4 then
stagesVocation = stagesVocation - 4
end
local targetVocation = skillStagesConfig[stagesVocation]
if targetVocation then
local targetSkillStage = targetVocation[skill]
if targetSkillStage then
local skillRate = 1
for level, rate in pairs(targetSkillStage) do
if newLevel >= level[1] and newLevel <= level[2] then
skillRate = rate
end
end
doPlayerSetRate(cid, skill, skillRate)
end
end
return true
end
-- add to global.lua
-- dofile(getDataDir() .. "lib/skills_stages.lua")
-- skills_stages.lua
skillStagesConfig = {
-- base vocationId
[0] = {
-- skillId
[SKILL_FIST] = {
-- [{skillLevel}] = skillRate
[{0, 14}] = 12,
[{15, 21}] = 8
},
[SKILL_CLUB] = {
[{0, 14}] = 12,
[{15, 21}] = 8
},
[SKILL_SWORD] = {
[{0, 14}] = 12,
[{15, 21}] = 8
},
[SKILL_AXE] = {
[{0, 14}] = 12,
[{15, 21}] = 8
},
[SKILL_DISTANCE] = {
[{0, 14}] = 12,
[{15, 21}] = 8
},
[SKILL_SHIELD] = {
[{0, 19}] = 12,
[{20, 26}] = 8
},
[SKILL_FISHING] = {
[{0, 19}] = 12,
[{20, 29}] = 8
}
},
[1] = {
-- skillId
[SKILL_FIST] = {
-- [{skillLevel}] = skillRate
[{0, 14}] = 12,
[{15, 21}] = 8
},
[SKILL_CLUB] = {
[{0, 14}] = 12,
[{15, 21}] = 8
},
[SKILL_SWORD] = {
[{0, 14}] = 12,
[{15, 21}] = 8
},
[SKILL_AXE] = {
[{0, 14}] = 12,
[{15, 21}] = 8
},
[SKILL_DISTANCE] = {
[{0, 14}] = 12,
[{15, 21}] = 8
},
[SKILL_SHIELD] = {
[{0, 19}] = 12,
[{20, 26}] = 8
},
[SKILL_FISHING] = {
[{0, 19}] = 12,
[{20, 29}] = 8
},
[SKILL_MAGLEVEL] = {
[{0, 30}] = 10,
[{31, 35}] = 8,
[{36, 45}] = 6,
[{46, 55}] = 4,
[{56, 65}] = 2,
[{66, 99}] = 1
}
},
[2] = {
-- skillId
[SKILL_FIST] = {
-- [{skillLevel}] = skillRate
[{0, 14}] = 12,
[{15, 21}] = 8
},
[SKILL_CLUB] = {
[{0, 14}] = 12,
[{15, 21}] = 8
},
[SKILL_SWORD] = {
[{0, 14}] = 12,
[{15, 21}] = 8
},
[SKILL_AXE] = {
[{0, 14}] = 12,
[{15, 21}] = 8
},
[SKILL_DISTANCE] = {
[{0, 14}] = 12,
[{15, 21}] = 8
},
[SKILL_SHIELD] = {
[{0, 19}] = 12,
[{20, 26}] = 8
},
[SKILL_FISHING] = {
[{0, 19}] = 12,
[{20, 29}] = 8
},
[SKILL_MAGLEVEL] = {
[{0, 30}] = 10,
[{31, 35}] = 8,
[{36, 45}] = 6,
[{46, 55}] = 4,
[{56, 65}] = 2,
[{66, 99}] = 1
}
},
[3] = {
-- skillId
[SKILL_FIST] = {
-- [{skillLevel}] = skillRate
[{0, 30}] = 12,
[{31, 40}] = 8
},
[SKILL_CLUB] = {
[{0, 30}] = 12,
[{31, 40}] = 8
},
[SKILL_SWORD] = {
[{0, 30}] = 12,
[{31, 40}] = 8
},
[SKILL_AXE] = {
[{0, 30}] = 12,
[{31, 40}] = 8
},
[SKILL_DISTANCE] = {
[{0, 40}] = 18,
[{41, 50}] = 14,
[{51, 60}] = 12,
[{61, 75}] = 10,
[{76, 85}] = 8,
[{86, 90}] = 6,
[{91, 95}] = 4,
[{96, 150}] = 1
},
[SKILL_SHIELD] = {
[{0, 40}] = 18,
[{41, 50}] = 14,
[{51, 60}] = 12,
[{61, 75}] = 10,
[{76, 85}] = 8,
[{86, 90}] = 6,
[{91, 95}] = 4,
[{96, 150}] = 1
},
[SKILL_FISHING] = {
[{0, 19}] = 12,
[{20, 29}] = 8
},
[SKILL_MAGLEVEL] = {
[{0, 8}] = 10,
[{9, 13}] = 7,
[{14, 16}] = 4,
[{17, 18}] = 2,
[{19, 90}] = 1
}
},
[4] = {
-- skillId
[SKILL_FIST] = {
-- [{skillLevel}] = skillRate
[{0, 40}] = 18,
[{41, 50}] = 14,
[{51, 60}] = 12,
[{61, 75}] = 10,
[{76, 85}] = 8,
[{86, 90}] = 6,
[{91, 95}] = 4,
[{96, 150}] = 1
},
[SKILL_CLUB] = {
[{0, 40}] = 18,
[{41, 50}] = 14,
[{51, 60}] = 12,
[{61, 75}] = 10,
[{76, 85}] = 8,
[{86, 90}] = 6,
[{91, 95}] = 4,
[{96, 150}] = 1
},
[SKILL_SWORD] = {
[{0, 40}] = 18,
[{41, 50}] = 14,
[{51, 60}] = 12,
[{61, 75}] = 10,
[{76, 85}] = 8,
[{86, 90}] = 6,
[{91, 95}] = 4,
[{96, 150}] = 1
},
[SKILL_AXE] = {
[{0, 40}] = 18,
[{41, 50}] = 14,
[{51, 60}] = 12,
[{61, 75}] = 10,
[{76, 85}] = 8,
[{86, 90}] = 6,
[{91, 95}] = 4,
[{96, 150}] = 1
},
[SKILL_DISTANCE] = {
[{0, 30}] = 12,
[{31, 40}] = 8
},
[SKILL_SHIELD] = {
[{0, 40}] = 18,
[{41, 50}] = 14,
[{51, 60}] = 12,
[{61, 75}] = 10,
[{76, 85}] = 8,
[{86, 90}] = 6,
[{91, 95}] = 4,
[{96, 150}] = 1
},
[SKILL_FISHING] = {
[{0, 19}] = 12,
[{20, 29}] = 8
},
[SKILL_MAGLEVEL] = {
[{0, 3}] = 10,
[{4, 4}] = 7,
[{5, 6}] = 4,
[{7, 8}] = 2,
[{9, 90}] = 1
}
}
}