shyguy Posted August 19, 2023 Group: Members Topic Count: 1 Topics Per Day: 0.00 Content Count: 2 Reputation: 0 Joined: 08/19/23 Last Seen: July 24, 2024 Share Posted August 19, 2023 Hello. I was looking to change HP and SP recovery, both idle and when sitting. I found some old threads but the code in the threads are old C code and not cpp. I looked into rathena/src/map/status.cpp and have seen some code related to HP and SP regen while sitting. static int status_natural_heal(struct block_list* bl, va_list args) But I am unsure if ths is the right place and what exactly I should change. If I understood it correctly I would like to edit the following lines to adjust the sitting HP and SP recovery: // for HP rate = (int)(natural_heal_diff_tick * (sregen->rate.hp / 100.)); // for SP rate = (int)(natural_heal_diff_tick * (sregen->rate.sp / 100.)); Any help would be appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
0 NimbleStorm Posted March 14, 2024 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 4 Reputation: 1 Joined: 05/18/16 Last Seen: April 9 Share Posted March 14, 2024 (edited) On 8/19/2023 at 3:49 PM, shyguy said: Hello. I was looking to change HP and SP recovery, both idle and when sitting. I found some old threads but the code in the threads are old C code and not cpp. I looked into rathena/src/map/status.cpp and have seen some code related to HP and SP regen while sitting. static int status_natural_heal(struct block_list* bl, va_list args) But I am unsure if ths is the right place and what exactly I should change. If I understood it correctly I would like to edit the following lines to adjust the sitting HP and SP recovery: // for HP rate = (int)(natural_heal_diff_tick * (sregen->rate.hp / 100.)); // for SP rate = (int)(natural_heal_diff_tick * (sregen->rate.sp / 100.)); Any help would be appreciated. Thanks. Hello, If you're running the latest rAthena: In /conf/battle/player.conf You may adjust the following to alter the time factor of regen for HP/SP: // The time interval for HP to restore naturally. (in milliseconds) natural_healhp_interval: 6000 // The time interval for SP to restore naturally. (in milliseconds) natural_healsp_interval: 8000 An alternative but not recommended method source-side: In /src/map/pc.cpp: Replace: //Character regen. Flag is used to know which types of regen can take place. //&1: HP regen //&2: SP regen void pc_regen (map_session_data *sd, t_tick diff_tick) { int hp = 0, sp = 0; if (sd->hp_regen.value) { sd->hp_regen.tick += diff_tick; while (sd->hp_regen.tick >= sd->hp_regen.rate) { hp += sd->hp_regen.value; sd->hp_regen.tick -= sd->hp_regen.rate; } } if (sd->sp_regen.value) { sd->sp_regen.tick += diff_tick; while (sd->sp_regen.tick >= sd->sp_regen.rate) { sp += sd->sp_regen.value; sd->sp_regen.tick -= sd->sp_regen.rate; } } if (sd->percent_hp_regen.value) { sd->percent_hp_regen.tick += diff_tick; while (sd->percent_hp_regen.tick >= sd->percent_hp_regen.rate) { hp += sd->status.max_hp * sd->percent_hp_regen.value / 100; sd->percent_hp_regen.tick -= sd->percent_hp_regen.rate; } } if (sd->percent_sp_regen.value) { sd->percent_sp_regen.tick += diff_tick; while (sd->percent_sp_regen.tick >= sd->percent_sp_regen.rate) { sp += sd->status.max_sp * sd->percent_sp_regen.value / 100; sd->percent_sp_regen.tick -= sd->percent_sp_regen.rate; } } if (hp > 0 || sp > 0) status_heal(&sd->bl, hp, sp, 0); } With: void pc_regen (map_session_data *sd, t_tick diff_tick) { int hp = 0, sp = 0; int regen_rate_modifier = 1; // Normal rate // Check if the player is sitting to apply a rate modifier [NimbleStorm] if (pc_issit(sd)) { regen_rate_modifier = 2; // Increase tick rate by a factor of 2, adjust as needed [NimbleStorm] } if (sd->hp_regen.value) { sd->hp_regen.tick += diff_tick * regen_rate_modifier; // Apply modified rate while (sd->hp_regen.tick >= sd->hp_regen.rate) { hp += sd->hp_regen.value; sd->hp_regen.tick -= sd->hp_regen.rate; } } if (sd->sp_regen.value) { sd->sp_regen.tick += diff_tick * regen_rate_modifier; // Apply modified rate while (sd->sp_regen.tick >= sd->sp_regen.rate) { sp += sd->sp_regen.value; sd->sp_regen.tick -= sd->sp_regen.rate; } } if (sd->percent_hp_regen.value) { sd->percent_hp_regen.tick += diff_tick * regen_rate_modifier; // Apply modified rate while (sd->percent_hp_regen.tick >= sd->percent_hp_regen.rate) { hp += sd->status.max_hp * sd->percent_hp_regen.value / 100; sd->percent_hp_regen.tick -= sd->percent_hp_regen.rate; } } if (sd->percent_sp_regen.value) { sd->percent_sp_regen.tick += diff_tick * regen_rate_modifier; // Apply modified rate while (sd->percent_sp_regen.tick >= sd->percent_sp_regen.rate) { sp += sd->status.max_sp * sd->percent_sp_regen.value / 100; sd->percent_sp_regen.tick -= sd->percent_sp_regen.rate; } } if (hp > 0 || sp > 0) status_heal(&sd->bl, hp, sp, 0); } Good luck. You can do it. Edited March 14, 2024 by NimbleStorm Quote Link to comment Share on other sites More sharing options...
0 Rynbef Posted August 29, 2023 Group: Forum Moderator Topic Count: 48 Topics Per Day: 0.01 Content Count: 941 Reputation: 125 Joined: 05/23/12 Last Seen: Saturday at 06:31 PM Share Posted August 29, 2023 Here u can change it: https://github.com/rathena/rathena/blob/b37107853aff9982b8932c4646c983f52796086b/src/map/pc.cpp#L12742 Or use a script like: OnInit: bonus bHPrecovRate,5; bonus bSPrecovRate,5; end; https://github.com/rathena/rathena/blob/b37107853aff9982b8932c4646c983f52796086b/doc/item_bonus.txt#L181 Rynbef~ Quote Link to comment Share on other sites More sharing options...
Question
shyguy
Hello.
I was looking to change HP and SP recovery, both idle and when sitting.
I found some old threads but the code in the threads are old C code and not cpp.
I looked into rathena/src/map/status.cpp and have seen some code related to HP and SP regen while sitting.
static int status_natural_heal(struct block_list* bl, va_list args)
But I am unsure if ths is the right place and what exactly I should change.
If I understood it correctly I would like to edit the following lines to adjust the sitting HP and SP recovery:
// for HP rate = (int)(natural_heal_diff_tick * (sregen->rate.hp / 100.)); // for SP rate = (int)(natural_heal_diff_tick * (sregen->rate.sp / 100.));
Any help would be appreciated.
Thanks.
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.