diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/battle.c | 42 | ||||
-rw-r--r-- | src/map/battle.h | 6 | ||||
-rw-r--r-- | src/map/clif.c | 17 | ||||
-rw-r--r-- | src/map/clif.h | 2 | ||||
-rw-r--r-- | src/map/skill.c | 6 | ||||
-rw-r--r-- | src/map/status.c | 14 |
6 files changed, 47 insertions, 40 deletions
diff --git a/src/map/battle.c b/src/map/battle.c index f56488713..285b177c3 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -874,7 +874,7 @@ int64 battle_calc_elefix(struct block_list *src, struct block_list *target, uint sc = iStatus->get_sc(src); if( sc && sc->data[SC_SUB_WEAPONPROPERTY] ) { // Descriptions indicate this means adding a percent of a normal attack in another element. [Skotlex] - int temp = battle->calc_base_damage(sstatus, &sstatus->rhw, sc, tstatus->size, BL_CAST(BL_PC, src), (flag?2:0)) * sc->data[SC_SUB_WEAPONPROPERTY]->val2 / 100; + int64 temp = battle->calc_base_damage(sstatus, &sstatus->rhw, sc, tstatus->size, BL_CAST(BL_PC, src), (flag?2:0)) * sc->data[SC_SUB_WEAPONPROPERTY]->val2 / 100; damage += battle->attr_fix(src, target, temp, sc->data[SC_SUB_WEAPONPROPERTY]->val1, tstatus->def_ele, tstatus->ele_lv); if( left ) { temp = battle->calc_base_damage(sstatus, &sstatus->lhw, sc, tstatus->size, BL_CAST(BL_PC, src), (flag?2:0)) * sc->data[SC_SUB_WEAPONPROPERTY]->val2 / 100; @@ -1194,7 +1194,7 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_ * &2 - pdef(Pierce defense) * &4 - tdef(Total defense reduction) *------------------------------------------*/ -int battle_calc_defense(int attack_type, struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 damage, int flag, int pdef){ +int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 damage, int flag, int pdef){ struct status_data *sstatus, *tstatus; struct map_session_data *sd, *tsd; struct status_change *sc, *tsc; @@ -2611,7 +2611,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam #ifdef RENEWAL d->dmg_lv = ATK_BLOCK; if ( ( group->val2 - damage) > 0 ) { - group->val2 -= damage; + group->val2 -= (int)cap_value(damage,INT_MIN,INT_MAX); } else skill->del_unitgroup(group,ALC_MARK); return 0; @@ -2656,7 +2656,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if( (sce = sc->data[SC_MILLENNIUMSHIELD]) && sce->val2 > 0 && damage > 0 ) { clif->skill_nodamage(bl, bl, RK_MILLENNIUMSHIELD, 1, 1); - sce->val3 -= damage; // absorb damage + sce->val3 -= (int)cap_value(damage,INT_MIN,INT_MAX); // absorb damage d->dmg_lv = ATK_BLOCK; sc_start(bl,SC_STUN,15,0,skill->get_time2(RK_MILLENNIUMSHIELD,sce->val1)); // There is a chance to be stuned when one shield is broken. if( sce->val3 <= 0 ) { // Shield Down @@ -2860,7 +2860,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam } if( (sce = sc->data[SC_STONEHARDSKIN]) && flag&(BF_SHORT|BF_WEAPON) && damage > 0 ) { - sce->val2 -= damage; + sce->val2 -= (int)cap_value(damage,INT_MIN,INT_MAX); if( src->type == BL_PC ) { TBL_PC *ssd = BL_CAST(BL_PC, src); if (ssd && ssd->status.weapon != W_BOW) @@ -2893,7 +2893,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam //Finally Kyrie because it may, or not, reduce damage to 0. if((sce = sc->data[SC_KYRIE]) && damage > 0){ - sce->val2-=damage; + sce->val2 -= (int)cap_value(damage,INT_MIN,INT_MAX); if(flag&BF_WEAPON || skill_id == TF_THROWSTONE){ if(sce->val2>=0) damage=0; @@ -3137,7 +3137,7 @@ int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64 * HP/SP drain calculation *------------------------------------------*/ int battle_calc_drain(int64 damage, int rate, int per) { - int diff = 0; + int64 diff = 0; if (per && rnd()%1000 < rate) { diff = (damage * per) / 100; @@ -3148,7 +3148,7 @@ int battle_calc_drain(int64 damage, int rate, int per) { diff = -1; } } - return diff; + return (int)cap_value(diff,INT_MIN,INT_MAX); } /*========================================== @@ -3640,7 +3640,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * case CR_ACIDDEMONSTRATION: #ifdef RENEWAL {// [malufett] - int matk=0, atk; + int64 matk=0, atk; short tdef = iStatus->get_total_def(target); short tmdef = iStatus->get_total_mdef(target); int targetVit = min(120, status_get_vit(target)); @@ -3666,7 +3666,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * if( (vitfactor=(status_get_vit(target)-120.0f)) > 0) vitfactor = (vitfactor * (matk + atk) / 10) / status_get_vit(target); temp = max(0, vitfactor) + (targetVit * (matk + atk)) / 10; - md.damage = (int)(temp * 70 * skill_lv / 100); + md.damage = (int64)(temp * 70 * skill_lv / 100); } md.damage -= totaldef; } @@ -3712,9 +3712,9 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * nk|=NK_IGNORE_FLEE|NK_NO_ELEFIX; //These two are not properties of the weapon based part. #else int ratio = 300 + 50 * skill_lv; - int matk = battle->calc_magic_attack(src, target, skill_id, skill_lv, mflag).damage; + int64 matk = battle->calc_magic_attack(src, target, skill_id, skill_lv, mflag).damage; short totaldef = iStatus->get_total_def(target) + iStatus->get_total_mdef(target); - int atk = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, false, s_ele, ELE_NEUTRAL, EQI_HAND_R, (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0), md.flag); + int64 atk = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, false, s_ele, ELE_NEUTRAL, EQI_HAND_R, (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0), md.flag); if( sc && sc->data[SC_EDP] ) ratio >>= 1; @@ -3921,7 +3921,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * if( sd ) { if ( md.damage > sd->status.zeny ) md.damage = sd->status.zeny; - pc->payzeny(sd, md.damage,LOG_TYPE_STEAL,NULL); + pc->payzeny(sd, (int)cap_value(md.damage,INT_MIN,INT_MAX),LOG_TYPE_STEAL,NULL); } break; } @@ -5027,7 +5027,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list if( wd.damage + wd.damage2 ) { //There is a total damage value - int64 damage = wd.damage + wd.damage2, rdamage = 0, rdelay = 0; + int64 damage = wd.damage + wd.damage2, rdamage = 0; + int rdelay = 0; if( src != target && (!skill_id || skill_id || @@ -5085,7 +5086,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list wd.damage = battle->calc_damage(src,target,&wd,wd.damage,skill_id,skill_lv); wd.damage2 = battle->calc_damage(src,target,&wd,wd.damage2,skill_id,skill_lv); #else - int d1 = wd.damage + wd.damage2,d2 = wd.damage2; + int64 d1 = wd.damage + wd.damage2,d2 = wd.damage2; wd.damage = battle->calc_damage(src,target,&wd,d1,skill_id,skill_lv); #endif if( map_flag_gvg2(target->m) ) @@ -5172,7 +5173,7 @@ struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct bl } //Calculates BF_WEAPON returned damage. -int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, int64 *dmg, int flag, uint16 skill_id, int64 *delay){ +int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, int64 *dmg, int flag, uint16 skill_id, int *delay){ int64 rdamage = 0, damage = *dmg, trdamage = 0; struct map_session_data* sd; struct status_change* sc; @@ -5225,7 +5226,7 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i t_dir = unit_getdir(bl); if( !iMap->check_dir(dir,t_dir) ) { - int rd1 = damage * sc->data[SC_DEATHBOUND]->val2 / 100; // Amplify damage. + int64 rd1 = damage * sc->data[SC_DEATHBOUND]->val2 / 100; // Amplify damage. trdamage += rdamage = rd1 - (*dmg = rd1 * 30 / 100); // not normalized as intended. clif->skill_damage(src, bl, iTimer->gettick(), status_get_amotion(src), 0, -3000, 1, RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1, 6); skill->blown(bl, src, skill->get_blewcount(RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1), unit_getdir(src), 0); @@ -5240,7 +5241,7 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i } } } else { - if (sd && sd->bonus.long_weapon_damage_return){ + if (sd && sd->bonus.long_weapon_damage_return){ NORMALIZE_RDAMAGE(damage * sd->bonus.long_weapon_damage_return / 100); *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); } @@ -5254,10 +5255,11 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i return max(0, trdamage); } -void battle_drain(TBL_PC *sd, struct block_list *tbl, int rdamage, int ldamage, int race, int boss) +void battle_drain(TBL_PC *sd, struct block_list *tbl, int64 rdamage, int64 ldamage, int race, int boss) { struct weapon_data *wd; - int type, thp = 0, tsp = 0, rhp = 0, rsp = 0, hp, sp, i, *damage; + int type, thp = 0, tsp = 0, rhp = 0, rsp = 0, hp, sp, i; + int64 *damage; for (i = 0; i < 4; i++) { //First two iterations: Right hand if (i < 2) { wd = &sd->right_weapon; damage = &rdamage; } diff --git a/src/map/battle.h b/src/map/battle.h index 44f6dd84f..64883069b 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -492,9 +492,9 @@ struct battle_interface { /* delays damage or skills by a timer */ int (*delay_damage) (unsigned int tick, int amotion, struct block_list *src, struct block_list *target, int attack_type, uint16 skill_id, uint16 skill_lv, int64 damage, enum damage_lv dmg_lv, int ddelay, bool additional_effects); /* drain damage */ - void (*drain) (struct map_session_data *sd, struct block_list *tbl, int rdamage, int ldamage, int race, int boss); + void (*drain) (struct map_session_data *sd, struct block_list *tbl, int64 rdamage, int64 ldamage, int race, int boss); /* damage return/reflect */ - int64 (*calc_return_damage) (struct block_list *bl, struct block_list *src, int64 *, int flag, uint16 skill_id, int64 *); + int64 (*calc_return_damage) (struct block_list *bl, struct block_list *src, int64 *, int flag, uint16 skill_id, int *); /* attribute rate */ int (*attr_ratio) (int atk_elem, int def_type, int def_lv); /* applies attribute modifiers */ @@ -514,7 +514,7 @@ struct battle_interface { int64 (*calc_weapon_damage) (struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, struct weapon_atk *watk, int nk, bool n_ele, short s_ele, short s_ele_, int size, int type, int flag, int flag2); #endif /* applies defense reductions */ - int (*calc_defense) (int attack_type, struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 damage, int flag, int pdef); + int64 (*calc_defense) (int attack_type, struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 damage, int flag, int pdef); /* get master (who does this unit respond to?) */ struct block_list *(*get_master) (struct block_list *src); /* returns a random unit who is targeting this unit */ diff --git a/src/map/clif.c b/src/map/clif.c index 2ab379e31..847c426e5 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -4380,7 +4380,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { //Modifies the type of damage according to status changes [Skotlex] //Aegis data specifies that: 4 endure against single hit sources, 9 against multi-hit. -static inline int clif_calc_delay(int type, int div, int64 damage, int delay) +static inline int clif_calc_delay(int type, int div, int damage, int delay) { return ( delay == 0 && damage > 0 ) ? ( div > 1 ? 9 : 4 ) : type; } @@ -4388,7 +4388,7 @@ static inline int clif_calc_delay(int type, int div, int64 damage, int delay) /*========================================== * Estimates walk delay based on the damage criteria. [Skotlex] *------------------------------------------*/ -int clif_calc_walkdelay(struct block_list *bl,int delay, int type, int64 damage, int div_) { +int clif_calc_walkdelay(struct block_list *bl,int delay, int type, int damage, int div_) { if (type == 4 || type == 9 || damage <=0) return 0; @@ -4423,10 +4423,11 @@ int clif_calc_walkdelay(struct block_list *bl,int delay, int type, int64 damage, /// 10 = critical hit /// 11 = lucky dodge /// 12 = (touch skill?) -int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tick, int sdelay, int ddelay, int64 damage, int div, int type, int64 damage2) +int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tick, int sdelay, int ddelay, int64 in_damage, int div, int type, int64 in_damage2) { unsigned char buf[33]; struct status_change *sc; + int damage,damage2; #if PACKETVER < 20071113 const int cmd = 0x8a; #else @@ -4436,8 +4437,9 @@ int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tic nullpo_ret(src); nullpo_ret(dst); - damage = cap_value(damage,INT_MIN,INT_MAX); - damage2 = cap_value(damage2,INT_MIN,INT_MAX); + damage = (int)cap_value(in_damage,INT_MIN,INT_MAX); + damage2 = (int)cap_value(in_damage2,INT_MIN,INT_MAX); + type = clif_calc_delay(type,div,damage+damage2,ddelay); sc = iStatus->get_sc(dst); if(sc && sc->count) { @@ -5108,15 +5110,16 @@ void clif_skill_cooldown(struct map_session_data *sd, uint16 skill_id, unsigned /// Skill attack effect and damage. /// 0114 <skill id>.W <src id>.L <dst id>.L <tick>.L <src delay>.L <dst delay>.L <damage>.W <level>.W <div>.W <type>.B (ZC_NOTIFY_SKILL) /// 01de <skill id>.W <src id>.L <dst id>.L <tick>.L <src delay>.L <dst delay>.L <damage>.L <level>.W <div>.W <type>.B (ZC_NOTIFY_SKILL2) -int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int tick,int sdelay,int ddelay,int64 damage,int div,uint16 skill_id,uint16 skill_lv,int type) +int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int tick,int sdelay,int ddelay,int64 in_damage,int div,uint16 skill_id,uint16 skill_lv,int type) { unsigned char buf[64]; struct status_change *sc; + int damage; nullpo_ret(src); nullpo_ret(dst); - damage = cap_value(damage,INT_MIN,INT_MAX); + damage = (int)cap_value(in_damage,INT_MIN,INT_MAX); type = clif_calc_delay(type,div,damage,ddelay); sc = iStatus->get_sc(dst); if(sc && sc->count) { diff --git a/src/map/clif.h b/src/map/clif.h index 58230ce85..f414ecebb 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -532,7 +532,7 @@ struct clif_interface { void (*set_unit_idle2) (struct block_list* bl, struct map_session_data *tsd, enum send_target target); #endif void (*set_unit_walking) (struct block_list* bl, struct map_session_data *tsd,struct unit_data* ud, enum send_target target); - int (*calc_walkdelay) (struct block_list *bl,int delay, int type, int64 damage, int div_); + int (*calc_walkdelay) (struct block_list *bl,int delay, int type, int damage, int div_); void (*getareachar_skillunit) (struct map_session_data *sd, struct skill_unit *unit); void (*getareachar_unit) (struct map_session_data* sd,struct block_list *bl); void (*clearchar_skillunit) (struct skill_unit *unit, int fd); diff --git a/src/map/skill.c b/src/map/skill.c index 9befc1d32..a4070e92f 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2793,7 +2793,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds iMap->freeblock_unlock(); - return damage; + return (int)cap_value(damage,INT_MIN,INT_MAX); } /*========================================== @@ -12140,13 +12140,13 @@ int skill_unit_ondamaged (struct skill_unit *src, struct block_list *bl, int64 d case UNT_ICEWALL: case UNT_REVERBERATION: case UNT_WALLOFTHORN: - src->val1-=damage; + src->val1 -= (int)cap_value(damage,INT_MIN,INT_MAX); break; default: damage = 0; break; } - return damage; + return (int)cap_value(damage,INT_MIN,INT_MAX); } /*========================================== diff --git a/src/map/status.c b/src/map/status.c index c79fff44e..64a107b42 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1132,13 +1132,14 @@ int status_charge(struct block_list* bl, int64 hp, int64 sp) //If flag&2, fail if target does not has enough to substract. //If flag&4, if killed, mob must not give exp/loot. //flag will be set to &8 when damaging sp of a dead character -int status_damage(struct block_list *src,struct block_list *target,int64 hp, int64 sp, int walkdelay, int flag) { +int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, int64 in_sp, int walkdelay, int flag) { struct status_data *status; struct status_change *sc; + int hp,sp; /* here onwards we consider it a 32-type, the client does not support higher and from here onwards the value doesn't get thru percentage modifiers */ - hp = cap_value(hp,INT_MIN,INT_MAX); - sp = cap_value(sp,INT_MIN,INT_MAX); + hp = (int)cap_value(in_hp,INT_MIN,INT_MAX); + sp = (int)cap_value(in_sp,INT_MIN,INT_MAX); if(sp && !(target->type&BL_CONSUME)) sp = 0; //Not a valid SP target. @@ -1353,10 +1354,11 @@ int status_damage(struct block_list *src,struct block_list *target,int64 hp, 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,int64 hp,int64 sp, int flag) +int status_heal(struct block_list *bl,int64 in_hp,int64 in_sp, int flag) { struct status_data *status; struct status_change *sc; + int hp,sp; status = iStatus->get_status_data(bl); @@ -1364,8 +1366,8 @@ int status_heal(struct block_list *bl,int64 hp,int64 sp, int flag) return 0; /* here onwards we consider it a 32-type, the client does not support higher and from here onwards the value doesn't get thru percentage modifiers */ - hp = cap_value(hp,INT_MIN,INT_MAX); - sp = cap_value(sp,INT_MIN,INT_MAX); + hp = (int)cap_value(in_hp,INT_MIN,INT_MAX); + sp = (int)cap_value(in_sp,INT_MIN,INT_MAX); sc = iStatus->get_sc(bl); if (sc && !sc->count) |