本文整理汇总了C++中ItemBase::SubCategory方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemBase::SubCategory方法的具体用法?C++ ItemBase::SubCategory怎么用?C++ ItemBase::SubCategory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemBase
的用法示例。
在下文中一共展示了ItemBase::SubCategory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetItem
ItemBase * ItemBaseManager::GetOreTemplate(short level, short obj_type, long sector_id, Field *f)
{
ItemBase * Template[60];
int TemplateCount = 0;
int ItemIndex = 0;
SectorData *sector_data = g_ServerMgr->m_SectorContent.GetSectorData(sector_id);
AsteroidSubcatVec *subcat_vec = g_ServerMgr->m_SectorContent.GetAsteroidContentSelection(obj_type);
//scan through to see how many ores there are for this level and type
if (subcat_vec)
{
//find out what we've got to choose from
//base sector ores
for (int i = 0; i < sector_data->ore_list_size; i++)
{
//now get item
ItemBase * myItem = GetItem(sector_data->OreList[i]->item_id);
//now check to see if it's in the categories, if so, add as choice
for (AsteroidSubcatVec::iterator subcatItr = subcat_vec->begin(); subcatItr != subcat_vec->end(); ++subcatItr)
{
if (myItem->SubCategory() == (*subcatItr) && myItem->TechLevel() == level)
{
Template[TemplateCount++] = myItem; //add to ore choice
if (TemplateCount == 60) break;
}
}
}
//Additional field ores
ItemIDList *orelist = f->GetAdditionalItemIDs();
for (ItemIDList::iterator itrI = orelist->begin(); itrI != orelist->end(); ++itrI)
{
//now get item
ItemBase * myItem = GetItem((*itrI)->item_id);
//now check to see if it's in the categories, if so, add as choice
for (AsteroidSubcatVec::iterator subcatItr = subcat_vec->begin(); subcatItr != subcat_vec->end(); ++subcatItr)
{
if (myItem->SubCategory() == (*subcatItr) && myItem->TechLevel() == level)
{
Template[TemplateCount++] = myItem; //add to ore choice
if (TemplateCount == 60) break;
}
}
}
}
if (TemplateCount > 0)
{
return Template[rand() % TemplateCount]; //randomly choose from ore choice - TODO: add frequency weightings
}
else
{
//didn't find anything to go here - issue error from resource class
return 0;// m_ItemList[rand() % m_ItemCount];
}
}
示例2: 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;
}
示例3: CanEquip
/* Checks if an item can be equiped in this slot */
bool Equipable::CanEquip(_Item * NewItem)
{
/* If this is a weapon/device then we can unequip it */
if (m_Slot >= 3 && m_Slot <= 14 && NewItem->ItemTemplateID == -1)
{
return true;
}
ItemBase * myItemBase = g_ItemBaseMgr->GetItem(NewItem->ItemTemplateID);
/* If we fail to find an itembase - exit */
if (!myItemBase)
{
return false;
}
int SubCat = myItemBase->SubCategory();
/* Now check to see if this is ammo for current item */
if (SubCat == 103 && m_UsesAmmo && !CorrectAmmo(NewItem))
{
m_Player->SendPriorityMessageString("The ammo does not fit here","MessageLine",2000,4);
//printf("CanEquip - Wrong ammo\n");
return false;
}
/* Cannot equip ammo without a launcher */
if (SubCat == 103 && !m_UsesAmmo)
{
m_Player->SendPriorityMessageString("Weapon doesn't require ammo","MessageLine",2000,4);
//m_Player->SendVaMessage("Weapon doesn't use ammo");
//printf("CanEquip - Ammo with no launcher\n");
return false;
}
/* Now check that the item matches the slot type */
if ((m_Slot == 0 && SubCat != 122) || // Shield
(m_Slot == 1 && SubCat != 120) || // Reactor
(m_Slot == 2 && SubCat != 121) || // Engine
(m_Slot >= 3 && m_Slot <= 8 && SubCat != 100 && SubCat != 101 && SubCat != 102 && SubCat != 103) || //Weapon/Ammo
(m_Slot >= 9 && m_Slot <= 15 && SubCat != 110)) //Device
{
m_Player->SendPriorityMessageString("Item does not fit here","MessageLine",2000,4);
//printf("CanEquip - Wrong item for slot\n");
return false;
}
AuxSkill * Skills = &m_Player->PlayerIndex()->RPGInfo.Skills.Skill[0];
/* Now check skill requirements */
if ((SubCat == 100 && Skills[SKILL_BEAM_WEAPON].GetLevel() < myItemBase->TechLevel()) ||
(SubCat == 101 && Skills[SKILL_PROJECTILE_WEAPON].GetLevel() < myItemBase->TechLevel()) ||
(SubCat == 102 && Skills[SKILL_MISSILE_WEAPON].GetLevel() < myItemBase->TechLevel()) ||
(SubCat == 110 && Skills[SKILL_DEVICE_TECH].GetLevel() < myItemBase->TechLevel()) ||
(SubCat == 120 && Skills[SKILL_REACTOR_TECH].GetLevel() < myItemBase->TechLevel()) ||
(SubCat == 121 && Skills[SKILL_ENGINE_TECH].GetLevel() < myItemBase->TechLevel()) ||
(SubCat == 122 && Skills[SKILL_SHIELD_TECH].GetLevel() < myItemBase->TechLevel()))
{
m_Player->SendPriorityMessageString("You need more skill to equip this item","MessageLine",2000,4);
//printf("CanEquip - bad skill\n");
return false;
}
ItemRequirements Req = myItemBase->GetItemRequirements();
/* Now check for race restrictions */
if (Req.RaceRestriction & (0x01 << m_Player->Race()))
{
//printf("CanEquip - Race restriction\n");
m_Player->SendPriorityMessageString("Your Race can not equip this item","MessageLine",2000,4);
return false;
}
/* Also check for race lore restrictions */
if ((m_Player->Race() == 1 && Req.LoreRestriction == 0x02) ||
(m_Player->Race() == 2 && Req.LoreRestriction == 0x01))
{
//printf("CanEquip - Lore restriction\n");
m_Player->SendPriorityMessageString("Your Lore can not equip this item","MessageLine",2000,4);
return false;
}
/* Now check for profession restrictions */
if (Req.ProfessionRestriction & (0x01 << m_Player->Profession()))
{
m_Player->SendPriorityMessageString("Your profession can not equip this item","MessageLine",2000,4);
//printf("CanEquip - Profession restriction\n");
return false;
}
/* Now check for level requirements */
if ((Req.CombatRequirement > m_Player->CombatLevel()) ||
(Req.ExploreRequirement > m_Player->ExploreLevel()) ||
(Req.TradeRequirement > m_Player->TradeLevel()) ||
(Req.OverallRequirement > m_Player->TotalLevel()))
{
m_Player->SendPriorityMessageString("You can not equip this item","MessageLine",2000,4);
//printf("CanEquip - level restriction\n");
//.........这里部分代码省略.........