Selaa lähdekoodia

- 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://svn.code.sf.net/p/rathena/svn/trunk@5610 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex 19 vuotta sitten
vanhempi
commit
b9b10700aa
7 muutettua tiedostoa jossa 82 lisäystä ja 76 poistoa
  1. 3 0
      Changelog-Trunk.txt
  2. 5 0
      conf-tmpl/battle/drops.conf
  3. 6 0
      src/map/battle.c
  4. 3 2
      src/map/battle.h
  5. 1 1
      src/map/map.h
  6. 6 1
      src/map/mob.c
  7. 58 72
      src/map/pc.c

+ 3 - 0
Changelog-Trunk.txt

@@ -5,6 +5,9 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.  EV
 GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS
 
 2006/03/15
+	* 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.
+	  (conf/battle/drops.conf) [Skotlex]
 	* Added item_db2.sql and mob_db2.sql, thanks to Joshuaali [Skotlex]
 	* Added more usage of msg_athena on the slave atcommands messages. [Skotlex]
 	* Fixed twilight pharmacy dropping 1 item to the ground instead of the qty

+ 5 - 0
conf-tmpl/battle/drops.conf

@@ -87,6 +87,11 @@ item_rate_mvp: 100
 item_drop_mvp_min: 1
 item_drop_mvp_max: 10000
 
+// The rate adjustment for card-granted item drops.
+item_rate_adddrop: 100
+item_drop_add_min: 1
+item_drop_add_max: 10000
+
 // Rate adjustment for Treasure Box drops (these override all other modifiers)
 item_rate_treasure: 100
 item_drop_treasure_min: 1

+ 6 - 0
src/map/battle.c

@@ -3929,6 +3929,8 @@ static const struct battle_data_short {
 	{ "item_drop_heal_max",                &battle_config.item_drop_heal_max },
 	{ "item_drop_use_min",                 &battle_config.item_drop_use_min },
 	{ "item_drop_use_max",                 &battle_config.item_drop_use_max },
+	{ "item_drop_add_min",                 &battle_config.item_drop_adddrop_min },
+	{ "item_drop_add_max",                 &battle_config.item_drop_adddrop_max },
 	{ "item_drop_treasure_min",            &battle_config.item_drop_treasure_min },
 	{ "item_drop_treasure_max",            &battle_config.item_drop_treasure_max },
 	{ "prevent_logout",                    &battle_config.prevent_logout		},	// Added by RoVeRT
@@ -4054,6 +4056,7 @@ static const struct battle_data_int {
 	{ "item_rate_card",                    &battle_config.item_rate_card	},	// End Addition
 	{ "item_rate_heal",                    &battle_config.item_rate_heal	},	// Added by Valaris
 	{ "item_rate_use",                     &battle_config.item_rate_use	},	// End
+	{ "item_rate_adddrop",                 &battle_config.item_rate_adddrop	},	// End
 	{ "item_rate_treasure",                &battle_config.item_rate_treasure }, // End
 	{ "day_duration",                      &battle_config.day_duration	}, // added by [Yor]
 	{ "night_duration",                    &battle_config.night_duration	}, // added by [Yor]
@@ -4315,6 +4318,7 @@ void battle_set_defaults() {
 	battle_config.item_rate_card = 100;
 	battle_config.item_rate_heal = 100;		// Added by Valaris
 	battle_config.item_rate_use = 100;		// End
+	battle_config.item_rate_adddrop = 100;
 	battle_config.item_rate_treasure = 100;
 	battle_config.logarithmic_drops = 0;
 	battle_config.item_drop_common_min=1;	// Added by TyrNemesis^
@@ -4329,6 +4333,8 @@ void battle_set_defaults() {
 	battle_config.item_drop_heal_max=10000;
 	battle_config.item_drop_use_min=1;
 	battle_config.item_drop_use_max=10000;	// End
+	battle_config.item_drop_adddrop_min=1;
+	battle_config.item_drop_adddrop_max=10000;
 	battle_config.item_drop_treasure_min=1;
 	battle_config.item_drop_treasure_max=10000;
 	battle_config.prevent_logout = 10000;	// Added by RoVeRT

+ 3 - 2
src/map/battle.h

@@ -284,7 +284,8 @@ extern struct Battle_Config {
 	unsigned short mob_ghostring_fix;
 	unsigned short pc_attack_attr_none;
 	int item_rate_mvp, item_rate_common,item_rate_card,item_rate_equip,
-		item_rate_heal, item_rate_use, item_rate_treasure;	// Added by RoVeRT, Additional Heal and Usable item rate by Val
+		item_rate_heal, item_rate_use, item_rate_treasure,	// Added by RoVeRT, Additional Heal and Usable item rate by Val
+		item_rate_adddrop;
 	
 	unsigned short logarithmic_drops;
 	unsigned short item_drop_common_min,item_drop_common_max;	// Added by TyrNemesis^
@@ -294,7 +295,7 @@ extern struct Battle_Config {
 	unsigned short item_drop_heal_min,item_drop_heal_max;	// Added by Valatris
 	unsigned short item_drop_use_min,item_drop_use_max;	//End
 	unsigned short item_drop_treasure_min,item_drop_treasure_max; //by [Skotlex]
-
+	unsigned short item_drop_adddrop_min,item_drop_adddrop_max; //[Skotlex]
 	unsigned short prevent_logout;	// Added by RoVeRT
 
 	unsigned short alchemist_summon_reward;	// [Valaris]

+ 1 - 1
src/map/map.h

@@ -591,7 +591,7 @@ struct map_session_data {
 		short class_, rate;
 	}	add_def[MAX_PC_BONUS], add_mdef[MAX_PC_BONUS],
 		add_dmg[MAX_PC_BONUS], add_mdmg[MAX_PC_BONUS];
-	struct { 
+	struct s_add_drop { 
 		short id, group;
 		int race, rate;
 	} add_drop[MAX_PC_BONUS];

+ 6 - 1
src/map/mob.c

@@ -2712,10 +2712,15 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
 					sd->add_drop[i].race & 1<<(mode&MD_BOSS?10:11))
 				{
 					//check if the bonus item drop rate should be multiplied with mob level/10 [Lupus]
-					if(sd->add_drop[i].rate<0)
+					if(sd->add_drop[i].rate<0) {
 						//it's negative, then it should be multiplied. e.g. for Mimic,Myst Case Cards, etc
 						// rate = base_rate * (mob_level/10) + 1
 						drop_rate = -sd->add_drop[i].rate*(md->level/10)+1;
+						if (drop_rate < battle_config.item_drop_adddrop_min)
+							drop_rate = battle_config.item_drop_adddrop_min;
+						else if (drop_rate > battle_config.item_drop_adddrop_max)
+							drop_rate = battle_config.item_drop_adddrop_max;
+					}
 					else
 						//it's positive, then it goes as it is
 						drop_rate = sd->add_drop[i].rate;

+ 58 - 72
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: