Decoded: Rogue (1980) by Toy, Arnold, Wichman
DOS version (1983) by Mel Sibony and Jon Lane
Source file: EXTERN.C
Beginner friendly, line-by-line code walkthrough by MaiZure

EXTERN.C defines global variables including monsters, player stats, etc.

Original code:
https://britzl.github.io/roguearchive/

Original code with line numbers
http://www.maizure.org/projects/decoded-rogue/EXTERN_linenum.txt



1     COMMENT
2     COMMENT
3     COMMENT
4     COMMENT
5     COMMENT
6     BLANK
7     Includes the game header
8     Includes the console management header
9     BLANK
10    Preprocessor check for log mode (not set)
11    Declares a variable for log files (dead code)
12    End of preprocessor log check
13    Preprocessor check for debug mode (not set)
14    Declares a variable for debug (dead code)
15    End of preprocessor check for debug mode
16    COMMENT
17    COMMENT
18    COMMENT
19    COMMENT
20    Revision number global
21    Version number global
22    BLANK
23    COMMENT
24    COMMENT
25    COMMENT
26    COMMENT
27    Defines a global array of weapon name text
28    Weapon name global char array
29    Weapon name global char array
30    Weapon name global char array
31    Weapon name global char array
32    Weapon name global char array
33    Weapon name global char array
34    Weapon name global char array
35    Weapon name global char array
36    Weapon name global char array
37    Weapon name global char array
38    Empty space in array
39    End of weapon name array definition
40    Defines a global array of armor name text
41    Armor name global char array
42    Armor name global char array
43    Armor name global char array
44    Armor name global char array
45    Armor name global char array
46    Armor name global char array
47    Armor name global char array
48    Armor name global char array
49    End of armor name array definition
50    BLANK
51    Defines a global array for armor generation cumulative chance by type
52    Chance to generate leather armor is 20%
53    Chance to generate ring mail is 15%
54    Chance to generate studded leather is 13%
55    Chance to generate scale mail is 12%
56    Chance to generate chain mail is 10%
57    Chance to generate splint mail is 10%
58    Chance to generate banded mail is 10%
59    Chance to generate plate mail is 5%
60    End of armor generation chance
61    Defines global array of armor class by type (early DnD rules: low=good)
62    Leather armor has AC of 8
63    Ring mail has AC of 7
64    Studded leather has AC of 7
65    Scale mail has AC of 6
66    Chain mail has AC of 5
67    Splint mail has AC of 4
68    Banded mail has AC of 4
69    Plate mail has AC of 3
70    End of armor class array
71    BLANK
72    Defines a global struct array of magic scroll data
73    Monster confusion scrolls appear 8% of the time and are worth 140 gold
74    Magic mapping scrolls appear 5% of the time and are worth 150 gold
75    Hold monster scrolls appear 3% of the time and are worth 180 gold
76    Sleep scrolls appear 5% of the time and are worth 5 gold
77    Enchant armor scrolls appear 8% of the time and are worth 160 gold
78    Identify scrolls appear 27% of the time and are worth 100 gold
79    Scare monster scrolls appear 4% of the time and are worth 200 gold
80    Food detection scrolls appear 4% of the time and are worth 50 gold
81    Teleportation scrolls appear 7% of the time and are worth 165 gold
82    Enchant weapon scrolls appear 10% of the time and are worth 150 gold
83    Create monster scrolls appear 5% of the time and are worth 75 gold
84    Remove curse scrolls appear 8% of the time and are worth 105 gold
85    Aggravate monster scrolls appear 4% of the time and are worth 20 gold
86    Blank paper scrolls appear 1% of the time and are worth 5 gold
87    Vorpalize weapons scrolls appear 1% of the time and are worth 300 gold
88    End of scroll data
89    BLANK
90    Defines a global struct array of magic potion data
91    Confusion potions appear 8% of the time and are worth 5 gold
92    Paralysis potions appear 10% of the time and are worth 5 gold
93    Poison potions appear 8% of the time and are worth 5 gold
94    Strength potions appear 15% of the time and are worth 150 gold
95    See invisible potions appear 2% of the time and are worth 100 gold
96    Healing potions appear 15% of the time and are worth 130 gold
97    If this is a demo version...
98    Advertisement potions appear 6% of the time and are worth 130 gold
99    Otherwise this is the full version and so...
100   Monster detection potions appear 6% of the time and are worth 130 gold
101   End check for demo version
102   Magic detection potions appear 6% of the time and are worth 105 gold
103   Raise level potions appear 2% of the time and are worth 250 gold
104   Extra healing potions appear 5% of the time and are worth 200 gold
105   Haste potions appear 4% of the time and are worth 190 gold
106   Restore strength potions appear 14% of the time and are worth 130 gold
107   Blindness potions appear 4% of the time and are worth 5 gold
108   Thirst quenching potions appear 1% of the time and are worth 5 gold
109   End of potions data
110   BLANK
111   Defines a global struct array of magic rings data
112   Protection rings appear 9% of the time and are worth 400 gold
113   Protection rings appear 9% of the time and are worth 400 gold
114   Protection rings appear 5% of the time and are worth 280 gold
115   Protection rings appear 10% of the time and are worth 420 gold
116   Protection rings appear 10% of the time and are worth 310 gold
117   Protection rings appear 1% of the time and are worth 10 gold
118   Protection rings appear 10% of the time and are worth 10 gold
119   Protection rings appear 8% of the time and are worth 440 gold
120   Protection rings appear 8% of the time and are worth 400 gold
121   Protection rings appear 4% of the time and are worth 460 gold
122   Protection rings appear 9% of the time and are worth 240 gold
123   Protection rings appear 5% of the time and are worth 30 gold
124   Protection rings appear 7% of the time and are worth 470 gold
125   Protection rings appear 5% of the time and are worth 380 gold
126   End of rings data
127   BLANK
128   Defines a global struct array of wand and staff data
129   Light wands/staves appear 12% of the time and are worth 250 gold
130   Striking wands/staves appear 12% of the time and are worth 75 gold
131   Lightning wands/staves appear 12% of the time and are worth 330 gold
132   Fire wands/staves appear 12% of the time and are worth 330 gold
133   Cold wands/staves appear 12% of the time and are worth 330 gold
134   Polymorph wands/staves appear 12% of the time and are worth 310 gold
135   Magic missile wands/staves appear 12% of the time and are worth 170 gold
136   Haste monster wands/staves appear 12% of the time and are worth 5 gold
137   Slow monster wands/staves appear 12% of the time and are worth 350 gold
138   Drain life wands/staves appear 12% of the time and are worth 300 gold
139   Useless wands/staves appear 12% of the time and are worth 5 gold
140   Teleport away wands/staves appear 12% of the time and are worth 340 gold
141   Teleport to wands/staves appear 12% of the time and are worth 50 gold
142   Cancellation wands/staves appear 12% of the time and are worth 280 gold
143   End of wand and staff data
144   BLANK
145   Check if help is defined (it is in ROGUE.H)
146   Set a maximum of 65 help items
147   Define a global array of formatted output strings for control help
148   Help command string
149   Help command string
150   Help command string
151   Help command string
152   Help command string
153   Help command string
154   Help command string
155   Help command string
156   Help command string
157   Help command string
158   Help command string
159   Help command string
160   Help command string
161   Help command string
162   Help command string
163   Help command string
164   Help command string
165   Help command string
166   Help command string
167   Help command string
168   Help command string
169   Help command string
170   Help command string
171   Help command string
172   Help command string
173   Help command string
174   Help command string
175   Help command string
176   Help command string
177   Help command string
178   Help command string
179   Help command string
180   Help command string
181   Help command string
182   Help command string
183   Help command string
184   Help command string
185   Help command string
186   Help command string
187   Help command string
188   Help command string
189   Help command string
190   Help command string
191   Help command string
192   Help command string
193   Help command string
194   Help command string
195   Help command string
196   Help command string
197   Help command string
198   Help command string
199   Help command string
200   Help command string
201   Help command string
202   Help command string
203   Help command string
204   Help command string
205   Help command string
206   Help command string
207   Help command string
208   Help command string
209   Help command string
210   Help command string
211   Help command string
212   Null array element
213   End of help command strings array
214   BLANK
215   Defines the global game symbol help list
216   Game symbol description string
217   Game symbol description string
218   Game symbol description string
219   Game symbol description string
220   Game symbol description string
221   Game symbol description string
222   Game symbol description string
223   Game symbol description string
224   Game symbol description string
225   Game symbol description string
226   Game symbol description string
227   Game symbol description string
228   Game symbol description string
229   COMMENT
230   COMMENT
231   Game symbol description string
232   Game symbol description string
233   Game symbol description string
234   Game symbol description string
235   Game symbol description string
236   Game symbol description string
237   Game symbol description string
238   Game symbol description string
239   Game symbol description string
240   Game symbol description string
241   Game symbol description string
242   Null symbol
243   End of global game symbol help data
244   End for help check
245   COMMENT
246   COMMENT
247   COMMENT
248   BLANK
249   Define a global array for character level (rank) names
250   Level 0 has no name
251   Level 1 is Guild Novice
252   Level 2 is Apprentice
253   Level 3 is Journeyman
254   Level 4 is Adventurer
255   Level 5 is Fighter
256   Level 6 is Warrior
257   Level 7 is Rogue
258   Level 8 is Champion
259   Level 9 is Master Rogue
260   Level 10 is Warlord
261   Level 11 is Hero
262   Level 12 is Guild Master
263   Level 13 is Dragonlord
264   Level 14 is Wizard
265   Level 15 is Rogue Geek
266   Level 16 is Rogue Addict
267   Level 17 is Schmendrick (aka...you might need a life)
268   Level 18 is Gunfighter
269   Level 19 is Time Waster
270   Level 20 is Bug Chaser
271   End of level name array
272   BLANK
273   COMMENT
274   COMMENT
275   COMMENT
276   Global integer for max item count. Init to zero and set later
277   Global integer for reinitialization (used on restart)
278   BLANK
279   Global flag to defer events until after daemon/timer processing
280   Global flag to invalidate the game score
281   Global flag to repeat last command
282   Global flag mask for (un)known scrolls
283   Global flag mask for (un)known potions
284   Global flag mask for (un)known rings
285   Global flag mask for (un)known wands/staves
286   Global flag for if the player has the amulet of Yendor
287   Global flag for if the player has seen, but not picked up, the amulet.
288   COMMENT
289   Global flag to capture door passes during running
290   Global flag used to detect running-break conditions
291   Another global flag used during running
292   COMMENT
293   Global flag to detect player moves
294   COMMENT
295   COMMENT
296   Global flag true when the game is active (this is the game loop var)
297   Global flag for running players
298   Global flag to save messages
299   COMMENT
300   Global flag for terse mode (short text)
301   Global flag for expert mode (ever shorter messages)
302   Check for developer mode (not used)
303   Global flag for developer mode
304   End check for developer mode
305   Global variable for current trap status
306   Check if we're in wizard mode (basically debug/superuser mode)
307   Global flag if wizard mode is enabled
308   End check for wizard mode
309   Global bailout flag. Used for debug detection for several failure cases
310   Declares a global byte holding the type of item the player picks up
311   Declares a global variable hlding player's running direction
312   COMMENT
313   Decalres a global array for actual scroll types
314   Decalres a global array for actual potion types
315   Decalres a global array for actual ring types
316   Decalres a global array for actual wand/staff types
317   COMMENT
318   Declares a global message buffer for the last printed message
319   Declares a global guess array for scrolls
320   Declares a global guess array for potions
321   Declares a global guess array for rings
322   Declares a global guess array for wands/staves
323   COMMENT
324   Declares a global array for all item types during guessing
325   Defines a global integer for indexing arrays during player guessing
326   Declares an array to mask for wands vs sticks
327   BLANK
328   Declares a global variable for screen vertical size (in lines)
329   Declares a global tracking variable for furthest player level progress
330   Declares a global trap counter for the level
331   Declares a global dungeon number tracker (number of games played)
332   Defines a global for current level number
333   Defines a global integer for tracking player gold
334   Defines a global for cursor horizontal position
335   Defines a global counter for no player movement turns
336   Defines a global counter for turns that player cannot execute commands
337   Defines a global inventory counter
338   Defines a global memory tracker
339   Defines a global counter for counting levels without food
340   Defines a global counter for command repeats
341   Defines a global counter for fungus hits on player (freeze/drain effect)
342   Defines a global counter for turns without combat (healing daemon)
343   Defines a global integer for player's hunger level
344   Defines a global number for group (not used)
345   Defines a global flag for the player's hunger state
346   Defines a global checksum comparison used in copy protection (not used)
347   Declares a global long for random number seed (32-bit in this era)
348   BLANK
349   Defines a global integer for player hit damage multiplier
350   Defines global integer meant for copy protection check (disabled)
351   Defines a global text string meant for copy protection failure
352   Defines a global text string meant for copy protection failure  
353   Defines a global pointer, probably meant for player (appears dead)
354   BLANK
355   COMMENT
356   BLANK
357   Defines a coord struct (x,y pair) for the player's last drawn location
358   Defines a coord struct for the last movement direction
359   BLANK
360   Global pointer to the player's current armor
361   Global pointers to the player's current rings
362   Global pointer to the player's current weapon
363   BLANK
364   Global pointer to a room of interest
365   Global array of level rooms
366   Global array of passage information. These are initialized as null
367   Initializing passage to null
368   Initializing passage to null
369   Initializing passage to null
370   Initializing passage to null
371   Initializing passage to null
372   Initializing passage to null
373   Initializing passage to null
374   Initializing passage to null
375   Initializing passage to null
376   Initializing passage to null
377   Initializing passage to null
378   Initializing passage to null
379   Initializing passage to null
380   Initializing passage to null
381   BLANK
382   Defines a preprocessor macro for the initial player stats
383   BLANK
384   Sets the maximum stats for the player using the previous macro
385   BLANK
386   Global reference for the player
387   Global pointer to the level object linked list
388   Global pointer to the level monster linked list
389   BLANK
390   Preprocessor macro to plug enemy hitpoint values
391   Preprocessor macro to plug enemy strength values
392   Defines the global structure of monster data, including strength,
      experience, level, armor, hitpoints, damage range, and special
	  behavior flags.
