Merge branch 'moverock_core' of https://github.com/argrath/NetHack into NetHack-3.7
This commit is contained in:
41
src/hack.c
41
src/hack.c
@@ -11,6 +11,7 @@
|
|||||||
staticfn boolean could_move_onto_boulder(coordxy, coordxy);
|
staticfn boolean could_move_onto_boulder(coordxy, coordxy);
|
||||||
staticfn void moverock_done(coordxy, coordxy);
|
staticfn void moverock_done(coordxy, coordxy);
|
||||||
staticfn int moverock(void);
|
staticfn int moverock(void);
|
||||||
|
staticfn int moverock_core(coordxy, coordxy);
|
||||||
staticfn void dosinkfall(void);
|
staticfn void dosinkfall(void);
|
||||||
staticfn boolean findtravelpath(int);
|
staticfn boolean findtravelpath(int);
|
||||||
staticfn boolean trapmove(coordxy, coordxy, struct trap *);
|
staticfn boolean trapmove(coordxy, coordxy, struct trap *);
|
||||||
@@ -166,21 +167,31 @@ moverock_done(coordxy sx, coordxy sy)
|
|||||||
staticfn int
|
staticfn int
|
||||||
moverock(void)
|
moverock(void)
|
||||||
{
|
{
|
||||||
coordxy rx, ry, sx, sy;
|
coordxy sx, sy;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
sx = u.ux + u.dx, sy = u.uy + u.dy; /* boulder starting position */
|
||||||
|
ret = moverock_core(sx, sy);
|
||||||
|
moverock_done(sx, sy);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
staticfn int
|
||||||
|
moverock_core(coordxy sx, coordxy sy)
|
||||||
|
{
|
||||||
|
coordxy rx, ry;
|
||||||
struct obj *otmp;
|
struct obj *otmp;
|
||||||
struct trap *ttmp;
|
struct trap *ttmp;
|
||||||
struct monst *mtmp, *shkp;
|
struct monst *mtmp, *shkp;
|
||||||
const char *what;
|
const char *what;
|
||||||
boolean costly, firstboulder = TRUE;
|
boolean costly, firstboulder = TRUE;
|
||||||
|
|
||||||
sx = u.ux + u.dx, sy = u.uy + u.dy; /* boulder starting position */
|
|
||||||
while ((otmp = sobj_at(BOULDER, sx, sy)) != 0) {
|
while ((otmp = sobj_at(BOULDER, sx, sy)) != 0) {
|
||||||
|
|
||||||
if (Blind && glyph_to_obj(glyph_at(sx, sy)) != BOULDER) {
|
if (Blind && glyph_to_obj(glyph_at(sx, sy)) != BOULDER) {
|
||||||
pline("That feels like a boulder.");
|
pline("That feels like a boulder.");
|
||||||
map_object(otmp, TRUE);
|
map_object(otmp, TRUE);
|
||||||
nomul(0);
|
nomul(0);
|
||||||
moverock_done(sx, sy);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +243,6 @@ moverock(void)
|
|||||||
svc.context.door_opened = svc.context.move = TRUE;
|
svc.context.door_opened = svc.context.move = TRUE;
|
||||||
res = -1; /* don't move to <sx,sy>, so no soko guilt */
|
res = -1; /* don't move to <sx,sy>, so no soko guilt */
|
||||||
}
|
}
|
||||||
moverock_done(sx, sy); /* stop further push attempts */
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
if (Levitation || Is_airlevel(&u.uz)) {
|
if (Levitation || Is_airlevel(&u.uz)) {
|
||||||
@@ -244,7 +254,6 @@ moverock(void)
|
|||||||
feel_location(sx, sy);
|
feel_location(sx, sy);
|
||||||
You("don't have enough leverage to push %s.", the(xname(otmp)));
|
You("don't have enough leverage to push %s.", the(xname(otmp)));
|
||||||
/* Give them a chance to climb over it? */
|
/* Give them a chance to climb over it? */
|
||||||
moverock_done(sx, sy);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (verysmall(gy.youmonst.data) && !u.usteed) {
|
if (verysmall(gy.youmonst.data) && !u.usteed) {
|
||||||
@@ -273,7 +282,6 @@ moverock(void)
|
|||||||
|
|
||||||
if (revive_nasty(rx, ry,
|
if (revive_nasty(rx, ry,
|
||||||
"You sense movement on the other side.")) {
|
"You sense movement on the other side.")) {
|
||||||
moverock_done(sx, sy);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +327,6 @@ moverock(void)
|
|||||||
if (ttmp) {
|
if (ttmp) {
|
||||||
int newlev = 0; /* lint suppression */
|
int newlev = 0; /* lint suppression */
|
||||||
d_level dest;
|
d_level dest;
|
||||||
int res;
|
|
||||||
|
|
||||||
/* if a trap operates on the boulder, don't attempt
|
/* if a trap operates on the boulder, don't attempt
|
||||||
to move any others at this location; return -1
|
to move any others at this location; return -1
|
||||||
@@ -348,9 +355,7 @@ moverock(void)
|
|||||||
fill_pit(u.ux, u.uy);
|
fill_pit(u.ux, u.uy);
|
||||||
if (cansee(rx, ry))
|
if (cansee(rx, ry))
|
||||||
newsym(rx, ry);
|
newsym(rx, ry);
|
||||||
res = sobj_at(BOULDER, sx, sy) ? -1 : 0;
|
return sobj_at(BOULDER, sx, sy) ? -1 : 0;
|
||||||
moverock_done(sx, sy);
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SPIKED_PIT:
|
case SPIKED_PIT:
|
||||||
@@ -366,9 +371,7 @@ moverock(void)
|
|||||||
}
|
}
|
||||||
if (mtmp && !Blind)
|
if (mtmp && !Blind)
|
||||||
newsym(rx, ry);
|
newsym(rx, ry);
|
||||||
res = sobj_at(BOULDER, sx, sy) ? -1 : 0;
|
return sobj_at(BOULDER, sx, sy) ? -1 : 0;
|
||||||
moverock_done(sx, sy);
|
|
||||||
return res;
|
|
||||||
case HOLE:
|
case HOLE:
|
||||||
case TRAPDOOR:
|
case TRAPDOOR:
|
||||||
Soundeffect(se_kerplunk_boulder_gone, 40);
|
Soundeffect(se_kerplunk_boulder_gone, 40);
|
||||||
@@ -391,9 +394,7 @@ moverock(void)
|
|||||||
levl[rx][ry].candig = 1;
|
levl[rx][ry].candig = 1;
|
||||||
if (cansee(rx, ry))
|
if (cansee(rx, ry))
|
||||||
newsym(rx, ry);
|
newsym(rx, ry);
|
||||||
res = sobj_at(BOULDER, sx, sy) ? -1 : 0;
|
return sobj_at(BOULDER, sx, sy) ? -1 : 0;
|
||||||
moverock_done(sx, sy);
|
|
||||||
return res;
|
|
||||||
case LEVEL_TELEP:
|
case LEVEL_TELEP:
|
||||||
/* 20% chance of picking current level; 100% chance for
|
/* 20% chance of picking current level; 100% chance for
|
||||||
that if in single-level branch (Knox) or in endgame */
|
that if in single-level branch (Knox) or in endgame */
|
||||||
@@ -423,9 +424,7 @@ moverock(void)
|
|||||||
otmp->owornmask = (long) MIGR_RANDOM;
|
otmp->owornmask = (long) MIGR_RANDOM;
|
||||||
}
|
}
|
||||||
seetrap(ttmp);
|
seetrap(ttmp);
|
||||||
res = sobj_at(BOULDER, sx, sy) ? -1 : 0;
|
return sobj_at(BOULDER, sx, sy) ? -1 : 0;
|
||||||
moverock_done(sx, sy);
|
|
||||||
return res;
|
|
||||||
default:
|
default:
|
||||||
break; /* boulder not affected by this trap */
|
break; /* boulder not affected by this trap */
|
||||||
}
|
}
|
||||||
@@ -559,7 +558,6 @@ moverock(void)
|
|||||||
past it without pushing it to plug a pit or hole */
|
past it without pushing it to plug a pit or hole */
|
||||||
sokoban_guilt();
|
sokoban_guilt();
|
||||||
}
|
}
|
||||||
moverock_done(sx, sy);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -567,15 +565,12 @@ moverock(void)
|
|||||||
pline(
|
pline(
|
||||||
"However, you can squeeze yourself into a small opening.");
|
"However, you can squeeze yourself into a small opening.");
|
||||||
sokoban_guilt();
|
sokoban_guilt();
|
||||||
moverock_done(sx, sy);
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
moverock_done(sx, sy);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
moverock_done(sx, sy);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user