• 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!

TFS 0.X how to define X many skills/lvls loss when player death

zabuzo

Well-Known Member
Joined
Jun 10, 2016
Messages
238
Reaction score
54
how to make this rulles:
Code:
local totalblessreduction = 0.0
local eachblessreduction = 0.3 -- 5 blesses * eachblessreduction = 1.5
for i = 1, 5 do
    if(getPlayerBlessing(cid, bless[i])) then
        totalblessreduction += eachblessreduction
    end
end



if(skills >= 1 && skills <= 40) skillslose = 0.5
elseif(skills >= 41 && skills <= 60) skillslose = 1
elseif(skills >= 61 && skills <= 80) skillslose = 1.5
elseif(skills >= 81 && skills <= 90) skillslose = 2.0
elseif(skills >= 91 && skills <= 100) skillslose = 2.5
elseif(skills >= 101) skillslose = 3.0
elseif(skull == SKULL_RED) skillslose *= 1.5
elseif(skull == SKULL_BLACK) skillslose *= 3.0
skillslose -= totalblessreduction




if(ml >= 1 && ml <= 20) mllose = 0.5
elseif(ml >= 21 && ml <= 30) mllose = 1.0
elseif(ml >= 31 && ml <= 40) mllose = 1.5
elseif(ml >= 41 && ml <= 60) mllose = 2.0
elseif(ml >= 61 && ml <= 70) mllose = 2.5
elseif(ml >= 71) mllose = 3.0
elseif(skull == SKULL_RED) mllose *= 1.5
elseif(skull == SKULL_BLACK) mllose *= 3.0
mllose -= totalblessreduction
to define a X lvls/skills lose in Y skills like on this block /\


it can be done on LUA or it needs or is better with sources changes?

