Bug Fixes:

- Fixed wrong check added at e7b654a (bugreport:9095)
- Spirit sphere reduces damage for skill hit num < 0, eg. MO_TRIPLEATTACK has hit num -3. (bugreport:9094)
Misc:
- Removed unused parameters in battle_calc_bg_damage() and battle_calc_gvg_damage()
- Some random src docs.

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>
This commit is contained in:
Cydh Ramdh 2014-07-06 20:53:25 +07:00
parent 79f4600dcd
commit fcd79d63aa
3 changed files with 92 additions and 79 deletions

View File

@ -1270,7 +1270,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
* Initial refactoring by Baalberith * Initial refactoring by Baalberith
* Refined and optimized by helvetica * Refined and optimized by helvetica
*/ */
int64 battle_calc_bg_damage(struct block_list *src, struct block_list *bl, int64 damage, int div_, uint16 skill_id, uint16 skill_lv, int flag) int64 battle_calc_bg_damage(struct block_list *src, struct block_list *bl, int64 damage, uint16 skill_id, int flag)
{ {
if( !damage ) if( !damage )
return 0; return 0;
@ -1326,7 +1326,7 @@ bool battle_can_hit_gvg_target(struct block_list *src,struct block_list *bl,uint
/*========================================== /*==========================================
* Calculates GVG related damage adjustments. * Calculates GVG related damage adjustments.
*------------------------------------------*/ *------------------------------------------*/
int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64 damage,int div_,uint16 skill_id,uint16 skill_lv,int flag) int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64 damage,uint16 skill_id,int flag)
{ {
if (!damage) //No reductions to make. if (!damage) //No reductions to make.
return 0; return 0;
@ -2523,9 +2523,9 @@ static struct Damage battle_calc_attack_masteries(struct Damage wd, struct block
if (skill_id != MC_CARTREVOLUTION && pc_checkskill(sd, BS_HILTBINDING) > 0) if (skill_id != MC_CARTREVOLUTION && pc_checkskill(sd, BS_HILTBINDING) > 0)
ATK_ADD(wd.masteryAtk, wd.masteryAtk2, 4); ATK_ADD(wd.masteryAtk, wd.masteryAtk2, 4);
if (skill_id == MO_FINGEROFFENSIVE) { if (skill_id == MO_FINGEROFFENSIVE) {
ATK_ADD(wd.masteryAtk, wd.masteryAtk2, wd.div_ * sd->spiritball_old * 3); ATK_ADD(wd.masteryAtk, wd.masteryAtk2, ((wd.div_ < 1) ? 1 : wd.div_) * sd->spiritball_old * 3);
} else } else
ATK_ADD(wd.masteryAtk, wd.masteryAtk2, wd.div_ * sd->spiritball * 3); ATK_ADD(wd.masteryAtk, wd.masteryAtk2, ((wd.div_ < 1) ? 1 : wd.div_) * sd->spiritball * 3);
#endif #endif
if (sc) { // Status change considered as masteries if (sc) { // Status change considered as masteries
@ -4467,10 +4467,10 @@ struct Damage battle_calc_attack_plant(struct Damage wd, struct block_list *src,
} }
if (wd.damage > 0) { if (wd.damage > 0) {
wd.damage = battle_attr_fix(src, target, wd.damage, right_element, tstatus->def_ele, tstatus->ele_lv); 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, wd.div_, skill_id, skill_lv, wd.flag); wd.damage = battle_calc_gvg_damage(src, target, wd.damage, skill_id, wd.flag);
} else if (wd.damage2 > 0) { } else if (wd.damage2 > 0) {
wd.damage2 = battle_attr_fix(src, target, wd.damage2, left_element, tstatus->def_ele, tstatus->ele_lv); wd.damage2 = battle_attr_fix(src, target, wd.damage2, left_element, tstatus->def_ele, tstatus->ele_lv);
wd.damage2 = battle_calc_gvg_damage(src, target, wd.damage2, wd.div_, skill_id, skill_lv, wd.flag); wd.damage2 = battle_calc_gvg_damage(src, target, wd.damage2, skill_id, wd.flag);
} }
return wd; return wd;
} }
@ -4552,24 +4552,24 @@ struct Damage battle_calc_attack_gvg_bg(struct Damage wd, struct block_list *src
if(!wd.damage2) { if(!wd.damage2) {
wd.damage = battle_calc_damage(src,target,&wd,wd.damage,skill_id,skill_lv); wd.damage = battle_calc_damage(src,target,&wd,wd.damage,skill_id,skill_lv);
if( map_flag_gvg2(target->m) ) if( map_flag_gvg2(target->m) )
wd.damage=battle_calc_gvg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); wd.damage=battle_calc_gvg_damage(src,target,wd.damage,skill_id,wd.flag);
else if( map[target->m].flag.battleground ) else if( map[target->m].flag.battleground )
wd.damage=battle_calc_bg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); wd.damage=battle_calc_bg_damage(src,target,wd.damage,skill_id,wd.flag);
} }
else if(!wd.damage) { else if(!wd.damage) {
wd.damage2 = battle_calc_damage(src,target,&wd,wd.damage2,skill_id,skill_lv); wd.damage2 = battle_calc_damage(src,target,&wd,wd.damage2,skill_id,skill_lv);
if( map_flag_gvg2(target->m) ) if( map_flag_gvg2(target->m) )
wd.damage2 = battle_calc_gvg_damage(src,target,wd.damage2,wd.div_,skill_id,skill_lv,wd.flag); wd.damage2 = battle_calc_gvg_damage(src,target,wd.damage2,skill_id,wd.flag);
else if( map[target->m].flag.battleground ) else if( map[target->m].flag.battleground )
wd.damage2 = battle_calc_bg_damage(src,target,wd.damage2,wd.div_,skill_id,skill_lv,wd.flag); wd.damage2 = battle_calc_bg_damage(src,target,wd.damage2,skill_id,wd.flag);
} }
else { else {
int64 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); wd.damage = battle_calc_damage(src,target,&wd,d1,skill_id,skill_lv);
if( map_flag_gvg2(target->m) ) if( map_flag_gvg2(target->m) )
wd.damage = battle_calc_gvg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); wd.damage = battle_calc_gvg_damage(src,target,wd.damage,skill_id,wd.flag);
else if( map[target->m].flag.battleground ) else if( map[target->m].flag.battleground )
wd.damage = battle_calc_bg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); wd.damage = battle_calc_bg_damage(src,target,wd.damage,skill_id,wd.flag);
wd.damage2 = (int64)d2*100/d1 * wd.damage/100; wd.damage2 = (int64)d2*100/d1 * wd.damage/100;
if(wd.damage > 1 && wd.damage2 < 1) wd.damage2 = 1; if(wd.damage > 1 && wd.damage2 < 1) wd.damage2 = 1;
wd.damage-=wd.damage2; wd.damage-=wd.damage2;
@ -5048,9 +5048,9 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src, struct bl
if (skill_id != MC_CARTREVOLUTION && pc_checkskill(sd, BS_HILTBINDING) > 0) if (skill_id != MC_CARTREVOLUTION && pc_checkskill(sd, BS_HILTBINDING) > 0)
ATK_ADD(wd.damage, wd.damage2, 4); ATK_ADD(wd.damage, wd.damage2, 4);
if (skill_id == MO_FINGEROFFENSIVE) { //The finger offensive spheres on moment of attack do count. [Skotlex] if (skill_id == MO_FINGEROFFENSIVE) { //The finger offensive spheres on moment of attack do count. [Skotlex]
ATK_ADD(wd.damage, wd.damage2, wd.div_ * sd->spiritball_old * 3); ATK_ADD(wd.damage, wd.damage2, ((wd.div_ < 1) ? 1 : wd.div_) * sd->spiritball_old * 3);
} else } else
ATK_ADD(wd.damage, wd.damage2, wd.div_ * sd->spiritball * 3); ATK_ADD(wd.damage, wd.damage2, ((wd.div_ < 1) ? 1 : wd.div_) * sd->spiritball * 3);
#endif #endif
if( skill_id == CR_SHIELDBOOMERANG || skill_id == PA_SHIELDCHAIN ) { //Refine bonus applies after cards and elements. if( skill_id == CR_SHIELDBOOMERANG || skill_id == PA_SHIELDCHAIN ) { //Refine bonus applies after cards and elements.
short index = sd->equip_index[EQI_HAND_L]; short index = sd->equip_index[EQI_HAND_L];
@ -5933,9 +5933,9 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
default: default:
ad.damage=battle_calc_damage(src,target,&ad,ad.damage,skill_id,skill_lv); ad.damage=battle_calc_damage(src,target,&ad,ad.damage,skill_id,skill_lv);
if( map_flag_gvg2(target->m) ) if( map_flag_gvg2(target->m) )
ad.damage=battle_calc_gvg_damage(src,target,ad.damage,ad.div_,skill_id,skill_lv,ad.flag); ad.damage=battle_calc_gvg_damage(src,target,ad.damage,skill_id,ad.flag);
else if( map[target->m].flag.battleground ) else if( map[target->m].flag.battleground )
ad.damage=battle_calc_bg_damage(src,target,ad.damage,ad.div_,skill_id,skill_lv,ad.flag); ad.damage=battle_calc_bg_damage(src,target,ad.damage,skill_id,ad.flag);
break; break;
} }
@ -6303,9 +6303,9 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
md.damage=battle_calc_damage(src,target,&md,md.damage,skill_id,skill_lv); md.damage=battle_calc_damage(src,target,&md,md.damage,skill_id,skill_lv);
if( map_flag_gvg2(target->m) ) if( map_flag_gvg2(target->m) )
md.damage=battle_calc_gvg_damage(src,target,md.damage,md.div_,skill_id,skill_lv,md.flag); md.damage=battle_calc_gvg_damage(src,target,md.damage,skill_id,md.flag);
else if( map[target->m].flag.battleground ) else if( map[target->m].flag.battleground )
md.damage=battle_calc_bg_damage(src,target,md.damage,md.div_,skill_id,skill_lv,md.flag); md.damage=battle_calc_bg_damage(src,target,md.damage,skill_id,md.flag);
switch( skill_id ) { switch( skill_id ) {
case RA_FIRINGTRAP: case RA_FIRINGTRAP:

View File

@ -8,57 +8,66 @@
#include "../config/core.h" #include "../config/core.h"
#include "map.h" //ELE_MAX #include "map.h" //ELE_MAX
// state of a single attack attempt; used in flee/def penalty calculations when mobbed /// State of a single attack attempt; used in flee/def penalty calculations when mobbed
typedef enum damage_lv { typedef enum damage_lv {
ATK_NONE, // not an attack ATK_NONE, /// Not an attack
ATK_LUCKY, // attack was lucky-dodged ATK_LUCKY, /// Attack was lucky-dodged
ATK_FLEE, // attack was dodged ATK_FLEE, /// Attack was dodged
ATK_MISS, // attack missed because of element/race modifier. ATK_MISS, /// Attack missed because of element/race modifier.
ATK_BLOCK, // attack was blocked by some skills. ATK_BLOCK, /// Attack was blocked by some skills.
ATK_DEF // attack connected ATK_DEF /// Attack connected
} damage_lv; } damage_lv;
enum { // Flag of the final calculation /// Flag of the final calculation
BF_WEAPON = 0x0001, enum e_battle_flag {
BF_MAGIC = 0x0002, BF_WEAPON = 0x0001, /// Weapon attack
BF_MISC = 0x0004, BF_MAGIC = 0x0002, /// Magic attack
BF_SHORT = 0x0010, BF_MISC = 0x0004, /// Misc attack
BF_LONG = 0x0040,
BF_SKILL = 0x0100, BF_SHORT = 0x0010, /// Short attack
BF_NORMAL = 0x0200, BF_LONG = 0x0040, /// Long attack
BF_WEAPONMASK=0x000f,
BF_RANGEMASK= 0x00f0, BF_SKILL = 0x0100, /// Skill attack
BF_SKILLMASK= 0x0f00, BF_NORMAL = 0x0200, /// Normal attack
BF_WEAPONMASK = BF_WEAPON|BF_MAGIC|BF_MISC, /// Weapon attack mask
BF_RANGEMASK = BF_SHORT|BF_LONG, /// Range attack mask
BF_SKILLMASK = BF_SKILL|BF_NORMAL, /// Skill attack mask
}; };
enum e_battle_check_target /// Battle check target [Skotlex]
{//New definitions [Skotlex] enum e_battle_check_target {
BCT_NOONE = 0x000000, BCT_NOONE = 0x000000, /// No one
BCT_SELF = 0x010000, BCT_SELF = 0x010000, /// Self
BCT_ENEMY = 0x020000, BCT_ENEMY = 0x020000, /// Enemy
BCT_PARTY = 0x040000, BCT_PARTY = 0x040000, /// Party members
BCT_GUILDALLY = 0x080000, // Only allies, NOT guildmates BCT_GUILDALLY = 0x080000, /// Only allies, NOT guildmates
BCT_NEUTRAL = 0x100000, BCT_NEUTRAL = 0x100000, /// Neutral target
BCT_SAMEGUILD = 0x200000, // No Guild Allies BCT_SAMEGUILD = 0x200000, /// Guildmates, No Guild Allies
BCT_GUILD = 0x280000, // Guild AND Allies (BCT_SAMEGUILD|BCT_GUILDALLY)
BCT_NOGUILD = 0x170000, // This should be (~BCT_GUILD&BCT_ALL) BCT_ALL = 0x3F0000, /// All targets
BCT_NOPARTY = 0x3b0000, // This should be (~BCT_PARTY&BCT_ALL)
BCT_NOENEMY = 0x3d0000, // This should be (~BCT_ENEMY&BCT_ALL) BCT_GUILD = BCT_SAMEGUILD|BCT_GUILDALLY, /// Guild AND Allies (BCT_SAMEGUILD|BCT_GUILDALLY)
BCT_ALL = 0x3f0000, BCT_NOGUILD = BCT_ALL&~BCT_GUILD, /// Except guildmates
BCT_NOPARTY = BCT_ALL&~BCT_PARTY, /// Except party members
BCT_NOENEMY = BCT_ALL&~BCT_ENEMY, /// Except enemy
}; };
// dammage structure /// Damage structure
struct Damage { struct Damage {
#ifdef RENEWAL #ifdef RENEWAL
int statusAtk, statusAtk2, weaponAtk, weaponAtk2, equipAtk, equipAtk2, masteryAtk, masteryAtk2; int statusAtk, statusAtk2, weaponAtk, weaponAtk2, equipAtk, equipAtk2, masteryAtk, masteryAtk2;
#endif #endif
int64 damage,damage2; //right, left dmg int64 damage, /// Right hand damage
int type,div_; //chk clif_damage for type @TODO add an enum ? ; nb of hit damage2; /// Left hand damage
int amotion,dmotion; int type, /// chk clif_damage for type @TODO add an enum ?
int blewcount; //nb of knockback div_; /// Number of hit
int flag; //chk BF_* flag, (enum below) int amotion,
int miscflag; // dmotion;
enum damage_lv dmg_lv; //ATK_LUCKY,ATK_FLEE,ATK_DEF int blewcount; /// Number of knockback
int flag; /// chk e_battle_flag
int miscflag;
enum damage_lv dmg_lv; /// ATK_LUCKY,ATK_FLEE,ATK_DEF
}; };
//(Used in read pc.c,) attribute table (battle_attr_fix) //(Used in read pc.c,) attribute table (battle_attr_fix)
@ -82,8 +91,8 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li
// Final calculation Damage // Final calculation Damage
int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damage *d,int64 damage,uint16 skill_id,uint16 skill_lv); int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damage *d,int64 damage,uint16 skill_id,uint16 skill_lv);
int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64 damage,int div_,uint16 skill_id,uint16 skill_lv,int flag); int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64 damage,uint16 skill_id,int flag);
int64 battle_calc_bg_damage(struct block_list *src,struct block_list *bl,int64 damage,int div_,uint16 skill_id,uint16 skill_lv,int flag); int64 battle_calc_bg_damage(struct block_list *src,struct block_list *bl,int64 damage,uint16 skill_id,int flag);
int battle_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); int battle_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);
@ -530,6 +539,17 @@ extern struct Battle_Config
int feature_autotrade_direction; int feature_autotrade_direction;
int feature_autotrade_sit; int feature_autotrade_sit;
// Fame points
int fame_taekwon_mission;
int fame_refine_lv1;
int fame_refine_lv2;
int fame_refine_lv3;
int fame_forge;
int fame_pharmacy_3;
int fame_pharmacy_5;
int fame_pharmacy_7;
int fame_pharmacy_10;
int disp_serverbank_msg; int disp_serverbank_msg;
int warg_can_falcon; int warg_can_falcon;
int path_blown_halt; int path_blown_halt;
@ -543,17 +563,6 @@ extern struct Battle_Config
int taekwon_ranker_min_lv; int taekwon_ranker_min_lv;
int revive_onwarp; int revive_onwarp;
int mail_delay; int mail_delay;
// Fame points
int fame_taekwon_mission;
int fame_refine_lv1;
int fame_refine_lv2;
int fame_refine_lv3;
int fame_forge;
int fame_pharmacy_3;
int fame_pharmacy_5;
int fame_pharmacy_7;
int fame_pharmacy_10;
} battle_config; } battle_config;
void do_init_battle(void); void do_init_battle(void);

