コード例 #1
0
ファイル: entity.cpp プロジェクト: Aelig/Cataclysm2
Attack Entity::std_attack()
{
  Attack att = base_attack();
  if (weapon.is_real()) {
    att.use_weapon(weapon, stats);
  }
  return att;
}
コード例 #2
0
ファイル: monster.cpp プロジェクト: tyrael93/Cataclysm2
void Monster::move_towards(int target_x, int target_y)
{
  Generic_map move_map = GAME.map->get_movement_map(get_intelligence());
  Pathfinder pf(move_map);
// Simple, dumb movement - suitable for zombies at least
  Point move;
  Point to(target_x, target_y), from = get_position();
  switch (get_intelligence()) {
    case INTEL_NULL:
    case INTEL_PLANT:
// Mobile plants just drunken walk.
      move.x = rng(posx - 1, posx + 1);
      move.y = rng(posy - 1, posy + 1);
      break;

    case INTEL_ZOMBIE:
      move = pf.get_step(PATH_LINE, from, to);
      break;

    case INTEL_ANIMAL:
    case INTEL_HUMAN:
      move = pf.get_step(PATH_A_STAR, from, to);
      break;

    default:
      debugmsg("No AI movement coded for Intel_level %s",
               intel_level_name(get_intelligence()).c_str());
  }

// TODO:  Add a "Stumble" flag that occasionally randomly picks, rather than
//        picking the best available.

  if (can_move_to( GAME.map, move.x, move.y )) {
    move_to( GAME.map, move.x, move.y );
// TODO: Add a "smashes terrain" flag, and if we can't move then smash
  } else if (GAME.map->is_smashable(move.x, move.y)) {
    std::string sound = GAME.map->smash(move.x, move.y, 
                                        base_attack().roll_damage());
    GAME.make_sound(sound, move.x, move.y);
    use_ap(100);
  } else {
    pause();
  }
}