コード例 #1
0
ファイル: item.cpp プロジェクト: Knochenschaeler/keeperrl
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);
  }
}
コード例 #2
0
ファイル: item.cpp プロジェクト: miki151/keeperrl
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);
}
コード例 #3
0
ファイル: item.cpp プロジェクト: gustavsen/keeperrl
string Item::getPluralTheNameAndVerb(int count, const string& verbSingle, const string& verbPlural) const {
  return getPluralTheName(count) + " " + (count > 1 ? verbPlural : verbSingle);
}