Jump to content
  • 0

mob.cpp - autoloot flag autoloot system


Adimgar

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  17
  • Reputation:   0
  • Joined:  01/17/13
  • Last Seen:  

Hi everyone.

I'd like to request a source modification on autoloot behaviour, using a new item_db flag (flag_autoloot) which will prevent an item to be autolooted.

If the flag as a null value (default value), it'll be autolooted as usual, but if it has a non null value, it won't be autolooted.

Instead of modifying mob.cpp for adding custom conditions on when an item can/cannot be autolooted, it'll be much easier to customize with a global item flag.

I hope you'll find this request usefull.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  17
  • Reputation:   0
  • Joined:  01/17/13
  • Last Seen:  

Solved:

diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp
index 1a56cd2df..a535c724b 100644
--- a/src/map/itemdb.cpp
+++ b/src/map/itemdb.cpp
@@ -649,6 +649,18 @@ uint64 ItemDatabase::parseBodyNode(const YAML::Node &node) {
 			if (!exists)
 				item->flag.dropEffect = DROPEFFECT_NONE;
 		}
+
+		if (this->nodeExists(flagNode, "NoAutoLoot")) {
+			bool active;
+
+			if (!this->asBool(flagNode, "NoAutoLoot", active))
+				return 0;
+
+			item->flag.noautoloot = active;
+		} else {
+			if (!exists)
+				item->flag.noautoloot = false;
+		}
 	} else {
 		if (!exists) {
 			item->flag.buyingstore = false;
@@ -657,6 +669,7 @@ uint64 ItemDatabase::parseBodyNode(const YAML::Node &node) {
 			item->flag.guid = false;
 			item->flag.bindOnEquip = false;
 			item->flag.broadcast = false;
+			item->flag.noautoloot = false;
 			if (!(item->flag.delay_consume & DELAYCONSUME_TEMP))
 				item->flag.delay_consume = DELAYCONSUME_NONE;
 			item->flag.dropEffect = DROPEFFECT_NONE;
@@ -2115,6 +2128,8 @@ static bool itemdb_read_sqldb_sub(std::vector<std::string> str) {
 		flags["NoConsume"] = std::stoi(str[index]) ? "true" : "false";
 	if (!str[++index].empty())
 		flags["DropEffect"] = str[index];
+	if (!str[++index].empty())
+		flags["NoAutoLoot"] = std::stoi(str[index]) ? "true" : "false";
 	node["Flags"] = flags;
 
 	YAML::Node delay;
@@ -2219,7 +2234,7 @@ static int itemdb_read_sqldb(void) {
 			"`location_head_top`,`location_head_mid`,`location_head_low`,`location_armor`,`location_right_hand`,`location_left_hand`,`location_garment`,`location_shoes`,`location_right_accessory`,`location_left_accessory`,"
 			"`location_costume_head_top`,`location_costume_head_mid`,`location_costume_head_low`,`location_costume_garment`,`location_ammo`,`location_shadow_armor`,`location_shadow_weapon`,`location_shadow_shield`,`location_shadow_shoes`,`location_shadow_right_accessory`,`location_shadow_left_accessory`,"
 			"`weapon_level`,`equip_level_min`,`equip_level_max`,`refineable`,`view`,`alias_name`,"
-			"`flag_buyingstore`,`flag_deadbranch`,`flag_container`,`flag_uniqueid`,`flag_bindonequip`,`flag_dropannounce`,`flag_noconsume`,`flag_dropeffect`,"
+			"`flag_buyingstore`,`flag_deadbranch`,`flag_container`,`flag_uniqueid`,`flag_bindonequip`,`flag_dropannounce`,`flag_noconsume`,`flag_dropeffect`,`flag_noautoloot`,"
 			"`delay_duration`,`delay_status`,`stack_amount`,`stack_inventory`,`stack_cart`,`stack_storage`,`stack_guildstorage`,`nouse_override`,`nouse_sitting`,"
 			"`trade_override`,`trade_nodrop`,`trade_notrade`,`trade_tradepartner`,`trade_nosell`,`trade_nocart`,`trade_nostorage`,`trade_noguildstorage`,`trade_nomail`,`trade_noauction`,`script`,`equip_script`,`unequip_script`"
 #ifdef RENEWAL
diff --git a/src/map/itemdb.hpp b/src/map/itemdb.hpp
index 5307110e8..3594457eb 100644
--- a/src/map/itemdb.hpp
+++ b/src/map/itemdb.hpp
@@ -901,6 +901,7 @@ struct item_data
 		bool broadcast; ///< Will be broadcasted if someone obtain the item [Cydh]
 		bool bindOnEquip; ///< Set item as bound when equipped
 		e_item_drop_effect dropEffect; ///< Drop Effect Mode
+		bool noautoloot;
 	} flag;
 	struct {// item stacking limitation
 		uint16 amount;
diff --git a/src/map/mob.cpp b/src/map/mob.cpp
index 2ea69795e..31472a496 100644
--- a/src/map/mob.cpp
+++ b/src/map/mob.cpp
@@ -2252,6 +2252,8 @@ static void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, str
 	if( sd == NULL ) sd = map_charid2sd(dlist->second_charid);
 	if( sd == NULL ) sd = map_charid2sd(dlist->third_charid);
 	test_autoloot = sd 
+		&& (itemdb_search(ditem->item_data.nameid))->flag.noautoloot == false
+		&& (itemdb_type(ditem->item_data.nameid) != IT_CARD)
 		&& (drop_rate <= sd->state.autoloot || pc_isautolooting(sd, ditem->item_data.nameid))
 		&& (flag?(battle_config.homunculus_autoloot?(battle_config.hom_idle_no_share == 0 || !pc_isidle_hom(sd)):0):
 			(battle_config.idle_no_autoloot == 0 || DIFF_TICK(last_tick, sd->idletime) < battle_config.idle_no_autoloot));
ALTER TABLE item_db_re ADD COLUMN `flag_noautoloot` tinyint(1) unsigned DEFAULT NULL AFTER `flag_dropeffect`;
ALTER TABLE item_db2_re ADD COLUMN `flag_noautoloot` tinyint(1) unsigned DEFAULT NULL AFTER `flag_dropeffect`;

Thanks to @Litro Endemic

 

Edited by Adimgar
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...