Grappling location feedback

This commit is contained in:
Pasi Kallinen
2022-07-28 13:50:57 +03:00
parent 0517974b6d
commit bae221d0c3

View File

@@ -34,6 +34,8 @@ static void display_polearm_positions(int);
static int use_cream_pie(struct obj *); static int use_cream_pie(struct obj *);
static int jelly_ok(struct obj *); static int jelly_ok(struct obj *);
static int use_royal_jelly(struct obj *); static int use_royal_jelly(struct obj *);
static int grapple_range(void);
static boolean can_grapple_location(coordxy, coordxy);
static int use_grapple(struct obj *); static int use_grapple(struct obj *);
static int do_break_wand(struct obj *); static int do_break_wand(struct obj *);
static int apply_ok(struct obj *); static int apply_ok(struct obj *);
@@ -3470,10 +3472,31 @@ use_royal_jelly(struct obj *obj)
return ECMD_TIME; return ECMD_TIME;
} }
static int
grapple_range(void)
{
int typ = uwep_skill_type();
int max_range = 4;
if (typ == P_NONE || P_SKILL(typ) <= P_BASIC)
max_range = 4;
else if (P_SKILL(typ) == P_SKILLED)
max_range = 5;
else
max_range = 8;
return max_range;
}
static boolean
can_grapple_location(coordxy x, coordxy y)
{
return (isok(x, y) && cansee(x, y) && distu(x, y) <= grapple_range());
}
static int static int
use_grapple(struct obj *obj) use_grapple(struct obj *obj)
{ {
int res = ECMD_OK, typ, max_range = 4, tohit; int res = ECMD_OK, typ, tohit;
boolean save_confirm; boolean save_confirm;
coord cc; coord cc;
struct monst *mtmp; struct monst *mtmp;
@@ -3498,18 +3521,13 @@ use_grapple(struct obj *obj)
pline(where_to_hit); pline(where_to_hit);
cc.x = u.ux; cc.x = u.ux;
cc.y = u.uy; cc.y = u.uy;
getpos_sethilite(NULL, can_grapple_location);
if (getpos(&cc, TRUE, "the spot to hit") < 0) if (getpos(&cc, TRUE, "the spot to hit") < 0)
return (res|ECMD_CANCEL); /* ESC; uses turn iff grapnel became wielded */ return (res|ECMD_CANCEL); /* ESC; uses turn iff grapnel became wielded */
/* Calculate range; unlike use_pole(), there's no minimum for range */ /* Calculate range; unlike use_pole(), there's no minimum for range */
typ = uwep_skill_type(); typ = uwep_skill_type();
if (typ == P_NONE || P_SKILL(typ) <= P_BASIC) if (distu(cc.x, cc.y) > grapple_range()) {
max_range = 4;
else if (P_SKILL(typ) == P_SKILLED)
max_range = 5;
else
max_range = 8;
if (distu(cc.x, cc.y) > max_range) {
pline("Too far!"); pline("Too far!");
return res; return res;
} else if (!cansee(cc.x, cc.y)) { } else if (!cansee(cc.x, cc.y)) {