393   BLOCK START - Monster data structure
394   COMMENT
395   Aquator stats
396   Bat stats
397   Centaur stats
398   Dragon stats (toughest enemy!)
399   Emu stats
400   COMMENT
401   COMMENT
402   Venus flytrap stats
403   Griffin stats
404   Hobgoblin stats
405   Ice monster stats
406   Jabberwock stats
407   Kestral stats
408   Leprechaun stats
409   Medusa stats
410   Nymph stats
411   Orc stats
412   Phantom stats
413   Quagga stats
414   Rattlesnake stats
415   Slime stats
416   Troll stats
417   Ur-vile stats
418   Vampire stats
419   Wraith stats
420   Xeroc stats
421   Yeti stats
422   Zombie stats
423   BLOCK END - Monster data structure
424   Global string holder for monster damage data
425   Removes preprocessor macro for hitpoints
426   Removes preprocessor macro for strength
427   BLANK
428   Defines the global item probability table by type
429   Potions generate 27% of the time
430   Scrolls generate 30% of the time
431   Food generate 17% of the time
432   Weapons generate 8% of the time
433   Armor generate 8% of the time
434   Rings generate 5% of the time
435   Wands/staves generate 5% of the time
436   End of global item probability data
437   BLANK
438   COMMENT
439   COMMENT
440   COMMENT
441   Global empty string
442   Global reference to the empty string
443   BLANK
444   Global common string
445   Global common string
446   Global common string
447   Global common string
448   Global common string
449   Global common string
450   EOF