Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: conf/battle/drops.conf
- ===================================================================
- --- conf/battle/drops.conf (版本 15049)
- +++ conf/battle/drops.conf (工作副本)
- @@ -146,3 +146,10 @@
- // 333 = show announces for 3.33% or lower drop chance items
- // 10000 = show announces for all items
- rare_drop_announce: 0
- +
- +// enable common drop advanced
- +// if switch on that common drop suport format must be
- +// mobid,itemid,droprate
- +// but switch off that common drop suport format can be
- +// anything,itemid,droprate
- +common_drop.adv_flag: 1
- Index: db/item_droprate.txt
- ===================================================================
- --- db/item_droprate.txt (版本 0)
- +++ db/item_droprate.txt (版本 0)
- @@ -0,0 +1,11 @@
- +// Advanced common drop data base
- +// common drop type 1: Advanced mode. -> conf/drop.conf -> common_drop.adv_flag: 1
- +// e.g 1: set knight of abyss's knight of abyss card's drop rate to 100%
- +// 1219,4120,10000
- +// e.g 2: set moonlight_flower's elunium's drop rate to 0.01%
- +// 1150,985,1
- +//
- +// common drop type 2: Ind's mode. -> conf/drop.conf -> common_drop.adv_flag: 0
- +// e.g : set any monster's elunium's drop rate to 100%
- +// X,985,10000
- +// X can be any number
- \ No newline at end of file
- Index: src/map/battle.c
- ===================================================================
- --- src/map/battle.c (版本 15049)
- +++ src/map/battle.c (工作副本)
- @@ -4023,6 +4023,7 @@
- { "bg_magic_attack_damage_rate", &battle_config.bg_magic_damage_rate, 60, 0, INT_MAX, },
- { "bg_misc_attack_damage_rate", &battle_config.bg_misc_damage_rate, 60, 0, INT_MAX, },
- { "bg_flee_penalty", &battle_config.bg_flee_penalty, 20, 0, INT_MAX, },
- + { "common_drop.adv_flag", &battle_config.common_drop_flag, 1, 0, 1, },
- };
- Index: src/map/battle.h
- ===================================================================
- --- src/map/battle.h (版本 15049)
- +++ src/map/battle.h (工作副本)
- @@ -497,6 +497,7 @@
- int bg_magic_damage_rate;
- int bg_misc_damage_rate;
- int bg_flee_penalty;
- + int common_drop_flag;
- } battle_config;
- void do_init_battle(void);
- Index: src/map/mob.c
- ===================================================================
- --- src/map/mob.c (版本 15049)
- +++ src/map/mob.c (工作副本)
- @@ -66,6 +66,10 @@
- static struct eri *item_drop_ers; //For loot drops delay structures.
- static struct eri *item_drop_list_ers;
- +// common drop type 1 advanced mode and type 2 Ind mode. by [dreamunreal]
- +int common_drop1[MAX_MOB_DB][0x8000];
- +int common_drop2[0x8000];
- +
- static struct {
- int qty;
- int class_[350];
- @@ -3610,6 +3614,14 @@
- break;
- }
- db->dropitem[i].p = mob_drop_adjust(rate, rate_adjust, ratemin, ratemax);
- +
- + // set type 1 or type 2 drop rate. by [dreamunreal]
- + if(battle_config.common_drop_flag)
- + if(common_drop1[class_][db->dropitem[i].nameid])
- + db->dropitem[i].p = common_drop1[class_][db->dropitem[i].nameid];
- + else
- + if(common_drop2[db->dropitem[i].nameid])
- + db->dropitem[i].p = common_drop2[db->dropitem[i].nameid];
- //calculate and store Max available drop chance of the item
- if( db->dropitem[i].p && (class_ < 1324 || class_ > 1363) && (class_ < 1938 || class_ > 1946) )
- @@ -4272,8 +4284,71 @@
- return true;
- }
- +// set common droprate. by [dreamunreal]
- +static bool common_parse_drop(char** str) {
- + int ratio = atoi(str[2]);
- + if( mobdb_checkid(atoi(str[0])) == 0 && battle_config.common_drop_flag)
- + return false; // mobid is dummy ? if type 2 is selected. that mobid check will be skip.
- + if( itemdb_exists(atoi(str[1])) == NULL )
- + return false; // requet unexists item
- + if( ratio < 1 )
- + ratio = 1; // low than 0.01% default to 0.01%
- + if( ratio > 10000 ) {
- + ratio = 10000; // high than 100% default to 100%
- + ShowWarning("[Common Drop] ItemID: %d droprate high than 100%%,default to 100%%.\n",atoi(str[1]));
- + }
- + if(battle_config.common_drop_flag)
- + common_drop1[atoi(str[0])][atoi(str[1])] = ratio;
- + else
- + common_drop2[atoi(str[1])] = ratio;
- + return true;
- +}
- +// item_droprate.txt loaded. by [dreamunreal]
- +void mob_common_droprate(void) {
- + uint32 lines = 0, count = 0;
- + char line[1024], path[256], filename[20] = "item_droprate.txt";
- + FILE* fp;
- + sprintf(path, "%s/%s", db_path,filename);
- + fp = fopen(path, "r");
- + if(fp == NULL) {
- + ShowWarning("[Common Drop] Faild to open file '%s'.\n",path);
- + return;
- + }
- +
- + // process rows one by one
- + while(fgets(line, sizeof(line), fp))
- + {
- + char *str[3], *p, *np;
- + int i;
- +
- + lines++;
- + if(line[0] == '/' && line[1] == '/')
- + continue;
- + for(i = 0, p = line; i < 3; i++)
- + {
- + str[i] = p;
- + if((np = strchr(p, ',')) != NULL) {
- + *np = '\0'; p = np + 1;
- + }
- + }
- + if(i < 3) {
- + ShowWarning("[Common Drop] MobID: %d,ItemID: %d, Droprate: %d skip.\n", atoi(str[0]),atoi(str[1]),atoi(str[2]));
- + continue;
- + }
- +
- + if (!common_parse_drop(str))
- + continue;
- + count++;
- + }
- + fclose(fp);
- + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count,path);
- + return;
- +}
- +
- static void mob_load(void)
- {
- + // load common drop function. by [dreamunreal]
- + mob_common_droprate();
- #ifndef TXT_ONLY
- if(db_use_sqldbs)
- mob_read_sqldb();
- @@ -4290,8 +4365,22 @@
- void mob_reload(void)
- {
- - int i;
- + int i,j;
- + // clean common drop when reload mob_db. by [dreamunral]
- + if(battle_config.common_drop_flag) // here is type 1
- + {
- + for(i = 0; i < MAX_MOB_DB; i++)
- + for(j = 0; j < 0x8000; j++)
- + if(common_drop1[i][j])
- + common_drop1[i][j] = 0;
- + }
- + else // here is type 2
- + {
- + for(i = 0; i < 0x8000; i++)
- + if(common_drop2[i]) common_drop2[i] = 0;
- + }
- +
- //Mob skills need to be cleared before re-reading them. [Skotlex]
- for (i = 0; i < MAX_MOB_DB; i++)
- if (mob_db_data[i])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement