Jump to content
  • 0

Attach RandomOptionGroup directly to ALL monster drop EQUIPMENTS via db.yml


Question

Posted

So on official servers, RandomOptionGroup is attached to specific monster dropped equips and from boxes. What I want to do is to have all equips (weapons/armors) to have a RandomOptionGroup assigned to it, without manually editing all db entries (because that will be a lot of work). Is there any other way to set the value for RandomOptionGroup to all equips globally so I can skip to the good part? 

Thanks!

3 answers to this question

Recommended Posts

  • 0
Posted

The only easy way with 1 random option group id to all equip dropped by monster is to mod the source

diff --git a/conf/battle/feature.conf b/conf/battle/feature.conf
index aa08ec4dd..49f9f64ab 100644
--- a/conf/battle/feature.conf
+++ b/conf/battle/feature.conf
@@ -175,3 +175,9 @@ feature.stylist: on
 // If this is allowed the "nosave" mapflag is still being respected
 // and may prevent players from warping back into the instance.
 //feature.instance_allow_reconnect: yes
+
+// Default random option group attached to all equipment
+// This random option group id will be attached
+// If the original drop entry on mob_db.yml
+// Do not have RandomOptionGroup entry on it.
+feature.default_randomopt_group: 1111

 

diff --git a/src/map/battle.cpp b/src/map/battle.cpp
index 908d67571..1b6f3f030 100644
--- a/src/map/battle.cpp
+++ b/src/map/battle.cpp
@@ -10476,6 +10476,8 @@ static const struct _battle_data {
 
+	{ "feature.default_randomopt_group",    &battle_config.default_randomopt_group,         0,      0,      INT_MAX,        },
+
 #include <custom/battle_config_init.inc>
 };
 

 

diff --git a/src/map/battle.hpp b/src/map/battle.hpp
index 015249b5d..5b8b1063b 100644
--- a/src/map/battle.hpp
+++ b/src/map/battle.hpp
@@ -735,6 +735,8 @@ struct Battle_Config
 
+	int default_randomopt_group;
+
 #include <custom/battle_config_struct.inc>
 };
 

 

diff --git a/src/map/mob.cpp b/src/map/mob.cpp
index a4e73ea5d..b8bee338b 100644
--- a/src/map/mob.cpp
+++ b/src/map/mob.cpp
@@ -2124,6 +2124,16 @@ void mob_setdropitem_option(item *item, s_mob_drop *mobdrop) {
 
 	std::shared_ptr<s_random_opt_group> group = random_option_group.find(mobdrop->randomopt_group);
 
+	if (group == nullptr && battle_config.default_randomopt_group) {
+		if (itemdb_isequip(item->nameid)) {
+			group = random_option_group.find(battle_config.default_randomopt_group);
+			if (group == nullptr) {
+				ShowWarning("Battle setting 'feature.default_randomopt_group' is disabled as random option group with id %d is not exist.\n", battle_config.default_randomopt_group);
+				battle_config.default_randomopt_group = 0;
+			}
+		}
+	}
+
 	if (group != nullptr) {
 		group->apply( *item );
 	}

 

  • Like 1
  • 0
Posted
On 4/16/2023 at 4:50 PM, Litro Endemic said:

The only easy way with 1 random option group id to all equip dropped by monster is to mod the source

diff --git a/conf/battle/feature.conf b/conf/battle/feature.conf
index aa08ec4dd..49f9f64ab 100644
--- a/conf/battle/feature.conf
+++ b/conf/battle/feature.conf
@@ -175,3 +175,9 @@ feature.stylist: on
 // If this is allowed the "nosave" mapflag is still being respected
 // and may prevent players from warping back into the instance.
 //feature.instance_allow_reconnect: yes
+
+// Default random option group attached to all equipment
+// This random option group id will be attached
+// If the original drop entry on mob_db.yml
+// Do not have RandomOptionGroup entry on it.
+feature.default_randomopt_group: 1111

 

diff --git a/src/map/battle.cpp b/src/map/battle.cpp
index 908d67571..1b6f3f030 100644
--- a/src/map/battle.cpp
+++ b/src/map/battle.cpp
@@ -10476,6 +10476,8 @@ static const struct _battle_data {
 
+	{ "feature.default_randomopt_group",    &battle_config.default_randomopt_group,         0,      0,      INT_MAX,        },
+
 #include <custom/battle_config_init.inc>
 };
 

 

diff --git a/src/map/battle.hpp b/src/map/battle.hpp
index 015249b5d..5b8b1063b 100644
--- a/src/map/battle.hpp
+++ b/src/map/battle.hpp
@@ -735,6 +735,8 @@ struct Battle_Config
 
+	int default_randomopt_group;
+
 #include <custom/battle_config_struct.inc>
 };
 

 

diff --git a/src/map/mob.cpp b/src/map/mob.cpp
index a4e73ea5d..b8bee338b 100644
--- a/src/map/mob.cpp
+++ b/src/map/mob.cpp
@@ -2124,6 +2124,16 @@ void mob_setdropitem_option(item *item, s_mob_drop *mobdrop) {
 
 	std::shared_ptr<s_random_opt_group> group = random_option_group.find(mobdrop->randomopt_group);
 
+	if (group == nullptr && battle_config.default_randomopt_group) {
+		if (itemdb_isequip(item->nameid)) {
+			group = random_option_group.find(battle_config.default_randomopt_group);
+			if (group == nullptr) {
+				ShowWarning("Battle setting 'feature.default_randomopt_group' is disabled as random option group with id %d is not exist.\n", battle_config.default_randomopt_group);
+				battle_config.default_randomopt_group = 0;
+			}
+		}
+	}
+
 	if (group != nullptr) {
 		group->apply( *item );
 	}

 

can you make it to have different rdmopt group to different equipment? like group 1 to armor, group 2 to weapon, etc

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