void Item::onHitCreature(Creature* c, const Attack& attack, int numItems) { if (attributes->fragile) { c->you(attributes->plural ? MsgType::ITEM_CRASHES_PLURAL : MsgType::ITEM_CRASHES, getPluralTheName(numItems)); discarded = true; } else c->you(attributes->plural ? MsgType::HIT_THROWN_ITEM_PLURAL : MsgType::HIT_THROWN_ITEM, getPluralTheName(numItems)); if (c->takeDamage(attack)) return; if (attributes->effect && getClass() == ItemClass::POTION) { Effect::applyToCreature(c, *attributes->effect, EffectStrength::NORMAL); } }
void Item::onHitCreature(Creature* c, const Attack& attack, int numItems) { if (attributes->fragile) { c->you(numItems > 1 ? MsgType::ITEM_CRASHES_PLURAL : MsgType::ITEM_CRASHES, getPluralTheName(numItems)); discarded = true; } else c->you(numItems > 1 ? MsgType::HIT_THROWN_ITEM_PLURAL : MsgType::HIT_THROWN_ITEM, getPluralTheName(numItems)); if (attributes->effect && getClass() == ItemClass::POTION) attributes->effect->apply(c->getPosition(), attack.attacker); c->takeDamage(attack); if (!c->isDead() && attributes->ownedEffect == LastingEffect::LIGHT_SOURCE) c->affectByFire(1); }
string Item::getPluralTheNameAndVerb(int count, const string& verbSingle, const string& verbPlural) const { return getPluralTheName(count) + " " + (count > 1 ? verbPlural : verbSingle); }