From 6343274ad8e270888df854926bc47a0bc5713f47 Mon Sep 17 00:00:00 2001 From: skotlex Date: Tue, 30 May 2006 04:07:27 +0000 Subject: - Changed status_heal and status_damage to receive signed int values. They will invoke each other as needed when the passed values are negative. - Updated battle_calc_attack to set atk type to ATK_FLEE and dmotion to 0 when the damage is less than 1 (missed or absorbed) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6832 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/battle.c | 21 ++++++++------------- src/map/battle.h | 2 +- src/map/status.c | 30 ++++++++++++++++++++++++++---- src/map/status.h | 4 ++-- 4 files changed, 37 insertions(+), 20 deletions(-) diff --git a/src/map/battle.c b/src/map/battle.c index 52e82ce9f..0287fb8f8 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -1970,6 +1970,7 @@ static struct Damage battle_calc_weapon_attack( mob_class_change(tmd,class_); } } + if (wd.damage > 0 || wd.damage2 > 0) { if (sd && battle_config.equip_self_break_rate) { // Self weapon breaking @@ -2392,8 +2393,6 @@ struct Damage battle_calc_magic_attack( ad.damage=battle_calc_damage(src,target,ad.damage,ad.div_,skill_num,skill_lv,ad.flag); if (map_flag_gvg(target->m)) ad.damage=battle_calc_gvg_damage(src,target,ad.damage,ad.div_,skill_num,skill_lv,ad.flag); - if (ad.damage == 0) //Magic attack blocked? Consider it a miss so it doesn't invokes additional effects. [Skotlex] - ad.dmg_lv = ATK_FLEE; return ad; } @@ -2632,7 +2631,7 @@ struct Damage battle_calc_misc_attack( md.damage=battle_calc_damage(src,target,md.damage,md.div_,skill_num,skill_lv,md.flag); if (map_flag_gvg(target->m)) md.damage=battle_calc_gvg_damage(src,target,md.damage,md.div_,skill_num,skill_lv,md.flag); - + return md; } /*========================================== @@ -2659,6 +2658,11 @@ struct Damage battle_calc_attack( int attack_type, memset(&d,0,sizeof(d)); break; } + if (d.damage + d.damage2 < 1 && d.dmg_lv != ATK_LUCKY) + { //Miss/Absorbed + d.dmg_lv = ATK_FLEE; + d.dmotion = 0; + } return d; } @@ -2744,16 +2748,7 @@ void battle_drain(TBL_PC *sd, TBL_PC* tsd, int rdamage, int ldamage, int race, i if (!thp && !tsp) return; //Split'em up as Hp/Sp could be drained/leeched. - if(thp> 0) - status_heal(&sd->bl, thp, 0, battle_config.show_hp_sp_drain?3:1); - else if (thp < 0) - status_zap(&sd->bl, thp, 0); - - if(tsp > 0) - status_heal(&sd->bl, 0, tsp, battle_config.show_hp_sp_drain?3:1); - else if (tsp < 0) - status_zap(&sd->bl, 0, tsp); - + status_heal(&sd->bl, thp, tsp, battle_config.show_hp_sp_drain?3:1); if (tsd) { if (rhp || rsp) diff --git a/src/map/battle.h b/src/map/battle.h index 2b5da6f0a..3b386b42e 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -11,7 +11,7 @@ struct Damage { int amotion,dmotion; int blewcount; int flag; - int dmg_lv; //囲まれ減算計算用 0:スキル攻撃 ATK_LUCKY,ATK_FLEE,ATK_DEF + int dmg_lv; //ATK_LUCKY,ATK_FLEE,ATK_DEF }; // 属性表(読み込みはpc.c、battle_attr_fixで使用) diff --git a/src/map/status.c b/src/map/status.c index 3d574d314..952045c33 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -467,7 +467,7 @@ int status_getrefinebonus(int lv,int type) //If flag&1, damage is passive and does not triggers cancelling status changes. //If flag&2, fail if target does not has enough to substract. //If flag&4, if killed, mob must not give exp/loot. -int status_damage(struct block_list *src,struct block_list *target,unsigned int hp, unsigned sp, int walkdelay, int flag) +int status_damage(struct block_list *src,struct block_list *target,int hp, int sp, int walkdelay, int flag) { struct status_data *status; struct status_change *sc; @@ -475,8 +475,19 @@ int status_damage(struct block_list *src,struct block_list *target,unsigned int if(sp && target->type != BL_PC) sp = 0; //Only players get SP damage. + if (hp < 0) { //Assume absorbed damage. + status_heal(target, -hp, 0, 1); + hp = 0; + } + + if (sp < 0) { + status_heal(target, 0, -sp, 1); + sp = 0; + } + if (!hp && !sp) return 0; + if (target->type == BL_SKILL) return skill_unit_ondamaged((struct skill_unit *)target, src, hp, gettick()); @@ -586,7 +597,7 @@ int status_damage(struct block_list *src,struct block_list *target,unsigned int //Heals a character. If flag&1, this is forced healing (otherwise stuff like Berserk can block it) //If flag&2, when the player is healed, show the HP/SP heal effect. -int status_heal(struct block_list *bl,unsigned int hp,unsigned int sp, int flag) +int status_heal(struct block_list *bl,int hp,int sp, int flag) { struct status_data *status; struct status_change *sc; @@ -599,15 +610,26 @@ int status_heal(struct block_list *bl,unsigned int hp,unsigned int sp, int flag) sc = status_get_sc(bl); if (sc && !sc->count) sc = NULL; + + if (hp < 0) { + status_damage(NULL, bl, -hp, 0, 0, 1); + hp = 0; + } if(hp) { if (!(flag&1) && sc && sc->data[SC_BERSERK].timer!=-1) hp = 0; - + + if(hp > status->max_hp - status->hp) hp = status->max_hp - status->hp; } - + + if(sp < 0) { + status_damage(NULL, bl, 0, -sp, 0, 1); + sp = 0; + } + if(sp) { if(sp > status->max_sp - status->sp) sp = status->max_sp - status->sp; diff --git a/src/map/status.h b/src/map/status.h index 75c446c1e..25f6b6734 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -502,7 +502,7 @@ enum { #define SCB_PC 0x80000000 #define SCB_ALL 0x7FFFFFFF -int status_damage(struct block_list *src,struct block_list *target,unsigned int hp, unsigned sp, int walkdelay, int flag); +int status_damage(struct block_list *src,struct block_list *target,int hp,int sp, int walkdelay, int flag); //Define for standard HP damage attacks. #define status_fix_damage(src, target, hp, walkdelay) status_damage(src, target, hp, 0, walkdelay, 0) //Define for standard HP/SP damage triggers. @@ -516,7 +516,7 @@ int status_percent_change(struct block_list *src,struct block_list *target,signe //Instant kill with no drops/exp/etc // #define status_kill(bl) status_percent_damage(NULL, bl, 100, 0) -int status_heal(struct block_list *bl,unsigned int hp,unsigned int sp, int flag); +int status_heal(struct block_list *bl,int hp,int sp, int flag); int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per_sp); //Define for copying a status_data structure from b to a, without overwriting current Hp and Sp, nor messing the lhw pointer. -- cgit v1.2.3-70-g09d2