Jump to content
  • 0
Sign in to follow this  
rootKid

Automatic Removal of Non-Existent Mob Drops

Question

How can I go about altering the mob_read_db_drops_sub routine so that it automatically removes the item line from mob_db.conf?

I am using an older version of Herc, and so it may be outdated, but the following is the routine found within my mob.c.

void mob_read_db_drops_sub(struct mob_db *entry, struct status_data *mstatus, int class_, config_setting_t *t)
{
	config_setting_t *drop;
	int i = 0;
	int idx = 0;
	int i32;
	int k;

	while (idx < MAX_MOB_DROP && (drop = libconfig->setting_get_elem(t, i))) {
		const char *name = config_setting_name(drop);
		int rate_adjust, type;
		unsigned short ratemin, ratemax;
		struct item_data* id = itemdb->search_name(name);
		int value = 0;
		if (!id)
		{
			ShowWarning("mob_read_db: drop item %s not found in monster %d\n", name, class_);
			i ++;
			continue;
		}
		if (mob->get_const(drop, &i32) && i32 >= 0) {
			value = i32;
		}
		if (value <= 0)
		{
			ShowWarning("mob_read_db: wrong drop chance %d for drop item %s in monster %d\n", value, name, class_);
			i ++;
			continue;
		}

		entry->dropitem[idx].nameid = id->nameid;
		if (!entry->dropitem[idx].nameid) {
			entry->dropitem[idx].p = 0; //No drop.
			i ++;
			continue;
		}
		type = id->type;
		if ((class_ >= 1324 && class_ <= 1363) || (class_ >= 1938 && class_ <= 1946)) {
			//Treasure box drop rates [Skotlex]
			rate_adjust = battle_config.item_rate_treasure;
			ratemin = battle_config.item_drop_treasure_min;
			ratemax = battle_config.item_drop_treasure_max;
		}
		else switch (type)
		{ // Added support to restrict normal drops of MVP's [Reddozen]
			case IT_HEALING:
				rate_adjust = (mstatus->mode&MD_BOSS) ? battle_config.item_rate_heal_boss : battle_config.item_rate_heal;
				ratemin = battle_config.item_drop_heal_min;
				ratemax = battle_config.item_drop_heal_max;
				break;
			case IT_USABLE:
			case IT_CASH:
				rate_adjust = (mstatus->mode&MD_BOSS) ? battle_config.item_rate_use_boss : battle_config.item_rate_use;
				ratemin = battle_config.item_drop_use_min;
				ratemax = battle_config.item_drop_use_max;
				break;
			case IT_WEAPON:
			case IT_ARMOR:
			case IT_PETARMOR:
				rate_adjust = (mstatus->mode&MD_BOSS) ? battle_config.item_rate_equip_boss : battle_config.item_rate_equip;
				ratemin = battle_config.item_drop_equip_min;
				ratemax = battle_config.item_drop_equip_max;
				break;
			case IT_CARD:
				rate_adjust = (mstatus->mode&MD_BOSS) ? battle_config.item_rate_card_boss : battle_config.item_rate_card;
				ratemin = battle_config.item_drop_card_min;
				ratemax = battle_config.item_drop_card_max;
				break;
			default:
				rate_adjust = (mstatus->mode&MD_BOSS) ? battle_config.item_rate_common_boss : battle_config.item_rate_common;
				ratemin = battle_config.item_drop_common_min;
				ratemax = battle_config.item_drop_common_max;
				break;
		}
		mob->item_dropratio_adjust(id->nameid, class_, &rate_adjust);
		entry->dropitem[idx].p = mob->drop_adjust(value, rate_adjust, ratemin, ratemax);

		//calculate and store Max available drop chance of the item
		if (entry->dropitem[idx].p && (class_ < 1324 || class_ > 1363) && (class_ < 1938 || class_ > 1946))
		{ //Skip treasure chests.
			if (id->maxchance == -1 || (id->maxchance < entry->dropitem[idx].p) ) {
				id->maxchance = entry->dropitem[idx].p; //item has bigger drop chance or sold in shops
			}
			for (k = 0; k< MAX_SEARCH; k++) {
				if (id->mob[k].chance <= entry->dropitem[idx].p)
					break;
			}
			if (k == MAX_SEARCH)
			{
				i++;
				idx++;
				continue;
			}

			if (id->mob[k].id != class_ && k != MAX_SEARCH - 1)
				memmove(&id->mob[k+1], &id->mob[k], (MAX_SEARCH-k-1)*sizeof(id->mob[0]));
			id->mob[k].chance = entry->dropitem[idx].p;
			id->mob[k].id = class_;
		}
		i++;
		idx++;
	}
	if (idx == MAX_MOB_DROP && libconfig->setting_get_elem(t, i)) {
		ShowWarning("mob_read_db: Too many drops in mob %d\n", class_);
	}
}

 

To further elaborate upon my request. As is shown above, when the item listed under the mob does not exist in the item_db, the following occurs.

		if (!id)
		{
			ShowWarning("mob_read_db: drop item %s not found in monster %d\n", name, class_);
			i ++;
			continue;
		}

On top of the warning, how can I alter the code to automatically delete the non-existent item line from the mob inside the mob_db.conf and save the file?

So for instance, if the following was the original drops of the monster:

	Drops: {
		Wand: 100
		Orange: 1000
		Pecopeco_Card: 1
	}

And the Orange does not exist within the item_db, the following change to mob_db.conf would result automatically:

	Drops: {
		Wand: 100
		Pecopeco_Card: 1
	}

 

Edited by rootKid

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.