Difference between revisions of "Talk:Traproom"

From NetHackWiki
Jump to navigation Jump to search
(Created page with "I was reading through Sporkhack code and stumbled across this new special room +mktraproom() +{ + struct mkroom *sroom; + struct rm *lev; + int area, ttyp, ntraps; +...")
 
Line 1: Line 1:
 
I was reading through Sporkhack code and stumbled across this new special room
 
I was reading through Sporkhack code and stumbled across this new special room
 
+
<pre>
 
+mktraproom()
 
+mktraproom()
 
+{
 
+{
Line 32: Line 32:
 
+
 
+
 
+}
 
+}
 +
 +
<\pre>
 +
  
  
 
Generation:
 
Generation:
 +
 +
<pre>
  
 
case 10:
 
case 10:
 
+ if (u_depth > 4 && !rn2(24)) { mkroom(TRAPROOM); break; }
 
+ if (u_depth > 4 && !rn2(24)) { mkroom(TRAPROOM); break; }
 +
 +
<\pre>
 +
  
  
 
--[[User:Ozymandias|Ozymandias]] ([[User talk:Ozymandias|talk]]) 01:51, 24 July 2013 (UTC) if someone could write this article, that would be great.
 
--[[User:Ozymandias|Ozymandias]] ([[User talk:Ozymandias|talk]]) 01:51, 24 July 2013 (UTC) if someone could write this article, that would be great.

Revision as of 01:53, 24 July 2013

I was reading through Sporkhack code and stumbled across this new special room

+mktraproom()
+{
+    struct mkroom *sroom;
+    struct rm *lev;
+    int area, ttyp, ntraps;
+    int idx = (level_difficulty() + ((long)u.ubirthday)) % 9;
+
+    if(!(sroom = pick_room(TRUE))) return;
+
+    sroom->rtype = TRAPROOM;
+    if (!rn2(10)) idx = rn2(10); /* occasionally give anything if called twice on same level */
+
+    area = ((sroom->hx - sroom->lx + 1) * (sroom->hy - sroom->ly + 1));
+    ntraps = rn2(area/3) + (area/4);
+
+    while (ntraps-- > 0) {
+	switch (idx) {
+	default: ttyp = LANDMINE; break;
+	case 0:  ttyp = ROLLING_BOULDER_TRAP; ntraps--; break;
+	case 1:  ttyp = rn2(2) ? PIT : SPIKED_PIT; break;
+	case 2:  ttyp = WEB; break;
+	case 3:  ttyp = rn2(3) ? ROCKTRAP : COLLAPSE_TRAP; break;
+	case 4:  ttyp = FIRE_TRAP; break;
+	case 5:  ttyp = rn2(5) ? TRAPDOOR : HOLE; break;
+	case 6:  ttyp = STATUE_TRAP; break;
+	case 7:  ttyp = rn2(2) ? DART_TRAP : ARROW_TRAP; break;
+	}
+	mktrap(ttyp, 0, sroom, NULL);
+    }
+
+}

<\pre>



Generation:


case 10:
+					if (u_depth > 4 && !rn2(24)) { mkroom(TRAPROOM); break; }

<\pre>



--Ozymandias (talk) 01:51, 24 July 2013 (UTC) if someone could write this article, that would be great.