Item::Item(const uint16_t _type, uint16_t _count /*= 0*/) { parent = NULL; useCount = 0; id = _type; attributes = NULL; const ItemType& it = items[id]; setItemCount(1); if (it.isFluidContainer() || it.isSplash()) { setFluidType(_count); } else if (it.stackable) { if (_count != 0) { setItemCount(_count); } else if (it.charges != 0) { setItemCount(it.charges); } } else if (it.charges != 0) { if (_count != 0) { setCharges(_count); } else { setCharges(it.charges); } } loadedFromMap = false; setDefaultDuration(); }
Item::Item(const uint16_t _type, uint16_t _count /*= 0*/) : ItemAttributes() { id = _type; const ItemType& it = items[id]; setItemCount(1); if(it.isFluidContainer() || it.isSplash()){ setFluidType(_count); } else if(it.stackable){ if(_count != 0){ setItemCount(_count); } else if(it.charges != 0){ setItemCount(it.charges); } } else if(it.charges != 0){ //if count is higher than 1, override default charges if(_count > 1){ setCharges(_count); } else{ setCharges(it.charges); } } setDefaultDuration(); }
void MenuActionBar::logic() { tablist.logic(); // hero has no powers if (pc->power_cast_ticks.empty()) return; for (unsigned i = 0; i < slots_count; i++) { if (!slots[i]) continue; if (hotkeys[i] > 0 && static_cast<unsigned>(hotkeys_mod[i]) < powers->powers.size()) { const Power &power = powers->powers[hotkeys_mod[i]]; int item_id = power.requires_item; int equipped_item_id = power.requires_equipped_item; if (equipped_item_id > 0) { // if a non-consumable item power is unequipped, disable that slot if (!menu->inv->inventory[EQUIPMENT].contain(equipped_item_id)) { setItemCount(i, 0, true); } else { setItemCount(i, 1, true); } } else if (item_id > 0) { setItemCount(i, menu->inv->inventory[CARRIED].count(item_id)); } else { setItemCount(i, -1); } //see if the slot should be greyed out slot_enabled[i] = (pc->hero_cooldown[hotkeys_mod[i]] == 0) && (pc->power_cast_ticks[hotkeys_mod[i]] == 0) && (slot_item_count[i] == -1 || (slot_item_count[i] > 0 && power.requires_item_quantity <= slot_item_count[i])) && pc->stats.canUsePower(power, hotkeys_mod[i]) && (twostep_slot == -1 || static_cast<unsigned>(twostep_slot) == i); slots[i]->setIcon(power.icon); } else { slot_enabled[i] = true; } if (pc->power_cast_ticks[hotkeys_mod[i]] > 0 && pc->power_cast_duration[hotkeys_mod[i]] > 0) { slot_cooldown_size[i] = (ICON_SIZE * pc->power_cast_ticks[hotkeys_mod[i]]) / pc->power_cast_duration[hotkeys_mod[i]]; } else if (pc->hero_cooldown[hotkeys_mod[i]] > 0 && powers->powers[hotkeys_mod[i]].cooldown > 0) { slot_cooldown_size[i] = (ICON_SIZE * pc->hero_cooldown[hotkeys_mod[i]]) / powers->powers[hotkeys_mod[i]].cooldown; } else { slot_cooldown_size[i] = (slot_enabled[i] ? 0 : ICON_SIZE);; } } }
void Burglar::afterEnter(Creature* creature) { if (creature->getType() == CreatureType::CHIP) { auto inventory = _level->getInventory(); inventory->setItemCount(TileType::BOOTS_FIRE, 0); inventory->setItemCount(TileType::BOOTS_SLIDE, 0); inventory->setItemCount(TileType::BOOTS_WATER, 0); inventory->setItemCount(TileType::BOOTS_ICE, 0); } }
void Item::setSubType(uint16_t n) { const ItemType& it = items[id]; if (it.isFluidContainer() || it.isSplash()) { setFluidType(n); } else if (it.stackable) { setItemCount(n); } else if (it.charges != 0) { setCharges(n); } else { setItemCount(n); } }
void Item::setDefaultSubtype() { const ItemType& it = items[id]; setItemCount(1); if (it.charges != 0) { if (it.stackable) { setItemCount(it.charges); } else { setCharges(it.charges); } } }
void Item::setDefaultSubtype() { setItemCount(1); const ItemType& it = items[id]; if(it.charges) setCharges(it.charges); }
Packet::Packet(const QSqlRecord &record, QObject *parent) : QObject(parent) { // md5hash, datetime, idbegin, item_count, jsondata, status setMd5hash(record.value(0)); setDateTime(record.value(1)); setIdBegin(record.value(2)); setItemCount(record.value(3)); setJsonData(record.value(4)); setStatus(record.value(5)); }
Item::Item(const uint16_t type, uint16_t amount/* = 0*/): ItemAttributes(), id(type) { raid = NULL; loadedFromMap = false; setItemCount(1); setDefaultDuration(); const ItemType& it = items[id]; if(it.isFluidContainer() || it.isSplash()) setFluidType(amount); else if(it.stackable) { if(amount || it.charges) setItemCount(amount ? amount : it.charges); } else if(it.charges) setCharges(amount ? amount : it.charges); }
Item::Item(const uint16_t type, uint16_t amount/* = 0*/): ItemAttributes(), id(type) { count = 1; raid = NULL; loadedFromMap = false; setItemCount(1); setDefaultDuration(); const ItemType& it = items[type]; if(it.isFluidContainer() || it.isSplash()) setFluidType(amount); else if(it.stackable) { if(amount) count = setItemCount(amount); else if(it.charges) setItemCount(it.charges); } else if(it.charges) setCharges(amount ? amount : it.charges); if(it.armorRndMin > -1 && it.armorRndMax > it.armorRndMin) setAttribute("armor", it.armorRndMin + rand() % (it.armorRndMax+1 - it.armorRndMin)); if(it.defenseRndMin > -1 && it.defenseRndMax > it.defenseRndMin) setAttribute("defense", it.defenseRndMin + rand() % (it.defenseRndMax+1 - it.defenseRndMin)); if(it.extraDefenseRndMin > -1 && it.extraDefenseRndMax > it.extraDefenseRndMin) if(it.extraDefenseChance == -1 || (it.extraDefenseChance >= rand() % 101) ) setAttribute("extradefense", it.extraDefenseRndMin + rand() % (it.extraDefenseRndMax+1 - it.extraDefenseRndMin)); if(it.attackRndMin > -1 && it.attackRndMax > it.attackRndMin) setAttribute("attack", it.attackRndMin + rand() % (it.attackRndMax - it.attackRndMin)); if(it.extraAttackRndMin > -1 && it.extraAttackRndMax > it.extraAttackRndMin) if(it.extraAttackChance == -1 || (it.extraAttackChance >= rand() % 101) ) setAttribute("extraattack", it.extraAttackRndMin + rand() % (it.extraAttackRndMax+1 - it.extraAttackRndMin)); if(it.chargesRndMin > -1 && it.chargesRndMax > it.chargesRndMin) setAttribute("charges", it.chargesRndMin + rand() % (it.chargesRndMax+1 - it.chargesRndMin)); if(it.attackSpeedRndMin > -1 && it.attackSpeedRndMax > it.attackSpeedRndMin) if(it.attackSpeedChance == -1 || (it.attackSpeedChance >= rand() % 101) ) setAttribute("attackSpeed", it.attackSpeedRndMin + rand() % (it.attackSpeedRndMax+1 - it.attackSpeedRndMin) ); }
void ItemIndexWidget::initGraph() { static QSize sIconSize(64, 64); std::string iconPath = GameDirecotry::ItemDirectory + _gameItem.icon(); setIcon(QString::fromStdString(iconPath), sIconSize); setItemName(QString::fromStdString(_gameItem.name().c_str())); setItemDescription(QString::fromStdString(_gameItem.description().c_str())); setItemTypename(QString::fromStdString(_gameItem.typeName().c_str())); setItemCount(_gameItem.count()); _ui->btnEmploy->setEnabled(_gameItem.flags() & ItemFlag::Item_CanUse); _ui->btnEmploy->setText(QString::fromStdString(ItemHelper::Employ::toEmployName(_gameItem.type()))); }
void UIItem::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode) { UIWidget::onStyleApply(styleName, styleNode); for(const OTMLNodePtr& node : styleNode->children()) { if(node->tag() == "item-id") setItemId(node->value<int>()); else if(node->tag() == "item-count") setItemCount(node->value<int>()); else if(node->tag() == "item-visible") setItemVisible(node->value<bool>()); else if(node->tag() == "virtual") setVirtual(node->value<bool>()); else if(node->tag() == "show-id") m_showId = node->value<bool>(); } }
void Inventory::addItem(TileType itemType, int count) { setItemCount(itemType, getItemCount(itemType) + count); }