the only thing about skill loss and ml loss i found on sources are: (Fir3element/3777 (https://github.com/Fir3element/3777/blob/aef29d0ac94140c5d095cb1f55a34035e42746b3/src/player.cpp#L2321) AND Fir3element/3777 (https://github.com/Fir3element/3777/blob/aef29d0ac94140c5d095cb1f55a34035e42746b3/src/player.cpp#L2297))
 
man, maybe lessloss="" on data/XML/vocations.xml??

No :/

---

i tried to put it to run, but not work :(


i tried to die with a mage
lvl 24, ml28, skills 0

when i die no errors was printed on console, but player become
lvl 1
ml 0


full script now:
Code:
function GetLevelLoss(playerLvl)
    local levelLoss = 0.0
    -- get lvl lose
    if(playerLvl >= 1 and playerLvl <= 10) then levelLoss = 0.10
    elseif(playerLvl >= 11 and playerLvl <= 20) then levelLoss = 1
    elseif(playerLvl >= 21 and playerLvl <= 50) then levelLoss = 2
    elseif(playerLvl >= 51 and playerLvl <= 100) then levelLoss = 3
    elseif(playerLvl >= 101) then
        levelLoss = 3.0 + ((playerLvl - 100) / 50) -- each 50 lvls + 1 (150=4, 200=5, 250=6...)
    end
    -- skull incrise SKILLS loss
    if(skull == SKULL_RED) then levelLoss = levelLoss * 1.5
    elseif(skull == SKULL_BLACK) then levelLoss = levelLoss * 3.0
    end
    return levelLoss
end
function SetPlayerLevel(cid, lvl)
    doPlayerAddExperience(cid, getExperienceForLevel(lvl) - getPlayerExperience(cid))
end

function GetSkillLoss(skillsLvl)
    local skillLoss = 0.0
    -- get skill lose SKILLS
    if(skillsLvl >= 1 and skillsLvl <= 15) then skillLoss = 0.10
    elseif(skillsLvl >= 16 and skillsLvl <= 25) then skillLoss = 0.25
    elseif(skillsLvl >= 26 and skillsLvl <= 40) then skillLoss = 0.5
    elseif(skillsLvl >= 41 and skillsLvl <= 60) then skillLoss = 1
    elseif(skillsLvl >= 61 and skillsLvl <= 80) then skillLoss = 1.5
    elseif(skillsLvl >= 81 and skillsLvl <= 90) then skillLoss = 2.0
    elseif(skillsLvl >= 91 and skillsLvl <= 100) then skillLoss = 2.5
    elseif(skillsLvl >= 101) then skillLoss = 3.0
    end
    -- skull incrise SKILLS loss
    if(skull == SKULL_RED) then skillLoss = skillLoss * 1.5
    elseif(skull == SKULL_BLACK) then skillLoss = skillLoss * 3.0
    end
    return skillLoss
end

function GetMagicLevelLoss(mlLvl)
    local mlLoss = 0.0
    -- get ml lose SKILLS
    if(mlLvl >= 1 and mlLvl <= 5) then mlLoss = 0.10
    elseif(mlLvl >= 6 and mlLvl <= 15) then mlLoss = 0.25
    elseif(mlLvl >= 16 and mlLvl <= 20) then mlLoss = 0.5
    elseif(mlLvl >= 21 and mlLvl <= 30) then mlLoss = 1.0
    elseif(mlLvl >= 31 and mlLvl <= 40) then mlLoss = 1.5
    elseif(mlLvl >= 41 and mlLvl <= 60) then mlLoss = 2.0
    elseif(mlLvl >= 61 and mlLvl <= 70) then mlLoss = 2.5
    elseif(mlLvl >= 71) then mlLoss = 3.0
    end
    -- skull incrise ML loss
    if(skull == SKULL_RED) then mlLoss = mlLoss * 1.5
    elseif(skull == SKULL_BLACK) then mlLoss = mlLoss * 3.0
    end
    return mlLoss
end

function GetDeathLossReductions(cid)
    local reductionsValue = 0.0
    -- get reduction bless
    local eachblessreduction = 0.4 -- 5 blesses... MAX = 2
    local bless = {1, 2, 3, 4, 5}
    for i = 1, 5 do
        if(getPlayerBlessing(cid, bless[i])) then
            reductionsValue = reductionsValue + eachblessreduction
        end
    end
    -- get reduction VIP
    if isPremium(cid) then
        reductionsValue = reductionsValue + 1.0 -- MAX 3.0
    end
    return reductionsValue
end

function onDeath(cid, corpse, deathList)
    -- zero death loss (exp,skills,ml)
    doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 0)
    doPlayerSetLossPercent(cid, PLAYERLOSS_SKILLS, 0)
    doPlayerSetLossPercent(cid, PLAYERLOSS_MAGIC, 0)

    -- GET reduction value
    local reductionsValue = GetDeathLossReductions(cid)

    -- (1) SET LVL LOSS
    local currentLevel = getPlayerLevel(cid)
    local lvlLoss = GetLevelLoss(currentLevel)
    local newLvl = currentLevel - (lvlLoss / reductionsValue)
    SetPlayerLevel(cid, newLvl)

    -- (2) SET ML LOSS
    local currentMagic = getPlayerMagLevel(cid)
    local mlLoss = GetMagicLevelLoss(currentMagic)
    local newMagic = currentMagic - (mlLoss / reductionsValue)
    doPlayerSetMagicLevel(cid, newMagic)

    -- (3) SET SKILL LOSS
    -- get current skill
    local skills = {
        SKILL_FIST,
        SKILL_CLUB,
        SKILL_AXE,
        SKILL_SWORD,
        SKILL_SHIELD,
        SKILL_DISTANCE
    }
    for i = 1, #skills do
        -- get skill
        local currentSkill = getPlayerSkillLevel(cid, skills[i])
        -- set skill
        local skillLoss = GetSkillLoss(currentSkill)
        local newSkill = currentSkill - (skillLoss / reductionsValue)
        doPlayerSetSkillLevel(cid, skills[i], newSkill)
    end

    return true
end

help pls
 
Back
Top