View File

@ -1940,7 +1940,7 @@ static void pc_bonus_autospell(struct s_autospell *spell, int max, short id, sho
} }
} }
if (i == max) { if (i == max) {
ShowWarning("pc_bonus: Reached max (%d) number of autospells per character!\n", max); ShowWarning("pc_bonus_autospell: Reached max (%d) number of autospells per character!\n", max);
return; return;
} }
spell[i].id = id; spell[i].id = id;
@ -1971,7 +1971,7 @@ static void pc_bonus_autospell_onskill(struct s_autospell *spell, int max, short
if( i == max ) if( i == max )
{ {
ShowWarning("pc_bonus: Reached max (%d) number of autospells per character!\n", max); ShowWarning("pc_bonus_autospell_onskill: Reached max (%d) number of autospells per character!\n", max);
return; return;
} }
@ -2002,7 +2002,7 @@ static void pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type id
} }
} }
if (i == max) { if (i == max) {
ShowWarning("pc_bonus: Reached max (%d) number of add effects per character!\n", max); ShowWarning("pc_bonus_addeff: Reached max (%d) number of add effects per character!\n", max);
return; return;
} }
effect[i].id = id; effect[i].id = id;
@ -2023,7 +2023,7 @@ static void pc_bonus_addeff_onskill(struct s_addeffectonskill* effect, int max,
} }
} }
if( i == max ) { if( i == max ) {
ShowWarning("pc_bonus: Reached max (%d) number of add effects on skill per character!\n", max); ShowWarning("pc_bonus_addeff_onskill: Reached max (%d) number of add effects on skill per character!\n", max);
return; return;
} }
effect[i].id = id; effect[i].id = id;
@ -2044,12 +2044,16 @@ static void pc_bonus_addeff_onskill(struct s_addeffectonskill* effect, int max,
static void pc_bonus_item_drop(struct s_add_drop *drop, const short max, unsigned short nameid, uint16 group, int class_, short race, int rate) static void pc_bonus_item_drop(struct s_add_drop *drop, const short max, unsigned short nameid, uint16 group, int class_, short race, int rate)
{ {
uint8 i; uint8 i;
struct s_item_group_db *group_ = NULL;
if (!nameid && !group) {
ShowWarning("pc_bonus_item_drop: No Item ID nor Item Group ID specified.\n");
return;
}
if (nameid && !itemdb_exists(nameid)) { if (nameid && !itemdb_exists(nameid)) {
ShowWarning("pc_bonus_item_drop: Invalid item id %hu\n",nameid); ShowWarning("pc_bonus_item_drop: Invalid item id %hu\n",nameid);
return; return;
} }
if (!group || (group_ = itemdb_group_exists(group)) == NULL) { if (group && !itemdb_group_exists(group)) {
ShowWarning("pc_bonus_item_drop: Invalid Item Group %hu\n",group); ShowWarning("pc_bonus_item_drop: Invalid Item Group %hu\n",group);
return; return;
} }
@ -2215,7 +2219,7 @@ static void pc_bonus_addele(struct map_session_data* sd, unsigned char ele, shor
if (i == MAX_PC_BONUS) if (i == MAX_PC_BONUS)
{ {
ShowWarning("pc_addele: Reached max (%d) possible bonuses for this player.\n", MAX_PC_BONUS); ShowWarning("pc_bonus_addele: Reached max (%d) possible bonuses for this player.\n", MAX_PC_BONUS);
return; return;
} }
@ -2244,7 +2248,7 @@ static void pc_bonus_subele(struct map_session_data* sd, unsigned char ele, shor
if (i == MAX_PC_BONUS) if (i == MAX_PC_BONUS)
{ {
ShowWarning("pc_subele: Reached max (%d) possible bonuses for this player.\n", MAX_PC_BONUS); ShowWarning("pc_bonus_subele: Reached max (%d) possible bonuses for this player.\n", MAX_PC_BONUS);
return; return;
} }