• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

C++ Classic Ammo Slot/Healing Mana show numbers

Solution
my bad

LUA:
local config = {
    [{1, 5}] = { healAmount = {90, 250}, effect = 1, color = 210 },
    [{2, 6}] = { healAmount = {90, 250}, effect = 1, color = 210 },
    [{3, 7}] = { healAmount = {90, 250}, effect = 1, color = 210 },
    [{4, 8}] = { healAmount = {90, 250}, effect = 1, color = 210 }
}

function onCastSpell(player, variant, isHotkey)
    for v, c in pairs(config) do
        if table.contains(v, player:getVocation():getId()) then
            local pos = player:getPosition()
            local mana_add = math.random(c.healAmount[1], c.healAmount[2])
            player:addMana(mana_add)
            pos:sendMagicEffect(c.effect)
            Game.sendAnimatedText(mana_add, pos, c.color)
        end
    end...
If it's not a problem, that hand slots (weapon/shield slots) can wear any item too, you can edit config.lua ( forgottenserver/config.lua.dist at 6982d66e71fd8f113673cf1624ee28178670d186 · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/6982d66e71fd8f113673cf1624ee28178670d186/config.lua.dist#L83) ):
LUA:
classicEquipmentSlots = false
to:
LUA:
classicEquipmentSlots = true
If you want to make only ammo slot able to wear any item, but keep hands only equip weapons/shields, you will have to edit player.cpp code. Search for CLASSIC_EQUIPMENT_SLOTS and make it true (not read config) in IFs with SLOTP_AMMO (others are SLOTP_RIGHT and SLOTP_LEFT).
 
Fixed

Searched for player.cpp for the ammo slot

C++:
case CONST_SLOT_AMMO: {
    if ((slotPosition & SLOTP_AMMO) || g_config.getBoolean(ConfigManager::CLASSIC_EQUIPMENT_SLOTS)) {
        ret = RETURNVALUE_NOERROR;
    }
    break;
}

Just removed the condition for the slot

C++:
case CONST_SLOT_AMMO: {
    ret = RETURNVALUE_NOERROR;
    break;
}
Post automatically merged:

If it's not a problem, that hand slots (weapon/shield slots) can wear any item too, you can edit config.lua ( forgottenserver/config.lua.dist at 6982d66e71fd8f113673cf1624ee28178670d186 · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/6982d66e71fd8f113673cf1624ee28178670d186/config.lua.dist#L83) ):
LUA:
classicEquipmentSlots = false
to:
LUA:
classicEquipmentSlots = true
If you want to make only ammo slot able to wear any item, but keep hands only equip weapons/shields, you will have to edit player.cpp code. Search for CLASSIC_EQUIPMENT_SLOTS and make it true (not read config) in IFs with SLOTP_AMMO (others are SLOTP_RIGHT and SLOTP_LEFT).
Lol I went to the engine hahaha didnt know that it is an already in the config but thanks
 
in config lua classic slots or something.

u can also restrict it via events in moveitem or similar function after
Thanks you I also figured out in the player.cpp removed this condition and worked perfectly but still better to make the things more easier with the config.
Post automatically merged:

If it's not a problem, that hand slots (weapon/shield slots) can wear any item too, you can edit config.lua ( forgottenserver/config.lua.dist at 6982d66e71fd8f113673cf1624ee28178670d186 · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/6982d66e71fd8f113673cf1624ee28178670d186/config.lua.dist#L83) ):
LUA:
classicEquipmentSlots = false
to:
LUA:
classicEquipmentSlots = true
If you want to make only ammo slot able to wear any item, but keep hands only equip weapons/shields, you will have to edit player.cpp code. Search for CLASSIC_EQUIPMENT_SLOTS and make it true (not read config) in IFs with SLOTP_AMMO (others are SLOTP_RIGHT and SLOTP_LEFT).
Sorry for asking again but there is another problem facing me The mana healing numbers with purple isn't showing with my mana rune script searched a lot if it is a function should be changed or not but what do you think about that?
C++:
local t = {
    [1] = {90, 250},
    [2] = {90, 250}, 
    [3] = {90, 250},
    [4] = {100, 250},
    [5] = {90, 250},
    [6] = {90, 250}, 
    [7] = {90, 250},
    [8] = {150, 300}
}

function onCastSpell(cid, var)
    local v = t[getPlayerVocation(cid)]
    if v ~= nil then
        doPlayerAddMana(cid, math.random(v[1], v[2]))
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
    end
end
 
Last edited:

local colors = {5,30,35,95,108,129,143,155,180,198,210,215}
 
Last edited:

local colors = {5,30,35,95,108,129,143,155,180,198,210,215}
What if it is 8.6 ,It may has another way right?
 
Thanks you I also figured out in the player.cpp removed this condition and worked perfectly but still better to make the things more easier with the config.
Post automatically merged:


Sorry for asking again but there is another problem facing me The mana healing numbers with purple isn't showing with my mana rune script searched a lot if it is a function should be changed or not but what do you think about that?
C++:
local t = {
    [1] = {90, 250},
    [2] = {90, 250},
    [3] = {90, 250},
    [4] = {100, 250},
    [5] = {90, 250},
    [6] = {90, 250},
    [7] = {90, 250},
    [8] = {150, 300}
}

