• 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 Show Magic Percent increased on look item

potinho

Advanced OT User
Joined
Oct 11, 2009
Messages
1,403
Solutions
17
Reaction score
151
Location
Brazil
Hello everyone, everything good? Very similar to the post below, I would like to know if I can (via C++) make it so that when giving an item a look, it is shown by default how much increaseMagicPercent it has, actually I use the description flag, but for some items purchased in the shop, the description is different and overlaps with the look of the item.


Like this one
XML:
    <item id="5570" article="a" name="nightmare robe">
        <attribute key="weight" value="3000"/>
        <attribute key="armor" value="15"/>
        <attribute key="slotType" value="body"/>
        <attribute key="increaseMagicPercent" value="110"/>
        <attribute key="description" value="Magic Damage +10%."/>
        <attribute key="magiclevelpoints" value="3"/>
    </item>

No need to use "description" field. I'm using this server as engine:
 
Go to item.h, find the line 'if(it.abilities->speed)' and add below it. Then, search for that line again and repeat the addition.

C++:
if (it.abilities->increasemagicpercent) {
    if (begin) {
        begin = false;
        s << " (";
    } else {
        s << ", ";
    }

    s << "Inc.Magic " << std::showpos << (int32_t)(it.getAbilities()->increment[MAGIC_PERCENT]) << std::noshowpos;
}

or

C++:
if (it.abilities->increasemagicpercent) {

    if (begin) {

        begin = false;

        s << " (";

    } else {

        s << ", ";

    }



    s << "Inc.Magic " << std::showpos << (int32_t)(it.abilities->increasemagicpercent) << std::noshowpos;

}

I'm not sure which one is right... If it doesn't work, you can try removing 'int32_t', keeping the rest and compiling. Then, enter the game and check the item to display the 'inc magic' attribute correctly or not.

C++:
if (it.abilities->increasemagicpercent) {
    if (begin) {
        begin = false;
        s << " (";
    } else {
        s << ", ";
    }

    s << "Inc.Magic " << std::showpos << it.abilities->increasemagicpercent << std::noshowpos;
}

or

C++:
if (it.abilities->increasemagicpercent) {
    if (begin) {
        begin = false;
        s << " (";
    } else {
        s << ", ";
    }

    s << "Inc.Magic " << std::showpos << it.getAbilities()->increment[MAGIC_PERCENT] << std::noshowpos;
}
 
Go to item.h, find the line 'if(it.abilities->speed)' and add below it. Then, search for that line again and repeat the addition.

C++:
if (it.abilities->increasemagicpercent) {
    if (begin) {
        begin = false;
        s << " (";
    } else {
        s << ", ";
    }

    s << "Inc.Magic " << std::showpos << (int32_t)(it.getAbilities()->increment[MAGIC_PERCENT]) << std::noshowpos;
}

or

C++:
if (it.abilities->increasemagicpercent) {

    if (begin) {

        begin = false;

        s << " (";

    } else {

        s << ", ";

    }



    s << "Inc.Magic " << std::showpos << (int32_t)(it.abilities->increasemagicpercent) << std::noshowpos;

}

I'm not sure which one is right... If it doesn't work, you can try removing 'int32_t', keeping the rest and compiling. Then, enter the game and check the item to display the 'inc magic' attribute correctly or not.

C++:
if (it.abilities->increasemagicpercent) {
    if (begin) {
        begin = false;
        s << " (";
    } else {
        s << ", ";
    }

    s << "Inc.Magic " << std::showpos << it.abilities->increasemagicpercent << std::noshowpos;
}

or

C++:
if (it.abilities->increasemagicpercent) {
    if (begin) {
        begin = false;
        s << " (";
    } else {
        s << ", ";
    }

    s << "Inc.Magic " << std::showpos << it.getAbilities()->increment[MAGIC_PERCENT] << std::noshowpos;
}
Got this error:
C++:
item.cpp: In static member function ‘static std::__cxx11::string Item::getDescription(const ItemType                                                                                                                                         &, int32_t, const Item*, int32_t, bool)’:
item.cpp:1099:22: error: ‘struct Abilities’ has no member named ‘increasemagicpercent’
    if (it.abilities->increasemagicpercent) {
                      ^~~~~~~~~~~~~~~~~~~~
item.cpp:1107:58: error: passing ‘const ItemType’ as ‘this’ argument discards qualifiers [-fpermissi                                                                                                                                         ve]
     s << "Inc.Magic " << std::showpos << it.getAbilities()->increment[MAGIC_PERCENT] << std::noshow                                                                                                                                         pos;
                                                          ^
In file included from item.h:28:0,
                 from item.cpp:21:
items.h:121:14: note:   in call to ‘Abilities* ItemType::getAbilities()’
   Abilities* getAbilities() {if(!abilities) abilities = new Abilities; return abilities;}
              ^~~~~~~~~~~~
item.cpp:1429:22: error: ‘struct Abilities’ has no member named ‘increasemagicpercent’
    if (it.abilities->increasemagicpercent) {
                      ^~~~~~~~~~~~~~~~~~~~
item.cpp:1437:58: error: passing ‘const ItemType’ as ‘this’ argument discards qualifiers [-fpermissi                                                                                                                                         ve]
     s << "Inc.Magic " << std::showpos << it.getAbilities()->increment[MAGIC_PERCENT] << std::noshow                                                                                                                                         pos;
                                                          ^
In file included from item.h:28:0,

When i put look like bellow, i can compile, but nothing appear when i look:

C++:
            if (it.abilities->increment[MAGIC_VALUE]) {
                if (begin) {
                    begin = false;
                    s << " (";
                } else {
                    s << ", ";
                }

                s << "magic damage percent + " << std::showpos << it.abilities->increment[MAGIC_VALUE] << std::noshowpos;
            }
 
C++:
if (it.abilities->increment[MAGIC_VALUE])) {
                if (begin) {
                    begin = false;
                    s << " (";
                }
                else {
                    s << ", ";
                }


                s << "magic damage percent + " << std::showpos << it.abilities->increment[MAGIC_VALUE]) << '%' << std::noshowpos;
            }

