예제 #1
0
 virtual void specialTick(double time, Position position) override {
   Creature* owner = position.getCreature();
   if (owner && owner->getEquipment().isEquiped(this)) {
     bool isDanger = false;
     bool isBigDanger = false;
     for (Position v : position.getRectangle(Rectangle(-radius, -radius, radius + 1, radius + 1))) {
       for (Trigger* t : v.getTriggers())
         if (t->isDangerous(owner)) {
           if (v.dist8(position) <= 1)
             isBigDanger = true;
           else
             isDanger = true;
         }
       if (Creature* c = v.getCreature()) {
         if (!owner->canSee(c) && c->isEnemy(owner)) {
           int diff = c->getModifier(ModifierType::DAMAGE) - owner->getModifier(ModifierType::DAMAGE);
           if (diff > 5)
             isBigDanger = true;
           else
             if (diff > 0)
               isDanger = true;
         }
       }
     }
     if (isBigDanger)
       owner->playerMessage(getTheName() + " vibrates vigorously");
     else
     if (isDanger)
       owner->playerMessage(getTheName() + " vibrates");
   }
 }
예제 #2
0
void Item::onHitSquareMessage(Vec2 position, Square* s, bool plural) {
    if (fragile) {
        s->getConstLevel()->globalMessage(position,
                                          getTheName(plural) + chooseElem<string>({" crashes", " crash"}, int(plural)) + " on the " + s->getName(),
                                          "You hear a crash");
        discarded = true;
    } else
        s->getConstLevel()->globalMessage(position, getTheName(plural) +
                                          chooseElem<string>({" hits", " hit"}, int(plural)) + " the " + s->getName());
}
예제 #3
0
void Item::onHitCreature(Creature* c, const Attack& attack, bool plural) {
    if (fragile) {
        c->you(plural ? MsgType::ITEM_CRASHES_PLURAL : MsgType::ITEM_CRASHES, getTheName(plural));
        discarded = true;
    } else
        c->you(plural ? MsgType::HIT_THROWN_ITEM_PLURAL : MsgType::HIT_THROWN_ITEM, getTheName(plural));
    if (c->takeDamage(attack))
        return;
    if (effect && getType() == ItemType::POTION) {
        Effect::applyToCreature(c, *effect, EffectStrength::NORMAL);
        if (c->getLevel()->playerCanSee(c->getPosition()))
            identify();
    }
}
예제 #4
0
 virtual void specialTick(double time, Position position) override {
   if (rottenTime == -1)
     rottenTime = time + rottingTime;
   if (time >= rottenTime && !rotten) {
     setName(rottenName);
     setViewObject(object2);
     corpseInfo.isSkeleton = true;
   } else {
     if (!rotten && getWeight() > 10 && Random.roll(20 + (rottenTime - time) / 10))
       Effect::applyToPosition(position, EffectId::EMIT_POISON_GAS, EffectStrength::WEAK);
     if (getWeight() > 10 && !corpseInfo.isSkeleton && 
         !position.getCoverInfo().covered && Random.roll(35)) {
       for (Position v : position.neighbors8(Random)) {
         PCreature vulture = CreatureFactory::fromId(CreatureId::VULTURE,
             position.getModel()->getPestTribe(), MonsterAIFactory::scavengerBird(v));
         if (v.canEnter(vulture.get())) {
           v.addCreature(std::move(vulture));
           v.globalMessage("A vulture lands near " + getTheName());
           rottenTime -= 40;
           break;
         }
       }
     }
   }
 }
예제 #5
0
파일: item.cpp 프로젝트: gustavsen/keeperrl
void Item::setOnFire(double amount, Position position) {
  bool burning = fire->isBurning();
  string noBurningName = getTheName();
  fire->set(amount);
  if (!burning && fire->isBurning()) {
    position.globalMessage(noBurningName + " catches fire");
    modViewObject().setAttribute(ViewObject::Attribute::BURNING, fire->getSize());
  }
}
예제 #6
0
 virtual void applySpecial(Creature* c) override {
   Item* it = c->getWeapon();
   if (it && it->getAttackType() == AttackType::CUT) {
     c->you(MsgType::DECAPITATE, getTheName());
     setName("decapitated " + getName());
   } else {
     c->playerMessage("You need something sharp to decapitate the corpse.");
   }
 }
