Wikia

Wikihack

Source:NetHack 3.0.0/timeout.c

2,032pages on
this wiki
Talk0

Below is the full text to timeout.c from the source code of NetHack 3.0.0. To link to a particular line, write [[NetHack 3.0.0/timeout.c#line123]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

The NetHack General Public License applies to screenshots, source code and other content from NetHack.
1.    /*	SCCS Id: @(#)timeout.c	3.0	87/07/06
2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3.    /* NetHack may be freely redistributed.  See license for details. */
4.    
5.    #include	"hack.h"
6.    
7.    /* He is being petrified - dialogue by inmet!tower */
8.    static const char *stoned_texts[] = {
9.    	"You are slowing down.",		/* 5 */
10.   	"Your limbs are stiffening.",		/* 4 */
11.   	"Your limbs have turned to stone.",	/* 3 */
12.   	"You have turned to stone.",		/* 2 */
13.   	"You are a statue."			/* 1 */
14.   };
15.   
16.   static void
17.   stoned_dialogue() {
18.   	register long i = (Stoned & TIMEOUT);
19.   
20.   	if(i > 0 && i <= SIZE(stoned_texts))
21.   		pline(stoned_texts[SIZE(stoned_texts) - i]);
22.   	if(i == 5)
23.   		Fast &= ~(TIMEOUT|INTRINSIC);
24.   	if(i == 3)
25.   		nomul(-3);
26.   }
27.   
28.   static const char *choke_texts[] = {
29.   	"You find it hard to breathe.",
30.   	"You're gasping for air.",
31.   	"You can no longer breathe.",
32.   	"You're turning blue.",
33.   	"You suffocate."
34.   };
35.   
36.   static void
37.   choke_dialogue()
38.   {
39.   	register long i = (Strangled & TIMEOUT);
40.   
41.   	if(i > 0 && i <= SIZE(choke_texts))
42.   		pline(choke_texts[SIZE(choke_texts) - i]);
43.   }
44.   
45.   void
46.   timeout()
47.   {
48.   	register struct prop *upp;
49.   	int sleeptime;
50.   
51.   	if(Stoned) stoned_dialogue();
52.   	if(Strangled) choke_dialogue();
53.   #ifdef POLYSELF
54.   	if(u.mtimedone) if(!--u.mtimedone) rehumanize();
55.   #endif
56.   	if(u.ucreamed) u.ucreamed--;
57.   	if(u.uluck && moves % (u.uhave_amulet
58.   #ifdef THEOLOGY
59.   		|| u.ugangr
60.   #endif
61.   		? 300 : 600) == 0) {
62.   	/* Cursed luckstones stop bad luck from timing out; blessed luckstones
63.   	 * stop good luck from timing out; normal luckstones stop both;
64.   	 * neither is stopped if you don't have a luckstone.
65.   	 */
66.   	    register int time_luck = stone_luck(FALSE);
67.   	    boolean nostone = !carrying(LUCKSTONE);
68.   
69.   	    if(u.uluck > 0 && (nostone || time_luck < 0))
70.   		u.uluck--;
71.   	    else if(u.uluck < 0 && (nostone || time_luck > 0))
72.   		u.uluck++;
73.   	}
74.   
75.   	for(upp = u.uprops; upp < u.uprops+SIZE(u.uprops); upp++)
76.   	    if((upp->p_flgs & TIMEOUT) && !(--upp->p_flgs & TIMEOUT)) {
77.   		if(upp->p_tofn) (*upp->p_tofn)();
78.   		else switch(upp - u.uprops){
79.   		case STONED:
80.   			killer = "cockatrice";
81.   			done("stoned");
82.   			break;
83.   		case SICK:
84.   			You("die from food poisoning.");
85.   			killer = u.usick_cause;
86.   			done("died");
87.   			break;
88.   		case FAST:
89.   			You("feel yourself slowing down.");
90.   			break;
91.   		case CONFUSION:
92.   			HConfusion = 1; /* So make_confused works properly */
93.   			make_confused(0L, TRUE);
94.   			break;
95.   		case STUN:
96.   			HStun = 1;
97.   			make_stunned(0L, TRUE);
98.   			break;
99.   		case BLINDED:
100.  			Blinded = 1;
101.  			make_blinded(0L, TRUE);
102.  			break;
103.  		case INVIS:
104.  			on_scr(u.ux,u.uy);
105.  			if (!Invis && !See_invisible)
106.  				You("are no longer invisible.");
107.  			break;
108.  		case WOUNDED_LEGS:
109.  			heal_legs();
110.  			break;
111.  		case HALLUC:
112.  			Hallucination = 1;
113.  			make_hallucinated(0L, TRUE);
114.  			break;
115.  		case SLEEPING:
116.  			if (unconscious() || Sleep_resistance)
117.  				Sleeping += rnd(100);
118.  			else {
119.  				You("fall asleep.");
120.  				sleeptime = rnd(20);
121.  				nomul(-sleeptime);
122.  				nomovemsg = "You wake up.";
123.  				Sleeping = sleeptime + rnd(100);
124.  			}
125.  			break;
126.  		case STRANGLED:
127.  			killer = "strangulation";
128.  			done("died");
129.  			break;
130.  		case FUMBLING:
131.  			/* call this only when a move took place.  */
132.  			/* otherwise handle fumbling msgs locally. */
133.  			if (!Levitation && u.umoved) {
134.  			    if (levl[u.ux][u.uy].omask)
135.  				You("trip over something.");
136.  			    else
137.  				switch (rn2(4)) {
138.  				    case 1:
139.  					if (ACCESSIBLE(levl[u.ux][u.uy].typ)) { /* not POOL or STONE */
140.  					    if (Hallucination) pline("A rock bites your foot.");
141.  					    else You("trip over a rock.");
142.  					    break;
143.  					}
144.  				    case 2:
145.  					if (Hallucination) You("slip on a banana peel.");
146.  					else You("slip and nearly fall.");
147.  					break;
148.  				    case 3:
149.  					You("flounder.");
150.  					break;
151.  				    default:
152.  					You("stumble.");
153.  				}
154.  			    nomul(-2);
155.  			    nomovemsg = "";
156.  			}
157.  			Fumbling = rnd(20);
158.  			break;
159.  		}
160.  	}
161.  }
162.  
163.  static const char slithy[] = { S_SNAKE, S_NAGA, S_WORM, 0 };
164.  
165.  static void
166.  hatch_it(otmp)		/* hatch the egg "otmp" if possible */
167.  register struct obj *otmp;
168.  {
169.  	register struct monst *mtmp;
170.  #ifdef POLYSELF
171.  	int yours = otmp->spe;
172.  #endif
173.  
174.  	if(moves-otmp->age > 200)  /* very old egg - it's dead */
175.  	    otmp->corpsenm = -1;
176.  #ifdef LINT	/* long conv. ok */
177.  	else if(rnd(150) > 150) {
178.  #else
179.  	else if(rnd((int)(moves-otmp->age)) > 150) {
180.  #endif
181.  	    mtmp = makemon(&mons[big_to_little(otmp->corpsenm)], u.ux, u.uy);
182.  	    useup(otmp);
183.  	    if(mtmp) {
184.  
185.  		if(Blind)
186.  		    You("feel something %s from your pack!",
187.  			  (index(slithy, mtmp->data->mlet)) ?
188.  			  "slither" : "drop");
189.  		else
190.  		    pline("A%s %s just %s out of your pack!",
191.  			  (index(vowels, *(mtmp->data->mname))) ? "n" : "",
192.  			  mtmp->data->mname,
193.  			  (index(slithy, mtmp->data->mlet)) ?
194.  			  "slithered" : "dropped");
195.  
196.  #ifdef POLYSELF
197.  		if (yours) {
198.  		    pline("Its cries sound like \"%s.\"",
199.  			flags.female ? "mommy" : "daddy");
200.  		    (void) tamedog(mtmp, (struct obj *)0);
201.  		    return;
202.  		}
203.  #endif
204.  		if(mtmp->data->mlet == S_DRAGON) {
205.  		    pline("\"Gleep!\"");		/* Mything eggs :-) */
206.  		    (void) tamedog(mtmp, (struct obj *)0);
207.  		}
208.  	    }
209.  	}
210.  }
211.  
212.  void
213.  hatch_eggs()	    /* hatch any eggs that have been too long in pack */
214.  {
215.  	register struct obj *otmp,/* *ctmp, /* use of ctmp commented out below*/
216.  		*otmp2;
217.  
218.  	for(otmp = invent; otmp; otmp = otmp2) {
219.  
220.  	    otmp2 = otmp->nobj;	    /* otmp may hatch */
221.  	    if(otmp->otyp == EGG && otmp->corpsenm >= 0) hatch_it(otmp);
222.  	}
223.  
224.  /*	Not yet - there's a slight problem with "useup" on contained objs.
225.  	for(otmp = fcobj; otmp; otmp = otmp2) {
226.  
227.  	    otmp2 = otmp->nobj;
228.  	    for(ctmp = invent; ctmp; ctmp = ctmp->nobj)
229.  		if(otmp->cobj == ctmp)
230.  		    if(ctmp->otyp != ICE_BOX)
231.  			if(otmp->otyp == EGG && otmp->corpsenm >= 0)
232.  			    hatch_it(otmp);
233.  	}
234.  */
235.  }

Around Wikia's network

Random Wiki