summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2020-07-27 10:55:27 +0200
committerGitHub <noreply@github.com>2020-07-27 10:55:27 +0200
commitda6bd5bd44ab14f8dd2658912e92d959ed26b7ad (patch)
tree7807a698d05ee0b47f3e5148330e2ab521879702 /src
parente90730312b92edc237088d601b1047ceff3402eb (diff)
parent9f39a74248de7908955cb876fa2fb936babd2546 (diff)
downloadhercules-da6bd5bd44ab14f8dd2658912e92d959ed26b7ad.tar.gz
hercules-da6bd5bd44ab14f8dd2658912e92d959ed26b7ad.tar.bz2
hercules-da6bd5bd44ab14f8dd2658912e92d959ed26b7ad.tar.xz
hercules-da6bd5bd44ab14f8dd2658912e92d959ed26b7ad.zip
Merge pull request #2790 from Kenpachi2k13/def_ele_tolerance
Add bonuses to reduce received damage based on attacker's defense element
Diffstat (limited to 'src')
-rw-r--r--src/map/battle.c39
-rw-r--r--src/map/map.h1
-rw-r--r--src/map/pc.c46
-rw-r--r--src/map/pc.h4
4 files changed, 90 insertions, 0 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index a571a555d..72c3d8963 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -1068,6 +1068,25 @@ static int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct
continue;
ele_fix += tsd->subele2[i].rate;
}
+
+ // Apply bMagicSubDefEle damage reduction.
+ if (src->type == BL_MOB || src->type == BL_PC) {
+ int ele = (int)sstatus->def_ele;
+
+ if (!Assert_chk(ele >= ELE_NEUTRAL && ele < ELE_MAX)) {
+ switch (src->type) {
+ case BL_MOB:
+ ele_fix += tsd->magic_sub_def_ele[ele].rate_mob;
+ break;
+ case BL_PC:
+ ele_fix += tsd->magic_sub_def_ele[ele].rate_pc;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
cardfix = cardfix * (100 - ele_fix) / 100;
}
cardfix = cardfix * (100 - tsd->subsize[sstatus->size]) / 100;
@@ -1234,6 +1253,26 @@ static int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct
}
cardfix = cardfix * (100 - ele_fix_lh) / 100;
}
+
+ // Apply bSubDefEle damage reduction.
+ if (src->type == BL_MOB || src->type == BL_PC) {
+ int ele = (int)sstatus->def_ele;
+
+ if (!Assert_chk(ele >= ELE_NEUTRAL && ele < ELE_MAX)) {
+ switch (src->type) {
+ case BL_MOB:
+ ele_fix = tsd->sub_def_ele[ele].rate_mob;
+ break;
+ case BL_PC:
+ ele_fix = tsd->sub_def_ele[ele].rate_pc;
+ break;
+ default:
+ break;
+ }
+
+ cardfix = cardfix * (100 - ele_fix) / 100;
+ }
+ }
}
cardfix = cardfix * (100-tsd->subsize[sstatus->size]) / 100;
cardfix = cardfix * (100-tsd->subrace2[s_race2]) / 100;
diff --git a/src/map/map.h b/src/map/map.h
index e7c0cb50d..30e73960c 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -557,6 +557,7 @@ enum status_point_types { //we better clean up this enum and change it name [Hem
SP_SKILL_USE_SP,SP_MAGIC_ATK_ELE, SP_ADD_FIXEDCAST, SP_ADD_VARIABLECAST, //2055-2058
SP_SET_DEF_RACE,SP_SET_MDEF_RACE, //2059-2060
SP_RACE_TOLERANCE,SP_ADDMAXWEIGHT, //2061-2062
+ SP_SUB_DEF_ELE, SP_MAGIC_SUB_DEF_ELE, // 2063-2064
/* must be the last, plugins add bonuses from this value onwards */
SP_LAST_KNOWN,
diff --git a/src/map/pc.c b/src/map/pc.c
index 04c3cd1cb..9cd04c96f 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -4031,6 +4031,52 @@ static int pc_bonus3(struct map_session_data *sd, int type, int type2, int type3
sd->bonus.sp_vanish_trigger = val;
}
break;
+ case SP_SUB_DEF_ELE:
+ if ((type2 >= ELE_MAX && type2 != ELE_ALL) || type2 < ELE_NEUTRAL) {
+ ShowError("pc_bonus3: SP_SUB_DEF_ELE: Invalid element %d\n", type2);
+ break;
+ }
+
+ if (type2 == ELE_ALL) {
+ for (int j = ELE_NEUTRAL; j < ELE_MAX; j++) {
+ if ((val & 1) != 0)
+ sd->sub_def_ele[j].rate_mob += type3;
+
+ if ((val & 2) != 0)
+ sd->sub_def_ele[j].rate_pc += type3;
+ }
+ } else {
+ if ((val & 1) != 0)
+ sd->sub_def_ele[type2].rate_mob += type3;
+
+ if ((val & 2) != 0)
+ sd->sub_def_ele[type2].rate_pc += type3;
+ }
+
+ break;
+ case SP_MAGIC_SUB_DEF_ELE:
+ if ((type2 >= ELE_MAX && type2 != ELE_ALL) || type2 < ELE_NEUTRAL) {
+ ShowError("pc_bonus3: SP_MAGIC_SUB_DEF_ELE: Invalid element %d\n", type2);
+ break;
+ }
+
+ if (type2 == ELE_ALL) {
+ for (int j = ELE_NEUTRAL; j < ELE_MAX; j++) {
+ if ((val & 1) != 0)
+ sd->magic_sub_def_ele[j].rate_mob += type3;
+
+ if ((val & 2) != 0)
+ sd->magic_sub_def_ele[j].rate_pc += type3;
+ }
+ } else {
+ if ((val & 1) != 0)
+ sd->magic_sub_def_ele[type2].rate_mob += type3;
+
+ if ((val & 2) != 0)
+ sd->magic_sub_def_ele[type2].rate_pc += type3;
+ }
+
+ 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 e8e591b09..7afb35be2 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -396,6 +396,10 @@ BEGIN_ZEROED_BLOCK; // this block will be globally zeroed at the beginning of st
int rate, tick;
} def_set_race[RC_MAX], mdef_set_race[RC_MAX];
struct {
+ int rate_mob; //!< Damage reduction rate against monster's defense element.
+ int rate_pc; //!< Damage reduction rate against player's defense element.
+ } sub_def_ele[ELE_MAX], magic_sub_def_ele[ELE_MAX]; //!< Bonus bSubDefEle/bMagicSubDefEle data structure.
+ struct {
int atk_rate;
int arrow_atk,arrow_ele,arrow_cri,arrow_hit;
int nsshealhp,nsshealsp;