本文整理汇总了C++中ItemInst::GetCharges方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemInst::GetCharges方法的具体用法?C++ ItemInst::GetCharges怎么用?C++ ItemInst::GetCharges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemInst
的用法示例。
在下文中一共展示了ItemInst::GetCharges方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _HasItemByUse
// Internal Method: Checks an inventory queue type bucket for a particular item
sint16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity)
{
iter_queue it;
iter_contents itb;
uint8 quantity_found = 0;
// Read-only iteration of queue
for (it=iqueue.begin(); it!=iqueue.end(); it++) {
ItemInst* inst = *it;
if (inst && inst->IsType(ItemClassCommon) && inst->GetItem()->ItemType == use) {
quantity_found += (inst->GetCharges()<=0) ? 1 : inst->GetCharges();
if (quantity_found >= quantity)
return SLOT_CURSOR;
}
// Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second;
if (baginst && baginst->IsType(ItemClassCommon) && baginst->GetItem()->ItemType == use) {
quantity_found += (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges();
if (quantity_found >= quantity)
return Inventory::CalcSlotId(SLOT_CURSOR, itb->first);
}
}
}
}
// Not found
return SLOT_INVALID;
}
示例2: _HasItem
// Internal Method: Checks an inventory bucket for a particular item
int16 Inventory::_HasItem(std::map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity)
{
iter_inst it;
iter_contents itb;
ItemInst* inst = nullptr;
uint8 quantity_found = 0;
// Check item: After failed checks, check bag contents (if bag)
for (it = bucket.begin(); it != bucket.end(); ++it) {
inst = it->second;
if (inst) {
if (inst->GetID() == item_id) {
quantity_found += (inst->GetCharges() <= 0) ? 1 : inst->GetCharges();
if (quantity_found >= quantity)
return it->first;
}
}
// Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) {
for (itb = inst->_begin(); itb != inst->_end(); ++itb) {
ItemInst* baginst = itb->second;
if (baginst->GetID() == item_id) {
quantity_found += (baginst->GetCharges() <= 0) ? 1 : baginst->GetCharges();
if (quantity_found >= quantity)
return Inventory::CalcSlotId(it->first, itb->first);
}
}
}
}
// Not found
return SLOT_INVALID;
}
示例3: _HasItem
// Internal Method: Checks an inventory queue type bucket for a particular item
sint16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity)
{
iter_queue it;
iter_contents itb;
uint8 quantity_found = 0;
// Read-only iteration of queue
for (it=iqueue.begin(); it!=iqueue.end(); it++) {
ItemInst* inst = *it;
if (inst)
{
if (inst->GetID() == item_id) {
quantity_found += (inst->GetCharges()<=0) ? 1 : inst->GetCharges();
if (quantity_found >= quantity)
return SLOT_CURSOR;
}
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
if (inst->GetAugmentItemID(i) == item_id && quantity <= 1)
return SLOT_AUGMENT; // Only one augment per slot.
}
}
// Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second;
if (baginst->GetID() == item_id) {
quantity_found += (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges();
if (quantity_found >= quantity)
return Inventory::CalcSlotId(SLOT_CURSOR, itb->first);
}
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
if (baginst->GetAugmentItemID(i) == item_id && quantity <= 1)
return SLOT_AUGMENT; // Only one augment per slot.
}
}
}
}
// Not found
return SLOT_INVALID;
}
示例4: dumpBagContents
void Inventory::dumpBagContents(ItemInst *inst, iter_inst *it) {
iter_contents itb;
if (!inst || !inst->IsType(ItemClassContainer))
return;
// Go through bag, if bag
for (itb=inst->_begin(); itb!=inst->_end(); ++itb) {
ItemInst* baginst = itb->second;
if(!baginst || !baginst->GetItem())
continue;
std::string subSlot;
StringFormat(subSlot," Slot %d: %s (%d)", Inventory::CalcSlotId((*it)->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
std::cout << subSlot << std::endl;
}
}
示例5: dumpItemCollection
void Inventory::dumpItemCollection(const std::map<int16, ItemInst*> &collection) {
iter_inst it;
iter_contents itb;
ItemInst* inst = nullptr;
for (it=collection.begin(); it!=collection.end(); ++it) {
inst = it->second;
if(!inst || !inst->GetItem())
continue;
std::string slot;
StringFormat(slot, "Slot %d: %s (%d)",it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
std::cout << slot << std::endl;
dumpBagContents(inst, &it);
}
}
示例6: LootItem
//.........这里部分代码省略.........
}
else {
inst = database.CreateItem(item);
}
}
if (client && inst) {
if (client->CheckLoreConflict(item)) {
client->Message_StringID(0, LOOT_LORE_ERROR);
SendEndLootErrorPacket(client);
being_looted_by = 0;
delete inst;
return;
}
if (inst->IsAugmented()) {
for (int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++) {
ItemInst *itm = inst->GetAugment(i);
if (itm) {
if (client->CheckLoreConflict(itm->GetItem())) {
client->Message_StringID(0, LOOT_LORE_ERROR);
SendEndLootErrorPacket(client);
being_looted_by = 0;
delete inst;
return;
}
}
}
}
char buf[88];
char corpse_name[64];
strcpy(corpse_name, corpse_name);
snprintf(buf, 87, "%d %d %s", inst->GetItem()->ID, inst->GetCharges(), EntityList::RemoveNumbers(corpse_name));
buf[87] = '\0';
std::vector<EQEmu::Any> args;
args.push_back(inst);
args.push_back(this);
parse->EventPlayer(EVENT_LOOT, client, buf, 0, &args);
parse->EventItem(EVENT_LOOT, client, inst, this, buf, 0);
if (!IsPlayerCorpse() && RuleB(Character, EnableDiscoveredItems)) {
if (client && !client->GetGM() && !client->IsDiscovered(inst->GetItem()->ID))
client->DiscoverItem(inst->GetItem()->ID);
}
if (zone->adv_data) {
ServerZoneAdventureDataReply_Struct *ad = (ServerZoneAdventureDataReply_Struct*)zone->adv_data;
if (ad->type == Adventure_Collect && !IsPlayerCorpse()) {
if (ad->data_id == inst->GetItem()->ID) {
zone->DoAdventureCountIncrease();
}
}
}
/* First add it to the looter - this will do the bag contents too */
if (lootitem->auto_loot) {
if (!client->AutoPutLootInInventory(*inst, true, true, bag_item_data))
client->PutLootInInventory(MainCursor, *inst, bag_item_data);
}
else {
client->PutLootInInventory(MainCursor, *inst, bag_item_data);
}
/* Update any tasks that have an activity to loot this item */
if (RuleB(TaskSystem, EnableTaskSystem))
示例7: HasSpaceForItem
bool Inventory::HasSpaceForItem(const Item_Struct *ItemToTry, sint16 Quantity) {
if(ItemToTry->Stackable) {
for(sint16 i = 22; i <= 29; i++) {
ItemInst* InvItem = GetItem(i);
if(InvItem && (InvItem->GetItem()->ID == ItemToTry->ID) && (InvItem->GetCharges() < InvItem->GetItem()->StackSize)) {
int ChargeSlotsLeft = InvItem->GetItem()->StackSize - InvItem->GetCharges();
if(Quantity <= ChargeSlotsLeft)
return true;
Quantity -= ChargeSlotsLeft;
}
if (InvItem && InvItem->IsType(ItemClassContainer)) {
sint16 BaseSlotID = Inventory::CalcSlotId(i, 0);
int8 BagSize=InvItem->GetItem()->BagSlots;
for (uint8 BagSlot = 0; BagSlot < BagSize; BagSlot++) {
InvItem = GetItem(BaseSlotID + BagSlot);
if(InvItem && (InvItem->GetItem()->ID == ItemToTry->ID) &&
(InvItem->GetCharges() < InvItem->GetItem()->StackSize)) {
int ChargeSlotsLeft = InvItem->GetItem()->StackSize - InvItem->GetCharges();
if(Quantity <= ChargeSlotsLeft)
return true;
Quantity -= ChargeSlotsLeft;
}
}
}
}
}
for (sint16 i = 22; i <= 29; i++) {
ItemInst* InvItem = GetItem(i);
if (!InvItem) {
if(!ItemToTry->Stackable) {
if(Quantity == 1)
return true;
else
Quantity--;
}
else {
if(Quantity <= ItemToTry->StackSize)
return true;
else
Quantity -= ItemToTry->StackSize;
}
}
else if(InvItem->IsType(ItemClassContainer) && CanItemFitInContainer(ItemToTry, InvItem->GetItem())) {
sint16 BaseSlotID = Inventory::CalcSlotId(i, 0);
int8 BagSize=InvItem->GetItem()->BagSlots;
for (uint8 BagSlot=0; BagSlot<BagSize; BagSlot++) {
InvItem = GetItem(BaseSlotID + BagSlot);
if(!InvItem) {
if(!ItemToTry->Stackable) {
if(Quantity == 1)
return true;
else
Quantity--;
}
else {
if(Quantity <= ItemToTry->StackSize)
return true;
else
Quantity -= ItemToTry->StackSize;
}
}
}
}
}
return false;
}
示例8: dumpInventory
void Inventory::dumpInventory() {
iter_inst it;
iter_contents itb;
ItemInst* inst = NULL;
// Check item: After failed checks, check bag contents (if bag)
printf("Worn items:\n");
for (it=m_worn.begin(); it!=m_worn.end(); it++) {
inst = it->second;
it->first;
if(!inst || !inst->GetItem())
continue;
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
// Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second;
if(!baginst || !baginst->GetItem())
continue;
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
}
}
}
printf("Inventory items:\n");
for (it=m_inv.begin(); it!=m_inv.end(); it++) {
inst = it->second;
it->first;
if(!inst || !inst->GetItem())
continue;
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
// Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second;
if(!baginst || !baginst->GetItem())
continue;
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
}
}
}
printf("Bank items:\n");
for (it=m_bank.begin(); it!=m_bank.end(); it++) {
inst = it->second;
it->first;
if(!inst || !inst->GetItem())
continue;
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
// Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second;
if(!baginst || !baginst->GetItem())
continue;
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
}
}
}
printf("Shared Bank items:\n");
for (it=m_shbank.begin(); it!=m_shbank.end(); it++) {
inst = it->second;
it->first;
if(!inst || !inst->GetItem())
continue;
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
// Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second;
if(!baginst || !baginst->GetItem())
continue;
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
}
}
}
printf("\n");
fflush(stdout);
}
示例9: ExportEventVariables
void PerlembParser::ExportEventVariables(std::string &package_name, QuestEventID event, uint32 objid, const char * data,
NPC* npcmob, ItemInst* iteminst, Mob* mob, uint32 extradata, std::vector<EQEmu::Any> *extra_pointers)
{
switch (event) {
case EVENT_SAY: {
if(npcmob && mob) {
npcmob->DoQuestPause(mob);
}
ExportVar(package_name.c_str(), "data", objid);
ExportVar(package_name.c_str(), "text", data);
ExportVar(package_name.c_str(), "langid", extradata);
break;
}
case EVENT_TRADE: {
if(extra_pointers) {
size_t sz = extra_pointers->size();
for(size_t i = 0; i < sz; ++i) {
ItemInst *inst = EQEmu::any_cast<ItemInst*>(extra_pointers->at(i));
std::string var_name = "item";
var_name += std::to_string(i + 1);
if(inst) {
ExportVar(package_name.c_str(), var_name.c_str(), inst->GetItem()->ID);
std::string temp_var_name = var_name;
temp_var_name += "_charges";
ExportVar(package_name.c_str(), temp_var_name.c_str(), inst->GetCharges());
temp_var_name = var_name;
temp_var_name += "_attuned";
ExportVar(package_name.c_str(), temp_var_name.c_str(), inst->IsAttuned());
} else {
ExportVar(package_name.c_str(), var_name.c_str(), 0);
std::string temp_var_name = var_name;
temp_var_name += "_charges";
ExportVar(package_name.c_str(), temp_var_name.c_str(), 0);
temp_var_name = var_name;
temp_var_name += "_attuned";
ExportVar(package_name.c_str(), temp_var_name.c_str(), 0);
}
}
}
ExportVar(package_name.c_str(), "copper", GetVar("copper." + std::string(itoa(objid))).c_str());
ExportVar(package_name.c_str(), "silver", GetVar("silver." + std::string(itoa(objid))).c_str());
ExportVar(package_name.c_str(), "gold", GetVar("gold." + std::string(itoa(objid))).c_str());
ExportVar(package_name.c_str(), "platinum", GetVar("platinum." + std::string(itoa(objid))).c_str());
std::string hashname = package_name + std::string("::itemcount");
perl->eval(std::string("%").append(hashname).append(" = ();").c_str());
perl->eval(std::string("++$").append(hashname).append("{$").append(package_name).append("::item1};").c_str());
perl->eval(std::string("++$").append(hashname).append("{$").append(package_name).append("::item2};").c_str());
perl->eval(std::string("++$").append(hashname).append("{$").append(package_name).append("::item3};").c_str());
perl->eval(std::string("++$").append(hashname).append("{$").append(package_name).append("::item4};").c_str());
break;
}
case EVENT_WAYPOINT_ARRIVE:
case EVENT_WAYPOINT_DEPART: {
ExportVar(package_name.c_str(), "wp", data);
break;
}
case EVENT_HP: {
if (extradata == 1) {
ExportVar(package_name.c_str(), "hpevent", "-1");
ExportVar(package_name.c_str(), "inchpevent", data);
}
else
{
ExportVar(package_name.c_str(), "hpevent", data);
ExportVar(package_name.c_str(), "inchpevent", "-1");
}
break;
}
case EVENT_TIMER: {
ExportVar(package_name.c_str(), "timer", data);
break;
}
case EVENT_SIGNAL: {
ExportVar(package_name.c_str(), "signal", data);
break;
}
case EVENT_NPC_SLAY: {
ExportVar(package_name.c_str(), "killed", mob->GetNPCTypeID());
break;
}
case EVENT_COMBAT: {
ExportVar(package_name.c_str(), "combat_state", data);
break;
}
//.........这里部分代码省略.........
示例10: HandleCombine
// Perform tradeskill combine
void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Object *worldo)
{
if (!user || !in_combine) {
Log.Out(Logs::General, Logs::Error, "Client or NewCombine_Struct not set in Object::HandleCombine");
return;
}
Inventory& user_inv = user->GetInv();
PlayerProfile_Struct& user_pp = user->GetPP();
ItemInst* container = nullptr;
ItemInst* inst = nullptr;
uint8 c_type = 0xE8;
uint32 some_id = 0;
bool worldcontainer=false;
if (in_combine->container_slot == legacy::SLOT_TRADESKILL) {
if(!worldo) {
user->Message(13, "Error: Server is not aware of the tradeskill container you are attempting to use");
return;
}
c_type = worldo->m_type;
inst = worldo->m_inst;
worldcontainer=true;
}
else {
inst = user_inv.GetItem(in_combine->container_slot);
if (inst) {
const Item_Struct* item = inst->GetItem();
if (item && inst->IsType(ItemClassContainer)) {
c_type = item->BagType;
some_id = item->ID;
}
}
}
if (!inst || !inst->IsType(ItemClassContainer)) {
user->Message(13, "Error: Server does not recognize specified tradeskill container");
return;
}
container = inst;
if (container->GetItem() && container->GetItem()->BagType == BagTypeTransformationmold) {
const ItemInst* inst = container->GetItem(0);
bool AllowAll = RuleB(Inventory, AllowAnyWeaponTransformation);
if (inst && ItemInst::CanTransform(inst->GetItem(), container->GetItem(), AllowAll)) {
const Item_Struct* new_weapon = inst->GetItem();
user->DeleteItemInInventory(Inventory::CalcSlotId(in_combine->container_slot, 0), 0, true);
container->Clear();
user->SummonItem(new_weapon->ID, inst->GetCharges(), inst->GetAugmentItemID(0), inst->GetAugmentItemID(1), inst->GetAugmentItemID(2), inst->GetAugmentItemID(3), inst->GetAugmentItemID(4), inst->GetAugmentItemID(5), inst->IsAttuned(), MainCursor, container->GetItem()->Icon, atoi(container->GetItem()->IDFile + 2));
user->Message_StringID(4, TRANSFORM_COMPLETE, inst->GetItem()->Name);
if (RuleB(Inventory, DeleteTransformationMold))
user->DeleteItemInInventory(in_combine->container_slot, 0, true);
}
else if (inst) {
user->Message_StringID(4, TRANSFORM_FAILED, inst->GetItem()->Name);
}
EQApplicationPacket* outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
return;
}
if (container->GetItem() && container->GetItem()->BagType == BagTypeDetransformationmold) {
const ItemInst* inst = container->GetItem(0);
if (inst && inst->GetOrnamentationIcon() && inst->GetOrnamentationIcon()) {
const Item_Struct* new_weapon = inst->GetItem();
user->DeleteItemInInventory(Inventory::CalcSlotId(in_combine->container_slot, 0), 0, true);
container->Clear();
user->SummonItem(new_weapon->ID, inst->GetCharges(), inst->GetAugmentItemID(0), inst->GetAugmentItemID(1), inst->GetAugmentItemID(2), inst->GetAugmentItemID(3), inst->GetAugmentItemID(4), inst->GetAugmentItemID(5), inst->IsAttuned(), MainCursor, 0, 0);
user->Message_StringID(4, TRANSFORM_COMPLETE, inst->GetItem()->Name);
}
else if (inst) {
user->Message_StringID(4, DETRANSFORM_FAILED, inst->GetItem()->Name);
}
EQApplicationPacket* outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
return;
}
DBTradeskillRecipe_Struct spec;
if (!database.GetTradeRecipe(container, c_type, some_id, user->CharacterID(), &spec)) {
user->Message_StringID(MT_Emote,TRADESKILL_NOCOMBINE);
EQApplicationPacket* outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
return;
}
// Character hasn't learnt the recipe yet.
// must_learn:
// bit 1 (0x01): recipe can't be experimented
// bit 2 (0x02): can try to experiment but not useable for auto-combine until learnt
// bit 5 (0x10): no learn message, use unlisted flag to prevent it showing up on search
// bit 6 (0x20): unlisted recipe flag
if ((spec.must_learn&0xF) == 1 && !spec.has_learnt) {
// Made up message for the client. Just giving a DNC is the other option.
user->Message(4, "You need to learn how to combine these first.");
EQApplicationPacket* outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
//.........这里部分代码省略.........