annotate rogue4/sticks.c @ 209:4438569c1b02

Merge the MSVC branch.
author John "Elwin" Edwards
date Fri, 27 Nov 2015 08:59:24 -0500
parents 9535a08ddc39
children 1b73a8641b37
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
1 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
2 * Functions to implement the various sticks one might find
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
3 * while wandering around the dungeon.
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
4 *
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
5 * @(#)sticks.c 4.22 (Berkeley) 5/19/82
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
6 *
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
7 * Rogue: Exploring the Dungeons of Doom
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
8 * Copyright (C) 1980, 1981, 1982 Michael Toy, Ken Arnold and Glenn Wichman
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
9 * All rights reserved.
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
10 *
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
11 * See the file LICENSE.TXT for full copyright and licensing information.
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
12 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
13
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
14 #include <curses.h>
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
15 #include <ctype.h>
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
16 #include <string.h>
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
17 #include "rogue.h"
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
18
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
19 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
20 * fix_stick:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
21 * Set up a new stick
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
22 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
23 fix_stick(cur)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
24 register THING *cur;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
25 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
26 if (strcmp(ws_type[cur->o_which], "staff") == 0)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
27 strcpy(cur->o_damage,"2d3");
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
28 else
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
29 strcpy(cur->o_damage,"1d1");
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
30 strcpy(cur->o_hurldmg,"1d1");
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
31
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
32 cur->o_charges = 3 + rnd(5);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
33 switch (cur->o_which)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
34 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
35 case WS_HIT:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
36 cur->o_hplus = 100;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
37 cur->o_dplus = 3;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
38 strcpy(cur->o_damage,"1d8");
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
39 when WS_LIGHT:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
40 cur->o_charges = 10 + rnd(10);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
41 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
42 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
43
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
44 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
45 * do_zap:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
46 * Perform a zap with a wand
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
47 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
48 do_zap()
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
49 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
50 register THING *obj, *tp;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
51 register int y, x;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
52 register char *name;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
53
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
54 if ((obj = get_item("zap with", STICK)) == NULL)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
55 return;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
56 if (obj->o_type != STICK)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
57 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
58 after = FALSE;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
59 msg("you can't zap with that!");
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
60 return;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
61 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
62 if (obj->o_charges == 0)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
63 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
64 msg("nothing happens");
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
65 return;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
66 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
67 switch (obj->o_which)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
68 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
69 case WS_LIGHT:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
70 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
71 * Reddy Kilowat wand. Light up the room
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
72 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
73 ws_know[WS_LIGHT] = TRUE;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
74 if (proom->r_flags & ISGONE)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
75 msg("the corridor glows and then fades");
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
76 else
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
77 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
78 proom->r_flags &= ~ISDARK;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
79 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
80 * Light the room and put the player back up
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
81 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
82 enter_room(&hero);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
83 addmsg("the room is lit");
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
84 if (!terse)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
85 addmsg(" by a shimmering blue light");
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
86 endmsg();
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
87 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
88 when WS_DRAIN:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
89 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
90 * Take away 1/2 of hero's hit points, then take it away
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
91 * evenly from the monsters in the room (or next to hero
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
92 * if he is in a passage)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
93 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
94 if (pstats.s_hpt < 2)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
95 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
96 msg("you are too weak to use it");
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
97 return;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
98 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
99 else
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
100 drain();
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
101 when WS_POLYMORPH:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
102 case WS_TELAWAY:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
103 case WS_TELTO:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
104 case WS_CANCEL:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
105 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
106 register char monster, oldch;