{
bool ring_eff;
int ring_bonus;
- int healing; // = 0;
+ int healing = 0;
if (u.ring != NO_OBJ)
{
ring_eff = ring_effectiveness(mon, objects[u.ring].obj_id, damage, &ring_bonus, &healing);
int tohit;
int range;
Coord c = u.pos + step;
- int done = 0;
+ bool done = false;
int mon;
Mon *mptr;
Obj *wep;
wep = objects + u.weapon;
pwep = permobjs + wep->obj_id;
damage = one_die(pwep->power);
- range = 1;
- for ( ; !done; c += step)
+ for (range = 1; !done; ++range, (c += step))
{
mon = lvl.mon_at(c);
if (mon != NO_MON)
{
- done = 1;
+ done = true;
mptr = monsters + mon;
tohit = zero_die(u.agility + u.level - range);
if (range == 1)
{
/* Shooting at point-blank is tricky */
tohit = (tohit + 1) / 2;
+ notify_point_blank_warning();
}
if (tohit >= mptr->defence)
{
{
/* Monster hit your armour. */
damage_obj(u.armour);
+ notify_mon_hit_armour(mon);
}
else
{
drain_body(1, "snake venom", 0);
}
damage_u(damage, DEATH_KILLED_MON, permons[mptr->mon_id].name);
- display_update();
}
return 1;
}
damage = one_die(mptr->rdam);
damage_u(damage, DEATH_KILLED_MON, permons[mptr->mon_id].name);
}
- display_update();
return 1;
}
else
#include <ncursesw/curses.h>
#include <ncursesw/panel.h>
+#undef DEBUG_TO_STDERR
+//#define DEBUG_TO_STDERR
#define DISP_NC_RADIUS (10)
#define DISP_NC_SIDE (DISP_NC_RADIUS * 2 + 1)
void set_inventory_message(char const *s, bool allow_nil);
j = mbtowc(wch, terrain_props[i].unicode, 4);
if (j != 1)
{
- /// welp. someone didn't see the above warning
}
wch[1] = 0;
setcchar(terrain_tiles + i, wch,
{
wchar_t wch[2];
/* policy decision: for now we don't support use of combining
- * characters for tiles. */
+ * characters for items. */
j = mbtowc(wch, permobjs[i].unicode, 4);
if (j != 1)
{
- /// welp. someone didn't see the above warning
}
wch[1] = 0;
- setcchar(permobj_tiles + i, wch, 0, 0, nullptr);
+ setcchar(permobj_tiles + i, wch,
+ colour_data[permobjs[i].colour].attr,
+ colour_data[permobjs[i].colour].cpair, nullptr);
}
}
wchar_t wch[2];
wch[0] = permobjs[i].sym;
wch[1] = 0;
- setcchar(permobj_tiles + i, wch, 0, 0, nullptr);
+ setcchar(permobj_tiles + i, wch,
+ colour_data[permobjs[i].colour].attr,
+ colour_data[permobjs[i].colour].cpair, nullptr);
}
}
va_start(ap, fmt);
vw_printw(message_window, fmt, ap);
va_end(ap);
+#ifdef DEBUG_TO_STDERR
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+#endif
display_update();
}
vw_printw(message_window, fmt, ap);
wattr_set(message_window, colour_data[Gcol_prio_normal].attr, colour_data[Gcol_prio_normal].cpair, nullptr);
va_end(ap);
+#ifdef DEBUG_TO_STDERR
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+#endif
display_update();
}
}
update_player();
game_tick++;
+ notify_tick();
}
}
}
}
depth++;
- status_updated = 1;
- map_updated = 1;
}
void make_new_level(void)
populate_level();
inject_player();
look_around_you();
- display_update();
+ notify_change_of_depth();
}
typedef int (*rwalk_mod_funcptr)(Coord c, void *data);
}
}
}
- if (created > 0)
- {
- map_updated = 1;
- display_update();
- }
return created;
}
if (amount >= mptr->hpcur)
{
kill_mon(mon, by_you);
- display_update();
}
else
{
return;
}
reloc_mon(mon, c);
- display_update();
}
void summon_demon_near(Coord c)
void notify_player_heal(int amount, int boost, bool loud)
{
- status_updated = 1;
+ status_updated = true;
if (loud)
{
/* Tell the player how much better they feel. */
*/
void notify_level_gain(void)
{
- status_updated = 1;
+ status_updated = true;
print_msg("You gained a level!\n");
}
+/*! \brief The player has gained experience points
+ */
+void notify_exp_gain(int amount)
+{
+ status_updated = true;
+ display_update();
+}
+
/*! \brief The player has gained some Agility
*
* \param Amount of Agility gained
*/
void notify_agility_gain(int amount)
{
- status_updated = 1;
+ status_updated = true;
print_msg("You gained %d Agility.\n", amount);
}
*/
void notify_body_gain(int amount)
{
- status_updated = 1;
+ status_updated = true;
print_msg("You gained %d Body.\n", amount);
}
void notify_hp_gain(int amount)
{
- status_updated = 1;
+ status_updated = true;
print_msg("You gained %d hit points.\n", amount);
}
void notify_body_restore(void)
{
- status_updated = 1;
+ status_updated = true;
print_msg("You feel less feeble.\n");
}
void notify_agility_restore(void)
{
- status_updated = 1;
+ status_updated = true;
print_msg("You feel less clumsy.\n");
}
void notify_agility_drain(int amount)
{
- status_updated = 1;
+ status_updated = true;
print_msg("You feel clumsy!\n");
}
void notify_body_drain(int amount)
{
- status_updated = 1;
+ status_updated = true;
print_msg("You feel weaker!\n");
}
+void notify_defence_recalc(void)
+{
+ status_updated = true;
+ display_update();
+}
+
void notify_player_teleport(void)
{
print_msg("You are whisked away!\n");
void notify_start_armourmelt(void)
{
- status_updated = 1;
+ status_updated = true;
print_msg("Your armour seems suddenly no stronger than dust!\n");
}
void notify_start_leadfoot(void)
{
- status_updated = 1;
+ status_updated = true;
print_msg("Your feet feel like lead!\n");
}
void notify_start_withering(void)
{
- status_updated = 1;
+ status_updated = true;
print_msg("Your limbs twist and wither!\n");
}
print_msg(".\n");
}
+void notify_point_blank_warning(void)
+{
+ print_msg(Msg_prio::Alert, "Using a bow at such close quarters is awkward, and you are unlikely to hit your target.\n");
+}
+
void notify_player_shot_terrain(int obj, Coord c)
{
print_msg("Your %s hits the %s.\n", (objects[obj].obj_id == PO_CROSSBOW) ? "bolt" : "arrow", terrain_props[lvl.terrain_at(c)].name);
void notify_player_damage_taken(int amount)
{
+ status_updated = true;
print_msg("You take %d damage.\n", amount);
}
print_msg(Msg_prio::Alert, "Your pack is full.\n");
}
+/*! \brief Inform client of monster at specified position
+ *
+ * For local tty versions, this is just a call to newsym() and
+ * display_update().
+ *
+ * \param c Affected location
+ * \param mon Monster at that location.
+ */
void notify_new_mon_at(Coord c, int mon)
{
newsym(c);
+ display_update();
}
void notify_fov(void)
{
touch_back_buffer();
+ display_update();
+}
+
+/*! \brief Inform the client that the game tick has advanced.
+ *
+ * For local tty versions, this is done by flushing any pending
+ * display updates.
+ */
+void notify_tick(void)
+{
+ display_update();
+}
+
+void notify_change_of_depth(void)
+{
+ status_updated = true;
+ print_msg("Welcome to level %d of the Abyss.\n", depth);
}
/* Debugging notifications */
void notify_death(Death d, char const *what);
void notify_player_heal(int amount, int boost, bool loud);
void notify_level_gain(void);
+void notify_exp_gain(int amount);
void notify_agility_gain(int amount);
void notify_body_gain(int amount);
void notify_agility_restore(void);
void notify_wither_recovered(void);
void notify_protection_lost(void);
void notify_wasted_gain(void);
+void notify_defence_recalc(void);
// Resistance notifications
void notify_knockback_mon_water_offscreen(void);
void notify_knockback_mon_lava_offscreen(void);
+void notify_point_blank_warning(void);
void notify_player_shot_terrain(int obj, Coord c);
void notify_mon_hit_armour(int mon);
// Miscellaneous notifications
void notify_fov(void);
+void notify_tick(void);
+void notify_change_of_depth(void);
// Debugging notifications
void debug_move_oob(Coord c);
break;
case PO_RESTORATION_POTION:
notify_quaff_potion_restoration();
- status_updated = 1;
if (u.bdam && ((!u.adam) || zero_die(2)))
{
u.bdam = 0;
break;
}
}
- status_updated = 1;
- display_update();
+ notify_defence_recalc();
}
Action_cost move_player(Offset delta)
u.pos = c;
touch_one_screen(oc);
look_around_you();
- map_updated = 1;
- status_updated = 1;
- display_update();
if (lvl.obj_at(c) != NO_OBJ)
{
notify_obj_at(c);
amount = 99 - u.body;
}
u.body += amount;
- status_updated = 1;
notify_body_gain(amount);
return amount;
}
{
return do_death(DEATH_BODY, what);
}
- display_update();
return 0;
}
amount = 99 - u.agility;
}
u.agility += amount;
- status_updated = 1;
recalc_defence();
notify_agility_gain(amount);
return amount;
int damage_u(int amount, Death d, char const *what)
{
u.hpcur -= amount;
- status_updated = 1;
notify_player_damage_taken(amount);
if (u.hpcur < 0)
{
u.adam = 0;
u.bdam = 0;
recalc_defence();
- status_updated = 1;
- display_update();
}
else
{
int bodygain;
int agilgain;
u.experience += amount;
- status_updated = 1;
+ notify_exp_gain(amount);
if (u.experience > lev_threshold(u.level))
{
u.level++;
notify_hp_gain(hpgain);
}
}
- else
- {
- display_update();
- }
}
Pass_fail teleport_u(void)
squeal = 2;
}
u.food -= food_use;
- status_updated = 1;
notify_hunger_level(squeal);
}
if (u.leadfoot > 0)
notify_protection_lost();
}
}
- display_update();
}
bool Player::resists(Damtyp dtype) const