0 Hits on server Restart.

Discussion in 'Script Support' started by Lionar, Oct 9, 2017.

  1. Lionar

    Lionar Squire

    Joined:
    Jan 2, 2014
    Messages:
    59
    Likes Received:
    0
    Hello Everyone,
    i've started some times ago a new project inspired by DnD rules. Right now i added the 3 missing Statistics : Wisdom, Charisma and Constitution. I've changed the way to set the HitsMax of the Player in order to let Constitution to be used as intended. Everything is Fine, HitsMax changes on Constitution changes but when i restart the server all players have 0 hitpoints :/ .
    Here my PlayerMobile.cs code.
    Any Clues?
     

    Attached Files:

  2. ThoughtsRiff

    ThoughtsRiff Wanderer

    Joined:
    Oct 9, 2017
    Messages:
    18
    Likes Received:
    1
  3. ThoughtsRiff

    ThoughtsRiff Wanderer

    Joined:
    Oct 9, 2017
    Messages:
    18
    Likes Received:
    1
    Well, I've read your file. First of all, at lines 446-454, private variables should be declared before their methods. Try after the change
     
  4. Lionar

    Lionar Squire

    Joined:
    Jan 2, 2014
    Messages:
    59
    Likes Received:
    0
    It's weird cause Constitution seems to serialize, when server is up the Constitution value seems to not be resetted. I've tryed to swap positions. Nothin to do.
    p.s. Si sono italiano ;)
     
  5. ThoughtsRiff

    ThoughtsRiff Wanderer

    Joined:
    Oct 9, 2017
    Messages:
    18
    Likes Received:
    1
    Well, try to deserialize all characteristics in different "cases".
    P.S.: ciao :)
     
  6. Lionar

    Lionar Squire

    Joined:
    Jan 2, 2014
    Messages:
    59
    Likes Received:
    0
    Done, the issue still remains.
    p.s. mannaggia.
     
  7. Grimoric

    Grimoric Sorceror

    Joined:
    Feb 8, 2006
    Messages:
    61
    Likes Received:
    17
    Is the value of constitution 0 after saving and restarting?

    Edit: If you never saved the information it will be 0. "[save" saves the world.
     
  8. Lionar

    Lionar Squire

    Joined:
    Jan 2, 2014
    Messages:
    59
    Likes Received:
    0
    No, constitution keeps the same value i set before the restart :(

    Yeah i use [save XD
     
  9. Grimoric

    Grimoric Sorceror

    Joined:
    Feb 8, 2006
    Messages:
    61
    Likes Received:
    17
    What value does "return this.Costituzione" on line 1534 have?
     
  10. Lionar

    Lionar Squire

    Joined:
    Jan 2, 2014
    Messages:
    59
    Likes Received:
    0
    It should be the "Constitution" Stat (translated)
     
  11. Grimoric

    Grimoric Sorceror

    Joined:
    Feb 8, 2006
    Messages:
    61
    Likes Received:
    17
    Yes but the init function is calling that prop from it's virtual class and this override should calculate the value.

    The question is what value does it return is this.Costituzione set to anything under the init call?

    If you for example change it to "return 75" will your character have a max of 75 points? If it does then the issue is that the value havnt been set in time.

    If you change the value after reboot does it update health to a correct value?
     
  12. Lionar

    Lionar Squire

    Joined:
    Jan 2, 2014
    Messages:
    59
    Likes Received:
    0
    "Costituzione" (Constitution) should replace the "HitsMax", 75 Costituzione means 75 HitsMax. I log in - set Costituzione to 100 - my maxhits are 100 - i use [save - i reboot - my maxhits are 100 , everything is fine but...my hits points are 0 (and then raising up thanks to FocusSkill)
     
  13. Grimoric

    Grimoric Sorceror

    Joined:
    Feb 8, 2006
    Messages:
    61
    Likes Received:
    17
    Aha

    There is two functions in server/mobile.cs that I think handle it.
    I have rewritten my core completely so the line numbers don't add up but the functions are:

    public void InitStats( int str, int dex, int intel )
    public int Hits

    Try to debug them and see if the values are correct here.
     
  14. Lionar

    Lionar Squire

    Joined:
    Jan 2, 2014
    Messages:
    59
    Likes Received:
    0
    Oh nice thanks! I'll give It a try when i have a break fronte workshop and i'll let You know
     
  15. Vorspire

    Vorspire Knight

    Joined:
    Jan 25, 2005
    Messages:
    12,875
    Likes Received:
    677
    At the end of the PlayerMobile.Deserialize method, you could do this;

    this.Hits = this.HitsMax;

    That will ensure that Hits fills out. Sometimes Hits is deserialized before mods that increase HitsMax are applied, meaning you can log back in with less than HitsMax.

    You can test this by equipping +BonusHits items.
    If you wear an item with +100 bonus hits giving you 200 hits max total, saving and restarting will having you logging in with 100/200 hits, because the item's hits bonus isn't applied at the time Hits is deserialized.
     
  16. Lionar

    Lionar Squire

    Joined:
    Jan 2, 2014
    Messages:
    59
    Likes Received:
    0
    This can be a good solution too, it's better to login with full hp instead of 0. I'll try this instead touching the core (i never did it before and i'm a little bit scared :p ).
    Thank you so much. I hope today i can spend some time on server and give you good news!
     
  17. ThoughtsRiff

    ThoughtsRiff Wanderer

    Joined:
    Oct 9, 2017
    Messages:
    18
    Likes Received:
    1
    I don't know how it works but take care of it. For example, if a player is fighting and gets disconnected, he shouldn't come back with full hp.
     
  18. Lionar

    Lionar Squire

    Joined:
    Jan 2, 2014
    Messages:
    59
    Likes Received:
    0
    Everything is fine, the problem was on server restart not on Login- Logout ^^

    1 Line Code and everything is fine, thank you Master :p
     

Share This Page