Jump to content
Sign in to follow this  
Mustang

débutant Drop Bonus aléatoire

Recommended Posts

Posted (edited)

Temps estimé : ~ 5 minutes

 

Cette méthode utilise la fonction AddRareAttribute() ce sont donc les bonus 6/7 qui sont utilisé et configuré via la table attr_rare

Si vous souhaitez garder les 6/7, il est très simple d'ajouter une nouvelle fonction en reprenant l'existant ( AddRareRandomAttribute)

 

Service.h

Révélation
#define ENABLE_BONUS_RARE

 

 

 

item_attribute.cpp

Révélation
bool CItem::AddRareAttribute()
{

	if (GetType() == ITEM_WEAPON)
	{
		if (GetSubType() == WEAPON_ARROW)
			return false;

#ifdef __NEW_ARROW_SYSTEM__
		if (GetSubType() == WEAPON_UNLIMITED_ARROW)
			return false;
#endif
	}
#if defined(ENABLE_PENDANT) && defined(ENABLE_BONUS_RARE)
	else if (GetType() == ITEM_ARMOR)
	{
		if (GetSubType() == ARMOR_PENDANT)
			return false;
	}
#endif

	int count = GetRareAttrCount();
  
  .....
    

 

 

 

item_manager.cpp

Révélation
.........

#ifdef ENABLE_BONUS_RARE
bool inArr(int* tab, int line,int size) {
		for(int i = 0; i < size; i++){
				if(tab[i] == line)
					return true;           
			}
		return false;
}
#endif

LPITEM ITEM_MANAGER::CreateItem(DWORD vnum, DWORD count, DWORD id, bool bTryMagic, int iRarePct, bool bSkipSave)
  
  .........

 

 

item_manager.cpp

 

Révélation
..........

		if (bTryMagic)
		{
			if (iRarePct == -1)
				iRarePct = table->bAlterToMagicItemPct;

			if (number(1, 100) <= iRarePct)
				item->AlterToMagicItem();
#ifdef ENABLE_BONUS_RARE
			int RareArray[2] = {1,2};
			if(inArr(RareArray,item->GetType(),_countof(RareArray)))
			{
				if (number(1, 100) <= 70) //70% Chance
				{
					item->AddRareAttribute();
				}
				if (number(1, 100) <= 30) // 30% Chance
				{
					item->AddRareAttribute();
				}
			}
#endif
		}
              
              ........

 

 

Edited by Mustang (see edit history)
  • Like 1

Share this post


Link to post

Si j'ai bien compris, si je drop trois épées (par exemple), les trois n'auront pas les même bonus ?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.