本文整理汇总了C++中ItemBase类的典型用法代码示例。如果您正苦于以下问题:C++ ItemBase类的具体用法?C++ ItemBase怎么用?C++ ItemBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ItemBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnComplete
void ActionMeassureBattery::OnComplete( PlayerBase player, PlayerBase target, ItemBase item )
{
//float energy = item.GetEnergy;
item.TransferModifiers(player);
//if(energy > 0) m_MessageSuccess = "Theres still some juice.";
//if(energy == 0) m_MessageSuccess = "Theres nothing.";
}
示例2: if
int Player::GetVenderBuyPrice(int ItemID)
{
VendorItemList *ItemL = 0;
ItemBase * Item = 0;
if (!m_CurrentNPC)
{
Item = g_ItemBaseMgr->GetItem(ItemID);
if (Item)
{
return Item->Cost();
}
else
{
return 0;
}
}
for(vecItemList::const_iterator v_item = m_CurrentNPC->Vendor.Items.begin(); v_item < m_CurrentNPC->Vendor.Items.end(); ++v_item)
{
ItemL = g_ServerMgr->m_StationMgr.GetVendorItem(*v_item);
if (ItemL && ItemL->ItemID == ItemID && (Item = g_ItemBaseMgr->GetItem(ItemL->ItemID)) )
{
if (ItemL->BuyPrice > 0)
{
return ItemL->BuyPrice;
}
else if (ItemL->BuyPrice == -1)
{
return 0;
}
else //panic! NPC buys for low cost
{
return (int)(Item->Cost() * 0.50f);
}
}
}
Item = g_ItemBaseMgr->GetItem(ItemID);
if (Item)
{
return Item->Cost();
}
return 0;
}
示例3: ViewGeometry
void PartsBinListView::loadImage(ModelPart * modelPart, QListWidgetItem * lwi, const QString & moduleID)
{
ItemBase * itemBase = ItemBaseHash.value(moduleID);
if (itemBase == NULL) {
itemBase = PartFactory::createPart(modelPart, ViewLayer::NewTop, ViewLayer::IconView, ViewGeometry(), ItemBase::getNextID(), NULL, NULL, false);
ItemBaseHash.insert(moduleID, itemBase);
LayerAttributes layerAttributes;
itemBase->initLayerAttributes(layerAttributes, ViewLayer::IconView, ViewLayer::Icon, itemBase->viewLayerPlacement(), false, false);
FSvgRenderer * renderer = itemBase->setUpImage(modelPart, layerAttributes);
if (renderer != NULL) {
if (itemBase) {
itemBase->setFilename(renderer->filename());
}
itemBase->setSharedRendererEx(renderer);
}
}
lwi->setData(Qt::UserRole, qVariantFromValue( itemBase ) );
QSize size(HtmlInfoView::STANDARD_ICON_IMG_WIDTH, HtmlInfoView::STANDARD_ICON_IMG_HEIGHT);
QPixmap * pixmap = FSvgRenderer::getPixmap(itemBase->renderer(), size);
lwi->setIcon(QIcon(*pixmap));
delete pixmap;
lwi->setData(Qt::UserRole + 1, itemBase->renderer()->defaultSize());
m_itemBaseHash.insert(moduleID, itemBase);
}
示例4: Reload
/* We are out of ammo, reload the launcher */
bool Equipable::Reload()
{
ItemBase * Ammo = 0;
for(u32 i=0; i<m_Player->ShipIndex()->Inventory.GetCargoSpace(); i++)
{
Ammo = g_ItemBaseMgr->GetItem(m_Player->ShipIndex()->Inventory.CargoInv.Item[i].GetItemTemplateID());
/* If this is ammo that matches the launcher */
if (Ammo && strstr(Ammo->Name(), m_ItemInstance.WeaponAmmo))
{
m_AuxAmmoItem->SetData(m_Player->ShipIndex()->Inventory.CargoInv.Item[i].GetData());
m_Player->ShipIndex()->Inventory.CargoInv.Item[i].Empty();
return true;
}
}
return false;
}
示例5: CanDo
bool ActionOnConsciousSelfContinuousQuantity::CanDo( PlayerBase player, Object target, ItemBase item )
{
if ( player && player.IsAlive() && item.GetDamage() < 1 ) //&& IsConscious && IsNotCaptured
{
return true;
}
else
{
return false;
}
}
示例6: 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];
}
}
示例7: GetNet7TickCount
//This is for the various effects associated with the item
void Equipable::AddEffects()
{
ItemBase * myItemBase = g_ItemBaseMgr->GetItem(m_AuxEquipItem->GetItemTemplateID());
if (myItemBase && myItemBase->EquipEffect() > 0)
{
// Add Equip Effect
ObjectEffect Effect;
Effect.Bitmask = 0x07;
Effect.EffectDescID = myItemBase->EquipEffect();
Effect.GameID = m_Player->GameID();
Effect.Duration = 0;
Effect.TimeStamp = GetNet7TickCount();
m_EEffectID = m_Player->m_Effects.AddEffect(&Effect);
// ----
}
/*
if (m_ItemBase->m_EffectsEquip > 0)
{
// Display Equip Effect
ObjectEffect OBTOBE;
OBTOBE.Bitmask = 0x07;
OBTOBE.GameID = m_Player->GameID();
OBTOBE.EffectDescID = m_ItemBase->m_EffectsEquip;
OBTOBE.EffectID = GetNet7TickCount();
OBTOBE.TimeStamp = GetNet7TickCount();
OBTOBE.Duration = 1750;
if (m_Player->ConnectionAvailable())
{
m_Player->Connection()->SendObjectEffect(m_Player->GameID(), &OBTOBE, TRUE); // Sector Wide
}
}
*/
}
示例8: CheckForItem
bool Equipable::CheckForItem(const char *description, const char *search)
{
long skill_count = 0;
bool no_duplicate = true;
bool retval = false;
if (strstr(description, search))
{
retval = true;
//check to see if there's already an item like this installed
for(int i=0;i<6;i++)
{
_Item *item = m_Player->ShipIndex()->Inventory.EquipInv.EquipItem[9+i].GetItemData();
if (item->ItemTemplateID > 0)
{
ItemBase *itembase = g_ItemBaseMgr->GetItem(item->ItemTemplateID);
//protect against equipping a null item, but how can that happen?
if(itembase)
{
//what have we here?
char *item_desc = itembase->Description();
if (strstr(item_desc, search))
{
//already equipped this item, don't allow it to affect stats again
skill_count++;
if (skill_count > 1)
{
no_duplicate = false;
break;
}
}
}
}
}
}
return (retval && no_duplicate);
}
示例9: settingItem
int PartsBinListView::setItemAux(ModelPart * modelPart, int position) {
if (modelPart->modelPartShared() == NULL) return position;
if (modelPart->itemType() == ModelPart::Unknown) {
// don't want the empty root to appear in the view
return position;
}
emit settingItem();
QString moduleID = modelPart->moduleID();
if(contains(moduleID)) {
m_partHash[moduleID]->copy(modelPart); // copies into the cached modelPart, but I don't know why
return position;
}
QListWidgetItem * lwi = new QListWidgetItem(modelPart->title());
if (modelPart->itemType() == ModelPart::Space) {
lwi->setBackground(QBrush(SectionHeaderBackgroundColor));
lwi->setForeground(QBrush(SectionHeaderForegroundColor));
lwi->setData(Qt::UserRole, 0);
lwi->setFlags(0);
lwi->setText(" " + TranslatedCategoryNames.value(modelPart->instanceText(), modelPart->instanceText()));
}
else {
ItemBase * itemBase = ItemBaseHash.value(moduleID);
if (itemBase == NULL) {
itemBase = PartFactory::createPart(modelPart, ViewLayer::ThroughHoleThroughTop_OneLayer, ViewLayer::IconView, ViewGeometry(), ItemBase::getNextID(), NULL, NULL, false);
ItemBaseHash.insert(moduleID, itemBase);
QString error;
LayerAttributes layerAttributes;
FSvgRenderer * renderer = itemBase->setUpImage(modelPart, ViewLayer::IconView, ViewLayer::Icon, itemBase->viewLayerSpec(), layerAttributes, error);
if (renderer != NULL) {
if (itemBase) {
itemBase->setFilename(renderer->filename());
}
itemBase->setSharedRendererEx(renderer);
}
}
lwi->setData(Qt::UserRole, qVariantFromValue( itemBase ) );
QSize size(HtmlInfoView::STANDARD_ICON_IMG_WIDTH, HtmlInfoView::STANDARD_ICON_IMG_HEIGHT);
QPixmap * pixmap = FSvgRenderer::getPixmap(itemBase->renderer(), size);
lwi->setIcon(QIcon(*pixmap));
delete pixmap;
lwi->setData(Qt::UserRole + 1, itemBase->renderer()->defaultSize());
m_partHash[moduleID] = modelPart;
}
if(position > -1 && position < count()) {
insertItem(position, lwi);
} else {
addItem(lwi);
position = this->count();
}
return position;
}
示例10: OnComplete
void ActionForceConsumeSingle::OnComplete( PlayerBase player, PlayerBase target, ItemBase item )
{
float quantity = item.GetQuantity();
if ( quantity <= 0 )
{
m_MessageSuccess = m_MessageStartFail ;
}
else
{
quantity--;
item.CalculateNutritions(target, m_GramsConsumedPerUse);
item.TransferModifiers(player);
item.SetQuantity(quantity, false);
if ( quantity <= 0 )
{
bool destroy = g_Game.ConfigGetInt("cfgVehicles " + item.GetType() + " destroyOnEmpty");
if ( destroy == 1 ) item.Delete();
}
}
}
示例11: itemItemBase
ModelPart *PartsBinListView::itemModelPart(const QListWidgetItem *item) const {
ItemBase * itemBase = itemItemBase(item);
if (itemBase == NULL) return NULL;
return itemBase->modelPart();
}
示例12: operator
void operator()(const ItemBase& item){
called = true;
frame = item.getFrame();
}
示例13: 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");
//.........这里部分代码省略.........
示例14: memset
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;
}
示例15: memcpy
/* This currently does not check quality */
void Player::CheckStack(int MoveNum, _Item * Source, _Item * Destination)
{
/* If the items have the same ID they can stack */
if (Source->ItemTemplateID == Destination->ItemTemplateID)
{
ItemBase * myItemBase = g_ItemBaseMgr->GetItem(Source->ItemTemplateID);
if (!myItemBase)
{
return;
}
/* If the MoveNum has enough items to make a full stack at Destination */
if (Destination->StackCount + MoveNum > myItemBase->MaxStack())
{
int moved = myItemBase->MaxStack() - Destination->StackCount;
Source->StackCount -= moved;
Destination->StackCount = myItemBase->MaxStack();
/* Now update the trade stacks */
Destination->TradeStack += (Source->TradeStack < moved ? Source->TradeStack : moved);
Source->TradeStack -= moved;
}
/* Otherwise the Destination can store the entire MoveNum ammount */
else
{
Destination->StackCount += MoveNum;
Source->StackCount -= MoveNum;
/* Now update the trade stacks */
Destination->TradeStack += (Source->TradeStack < MoveNum ? Source->TradeStack : MoveNum);
Source->TradeStack -= MoveNum;
}
/* Switch the Source and Destination stack counts */
u32 tmpStack = Destination->StackCount;
Destination->StackCount = Source->StackCount;
Source->StackCount = tmpStack;
/* Now switch their trade stacks aswell */
tmpStack = Destination->TradeStack;
Destination->TradeStack = Source->TradeStack;
Source->TradeStack = tmpStack;
/* If weve moved all of the items out of the source, set it to an empty item */
if (Destination->StackCount == 0)
{
memcpy(Destination, &g_ItemBaseMgr->EmptyItem, sizeof(_Item));
}
}
/* If the destination is am empty item and we are moving a substack*/
else if (Destination->ItemTemplateID == -1 && (u32)MoveNum < Source->StackCount)
{
/* Copy the source item to the destination */
memcpy(Destination, Source, sizeof(_Item));
Destination->StackCount = MoveNum;
Source->StackCount -= MoveNum;
/* Now update the trade stacks */
Destination->TradeStack += (Source->TradeStack < MoveNum ? Source->TradeStack : MoveNum);
Source->TradeStack -= MoveNum;
/* Switch the Source and Destination stack counts */
u32 tmpStack = Destination->StackCount;
Destination->StackCount = Source->StackCount;
Source->StackCount = tmpStack;
/* Now switch their trade stacks aswell */
tmpStack = Destination->TradeStack;
Destination->TradeStack = Source->TradeStack;
Source->TradeStack = tmpStack;
/* If weve moved all of the items out of the source, set it to an empty item */
if (Destination->StackCount == 0)
{
memcpy(Destination, &g_ItemBaseMgr->EmptyItem, sizeof(_Item));
}
}
}