About: Source:NetHack 2.2a/mkshop.c   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

Below is the full text to mkshop.c from the source code of NetHack 2.2a. To link to a particular line, write [[NetHack 2.2a/mkshop.c#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code

AttributesValues
rdfs:label
  • Source:NetHack 2.2a/mkshop.c
rdfs:comment
  • Below is the full text to mkshop.c from the source code of NetHack 2.2a. To link to a particular line, write [[NetHack 2.2a/mkshop.c#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code
dcterms:subject
dbkwik:nethack/pro...iPageUsesTemplate
abstract
  • Below is the full text to mkshop.c from the source code of NetHack 2.2a. To link to a particular line, write [[NetHack 2.2a/mkshop.c#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code 1. /* SCCS Id: @(#)mkshop.c 2.1 87/09/23 2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. 4. #ifndef QUEST 5. #include "hack.h" 6. #include "mkroom.h" 7. extern struct monst *makemon(); 8. extern struct obj *mkobj_at(); 9. extern int nroom; 10. 11. mkshop(){ 12. register struct mkroom *sroom; 13. int roomno, i = -1; 14. #ifdef WIZARD 15. extern char *getenv(); 16. 17. /* first determine shoptype */ 18. if(wizard){ 19. register char *ep = getenv("SHOPTYPE"); 20. if(ep){ 21. if(*ep == 'z' || *ep == 'Z'){ 22. mkzoo(ZOO); 23. return; 24. } 25. if(*ep == 'm' || *ep == 'M'){ 26. mkzoo(MORGUE); 27. return; 28. } 29. if(*ep == 'b' || *ep == 'B'){ 30. mkzoo(BEEHIVE); 31. return; 32. } 33. #ifdef NEWCLASS 34. if(*ep == 't' || *ep == 'T'){ 35. mkzoo(COURT); 36. return; 37. } 38. #endif 39. if(*ep == 's' || *ep == 'S'){ 40. mkswamp(); 41. return; 42. } 43. for(i=0; shtypes[i].name; i++) 44. if(*ep == shtypes[i].symb) goto gottype; 45. i = -1; 46. } 47. } 48. gottype: 49. #endif 50. for(sroom = &rooms[0], roomno = 0; ; sroom++, roomno++){ 51. if(sroom->hx < 0) return; 52. if(sroom - rooms >= nroom) { 53. pline("rooms not closed by -1?"); 54. return; 55. } 56. if(sroom->rtype != OROOM) continue; 57. if(!sroom->rlit || has_dnstairs(sroom) || has_upstairs(sroom)) 58. continue; 59. if( 60. #ifdef WIZARD 61. (wizard && getenv("SHOPTYPE") && sroom->doorct != 0) || 62. #endif 63. sroom->doorct == 1) break; 64. } 65. 66. if(i < 0) { /* shoptype not yet determined */ 67. register int j; 68. 69. /* pick a shop type at random */ 70. for(j = rn2(100), i = 0; j -= shtypes[i].prob; i++) 71. if (j < 0) break; 72. 73. /* big rooms cannot be wand or book shops, 74. * - so make them general stores 75. */ 76. if(isbig(sroom) && (shtypes[i].symb == WAND_SYM 77. #ifdef SPELLS 78. || shtypes[i].symb == SPBOOK_SYM 79. #endif 80. )) i = 0; 81. } 82. sroom->rtype = SHOPBASE + i; 83. 84. /* stock the room with a shopkeeper and artifacts */ 85. stock_room(&(shtypes[i]), sroom); 86. } 87. 88. mkzoo(type) 89. int type; 90. { 91. register struct mkroom *sroom; 92. register struct monst *mon; 93. register int sh,sx,sy,i; 94. int goldlim = 500 * dlevel; 95. int moct = 0; 96. struct permonst *morguemon(); 97. #ifdef NEWCLASS 98. struct permonst *courtmon(); 99. #endif 100. 101. i = nroom; 102. for(sroom = &rooms[rn2(nroom)]; ; sroom++) { 103. if(sroom == &rooms[nroom]) 104. sroom = &rooms[0]; 105. if(!i-- || sroom->hx < 0) 106. return; 107. if(sroom->rtype != OROOM) continue; 108. if(has_upstairs(sroom) || (has_dnstairs(sroom) && rn2(3))) 109. continue; 110. if(sroom->doorct == 1 || !rn2(5)) 111. break; 112. } 113. sroom->rtype = type; 114. sh = sroom->fdoor; 115. for(sx = sroom->lx; sx <= sroom->hx; sx++) 116. for(sy = sroom->ly; sy <= sroom->hy; sy++){ 117. if((sx == sroom->lx && doors[sh].x == sx-1) || 118. (sx == sroom->hx && doors[sh].x == sx+1) || 119. (sy == sroom->ly && doors[sh].y == sy-1) || 120. (sy == sroom->hy && doors[sh].y == sy+1)) continue; 121. mon = makemon( 122. #ifdef NEWCLASS 123. (type == COURT) ? courtmon() : 124. #endif 125. (type == MORGUE) ? morguemon() : 126. (type == BEEHIVE) ? PM_KILLER_BEE : (struct permonst *) 0, 127. sx, sy); 128. if(mon) mon->msleep = 1; 129. switch(type) { 130. case ZOO: 131. i = sq(dist2(sx,sy,doors[sh].x,doors[sh].y)); 132. if(i >= goldlim) i = 5*dlevel; 133. goldlim -= i; 134. mkgold((long)(10 + rn2(i)), sx, sy); 135. break; 136. case MORGUE: 137. /* Usually there is one dead body in the morgue */ 138. if(!moct && rn2(3)) { 139. mksobj_at(CORPSE, sx, sy); 140. moct++; 141. } 142. break; 143. case BEEHIVE: 144. if(!rn2(3)) mksobj_at(LUMP_OF_ROYAL_JELLY, sx, sy); 145. break; 146. } 147. } 148. #ifdef NEWCLASS 149. if(type == COURT) { 150. 151. sx = sroom->lx + (rn2(sroom->hx - sroom->lx)); 152. sy = sroom->ly + (rn2(sroom->hy - sroom->ly)); 153. levl[sx][sy].typ = THRONE; 154. levl[sx][sy].scrsym = THRONE_SYM; 155. mkgold((long) rn1(50 * dlevel,10), sx, sy); 156. } 157. #endif 158. 159. } 160. 161. struct permonst * 162. morguemon() 163. { 164. extern struct permonst pm_ghost; 165. register int i = rn2(100), hd = rn2(dlevel); 166. 167. if(hd > 10 && i < 10) return(PM_DEMON); 168. if(hd > 8 && i > 85) return(PM_VAMPIRE); 169. return((i < 40) ? PM_GHOST : (i < 60) ? PM_WRAITH : PM_ZOMBIE); 170. } 171. 172. mkswamp() /* Michiel Huisjes & Fred de Wilde */ 173. { 174. register struct mkroom *sroom; 175. register int sx,sy,i,eelct = 0; 176. extern struct permonst pm_eel; 177. 178. for(i=0; i<5; i++) { /* 5 tries */ 179. sroom = &rooms[rn2(nroom)]; 180. if(sroom->hx < 0 || sroom->rtype != OROOM || 181. has_upstairs(sroom) || has_dnstairs(sroom)) 182. continue; 183. 184. /* satisfied; make a swamp */ 185. sroom->rtype = SWAMP; 186. for(sx = sroom->lx; sx <= sroom->hx; sx++) 187. for(sy = sroom->ly; sy <= sroom->hy; sy++) 188. if((sx+sy)%2 && !o_at(sx,sy) && !t_at(sx,sy) 189. && !m_at(sx,sy) && !nexttodoor(sx,sy)){ 190. levl[sx][sy].typ = POOL; 191. levl[sx][sy].scrsym = POOL_SYM; 192. if(!eelct || !rn2(4)) { 193. (void) makemon(PM_EEL, sx, sy); 194. eelct++; 195. } 196. } 197. } 198. } 199. 200. nexttodoor(sx,sy) 201. register sx,sy; 202. { 203. register dx,dy; 204. register struct rm *lev; 205. for(dx = -1; dx <= 1; dx++) for(dy = -1; dy <= 1; dy++) 206. if((lev = &levl[sx+dx][sy+dy])->typ == DOOR || 207. lev->typ == SDOOR || lev->typ == LDOOR) 208. return(1); 209. return(0); 210. } 211. 212. has_dnstairs(sroom) 213. register struct mkroom *sroom; 214. { 215. return(sroom->lx <= xdnstair && xdnstair <= sroom->hx && 216. sroom->ly <= ydnstair && ydnstair <= sroom->hy); 217. } 218. 219. has_upstairs(sroom) 220. register struct mkroom *sroom; 221. { 222. return(sroom->lx <= xupstair && xupstair <= sroom->hx && 223. sroom->ly <= yupstair && yupstair <= sroom->hy); 224. } 225. 226. isbig(sroom) 227. register struct mkroom *sroom; 228. { 229. register int area = (sroom->hx - sroom->lx) * (sroom->hy - sroom->ly); 230. return( area > 20 ); 231. } 232. 233. dist2(x0,y0,x1,y1){ 234. return((x0-x1)*(x0-x1) + (y0-y1)*(y0-y1)); 235. } 236. 237. sq(a) int a; { 238. return(a*a); 239. } 240. #endif /* QUEST /**/ 241. 242. #ifdef NEWCLASS 243. struct permonst * 244. courtmon() 245. { 246. int i = rn2(60) + rn2(3*dlevel); 247. 248. if (i > 100) return(PM_DRAGON); 249. else if (i > 95) return(PM_XORN); 250. else if (i > 85) return(PM_TROLL); 251. else if (i > 75) return(PM_ETTIN); 252. else if (i > 60) return(PM_CENTAUR); 253. else if (i > 45) return(PM_ORC); 254. else if (i > 30) return(PM_HOBGOBLIN); 255. #ifdef KOPS 256. else return(PM_GNOME); 257. #else 258. else if (i > 15) return(PM_GNOME); 259. else return(PM_KOBOLD); 260. #endif 261. } 262. #endif /* NEWCLASS /**/
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software