Jump to content
  • 0

Question

Posted (edited)

I'm trying to add an additional loot command to only autoloot if an item does not have a drop effect set in the DB. I still haven't gotten this new command filter to work correctly because it's still looting everything. If anyone spots where I'm going wrong it would be greatly appreciated.

 

 /*==========================================
* @lootcommon - autoloots common items and drops most rares with drop effects.
* Made by Moobs/NickyB
 *------------------------------------------*/
ACMD_FUNC(lootcommon)
{
	int rate;
	nullpo_retr(-1, sd);

	if (sd->state.autoloot)
			rate = 0;
		else
			rate = 10000;

	sd->state.autoloot = rate;

	if (sd->state.autoloot) {
		clif_displaymessage(fd, "Autoloot common loot is now enabled.");
		sd->state.lootcommon = 1;
	}else{
		clif_displaymessage(fd, "Autoloot common loot is now disabled."); // Autoloot is now off.
		sd->state.lootcommon = 0;
	}
	return 0;
}

pc.cpp

/**
 * Check if player is autolooting given itemID.
 */
bool pc_isautolooting(struct map_session_data *sd, t_itemid nameid)
{
	uint8 i = 0;

	std::shared_ptr<item_data> item_data;
	item_data = item_db.find(nameid);

	//add lootcommon 
	if (sd->state.lootcommon && item_data->flag.dropEffect != 0)
		return false;

	if (sd->state.autoloottype && sd->state.autoloottype&(1<<itemdb_type(nameid)))
		return true;

	if (!sd->state.autolooting)
		return false;

	if (sd->state.autolooting)
		ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == nameid);

	return (i != AUTOLOOTITEM_SIZE);
}

 

Edited by nickyb

4 answers to this question

Recommended Posts

  • 1
Posted

Please revert all code modified and use this instead.

\src\map\mob.cpp  Line 2212


	if( test_autoloot && (itemdb_dropeffect(ditem->item_data.nameid) <= 0)) {	//Autoloot.

image.png.28d53c26c5bdd5db920498ef5bef5eaf.png

  • 0
Posted

pc.cpp

replace

	//add lootcommon 
	if (sd->state.lootcommon && item_data->flag.dropEffect != 0)
		return false;

with

	//add lootcommon 
	if (sd->state.lootcommon)
		return (item_data->flag.dropEffect == 0);

 

  • 0
Posted
12 minutes ago, Litro Endemic said:

pc.cpp

replace

	//add lootcommon 
	if (sd->state.lootcommon && item_data->flag.dropEffect != 0)
		return false;

with

	//add lootcommon 
	if (sd->state.lootcommon)
		return (item_data->flag.dropEffect == 0);

 

Thanks, still autolooting everything, but I'll continue to work on it. There may be a bug in the custom command as well.

  • 0
Posted
2 hours ago, Start_ said:

Please revert all code modified and use this instead.

\src\map\mob.cpp  Line 2212


	if( test_autoloot && (itemdb_dropeffect(ditem->item_data.nameid) <= 0)) {	//Autoloot.

 

Thank you very much, works perfectly!

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...