Issue information

Issue ID
#3620
Status
Fixed
Severity
None
Started
Hercules Elf Bot
Sep 28, 2009 18:32
Last Post
Hercules Elf Bot
Jun 9, 2012 21:18
Confirmation
N/A

Hercules Elf Bot - Sep 28, 2009 18:32

Originally posted by [b]HiddenDragon[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=3620

Set any castle to 100 defense and have battle_config.castle_defense_rate = 100 (default) and the result is all guardians, plus the emperium itself become invulnerable to damage.

The cause is this little snippet in battle_calc_gvg:

CODE
    switch (skill_num) {
    //Skills with no damage reduction.
    case PA_PRESSURE:
    case HW_GRAVITATION:
    case NJ_ZENYNAGE:
        break;
    default:
        if (md && md->guardian_data) {
            damage -= damage * (md->guardian_data->castle->defense/100) * battle_config.castle_defense_rate/100;
        }


It's rather odd because:

1. "(md->guardian_data->castle->defense/100)" normally returns 0 because most of the time, the castle defense is between 0 and 99 which means this division equates to zero (integer division discards decimal remainders) as a result of order of operations. Hence, most of the time defense investment in castles produces no benefit in damage reduction so it's unnecessary at all o_O.

2. Second, if the defense is 100 and battle_config.castle_defense_rate is also set to 100 (as is default on eAthena), the line becomes:
CODE
damage -= damage * 1 * 1;


Thus, the damage is completely negated and both guardians and emperium are invulnerable to damage (except via those three skills).

Is this line even official behavior? It was added to stable wayyyyyyy back in r699 by celest.

Hercules Elf Bot - Dec 9, 2011 3:08

Originally posted by [b]Ind[/b]
how is castle defense modifier meant to be applied then?!

Hercules Elf Bot - May 27, 2012 21:53

Originally posted by [b]MarkZD[/b]
It was fixed in eAthena: [url="http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=2901"]http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=2901[/url]