Imbuements - It does not save attributes when disconnecting and reconnecting.
soyfabi opened this issue · 11 comments
Added Tibia Imbuements
3b989ce
@ohman92
I've been implementing this system on a [TFS 1.5 Downgrade], and the attributes, life, mana, imbue duration, everything works perfectly, there is no problem with that.
The problem occurs when you have an imbued item equipped, when you disconnect and reconnect the item it is as if it loses the attribute.
The solution is to unequip the imbued item, log back in, and equip it again.
Try using an onLogin(player) to place
addChanceToImbuement(player, object, team)
But I was not successful.
Well the base player has Skill 10 Axe, when the Basic Slash +1 Axe imbued Mage hat is equipped it goes to 11, logging back in with the item equipped the player gets the skill to 10, unequipping it the item goes to 9.
PD: I must emphasize that I have not made any modifications, I only followed the commits to add imbuments and nothing more.
Have you tried with the latest commits? Specifically the one that is supposed to fix an issue we were having with adding and removing attributes to equipped items?
How do you know for sure you have all the commits, could you list all the commits you got the code from? Imbuements has had many commits fixing and changing things, it does not only consist of a single or even just two commits, there must be almost a dozen by now.
Yes, I have implemented all the commits.
From this commit onwards
Feature: Imbuements! Includes Imbuement creation and full api in lua.
e1b3f35
all the commit that had to do with imbuement
57c4c72
The last commit was this
270794b
and the problem persists, when you log back in with an imbued item, you lose the ability.
I tested this with clean TFS 1.5 Nekiro to check if it was an issue with my current project and the same thing happens.
e1b3f35
08d8d43
0293ab7
5364f76
99cc75b
0c48e96
863f414
422fbb5
21c5ff3
71984ba
57c4c72
270794b
Those are all the ones I know for sure that contain code related to imbuements. Please make sure you have done all of them in the correct order (they are not listed in correct order above, you will need to go by date).
I would start with this one below first though.
This one isnt an "imbuement fix", but it is definitely needed, as it properly removes equipment during death or logout, and is most likely the one you need
If this doesnt fix your problem, I suggest opening every one of those commits up in their own tab, rearranging them in the order they were applied, and applying them all one by one in order... we dont have the problem you are facing here for black tek... I assume its an issue with either serializing or just updating the client about the skills/stats change... most likely because you dont have that bug fix up there that doesnt have anything to do with imbuements.
I was looking at the commits carefully.
And I still don't have success
for (int32_t slot = CONST_SLOT_FIRST; slot <= CONST_SLOT_LAST; ++slot) { Item* item = inventory[slot]; if (item) { g_moveEvents->onPlayerDeEquip(this, item, static_cast<slots_t>(slot)); std::cout << "Check when disconnecting player: " << getName() << std::endl; } }
On this, place a
std::cout << "Check when disconnecting player: " << getName() << std::endl;
nothing at all...
Isn't a solution possible using Lua?
something like function onLogin(player), That when the player logs in, if it has imbued items then the attributes are applied.
Meanwhile, I'm waiting for some other user who uses tfs 1.5 downgrade to review this imbuements system, to see if the same thing happens to them or if it's just me.
for (int32_t slot = CONST_SLOT_FIRST; slot <= CONST_SLOT_LAST; ++slot) { Item* item = inventory[slot]; if (item) { g_moveEvents->onPlayerDeEquip(this, item, static_cast<slots_t>(slot)); std::cout << "Check when disconnecting player: " << getName() << std::endl; } }
That code does not exist in my imbuements. I honestly think the issue has to be with the serialization and deserialization. I would try putting prints where the imbuements are supposed to be deserialized upon login (talking about source edit) I think its in item.cpp if I remember correctly. Basically, if I were you, and everything compiled fine, just didnt save, I would put prints everywhere until I found the problem.
hmm, I made a repository and did everything again, there were a total of 12 commits in imbuements.
I followed all the steps of the commits 1 by one and the problem persists.
I don't know if sharing a repository is allowed:
https://github.com/soyfabi/TFS-1.5-Imbuements/commits/main/
Let's see if someone finds a solution for tfs 1.5 later :/
I’m on vacation but I took a quick look at your rep.
I don’t know what function is adding the skills when login but I know offlinetraining in player.cpp does “sendSkill” and runs when login. And that is commented out in your rep. Maybe try to uncomment it. I’m new to programming so take my advice with that in mind 😊
Have a good vacation.
I also don't know which one is responsible for sending the skills when you log in, but that about Offline Training is about the statues, my server doesn't have those actions.
Searching for the function
sendSkills
It is in protocolgame.ccp
void ProtocolGame::sendAddCreature(const Creature creature, const Position& pos, int32_t stackpos, bool isLogin)*
I think that this is responsible for loading the skills when you log in.
I've been testing for a while
and the imbuments of
Imbuement::isResist()
Imbuement::isDamage()
ImbuementType::IMBUEMENT_TYPE_CAPACITY_BOOST :
ImbuementDecayType::IMBUEMENT_DECAY_EQUIPPED;
ImbuementDecayType::IMBUEMENT_DECAY_INFIGHT;
They all work great when you reconnect, the attribute remains
The ones that don't work are:
Imbuement::isSkill()
Imbuement::isSpecialSkill()
IMBUEMENT_TYPE_SPEED_BOOST:
I don't know what's happening, when you reconnect you don't get the attribute :/
@soyfabi Good call sharing your repository. I was able to find your problem. The problem is not with the imbuements themselves, you did a very good and thorough job at adding them to 1.5 downgrade! Well done and good for you! The issue is that inventory update is not applied during login. This is a fix that was added by sarah on TFS. Its a one liner, but it literally resolves your problem, and any other problems related to item abilities on login.
Here is the commit you are looking for, I already checked your sources to confirm you were missing this line, adding this line should 100 percent resolve your problem, if it does, please close this issue as resolved if you are able, if not, just let me know its resolved and I will close this issue.
otland/forgottenserver@a03b30f
Cheers!
Thank you very much, if that solved my problem 100%, thank you for your time. @Codinablack @ohman92
Solution:
otland/forgottenserver@a03b30f