• 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++ Item Attributes not working as intended TFS 1.3

charlyhustle

Member
Joined
Dec 9, 2011
Messages
47
Reaction score
6
Hey guys,

i recently posted in requests, asking for a system that lets you do stuff like this:

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>

I was pointed to Nekiro's system (Adding features from #998 by nekiro · Pull Request #2807 · otland/forgottenserver (https://github.com/otland/forgottenserver/pull/2807/files)) which I am using now.
I compiled it without errors and adding the attributes in the items.xml didn't give me errors as well.

The damage increase works fine for "autoattacks" but not for spells or runes. The healing increase doesn't work at all.
Then i discovered, that the already built in crit/manaleech/lifeleech system doesnt work either, so i figured it has to be an issue with my source files in general.

I'm also using this:
Feature - Reborn System | Reset level, increase power, set exclusive items, spells, houses, web and more! (https://otland.net/threads/reborn-system-reset-level-increase-power-set-exclusive-items-spells-houses-web-and-more.245808/)

Maybe there's the problem?
I've spent the last 2 days trying to understand the code but I'm getting nowhere.

I can't post all my source files here because it will exceed the character limit but i can provide them at any time if needed.
I would greatly appreciate any help!

Thanks in advance!
 
show me the items.xml entry of item 38848
XML:
<item id="38848" article="a" name="diamond star ring">
        <attribute key="weight" value="90" />
        <attribute key="slotType" value="ring" />
        <attribute key="absorbPercentAll" value="90" />
        <attribute key="boostPercentAll" value="2000" />
        <attribute key="boostPercentHealing" value="2000" />
</item>
 
XML:
<item id="38848" article="a" name="diamond star ring">
        <attribute key="weight" value="90" />
        <attribute key="slotType" value="ring" />
        <attribute key="absorbPercentAll" value="90" />
        <attribute key="boostPercentAll" value="2000" />
        <attribute key="boostPercentHealing" value="2000" />
</item>
2000%?
 
What u mean dont work? Dont give bonuses or not visible on item look?
Add
XML:
<attribute key="showattributes" value="1" />
The bonuses are displayed perfectly. For the crit/leech as well as for healing and damage bonuses. But you don't actually get the bonus. The only thing that is working is the damage reduction and the damage bonus on "autoattacks".
Post automatically merged:

ring.png
To make it more clear. This is how the ring is displaying the following ingame:

XML:
<item id="38848" article="a" name="diamond star ring">
        <attribute key="weight" value="90" />
        <attribute key="slotType" value="ring" />
        <attribute key="absorbPercentAll" value="90" />
        <attribute key="showattributes" value="true" />
        <attribute key="boostPercentAll" value="2000" />
        <attribute key="boostPercentHealing" value="90" /> <!--Changed this value to 90% to see if a value over 100 is causing the issue-->
</item>

Damage reduction works perfectly (absorbPercentAll)

Healing isn't working at all

Everything else is just working for autoattacks and not for spells/runes/etc
 
Last edited:
The bonuses are displayed perfectly. For the crit/leech as well as for healing and damage bonuses. But you don't actually get the bonus. The only thing that is working is the damage reduction and the damage bonus on "autoattacks".
Post automatically merged:

View attachment 56629
To make it more clear. This is how the ring is displaying the following ingame:

XML:
<item id="38848" article="a" name="diamond star ring">
        <attribute key="weight" value="90" />
        <attribute key="slotType" value="ring" />
        <attribute key="absorbPercentAll" value="90" />
        <attribute key="showattributes" value="true" />
        <attribute key="boostPercentAll" value="2000" />
        <attribute key="boostPercentHealing" value="90" /> <!--Changed this value to 90% to see if a value over 100 is causing the issue-->
</item>

Damage reduction works perfectly (absorbPercentAll)

Healing isn't working at all

Everything else is just working for autoattacks and not for spells/runes/etc
What you use to "heal? U must know the potion or spell must trigger "COMBAT_HEALING" to make this bonus work..
 
Edit: I just screwed up my last post...

Here's what I wrote:

I tested it with "exura", "exura san" and regular health potions. I haven't touched any of these scripts.
 
Last edited:
The bonuses are displayed perfectly. For the crit/leech as well as for healing and damage bonuses. But you don't actually get the bonus. The only thing that is working is the damage reduction and the damage bonus on "autoattacks".
Post automatically merged:

View attachment 56629
To make it more clear. This is how the ring is displaying the following ingame:

XML:
<item id="38848" article="a" name="diamond star ring">
        <attribute key="weight" value="90" />
        <attribute key="slotType" value="ring" />
        <attribute key="absorbPercentAll" value="90" />
        <attribute key="showattributes" value="true" />
        <attribute key="boostPercentAll" value="2000" />
        <attribute key="boostPercentHealing" value="90" /> <!--Changed this value to 90% to see if a value over 100 is causing the issue-->
</item>

Damage reduction works perfectly (absorbPercentAll)

Healing isn't working at all

Everything else is just working for autoattacks and not for spells/runes/etc

For some reasons it does not show for me
 
For some reasons it does not show for me
XML:
<attribute key="showattributes" value="1" />
This should do the trick for you

Yesterday I fetched the latest tfs resources and started fresh. I compiled everything including the custom item attributes and it's still not working. The good news is that at least the crit/leech is working now so that was probably not working because of the rebirth system I used before.
I don't know why the item attribute system is not working for me. It's really starting to get frustrating.
 
I might be wrong but these boosts were made to work only with regular hits and not with everything like critical/mana/health/leech, @Nekiro can enlighten this tho
But they should work with spells, right? Which they don't unfortunately.
Post automatically merged:

Okay I just tested some more and i discovered that the problem isn't the spells but the damage type. ALL physical damage works fine. Spells like exori, exori gran, etc are getting buffed and attacks with wands and rods are not getting buffed. So i guess the problem is that just the physical damage is getting buffed and thats why healing is also not working. I'm diving back into my sources now and try to fix it but maybe @Evil Puncker or @Nekiro already know what to do here.
 
Last edited:
I don't really remember, but I wrote "code was tested and it works", so either you are using it wrong or you are using it in specific way that doesn't work.

Remember to register every single item using attributes in movements.
 
I don't really remember, but I wrote "code was tested and it works", so either you are using it wrong or you are using it in specific way that doesn't work.

Remember to register every single item using this attributes in movements.
I took the code from Adding features from #998 by nekiro · Pull Request #2807 · otland/forgottenserver (https://github.com/otland/forgottenserver/pull/2807/files)
I didn't change anything else. I triple checked every single line of code.
I registered every item in movements.xml.
Still only physical damage is getting boosted.
Post automatically merged:

I can stream this on discord to anyone if that helps them believing me that I did everything according to Nekiro's PR and nothing else
 
Last edited:
I took the code from Adding features from #998 by nekiro · Pull Request #2807 · otland/forgottenserver (https://github.com/otland/forgottenserver/pull/2807/files)
I didn't change anything else. I triple checked every single line of code.
I registered every item in movements.xml.
Still only physical damage is getting boosted.
Post automatically merged:

I can stream this on discord to anyone if that helps them believing me that I did everything according to Nekiro's PR and nothing else
Honestly not to be rude, but this makes no sense at all that only physical is getting boosted (physical and every other combat type is using the same code in Creature::blockHit)
 
Honestly not to be rude, but this makes no sense at all that only physical is getting boosted (physical and every other combat type is using the same code in Creature::blockHit)
It's not rude don't worry :)
It might make no sense but thats how it is.

