Mercurial > hg > early-roguelike
annotate rogue5/rings.c @ 184:7c059ec2a2c7
Merge Super-Rogue fixes into the MSVC testing branch.
author | John "Elwin" Edwards |
---|---|
date | Sun, 02 Aug 2015 12:25:44 -0400 |
parents | f502bf60e6e4 |
children |
rev | line source |
---|---|
33
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
1 /* |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
2 * Routines dealing specifically with rings |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
3 * |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
4 * @(#)rings.c 4.19 (Berkeley) 05/29/83 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
5 * |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
6 * Rogue: Exploring the Dungeons of Doom |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
7 * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
8 * All rights reserved. |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
9 * |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
10 * See the file LICENSE.TXT for full copyright and licensing information. |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
11 */ |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
12 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
13 #include <curses.h> |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
14 #include "rogue.h" |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
15 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
16 /* |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
17 * ring_on: |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
18 * Put a ring on a hand |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
19 */ |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
20 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
21 void |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
22 ring_on(void) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
23 { |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
24 THING *obj; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
25 int ring; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
26 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
27 obj = get_item("put on", RING); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
28 /* |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
29 * Make certain that it is somethings that we want to wear |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
30 */ |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
31 if (obj == NULL) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
32 return; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
33 if (obj->o_type != RING) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
34 { |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
35 if (!terse) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
36 msg("it would be difficult to wrap that around a finger"); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
37 else |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
38 msg("not a ring"); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
39 return; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
40 } |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
41 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
42 /* |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
43 * find out which hand to put it on |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
44 */ |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
45 if (is_current(obj)) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
46 return; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
47 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
48 if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
49 { |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
50 if ((ring = gethand()) < 0) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
51 return; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
52 } |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
53 else if (cur_ring[LEFT] == NULL) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
54 ring = LEFT; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
55 else if (cur_ring[RIGHT] == NULL) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
56 ring = RIGHT; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
57 else |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
58 { |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
59 if (!terse) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
60 msg("you already have a ring on each hand"); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
61 else |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
62 msg("wearing two"); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
63 return; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
64 } |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
65 cur_ring[ring] = obj; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
66 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
67 /* |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
68 * Calculate the effect it has on the poor guy. |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
69 */ |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
70 switch (obj->o_which) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
71 { |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
72 case R_ADDSTR: |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
73 chg_str(obj->o_arm); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
74 break; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
75 case R_SEEINVIS: |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
76 invis_on(); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
77 break; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
78 case R_AGGR: |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
79 aggravate(); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
80 break; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
81 } |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
82 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
83 if (!terse) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
84 addmsg("you are now wearing "); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
85 msg("%s (%c)", inv_name(obj, TRUE), obj->o_packch); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
86 } |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
87 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
88 /* |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
89 * ring_off: |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
90 * take off a ring |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
91 */ |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
92 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
93 void |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
94 ring_off(void) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
95 { |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
96 int ring; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
97 THING *obj; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
98 |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
99 if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
100 { |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
101 if (terse) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
102 msg("no rings"); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
103 else |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
104 msg("you aren't wearing any rings"); |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
105 return; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
106 } |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
107 else if (cur_ring[LEFT] == NULL) |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
108 ring = RIGHT; |
f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
109 else if (cur_ring[RIGHT] == NULL) |