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)

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 11-13-2008, 01:36 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

To get the skill value of the item being used in the primary spot, I am trying to write a function to handle it. I am not sure if this will work as it is, but might be worth a shot. Basically, it is supposed to get the item ID from the primary slot, and then determine the item type of that item. Finally, it checks the skill value of the player for the skill that item type uses.

I guess this could go in mob.cpp:
Code:
int Mob::GetPrimarySkillValue(SkillType &PrimarySkill, const ItemInst* Item_ID)
{
	int16 Item_ID = CastToClient()->GetItemIDAt(13);

	if (Item_ID = NULL)
		PrimarySkill = HAND_TO_HAND;

	else {
		const Item_Struct* item = Item_ID->GetItem();

		switch (item->ItemType)
		{
			case ItemType1HS: // 1H Slashing
			{
				PrimarySkill = _1H_SLASHING;
				break;
			}
			case ItemType2HS: // 2H Slashing
			{
				PrimarySkill = _2H_SLASHING;
				break;
			}
			case ItemTypePierce: // Piercing
			{
				PrimarySkill = PIERCING;
				break;
			}
			case ItemType1HB: // 1H Blunt
			{
				PrimarySkill = _1H_BLUNT;
				break;
			}
			case ItemType2HB: // 2H Blunt
			{
				PrimarySkill = _2H_BLUNT;
				break;
			}
			case ItemType2HPierce: // 2H Piercing
			{
				PrimarySkill = PIERCING;
				break;
			}
			case ItemTypeHand2Hand:
			{
				PrimarySkill = HAND_TO_HAND;
				break;
			}
			default:
			{
				PrimarySkill = NULL;
				break;
			}
		}
	}

	uint16 skill = GetSkill(PrimarySkill);

	return skill;
}
If anyone has any corrections or suggestions on how to do it better, I would be very happy to hear it. I am fairly certain that this will fail to even compile lol.

Once that function is working, all I will need to figure in is the attack rating cap formula, which should be fairly simple. And the new code for #showstats with this function would look like this:

Code:
void Mob::ShowStats(Client* client) {
	float attackRating = 0;

	if(this->IsClient()) {
		attackRating = (((GetATK() + GetSkill(OFFENSE)) * 1.342) + ((GetSTR() - 66) * .9) + (GetPrimarySkillValue() * 2.69));
		int32	AR_Cap = 0;  //Attack Rating Cap
		AR_Cap = (GetSkill(OFFENSE) + GetPrimarySkillValue() ) * 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 I get this attack rating calculation working smoothly, I may try to just make a function to handle the whole thing, so we could just use GetTotalATK() where needed instead of doing the same code over and over.

That code would be something like this:
EDIT: Change the code below for GetTotalATK() a bit.
client.cpp
Code:
uint16 Client::GetTotalATK()
{
	int16 AttackRating = 0;

	if(IsClient()) {
		AttackRating = (((GetATK() + GetSkill(OFFENSE)) * 1.342) + ((GetSTR() - 66) * 0.9) + (GetPrimarySkillValue() * 2.69));
		int16	AR_Cap = 0;  //Attack Rating Cap
		AR_Cap = (GetSkill(OFFENSE) + GetPrimarySkillValue()) * 10;  //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);

	return AttackRating;
}
Then, the #showstats would just need to have GetATK() replaced with GetTotalATK(), and it should show more accurate values. For the actual attack code to use this, it could just replace the current Attack Rating calculations in mitigation, and just do (GetTotalATK() / 2) instead to get it back to about the same as it is now. NPC DPS wouldn't be effected by this, just players. And by dividing it by 2, it should get them back to about the same as they are now.

Of course, again, if anyone has any corrections or suggestions on how to code this stuff properly, I would be glad to hear them. My coding skills are still really bad and there are certain things I don't understand well or at all yet. I mostly just work by examples I find elsewhere in the source.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 11-18-2008 at 08:49 AM..
Reply With Quote
 


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 11:59 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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3