summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorL0ne_W0lf <L0ne_W0lf@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-08-18 19:24:27 +0000
committerL0ne_W0lf <L0ne_W0lf@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-08-18 19:24:27 +0000
commit480fd5dec044c10579f0e9b5b24ce92a5b38fc7d (patch)
tree7255c561a69e2f7055c5b88b352d79df56bbbc38 /src/map
parentc024c27068518fef269dc9dbe5c1d01a0b50d963 (diff)
downloadhercules-480fd5dec044c10579f0e9b5b24ce92a5b38fc7d.tar.gz
hercules-480fd5dec044c10579f0e9b5b24ce92a5b38fc7d.tar.bz2
hercules-480fd5dec044c10579f0e9b5b24ce92a5b38fc7d.tar.xz
hercules-480fd5dec044c10579f0e9b5b24ce92a5b38fc7d.zip
* Added bonus3 bAdd/SubEle, which allows you to specify a battle flag as well! Dun dun dun!
- The bonuses are addititive to existing bAdd/SubEles, as that's how it appears to work. - Updated Asprika to use new bonus3 bSubEle. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14381 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/battle.c124
-rw-r--r--src/map/pc.c83
-rw-r--r--src/map/pc.h9
-rw-r--r--src/map/status.c1
4 files changed, 204 insertions, 13 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index 0f800b759..12f16f83d 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -2001,12 +2001,23 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
if( (wd.damage || wd.damage2) && !(nk&NK_NO_CARDFIX_ATK) )
{
int cardfix = 1000, cardfix_ = 1000;
- int t_race2 = status_get_race2(target);
+ int t_race2 = status_get_race2(target);
if(sd->state.arrow_atk)
{
cardfix=cardfix*(100+sd->right_weapon.addrace[tstatus->race]+sd->arrow_addrace[tstatus->race])/100;
if (!(nk&NK_NO_ELEFIX))
- cardfix=cardfix*(100+sd->right_weapon.addele[tstatus->def_ele]+sd->arrow_addele[tstatus->def_ele])/100;
+ {
+ int ele_fix = sd->right_weapon.addele[tstatus->def_ele] + sd->arrow_addele[tstatus->def_ele];
+ for (i = 0; ARRAYLENGTH(sd->right_weapon.addele2) > i && sd->right_weapon.addele2[i].rate != 0; i++) {
+ if (sd->right_weapon.addele2[i].ele != tstatus->def_ele) continue;
+ if(!(sd->right_weapon.addele2[i].flag&wd.flag&BF_WEAPONMASK &&
+ sd->right_weapon.addele2[i].flag&wd.flag&BF_RANGEMASK &&
+ sd->right_weapon.addele2[i].flag&wd.flag&BF_SKILLMASK))
+ continue;
+ ele_fix += sd->right_weapon.addele2[i].rate;
+ }
+ cardfix=cardfix*(100+ele_fix)/100;
+ }
cardfix=cardfix*(100+sd->right_weapon.addsize[tstatus->size]+sd->arrow_addsize[tstatus->size])/100;
cardfix=cardfix*(100+sd->right_weapon.addrace2[t_race2])/100;
cardfix=cardfix*(100+sd->right_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS]+sd->arrow_addrace[is_boss(target)?RC_BOSS:RC_NONBOSS])/100;
@@ -2017,9 +2028,19 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
{ // Melee attack
if( !battle_config.left_cardfix_to_right )
{
- cardfix=cardfix*(100+sd->right_weapon.addrace[tstatus->race])/100;
- if (!(nk&NK_NO_ELEFIX))
- cardfix=cardfix*(100+sd->right_weapon.addele[tstatus->def_ele])/100;
+ cardfix=cardfix*(100+sd->right_weapon.addrace[tstatus->race])/100;
+ if (!(nk&NK_NO_ELEFIX)) {
+ int ele_fix = sd->right_weapon.addele[tstatus->def_ele];
+ for (i = 0; ARRAYLENGTH(sd->right_weapon.addele2) > i && sd->right_weapon.addele2[i].rate != 0; i++) {
+ if (sd->right_weapon.addele2[i].ele != tstatus->def_ele) continue;
+ if(!(sd->right_weapon.addele2[i].flag&wd.flag&BF_WEAPONMASK &&
+ sd->right_weapon.addele2[i].flag&wd.flag&BF_RANGEMASK &&
+ sd->right_weapon.addele2[i].flag&wd.flag&BF_SKILLMASK))
+ continue;
+ ele_fix += sd->right_weapon.addele2[i].rate;
+ }
+ cardfix=cardfix*(100+ele_fix)/100;
+ }
cardfix=cardfix*(100+sd->right_weapon.addsize[tstatus->size])/100;
cardfix=cardfix*(100+sd->right_weapon.addrace2[t_race2])/100;
cardfix=cardfix*(100+sd->right_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS])/100;
@@ -2028,9 +2049,19 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
if( flag.lh )
{
- cardfix_=cardfix_*(100+sd->left_weapon.addrace[tstatus->race])/100;
- if (!(nk&NK_NO_ELEFIX))
- cardfix_=cardfix_*(100+sd->left_weapon.addele[tstatus->def_ele])/100;
+ cardfix_=cardfix_*(100+sd->left_weapon.addrace[tstatus->race])/100;
+ if (!(nk&NK_NO_ELEFIX)) {
+ int ele_fix_lh = sd->left_weapon.addele[tstatus->def_ele];
+ for (i = 0; ARRAYLENGTH(sd->left_weapon.addele2) > i && sd->left_weapon.addele2[i].rate != 0; i++) {
+ if (sd->left_weapon.addele2[i].ele != tstatus->def_ele) continue;
+ if(!(sd->left_weapon.addele2[i].flag&wd.flag&BF_WEAPONMASK &&
+ sd->left_weapon.addele2[i].flag&wd.flag&BF_RANGEMASK &&
+ sd->left_weapon.addele2[i].flag&wd.flag&BF_SKILLMASK))
+ continue;
+ ele_fix_lh += sd->left_weapon.addele2[i].rate;
+ }
+ cardfix=cardfix*(100+ele_fix_lh)/100;
+ }
cardfix_=cardfix_*(100+sd->left_weapon.addsize[tstatus->size])/100;
cardfix_=cardfix_*(100+sd->left_weapon.addrace2[t_race2])/100;
cardfix_=cardfix_*(100+sd->left_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS])/100;
@@ -2040,8 +2071,26 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
}
else
{
+ int ele_fix = sd->right_weapon.addele[tstatus->def_ele] + sd->left_weapon.addele[tstatus->def_ele];
+ for (i = 0; ARRAYLENGTH(sd->right_weapon.addele2) > i && sd->right_weapon.addele2[i].rate != 0; i++) {
+ if (sd->right_weapon.addele2[i].ele != tstatus->def_ele) continue;
+ if(!(sd->right_weapon.addele2[i].flag&wd.flag&BF_WEAPONMASK &&
+ sd->right_weapon.addele2[i].flag&wd.flag&BF_RANGEMASK &&
+ sd->right_weapon.addele2[i].flag&wd.flag&BF_SKILLMASK))
+ continue;
+ ele_fix += sd->right_weapon.addele2[i].rate;
+ }
+ for (i = 0; ARRAYLENGTH(sd->left_weapon.addele2) > i && sd->left_weapon.addele2[i].rate != 0; i++) {
+ if (sd->left_weapon.addele2[i].ele != tstatus->def_ele) continue;
+ if(!(sd->left_weapon.addele2[i].flag&wd.flag&BF_WEAPONMASK &&
+ sd->left_weapon.addele2[i].flag&wd.flag&BF_RANGEMASK &&
+ sd->left_weapon.addele2[i].flag&wd.flag&BF_SKILLMASK))
+ continue;
+ ele_fix += sd->left_weapon.addele2[i].rate;
+ }
+
cardfix=cardfix*(100+sd->right_weapon.addrace[tstatus->race]+sd->left_weapon.addrace[tstatus->race])/100;
- cardfix=cardfix*(100+sd->right_weapon.addele[tstatus->def_ele]+sd->left_weapon.addele[tstatus->def_ele])/100;
+ cardfix=cardfix*(100+ele_fix)/100;
cardfix=cardfix*(100+sd->right_weapon.addsize[tstatus->size]+sd->left_weapon.addsize[tstatus->size])/100;
cardfix=cardfix*(100+sd->right_weapon.addrace2[t_race2]+sd->left_weapon.addrace2[t_race2])/100;
cardfix=cardfix*(100+sd->right_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS]+sd->left_weapon.addrace[is_boss(target)?RC_BOSS:RC_NONBOSS])/100;
@@ -2097,9 +2146,31 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo
if( !(nk&NK_NO_ELEFIX) )
{
- cardfix=cardfix*(100-tsd->subele[s_ele])/100;
+ int ele_fix = tsd->subele[s_ele];
+ for (i = 0; ARRAYLENGTH(tsd->subele2) > i && tsd->subele2[i].rate != 0; i++)
+ {
+ if(tsd->subele2[i].ele != s_ele) continue;
+ if(!(tsd->subele2[i].flag&wd.flag&BF_WEAPONMASK &&
+ tsd->subele2[i].flag&wd.flag&BF_RANGEMASK &&
+ tsd->subele2[i].flag&wd.flag&BF_SKILLMASK))
+ continue;
+ ele_fix += tsd->subele2[i].rate;
+ }
+ cardfix=cardfix*(100-ele_fix)/100;
if( flag.lh && s_ele_ != s_ele )
- cardfix=cardfix*(100-tsd->subele[s_ele_])/100;
+ {
+ int ele_fix_lh = tsd->subele[s_ele_];
+ for (i = 0; ARRAYLENGTH(tsd->subele2) > i && tsd->subele2[i].rate != 0; i++)
+ {
+ if(tsd->subele2[i].ele != s_ele_) continue;
+ if(!(tsd->subele2[i].flag&wd.flag&BF_WEAPONMASK &&
+ tsd->subele2[i].flag&wd.flag&BF_RANGEMASK &&
+ tsd->subele2[i].flag&wd.flag&BF_SKILLMASK))
+ continue;
+ ele_fix_lh += tsd->subele2[i].rate;
+ }
+ cardfix=cardfix*(100-ele_fix_lh)/100;
+ }
}
cardfix=cardfix*(100-tsd->subsize[sstatus->size])/100;
cardfix=cardfix*(100-tsd->subrace2[s_race2])/100;
@@ -2532,7 +2603,19 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
int cardfix=1000;
if (!(nk&NK_NO_ELEFIX))
- cardfix=cardfix*(100-tsd->subele[s_ele])/100;
+ {
+ int ele_fix = tsd->subele[s_ele];
+ for (i = 0; ARRAYLENGTH(tsd->subele2) > i && tsd->subele2[i].rate != 0; i++)
+ {
+ if(tsd->subele2[i].ele != s_ele) continue;
+ if(!(tsd->subele2[i].flag&ad.flag&BF_WEAPONMASK &&
+ tsd->subele2[i].flag&ad.flag&BF_RANGEMASK &&
+ tsd->subele2[i].flag&ad.flag&BF_SKILLMASK))
+ continue;
+ ele_fix += tsd->subele2[i].rate;
+ }
+ cardfix=cardfix*(100-ele_fix)/100;
+ }
cardfix=cardfix*(100-tsd->subsize[sstatus->size])/100;
cardfix=cardfix*(100-tsd->subrace2[s_race2])/100;
cardfix=cardfix*(100-tsd->subrace[sstatus->race])/100;
@@ -2769,7 +2852,22 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
int cardfix = 10000;
int race2 = status_get_race2(src);
if (!(nk&NK_NO_ELEFIX))
- cardfix=cardfix*(100-tsd->subele[s_ele])/100;
+ {
+ if (!(nk&NK_NO_ELEFIX))
+ {
+ int ele_fix = tsd->subele[s_ele];
+ for (i = 0; ARRAYLENGTH(tsd->subele2) > i && tsd->subele2[i].rate != 0; i++)
+ {
+ if(tsd->subele2[i].ele != s_ele) continue;
+ if(!(tsd->subele2[i].flag&md.flag&BF_WEAPONMASK &&
+ tsd->subele2[i].flag&md.flag&BF_RANGEMASK &&
+ tsd->subele2[i].flag&md.flag&BF_SKILLMASK))
+ continue;
+ ele_fix += tsd->subele2[i].rate;
+ }
+ cardfix=cardfix*(100-ele_fix)/100;
+ }
+ }
cardfix=cardfix*(100-tsd->subsize[sstatus->size])/100;
cardfix=cardfix*(100-tsd->subrace2[race2])/100;
cardfix=cardfix*(100-tsd->subrace[sstatus->race])/100;
diff --git a/src/map/pc.c b/src/map/pc.c
index 04027c42d..70a433c0e 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -1729,6 +1729,71 @@ int pc_endautobonus(int tid, unsigned int tick, int id, intptr data)
return 0;
}
+int pc_bonus_addele(struct map_session_data* sd, unsigned char ele, short rate, short flag)
+{
+ int i;
+ struct weapon_data* wd;
+
+ wd = (sd->state.lr_flag ? &sd->left_weapon : &sd->right_weapon);
+
+ ARR_FIND(0, MAX_PC_BONUS, i, wd->addele2[i].rate == 0);
+
+ if (i == MAX_PC_BONUS)
+ {
+ ShowWarning("pc_addele: Reached max (%d) possible bonuses for this player.\n", MAX_PC_BONUS);
+ return 0;
+ }
+
+ if (!(flag&BF_RANGEMASK))
+ flag |= BF_SHORT|BF_LONG;
+ if (!(flag&BF_WEAPONMASK))
+ flag |= BF_WEAPON;
+ if (!(flag&BF_SKILLMASK))
+ {
+ if (flag&(BF_MAGIC|BF_MISC))
+ flag |= BF_SKILL;
+ if (flag&BF_WEAPON)
+ flag |= BF_NORMAL|BF_SKILL;
+ }
+
+ wd->addele2[i].ele = ele;
+ wd->addele2[i].rate = rate;
+ wd->addele2[i].flag = flag;
+
+ return 0;
+}
+
+int pc_bonus_subele(struct map_session_data* sd, unsigned char ele, short rate, short flag)
+{
+ int i;
+
+ ARR_FIND(0, MAX_PC_BONUS, i, sd->subele2[i].rate == 0);
+
+ if (i == MAX_PC_BONUS)
+ {
+ ShowWarning("pc_subele: Reached max (%d) possible bonuses for this player.\n", MAX_PC_BONUS);
+ return 0;
+ }
+
+ if (!(flag&BF_RANGEMASK))
+ flag |= BF_SHORT|BF_LONG;
+ if (!(flag&BF_WEAPONMASK))
+ flag |= BF_WEAPON;
+ if (!(flag&BF_SKILLMASK))
+ {
+ if (flag&(BF_MAGIC|BF_MISC))
+ flag |= BF_SKILL;
+ if (flag&BF_WEAPON)
+ flag |= BF_NORMAL|BF_SKILL;
+ }
+
+ sd->subele2[i].ele = ele;
+ sd->subele2[i].rate = rate;
+ sd->subele2[i].flag = flag;
+
+ return 0;
+}
+
/*==========================================
* ? 備品による能力等のボ?ナス設定
*------------------------------------------*/
@@ -2856,6 +2921,24 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
if( sd->state.lr_flag != 2 )
pc_bonus_addeff_onskill(sd->addeff3, ARRAYLENGTH(sd->addeff3), (sc_type)type3, val, type2, 2);
break;
+
+ case SP_ADDELE:
+ if (type2 > ELE_MAX) {
+ ShowWarning("pc_bonus3 (SP_ADDELE): element %d is out of range.\n", type2);
+ break;
+ }
+ if (sd->state.lr_flag != 2)
+ pc_bonus_addele(sd, (unsigned char)type2, type3, val);
+ break;
+
+ case SP_SUBELE:
+ if (type2 > ELE_MAX) {
+ ShowWarning("pc_bonus3 (SP_SUBELE): element %d is out of range.\n", type2);
+ break;
+ }
+ if (sd->state.lr_flag != 2)
+ pc_bonus_subele(sd, (unsigned char)type2, type3, val);
+ break;
default:
ShowWarning("pc_bonus3: unknown type %d %d %d %d!\n",type,type2,type3,val);
diff --git a/src/map/pc.h b/src/map/pc.h
index 65d21739a..1328e9367 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -44,6 +44,11 @@ struct weapon_data {
struct {
short class_, rate;
} add_dmg[MAX_PC_BONUS];
+
+ struct {
+ short flag, rate;
+ unsigned char ele;
+ } addele2[MAX_PC_BONUS];
};
struct s_autospell {
@@ -250,6 +255,10 @@ struct map_session_data {
int nameid;
int rate;
} itemhealrate[MAX_PC_BONUS];
+ struct {
+ short flag, rate;
+ unsigned char ele;
+ } subele2[MAX_PC_BONUS];
// zeroed structures end here
// manually zeroed structures start here.
struct s_autobonus autobonus[MAX_PC_BONUS], autobonus2[MAX_PC_BONUS], autobonus3[MAX_PC_BONUS]; //Auto script on attack, when attacked, on skill usage
diff --git a/src/map/status.c b/src/map/status.c
index f1315f23f..f65771045 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -1804,6 +1804,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
+ sizeof(sd->add_mdmg)
+ sizeof(sd->add_drop)
+ sizeof(sd->itemhealrate)
+ + sizeof(sd->subele2)
);
// vars zeroing. ints, shorts, chars. in that order.