Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-30-2007, 07:25 PM
AiliaMorisato
Sarnak
 
Join Date: Sep 2005
Posts: 34
Default No gains for illegially equipped items

First a fix to support Frogloks and Berserkers
Code:
bool ItemInst::IsEquipable(int16 race, int16 class_) const
{
	if (!m_item)
		return false;
	
	bool israce = false;
	bool isclass = false;
	
	if (m_item->Slots == 0) {
		return false;
	}
	
	uint32 classes_ = m_item->Classes;
	uint32 races_ = m_item->Races;
	int32 race_ = 0;
	#ifndef PACKETCOLLECTOR
	race_ = GetArrayRace(race);
	race_ = (race_==17? 15 : race_);
	#endif
	// @merth: can this be optimized?  i.e., will (race & common->Races) suffice?
	for (int cur_class = 1; cur_class<=16; cur_class++) {
		if (classes_ % 2 == 1) {
    		if (cur_class == class_) {
    			isclass = true;
			}
		}
		classes_ >>= 1;
	}
	for (unsigned int cur_race = 1; cur_race <= 15; cur_race++) {
		
		if (races_ % 2 == 1) {
    		if (cur_race == race_) {
    			israce = true;
   			}
		}
		races_ >>= 1;
	}
	if (!isclass){printf("CLASS FAILED:%i ",class_);}
	if (!israce){printf("RACE FAILED:%i ",race_);}
	return (israce && isclass);
}
Update to allow new aug bool used in function
Code:
	void AddItemBonuses(const ItemInst *inst, StatBonuses* newbon, bool isaug = false);
