From 57b1e96238cd5798bd811bc58a785adadf913b23 Mon Sep 17 00:00:00 2001 From: "nethack.allison" Date: Mon, 22 Dec 2003 19:09:39 +0000 Subject: [PATCH] teetering on edge of pit - when you're teetering on the edge of a pit you can use '>' to enter the pit - pull the numerious teetering checks into a new function --- doc/fixes34.4 | 1 + include/extern.h | 1 + include/hack.h | 1 + src/do.c | 16 ++++++++-------- src/hack.c | 9 +++------ src/pickup.c | 9 +++------ src/trap.c | 27 +++++++++++++++++++++++---- 7 files changed, 40 insertions(+), 24 deletions(-) diff --git a/doc/fixes34.4 b/doc/fixes34.4 index d8a4a1668..8d73a446a 100644 --- a/doc/fixes34.4 +++ b/doc/fixes34.4 @@ -8,6 +8,7 @@ wizard mode: avoid division by 0 crash for level teleport in the endgame if confusion overrides teleport control don't #sit on an object in a pit if you're only on the precipice fix message when pushing a boulder into a pool while riding +when you're teetering on the edge of a pit you can use '>' to enter the pit Platform- and/or Interface-Specific Fixes diff --git a/include/extern.h b/include/extern.h index 4afefe71d..4bc7e4198 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2088,6 +2088,7 @@ E boolean NDECL(unconscious); E boolean NDECL(lava_effects); E void FDECL(blow_up_landmine, (struct trap *)); E int FDECL(launch_obj,(SHORT_P,int,int,int,int,int)); +E boolean FDECL(uteetering_at_seen_pit, (struct trap *)); /* ### u_init.c ### */ diff --git a/include/hack.h b/include/hack.h index 5d7f91d47..b1677b1f5 100644 --- a/include/hack.h +++ b/include/hack.h @@ -193,6 +193,7 @@ NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */ #define NOWEBMSG 0x01 /* suppress stumble into web message */ #define FORCEBUNGLE 0x02 /* adjustments appropriate for bungling */ #define RECURSIVETRAP 0x04 /* trap changed into another type this same turn */ +#define TOOKPLUNGE 0x08 /* used '>' to enter pit below you */ /* Flags to control test_move in hack.c */ #define DO_MOVE 0 /* really doing the move */ diff --git a/src/do.c b/src/do.c index 0bd243579..9bb52b0ed 100644 --- a/src/do.c +++ b/src/do.c @@ -209,10 +209,7 @@ const char *verb; } water_damage(obj, FALSE, FALSE); } else if (u.ux == x && u.uy == y && - (!u.utrap || u.utraptype != TT_PIT) && - (t = t_at(x,y)) != 0 && t->tseen && - (t->ttyp==PIT || t->ttyp==SPIKED_PIT)) { - /* you escaped a pit and are standing on the precipice */ + (t = t_at(x,y)) != 0 && uteetering_at_seen_pit(t)) { if (Blind && !Deaf) You_hear("%s tumble downwards.", the(xname(obj))); @@ -778,10 +775,13 @@ dodown() return (0); /* didn't move */ } if (!stairs_down && !ladder_down) { - if (!(trap = t_at(u.ux,u.uy)) || - (trap->ttyp != TRAPDOOR && trap->ttyp != HOLE) - || !Can_fall_thru(&u.uz) || !trap->tseen) { - + trap = t_at(u.ux,u.uy); + if (trap && uteetering_at_seen_pit(trap)) { + dotrap(trap, TOOKPLUNGE); + return(1); + } else if (!trap || + (trap->ttyp != TRAPDOOR && trap->ttyp != HOLE) || + !Can_fall_thru(&u.uz) || !trap->tseen) { if (flags.autodig && !context.nopick && uwep && is_pick(uwep)) { return use_pick_axe2(uwep); diff --git a/src/hack.c b/src/hack.c index b4520e06b..4431e679d 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1937,17 +1937,14 @@ dopickup() return(0); } - if (traphere && traphere->tseen) { + if (traphere && uteetering_at_seen_pit(traphere)) { /* Allow pickup from holes and trap doors that you escaped from * because that stuff is teetering on the edge just like you, but * not pits, because there is an elevation discrepancy with stuff * in pits. */ - if ((traphere->ttyp == PIT || traphere->ttyp == SPIKED_PIT) && - (!u.utrap || (u.utrap && u.utraptype != TT_PIT))) { - You("cannot reach the bottom of the pit."); - return(0); - } + You("cannot reach the bottom of the pit."); + return(0); } return (pickup(-count)); diff --git a/src/pickup.c b/src/pickup.c index af7216f48..b93a89fb5 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -412,17 +412,14 @@ int what; /* should be a long */ read_engr_at(u.ux, u.uy); return (0); } - if (ttmp && ttmp->tseen) { + if (ttmp && uteetering_at_seen_pit(ttmp)) { /* Allow pickup from holes and trap doors that you escaped * from because that stuff is teetering on the edge just * like you, but not pits, because there is an elevation * discrepancy with stuff in pits. */ - if ((ttmp->ttyp == PIT || ttmp->ttyp == SPIKED_PIT) && - (!u.utrap || (u.utrap && u.utraptype != TT_PIT))) { - read_engr_at(u.ux, u.uy); - return(0); - } + read_engr_at(u.ux, u.uy); + return(0); } /* multi && !context.run means they are in the middle of some other * action, or possibly paralyzed, sleeping, etc.... and they just diff --git a/src/trap.c b/src/trap.c index a3fbc0653..ce6704bb0 100644 --- a/src/trap.c +++ b/src/trap.c @@ -577,6 +577,7 @@ unsigned trflags; boolean already_seen = trap->tseen; boolean webmsgok = (!(trflags & NOWEBMSG)); boolean forcebungle = (trflags & FORCEBUNGLE); + boolean plunged = (trflags & TOOKPLUNGE); nomul(0); @@ -604,7 +605,7 @@ unsigned trflags; return; } if(!Fumbling && ttype != MAGIC_PORTAL && - ttype != ANTI_MAGIC && !forcebungle && + ttype != ANTI_MAGIC && !forcebungle && !plunged && (!rn2(5) || ((ttype == PIT || ttype == SPIKED_PIT) && is_clinger(youmonst.data)))) { You("escape %s %s.", @@ -877,7 +878,7 @@ glovecheck: (void) rust_dmg(uarmg, "gauntlets", 1, TRUE, &youmonst); "poor", SUPPRESS_SADDLE, FALSE)); } else #endif - Strcpy(verbbuf,"fall"); + Strcpy(verbbuf, plunged ? "plunge" : "fall"); You("%s into %s pit!", verbbuf, a_your[trap->madeby_u]); } /* wumpus reference */ @@ -909,13 +910,16 @@ glovecheck: (void) rust_dmg(uarmg, "gauntlets", 1, TRUE, &youmonst); #endif if (ttype == SPIKED_PIT) { losehp(Maybe_Half_Phys(rnd(10)), - "fell into a pit of iron spikes", + plunged ? "deliberately plunged into a pit of iron spikes" : + "fell into a pit of iron spikes", NO_KILLER_PREFIX); if (!rn2(6)) poisoned("spikes", A_STR, "fall onto poison spikes", 8, FALSE); } else - losehp(Maybe_Half_Phys(rnd(6)),"fell into a pit", + losehp(Maybe_Half_Phys(rnd(6)), + plunged ? "deliberately plunged into a pit" : + "fell into a pit", NO_KILLER_PREFIX); if (Punished && !carried(uball)) { unplacebc(); @@ -3779,6 +3783,21 @@ register struct trap *trap; dealloc_trap(trap); } +/* + * Returns TRUE if you escaped a pit and are standing on the precipice. + */ +boolean +uteetering_at_seen_pit(trap) +struct trap *trap; +{ + if (trap && trap->tseen && + (!u.utrap || u.utraptype != TT_PIT) && + (trap->ttyp==PIT || trap->ttyp==SPIKED_PIT)) + return TRUE; + else + return FALSE; +} + boolean delfloortrap(ttmp) register struct trap *ttmp;