Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

Reply
 
Thread Tools Display Modes
  #1  
Old 06-03-2012, 11:32 AM
Kayen
Developer
 
Join Date: Mar 2009
Location: -
Posts: 228
Default Applying Skill Mods in Mob::CheckHitChance

Was reviewing the CheckHitChance routine and it did not seem to me that skill bonuses were being correctly applied, esp. to defense which is not being applied anywhere.

Anyways to me this seems to be a better way to code it but curious what others think before pushing it for submission.


attack.cpp
bool Mob::CheckHitChance(Mob* other, SkillType skillinuse, int Hand)

Old

Code:
if(attacker->IsClient())
	{
		chancetohit -= (RuleR(Combat,WeaponSkillFalloff) * (attacker->CastToClient()->MaxSkill(skillinuse) - attacker->GetSkill(skillinuse)));
		mlog(COMBAT__TOHIT, "Chance to hit after weapon falloff calc (attack) %.2f", chancetohit);
	}

	if(defender->IsClient())
	{
		chancetohit += (RuleR(Combat,WeaponSkillFalloff) * (defender->CastToClient()->MaxSkill(DEFENSE) - defender->GetSkill(DEFENSE)));
		mlog(COMBAT__TOHIT, "Chance to hit after weapon falloff calc (defense) %.2f", chancetohit);
	}

	//I dont think this is 100% correct, but at least it does something...
	if(attacker->spellbonuses.MeleeSkillCheckSkill == skillinuse || attacker->spellbonuses.MeleeSkillCheckSkill == 255) {
		chancetohit += attacker->spellbonuses.MeleeSkillCheck;
		mlog(COMBAT__TOHIT, "Applied spell melee skill bonus %d, yeilding %.2f", attacker->spellbonuses.MeleeSkillCheck, chancetohit);
	}
	if(attacker->itembonuses.MeleeSkillCheckSkill == skillinuse || attacker->itembonuses.MeleeSkillCheckSkill == 255) {
		chancetohit += attacker->itembonuses.MeleeSkillCheck;
		mlog(COMBAT__TOHIT, "Applied item melee skill bonus %d, yeilding %.2f", attacker->spellbonuses.MeleeSkillCheck, chancetohit);
	}
New

Code:
	if(attacker->IsClient())
	{
		int SkillMod = 0;
		if(attacker->spellbonuses.MeleeSkillCheckSkill == skillinuse || attacker->spellbonuses.MeleeSkillCheckSkill == 255) 
		{
			SkillMod += attacker->spellbonuses.MeleeSkillCheckSkill;
		}
		
		if(attacker->itembonuses.MeleeSkillCheckSkill == skillinuse || attacker->itembonuses.MeleeSkillCheckSkill == 255) 
		{
			SkillMod += attacker->itembonuses.MeleeSkillCheckSkill;
		}
		
		chancetohit -= (RuleR(Combat,WeaponSkillFalloff) * (attacker->CastToClient()->MaxSkill(skillinuse)  - (SkillMod * attacker->GetSkill(skillinuse) /100) + attacker->GetSkill(skillinuse)));
		mlog(COMBAT__TOHIT, "Chance to hit after weapon falloff calc (attack) %.2f", chancetohit);
	}
	
	if(defender->IsClient())
	{
		int SkillMod = 0;
		if(defender->spellbonuses.MeleeSkillCheckSkill == DEFENSE || defender->spellbonuses.MeleeSkillCheckSkill == 255) 
		{
			SkillMod += defender->spellbonuses.MeleeSkillCheckSkill;
		}
		
		if(defender->itembonuses.MeleeSkillCheckSkill == DEFENSE || defender->itembonuses.MeleeSkillCheckSkill == 255) 
		{
			SkillMod += defender->itembonuses.MeleeSkillCheckSkill;
		}
		
		chancetohit -= (RuleR(Combat,WeaponSkillFalloff) * (defender->CastToClient()->MaxSkill(DEFENSE)  - (SkillMod * defender->GetSkill(DEFENSE) /100) + defender->GetSkill(DEFENSE)));
	}
Kayen
GM Storm Haven
Reply With Quote
  #2  
Old 06-03-2012, 10:06 PM
Kayen
Developer
 
Join Date: Mar 2009
Location: -
Posts: 228
Default

Since I can't edit my original post. Revised new version.

New

Code:
	if(attacker->IsClient())
	{
		int SkillMod = 0;
		if(attacker->spellbonuses.MeleeSkillCheckSkill == skillinuse || attacker->spellbonuses.MeleeSkillCheckSkill == 255) 
		{
			SkillMod += attacker->spellbonuses.MeleeSkillCheckSkill;
		}
		
		if(attacker->itembonuses.MeleeSkillCheckSkill == skillinuse || attacker->itembonuses.MeleeSkillCheckSkill == 255) 
		{
			SkillMod += attacker->itembonuses.MeleeSkillCheckSkill;
		}
		
		chancetohit -= (RuleR(Combat,WeaponSkillFalloff) * (attacker->CastToClient()->MaxSkill(skillinuse)  - (SkillMod * attacker->GetSkill(skillinuse) /100) + attacker->GetSkill(skillinuse)));
		mlog(COMBAT__TOHIT, "Chance to hit after weapon falloff calc (attack) %.2f", chancetohit);
	}
	
	if(defender->IsClient())
	{
		int SkillMod = 0;
		if(defender->spellbonuses.MeleeSkillCheckSkill == DEFENSE || defender->spellbonuses.MeleeSkillCheckSkill == 255) 
		{
			SkillMod += defender->spellbonuses.MeleeSkillCheckSkill;
		}
		
		if(defender->itembonuses.MeleeSkillCheckSkill == DEFENSE || defender->itembonuses.MeleeSkillCheckSkill == 255) 
		{
			SkillMod += defender->itembonuses.MeleeSkillCheckSkill;
		}
		
		chancetohit += (RuleR(Combat,WeaponSkillFalloff) * (defender->CastToClient()->MaxSkill(DEFENSE)  - (SkillMod * defender->GetSkill(DEFENSE) /100) + defender->GetSkill(DEFENSE)));
	}
Reply With Quote
Reply


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 02:20 AM.


 

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