split getting damages with a kick into separate function
This commit is contained in:
117
src/dokick.c
117
src/dokick.c
@@ -20,6 +20,7 @@ static char *kickstr(char *, const char *);
|
||||
static boolean watchman_thief_arrest(struct monst *);
|
||||
static boolean watchman_door_damage(struct monst *, xchar, xchar);
|
||||
static void kick_dumb(int, int);
|
||||
static void kick_ouch(int, int, const char *);
|
||||
static void otransit_msg(struct obj *, boolean, boolean, long);
|
||||
static void drop_to(coord *, schar, xchar, xchar);
|
||||
|
||||
@@ -818,13 +819,40 @@ kick_dumb(int x, int y)
|
||||
hurtle(-u.dx, -u.dy, 1, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
kick_ouch(int x, int y, const char *kickobjnam)
|
||||
{
|
||||
int dmg;
|
||||
char buf[BUFSZ];
|
||||
|
||||
pline("Ouch! That hurts!");
|
||||
exercise(A_DEX, FALSE);
|
||||
exercise(A_STR, FALSE);
|
||||
if (isok(x, y)) {
|
||||
if (Blind)
|
||||
feel_location(x, y); /* we know we hit it */
|
||||
if (is_drawbridge_wall(x, y) >= 0) {
|
||||
pline_The("drawbridge is unaffected.");
|
||||
/* update maploc to refer to the drawbridge */
|
||||
(void) find_drawbridge(&x, &y);
|
||||
g.maploc = &levl[x][y];
|
||||
}
|
||||
}
|
||||
if (!rn2(3))
|
||||
set_wounded_legs(RIGHT_SIDE, 5 + rnd(5));
|
||||
dmg = rnd(ACURR(A_CON) > 15 ? 3 : 5);
|
||||
losehp(Maybe_Half_Phys(dmg), kickstr(buf, kickobjnam), KILLED_BY);
|
||||
if (Is_airlevel(&u.uz) || Levitation)
|
||||
hurtle(-u.dx, -u.dy, rn1(2, 4), TRUE); /* assume it's heavy */
|
||||
}
|
||||
|
||||
/* the #kick command */
|
||||
int
|
||||
dokick(void)
|
||||
{
|
||||
int x, y;
|
||||
int avrg_attrib;
|
||||
int dmg = 0, glyph, oldglyph = -1;
|
||||
int glyph, oldglyph = -1;
|
||||
register struct monst *mtmp;
|
||||
boolean no_kick = FALSE;
|
||||
char buf[BUFSZ], kickobjnam[BUFSZ];
|
||||
@@ -948,7 +976,8 @@ dokick(void)
|
||||
|
||||
if (!isok(x, y)) {
|
||||
g.maploc = &g.nowhere;
|
||||
goto ouch;
|
||||
kick_ouch(x, y, kickobjnam);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
g.maploc = &levl[x][y];
|
||||
|
||||
@@ -1016,7 +1045,8 @@ dokick(void)
|
||||
hurtle(-u.dx, -u.dy, 1, TRUE); /* assume it's light */
|
||||
return ECMD_TIME;
|
||||
}
|
||||
goto ouch;
|
||||
kick_ouch(x, y, kickobjnam);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
|
||||
if (!IS_DOOR(g.maploc->typ)) {
|
||||
@@ -1041,8 +1071,10 @@ dokick(void)
|
||||
|| g.maploc->doormask == D_NODOOR)
|
||||
unblock_point(x, y); /* vision */
|
||||
return ECMD_TIME;
|
||||
} else
|
||||
goto ouch;
|
||||
} else {
|
||||
kick_ouch(x, y, kickobjnam);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
}
|
||||
if (g.maploc->typ == SCORR) {
|
||||
if (!Levitation && rn2(30) < avrg_attrib) {
|
||||
@@ -1052,8 +1084,10 @@ dokick(void)
|
||||
feel_newsym(x, y); /* we know it's gone */
|
||||
unblock_point(x, y); /* vision */
|
||||
return ECMD_TIME;
|
||||
} else
|
||||
goto ouch;
|
||||
} else {
|
||||
kick_ouch(x, y, kickobjnam);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
}
|
||||
if (IS_THRONE(g.maploc->typ)) {
|
||||
register int i;
|
||||
@@ -1095,10 +1129,13 @@ dokick(void)
|
||||
if (dunlev(&u.uz) < dunlevs_in_dungeon(&u.uz)) {
|
||||
fall_through(FALSE, 0);
|
||||
return ECMD_TIME;
|
||||
} else
|
||||
goto ouch;
|
||||
} else {
|
||||
kick_ouch(x, y, kickobjnam);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
}
|
||||
goto ouch;
|
||||
kick_ouch(x, y, kickobjnam);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
if (IS_ALTAR(g.maploc->typ)) {
|
||||
if (Levitation) {
|
||||
@@ -1107,8 +1144,10 @@ dokick(void)
|
||||
}
|
||||
You("kick %s.", (Blind ? something : "the altar"));
|
||||
altar_wrath(x, y);
|
||||
if (!rn2(3))
|
||||
goto ouch;
|
||||
if (!rn2(3)) {
|
||||
kick_ouch(x, y, kickobjnam);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
exercise(A_DEX, TRUE);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
@@ -1118,8 +1157,10 @@ dokick(void)
|
||||
return ECMD_TIME;
|
||||
}
|
||||
You("kick %s.", (Blind ? something : "the fountain"));
|
||||
if (!rn2(3))
|
||||
goto ouch;
|
||||
if (!rn2(3)) {
|
||||
kick_ouch(x, y, kickobjnam);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
/* make metal boots rust */
|
||||
if (uarmf && rn2(3))
|
||||
if (water_damage(uarmf, "metal boots", TRUE) == ER_NOTHING) {
|
||||
@@ -1134,8 +1175,10 @@ dokick(void)
|
||||
kick_dumb(x, y);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
if (rn2(4))
|
||||
goto ouch;
|
||||
if (rn2(4)) {
|
||||
kick_ouch(x, y, kickobjnam);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
exercise(A_WIS, FALSE);
|
||||
if (Role_if(PM_ARCHEOLOGIST) || Role_if(PM_SAMURAI)
|
||||
|| ((u.ualign.type == A_LAWFUL) && (u.ualign.record > -10))) {
|
||||
@@ -1153,8 +1196,10 @@ dokick(void)
|
||||
}
|
||||
return ECMD_TIME;
|
||||
}
|
||||
if (g.maploc->typ == IRONBARS)
|
||||
goto ouch;
|
||||
if (g.maploc->typ == IRONBARS) {
|
||||
kick_ouch(x, y, kickobjnam);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
if (IS_TREE(g.maploc->typ)) {
|
||||
struct obj *treefruit;
|
||||
|
||||
@@ -1162,7 +1207,8 @@ dokick(void)
|
||||
if (rn2(3)) {
|
||||
if (!rn2(6) && !(g.mvitals[PM_KILLER_BEE].mvflags & G_GONE))
|
||||
You_hear("a low buzzing."); /* a warning */
|
||||
goto ouch;
|
||||
kick_ouch(x, y, kickobjnam);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
if (rn2(15) && !(g.maploc->looted & TREE_LOOTED)
|
||||
&& (treefruit = rnd_treefruit_at(x, y))) {
|
||||
@@ -1210,7 +1256,8 @@ dokick(void)
|
||||
g.maploc->looted |= TREE_SWARM;
|
||||
return ECMD_TIME;
|
||||
}
|
||||
goto ouch;
|
||||
kick_ouch(x, y, kickobjnam);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
if (IS_SINK(g.maploc->typ)) {
|
||||
int gend = poly_gender();
|
||||
@@ -1271,7 +1318,8 @@ dokick(void)
|
||||
}
|
||||
return ECMD_TIME;
|
||||
}
|
||||
goto ouch;
|
||||
kick_ouch(x, y, kickobjnam);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
if (g.maploc->typ == STAIRS || g.maploc->typ == LADDER
|
||||
|| IS_STWALL(g.maploc->typ)) {
|
||||
@@ -1279,26 +1327,7 @@ dokick(void)
|
||||
kick_dumb(x, y);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
ouch:
|
||||
pline("Ouch! That hurts!");
|
||||
exercise(A_DEX, FALSE);
|
||||
exercise(A_STR, FALSE);
|
||||
if (isok(x, y)) {
|
||||
if (Blind)
|
||||
feel_location(x, y); /* we know we hit it */
|
||||
if (is_drawbridge_wall(x, y) >= 0) {
|
||||
pline_The("drawbridge is unaffected.");
|
||||
/* update maploc to refer to the drawbridge */
|
||||
(void) find_drawbridge(&x, &y);
|
||||
g.maploc = &levl[x][y];
|
||||
}
|
||||
}
|
||||
if (!rn2(3))
|
||||
set_wounded_legs(RIGHT_SIDE, 5 + rnd(5));
|
||||
dmg = rnd(ACURR(A_CON) > 15 ? 3 : 5);
|
||||
losehp(Maybe_Half_Phys(dmg), kickstr(buf, kickobjnam), KILLED_BY);
|
||||
if (Is_airlevel(&u.uz) || Levitation)
|
||||
hurtle(-u.dx, -u.dy, rn1(2, 4), TRUE); /* assume it's heavy */
|
||||
kick_ouch(x, y, kickobjnam);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
kick_dumb(x, y);
|
||||
@@ -1312,8 +1341,10 @@ dokick(void)
|
||||
}
|
||||
|
||||
/* not enough leverage to kick open doors while levitating */
|
||||
if (Levitation)
|
||||
goto ouch;
|
||||
if (Levitation) {
|
||||
kick_ouch(x, y, kickobjnam);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
|
||||
exercise(A_DEX, TRUE);
|
||||
/* door is known to be CLOSED or LOCKED */
|
||||
|
||||
Reference in New Issue
Block a user