Mateus Robeerto
Legendary OT User
Please watch the videos where magic damage percentage is correct. However, we have a problem: when passing over fields of fire, energy, poison, etc., the server crashes. Also, when monsters try to attack me, a server crash also occurs. I can't identify the source of this bug and would like someone's help to adapt correctly to TFS 1.5. If someone is willing, they can take the code and make the necessary adaptations. When it's working properly, please let me know here and where I can fix bugs. I thank!
The author released the codes and passed them to me. These codes were for TFS 1.2 in its original source. I tried adapting them for TFS 1.5, but the problem persists, causing the server to crash, as I mentioned earlier.
check the item, the 'increaseMagicPercent' function is working correctly and correctly displaying 'INC MAGIC', etc
You see teste robe (Arm:18, Inc.Magic +150%).
It weighs 71.00 oz
In the second video, when I scroll over energy, fire, etc., the server crashes
In the third video, when the monster tried to attack me, the server also crashed
Here are the codes I will make available:
In game.cpp file
after.
after.
after.
after.
after.
after.
The percentage magic damage is working perfectly, however, the problem occurs when I step over fire, energy, etc., or when a monster attacks me, resulting in the server crash. Could someone review the codes and fix them here or via GitHub? Thank you for your attention.
@Evil Puncker @Nekiro @Sarah Wesker @Roddet @Xikini
Sorry, I'm not very good at C++ so xD
Note: Without source modifications, everything is working normally and there is no percentage magic damage. However, when making changes to the desired source, the server is crashing.
The author released the codes and passed them to me. These codes were for TFS 1.2 in its original source. I tried adapting them for TFS 1.5, but the problem persists, causing the server to crash, as I mentioned earlier.
check the item, the 'increaseMagicPercent' function is working correctly and correctly displaying 'INC MAGIC', etc
You see teste robe (Arm:18, Inc.Magic +150%).
It weighs 71.00 oz
LUA:
item id="41195" name="teste robe">
<attribute key="weight" value="7100"/>
<attribute key="armor" value="18"/>
<attribute key="slotType" value="body"/>
<attribute key="increaseMagicPercent" value="150"/>
</item>
In the second video, when I scroll over energy, fire, etc., the server crashes
In the third video, when the monster tried to attack me, the server also crashed
Here are the codes I will make available:
In game.cpp file
after.
add. Fix made by @lurskyC++:Player* attackerPlayer; if (attacker) { attackerPlayer = attacker->getPlayer(); } else { attackerPlayer = nullptr; } Player* targetPlayer = target->getPlayer(); if (attackerPlayer && targetPlayer && attackerPlayer->getSkull() == SKULL_BLACK && attackerPlayer->getSkullClient(targetPlayer) == SKULL_NONE) { return false; } damage.primary.value = std::abs(damage.primary.value); damage.secondary.value = std::abs(damage.secondary.value); int32_t healthChange = damage.primary.value + damage.secondary.value; if (healthChange == 0) { return true; }
In item.cpp fileC++:// Inc Magic by lursky auto originList = { ORIGIN_RANGED, ORIGIN_MELEE, ORIGIN_CONDITION }; auto it = std::find(originList.begin(), originList.end(), damage.origin); if (attackerPlayer && it == originList.end()) { int32_t magicPercentBonus = 0; for (int32_t slot = CONST_SLOT_FIRST; slot <= CONST_SLOT_LAST; ++slot) { Item* item = attackerPlayer->inventory[slot]; if (item) { const ItemType& iiType = Item::items[item->getID()]; const int32_t& slotPosition = item->getSlotPosition(); if (iiType.increaseMagicPercent && (iiType.slotPosition & slotPosition)) { magicPercentBonus += iiType.increaseMagicPercent; } } } if (magicPercentBonus > 0) { damage.primary.value += damage.primary.value * (magicPercentBonus / 100.0f); } } }
after.
add.C++:if (it.abilities) { for (uint8_t i = SKILL_FIRST; i <= SKILL_LAST; i++) { if (!it.abilities->skills[i]) { continue; } if (begin) { begin = false; s << " ("; } else { s << ", "; } s << getSkillName(i) << ' ' << std::showpos << it.abilities->skills[i] << std::noshowpos; }
In items.cpp fileC++:if (it.increaseMagicPercent) { if (begin) { begin = false; s << " ("; } else { s << ", "; } s << "Inc.Magic " << std::showpos << it.increaseMagicPercent << '%' << std::noshowpos; }
after.
add:C++:{"worth", ITEM_PARSE_WORTH},
Again, in the items.cpp file:C++:{ "increasemagicpercent", ITEM_PARSE_INCREASEMAGICPERCENT },
after.
add.C++:case ITEM_PARSE_SUPPRESSCURSE: { if (valueAttribute.as_bool()) { abilities.conditionSuppressions |= CONDITION_CURSED; } break; }
In items.h fileC++:case ITEM_PARSE_INCREASEMAGICPERCENT: { it.increaseMagicPercent = pugi::cast<int32_t>(valueAttribute.value()); break; }
after.
add.C++:uint64_t worth = 0;
Again, in the items.h file:C++:int32_t increaseMagicPercent = 0;
after.
add:C++:ITEM_PARSE_WORTH,
C++:ITEM_PARSE_INCREASEMAGICPERCENT,
The percentage magic damage is working perfectly, however, the problem occurs when I step over fire, energy, etc., or when a monster attacks me, resulting in the server crash. Could someone review the codes and fix them here or via GitHub? Thank you for your attention.
@Evil Puncker @Nekiro @Sarah Wesker @Roddet @Xikini
Sorry, I'm not very good at C++ so xD
Note: Without source modifications, everything is working normally and there is no percentage magic damage. However, when making changes to the desired source, the server is crashing.
Last edited: