View Single Post
  #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