• 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 1.X+ I have weird Health/Mana bug with transforms

henkas

Well-Known Member
Joined
Jul 8, 2015
Messages
993
Solutions
5
Reaction score
55
Hi
so i dont exactly know how this bug works, but i noticed couple thinks so lets say my vocation has four transformations every transformation increase health and mana bar so the problem is when i die my health somehow increase randomly and mana drops to zero, and second think i'm not sure about this one. Its really hard to explain so i'll try my best lets say you have 200Hp with default and then you take some items that adds +100hp so now we have 300hp and then i type transform and transform add +200 so now i have 500hp, right? So now when i'm transformed lets say i want to take my item off so now it should be -100 and i should have 400 but the problem that i have 500 so its like if i add items that gives me hp i can bug my health. So i suppose i should show my transform system
Code:
function onSay(player, words, param)
    local kurwa_gdzie_jest_efekt = Position(player:getPosition().x + 1, player:getPosition().y, player:getPosition().z)
    local pid = player:getId()

    local TRANS = transform[player:getVocation():getId()]
   
    if not TRANS then
        player:sendCancelMessage("TRANSFORM ERROR 11. Vocation = " .. player:getVocation():getId() .. "") -- VOCATION NOT IN GLOBAL TABLE
        return false
    end
   
    if TRANS.newVoc == 0 then
        player:sendCancelMessage("You cannot transform.")
        return false
    end
   
    if player:getLevel() < TRANS.level then
        player:sendCancelMessage("You must reach level "..TRANS.level.." to transform.")
        return false
    end
    if player:getSoul() < TRANS.rage then
        player:sendCancelMessage("You need "..TRANS.rage.." to transform.")
        return false
    end

    local outfit = player:getOutfit()
    outfit.lookType = TRANS.looktype

    if TRANS.constant then
        player:setOutfit(outfit)
    else
        player:setOutfit(outfit, true)
    end

    player:addSoul(-TRANS.rage)
    player:setMaxHealth(player:getMaxHealth() + TRANS.addHealth)
    player:setMaxMana(player:getMaxMana() + TRANS.addMana)
    kurwa_gdzie_jest_efekt:sendMagicEffect(TRANS.effect)
    player:setVocation(TRANS.newVoc)
    player:save()
    return false
end
This is revert
Code:
local function removeExhaust(pid)
    exhaust_transform[pid] = nil
end

function onSay(player, words, param, channel)
    local pid = player:getId()
   
    if exhaust_transform[pid] ~= nil then
        return false
    end
   
    local TRANS = transform[player:getVocation():getId()]
   
    if not TRANS then
        player:sendCancelMessage("TRANSFORM ERROR 11. Vocation = " .. player:getVocation():getId() .. "") -- VOCATION NOT IN GLOBAL TABLE
        return false
    end
   
    if TRANS.fromVoc == 0 then
        player:sendCancelMessage("You cannot revert.")
        return false
    end

    for i = 1, TRANS.transform do
        player:setVocation(TRANS.fromVoc)
        TRANS = transform[player:getVocation():getId()]
        local outfit = player:getOutfit()
        outfit.lookType = TRANS.from_looktype
        if TRANS.constant then
            player:setOutfit(outfit)
        else
            player:setOutfit(outfit, false)
        end
        player:setMaxHealth(player:getMaxHealth() - TRANS.addHealth)
        player:setMaxMana(player:getMaxMana() - TRANS.addMana)
    end
    player:save()
   
    exhaust_transform[pid] = 1   
    addEvent(removeExhaust, 5 * 1000, pid)
    return false
end

bump

bump

bump

upupupup

bump

bump

bump
 
Last edited by a moderator:
Solution
Code:
1>..\src\luascript.cpp(2053): error C2039: 'luaPlayerGetBaseMaxHealth': is not a member of 'LuaScriptInterface'
1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\luascript.h(199): note: see declaration of 'LuaScriptInterface'
1>..\src\luascript.cpp(2053): error C2065: 'luaPlayerGetBaseMaxHealth': undeclared identifier
1>..\src\luascript.cpp(2054): error C2039: 'luaPlayerGetBaseMaxMana': is not a member of 'LuaScriptInterface'
1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\luascript.h(199): note: see declaration of 'LuaScriptInterface'
1>..\src\luascript.cpp(2054): error C2065: 'luaPlayerGetBaseMaxMana': undeclared identifier
1>..\src\luascript.cpp(7461): error C2039: 'luaPlayerGetBaseMaxHealth': is not a...
Do you use attribute in items.xml or script ? If it is script please send it here to check
Ofc i use atrributes in items.xml. Example how every item are created in items.xml
Code:
    <item id="14246" article="a" name="Paladin Cap">
        <attribute key="description" value="+200 HP/MP. ki regeneration +35/s" />
        <attribute key="weight" value="2100" />
        <attribute key="armor" value="10" />
        <attribute key="manaTicks" value="1000"/>
        <attribute key="manaGain" value="35" />   
        <attribute key="maxhitpoints" value="200"/>
        <attribute key="maxmanapoints" value="200"/>       
        <attribute key="slotType" value="head" />
    </item>
 
