• 0
Cripplez

solved Item_addon.cpp with case nvum

Question

Hi,

I'd like to make that with a specific vnum (like 299, 399, 499 ecc) the   

 int iSkillBonus = 
int iNormalHitBonus =

will be different, I don't think this is the right way to do it, it is just an example to explain how i'd like to do it

Thank you

 

void CItemAddonManager::ApplyAddonTo(int iAddonType, LPITEM pItem)
{
	if (!pItem)
	{
		sys_err("ITEM pointer null");
		return;
	}

	//FOR EXAMPLE SOMETHING LIKE THIS:
  
  	    switch (item->GetVnum())
	    {
		case 299:	
		case 399:	
		case 499:	
		case 599:	
	
        int iSkillBonus = MINMAX(-40, (int) (gauss_random(0, 5) + 0.5f), 40);
		int iNormalHitBonus = 0;
		if (abs(iSkillBonus) <= 30)
			iNormalHitBonus = -2 * iSkillBonus + abs(number(-8, 8) + number(-8, 8)) + number(1, 4);
		else
			iNormalHitBonus = -2 * iSkillBonus + number(1, 5);

		pItem->RemoveAttributeType(APPLY_SKILL_DAMAGE_BONUS);
		pItem->RemoveAttributeType(APPLY_NORMAL_HIT_DAMAGE_BONUS);
		pItem->AddAttribute(APPLY_NORMAL_HIT_DAMAGE_BONUS, iNormalHitBonus);
		pItem->AddAttribute(APPLY_SKILL_DAMAGE_BONUS, iSkillBonus);
		}
  		//ELSE IF THE VNUM ISN'T ABOVE, DO THIS ATTRIBUTE
  
	int iSkillBonus = MINMAX(-30, (int) (gauss_random(0, 5) + 0.5f), 30);
	int iNormalHitBonus = 0;
	if (abs(iSkillBonus) <= 20)
		iNormalHitBonus = -2 * iSkillBonus + abs(number(-8, 8) + number(-8, 8)) + number(1, 4);
	else
		iNormalHitBonus = -2 * iSkillBonus + number(1, 5);

	pItem->RemoveAttributeType(APPLY_SKILL_DAMAGE_BONUS);
	pItem->RemoveAttributeType(APPLY_NORMAL_HIT_DAMAGE_BONUS);
	pItem->AddAttribute(APPLY_NORMAL_HIT_DAMAGE_BONUS, iNormalHitBonus);
	pItem->AddAttribute(APPLY_SKILL_DAMAGE_BONUS, iSkillBonus);
}

 

Share this post


Link to post
Share on other sites

1 answer to this question

  • 1

That's what he requested in private, if someone need it, those are not my calculations/code.

void CItemAddonManager::ApplyAddonTo(int iAddonType, LPITEM pItem)
{
	if (!pItem)
	{
		sys_err("ITEM pointer null");
		return;
	}

	bool bCustomizedAddon = false;
	switch (pItem->GetVnum())
	{
		case 1129:	
		case 2129:	
		case 3129:	
		case 5129:	
			bCustomizedAddon = true;
			break;
	}
	
	int iSkillBonus = MINMAX(-30, static_cast<int>(gauss_random(0, 5) + 0.5f), 30);
	int iNormalHitBonus = 0;
	if (bCustomizedAddon)
	{
		if (abs(iSkillBonus) <= 0)
			iNormalHitBonus = (-1 * iSkillBonus) / 2 + abs(number(-2, 2) + number(-2, 2)) + number(1, 2);
		else
			iNormalHitBonus = (-1 * iSkillBonus) / 2 + abs(number(-3, 6));
	
		if (abs(iSkillBonus) <= 0)
			iSkillBonus = (1 * iSkillBonus) / 2 + abs(number(-1, 1) + number(-1, 1)) + number(1, 2);
		else
			iSkillBonus = (1 * iSkillBonus) / 2 + abs(number(-3, 1));
	}
	else
	{
		if (abs(iSkillBonus) <= 20)
			iNormalHitBonus = -2 * iSkillBonus + abs(number(-8, 8) + number(-8, 8)) + number(1, 4);
		else
			iNormalHitBonus = -2 * iSkillBonus + number(1, 5);
	}

	pItem->RemoveAttributeType(APPLY_SKILL_DAMAGE_BONUS);
	pItem->RemoveAttributeType(APPLY_NORMAL_HIT_DAMAGE_BONUS);
	pItem->AddAttribute(APPLY_NORMAL_HIT_DAMAGE_BONUS, iNormalHitBonus);
	pItem->AddAttribute(APPLY_SKILL_DAMAGE_BONUS, iSkillBonus);
}
  • Like 1
  • Thanks 1
  • Haha 1

Share this post


Link to post
Share on other sites

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

  • Recently Browsing   0 members

    No registered users viewing this page.