本文整理汇总了C++中ItemBase::ItemType方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemBase::ItemType方法的具体用法?C++ ItemBase::ItemType怎么用?C++ ItemBase::ItemType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemBase
的用法示例。
在下文中一共展示了ItemBase::ItemType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}