function onCastSpell(cid, var)
    local v = t[getPlayerVocation(cid)]
    if v ~= nil then
        doPlayerAddMana(cid, math.random(v[1], v[2]))
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
    end
end
According to this luascript.cpp code:
C++:
int LuaScriptInterface::luaPlayerAddMana(lua_State* L)
{
    // player:addMana(manaChange[, animationOnLoss = false])
    Player* player = getUserdata<Player>(L, 1);
    if (!player) {
        lua_pushnil(L);
        return 1;
    }

    int32_t manaChange = getNumber<int32_t>(L, 2);
    bool animationOnLoss = getBoolean(L, 3, false);
    if (!animationOnLoss && manaChange < 0) {
        player->changeMana(manaChange);
    } else {
        CombatDamage damage;
        damage.primary.value = manaChange;
        damage.origin = ORIGIN_NONE;
        g_game.combatChangeMana(nullptr, player, damage);
    }
    pushBoolean(L, true);
    return 1;
}
It shows mana points animation only, if you remove mana, not add mana.
To make it execute whole mana-change code (show added mana), you have to edit:
LUA:
doPlayerAddMana(cid, math.random(v[1], v[2]))
to:
LUA:
doPlayerAddMana(cid, math.random(v[1], v[2]), true)


If it does not work (it should), you may need to change TFS 0.x code to TFS 1.x code. Replace:
LUA:
doPlayerAddMana(cid, math.random(v[1], v[2]))
with:
LUA:
cid:addMana(math.random(v[1], v[2]), true)



if ur on OTclient use this
It looks like some 8.x downgrade code (sendAnimatedText), not 1.4 code for 10.98 client.
 
According to this luascript.cpp code:
C++:
int LuaScriptInterface::luaPlayerAddMana(lua_State* L)
{
    // player:addMana(manaChange[, animationOnLoss = false])
    Player* player = getUserdata<Player>(L, 1);
    if (!player) {
        lua_pushnil(L);
        return 1;
    }

    int32_t manaChange = getNumber<int32_t>(L, 2);
    bool animationOnLoss = getBoolean(L, 3, false);
    if (!animationOnLoss && manaChange < 0) {
        player->changeMana(manaChange);
    } else {
        CombatDamage damage;
        damage.primary.value = manaChange;
        damage.origin = ORIGIN_NONE;
        g_game.combatChangeMana(nullptr, player, damage);
    }
    pushBoolean(L, true);
    return 1;
}
It shows mana points animation only, if you remove mana, not add mana.
To make it execute whole mana-change code (show added mana), you have to edit:
LUA:
doPlayerAddMana(cid, math.random(v[1], v[2]))
to:
LUA:
doPlayerAddMana(cid, math.random(v[1], v[2]), true)


If it does not work (it should), you may need to change TFS 0.x code to TFS 1.x code. Replace:
LUA:
doPlayerAddMana(cid, math.random(v[1], v[2]))
with:
LUA:
cid:addMana(math.random(v[1], v[2]), true)




It looks like some 8.x downgrade code (sendAnimatedText), not 1.4 code for 10.98 client.
Stillss.gif
 
Last edited:
You can use for that the Game.sendAnimatedText function
Like add in your script
LUA:
Game.sendAnimatedText(value, player:getPosition(), yourColor)
If you couldn't do that, send me your script

EDIT: Didn't see the other posts, my bad but easier to work with in my opinion
 
Last edited:
LUA:
local t = {
    [1] = {90, 250},
    [2] = {90, 250},
    [3] = {90, 250},
    [4] = {100, 250},
    [5] = {90, 250},
    [6] = {90, 250},
    [7] = {90, 250},
    [8] = {150, 300}
}

function onCastSpell(cid, var)
    local v = t[getPlayerVocation(cid)]
    if v ~= nil then
        doPlayerAddMana(cid, math.random(v[1], v[2]), true)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
        Game.sendAnimatedText(value, player:getPosition(),COLOR_DARKPURPLE)
    end
end

And unfortunately didn't work yet :(
Post automatically merged:

doesnt matter the version if tfs is 1.2+ :) and it was removed because it was depracated function in cip client at the time somewhere i use it in nekiro and in 1.4.2 so
When I opened the game.cpp I found Healthgain function with the animation and yes healing health in the game shows the number you are healed tried to find mana gain function didnt see except manalose

Game.Cpp

Mana lose function
C++:
targetPlayer->drainMana(attacker, manaLoss);

std::string spectatorMessage;

TextMessage message;
std::ostringstream strManaLoss;
strManaLoss << manaLoss;
addAnimatedText(strManaLoss.str(), targetPos, TEXTCOLOR_PURPLE);


Gaining Health Function
C++:
int32_t realHealthChange = target->getHealth();
target->gainHealth(attacker, damage.primary.value);
realHealthChange = target->getHealth() - realHealthChange;