Ofc i use atrributes in items.xml. Example how every item are created in items.xml
Code:
    <item id="14246" article="a" name="Paladin Cap">
        <attribute key="description" value="+200 HP/MP. ki regeneration +35/s" />
        <attribute key="weight" value="2100" />
        <attribute key="armor" value="10" />
        <attribute key="manaTicks" value="1000"/>
        <attribute key="manaGain" value="35" />  
        <attribute key="maxhitpoints" value="200"/>
        <attribute key="maxmanapoints" value="200"/>      
        <attribute key="slotType" value="head" />
    </item>
i really don't know sry :S
 
I think this is the last hope xD
Find this
Code:
    player:save()
 
    exhaust_transform[pid] = 1
    addEvent(removeExhaust, 5 * 1000, pid)
    return false


and change it with this :
Code:
    exhaust_transform[pid] = 1
    addEvent(removeExhaust, 5 * 1000, pid)
    player:save()
    return false

If it didn't work try to remove player save from x2 scripts ?
 
I think this is the last hope xD
Find this
Code:
    player:save()
 
    exhaust_transform[pid] = 1
    addEvent(removeExhaust, 5 * 1000, pid)
    return false


and change it with this :
Code:
    exhaust_transform[pid] = 1
    addEvent(removeExhaust, 5 * 1000, pid)
    player:save()
    return false

If it didn't work try to remove player save from x2 scripts ?
Last hope didnt helped and tried to delete save from both transform and revert still the same.
 
If you use
Code:
maxhitpointspercent
maxmanapointspercent
it is normal for you to have unbalance in the health, if you have some other code what modify the health or mana, then you will have problems.
since you know that.

Upgrading Transformation
Code:
Transformations = {
   
    -- Sorcerer
    [1] = { toVoc = 5, effect = CONST_ME_HITAREA, lookType = 5 },
    [5] = { fromVoc = 1, toVoc = 9, effect = CONST_ME_FIREATTACK, lookType = 6, addHp = 100, addMana = 100, level = 100 },
    [9] = { fromVoc = 5, effect = CONST_ME_GIANTICE, lookType = 7, addHp = 1000, addMana = 1000, level = 500 }

}

Exhaust_Transformation = {}

function removeExhaustTransformation(playerId)
    Exhaust_Transformation[playerId] = nil
end

-- Upgrading Trans
function onSay(player, words, param, channel)

    if Exhaust_Transformation[player:getId()] then
        player:sendCancelMessage('You are exhausted.')
        return false
    end
   
    local currTrans = Transformations[player:getVocation():getId()]
    if currTrans then
        local newTrans = Transformations[currTrans.toVoc or 0]
        if newTrans then
            if newTrans.level and player:getLevel() < newTrans.level then
                player:sendCancelMessage(string.format('this transformation requires level %u', newTrans.level))
                return false
            end
            player:setVocation(currTrans.toVoc)
            local addHp = currTrans.addHp or 0
            local addMp = currTrans.addMana or 0
            if newTrans.addHp then
                addHp = (newTrans.addHp -addHp)
            end
            if newTrans.addMana then
                addMp = (newTrans.addMana -addMp)
            end
            player:setMaxHealth(player:getMaxHealth() + addHp)
            player:setMaxMana(player:getMaxMana() + addMp)
            player:getPosition():sendMagicEffect(newTrans.effect)
            local outfit = player:getOutfit()
            if newTrans.lookType then
                outfit.lookType = newTrans.lookType
            end
            player:setOutfit(outfit)
            player:save()
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You are transformed.')
            Exhaust_Transformation[player:getId()] = true
            addEvent(removeExhaustTransformation, 5000, player:getId())
            return false
        end
    end

    player:sendCancelMessage('You vocation no have more transformations.')

    return false
