Quote:
Originally Posted by trevius
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;
}
|
Per trev and my collaboration, corrections to the first function:
client.cpp:
Code:
uint16 Client::GetPrimarySkillValue()
{
uint8 type = m_inv.GetItem(13)->GetItem()->ItemType; //is this the best way to do this?
SkillType skill = HIGHEST_SKILL + 1; //because NULL == 0, which is 1H Slashing, & we want it to return 0 from GetSkill
if (!type)
skill = HAND_TO_HAND;
else {
switch (type)
{
case ItemType1HS: // 1H Slashing
{
skill = _1H_SLASHING;
break;
}
case ItemType2HS: // 2H Slashing
{
skill = _2H_SLASHING;
break;
}
case ItemTypePierce: // Piercing
{
skill = PIERCING;
break;
}
case ItemType1HB: // 1H Blunt
{
skill = _1H_BLUNT;
break;
}
case ItemType2HB: // 2H Blunt
{
skill = _2H_BLUNT;
break;
}
case ItemType2HPierce: // 2H Piercing
{
skill = PIERCING;
break;
}
case ItemTypeHand2Hand:
{
skill = HAND_TO_HAND;
break;
}
}
}
return GetSkill(skill);
}
One thing to note is that we'll probably want to put this in the Mob class, then create a virtual function in the NPC class to always return 0, since as far as we know, NPCs don't have "skillz", plus a virtual function (above) for the Client class.