View Single Post
  #1  
Old 11-12-2008, 10:03 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default Attack Rating Calculations

Tonight, I wrote a change for #showstats to try to make it show the correct attack rating for players. I used the exact same code that the source uses to calculate attack to factor into damage. Here is the calculation:

Code:
		if(attacker->IsClient())
			attackRating = attacker->GetATK() + ((attacker->GetSTR() + attacker->GetSkill(OFFENSE)) * 9 / 10);
		else
			attackRating = attacker->GetATK() + (attacker->GetSTR() * 9 / 10);
I found that this calculation is WAY off from what the character window shows.

After much testing of different values, I have found what I think to be very accurate numbers for the equation. We were also missing some major factors into it as well, such as skill for the item equiped.

Strength - 66 * 0.9
Attack from items * 1.342
skill in use (item type equiped in primary slot) * 2.69
offense skill * 1.342

I haven't tested this yet, but I think this may work to do the calculations above. I did the math manually a few times and it was extremely accurate within maybe 2 or 3 points off or so.

Code:
   if(this->IsClient())
      attackRating = (((GetATK() + GetSkill(OFFENSE)) * 1.342) + ((GetSTR() - 66) * .9) + (GetSkill(skillinuse) * 2.69));
   else
      attackRating = GetATK() + (GetSTR() * 9 / 10);
To test this, tomorrow night I will probably put this into #showstats like this:

Code:
void Mob::ShowStats(Client* client) {
   float attackRating = 0;
	if(this->IsClient()) {
		attackRating = (((GetATK() + GetSkill(OFFENSE)) * 1.342) + ((GetSTR() - 66) * .9) + (GetSkill(skillinuse) * 2.69));
		//Need to add a way to calculate the skill of the weapon in the primary slot instead of using skillinuse
		int32	AR_Cap = 0;  //Attack Rating Cap
		AR_Cap = (GetSkill(OFFENSE) + GetSkill(skillinuse) ) * 5;  //This isn't correct, but putting it here until I have the correct formula for caps
		if (attackRating > AR_Cap)
			attackRating = AR_Cap;

		if (attackRating < 10)
			attackRating = 10;
	}
	else
	attackRating = GetATK() + (GetSTR() * 9 / 10);

	client->Message(0, "Name: %s %s", GetName(), lastname);
	client->Message(0, "  Level: %i  MaxHP: %i  CurHP: %i  AC: %i  Class: %i", GetLevel(), GetMaxHP(), GetHP(), GetAC(), GetClass());
	client->Message(0, "  MaxMana: %i  CurMana: %i  ATK: %i  Size: %1.1f", GetMaxMana(), GetMana(), attackRating, GetSize());
If that proves to be accurate, we might want to consider altering all other parts of the code that rely on calculating attack properly.

***EDIT: Editing the code as I refine it to make it more accurate***
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 11-13-2008 at 02:48 AM..
Reply With Quote