end

Downgrading Transformation
Code:
-- Downgrading Trans
function onSay(player, words, param, channel)
   
    local currTrans = Transformations[player:getVocation():getId()]
    if currTrans then
        local newTrans = Transformations[currTrans.fromVoc or 0]
        if newTrans then
            player:setVocation(currTrans.fromVoc)
            local removeHp = currTrans.addHp
            local removeMp = currTrans.addMana
            if newTrans.addHp then
                removeHp = (removeHp -newTrans.addHp)
            end
            if newTrans.addMana then
                removeMp = (removeMp -newTrans.addMana)
            end
            player:setMaxHealth(player:getMaxHealth() - removeHp)
            player:setMaxMana(player:getMaxMana() - removeMp)
            player:getPosition():sendMagicEffect(newTrans.effect)
            local outfit = player:getOutfit()
            if newTrans.lookType then
                outfit.lookType = newTrans.lookType
            end
            player:setOutfit(outfit)
            player:save()
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Revert success.')
            Exhaust_Transformation[player:getId()] = true
            addEvent(removeExhaustTransformation, 5000, player:getId())
            return false
        end
    end

    player:sendCancelMessage('You transformation dont\'n revert.')

    return false
end
 
If you use
Code:
maxhitpointspercent
maxmanapointspercent
it is normal for you to have unbalance in the health, if you have some other code what modify the health or mana, then you will have problems.
since you know that.

Upgrading Transformation
Code:
Transformations = {
  
    -- Sorcerer
    [1] = { toVoc = 5, effect = CONST_ME_HITAREA, lookType = 5 },
    [5] = { fromVoc = 1, toVoc = 9, effect = CONST_ME_FIREATTACK, lookType = 6, addHp = 100, addMana = 100, level = 100 },
    [9] = { fromVoc = 5, effect = CONST_ME_GIANTICE, lookType = 7, addHp = 1000, addMana = 1000, level = 500 }

}

Exhaust_Transformation = {}

function removeExhaustTransformation(playerId)
    Exhaust_Transformation[playerId] = nil
end

-- Upgrading Trans
function onSay(player, words, param, channel)

    if Exhaust_Transformation[player:getId()] then
        player:sendCancelMessage('You are exhausted.')
        return false
    end
  
    local currTrans = Transformations[player:getVocation():getId()]
    if currTrans then
        local newTrans = Transformations[currTrans.toVoc or 0]
        if newTrans then
            if newTrans.level and player:getLevel() < newTrans.level then
                player:sendCancelMessage(string.format('this transformation requires level %u', newTrans.level))
                return false
            end
            player:setVocation(currTrans.toVoc)
            local addHp = currTrans.addHp or 0
            local addMp = currTrans.addMana or 0
            if newTrans.addHp then
                addHp = (newTrans.addHp -addHp)
            end
            if newTrans.addMana then
                addMp = (newTrans.addMana -addMp)
            end
            player:setMaxHealth(player:getMaxHealth() + addHp)
            player:setMaxMana(player:getMaxMana() + addMp)
            player:getPosition():sendMagicEffect(newTrans.effect)
            local outfit = player:getOutfit()
            if newTrans.lookType then
                outfit.lookType = newTrans.lookType
            end
            player:setOutfit(outfit)
            player:save()
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You are transformed.')
            Exhaust_Transformation[player:getId()] = true
            addEvent(removeExhaustTransformation, 5000, player:getId())
            return false
        end
    end

    player:sendCancelMessage('You vocation no have more transformations.')

    return false
end

Downgrading Transformation
Code:
-- Downgrading Trans
function onSay(player, words, param, channel)
  
    local currTrans = Transformations[player:getVocation():getId()]
    if currTrans then
        local newTrans = Transformations[currTrans.fromVoc or 0]
        if newTrans then
            player:setVocation(currTrans.fromVoc)
            local removeHp = currTrans.addHp
            local removeMp = currTrans.addMana
            if newTrans.addHp then
                removeHp = (removeHp -newTrans.addHp)
            end
            if newTrans.addMana then
                removeMp = (removeMp -newTrans.addMana)
            end
            player:setMaxHealth(player:getMaxHealth() - removeHp)
            player:setMaxMana(player:getMaxMana() - removeMp)
            player:getPosition():sendMagicEffect(newTrans.effect)
            local outfit = player:getOutfit()
            if newTrans.lookType then
                outfit.lookType = newTrans.lookType
            end
            player:setOutfit(outfit)
            player:save()
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Revert success.')
            Exhaust_Transformation[player:getId()] = true
            addEvent(removeExhaustTransformation, 5000, player:getId())
            return false
        end
    end

    player:sendCancelMessage('You transformation dont\'n revert.')

    return false
