Jump to content
  • 0

Custom Autolooting


nickyb

Question


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  15
  • Reputation:   1
  • Joined:  07/22/12
  • Last Seen:  

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
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 1

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  926
  • Reputation:   168
  • Joined:  04/05/13
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   76
  • Joined:  06/13/13
  • Last Seen:  

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);

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  15
  • Reputation:   1
  • Joined:  07/22/12
  • Last Seen:  

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.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  15
  • Reputation:   1
  • Joined:  07/22/12
  • Last Seen:  

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!

Link to comment
Share on other sites

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.

×
×
  • Create New...