or

C++:
if (it.abilities && it.abilities->increment[MAGIC_VALUE] != 0) {
    if (begin) {
        begin = false;
        s << " (";
    } else {
        s << ", ";
    }

    s << "magic damage percent + " << std::showpos << it.abilities->increment[MAGIC_VALUE] << '%' << std::noshowpos;
}
 
Go to item.h, find the line 'if(it.abilities->speed)' and add below it. Then, search for that line again and repeat the addition.

C++:
if (it.abilities->increasemagicpercent) {
    if (begin) {
        begin = false;
        s << " (";
    } else {
        s << ", ";
    }

    s << "Inc.Magic " << std::showpos << (int32_t)(it.getAbilities()->increment[MAGIC_PERCENT]) << std::noshowpos;
}

or

C++:
if (it.abilities->increasemagicpercent) {

    if (begin) {

        begin = false;

        s << " (";

    } else {

        s << ", ";

    }



    s << "Inc.Magic " << std::showpos << (int32_t)(it.abilities->increasemagicpercent) << std::noshowpos;

}

I'm not sure which one is right... If it doesn't work, you can try removing 'int32_t', keeping the rest and compiling. Then, enter the game and check the item to display the 'inc magic' attribute correctly or not.

C++:
if (it.abilities->increasemagicpercent) {
    if (begin) {
        begin = false;
        s << " (";
    } else {
        s << ", ";
    }

    s << "Inc.Magic " << std::showpos << it.abilities->increasemagicpercent << std::noshowpos;
}

or

C++:
if (it.abilities->increasemagicpercent) {
    if (begin) {
        begin = false;
        s << " (";
    } else {
        s << ", ";
    }

    s << "Inc.Magic " << std::showpos << it.getAbilities()->increment[MAGIC_PERCENT] << std::noshowpos;
}
Work in this way:

C++:
            if (it.abilities->increment[MAGIC_PERCENT]) {
                if (begin) {
                    begin = false;
                    s << " (";
                } else {
                    s << ", ";
                }

                s << "magic damage percent " << std::showpos << it.abilities->increment[MAGIC_PERCENT] << std::noshowpos;
            }

But i want to improve message, looks ugly and bad format:

23:01 You see a nightmare robe +10 (Arm:35, magic level +3, magic damage percent +110).
It can only be wielded properly by sorcerers and druids.
It weighs 30.00 oz.

I want to leave Magic Damage + 10%.
Post automatically merged:

C++:
if (it.abilities->increment[MAGIC_VALUE])) {
                if (begin) {
                    begin = false;
                    s << " (";
                }
                else {
                    s << ", ";
                }


                s << "magic damage percent + " << std::showpos << it.abilities->increment[MAGIC_VALUE]) << '%' << std::noshowpos;
            }

or

C++:
if (it.abilities && it.abilities->increment[MAGIC_VALUE] != 0) {
    if (begin) {
        begin = false;
        s << " (";
    } else {
        s << ", ";
    }

    s << "magic damage percent + " << std::showpos << it.abilities->increment[MAGIC_VALUE] << '%' << std::noshowpos;
}
Thanks for brainstorming, solved with this code:

C++:
            if (it.abilities->increment[MAGIC_PERCENT]) {
                if (begin) {
                    begin = false;
                    s << " (";
                } else {
                    s << ", ";
                }

                s << "Magic Damage " << std::showpos << it.abilities->increment[MAGIC_PERCENT] -100 << std::noshowpos << "%";
            }
 
Last edited:
Work in this way:

C++:
            if (it.abilities->increment[MAGIC_PERCENT]) {
                if (begin) {
                    begin = false;
                    s << " (";
                } else {
                    s << ", ";
                }

                s << "magic damage percent " << std::showpos << it.abilities->increment[MAGIC_PERCENT] << std::noshowpos;
            }

But i want to improve message, looks ugly and bad format:

23:01 You see a nightmare robe +10 (Arm:35, magic level +3, magic damage percent +110).
It can only be wielded properly by sorcerers and druids.
It weighs 30.00 oz.

I want to leave Magic Damage + 10%.

Haven't tested it, but you could play around with this:
if (it.abilities->increment[MAGIC_PERCENT] > 100) {
and
if (it.abilities->increment[MAGIC_PERCENT] < 100) {
or something along those lines.

You basically give two different messages depending on if the result is positive or negative.
Just don't forget to have an "else" statement as well for when it is exactly 100.

You could also look into the "it.abilities->increment[MAGIC_PERCENT]" source and see if you can't do some magic in there.
To find it I would just start searching "MAGIC_PERCENT" and see if I find anything interesting.
Post automatically merged:

Yeah, my bad, of course it's as simple as just adding "-100", man I'm tired. Derp 🤪
 
Last edited:

Similar threads

Back
Top