if (realHealthChange > 0 && !target->isInGhostMode()) {
    auto damageString = fmt::format("{:d} hitpoint{:s}", realHealthChange, realHealthChange != 1 ? "s" : "");

    std::string spectatorMessage;

    TextMessage message;
    std::ostringstream strHealthChange;
    strHealthChange << realHealthChange;
    addAnimatedText(strHealthChange.str(), targetPos, TEXTCOLOR_GREEN);

And yet there is no gaining mana function with animation text maybe thats why
 
Last edited:
LUA:
local t = {
    [1] = {90, 250},
    [2] = {90, 250},
    [3] = {90, 250},
    [4] = {100, 250},
    [5] = {90, 250},
    [6] = {90, 250},
    [7] = {90, 250},
    [8] = {150, 300}
}

function onCastSpell(cid, var)
    local v = t[getPlayerVocation(cid)]
    if v ~= nil then
        doPlayerAddMana(cid, math.random(v[1], v[2]), true)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
        Game.sendAnimatedText(value, player:getPosition(),COLOR_DARKPURPLE)
    end
end

And unfortunately didn't work yet :(
Post automatically merged:


When I opened the game.cpp I found Healthgain function with the animation and yes healing health in the game shows the number you are healed tried to find mana gain function didnt see except manalose

Game.Cpp

Mana lose function
C++:
targetPlayer->drainMana(attacker, manaLoss);

std::string spectatorMessage;

TextMessage message;
std::ostringstream strManaLoss;
strManaLoss << manaLoss;
addAnimatedText(strManaLoss.str(), targetPos, TEXTCOLOR_PURPLE);


Gaining Health Function
C++:
int32_t realHealthChange = target->getHealth();
target->gainHealth(attacker, damage.primary.value);
realHealthChange = target->getHealth() - realHealthChange;

if (realHealthChange > 0 && !target->isInGhostMode()) {
    auto damageString = fmt::format("{:d} hitpoint{:s}", realHealthChange, realHealthChange != 1 ? "s" : "");

    std::string spectatorMessage;

    TextMessage message;
    std::ostringstream strHealthChange;
    strHealthChange << realHealthChange;
    addAnimatedText(strHealthChange.str(), targetPos, TEXTCOLOR_GREEN);

And yet there is no gaining mana function with animation text maybe thats why
did u add my functions i send u from the thread dont use Game.send blabla that marko gave cuz its not in your engine. you have to manually add the depracated function from thread that I sent u its way better because u can change color without compiling.
 
did u add my functions i send u from the thread dont use Game.send blabla that marko gave cuz its not in your engine. you have to manually add the depracated function from thread that I sent u its way better because u can change color without compiling.
Bro I think animated text is working! the problem is with the managain function like look in the image 1731793534356.webp
Animated text above the teleports with yello color
1731793626022.webp
Health gain effect (It was blue and I changed from the game.bla bla function)
C++:
strHealthChange << realHealthChange;
    addAnimatedText(strHealthChange.str(), targetPos, TEXTCOLOR_GREEN);
 
Last edited:
LUA:
local t = {

    [1] = {90, 250},

    [2] = {90, 250},

    [3] = {90, 250},

    [4] = {100, 250},

    [5] = {90, 250},

    [6] = {90, 250},

    [7] = {90, 250},

    [8] = {150, 300}

}



function onCastSpell(cid, var)

    local v = t[getPlayerVocation(cid)]

    if v ~= nil then

        doPlayerAddMana(cid, math.random(v[1], v[2]))

        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)

         doSendAnimatedText(v, getThingPos(cid), 133)

    end

end
 
Last edited:
did u add my functions i send u from the thread dont use Game.send blabla that marko gave cuz its not in your engine. you have to manually add the depracated function from thread that I sent u its way better because u can change color without compiling.

LUA:
local t = {

    [1] = {90, 250},

    [2] = {90, 250},

    [3] = {90, 250},

    [4] = {100, 250},

    [5] = {90, 250},

    [6] = {90, 250},

    [7] = {90, 250},

    [8] = {150, 300}

}



function onCastSpell(cid, var)

    local v = t[getPlayerVocation(cid)]

    if v ~= nil then

        doPlayerAddMana(cid, math.random(v[1], v[2]))

        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)

         doSendAnimatedText(v, getThingPos(cid), 133)

    end

end
Didnt work @Nekiro Can you please see this post?
 
Last edited:
Didnt work @Nekiro Can you please see this post?

Try this:

LUA:
local config = {
    [{1, 5}] = { healAmount = {90, 250}, effect = 1, color = 210 }
    [{2, 6}] = { healAmount = {90, 250}, effect = 1, color = 210 }
    [{3, 7}] = { healAmount = {90, 250}, effect = 1, color = 210 }
    [{4, 8}] = { healAmount = {90, 250}, effect = 1, color = 210 }
}

function onCastSpell(player, variant)
    for v, c in pairs(config) do
        if table.contains(v, player:getVocation():getId()) then
            local pos = player:getPosition()
            player:addMana(math.random(v.healAmount[1], v.healAmount[2]))
            pos:sendMagicEffect(v.effect)
            Game.sendAnimatedText(v.healAmount, pos, v.color)
        end
    end
    combat:execute(player, variant)
end
 
Back
Top