/** * Attack the monster at the given location * * We get blows until energy drops below that required for another blow, or * until the target monster dies. Each blow is handled by py_attack_real(). * We don't allow @ to spend more than 100 energy in one go, to avoid slower * monsters getting double moves. */ void py_attack(int y, int x) { int blow_energy = 100 * z_info->move_energy / player->state.num_blows; int blows = 0; bool fear = FALSE; struct monster *mon = square_monster(cave, y, x); /* disturb the player */ disturb(player, 0); /* Initialize the energy used */ player->upkeep->energy_use = 0; /* Attack until energy runs out or enemy dies. We limit energy use to 100 * to avoid giving monsters a possible double move. */ while (player->energy >= blow_energy * (blows + 1)) { bool stop = py_attack_real(y, x, &fear); player->upkeep->energy_use += blow_energy; if (player->upkeep->energy_use + blow_energy > z_info->move_energy || stop) break; blows++; } /* Hack - delay fear messages */ if (fear && mflag_has(mon->mflag, MFLAG_VISIBLE)) { char m_name[80]; /* Don't set monster_desc flags, since add_monster_message does string * processing on m_name */ monster_desc(m_name, sizeof(m_name), mon, MDESC_DEFAULT); add_monster_message(m_name, mon, MON_MSG_FLEE_IN_TERROR, TRUE); } }
/** * Attack the monster at the given location * * We get blows until energy drops below that required for another blow, or * until the target monster dies. Each blow is handled by py_attack_real(). * We don't allow @ to spend more than 100 energy in one go, to avoid slower * monsters getting double moves. */ void py_attack(int y, int x) { int blow_energy = 10000 / p_ptr->state.num_blows; int blows = 0; bool fear = FALSE; monster_type *m_ptr = cave_monster(cave, cave->m_idx[y][x]); /* disturb the player */ disturb(p_ptr, 0,0); /* Initialize the energy used */ p_ptr->energy_use = 0; /* Attack until energy runs out or enemy dies. We limit energy use to 100 * to avoid giving monsters a possible double move. */ while (p_ptr->energy >= blow_energy * (blows + 1)) { bool stop = py_attack_real(y, x, &fear); p_ptr->energy_use += blow_energy; if (stop || p_ptr->energy_use + blow_energy > 100) break; blows++; } /* Hack - delay fear messages */ if (fear && m_ptr->ml) { char m_name[80]; monster_desc(m_name, sizeof(m_name), m_ptr, 0); add_monster_message(m_name, cave->m_idx[y][x], MON_MSG_FLEE_IN_TERROR, TRUE); } }
void py_attack(int y, int x) { int blow_energy; bool stop = FALSE; int blows = 0; /* disturb the player */ disturb(0,0); /* calculate energy per blow */ blow_energy = 10000 / p_ptr->state.num_blow; /* * set energy use to zero, overriding whatever was set before we * got here */ p_ptr->energy_use = 0; /* * take blows until energy runs out or monster dies - * note that we limit energy use to 100, even if an extra blow would * be possible, to avoid monster double moves */ while ((p_ptr->energy >= (blow_energy * (blows + 1))) && !stop) { stop = py_attack_real(y, x); p_ptr->energy_use += blow_energy; if ((p_ptr->energy_use + blow_energy) > 100) stop = TRUE; blows++; } }