mathmod
Sorry I'm such a n00b, but if I was correct this piece of code in item-eli.c would restore half of your max health:
if (&life == 0)
return;
&life = int math_mod(int &lifemax, int 2);
Am I correct?
if (&life == 0)
return;
&life = int math_mod(int &lifemax, int 2);
Am I correct?
No.
First, you don't need those 'int' keywords, so...
if (&life == 0)
return;
&life = math_mod(&lifemax, 2);
math_mod returns the remainder of a division operation. If &lifemax is 8, 8 divided by 2 is 4 with no remainder, so it would return 0. If &lifemax was 27, 27 divided by 2 is 13 with a remainder of 1, so it would return 1. In fact, this use of math_mod will only return 0 or 1, which isn't what you're looking for.
You'd probably want to do something like this:
if (&life == 0)
return;
int &halflifemax = &lifemax;
&lifemax / 2;
&life += &halflifemax;
if (&life > &lifemax)
{
&life = &lifemax;
}
First, you don't need those 'int' keywords, so...
if (&life == 0)
return;
&life = math_mod(&lifemax, 2);
math_mod returns the remainder of a division operation. If &lifemax is 8, 8 divided by 2 is 4 with no remainder, so it would return 0. If &lifemax was 27, 27 divided by 2 is 13 with a remainder of 1, so it would return 1. In fact, this use of math_mod will only return 0 or 1, which isn't what you're looking for.
You'd probably want to do something like this:
if (&life == 0)
return;
int &halflifemax = &lifemax;
&lifemax / 2;
&life += &halflifemax;
if (&life > &lifemax)
{
&life = &lifemax;
}
int &halflifemax = &lifemax;
&halflifemax / 2;//here, I corrected redink1's script
&life += &halflifemax;
if (&life > &lifemax)
{
&life = &lifemax;
}
I guess you wanted to use math_div instead of math_mod, but this way, if dink's life was higher than half of his lifemax, it would lower dink's life(and I guess you didn't want that).
&halflifemax / 2;//here, I corrected redink1's script
&life += &halflifemax;
if (&life > &lifemax)
{
&life = &lifemax;
}
I guess you wanted to use math_div instead of math_mod, but this way, if dink's life was higher than half of his lifemax, it would lower dink's life(and I guess you didn't want that).