Jump to content
  • 0

How to change HP and SP recovery


shyguy

Question


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  2
  • Reputation:   0
  • Joined:  08/19/23
  • Last Seen:  

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

  • 0

  • Group:  Forum Moderator
  • Topic Count:  44
  • Topics Per Day:  0.01
  • Content Count:  896
  • Reputation:   117
  • Joined:  05/23/12
  • Last Seen:  

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  4
  • Reputation:   1
  • Joined:  05/18/16
  • Last Seen:  

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 by NimbleStorm
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...