All of the following are from attack.cpp from the 3/1 cvs pull down and im assuming you want to be as close to eqlive combat as possible..
Code:
//
// we start by giving them a base chance to hit
//
chancetohit = 50;
I feel this is a bit on the low side, as evidence you can read extensive parsing in link provided below and discover in more testing that against an even con it generally falls in 55-60 percent for base chance to hit.
http://www.thesteelwarrior.org/forum...;threadid=3803
Code:
// if attacker is higher level, they have a better chance of hitting their
// target right from the start. for each level difference it's 2% chance,
// up to 20. so, if you're level 21 attacking a level 10 mob, that's a 22%
// chance bonus. the level difference shouldn't be that big of a bonus,
// otherwise when exping off an even con monster, after you leve up it would
// become significantly easier. this effect should be subtle, and should
// increase as you have more and more level on the monster, but it needs to
// be capped too
chancetohit += (float) level_difference * 2;
i like the caps imposed generally speaking, but i feel that your level bonus is a bit steep. Perhaps 1 percent per level would be more in line ?? The cap for a level 65 attacking a very very green mob is around 71 percent ( see link below) and there are several parses from link above that suggest attacking a level 69 red con from behind is only 55 percent from an SK... My point being is the spread seems alot more gradual..
http://www.eqbeastlord.com/forums/viewtopic.php?t=10317
Code:
//Quagmire: Take into account offense/defense skill
// with this formula if you have an attacker with 185 offense skill
// and a defender with 180 defense, the net effect is
// 24.05 - 16.2 == 7.85% added
// an example with the defender having a defense of 85, and the attacker
// having an offense of 60
// 7.8 - 7.65 = 0.15% added
// so basically defense is for cancelling out the attacker's offense,
// but offense is more effective than defense
chancetohit += (float)((float)attacker->GetSkill(OFFENSE) * 0.13f);
chancetohit -= (float)((float)defender->GetSkill(DEFENSE) * 0.09f);
Is there a calc for mobs offense and defense? i dont recall seeing it in DB, perhaps its figured out in code... I dont understand why only using the offense score here ( should be offense + weaponskill as both affect chance to hit) I really dont feel that eq uses any such calculation for live combat because given identical PCs hitting different mobs in general ( their are exceptions) you have the same chance to hit if mobs are same level...
Code:
int16 defender_agi = defender->GetAGI();
// skill points over 200 are 1/5 as effective
// at max stat of 252 this is a 10.52% bonus
defender_agi = (defender_agi <= 200) ? defender_agi : defender_agi + ((defender_agi-200)/5);
chancetohit -= (float)((float)defender_agi * 0.05f);
// this comes out to about 1% for every 7 dex over 50
// so someone with 105 dex gets 8.25% added here
int16 attacker_dex = attacker->GetDEX();
attacker_dex = (attacker_dex <= 200) ? attacker_dex : attacker_dex + ((attacker_dex-200)/5);
attacker_dex -= 50;
chancetohit += (float) ((float)attacker_dex * 0.15f);
10 percent penalty for max agility seems to big to me. Consider that a 65 warrior with all his defenses (riposte,parry,dodge,etc) together barely reduce a mobs chance to hit 10-12 percent... I d reduce that to 1/4 of what it is personally.
Adding dex into chance to hit equation is well.. wrong. To my knowledge dex does nothing to affect your chance to hit.
Code:
{
//
// if this is a client we want to take their weapon skill and give them
// a bonus to their chance to hit. at 200 skill you will get 40% added
// to your chance to hit
//
chancetohit += ((float)attacker->CastToClient()->GetSkill(skillinuse) / 6.5f);
}
else
{
chancetohit += 20; // assume NPCs have 120 skill with their weapon
}
// Chance to hit; Max 95%, Min 30%
chancetohit = (chancetohit > 95) ? 95 : ( (chancetohit < 30) ? 30 : chancetohit );
So pretty much any melee based PC at level 50 and above is gonna have a 90 percent chance to hit ( 50 percent base +40 percent from 200 weaponskill) just from base chance and weapon skill??? I would suggest you use something that compares OFFENSE skill + WEAPONSKILL compared to individuals level as the basis for this bonus. An example if crappy code i wrote that does this is...
Code:
else if (other->IsClient()){
int8 chancetohit = 0;
int8 otherlevel = this->GetLevel();
int8 mylevel = other->GetLevel();
otherlevel = otherlevel ? otherlevel : 1;
mylevel = mylevel ? mylevel : 1;
int16 skillval = ((float)other->CastToClient()->GetSkill(attack_skill));
int16 offval = ((float)other->CastToClient()->GetSkill(OFFENSE));
int16 combo = (skillval + offval);
int16 leveldif = (mylevel-otherlevel);
int16 skilind = (combo/mylevel);
// Given that levels are equal and given that clients skills are maxxed for his/her level
// this will give very close to a 60 percent chance to hit from behind again.
// skillind is basically an index of how skilled for clients level is he/she.
// this should reflect live behavior in ceratin skill peaks and valleys that happen from 40-50 and 60-65.
chancetohit = (52 + leveldif + skilind);
// The below caps the skills again, in most parses i have seen 73 percent
// was max hit rate against a level 1 by a 65 level char so seems appropriate.
if (chancetohit >= 73) {
chancetohit = 73;
}
else if (chancetohit <= 35) {
chancetohit = 35;
}
So to summarize ...
The following things should be considered when determining hitting an NPC...
1. Weapon Skill and Offense skill (if client is PC)
2. Level of PC's or NPC's
3. Agility to some small degree for the defender
Thats it....
Kudos to the people that went through that code and commented that first section so nicely and reorganized it, much easier to read for me.