Ejemplo n.º 1
0
void Attacker::attack(Actor *attacker, Actor *target) {

   float calcDamage = 0;
   float damageTaken = 0;
   float weaponPower = 0;
   Attacker *att = attacker->getAttacker();
   Destructible *dest = target->getDestructible();
   ostringstream attack_msg;
   attack_msg << attacker->getName() << " attacks!";

   if (attacker->getEquipment())
      weaponPower = attacker->getEquipment()->getWeaponStr();
   calcDamage = att->getPower() + weaponPower;

   // make sure target is destructible and alive
   if (target->getDestructible() && !target->getDestructible()->isDead()) {
      if ( (damageTaken = dest->takeDamage(target, calcDamage)) ) {
         attack_msg << " It does " << damageTaken << " points of damage.";
         engine.getGUI()->message(attack_msg.str(), TCODColor::darkerRed);
      } else {
         attack_msg << " It misses.";
         engine.getGUI()->message(attack_msg.str(), TCODColor::white);
      }
   }
}
Ejemplo n.º 2
0
void PlayerAttacker::attack(Actor *attacker, Actor *target) {
   float calcDamage = 0;
   float damageTaken = 0;
   float weaponPower = 0;
   Attacker *att = attacker->getAttacker();
   Destructible *dest = target->getDestructible();
   ostringstream attack_msg;
   attack_msg << "You attack the " << target->getName();

   if (attacker->getEquipment())
      weaponPower = attacker->getEquipment()->getWeaponStr();
   calcDamage = att->getPower() + weaponPower;

   if (target->getDestructible() && !target->getDestructible()->isDead()) {
      if ( (damageTaken = dest->takeDamage(target, calcDamage)) ) {
         attack_msg << " for " << damageTaken << " points of damage.";
      } else {
         attack_msg << ". You miss.";
      }
   }
   engine.getGUI()->message(attack_msg.str(), TCODColor::white);

   // did we kill it?
   if (target->isDead()) {
      attacker->addExp(target->getDestructible()->getExp());
   }
}
Ejemplo n.º 3
0
Destructible *Destructible::create(TCODZip &zip) {
	DestructibleType type = (DestructibleType)zip.getInt();
	Destructible *destructible = NULL;
	switch(type) {
		case MONSTER : destructible = new MonsterDestructible(0,0,NULL,0); break;
		case PLAYER : destructible = new PlayerDestructible(0,0,NULL); break;
	}
	destructible->load(zip);
	return destructible;
}
Ejemplo n.º 4
0
/**
 * @brief This function is called when a destructible item detects a non-pixel precise collision with this entity.
 * @param destructible the destructible item
 * @param collision_mode the collision mode that detected the event
 */
void Hookshot::notify_collision_with_destructible(Destructible& destructible, CollisionMode collision_mode) {

  if (destructible.is_obstacle_for(*this) && is_flying()) {

    if (destructible.can_explode()) {
      destructible.explode();
      go_back();
    }
    else {
      attach_to(destructible);
    }
  }
}
Ejemplo n.º 5
0
/**
 * \brief This function is called when a destructible item detects a non-pixel perfect collision with this entity.
 * \param destructible the destructible item
 * \param collision_mode the collision mode that detected the event
 */
void Arrow::notify_collision_with_destructible(
    Destructible& destructible, CollisionMode collision_mode) {

  if (destructible.is_obstacle_for(*this) && is_flying()) {

    if (destructible.get_can_explode()) {
      destructible.explode();
      remove_from_map();
    }
    else {
      attach_to(destructible);
    }
  }
}
Ejemplo n.º 6
0
/**
 * \copydoc MapEntity::is_destructible_obstacle
 */
bool CustomEntity::is_destructible_obstacle(Destructible& destructible) {

    const TraversableInfo& info = get_can_traverse_entity_info(destructible.get_type());
    if (!info.is_empty()) {
        return !info.is_traversable(*this, destructible);
    }
    return Detector::is_destructible_obstacle(destructible);
}
Ejemplo n.º 7
0
Destructible*
Destructible::Create(TCODZip& zip) {
    destructible_type type = (destructible_type)zip.getInt();
    Destructible* destructible = nullptr;

    switch(type) {
		case DESTRUCTIBLE_TYPE_ORC:
		{
			destructible = new OrcDestructible(0, 0);
		} break;

		case DESTRUCTIBLE_TYPE_PLAYER:
		{
			destructible = new PlayerDestructible(0, 0);
		} break;
	}

    destructible->Load(zip);

    return(destructible);
}