• 0
Sign in to follow this  
deitalk

attribute_recover isn't working properly

Question

Posted (edited)

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:

Spoiler

attribute_recover: yes

ratio on battle.cpp should determine if damage is a positive or negative value

battle.cpp:

Spoiler

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:

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?

Edited by deitalk

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0
Posted (edited)

battle.c

lines: 420, 576

Edited by deitalk

Share this post


Link to post
Share on other sites
  • 0

If I'm wearing Evil Druid and get hit by poison/shadow, it causes miss or 1 total damage. It should heal.

Share this post


Link to post
Share on other sites
  • 0

BTW, pasana should only reduce 75% from total fire damage, I think... Evil Druid should reduce 125% from shadow/poison...

Share this post


Link to post
Share on other sites
  • 0

The conf switch must make any x > 100% protection (ratio < 0 on battle.c) to heal the target instead of miss, but the ratio isn't receiving negative values

Share this post


Link to post
Share on other sites
  • 0

Actually I'm running pre-re setup, so yeah, I'd appreciate that. I've made some tests and couldn't even force directly ratio (therefore damage) to assume negative values. Even when I put damage = -ratio; it seems to revert negative to positive (ok) and when it tries to revert positives I get 0/1 damage

Share this post


Link to post
Share on other sites
  • 0

Apparently at some point someone decided that it wouldn't exist negative damage on RO anymore and then we lost attr_recover option (on both re and pre-re)... I'm still searching where on src it caps all forms of damage to positive

Share this post


Link to post
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.

Loading...
Sign in to follow this