end
its great script i may use it ! Thank you
 
If you use
Code:
maxhitpointspercent
maxmanapointspercent
it is normal for you to have unbalance in the health, if you have some other code what modify the health or mana, then you will have problems.
since you know that.

Upgrading Transformation
Code:
Transformations = {
 
    -- Sorcerer
    [1] = { toVoc = 5, effect = CONST_ME_HITAREA, lookType = 5 },
    [5] = { fromVoc = 1, toVoc = 9, effect = CONST_ME_FIREATTACK, lookType = 6, addHp = 100, addMana = 100, level = 100 },
    [9] = { fromVoc = 5, effect = CONST_ME_GIANTICE, lookType = 7, addHp = 1000, addMana = 1000, level = 500 }

}

Exhaust_Transformation = {}

function removeExhaustTransformation(playerId)
    Exhaust_Transformation[playerId] = nil
end

-- Upgrading Trans
function onSay(player, words, param, channel)

    if Exhaust_Transformation[player:getId()] then
        player:sendCancelMessage('You are exhausted.')
        return false
    end
 
    local currTrans = Transformations[player:getVocation():getId()]
    if currTrans then
        local newTrans = Transformations[currTrans.toVoc or 0]
        if newTrans then
            if newTrans.level and player:getLevel() < newTrans.level then
                player:sendCancelMessage(string.format('this transformation requires level %u', newTrans.level))
                return false
            end
            player:setVocation(currTrans.toVoc)
            local addHp = currTrans.addHp or 0
            local addMp = currTrans.addMana or 0
            if newTrans.addHp then
                addHp = (newTrans.addHp -addHp)
            end
            if newTrans.addMana then
                addMp = (newTrans.addMana -addMp)
            end
            player:setMaxHealth(player:getMaxHealth() + addHp)
            player:setMaxMana(player:getMaxMana() + addMp)
            player:getPosition():sendMagicEffect(newTrans.effect)
            local outfit = player:getOutfit()
            if newTrans.lookType then
                outfit.lookType = newTrans.lookType
            end
            player:setOutfit(outfit)
            player:save()
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You are transformed.')
            Exhaust_Transformation[player:getId()] = true
            addEvent(removeExhaustTransformation, 5000, player:getId())
            return false
        end
    end

    player:sendCancelMessage('You vocation no have more transformations.')

    return false
end

Downgrading Transformation
Code:
-- Downgrading Trans
function onSay(player, words, param, channel)
 
    local currTrans = Transformations[player:getVocation():getId()]
    if currTrans then
        local newTrans = Transformations[currTrans.fromVoc or 0]
        if newTrans then
            player:setVocation(currTrans.fromVoc)
            local removeHp = currTrans.addHp
            local removeMp = currTrans.addMana
            if newTrans.addHp then
                removeHp = (removeHp -newTrans.addHp)
            end
            if newTrans.addMana then
                removeMp = (removeMp -newTrans.addMana)
            end
            player:setMaxHealth(player:getMaxHealth() - removeHp)
            player:setMaxMana(player:getMaxMana() - removeMp)
            player:getPosition():sendMagicEffect(newTrans.effect)
            local outfit = player:getOutfit()
            if newTrans.lookType then
                outfit.lookType = newTrans.lookType
            end
            player:setOutfit(outfit)
            player:save()
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Revert success.')
            Exhaust_Transformation[player:getId()] = true
            addEvent(removeExhaustTransformation, 5000, player:getId())
            return false
        end
    end

    player:sendCancelMessage('You transformation dont\'n revert.')

    return false
end
Sorry for the stupid question. So you wrote Upgrading Transformation and Downgrading Transformation there is two different scripts you wrote so which one do i have to use? Probably there is some parts that i have to add to globa.lua and others to talkaction?
 
Last edited:
So yea i tried this script and its really gliched up, messed up with vocation ids somehow if you are id 1 that system thinks like example you are id 5. You can revert as much as you want, well its really messed up. So maybe it would be better to stick with mine transform system and just fix that health problem?
 
