Skip to content

Instantly share code, notes, and snippets.

@cydh
Last active December 19, 2016 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cydh/a3a2ec26732f8e6af2b91222d3da1aa3 to your computer and use it in GitHub Desktop.
Save cydh/a3a2ec26732f8e6af2b91222d3da1aa3 to your computer and use it in GitHub Desktop.
Double attack on Emperium is miss on rAthena. This diff fixes for issue #217 (https://github.com/rathena/rathena/issues/217). Reason for this change, see my comment below.
diff --git a/src/map/battle.c b/src/map/battle.c
index 825436e..70a3846 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -3282,9 +3282,10 @@ static struct Damage battle_calc_multi_attack(struct Damage wd, struct block_lis
|| ( sd->bonus.double_rate > 0 && sd->weapontype1 != W_FIST ) //Will fail bare-handed
|| ( sc && sc->data[SC_KAGEMUSYA] && sd->weapontype1 != W_FIST )) // Need confirmation
{ //Success chance is not added, the higher one is used [Skotlex]
- int max_rate = max(5*skill_lv,sd->bonus.double_rate);
- if(sc && sc->data[SC_KAGEMUSYA]) max_rate= max(max_rate,sc->data[SC_KAGEMUSYA]->val1*3);
-
+ int max_rate = max(5*skill_lv,sd->bonus.double_rate);
+ if(sc && sc->data[SC_KAGEMUSYA])
+ max_rate= max(max_rate,sc->data[SC_KAGEMUSYA]->val1*3);
+
if( rnd()%100 < max_rate ) {
wd.div_ = skill_get_num(TF_DOUBLE,skill_lv?skill_lv:1);
wd.type = DMG_MULTI_HIT;
@@ -4783,13 +4784,8 @@ struct Damage battle_calc_attack_plant(struct Damage wd, struct block_list *src,
//Plants receive 1 damage when hit
if( attack_hits || wd.damage > 0 )
wd.damage = 1; //In some cases, right hand no need to have a weapon to deal a damage
- if( is_attack_left_handed(src, skill_id) && (attack_hits || wd.damage2 > 0) ) {
- if(sd->status.weapon == W_KATAR)
- wd.damage2 = 0; //No backhand damage against plants
- else {
- wd.damage2 = 1; //Deal 1 HP damage as long as there is a weapon in the left hand
- }
- }
+ if( is_attack_left_handed(src, skill_id) && (attack_hits || wd.damage2 > 0) )
+ wd.damage2 = 1; //Deal 1 HP damage as long as there is a weapon in the left hand
if (attack_hits && target->type == BL_MOB) {
struct status_change *sc = status_get_sc(target);
@@ -4805,7 +4801,13 @@ struct Damage battle_calc_attack_plant(struct Damage wd, struct block_list *src,
wd.damage = wd.damage2 = 0;
return wd;
}
- if (wd.damage > 0) {
+ wd = battle_apply_div_fix(wd, skill_id);
+ //If there is left hand damage, total damage can never exceed 2, even on multiple hits
+ if(wd.damage > 1 && wd.damage2 > 0) {
+ wd.damage = 1;
+ wd.damage2 = 1;
+ }
+ if (wd.damage - wd.div_ > 0) {
wd.damage = battle_attr_fix(src, target, wd.damage, right_element, tstatus->def_ele, tstatus->ele_lv);
wd.damage = battle_calc_gvg_damage(src, target, wd.damage, skill_id, wd.flag);
} else if (wd.damage2 > 0) {
@@ -7721,7 +7723,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
return 0; // You can't target anything out of your duel
}
}
- if( map_flag_gvg(m) && !sd->status.guild_id && t_bl->type == BL_MOB && ((TBL_MOB*)t_bl)->mob_id == MOBID_EMPERIUM )
+ if( map_flag_gvg2(m) && !sd->status.guild_id && t_bl->type == BL_MOB && ((TBL_MOB*)t_bl)->mob_id == MOBID_EMPERIUM )
return 0; //If you don't belong to a guild, can't target emperium.
if( t_bl->type != BL_PC )
state |= BCT_ENEMY; //Natural enemy.
diff --git a/src/map/clif.c b/src/map/clif.c
index ae199a2..cc79db4 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -4704,13 +4704,17 @@ int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tic
}
}
+ // Removes 'miss' in Castles map because of the damage != div limit
+ if (map_flag_gvg2(dst->m) && div > damage)
+ damage = div;
+
WBUFW(buf,0) = cmd;
WBUFL(buf,2) = src->id;
WBUFL(buf,6) = dst->id;
WBUFL(buf,10) = tick;
WBUFL(buf,14) = sdelay;
WBUFL(buf,18) = ddelay;
- if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
+ if (battle_config.hide_woe_damage && map_flag_gvg2(src->m)) {
WBUFW(buf,22) = damage ? div : 0;
WBUFW(buf,27+offset) = damage2 ? div : 0;
} else {
@@ -5451,7 +5455,7 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int
WBUFL(buf,12)=tick;
WBUFL(buf,16)=sdelay;
WBUFL(buf,20)=ddelay;
- if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
+ if (battle_config.hide_woe_damage && map_flag_gvg2(src->m)) {
WBUFW(buf,24)=damage?div:0;
} else {
WBUFW(buf,24)=damage;
@@ -5482,7 +5486,7 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int
WBUFL(buf,12)=tick;
WBUFL(buf,16)=sdelay;
WBUFL(buf,20)=ddelay;
- if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
+ if (battle_config.hide_woe_damage && map_flag_gvg2(src->m)) {
WBUFL(buf,24)=damage?div:0;
} else {
WBUFL(buf,24)=damage;
@@ -5549,7 +5553,7 @@ int clif_skill_damage2(struct block_list *src,struct block_list *dst,unsigned in
WBUFL(buf,20)=ddelay;
WBUFW(buf,24)=dst->x;
WBUFW(buf,26)=dst->y;
- if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
+ if (battle_config.hide_woe_damage && map_flag_gvg2(src->m)) {
WBUFW(buf,28)=damage?div:0;
} else {
WBUFW(buf,28)=damage;
@cydh
Copy link
Author

cydh commented Dec 16, 2016

  • Fixes for issue #217 (rathena/rathena#217)
  • Just found out that Katar still deals 2 damage instead of 1
  • If you're asking why if (wd.damage - wd.div_ > 0) {, as long as the damage 1, if it reduced by map modifier, it's still 1. But if the damage is 2 (by DA) or more (by Fear Breeze) client will shows miss because of damage may reduced to less than div

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment