summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-04 16:38:36 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-04 16:38:36 +0000
commitc3c4b55d56bc72a77df54990832029a3280a72d2 (patch)
treed14d4bb48a5ea0b6957838017d878e6da1e23e79 /src/map/pc.c
parent869b3c9303a403b8c50f68202c61a96c6d9b9332 (diff)
downloadhercules-c3c4b55d56bc72a77df54990832029a3280a72d2.tar.gz
hercules-c3c4b55d56bc72a77df54990832029a3280a72d2.tar.bz2
hercules-c3c4b55d56bc72a77df54990832029a3280a72d2.tar.xz
hercules-c3c4b55d56bc72a77df54990832029a3280a72d2.zip
- Added structure s_addeffect to handle status change additions. Cleaned up relevant code. It is now possible to specify ANY status change, not just the basic ones.
- Added support for bonus3 bAddEff/bAddEffWhenHit as follows: bonus3 bAddEff/bAddEffWhenHit, <SC value>, <rate>, <target flag>. Target flag is 0: Self. 1: Enemy. 2: Both. - Added these descriptions to doc/item_bonus.txt git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7514 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c79
1 files changed, 59 insertions, 20 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index bd28d6f7a..935c3b3eb 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -1171,6 +1171,29 @@ static int pc_bonus_autospell(struct s_autospell *spell, int max, short id, shor
return 1;
}
+static int pc_bonus_addeff(struct s_addeffect *effect, int max, short id, short rate, short arrow_rate, unsigned char flag) {
+ int i;
+
+ for (i = 0; i < max && effect[i].id; i++) {
+ if (effect[i].id == id && effect[i].flag == flag)
+ {
+ effect[i].rate += rate;
+ effect[i].arrow_rate += rate;
+ return 1;
+ }
+ }
+ if (i == max) {
+ if (battle_config.error_log)
+ ShowWarning("pc_bonus: Reached max (%d) number of add effects per character!\n", max);
+ return 0;
+ }
+ effect[i].id = id;
+ effect[i].rate = rate;
+ effect[i].arrow_rate = arrow_rate;
+ effect[i].flag = flag;
+ return 1;
+}
+
static int pc_bonus_item_drop(struct s_add_drop *drop, short *count, short id, short group, int race, int rate) {
int i;
//Apply config rate adjustment settings.
@@ -1815,24 +1838,22 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
sd->subrace[type2]+=val;
break;
case SP_ADDEFF:
- if (type2 < SC_COMMON_MIN || type2 > SC_COMMON_MAX) {
+ if (type2 > SC_MAX) {
ShowWarning("pc_bonus2 (Add Effect): %d is not supported.\n", type2);
break;
}
- if(sd->state.lr_flag != 2)
- sd->addeff[type2-SC_COMMON_MIN]+=val;
- else
- sd->arrow_addeff[type2-SC_COMMON_MIN]+=val;
+ pc_bonus_addeff(sd->addeff, MAX_PC_BONUS, type2,
+ sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0,
+ ATF_SHORT|ATF_LONG|ATF_TARGET);
break;
case SP_ADDEFF2:
- if (type2 < SC_COMMON_MIN || type2 > SC_COMMON_MAX) {
+ if (type2 > SC_MAX) {
ShowWarning("pc_bonus2 (Add Effect2): %d is not supported.\n", type2);
break;
}
- if(sd->state.lr_flag != 2)
- sd->addeff2[type2-SC_COMMON_MIN]+=val;
- else
- sd->arrow_addeff2[type2-SC_COMMON_MIN]+=val;
+ pc_bonus_addeff(sd->addeff, MAX_PC_BONUS, type2,
+ sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0,
+ ATF_SHORT|ATF_LONG|ATF_SELF);
break;
case SP_RESEFF:
if (type2 < SC_COMMON_MIN || type2 > SC_COMMON_MAX) {
@@ -2040,24 +2061,22 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
sd->critaddrace[type2] += val*10;
break;
case SP_ADDEFF_WHENHIT:
- if (type2 < SC_COMMON_MIN || type2 > SC_COMMON_MAX) {
+ if (type2 > SC_MAX) {
ShowWarning("pc_bonus2 (Add Effect when hit): %d is not supported.\n", type2);
break;
}
- if(sd->state.lr_flag != 2) {
- sd->addeff3[type2-SC_COMMON_MIN]+=val;
- sd->addeff3_type[type2-SC_COMMON_MIN]=1;
- }
+ if(sd->state.lr_flag != 2)
+ pc_bonus_addeff(sd->addeff2, MAX_PC_BONUS, type2, val, 0,
+ ATF_SHORT|ATF_LONG|ATF_TARGET);
break;
case SP_ADDEFF_WHENHIT_SHORT:
- if (type2 < SC_COMMON_MIN || type2 > SC_COMMON_MAX) {
+ if (type2 > SC_MAX) {
ShowWarning("pc_bonus2 (Add Effect when hit short): %d is not supported.\n", type2);
break;
}
- if(sd->state.lr_flag != 2) {
- sd->addeff3[type2-SC_COMMON_MIN]+=val;
- sd->addeff3_type[type2-SC_COMMON_MIN]=0;
- }
+ if(sd->state.lr_flag != 2)
+ pc_bonus_addeff(sd->addeff2, MAX_PC_BONUS, type2, val, 0,
+ ATF_SHORT|ATF_TARGET);
break;
case SP_SKILL_ATK:
for (i = 0; i < MAX_PC_BONUS && sd->skillatk[i].id != 0 && sd->skillatk[i].id != type2; i++);
@@ -2251,6 +2270,26 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
pc_bonus_item_drop(sd->add_drop, &sd->add_drop_count, 0, type2, 1<<type3, val);
break;
+ case SP_ADDEFF:
+ if (type2 > SC_MAX) {
+ ShowWarning("pc_bonus3 (Add Effect): %d is not supported.\n", type2);
+ break;
+ }
+ pc_bonus_addeff(sd->addeff, MAX_PC_BONUS, type2,
+ sd->state.lr_flag!=2?type3:0, sd->state.lr_flag==2?type3:0,
+ ATF_SHORT|ATF_LONG|(val?ATF_TARGET:ATF_SELF)|(val==2?ATF_SELF:0));
+ break;
+
+ case SP_ADDEFF_WHENHIT:
+ if (type2 > SC_MAX) {
+ ShowWarning("pc_bonus3 (Add Effect when hit): %d is not supported.\n", type2);
+ break;
+ }
+ if(sd->state.lr_flag != 2)
+ pc_bonus_addeff(sd->addeff2, MAX_PC_BONUS, type2, type3, 0,
+ ATF_SHORT|ATF_LONG|(val?ATF_TARGET:ATF_SELF)|(val==2?ATF_SELF:0));
+ break;
+
default:
if(battle_config.error_log)
ShowWarning("pc_bonus3: unknown type %d %d %d %d!\n",type,type2,type3,val);