C++ (Cpp) Item Examples

C++ (Cpp) Item - 30 examples found. These are the top rated real world C++ (Cpp) examples of Item extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
void Player::UpdateArmorPenetration()
{
    m_armorPenetrationPct = GetRatingBonusValue(CR_ARMOR_PENETRATION);

    AuraList const& armorAuras = GetAurasByType(SPELL_AURA_MOD_TARGET_ARMOR_PCT);
    for(AuraList::const_iterator itr = armorAuras.begin(); itr != armorAuras.end(); ++itr)
    {
        // affects all weapons
        if((*itr)->GetSpellProto()->EquippedItemClass == -1)
        {
            m_armorPenetrationPct += (*itr)->GetModifier()->m_amount;
            continue;
        }

        // dependent on weapon class
        for(uint8 i = 0; i < MAX_ATTACK; ++i)
        {
            Item *weapon = GetWeaponForAttack(WeaponAttackType(i));
            if(weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellProto()))
            {
                m_armorPenetrationPct += (*itr)->GetModifier()->m_amount;
                break;
            }
        }
    }
}
Example #2
0
void Player::UpdateExpertise(WeaponAttackType attack)
{
    if (attack == RANGED_ATTACK)
        return;

    int32 expertise = int32(GetRatingBonusValue(CR_EXPERTISE));

    Item *weapon = GetWeaponForAttack(attack);

    AuraList const& expAuras = GetAurasByType(SPELL_AURA_MOD_EXPERTISE);
    for (AuraList::const_iterator itr = expAuras.begin(); itr != expAuras.end(); ++itr)
    {
        // item neutral spell
        if ((*itr)->GetSpellProto()->EquippedItemClass == -1)
            expertise += (*itr)->GetModifierValue();
        // item dependent spell
        else if (weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellProto()))
            expertise += (*itr)->GetModifierValue();
    }

    if (expertise < 0)
        expertise = 0;

    switch(attack)
    {
    case BASE_ATTACK:
        SetUInt32Value(PLAYER_EXPERTISE, expertise);
        break;
    case OFF_ATTACK:
        SetUInt32Value(PLAYER_OFFHAND_EXPERTISE, expertise);
        break;
    default:
        break;
    }
}
Example #3
0
void EquipmentWindow::draw(gcn::Graphics *graphics)
{
    // Draw window graphics
    Window::draw(graphics);

    Window::drawChildren(graphics);

    // Draw equipment boxes
    Graphics *g = static_cast<Graphics*>(graphics);

    for (int i = 0; i < mBoxesNumber; i++)
    {
        // When there is a background image, draw it centered in the box:
        if (mEquipBox[i].backgroundImage)
        {
            int posX = mEquipBox[i].posX
                       + (BOX_WIDTH - mEquipBox[i].backgroundImage->getWidth()) / 2;
            int posY = mEquipBox[i].posY
                       + (BOX_HEIGHT - mEquipBox[i].backgroundImage->getHeight()) / 2;
            g->drawImage(mEquipBox[i].backgroundImage, posX, posY);
        }

        if (i == mSelected)
        {
            const gcn::Color color = Theme::getThemeColor(Theme::HIGHLIGHT);

            // Set color to the highlight color
            g->setColor(gcn::Color(color.r, color.g, color.b, getGuiAlpha()));
            g->fillRectangle(gcn::Rectangle(mEquipBox[i].posX,
                                            mEquipBox[i].posY,
                                            BOX_WIDTH, BOX_HEIGHT));
        }

        // Set color black
        g->setColor(gcn::Color(0, 0, 0));
        // Draw box border
        g->drawRectangle(gcn::Rectangle(mEquipBox[i].posX, mEquipBox[i].posY,
                                        BOX_WIDTH, BOX_HEIGHT));

        Item *item = mEquipment->getEquipment(i);
        if (item)
        {
            // Draw Item.
            Image *image = item->getImage();
            // Ensure the image is drawn with maximum opacity
            image->setAlpha(1.0f);
            g->drawImage(image,
                         mEquipBox[i].posX + 2,
                         mEquipBox[i].posY + 2);
            if (i == TmwAthena::EQUIP_PROJECTILE_SLOT)
            {
                g->setColor(Theme::getThemeColor(Theme::TEXT));
                graphics->drawText(toString(item->getQuantity()),
                                   mEquipBox[i].posX + (BOX_WIDTH / 2),
                                   mEquipBox[i].posY - getFont()->getHeight(),
                                   gcn::Graphics::CENTER);
            }
        }
    }
}
Example #4
0
Item::Iterator::Ptr ApplyTemplate::evaluateSequence(const DynamicContext::Ptr &context) const
{
    const TemplateMode::Ptr templateMode(effectiveMode(context));
    const Template::Ptr &templateMatch = findTemplate(context, templateMode);

    if(templateMatch)
        return templateMatch->body->evaluateSequence(templateMatch->createContext(this, context, false));
    else
    {
        /* None of our templates matched. Proceed with a built-in. */
        const Item current(context->contextItem());
        // TODO it can be an atomic value?
        const QXmlNodeModelIndex::NodeKind kind(current.asNode().kind());

        if(kind == QXmlNodeModelIndex::Element || kind == QXmlNodeModelIndex::Document)
        {
            pDebug() << "No template match, using builtin template for element() | document-node()";

            const Item::Iterator::Ptr focusIterator(makeItemMappingIterator<Item>(ConstPtr(this),
                                                    current.asNode().iterate(QXmlNodeModelIndex::AxisChild),
                                                    context));

            const DynamicContext::Ptr focus(context->createFocus());
            focus->setFocusIterator(focusIterator);
            return makeSequenceMappingIterator<Item>(ConstPtr(this), focusIterator, focus);
        }
        return CommonValues::emptyIterator;
    }
}
Example #5
0
void Monster::pushItems(Tile* tile)
{
    TileItemVector* items = tile->getItemList();
    if(!items)
        return;

    //We cannot use iterators here since we can push the item to another tile
    //which will invalidate the iterator.
    //start from the end to minimize the amount of traffic
    int32_t moveCount = 0, removeCount = 0, downItemsSize = tile->getDownItemCount();
    Item* item = NULL;
    for(int32_t i = downItemsSize - 1; i >= 0; --i)
    {
        assert(i >= 0 && i < downItemsSize);
        if((item = items->at(i)) && item->hasProperty(MOVABLE) &&
                (item->hasProperty(BLOCKPATH) || item->hasProperty(BLOCKSOLID)))
        {
            if(moveCount < 20 && pushItem(item, 1))
                moveCount++;
            else if(g_game.internalRemoveItem(this, item) == RET_NOERROR)
                ++removeCount;
        }
    }

    if(removeCount > 0)
        g_game.addMagicEffect(tile->getPosition(), MAGIC_EFFECT_POFF);
}
Example #6
0
void EquipmentWindow::mouseMoved(gcn::MouseEvent &event)
{
    const int x = event.getX();
    const int y = event.getY();

    int mouseX, mouseY;
    SDL_GetMouseState(&mouseX, &mouseY);

    // Show ItemTooltip
    std::string slotName = getSlotName(x, y);
    if (!slotName.empty())
    {
        mItemPopup->setEquipmentText(slotName);

        Item *item = getItem(x, y);
        if (item)
        {
            mItemPopup->setItem(item->getInfo());
        }
        else
            mItemPopup->setNoItem();

        mItemPopup->position(x + getX(), y + getY());
    }
    else
    {
        mItemPopup->setVisible(false);
    }
}