you probably just bad config script, if you dont want to revert on 1 voc than dont add fromvoc there and it will return 0 and if you dont add to config vocation with id 0 it will always stop
 
you probably just bad config script, if you dont want to revert on 1 voc than dont add fromvoc there and it will return 0 and if you dont add to config vocation with id 0 it will always stop
I didnt said that i dont want to revert.
 
i meant that on specific vocation id not all, you know you must stop somewhere right? so if the first vocation(no transform) is vocation with id 1 you dont add there fromvoc, i dont know how to tell it more easier.
 
KFKhwRrnQgWpNguOMmF6SQ.png

you do not need to add anything to global.lua
 
KFKhwRrnQgWpNguOMmF6SQ.png

you do not need to add anything to global.lua
Lul i added in global.lua Transformations = {
But still it doesnt change the part that its really glitchy as i said i can revert as much as i want. Vocation id are messed up but this is how it looked

[1] = { fromVoc = 1, toVoc = 5, effect = CONST_ME_FIREATTACK, lookType = 6, addHp = 100, addMana = 100, level = 50 },
[5] = { fromVoc = 5, toVoc = 29,effect = CONST_ME_GIANTICE, lookType = 7, addHp = 1000, addMana = 1000, level = 100 }

So i went into the game with 1 level just for test and i as with id 1 and it says that i need level 100 to transform so it means that my vocation id is 5? But databse shows that my voc is id 1. Its so messed up.
 
you tangle yourself. :D
if you are already a vocation 1 for what
Code:
[1] = { fromVoc = 1,
????????
use my code as a reference forget yours.

1 > 5 > 9 > 5 > 1
not 1 > 1 ???

if you need to change to vocation 5
only change parameters of
Code:
[5] = { fromVoc = 1, toVoc = 9, effect = CONST_ME_FIREATTACK, lookType = 6, addHp = 100, addMana = 100, level = 100 }

if you need to change to vocation 1 and you are vocation 5
only change parameters of
Code:
[1] = { toVoc = 5, effect = CONST_ME_HITAREA, lookType = 5 }
you can not ask for a certain level to return to its minimum state, what is 1 <


Visual Example:
JfonIEwURSiK-7bYEA3jwQ.png
 
Last edited:
you tangle yourself. :D
if you are already a vocation 1 for what
Code:
[1] = { fromVoc = 1,
????????
use my code as a reference forget yours.

1 > 5 > 9 > 5 > 1
not 1 > 1 ???

if you need to change to vocation 5
olny change parameters of
Code:
[5] = { fromVoc = 1, toVoc = 9, effect = CONST_ME_FIREATTACK, lookType = 6, addHp = 100, addMana = 100, level = 100 }

if you need to change to vocation 1 and you are vocation 5
olny change parameters of
Code:
[1] = { toVoc = 5, effect = CONST_ME_HITAREA, lookType = 5 }
you can not ask for a certain level to return to its minimum state, what is 1 <
Reeeeeeeeee its still messed up with these ids i dont know what to say else tried every variation possible its still fuc... up :D Maybe lets stick with my old transform and just lets find a problem in tranform.lua ant revert.lua because i'm going crazy right now.
 
post your transformations config, I'm curious what you created there xD
Transformations = {

[1] = { toVoc = 5, effect = CONST_ME_HITAREA, lookType = 5, level = 50 },
[5] = { fromVoc = 1, toVoc = 26, effect = CONST_ME_FIREATTACK, lookType = 6, addHp = 100, addMana = 100, level = 100 },
[26] = { fromVoc = 5, toVoc = 27, effect = CONST_ME_GIANTICE, lookType = 7, addHp = 1000, addMana = 1000, level = 150 }

}

It should first go level 50 but in game it goes 100 first. Tried all variations so swoop ids.
 
I know in these days logic thinking is not so popular but how you dont get it already? the level required for transform getting from the transform(tovoc) vocation id, same with stats/effect/looktype
Code:
Transformations = {

[1] = { toVoc = 5, effect = CONST_ME_HITAREA, lookType = 5 },
[5] = { fromVoc = 1, toVoc = 26, effect = CONST_ME_FIREATTACK, lookType = 6, addHp = 100, addMana = 100, level = 50 },
[26] = { fromVoc = 5, toVoc = 27, effect = CONST_ME_GIANTICE, lookType = 7, addHp = 1000, addMana = 1000, level = 100 }

}
 
Back
Top