summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-03-15 14:58:04 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-03-15 14:58:04 +0000
commitee8093a79840edc7169291ca69ac3d256190fc83 (patch)
tree2a569814a328e229bfaa4f72ea38e5bc3b11c80f /src/map/pc.c
parent98f7e84cd7692c8cc982ea15ce26c4d546e705b5 (diff)
downloadhercules-ee8093a79840edc7169291ca69ac3d256190fc83.tar.gz
hercules-ee8093a79840edc7169291ca69ac3d256190fc83.tar.bz2
hercules-ee8093a79840edc7169291ca69ac3d256190fc83.tar.xz
hercules-ee8093a79840edc7169291ca69ac3d256190fc83.zip
- Added battle config options item_rate_adddrop, item_drop_add_min and item_drop_add_max to control drop rate of card-acquired loot bonuses.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5610 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c130
1 files changed, 58 insertions, 72 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index fe2783272..a467f3607 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -1164,6 +1164,56 @@ static int pc_bonus_autospell(struct s_autospell *spell, int max, short id, shor
spell[i].card_id = card_id;
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.
+ if (rate >= 0) { //Absolute drop.
+ if (battle_config.item_rate_adddrop != 100)
+ rate = rate*battle_config.item_rate_adddrop/100;
+ if (rate < battle_config.item_drop_adddrop_min)
+ rate = battle_config.item_drop_adddrop_min;
+ else if (rate > battle_config.item_drop_adddrop_max)
+ rate = battle_config.item_drop_adddrop_max;
+ } else { //Relative drop, max/min limits are applied at drop time.
+ if (battle_config.item_rate_adddrop != 100)
+ rate = rate*battle_config.item_rate_adddrop/100;
+ if (rate > -1)
+ rate = -1;
+ }
+ for(i = 0; i < *count; i++) {
+ if(
+ (id && drop[i].id == id) ||
+ (group && drop[i].group == group)
+ ) {
+ drop[i].race |= race;
+ if(drop[i].rate > 0 && rate > 0)
+ { //Both are absolute rates.
+ if (drop[i].rate < rate)
+ drop[i].rate = rate;
+ } else
+ if(drop[i].rate < 0 && rate < 0) {
+ //Both are relative rates.
+ if (drop[i].rate > rate)
+ drop[i].rate = rate;
+ } else if (rate < 0) //Give preference to relative rate.
+ drop[i].rate = rate;
+ return 1;
+ }
+ }
+ if(*count >= MAX_PC_BONUS) {
+ if (battle_config.error_log)
+ ShowWarning("pc_bonus: Reached max (%d) number of added drops per character!\n", MAX_PC_BONUS);
+ return 0;
+ }
+ drop[*count].id = id;
+ drop[*count].group = group;
+ drop[*count].race |= race;
+ drop[*count].rate = rate;
+ (*count)++;
+ return 1;
+}
+
/*==========================================
* ? 備品による能力等のボ?ナス設定
*------------------------------------------
@@ -2003,44 +2053,12 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
sd->sp_gain_race[type2]+=val;
break;
case SP_ADD_MONSTER_DROP_ITEM:
- if (sd->state.lr_flag != 2) {
- for(i = 0; i < sd->add_drop_count; i++) {
- if(sd->add_drop[i].id == type2) {
- sd->add_drop[i].race |= (1<<10)|(1<<11);
- if(sd->add_drop[i].rate < val)
- sd->add_drop[i].rate = val;
- break;
- }
- }
- if(i >= sd->add_drop_count && sd->add_drop_count < MAX_PC_BONUS) {
- sd->add_drop[sd->add_drop_count].id = type2;
- // all monsters, including boss and non boss monsters
- sd->add_drop[sd->add_drop_count].race |= (1<<10)|(1<<11);
- sd->add_drop[sd->add_drop_count].rate = val;
- sd->add_drop_count++;
- }
- }
+ if (sd->state.lr_flag != 2)
+ pc_bonus_item_drop(sd->add_drop, &sd->add_drop_count, type2, 0, (1<<10)|(1<<11), val);
break;
case SP_ADD_MONSTER_DROP_ITEMGROUP:
- if (sd->state.lr_flag != 2) {
- for(i = 0; i < sd->add_drop_count; i++) {
- if(sd->add_drop[i].group == type2) {
- sd->add_drop[i].id = 0;
- sd->add_drop[i].race |= (1<<10)|(1<<11);
- if(sd->add_drop[i].rate < val)
- sd->add_drop[i].rate = val;
- break;
- }
- }
- if(i >= sd->add_drop_count && sd->add_drop_count < MAX_PC_BONUS) {
- sd->add_drop[sd->add_drop_count].group = type2;
- sd->add_drop[sd->add_drop_count].id = 0;
- // all monsters, including boss and non boss monsters
- sd->add_drop[sd->add_drop_count].race |= (1<<10)|(1<<11);
- sd->add_drop[sd->add_drop_count].rate = val;
- sd->add_drop_count++;
- }
- }
+ if (sd->state.lr_flag != 2)
+ pc_bonus_item_drop(sd->add_drop, &sd->add_drop_count, 0, type2, (1<<10)|(1<<11), val);
break;
case SP_SP_LOSS_RATE:
if(sd->state.lr_flag != 2) {
@@ -2059,27 +2077,12 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
{
- int i;
nullpo_retr(0, sd);
switch(type){
case SP_ADD_MONSTER_DROP_ITEM:
- if(sd->state.lr_flag != 2) {
- for(i=0;i<sd->add_drop_count;i++) {
- if(sd->add_drop[i].id == type2) {
- sd->add_drop[i].race |= 1<<type3;
- if(sd->add_drop[i].rate < val)
- sd->add_drop[i].rate = val;
- break;
- }
- }
- if(i >= sd->add_drop_count && sd->add_drop_count < MAX_PC_BONUS) {
- sd->add_drop[sd->add_drop_count].id = type2;
- sd->add_drop[sd->add_drop_count].race |= 1<<type3;
- sd->add_drop[sd->add_drop_count].rate = val;
- sd->add_drop_count++;
- }
- }
+ if(sd->state.lr_flag != 2)
+ pc_bonus_item_drop(sd->add_drop, &sd->add_drop_count, type2, 0, 1<<type3, val);
break;
case SP_AUTOSPELL:
if(sd->state.lr_flag != 2)
@@ -2108,25 +2111,8 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
sd->sp_drain_type = val;
break;
case SP_ADD_MONSTER_DROP_ITEMGROUP:
- if (sd->state.lr_flag != 2) {
- for(i = 0; i < sd->add_drop_count; i++) {
- if(sd->add_drop[i].group == type2) {
- sd->add_drop[i].id = 0;
- sd->add_drop[i].race |= 1<<type3;
- if(sd->add_drop[i].rate < val)
- sd->add_drop[i].rate = val;
- break;
- }
- }
- if(i >= sd->add_drop_count && sd->add_drop_count < 10) {
- sd->add_drop[sd->add_drop_count].group = type2;
- sd->add_drop[sd->add_drop_count].id = 0;
- // all monsters, including boss and non boss monsters
- sd->add_drop[sd->add_drop_count].race |= 1<<type3;
- sd->add_drop[sd->add_drop_count].rate = val;
- sd->add_drop_count++;
- }
- }
+ if (sd->state.lr_flag != 2)
+ pc_bonus_item_drop(sd->add_drop, &sd->add_drop_count, 0, type2, 1<<type3, val);
break;
default: