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

C++ TFS 1.3 Item Attributes

charlyhustle

Member
Joined
Dec 9, 2011
Messages
46
Reaction score
6
Hey everyone,

I need a system that allows me to do something like this:

In items.xml:
XML:
<item id="1234" article="an" name="example armor">
        <attribute key="weight" value="10000" />
        <attribute key="armor" value="10" />
        <attribute key="slotType" value="body" />
        <attribute key="damageReduction" value="10" /> <(percentage, reduces all damage taken)
        <attribute key="damageIncrease" value="10" / (percentage, increases all damage dealt)
        <attribute key="healingIncrease" value="10" /> (percentage, increases all healing received)
</item>

Is there already a working system, that I missed?
If not, maybe there is something similar, where I can just change the code slightly to fit my needs.

Any help would be greatly appreciated and thanks in advance!
 

Ascuas Funkeln

Rakkedo Game
Joined
Apr 14, 2013
Messages
516
Solutions
30
Reaction score
268
Location
Poland
GitHub
AscuasFunkeln
Hey everyone,

I need a system that allows me to do something like this:

In items.xml:
XML:
<item id="1234" article="an" name="example armor">
        <attribute key="weight" value="10000" />
        <attribute key="armor" value="10" />
        <attribute key="slotType" value="body" />
        <attribute key="damageReduction" value="10" /> <(percentage, reduces all damage taken)
        <attribute key="damageIncrease" value="10" / (percentage, increases all damage dealt)
        <attribute key="healingIncrease" value="10" /> (percentage, increases all healing received)
</item>

Is there already a working system, that I missed?
If not, maybe there is something similar, where I can just change the code slightly to fit my needs.

Any help would be greatly appreciated and thanks in advance!
items.cpp -> defined what u need


Item using
XML:
<attribute key="absorbPercentAll" value="7" />
<attribute key="absorbPercentFire" value="8" />
<attribute key="absorbPercentPhysical" value="88" />
 

Evil Puncker

prolonged absenteeism
TFS Developer
Joined
May 30, 2009
Messages
8,040
Solutions
215
Reaction score
3,882
Solution

Levi999x

AoT
Joined
Dec 14, 2017
Messages
1,796
Solutions
35
Reaction score
997
Location
Germany

Levi999x

AoT
Joined
Dec 14, 2017
Messages
1,796
Solutions
35
Reaction score
997
Location
Germany
you can use it already, I'm using it :p

I just did read something about its not safe to use it?
Nekiro: "I will rework this pr, because using consts as numbers in custom attributes is unsafe, cause people can overwrite that by setting number values in custom attribute by accident. Safer approach is to use string values."
 

Nekiro

Legendary OT User
TFS Developer
Joined
Sep 7, 2015
Messages
2,512
Solutions
116
Reaction score
1,774
@Nekiro Will there be a "rewrite" soon?
Otherwise I would add it to my server :D I like it
It's working fine the only downside and why I don't want it to be merged this way is the possibilty that by using setCustomAttribute you reuse reserved numbers and break the system in the process. (0, 1, 2, 3 ITEM_CUSTOMATTRIBUTE_NONE, ITEM_CUSTOMATTRIBUTE_REFLECTPERCENTPHYSICAL ... respectively.)
If you block these ids (or just keep them in mind) from using in setCustomAttribute, then you are free to use the code. It should work.
I wanted to rework it into using strings, which is harder to overwrite, but thinking about it now, I could have just reserved ids from 0 to the last attribute in setCustomAttribute (like unique ids are prohibited from being set)
 
Last edited:
OP
OP
charlyhustle

charlyhustle

Member
Joined
Dec 9, 2011
Messages
46
Reaction score
6
this might help you:


except the healing part
Correct me if I'm wrong but as far as I can see the healing part is also implemented, isn't it?
C++:
ITEM_CUSTOMATTRIBUTE_BOOSTPERCENTHEALING

All in all looks really nice and if Nekiro says it's working fine I'm gonna use it :)

Just a couple of things. If I wanna do something like allDamageReduction can I handle that with the reflect attribute?
And if I wanna do allDamageIncrease to say 10% do i have to set all boostPercent types to 10%?
 

Nekiro

Legendary OT User
TFS Developer
Joined
Sep 7, 2015
Messages
2,512
Solutions
116
Reaction score
1,774
Correct me if I'm wrong but as far as I can see the healing part is also implemented, isn't it?
C++:
ITEM_CUSTOMATTRIBUTE_BOOSTPERCENTHEALING

All in all looks really nice and if Nekiro says it's working fine I'm gonna use it :)

Just a couple of things. If I wanna do something like allDamageReduction can I handle that with the reflect attribute?
And if I wanna do allDamageIncrease to say 10% do i have to set all boostPercent types to 10%?
If you are talking about setting them dynamically then you have to iterate all boosts enums and set them to value. If items.xml then you have premade strings for it, boostpercentall is one of them.
 
OP
OP
charlyhustle

charlyhustle

Member
Joined
Dec 9, 2011
Messages
46
Reaction score
6
If you are talking about setting them dynamically then you have to iterate all boosts enums and set them to value. If items.xml then you have premade strings for it, boostpercentall is one of them.
Awesome! Thank you so much for releasing this!

oh sorry, it has been a year already I forgot it
No problem :p thanks for your help. It's really much appreciated!
 
OP
OP
charlyhustle

charlyhustle

Member
Joined
Dec 9, 2011
Messages
46
Reaction score
6
@Nekiro I tried to understand your code but I'm stuck on 2 things.

First in item.cpp you got the following:

C++:
else {
                if (begin) {
                    begin = false;
                    s << " (";
                }
                else {
                    s << ", ";
                }

                s << "boost all " << std::showpos << show << std::noshowpos << '%';
            }

so if I do something like:

XML:
<attribute key="boostPercentAll" value="100" />

shouldn't it say "boost all + 100%"? because it just lists all of the attributes one by one.

Second in items.cpp you got:

C++:
case ITEM_PARSE_BOOSTPERCENTALL: {
                    int16_t value = pugi::cast<int16_t>(valueAttribute.value());
                    for (auto& i : abilities.boostPercent) {                      
                        i += value;
                    }
                    break;
                }

how could I exclude the healing boost from "all"?


Edit: So I noticed spells aren't getting buffed at all. Neither damage nor healing.
 
Last edited:
Top