View Single Post
  #3  
Old 07-12-2022, 05:43 PM
Ryuichi
Fire Beetle
 
Join Date: Jul 2008
Location: Colorado
Posts: 3
Default

I believe this to be a bug in the below code, and will post in the Bug section accordingly. For the sake of others, I'll include my findings here as well.

In mob.cpp, in the Mob::SendHPUpdate function, the cur_hp and max_hp values set in the packet are reduced by any HP gained from items. This is resulting in the client showing 2x the damage taken, both in the inventory window and on the health bar.

Code:
void Mob::SendHPUpdate(bool force_update_all)
{

	// If our HP is different from last HP update call - let's update selves
	if (IsClient()) {
		if (current_hp != last_hp || force_update_all) {

			LogHPUpdate(
				"[SendHPUpdate] Update HP of self [{}] current_hp [{}] max_hp [{}] last_hp [{}]",
				GetCleanName(), current_hp, max_hp, last_hp
			);

			auto client_packet     = new EQApplicationPacket(OP_HPUpdate, sizeof(SpawnHPUpdate_Struct));
			auto *hp_packet_client = (SpawnHPUpdate_Struct *) client_packet->pBuffer;

			hp_packet_client->cur_hp = static_cast<uint32>(CastToClient()->GetHP() - itembonuses.HP);
			hp_packet_client->spawn_id = GetID();
			hp_packet_client->max_hp = CastToClient()->GetMaxHP() - itembonuses.HP;

			CastToClient()->QueuePacket(client_packet);

			safe_delete(client_packet);

			ResetHPUpdateTimer();

			// Used to check if HP has changed to update self next round
			last_hp = current_hp;
		}
	}
	...
By making the following change, to remove the reduction of HP granted by items, the client is now showing values consistent with what the server is reporting.
Code:
hp_packet_client->cur_hp = CastToClient()->GetHP(); // static_cast<uint32>(CastToClient()->GetHP() - itembonuses.HP);
hp_packet_client->spawn_id = GetID();
hp_packet_client->max_hp = CastToClient()->GetMaxHP(); // CastToClient()->GetMaxHP() - itembonuses.HP;
Reply With Quote