Jump to content
  • 0
Adimgar

item_db - New flag_autoloot

Question

Hi everyone.

I would like to request the addition of a new flag to items (item_db), the autoloot flag, which will control if an item can be autolooted or not.

By default it should be NULL, which means it can be autolooted as usual, but for those items with a non null value, they won't be autolooted.

Instead of editing source mob.cpp to change autoloot behaviour (i've seen most of autoloot modifications are about prevent certain items to be looted) and made it easy to customize.

I know it should require some source modifications as well, i'll bee requesting the same thing on source requests.

I hope you'll find this option usefull.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 1
diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp
index a6777190b..b4ca490dd 100644
--- a/src/map/itemdb.cpp
+++ b/src/map/itemdb.cpp
@@ -652,6 +652,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;
@@ -660,6 +672,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;
diff --git a/src/map/itemdb.hpp b/src/map/itemdb.hpp
index 108cda7f7..70ff47c17 100644
--- a/src/map/itemdb.hpp
+++ b/src/map/itemdb.hpp
@@ -877,6 +877,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 72bec7421..62df797fd 100644
--- a/src/map/mob.cpp
+++ b/src/map/mob.cpp
@@ -2190,7 +2190,7 @@ static void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, str
 	sd = map_charid2sd(dlist->first_charid);
 	if( sd == NULL ) sd = map_charid2sd(dlist->second_charid);
 	if( sd == NULL ) sd = map_charid2sd(dlist->third_charid);
-	test_autoloot = sd 
+	test_autoloot = sd && (itemdb_search(ditem->item_data.nameid))->flag.noautoloot == false
 		&& (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));

 

Usage:

  - Id: 701
    AegisName: Ora_Ora
    Name: Ora Ora
    Type: Etc
    Buy: 55000
    Weight: 200
    Flags:
      BuyingStore: true
      NoAutoLoot: true

 

Edited by Litro Endemic
add example of usage
Link to comment
Share on other sites

  • 0

you can used @autoloot then rate if you want to loot below 10 or 5 % you wil just  type @autoloot 10 or @autoloot 5 or you can just used @alootid +"specific item" if you want to loot an specific item 

 

Link to comment
Share on other sites

  • 0
22 hours ago, chadness said:

you can used @autoloot then rate if you want to loot below 10 or 5 % you wil just  type @autoloot 10 or @autoloot 5 or you can just used @alootid +"specific item" if you want to loot an specific item 

Yes, i've already tweaked a bit the command behaviour in src, and made some scripts, but the intention is to enable/disable autolooting per-item globally through a db flag 😉

I'm a little lost there because i'm still getting used to/understanding rA's source code.

@Litro Endemic

Wow, that was quick!, thank you so much! i'll try it today and give my feedback.

Thank you both for your answers.

EDIT:

Implemented and tested, it works like a charm!, thank you so much, however, it does works when using YAML db, but my online/production server uses SQL db, i'm not migrating to YAML just yet.

I've edited SQL query in itemdb.cpp:

@@ -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

and also altered item_db_re and item_db2_re tables with the new column, but it gives me the the following errors on some items when loading them:

[Error]:  Loading [72/15405] rows from 'item_db_re'
script error on  line 0
    parse_line: expect command, missing function name or calling undeclared function
     0 : '1'

I believe i'm missing some other src modification. Haven't found where else SQL item_db flags are read.

Any clues?

EDIT2:

Found it:

itemdb.cpp:

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

For anyone interested, the last step to enable SQL db:

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 again!

Edited by Adimgar
Added SQL db support
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...

Important Information

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