sucibob
Member
- Joined
- Mar 28, 2017
- Messages
- 128
- Reaction score
- 13
I'm using the @Lessaire skill stages depending o vocation system (TFS 0.X - skill stages depending on vocation (https://otland.net/threads/skill-stages-depending-on-vocation.269757/)) and i would like to make it work with Training Monk skill rates reduction
I would like to when players enter on training monks their rates going to skill stages depending on vocation / 2
i already tried this with no sucess
i've change the codes to:
skillstagesadvanced.lua
skillstageslogin.lua
skillstagesconfig.lua
so in the training monks movemment i did:
But there are 2 problems
problem A) skills are not chaging right
problem B) skills get back to the normal (like player was out of training monks) when player advance skill
did u know how to fix or a better way to do this?
tests logs:
I would like to when players enter on training monks their rates going to skill stages depending on vocation / 2
i already tried this with no sucess
i've change the codes to:
skillstagesadvanced.lua
Code:
dofile(getDataDir() .. "creaturescripts/scripts/stagesconfig.lua")
function onAdvance(cid, skill, oldLevel, newLevel)
local function doAdvance(class)
local classStages = CUSTOM_RATE_STAGES[class]
local skillRate = 1
local oldRates = getPlayerRates(cid)
-- gotta check cuz some are empty in the defaults like fishing
if(classStages[skill] ~= nil) then
for i, skillStage in pairs(classStages[skill]) do
if(newLevel >= skillStage[1]) then
skillRate = skillStage[2]
else
break
end
end
doPlayerSetRate(cid, skill, skillRate)
if(config.infoOnAdvance and skillRate ~= oldRates[skill]) then
local configRate = 1
if(skill >= 0 and skill <= 6) then
configRate = SERVER_RATE_SR
else
configRate = SERVER_RATE_ML
end
if(config.infoOnLogin) then
local message = string.format("%s rate changed from %sx to %sx. %s",
SKILL_NAMES[skill], oldRates[skill] * configRate, skillRate * configRate, getPlayerSkillRatesText(cid))
doPlayerSendTextMessage(cid, config.msgColor, message)
getPlayerSkillRatesText(cid)
end
end
end
end
doAdvance(getClass(cid))
return true
end
skillstageslogin.lua
Code:
dofile(getDataDir() .. "creaturescripts/scripts/stagesconfig.lua")
function onLogin(cid)
local function doRatings(class)
local classStages = CUSTOM_RATE_STAGES[class]
--[[
first for loop cycles through skills
ie: SKILL_FIST - SKILL__MAGLEVEL
second loop cycles through the line
ie: {{ 0, 5 },{ 10, 4 },{ 15, 3 },{ 20, 2 },{ 25, 1 },{ 30, 0.5 }}
]]
for skill, stages in pairs(classStages) do
--[[
first loop this
skill: "SKILL_FIST"
stages: {{ 0, 0.0 }}
]]
local skillLevel = 0
if(skill >= 0 and skill <= 6) then
skillLevel = getPlayerSkillLevel(cid, skill)
else
-- if out of range, presume magic
skillLevel = getPlayerMagLevel(cid, true)
end
-- {{0,1},{3,2},{7,4}} -> on 3rd round -> i=3; skillRateInfo = {7,4}
local skillRate = 1
for i, skillStage in pairs(stages) do
if(skillLevel >= skillStage[1]) then
skillRate = skillStage[2]
else
break
end
end
doPlayerSetRate(cid, skill, skillRate)
end
end
doRatings(getClass(cid))
if(config.infoOnLogin) then
doPlayerSendTextMessage(cid, config.msgColor, getPlayerSkillRatesText(cid))
end
registerCreatureEvent(cid, "SkillStagesAdvance")
return true
end
skillstagesconfig.lua
Code:
config = {
infoOnAdvance = true, -- send player message about skill rate change
infoOnLogin = true, -- send player message about skill rates when he login
msgColor = MESSAGE_STATUS_CONSOLE_ORANGE
}
SERVER_RATE_SR = getConfigValue('rateSkill')
SERVER_RATE_ML = getConfigValue('rateMagic')
CUSTOM_RATE_STAGES = {
-- Skill Stages Mage --
MAGE = {
[SKILL_FIST] = {{ 0, 0.0 }},
[SKILL_CLUB] = {{ 0, 0.5 }},
[SKILL_SWORD] = {{ 0, 0.5 }},
[SKILL_AXE] = {{ 0, 0.5 }},
[SKILL_DISTANCE] = {{ 0, 0.5 }},
[SKILL_SHIELD] = {{ 0, 3.0 },{ 15, 2.0 },{ 25, 1.0 }},
[SKILL__MAGLEVEL] = {{ 0, 3.0 },{ 20, 2.0 },{ 30, 1.5 },{ 40, 1}, { 50, 0.5 }},
},
-- Skill Stages Paladin --
RANGER = {
[SKILL_FIST] = {{ 0, 0.0 }},
[SKILL_CLUB] = {{ 0, 0.5 }},
[SKILL_SWORD] = {{ 0, 0.5 }},
[SKILL_AXE] = {{ 0, 0.5 }},
[SKILL_DISTANCE] = {{ 0, 3.0 },{ 30, 2.0 },{ 40, 1.0 },{ 70, 0.5 }},
[SKILL_SHIELD] = {{ 0, 3.0 },{ 40, 1.0 },{ 60, 0.5 }},
[SKILL__MAGLEVEL] = {{ 0, 3.0 },{ 4, 2.0 },{ 9, 1.0 },{ 15, 0.5 }},
},
-- Skill Stages Knight --
WARRIOR = {
[SKILL_FIST] = {{ 0, 0.0 }},
[SKILL_CLUB] = {{ 0, 300.0 },{ 30, 200.0 },{ 40, 100.0 },{ 70, 0.5 }},
[SKILL_SWORD] = {{ 0, 3.0 },{ 30, 2.0 },{ 40, 1.0 },{ 70, 0.5 }},
[SKILL_AXE] = {{ 0, 3.0 },{ 30, 2.0 },{ 40, 1.0 },{ 70, 0.5 }},
[SKILL_DISTANCE] = {{ 0, 0.5 }},
[SKILL_SHIELD] = {{ 0, 3.0 },{ 40, 1.0 },{ 60, 0.5 }},
[SKILL__MAGLEVEL] = {{ 0, 3.0 },{ 4, 2.0 },{ 6, 1.0 },{ 9, 0.5 }},
},
-- Skill Stages Rooker (None) --
ROOK = {
[SKILL_FIST] = {{ 0, 0 }},
[SKILL_CLUB] = {{ 0, 5.0 },{ 15, 3.0 },{ 20, 2.0 },{ 25, 1.0 },{ 30, 0.5 }},
[SKILL_SWORD] = {{ 0, 5.0 },{ 15, 3.0 },{ 20, 2.0 },{ 25, 1.0 },{ 30, 0.5 }},
[SKILL_AXE] = {{ 0, 5.0 },{ 15, 3.0 },{ 20, 2.0 },{ 25, 1.0 },{ 30, 0.5 }},
[SKILL_DISTANCE] = {{ 0, 5.0 },{ 15, 3.0 },{ 20, 2.0 },{ 25, 1.0 },{ 30, 0.5 }},
[SKILL_SHIELD] = {{ 0, 5.0 },{ 15, 3.0 },{ 20, 2.0 },{ 25, 1.0 },{ 30, 0.5 }},
[SKILL__MAGLEVEL] = {{ 0, 0 }},
},
--SKILL_FISHING = {{0,5},{60,4},{80,3},{100,2},{110,1}}
}
function getPlayerSkillRatesText(cid)
local skillInfo = getPlayerRates(cid)
local divideBy = 1
if getCreatureStorage(cid, 17000 ) >= 1 then
divideBy = 2
end
local packed = {
(skillInfo[SKILL__MAGLEVEL] * SERVER_RATE_ML) / divideBy,
(skillInfo[SKILL_FIST] * SERVER_RATE_SR) / divideBy,
(skillInfo[SKILL_CLUB] * SERVER_RATE_SR) / divideBy,
(skillInfo[SKILL_SWORD] * SERVER_RATE_SR) / divideBy,
(skillInfo[SKILL_AXE] * SERVER_RATE_SR) / divideBy,
(skillInfo[SKILL_DISTANCE] * SERVER_RATE_SR) / divideBy,
(skillInfo[SKILL_SHIELD] * SERVER_RATE_SR) / divideBy,
(skillInfo[SKILL_FISHING] * SERVER_RATE_SR) / divideBy
}
local message = string.format("YOUR RATES: [ Magic Level: %sx || Fist: %sx | Club: %sx | Sword: %sx | Axe: %sx | Distance: %s | Shielding: %sx | Fishing: %sx ]", unpack(packed))
return message
end
so in the training monks movemment i did:
Code:
dofile(getDataDir() .. "creaturescripts/scripts/stagesconfig.lua")
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
setPlayerStorageValue(cid, 17000, 1)
local function doRatings(class)
local classStages = CUSTOM_RATE_STAGES[class]
for skill, stages in pairs(classStages) do
local skillLevel = 0
if(skill >= 0 and skill <= 6) then
skillLevel = getPlayerSkillLevel(cid, skill)
else
skillLevel = getPlayerMagLevel(cid, true)
end
local skillRate = 1
for i, skillStage in pairs(stages) do
if(skillLevel >= skillStage[1]) then
skillRate = skillStage[2]
else
break
end
end
doPlayerSetRate(cid, skill, skillRate/2)
end
end
doRatings(getClass(cid))
if(config.infoOnLogin) then
doPlayerSendTextMessage(cid, config.msgColor, getPlayerSkillRatesText(cid))
end
return true
end
function onStepOut(cid, item, position, fromPosition)
setPlayerStorageValue(cid, 17000, 0)
if(config.infoOnLogin) then
doPlayerSendTextMessage(cid, config.msgColor, getPlayerSkillRatesText(cid))
end
return true
end
But there are 2 problems
problem A) skills are not chaging right
problem B) skills get back to the normal (like player was out of training monks) when player advance skill
did u know how to fix or a better way to do this?
tests logs:
Code:
when i login, shows right:
03:30 YOUR RATES: [ Magic Level: 3x || Fist: 0x | Club: 300x | Sword: 1x | Axe: 1x | Distance: 0.5 | Shielding: 3x | Fishing: 1x ]
when i enter training monks rooms, it shows:
03:32 YOUR RATES: [ Magic Level: 0.75x || Fist: 0x | Club: 75x | Sword: 0.25x | Axe: 0.25x | Distance: 0.125 | Shielding: 0.75x | Fishing: 0.5x ]
clubs = Club: 75x
should be = Club: 150x
and when i leaves training rooms, instead of come back to 300x
it returns
03:33 YOUR RATES: [ Magic Level: 1.5x || Fist: 0x | Club: 150x | Sword: 0.5x | Axe: 0.5x | Distance: 0.25 | Shielding: 1.5x | Fishing: 1x ]
the fucking strange thing is
if i login with:
03:34 YOUR RATES: [ Magic Level: 3x || Fist: 0x | Club: 300x | Sword: 1x | Axe: 1x | Distance: 0.5 | Shielding: 3x | Fishing: 1x ]
i enter on traninig monks rooms it shows:
03:34 YOUR RATES: [ Magic Level: 0.75x || Fist: 0x | Club: 75x | Sword: 0.25x | Axe: 0.25x | Distance: 0.125 | Shielding: 0.75x | Fishing: 0.5x ]
But when i attack a training monk, it shows:
03:35 club fighting rate changed from 150x to 300x. YOUR RATES: [ Magic Level: 0.75x || Fist: 0x | Club: 150x | Sword: 0.25x | Axe: 0.25x | Distance: 0.125 | Shielding: 0.75x | Fishing: 0.5x ]