예제 #7
0
파일: item.cpp 프로젝트: miki151/keeperrl
void Item::fireDamage(Position position) {
  bool burning = fire->isBurning();
  string noBurningName = getTheName();
  fire->set();
  if (!burning && fire->isBurning()) {
    position.globalMessage(noBurningName + " catches fire");
    modViewObject().setModifier(ViewObject::Modifier::BURNING);
  }
}
예제 #8
0
void Item::setOnFire(double amount, const Level* level, Vec2 position) {
    bool burning = fire.isBurning();
    string noBurningName = getTheName();
    fire.set(amount);
    if (!burning && fire.isBurning()) {
        level->globalMessage(position, noBurningName + " catches fire.");
        viewObject.setBurning(fire.getSize());
    }
}
예제 #9
0
파일: item.cpp 프로젝트: gustavsen/keeperrl
void Item::applySpecial(Creature* c) {
  if (attributes->itemClass == ItemClass::SCROLL)
    c->getModel()->getStatistics().add(StatId::SCROLL_READ);
  if (attributes->effect)
    Effect::applyToCreature(c, *attributes->effect, EffectStrength::NORMAL);
  if (attributes->uses > -1 && --attributes->uses == 0) {
    discarded = true;
    if (attributes->usedUpMsg)
      c->playerMessage(getTheName() + " is used up.");
  }
}
예제 #10
0
파일: item.cpp 프로젝트: miki151/keeperrl
void Item::applySpecial(Creature* c) {
  if (attributes->itemClass == ItemClass::SCROLL)
    c->getGame()->getStatistics().add(StatId::SCROLL_READ);
  if (attributes->effect)
    attributes->effect->apply(c->getPosition(), c);
  if (attributes->uses > -1 && --attributes->uses == 0) {
    discarded = true;
    if (attributes->usedUpMsg)
      c->privateMessage(getTheName() + " is used up.");
  }
}
예제 #11
0
파일: item.cpp 프로젝트: gustavsen/keeperrl
void Item::tick(double time, Position position) {
  if (fire->isBurning()) {
    Debug() << getName() << " burning " << fire->getSize();
    position.setOnFire(fire->getSize());
    modViewObject().setAttribute(ViewObject::Attribute::BURNING, fire->getSize());
    fire->tick();
    if (!fire->isBurning()) {
      position.globalMessage(getTheName() + " burns out");
      discarded = true;
    }
  }
  specialTick(time, position);
}
예제 #12
0
void Item::apply(Creature* c, Level* l) {
    if (type == ItemType::SCROLL)
        Statistics::add(StatId::SCROLL_READ);
    if (identifyOnApply && l->playerCanSee(c->getPosition()))
        identify(*name);
    if (effect)
        Effect::applyToCreature(c, *effect, EffectStrength::NORMAL);
    if (uses > -1 && --uses == 0) {
        discarded = true;
        if (usedUpMsg)
            c->privateMessage(getTheName() + " is used up.");
    }
}
예제 #13
0
void Item::tick(double time, Level* level, Vec2 position) {
    if (fire.isBurning()) {
        Debug() << getName() << " burning " << fire.getSize();
        level->getSquare(position)->setOnFire(fire.getSize());
        viewObject.setBurning(fire.getSize());
        fire.tick(level, position);
        if (!fire.isBurning()) {
            level->globalMessage(position, getTheName() + " burns out");
            discarded = true;
        }
    }
    specialTick(time, level, position);
}
예제 #14
0
파일: item.cpp 프로젝트: miki151/keeperrl
void Item::tick(Position position) {
  PROFILE_BLOCK("Item::tick");
  if (fire->isBurning()) {
    INFO << getName() << " burning ";
    position.fireDamage(0.2);
    modViewObject().setModifier(ViewObject::Modifier::BURNING);
    fire->tick();
    if (!fire->isBurning()) {
      position.globalMessage(getTheName() + " burns out");
      discarded = true;
    }
  }
  specialTick(position);
  if (timeout) {
    if (position.getGame()->getGlobalTime() >= *timeout) {
      discarded = true;
    }
  }
}
예제 #15
0
파일: item.cpp 프로젝트: gustavsen/keeperrl
string Item::getPluralTheName(int count) const {
  if (count > 1)
    return toString(count) + " " + getTheName(true);
  else
    return getTheName(false);
}