• Vote in May Mapping Competition to select a winner!
  • 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!

Jak wysyłać HP i manę w procentach

Crypton3

Retired
Joined
Mar 13, 2010
Messages
549
Best answers
0
Reaction score
125
Jak wysyłać manę i HP w procentach
Witam,
W tym poradniku opiszę co zrobić, aby mana jak i HP były wysyłane do klienta procentowo.
Szczególnie może się to przydać na serverach z większymi mnożnikami doświadczenia, gdzie, gdy ilość HP lub many gracza przekracza 65535 przekręca się licznik i zaczyna liczyć od nowa.

A więc tak:
W pliku protocolgame.cpp szukamy i zamieniamy:
Code:
	msg->put<uint16_t>(player->getHealth());
	msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MAXHEALTH));
Na:
Code:
	if (player->getPlayerInfo(PLAYERINFO_MAXHEALTH) > 0)
	{
		msg->put<uint16_t>(uint16_t(player->getHealth() * 100 / player->getPlayerInfo(PLAYERINFO_MAXHEALTH)));
		msg->put<uint16_t>(100);
	}
	else
	{
		msg->put<uint16_t>(0);
		msg->put<uint16_t>(0);
	}
Oraz:
Code:
	msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MANA));
	msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MAXMANA));
Na:
Code:
	if (player->getPlayerInfo(PLAYERINFO_MAXMANA) > 0)
	{
		msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MANA) * 100 / player->getPlayerInfo(PLAYERINFO_MAXMANA));
		msg->put<uint16_t>(100);
	}
	else
	{
		msg->put<uint16_t>(0);
		msg->put<uint16_t>(0);
	}
Gotowe ☺
 
Last edited:

Burczyk91

New Member
Joined
Jul 21, 2012
Messages
268
Best answers
0
Reaction score
3
Ciekawe, prawdopodobnie wprowadzę to u siebie. Dzięki :D
 

zakius

Enter the Ninja!
Joined
Apr 30, 2009
Messages
2,635
Best answers
0
Reaction score
61
Location
with Taiga
Tak serio to kompilacja tego jest trudniejsza niż zmiana kodu(w końcu to matematyka na poziomie chyba podstawówki...)
Ale MOŻE komuś się przyda
 

Nurcz

Banned User
Joined
Feb 14, 2013
Messages
39
Best answers
0
Reaction score
0
$$$$$_______________###
_$$$$$$______________#$
_$$$$$$____________$$$#$
_$$$$$$$________$$$$$$$$
__$$$$$$$_____$$$$$$$$$
__$$$$$$$____$$$$$$$$
__$$$$$$$__$$$$$$$$$
____$$$$$_$$$$$$______
_____$$$$$$$$__________
______$$$$$$$$$$$$$
____$$$$$$$$$$$$$$$$$
____$$$$$$$$$$$$___$$$
___$$$$$$$$$$$$$__$$$$$
___$$$$$$$$$$$$$$$$$$$$$
____$$$$$$$$$$$$$$$$$$$
_____$$$$$$$$$$$$$$$$$
________$$$$$$$$$$
______$$$$$$$$$$
 

stanczyk

Scripter
Joined
Nov 24, 2009
Messages
294
Best answers
0
Reaction score
2
Jak zrobić to pod serwer z highexp gdzie do reborna musisz wbić 712k lvl i powiedzmy, że masz 300 rebornów i dalej będzie działało?
 

zygus0000

New Member
Joined
May 12, 2013
Messages
54
Best answers
0
Reaction score
1
Możesz dac ten plik bo ja nie wiem ale mi bład wyskakuje
 
Top