Here's my blockHit method:
C++:
BlockType_t Creature::blockHit(Creature* attacker, CombatType_t combatType, int32_t& damage,
                               bool checkDefense /* = false */, bool checkArmor /* = false */, bool /* field = false */, bool /* ignoreResistances = false */)
{
    BlockType_t blockType = BLOCK_NONE;

    if (isImmune(combatType)) {
        damage = 0;
        blockType = BLOCK_IMMUNITY;
    } else if (checkDefense || checkArmor) {
        bool hasDefense = false;

        if (blockCount > 0) {
            --blockCount;
            hasDefense = true;
        }

        if (checkDefense && hasDefense && canUseDefense) {
            int32_t defense = getDefense();
            damage -= uniform_random(defense / 2, defense);
            if (damage <= 0) {
                damage = 0;
                blockType = BLOCK_DEFENSE;
                checkArmor = false;
            }
        }

        if (checkArmor) {
            int32_t armor = getArmor();
            if (armor > 3) {
                damage -= uniform_random(armor / 2, armor - (armor % 2 + 1));
            } else if (armor > 0) {
                --damage;
            }

            if (damage <= 0) {
                damage = 0;
                blockType = BLOCK_ARMOR;
            }
        }

        if (Player* attackerPlayer = attacker->getPlayer()) {
            for (int32_t slot = CONST_SLOT_FIRST; slot <= CONST_SLOT_LAST; ++slot) {
                if (!attackerPlayer->isItemAbilityEnabled(static_cast<slots_t>(slot))) {
                    continue;
                }

                Item* item = attackerPlayer->getInventoryItem(static_cast<slots_t>(slot));
                if (!item) {
                    continue;
                }

                const int16_t& boostPercent = item->getBoostPercent(combatType);
                if (boostPercent != 0) {
                    damage += std::round(damage * (boostPercent / 100.));
                }
            }
        }

        if (damage <= 0) {
            damage = 0;
            blockType = BLOCK_ARMOR;
        }

        if (hasDefense && blockType != BLOCK_NONE) {
            onBlockHit();
        }
    }

    if (attacker) {
        attacker->onAttackedCreature(this);
        attacker->onAttackedCreatureBlockHit(blockType);
    }

    onAttacked();
    return blockType;
}
Post automatically merged:

By now I'm pretty sure this just doesnt work with the latest TFS sources anymore.
 
Last edited:
Back
Top