07-27-2022, 06:29 PM
4 hours ago, nicolasg said:
I am creating the code to implement a life bar above the characters. My question is: Does anyone know if the server constantly send the life values of the other characters?
On the server side I found:
if(ch->IsSearchLife() == true)
{
if(ch->m_targetPC != NULL && ch->m_targetPC->m_type != MSG_CHAR_UNKNOWN)
{
CPC* targetPC = ch->m_targetPC;
CNetMsg::SP rmsg(new CNetMsg);
UpdateClient::CharHpInfoMsg(rmsg, targetPC->m_index, targetPC->m_maxHP, targetPC->m_hp);
SEND_Q(rmsg, ch->m_desc);
}
}
I know that the server sends the values if a target is selected and you have the life searcher activated, but apart from that, the server sends the values constantly or only if the client requests them?
--UPDATE--
I came to the conclusion that the server only sends hp values in 3 cases, If the life searcher object is activated, If a player attacks another Or if a player enters the render range of another player(AppearMsg), so Showing these values would imply sending packets constantly and possibly consuming considerable bandwidth...
As for your question about if client store a list of other clients attribute inside, of course the reply is: no.
That's because is a server side task of course, is usless interrogate the server (which already has tons of other works to do) to send unused data. Of course, every client just load the information regarding the current char, otherwise it need to ask at the server what it needed, also because the server update all the stats in real time which should be sended at all clients, and that became a lot of resources lost, for something which probably will never be used.
So, in my opinion, implementation of HP bar is pretty stupid idea (also because you only interact with 1 object at time, and even in the PVP where you can think is useful, instead it may confuse the player with tons of HUD which already exist like title/nick/guild/effect...) ... at most you can restrict that and load the data of entities inside the radar (which should be the object reachable by the user), but still tons of data, and usless work for the server for a stupid system imo

