本文整理汇总了C++中ItemBase::Fields方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemBase::Fields方法的具体用法?C++ ItemBase::Fields怎么用?C++ ItemBase::Fields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemBase
的用法示例。
在下文中一共展示了ItemBase::Fields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CorrectAmmo
bool Equipable::CorrectAmmo(_Item * Ammo)
{
/* If our current item is empty, cant equip ammo */
if (!m_ItemBase)
{
return false;
}
/* If our current item does not use ammo, then we cannot equip any */
if (!m_UsesAmmo)
{
return false;
}
/* If we are removing ammo and have ammo to remove, return true */
if (Ammo->ItemTemplateID == -1 && m_AuxAmmoItem->GetItemTemplateID() != -1)
{
return true;
}
/* If for some reason the ammo field is null, print an error and exit */
if (m_ItemInstance.WeaponAmmo == 0)
{
LogMessage("Item ID: [%d] uses ammo but has null ammo field\n", m_AuxEquipItem->GetItemTemplateID());
return false;
}
ItemBase * newItemBase = g_ItemBaseMgr->GetItem(Ammo->ItemTemplateID);
/* If we fail to find an itembase - exit */
if (!newItemBase)
{
return false;
}
/* Check to see if this is ammo */
if (newItemBase->SubCategory() != 103)
{
return false;
}
/* Now see if the ammo matches */
if (!strstr(newItemBase->Fields(1)->sData, m_ItemInstance.WeaponAmmo))
{
m_Player->SendVaMessage("Wrong ammo type. Trying to install '%s'. Weapon takes '%s'", newItemBase->Fields(1)->sData, m_ItemInstance.WeaponAmmo);
return false;
}
return true;
}
示例2: QualityCalculator
bool Player::QualityCalculator(_Item * myItem)
{
char InstanceInfo[64];
char IInstanceInfo[64];
int QArraySize = 7;
QualityArray QArray[] = {{14, 5, 0, 1.55f, 0.01f }, // Beams
{15,21, 1, 1.55f, 0.01f }, // ML
{16,21, 1, 1.55f, 0.01f }, // Projectiles
{ 2,26, 0, 1.55f, 0.01f }, // Shields
{ 6,31, 0, 1.35f, 0.01f }, // Engines Thrust
{ 6,34, 1, 1.55f, 0.01f }, // Engines Warp Drain
{ 7,20, 0, 1.55f, 0.01f } // Reactors
};
ItemBase * myItemBase = g_ItemBaseMgr->GetItem(myItem->ItemTemplateID);
memset(InstanceInfo, 0, sizeof(InstanceInfo));
if (!myItemBase) return false; // early return if item invalid
for(int x=0;x<QArraySize;x++)
{
if (QArray[x].ItemType == myItemBase->ItemType())
{
int FieldID = QArray[x].ItemField;
// Get Field Type
int FieldType = myItemBase->FieldType(FieldID);
float FieldData = 0;
// Read in Data
switch(FieldType)
{
// Float
case 1:
FieldData = myItemBase->Fields(FieldID)->fData;
break;
// Int
case 2:
FieldData = (float) myItemBase->Fields(FieldID)->iData;
break;
}
// Calculate Real Quality Percent
float RealPercent;
float ChangeRate;
float ItemQuality = myItem->Quality;
float NewFieldValue = 0;
// Calculate real percent from numbers
if (ItemQuality < 1.0f)
{
ChangeRate = ((1.0f - QArray[x].MinQuality)/1.0f);
RealPercent = ItemQuality * ChangeRate + QArray[x].MinQuality;
}
else
{
ChangeRate = ((QArray[x].MaxQuality - 1.0f)/1.0f);
RealPercent = (ItemQuality - 1.0f)* ChangeRate + 1.0f;
}
// Calculate the field data
if (QArray[x].Direction == 1)
{
NewFieldValue = (1.0f + (1.0f - RealPercent)) * FieldData;
}
else
{
NewFieldValue = RealPercent * FieldData;
}
// Client does not read below 1
if (NewFieldValue < 1.0f)
NewFieldValue = 1.0f;
sprintf(IInstanceInfo, "%d:%4.2f^", FieldID,NewFieldValue);
strcat(InstanceInfo, IInstanceInfo);
}
}
if (InstanceInfo[0] != 0)
{
memcpy(myItem->InstanceInfo, InstanceInfo, sizeof(InstanceInfo));
return true;
}
return false;
}