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"); } }
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()); }
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(); } }
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; } } } } }
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()); } }
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."); } }
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); } }
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()); } }
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."); } }
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."); } }
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); }
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."); } }
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); }
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; } } }
string Item::getPluralTheName(int count) const { if (count > 1) return toString(count) + " " + getTheName(true); else return getTheName(false); }