function now makes a return if player does not meet level requirement, class requirement, race requirement, or if a non-augment item is inserted into an augment slot. Slot check is currently commented due to GetCurrentSlot() returning bad values.
Please excuse the return functions not being combined, left them separate while i was testing each part.
Code:
void Client::AddItemBonuses(const ItemInst *inst, StatBonuses* newbon, bool isaug) {
	if(!inst || !inst->IsType(ItemClassCommon))
	{
		return;
	}
	if (GetLevel() < inst->GetItem()->ReqLevel)
	{
		//printf("LEVEL FAILED:%i < %i ",GetLevel(),inst->GetItem()->ReqLevel);
		return;
	}
	if (!inst->IsEquipable(GetBaseRace(),GetClass()))
	{
		return;
	}
	if(inst->GetAugmentType()==0 && isaug == TRUE)
	{
		//printf("AUG FAILED:%i ",inst->GetAugmentType());
		return;
	}
	//if(!inst->IsEquipable(inst->GetCurrentSlot()))
	//{
	//	printf("SLOT FAILED:%i ",inst->GetCurrentSlot());
	//}


	const Item_Struct *item = inst->GetItem();
	if( GetLevel() >= item->RecLevel)
	{
		newbon->AC += item->AC;
		newbon->HP += item->HP;
		newbon->Mana += item->Mana;
		newbon->Endurance += item->Endur;
		newbon->STR += item->AStr;
		newbon->STA += item->ASta;
		newbon->DEX += item->ADex;
		newbon->AGI += item->AAgi;
		newbon->INT += item->AInt;
		newbon->WIS += item->AWis;
		newbon->CHA += item->ACha;
		
		newbon->MR += item->MR;
		newbon->FR += item->FR;
		newbon->CR += item->CR;
		newbon->PR += item->PR;
		newbon->DR += item->DR;
	}
	else
	{
		int lvl = GetLevel();
		int reclvl = item->RecLevel;

		newbon->AC += CalcRecommendedLevelBonus( lvl, reclvl, item->AC );
		newbon->HP += CalcRecommendedLevelBonus( lvl, reclvl, item->HP );
		newbon->Mana += CalcRecommendedLevelBonus( lvl, reclvl, item->Mana );
		newbon->Endurance += CalcRecommendedLevelBonus( lvl, reclvl, item->Endur );
		newbon->STR += CalcRecommendedLevelBonus( lvl, reclvl, item->AStr );
		newbon->STA += CalcRecommendedLevelBonus( lvl, reclvl, item->ASta );
		newbon->DEX += CalcRecommendedLevelBonus( lvl, reclvl, item->ADex );
		newbon->AGI += CalcRecommendedLevelBonus( lvl, reclvl, item->AAgi );
		newbon->INT += CalcRecommendedLevelBonus( lvl, reclvl, item->AInt );
		newbon->WIS += CalcRecommendedLevelBonus( lvl, reclvl, item->AWis );
		newbon->CHA += CalcRecommendedLevelBonus( lvl, reclvl, item->ACha );

		newbon->MR += CalcRecommendedLevelBonus( lvl, reclvl, item->MR );
		newbon->FR += CalcRecommendedLevelBonus( lvl, reclvl, item->FR );
		newbon->CR += CalcRecommendedLevelBonus( lvl, reclvl, item->CR );
		newbon->PR += CalcRecommendedLevelBonus( lvl, reclvl, item->PR );
		newbon->DR += CalcRecommendedLevelBonus( lvl, reclvl, item->DR );
	}
	
	//FatherNitwit: New style haste, shields, and regens
	if(newbon->haste < (sint8)item->Haste) {
		newbon->haste = item->Haste;
	}
	if(item->Regen > 0) {
		newbon->HPRegen += item->Regen;
	}
	if(item->ManaRegen > 0) {
		newbon->ManaRegen += item->ManaRegen;
	}
	if(item->EnduranceRegen > 0){
		newbon->EnduranceRegen += item->EnduranceRegen;
	}
	if(item->DamageShield > 0) {
		newbon->DamageShield += item->DamageShield;
	}
	if(item->SpellShield > 0) {
		newbon->SpellDamageShield += item->SpellShield;
	}
	if(item->Shielding > 0) {
		newbon->MeleeMitigation += item->Shielding;
	}
	if(item->StunResist > 0) {
		newbon->StunResist += item->StunResist;
	}
	if(item->StrikeThrough > 0) {
		newbon->StrikeThrough += item->StrikeThrough;
	}
	if(item->Avoidance > 0) {
		newbon->AvoidMeleeChance += item->Avoidance;
	}
	if(item->Accuracy > 0) {
		newbon->HitChance += item->Accuracy;
	}
	if(item->CombatEffects > 0) {
		newbon->ProcChance += item->CombatEffects;
	}
	if (item->Worn.Effect>0 && (item->Worn.Type == ET_WornEffect)) { // latent effects
		//printf("WORN EFFECT???");
		ApplySpellsBonuses(item->Worn.Effect, item->Worn.Level, newbon);
	}
	switch(item->BardType)
	{
	case 51: /* All (e.g. Singing Short Sword) */
		{
			if(item->BardValue > newbon->singingMod)
				newbon->singingMod = item->BardValue;
			if(item->BardValue > newbon->brassMod)
				newbon->brassMod = item->BardValue;
			if(item->BardValue > newbon->stringedMod)
				newbon->stringedMod = item->BardValue;
			if(item->BardValue > newbon->percussionMod)
				newbon->percussionMod = item->BardValue;
			if(item->BardValue > newbon->windMod)
				newbon->windMod = item->BardValue;
			break;
		}
	case 50: /* Singing */
		{
			if(item->BardValue > newbon->singingMod)
				newbon->singingMod = item->BardValue;
			break;
		}
	case 23: /* Wind */
		{
			if(item->BardValue > newbon->windMod)
				newbon->windMod = item->BardValue;
			break;
		}
	case 24: /* stringed */
		{
			if(item->BardValue > newbon->stringedMod)
				newbon->stringedMod = item->BardValue;
			break;
		}
	case 25: /* brass */
		{
			if(item->BardValue > newbon->brassMod)
				newbon->brassMod = item->BardValue;
			break;
		}
	case 26: /* Percussion */
		{
			if(item->BardValue > newbon->percussionMod)
				newbon->percussionMod = item->BardValue;
			break;
		}
	}
	
	if (item->SkillModValue != 0 && item->SkillModType < HIGHEST_SKILL){
		if (newbon->skillmod[item->SkillModType] < item->SkillModValue)
			newbon->skillmod[item->SkillModType] = (sint8)item->SkillModValue;
	}

	int i;
	for(i = 0; i < MAX_AUGMENT_SLOTS; i++) {
		AddItemBonuses(inst->GetAugment(i),newbon,TRUE);
	}
}
insert this where convienient in
int Mob::GetWeaponDamage(Mob *against, const ItemInst *weapon_item)
currently have it at the bottom; prevents illegally equipped weapons from doing damage
Code:
	if(weapon_item){
		if(weapon_item->GetItem() && GetLevel() < weapon_item->GetItem()->ReqLevel && weapon_item->IsEquipable(GetBaseRace(),GetClass()))
		{
			dmg = 0;
		}
	}
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 10:43 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3