EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Development (https://www.eqemulator.org/forums/forumdisplay.php?f=590)
-   -   Applying Skill Mods in Mob::CheckHitChance (https://www.eqemulator.org/forums/showthread.php?t=35377)

Kayen 06-03-2012 11:32 AM

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

Kayen 06-03-2012 10:06 PM

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)));
        }



All times are GMT -4. The time now is 05:01 PM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.