Jak wysyłać HP i manę w procentach

Discussion in 'Poradniki' started by Crypton3, Feb 19, 2013.

  1. Crypton3

    Crypton3 Retired

    Joined:
    Mar 13, 2010
    Messages:
    549
    Likes Received:
    136
    Best Answers:
    0
    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 (Text):
    1.     msg->put<uint16_t>(player->getHealth());
    2.     msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MAXHEALTH));
    Na:
    Code (Text):
    1.     if (player->getPlayerInfo(PLAYERINFO_MAXHEALTH) > 0)
    2.     {
    3.         msg->put<uint16_t>(uint16_t(player->getHealth() * 100 / player->getPlayerInfo(PLAYERINFO_MAXHEALTH)));
    4.         msg->put<uint16_t>(100);
    5.     }
    6.     else
    7.     {
    8.         msg->put<uint16_t>(0);
    9.         msg->put<uint16_t>(0);
    10.     }
    Oraz:
    Code (Text):
    1.     msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MANA));
    2.     msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MAXMANA));
    Na:
    Code (Text):
    1.     if (player->getPlayerInfo(PLAYERINFO_MAXMANA) > 0)
    2.     {
    3.         msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MANA) * 100 / player->getPlayerInfo(PLAYERINFO_MAXMANA));
    4.         msg->put<uint16_t>(100);
    5.     }
    6.     else
    7.     {
    8.         msg->put<uint16_t>(0);
    9.         msg->put<uint16_t>(0);
    10.     }
    Gotowe
     
    Last edited: Apr 14, 2013
    N e r o n Z, Erexo and sn3ejk like this.
  2. Burczyk91

    Burczyk91 Member

    Joined:
    Jul 21, 2012
    Messages:
    268
    Likes Received:
    3
    Best Answers:
    0
    Ciekawe, prawdopodobnie wprowadzę to u siebie. Dzięki :D
     
  3. szatan1x

    szatan1x Professional Lua

    Joined:
    May 10, 2011
    Messages:
    700
    Likes Received:
    25
    Best Answers:
    0
    Nice (fajne)
     
    Last edited: Nov 4, 2015
  4. lanc3k

    lanc3k Banned User

    Joined:
    Feb 14, 2013
    Messages:
    60
    Likes Received:
    4
    Best Answers:
    0
    Ładna buzia z pikseli pod koniec, polecam.
     
    Keram likes this.
  5. zakius

    zakius Enter the Ninja!

    Joined:
    Apr 30, 2009
    Messages:
    2,635
    Likes Received:
    63
    Best Answers:
    0
    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
     
  6. maciekxx

    maciekxx Banned User

    Joined:
    Mar 6, 2011
    Messages:
    267
    Likes Received:
    4
    Best Answers:
    0
    Przyda się na orszabumby.
     
  7. The_Hide

    The_Hide Banned User

    Joined:
    Dec 11, 2012
    Messages:
    389
    Likes Received:
    10
    Best Answers:
    0
    nie rozumiem, ale dam ci lajka :I

    #temat

    fajnie crypton, że to tak ładnie wyjaśniłeś, laaajk
     
    Potar likes this.
  8. szatan1x

    szatan1x Professional Lua

    Joined:
    May 10, 2011
    Messages:
    700
    Likes Received:
    25
    Best Answers:
    0
    Chyba o to chodzi ;p
    ☺☺☺☺☺☺☺☺☺☺
     
    The_Hide likes this.
  9. lanc3k

    lanc3k Banned User

    Joined:
    Feb 14, 2013
    Messages:
    60
    Likes Received:
    4
    Best Answers:
    0
    Nie prawda szatan1x, jego buźka jest inna!
     
  10. The_Hide

    The_Hide Banned User

    Joined:
    Dec 11, 2012
    Messages:
    389
    Likes Received:
    10
    Best Answers:
    0
    dzięki, reput.
     
  11. Nurcz

    Nurcz Banned User

    Joined:
    Feb 14, 2013
    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    $$$$$_______________###
    _$$$$$$______________#$
    _$$$$$$____________$$$#$
    _$$$$$$$________$$$$$$$$
    __$$$$$$$_____$$$$$$$$$
    __$$$$$$$____$$$$$$$$
    __$$$$$$$__$$$$$$$$$
    ____$$$$$_$$$$$$______
    _____$$$$$$$$__________
    ______$$$$$$$$$$$$$
    ____$$$$$$$$$$$$$$$$$
    ____$$$$$$$$$$$$___$$$
    ___$$$$$$$$$$$$$__$$$$$
    ___$$$$$$$$$$$$$$$$$$$$$
    ____$$$$$$$$$$$$$$$$$$$
    _____$$$$$$$$$$$$$$$$$
    ________$$$$$$$$$$
    ______$$$$$$$$$$
     
  12. TriamerA

    TriamerA The Mystic One.

    Joined:
    Nov 16, 2008
    Messages:
    1,256
    Likes Received:
    17
    Best Answers:
    0
    Stworzyłeś możliwość dzielenia przez zero ;)
     
    Crypton3 likes this.
  13. Crypton3

    Crypton3 Retired

    Joined:
    Mar 13, 2010
    Messages:
    549
    Likes Received:
    136
    Best Answers:
    0
    Ciekawa możliwość, teraz powinno być ok.
     
    Morlad likes this.
  14. Morlad

    Morlad Mega USER

    Joined:
    Dec 22, 2010
    Messages:
    288
    Likes Received:
    16
    Best Answers:
    0
    Super dzieki ;)
     
  15. stanczyk

    stanczyk Scripter

    Joined:
    Nov 24, 2009
    Messages:
    294
    Likes Received:
    2
    Best Answers:
    0
    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?
     
  16. Sekula 14

    Sekula 14 Active Member

    Joined:
    Jul 7, 2012
    Messages:
    361
    Likes Received:
    47
    Best Answers:
    0
  17. zygus0000

    zygus0000 Member

    Joined:
    May 12, 2013
    Messages:
    54
    Likes Received:
    2
    Best Answers:
    0
    Możesz dac ten plik bo ja nie wiem ale mi bład wyskakuje
     
  18. Amiroslo

    Amiroslo Guess who's back

    Joined:
    Jul 28, 2009
    Messages:
    6,507
    Likes Received:
    518
    Best Answers:
    3
    works on 0.4?
     
  19. sprytnaaa

    sprytnaaa New Member

    Joined:
    Jun 21, 2014
    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    hi plis for 10.98 tfs 1.2
     
  20. Kuzyn

    Kuzyn Well-Known Member

    Joined:
    Dec 19, 2009
    Messages:
    1,206
    Likes Received:
    248
    Best Answers:
    0
    Najpierw na tnecie nie możesz znaleźć pomocy a teraz w polskim dziale piszesz "hi plis for" xD I ty chcesz serwer odpalać ziomek?
     

Share This Page

Loading...