Jump to content
  • 0

Stopping Random Option Duplicates on Mob Drop


mawjustin

Question


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  121
  • Reputation:   6
  • Joined:  09/26/14
  • Last Seen:  

Hi Team,

 

May I ask on how we can detect if the random option is already assigned in either 1st to 5th random option slot?

I'm trying to avoid duplicate random option on mob drops.

I've used this post of mine as reference, random option is working.

My problem now is I cannot stop the duplication of random option, the random option always ends up being duplicated on either 1st to 5th slot.

 

I'm using this line. What I would like to achieve is that if the code detects the same random option id on the 1st to 5th slot, it will either break it, or reroll and add another random option.

Random Option must be unique and does not have a duplicate on all slots.

On 10/3/2020 at 7:38 AM, -to- said:

I needed a quick change to make something like this work.... It might help you:
You just need to replace the function void itemdb_add_randomopt(struct item *it) in itemdb.cpp and recompile. It makes 1random option 100%, 2nd 80%, 3rd 60% and so on...

 

void itemdb_add_randomopt(struct item *it)
{
	struct item_data *id;
	struct s_random_opt_group *randomopt_group;
	int i;

	if (!it || !it->nameid || (id = itemdb_exists(it->nameid)) == NULL)
	{
		return;
	}

	for (i = 0; i < MAX_ITEM_RDM_OPT; i++)
	{
		if (id->randomopt_groupid[i] && ((randomopt_group = itemdb_randomopt_group_exists(id->randomopt_groupid[i])) != NULL))
		{

			int rndOpt = rnd() % (MAX_ITEM_RDM_OPT);

			if (i > 0)
			{
				if ((i > 3 && rndOpt < 4) || (i > 2 && rndOpt < 3) || (i > 1 && rndOpt < 2))
					break;
				if (rndOpt < 1)
					break;
			}
			int rnd_value = rnd() % (randomopt_group->total_weight);
			int total = 0;
			int j;

			for (j = 0; j < randomopt_group->total; j++)
			{
				total += randomopt_group->entries[j].weight;

				if (rnd_value < total)
				{
					it->option[i].id = randomopt_group->entries[j].option.id;

					if (randomopt_group->entries[j].max_value > 0 && randomopt_group->entries[j].max_value != randomopt_group->entries[j].option.value)
					{
						int max = randomopt_group->entries[j].max_value;
						int min = randomopt_group->entries[j].option.value;

						it->option[i].value = rnd() % (max - min + 1) + min;
					}
					else
					{
						it->option[i].value = randomopt_group->entries[j].option.value;
					}

					it->option[i].param = randomopt_group->entries[j].option.param;
					break;
				}
			}
		}
	}
}

In item_randomopt_equips.txt you cannot duplicate any RandomOption_GroupId in the same item. You can use something like this:

1202,RDMOPT_Weapon_Tier1_Slot1,RDMOPT_Weapon_Tier1_Slot2,RDMOPT_Weapon_Tier1_Slot3,RDMOPT_Weapon_Tier1_Slot4,RDMOPT_Weapon_TierSpecial_Slot5

If you want a item to have less than 5 options, you just need to remove the option from this file.

Thank you.

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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