]> granicus.if.org Git - nethack/commitdiff
ice Warning (trunk only)
authornethack.allison <nethack.allison>
Mon, 13 Oct 2003 23:54:41 +0000 (23:54 +0000)
committernethack.allison <nethack.allison>
Mon, 13 Oct 2003 23:54:41 +0000 (23:54 +0000)
doc/fixes35.0
include/extern.h
src/hack.c
src/timeout.c

index 768d842d08ab87774114a4a76cc7b8bee9f34a35..9f5445a02b130ea467ec95f0b891ed8da592984a 100644 (file)
@@ -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
index 84f1834588632048bd100d678d379a3643a86488..cb8ded8fcc905872b9ca8a8d4947ae3697bd3e7a 100644 (file)
@@ -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));
index 7c118f627c2d6ad629a728d102591ad51ecef454..ff4b2efb9856ac12e5c216c046d5fc2fd635e204 100644 (file)
@@ -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) {
index 12314da9eb31b4c0baac4001d3ec15783972dd9e..14009e67ad4aee0c59ce57a947d09dda98427f9d 100644 (file)
@@ -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