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

OTClient (problem) Updating health/mana bar otclient

Itutorial

Legendary OT User
Joined
Dec 23, 2014
Messages
2,435
Solutions
68
Reaction score
1,082
So I am creating a WoW-like stat system on items. Two of the stats are: Stamina, Wisdom they give the player more maximum health/mana.

I modified movevents.cpp so when someone puts an item on with +stamina or +wisdom it increases their maximum health/mana.

This is how it is coded now.

Code:
//skill modifiers
    for (int32_t i = SKILL_FIRST; i <= SKILL_LAST; ++i) {
        if (it.abilities->skills[i]) {
            player->setVarSkill(static_cast<skills_t>(i), it.abilities->skills[i]);
            player->sendSkills();

            if (i == SKILL_STAMINA) {
                player->setVarStats(static_cast<stats_t>(STAT_MAXHITPOINTS), +(it.abilities->skills[i] * 2));
                player->sendStats();
            }
          
            if (i == SKILL_WISDOM) {
                player->setVarStats(static_cast<stats_t>(STAT_MAXMANAPOINTS), +(it.abilities->skills[i] * 2));
                player->sendStats();
            }
        }
    }

This is the way the maxhitpoints attribute for items is used in the original movement.cpp code when equipping items.

The problem is the health/mana bar in otclient doesn't update with player->sendStats().

On my God character I can see my character has the added health/mana from the item by looking at myself.

Otclient doesn't correct the health/mana bar until I heal or get damaged.

How can I force otclient to update the health and mana bar once I put the armor on?

Otclient updates the skills window when armor is put on but is not updating the health bar window.

Any help is appreciated.
 
Solution
1. What you are trying to do already exists, there is a stats percent on items

2. The only way to update healthinfo bars is via stats packet (which is also updating the skills window), so you can check if you actually received the correct packet by doing some prints in both modules (game_healthinfo/game_skills).

--------------------------------------
You are making it a little hard reading your post, it took some time to understand your issue as you used a lot of new lines, and...
1. What you are trying to do already exists, there is a stats percent on items

2. The only way to update healthinfo bars is via stats packet (which is also updating the skills window), so you can check if you actually received the correct packet by doing some prints in both modules (game_healthinfo/game_skills).

--------------------------------------
You are making it a little hard reading your post, it took some time to understand your issue as you used a lot of new lines, and separated a lot of text.
Take my answer as an example of how to properly write/respond to a thread so others can actually help you :)

Sincerely,
Slavi
 
Solution
Thanks for the reply Slavi. I will check what you have said. It seems people like to read things differently. Most people say they hate a big paragraph.

Appreciate it man, really.

That did work. Now the only problem is when the player first logs in the health and mana info are not correct until I heal, get damaged, or take the armor off and put it back on. @Slavi Dodo
 
As I mentioned above, through prints you can know what is being sent.. TFS sends stats when firstly logged in, then when the player equips/deequips (or gains a stat via spell) it's sent to the client right away.)
I honestly, don't see a reason for this unless you have an error in your "healthinfo" module that maybe stops the execution of updating the bar.

Sincerely,
Slavi
 
I think I need TFS to sendStats after the player has connected and his game window is open to update it.

I am now able to put armor on and take it off and it corrects the health/mana bar as intended so we did get that fixed thank to you.
 

Similar threads

Back
Top