ratio = attr_fix_table[def_lv-1][atk_elem][def_type];
battle.cpp:
Spoiler
if (battle_config.attr_recover == 0 && ratio < 0)
ratio = 0;
#ifdef RENEWAL
//In renewal, reductions are always rounded down so damage can never reach 0 unless ratio is 0
damage = damage - (int64)((damage * (100 - ratio)) / 100);
#else damage = (int64)((damage*ratio)/100);
#endif
//Damage can be negative, see battle_config.attr_recover
return damage;
status.cpp:
Spoiler
while (fgets(line, sizeof(line), fp)) {
int lv, i, j;
if (line[0] == '/' && line[1] == '/')
continue;
lv = atoi(line);
if (!CHK_ELEMENT_LEVEL(lv))
continue;
for (i = 0; i < ELE_ALL;) {
char *p;
if (!fgets(line, sizeof(line), fp))
break;
if (line[0]=='/' && line[1]=='/')
continue;
for (j = 0, p = line; j < ELE_ALL && p; j++) {
while (*p == 32) //skipping space (32=' ')
p++;
//TODO seem unsafe to continue without check attr_fix_table[lv-1][j] = atoi(p); p = strchr(p,','); if(p) *p++=0; }
i++; } entries++; }
What should I change in order to read attr_fix_table/ratio/damage negative values and make them heal target's HP?
Question
deitalk
I'm running the newest rathena on pre-re and negative values for elemental damage are being read as 1 or miss even with attribute_recover set to 1
battle.conf:
attribute_recover: yes
ratio on battle.cpp should determine if damage is a positive or negative value
battle.cpp:
int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 damage,int atk_elem,int def_type, int def_lv)
{
struct status_change *sc = NULL, *tsc = NULL;
int ratio;
if (src) sc = status_get_sc(src);
if (target) tsc = status_get_sc(target);
if (!CHK_ELEMENT(atk_elem))
atk_elem = rnd()%ELE_ALL;
if (!CHK_ELEMENT(def_type) || !CHK_ELEMENT_LEVEL(def_lv)) {
ShowError("battle_attr_fix: unknown attribute type: atk=%d def_type=%d def_lv=%d\n",atk_elem,def_type,def_lv);
return damage;
}
ratio = attr_fix_table[def_lv-1][atk_elem][def_type];
battle.cpp:
if (battle_config.attr_recover == 0 && ratio < 0)
ratio = 0;
#ifdef RENEWAL
//In renewal, reductions are always rounded down so damage can never reach 0 unless ratio is 0
damage = damage - (int64)((damage * (100 - ratio)) / 100);
#else
damage = (int64)((damage*ratio)/100);
#endif
//Damage can be negative, see battle_config.attr_recover
return damage;
status.cpp:
while (fgets(line, sizeof(line), fp)) {
int lv, i, j;
if (line[0] == '/' && line[1] == '/')
continue;
lv = atoi(line);
if (!CHK_ELEMENT_LEVEL(lv))
continue;
for (i = 0; i < ELE_ALL;) {
char *p;
if (!fgets(line, sizeof(line), fp))
break;
if (line[0]=='/' && line[1]=='/')
continue;
for (j = 0, p = line; j < ELE_ALL && p; j++) {
while (*p == 32) //skipping space (32=' ')
p++;
//TODO seem unsafe to continue without check
attr_fix_table[lv-1][j] = atoi(p);
p = strchr(p,',');
if(p)
*p++=0;
}
i++;
}
entries++;
}
What should I change in order to read attr_fix_table/ratio/damage negative values and make them heal target's HP?
Edited by deitalk9 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.