I added my enchantment system in tfs 1.4, but i had problems, could anyone help?
When i remove the functions everything seems to work normally
movement.cpp
player.cpp
When i remove the functions everything seems to work normally
movement.cpp
forgottenserver/src/movement.cpp at 1.4 · otland/forgottenserver
A free and open-source MMORPG server emulator written in C++ - otland/forgottenserver
github.com
C++:
uint32_t MoveEvents::onPlayerEquip(Player* player, Item* item, slots_t slot, bool isCheck)
{
player->updateSpecialSkills();
if (g_events->eventPlayerOnEquipItem(player, item, slot, isCheck)) {
MoveEvent* moveEvent = getEvent(item, MOVE_EVENT_EQUIP, slot);
if (!moveEvent) {
return 1;
}
return moveEvent->fireEquip(player, item, slot, isCheck);
}
return false;
}
uint32_t MoveEvents::onPlayerDeEquip(Player* player, Item* item, slots_t slot)
{
player->updateSpecialSkills();
if (g_events->eventPlayerOnDeEquipItem(player, item, slot, false)) {
MoveEvent* moveEvent = getEvent(item, MOVE_EVENT_DEEQUIP, slot);
if (!moveEvent) {
return 1;
}
return moveEvent->fireEquip(player, item, slot, false);
}
return false;
}
player.cpp
C++:
void Player::updateSpecialSkills()
{
for (int32_t i = SPECIALSKILL_FIRST; i <= SPECIALSKILL_LAST; ++i) {
setVarSpecialSkill(static_cast<SpecialSkills_t>(i), 0);
}
for (uint8_t slot = CONST_SLOT_FIRST; slot < CONST_SLOT_LAST; slot++) {
Thing* thing = getThing(slot);
if (thing) {
Item* item = thing->getItem();
if (item) {
const ItemType& iType = Item::items[item->getID()];
for (int32_t i = SPECIALSKILL_FIRST; i <= SPECIALSKILL_LAST; ++i) {
if (iType.abilities->specialSkills[i]) {
int64_t skillValue = iType.abilities->specialSkills[i];
addVarSpecialSkill(static_cast<SpecialSkills_t>(i), skillValue);
}
const ItemAttributes::CustomAttribute* attr = item->getCustomAttribute(getSpecialSkillCustomAttribute(i));
if (attr) {
int64_t skillValue = boost::get<int64_t>(attr->value);
addVarSpecialSkill(static_cast<SpecialSkills_t>(i), skillValue);
}
}
}
}
}
sendSkills();
sendStats();
}
Attachments
-
WhatsApp Video 2023-10-12 at 12.52.03.gif22.9 MB · Views: 24 · VirusTotal