From 84f667c5a4c1ce4ce53bc80c775e8eb43339537d Mon Sep 17 00:00:00 2001 From: "nethack.allison" Date: Mon, 13 Oct 2003 23:54:41 +0000 Subject: [PATCH] ice Warning (trunk only) --- doc/fixes35.0 | 1 + include/extern.h | 2 ++ src/hack.c | 13 +++++++++++++ src/timeout.c | 28 ++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+) diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 768d842d0..9f5445a02 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -68,6 +68,7 @@ provide core support for saving of messsage history in save file the following actions can now be continued after save/restore: digging, eating, studying, removing armor hero-created and monster-created ice will eventually melt away +extend Warning to include ice danger Platform- and/or Interface-Specific New Features diff --git a/include/extern.h b/include/extern.h index 84f183458..cb8ded8fc 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1983,6 +1983,8 @@ E void FDECL(obj_move_timers, (struct obj *, struct obj *)); E void FDECL(obj_split_timers, (struct obj *, struct obj *)); E void FDECL(obj_stop_timers, (struct obj *)); E void FDECL(spot_stop_timers, (XCHAR_P,XCHAR_P,SHORT_P)); +E long FDECL(spot_time_expires, (XCHAR_P,XCHAR_P,SHORT_P)); +E long FDECL(spot_time_left, (XCHAR_P,XCHAR_P,SHORT_P)); E boolean FDECL(obj_is_local, (struct obj *)); E void FDECL(save_timers, (int,int,int)); E void FDECL(restore_timers, (int,int,BOOLEAN_P,long)); diff --git a/src/hack.c b/src/hack.c index 7c118f627..ff4b2efb9 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1485,6 +1485,19 @@ stillinwater:; if (trap && !pit) dotrap(trap, 0); /* fall into arrow trap, etc. */ } + /* Warning alerts you to ice danger */ + if (Warning && is_ice(u.ux,u.uy)) { + static const char * const icewarnings[] = { + "The ice seems very soft and slushy.", + "You feel the ice shift beneath you!", + "The ice, is gonna BREAK!", /* The Dead Zone */ + }; + long time_left = spot_time_left(u.ux, u.uy, MELT_ICE_AWAY); + if (time_left && time_left < 15L) + pline("%s", + (time_left < 5L) ? icewarnings[2] : + (time_left < 10L) ? icewarnings[1] : icewarnings[0]); + } if((mtmp = m_at(u.ux, u.uy)) && !u.uswallow) { mtmp->mundetected = mtmp->msleeping = 0; switch(mtmp->data->mlet) { diff --git a/src/timeout.c b/src/timeout.c index 12314da9e..14009e67a 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -1585,6 +1585,34 @@ short func_index; } } +/* + * When is the spot timer of type func_index going to expire? + * Returns 0L if no such timer. + */ +long +spot_time_expires(x,y,func_index) +xchar x,y; +short func_index; +{ + timer_element *curr; + long where = (((long)x << 16) | ((long)y)); + + for (curr = timer_base; curr; curr = curr->next) { + if (curr->kind == TIMER_LEVEL && + curr->func_index == func_index && curr->arg == (genericptr_t)where) + return curr->timeout; + } + return 0L; +} + +long +spot_time_left(x,y,func_index) +xchar x,y; +short func_index; +{ + long expires = spot_time_expires(x,y,func_index); + return (expires > 0L) ? expires - monstermoves : 0L; +} /* Insert timer into the global queue */ STATIC_OVL void -- 2.40.0