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

Damage format

limen

New Member
Joined
Feb 6, 2025
Messages
8
Reaction score
0
Hello.
I would like to change the format of damage/healing in my TFS 1.42 10.98. For example, instead of 1000, I would like to display -1k, and instead of 15,300, I would like to display -15.3k.
Would it be easier to do this on the OTClient side or the server side? Any Tips?
 
Solution
Do you know where I can look for displayed damage and healing in OTClient?
look for
LUA:
case Otc::MessageDamageDealed:

and change value that is passed to
Code:
g_map.addAnimatedText(std::make_shared<AnimatedText>(std::to_string(value[j]), color[j]), pos);
change it to sum like this

Code:
#include <iomanip>
#include <sstream>

case Otc::MessageDamageDealed:
case Otc::MessageDamageReceived:
case Otc::MessageDamageOthers:
{
    const auto& pos = getPosition(msg);
    std::array<uint32_t, 2> value{};
    std::array<uint8_t, 2> color{};

    // physical damage
    value[0] = msg->getU32();
    color[0] = msg->getU8();

    // magic damage
    value[1] = msg->getU32();
    color[1] = msg->getU8();
    text =...
I think whole "show dmg" math line - do "/ -1"
Is that english?


Hello.
I would like to change the format of damage/healing in my TFS 1.42 10.98. For example, instead of 1000, I would like to display -1k, and instead of 15,300, I would like to display -15.3k.
Would it be easier to do this on the OTClient side or the server side? Any Tips?
Client side, there is no reason to need to change it on the server side when you have access to the client...
 
Do you know where I can look for displayed damage and healing in OTClient?
look for
LUA:
case Otc::MessageDamageDealed:

and change value that is passed to
Code:
g_map.addAnimatedText(std::make_shared<AnimatedText>(std::to_string(value[j]), color[j]), pos);
change it to sum like this

Code:
#include <iomanip>
#include <sstream>

case Otc::MessageDamageDealed:
case Otc::MessageDamageReceived:
case Otc::MessageDamageOthers:
{
    const auto& pos = getPosition(msg);
    std::array<uint32_t, 2> value{};
    std::array<uint8_t, 2> color{};

    // physical damage
    value[0] = msg->getU32();
    color[0] = msg->getU8();

    // magic damage
    value[1] = msg->getU32();
    color[1] = msg->getU8();
    text = msg->getString();

    auto formatDamage = [](uint32_t dmg) -> std::string {
        std::ostringstream oss;
        oss << std::fixed << std::setprecision(2);

        if (dmg >= 1000000000) {
            oss << (static_cast<double>(dmg) / 1000000000) << "b";
        } else if (dmg >= 1000000) {
            oss << (static_cast<double>(dmg) / 1000000) << "m";
        } else if (dmg >= 1000) {
            oss << (static_cast<double>(dmg) / 1000) << "k";
        } else {
            oss << dmg;
        }

        return oss.str();
    };

    for (auto j = 0; j < 2; j++) {
        if (value[j] == 0) {
            continue;
        }
        
        std::string formattedValue = formatDamage(value[j]);
        g_map.addAnimatedText(std::make_shared<AnimatedText>(formattedValue, color[j]), pos);
    }
    break;
 
Solution
look for
LUA:
case Otc::MessageDamageDealed:

and change value that is passed to
Code:
g_map.addAnimatedText(std::make_shared<AnimatedText>(std::to_string(value[j]), color[j]), pos);
change it to sum like this

Code:
#include <iomanip>
#include <sstream>

case Otc::MessageDamageDealed:
case Otc::MessageDamageReceived:
case Otc::MessageDamageOthers:
{
    const auto& pos = getPosition(msg);
    std::array<uint32_t, 2> value{};
    std::array<uint8_t, 2> color{};

    // physical damage
    value[0] = msg->getU32();
    color[0] = msg->getU8();

    // magic damage
    value[1] = msg->getU32();
    color[1] = msg->getU8();
    text = msg->getString();

    auto formatDamage = [](uint32_t dmg) -> std::string {
        std::ostringstream oss;
        oss << std::fixed << std::setprecision(2);

        if (dmg >= 1000000000) {
            oss << (static_cast<double>(dmg) / 1000000000) << "b";
        } else if (dmg >= 1000000) {
            oss << (static_cast<double>(dmg) / 1000000) << "m";
        } else if (dmg >= 1000) {
            oss << (static_cast<double>(dmg) / 1000) << "k";
        } else {
            oss << dmg;
        }

        return oss.str();
    };

    for (auto j = 0; j < 2; j++) {
        if (value[j] == 0) {
            continue;
        }
       
        std::string formattedValue = formatDamage(value[j]);
        g_map.addAnimatedText(std::make_shared<AnimatedText>(formattedValue, color[j]), pos);
    }
    break;
Very nicely done, especially the use of std::fixed and std::setPrecision, and to top it off, the core is all wrapped up in a nice lambda :D
 
That's cool! Alberto posted another one too... it's quite different from yours.
 
but now got double healing
You did the DMG on the OtClient side, and everything is fine for it to work correctly. However, you shouldn't have added the healing values, like millions and billions, on the OtClient side... That should be on the server side. I did it the same way, even adding different colors. Healing has options like normal, k, mil, millions, billions, and so on. I also added the option via config, true and false. If you don't want to display it, set it to false to hide mi, bi, and show the default TFS display. If you want to display healing in mi, bi, etc., set it to true, and it will display correctly.
 
When I think about it, it is actually just a waste of resources and time. I would just cut all the dmg values so for example they deal 1-15 dmg. After that you just write a "k" after all those numbers and call it a day. Pretty much no difference to the other stuff.
 
You did the DMG on the OtClient side, and everything is fine for it to work correctly. However, you shouldn't have added the healing values, like millions and billions, on the OtClient side... That should be on the server side. I did it the same way, even adding different colors. Healing has options like normal, k, mil, millions, billions, and so on. I also added the option via config, true and false. If you don't want to display it, set it to false to hide mi, bi, and show the default TFS display. If you want to display healing in mi, bi, etc., set it to true, and it will display correctly.
Honest question - why?
When I think about it, it is actually just a waste of resources and time. I would just cut all the dmg values so for example they deal 1-15 dmg. After that you just write a "k" after all those numbers and call it a day. Pretty much no difference to the other stuff.
It's client side, server won't be affected by anything
 
You did the DMG on the OtClient side, and everything is fine for it to work correctly. However, you shouldn't have added the healing values, like millions and billions, on the OtClient side... That should be on the server side. I did it the same way, even adding different colors. Healing has options like normal, k, mil, millions, billions, and so on. I also added the option via config, true and false. If you don't want to display it, set it to false to hide mi, bi, and show the default TFS display. If you want to display healing in mi, bi, etc., set it to true, and it will display correctly.
I'm with Sorky. I see no reason to have to do this work on the server side for the healing, so if you care to share on the reason why, I would love to hear it.
 
I'm with Sorky. I see no reason to have to do this work on the server side for the healing, so if you care to share on the reason why, I would love to hear it.
The Sorky system he made on the OTClient side is more practical and saves time. Even better, everything is fine. But the one I made on the server side is a bit more laborious, requiring many changes to work properly. However, yes, it is working, including healing displaying values like 1k, 1kk, 1kkk, with customizable colors. For example, 1k in blue, 1kk in red, 1kkk in green, or you can set them all to the same color. Everything is configurable in the server's config.lua. I will release it for the OTland community soon… I just don’t have time right now. If I have time, I will definitely release it. It is ideal for NTO/DBO/Pokemon servers. I made it for a friend who uses TFS 1.5 Nekiro with DBO.
 
Healing is next case in same file area. I hope you didn't combine them together? 😅
It's actually giving two times healing or just client side?
I messed up a bit while pasting, which caused double healing :D
I fixed it and everything is okay now.
If you have any ideas on how to also change the numbers for hp/mana, I would be grateful <3
Thanks guys
 
I messed up a bit while pasting, which caused double healing :D
I fixed it and everything is okay now.
If you have any ideas on how to also change the numbers for hp/mana, I would be grateful <3
Thanks guys
You want it where? On the right side in the bars?
 
If you have any ideas on how to also change the numbers for hp/mana, I would be grateful <3
Thanks guys

Basically it would be almost the exact same code he already provided you, but it would be in the case for the healing inside that switch statement so like if you look at this code

1738899380909.webp

You can see he wrote it inside the case for DamageOthers... but the other two above fallthrough to the same logic so it handles all damage dealt... as you already know that you were having issues with the healing was because of a pasting issue, it was because the very next case after this one, was healing, so you will give it it's own curly braces {} and inside it, basically same code as is inside your DamageOthers case, but you may or may not want to slightly tweak it (like the colors part for the damagetype for example), it may or may not need adjusting for the "negative" appearance as well.
 
Last edited:
Back
Top