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
* 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 )
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.
*------------------------------------------*/
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.
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)
ATK_ADD(wd.masteryAtk, wd.masteryAtk2, 4);
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
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
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) {
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) {
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;
}
@ -4552,24 +4552,24 @@ struct Damage battle_calc_attack_gvg_bg(struct Damage wd, struct block_list *src
if(!wd.damage2) {
wd.damage = battle_calc_damage(src,target,&wd,wd.damage,skill_id,skill_lv);
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 )
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) {
wd.damage2 = battle_calc_damage(src,target,&wd,wd.damage2,skill_id,skill_lv);
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 )
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 {
int64 d1 = wd.damage + wd.damage2,d2 = wd.damage2;
wd.damage = battle_calc_damage(src,target,&wd,d1,skill_id,skill_lv);
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 )
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;
if(wd.damage > 1 && wd.damage2 < 1) wd.damage2 = 1;
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)
ATK_ADD(wd.damage, wd.damage2, 4);
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
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
if( skill_id == CR_SHIELDBOOMERANG || skill_id == PA_SHIELDCHAIN ) { //Refine bonus applies after cards and elements.
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:
ad.damage=battle_calc_damage(src,target,&ad,ad.damage,skill_id,skill_lv);
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 )
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;
}
@ -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);
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 )
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 ) {
case RA_FIRINGTRAP:

View File

@ -8,57 +8,66 @@
#include "../config/core.h"
#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 {
ATK_NONE, // not an attack
ATK_LUCKY, // attack was lucky-dodged
ATK_FLEE, // attack was dodged
ATK_MISS, // attack missed because of element/race modifier.
ATK_BLOCK, // attack was blocked by some skills.
ATK_DEF // attack connected
ATK_NONE, /// Not an attack
ATK_LUCKY, /// Attack was lucky-dodged
ATK_FLEE, /// Attack was dodged
ATK_MISS, /// Attack missed because of element/race modifier.
ATK_BLOCK, /// Attack was blocked by some skills.
ATK_DEF /// Attack connected
} damage_lv;
enum { // Flag of the final calculation
BF_WEAPON = 0x0001,
BF_MAGIC = 0x0002,
BF_MISC = 0x0004,
BF_SHORT = 0x0010,
BF_LONG = 0x0040,
BF_SKILL = 0x0100,
BF_NORMAL = 0x0200,
BF_WEAPONMASK=0x000f,
BF_RANGEMASK= 0x00f0,
BF_SKILLMASK= 0x0f00,
/// Flag of the final calculation
enum e_battle_flag {
BF_WEAPON = 0x0001, /// Weapon attack
BF_MAGIC = 0x0002, /// Magic attack
BF_MISC = 0x0004, /// Misc attack
BF_SHORT = 0x0010, /// Short attack
BF_LONG = 0x0040, /// Long attack
BF_SKILL = 0x0100, /// Skill attack
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
{//New definitions [Skotlex]
BCT_NOONE = 0x000000,
BCT_SELF = 0x010000,
BCT_ENEMY = 0x020000,
BCT_PARTY = 0x040000,
BCT_GUILDALLY = 0x080000, // Only allies, NOT guildmates
BCT_NEUTRAL = 0x100000,
BCT_SAMEGUILD = 0x200000, // No Guild Allies
BCT_GUILD = 0x280000, // Guild AND Allies (BCT_SAMEGUILD|BCT_GUILDALLY)
BCT_NOGUILD = 0x170000, // This should be (~BCT_GUILD&BCT_ALL)
BCT_NOPARTY = 0x3b0000, // This should be (~BCT_PARTY&BCT_ALL)
BCT_NOENEMY = 0x3d0000, // This should be (~BCT_ENEMY&BCT_ALL)
BCT_ALL = 0x3f0000,
/// Battle check target [Skotlex]
enum e_battle_check_target {
BCT_NOONE = 0x000000, /// No one
BCT_SELF = 0x010000, /// Self
BCT_ENEMY = 0x020000, /// Enemy
BCT_PARTY = 0x040000, /// Party members
BCT_GUILDALLY = 0x080000, /// Only allies, NOT guildmates
BCT_NEUTRAL = 0x100000, /// Neutral target
BCT_SAMEGUILD = 0x200000, /// Guildmates, No Guild Allies
BCT_ALL = 0x3F0000, /// All targets
BCT_GUILD = BCT_SAMEGUILD|BCT_GUILDALLY, /// Guild AND Allies (BCT_SAMEGUILD|BCT_GUILDALLY)
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 {
#ifdef RENEWAL
int statusAtk, statusAtk2, weaponAtk, weaponAtk2, equipAtk, equipAtk2, masteryAtk, masteryAtk2;
#endif
int64 damage,damage2; //right, left dmg
int type,div_; //chk clif_damage for type @TODO add an enum ? ; nb of hit
int amotion,dmotion;
int blewcount; //nb of knockback
int flag; //chk BF_* flag, (enum below)
int miscflag; //
enum damage_lv dmg_lv; //ATK_LUCKY,ATK_FLEE,ATK_DEF
int64 damage, /// Right hand damage
damage2; /// Left hand damage
int type, /// chk clif_damage for type @TODO add an enum ?
div_; /// Number of hit
int amotion,
dmotion;
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)
@ -82,8 +91,8 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li
// 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_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_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_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,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);
@ -530,6 +539,17 @@ extern struct Battle_Config
int feature_autotrade_direction;
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 warg_can_falcon;
int path_blown_halt;
@ -543,17 +563,6 @@ extern struct Battle_Config
int taekwon_ranker_min_lv;
int revive_onwarp;
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;
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) {
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;
}
spell[i].id = id;
@ -1971,7 +1971,7 @@ static void pc_bonus_autospell_onskill(struct s_autospell *spell, int max, short
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;
}
@ -2002,7 +2002,7 @@ static void pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type id
}
}
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;
}
effect[i].id = id;
@ -2023,7 +2023,7 @@ static void pc_bonus_addeff_onskill(struct s_addeffectonskill* effect, int 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;
}
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)
{
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)) {
ShowWarning("pc_bonus_item_drop: Invalid item id %hu\n",nameid);
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);
return;
}
@ -2215,7 +2219,7 @@ static void pc_bonus_addele(struct map_session_data* sd, unsigned char ele, shor
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;
}
@ -2244,7 +2248,7 @@ static void pc_bonus_subele(struct map_session_data* sd, unsigned char ele, shor
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;
}