annotate arogue5/rings.c @ 63:0ed67132cf10

Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
author elwin
date Thu, 09 Aug 2012 22:58:48 +0000
parents
children c49f7927b0fa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
1 /*
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
2 * routines dealing specifically with rings
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
3 *
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
4 * Advanced Rogue
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
5 * Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
6 * All rights reserved.
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
7 *
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
8 * Based on "Rogue: Exploring the Dungeons of Doom"
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
10 * All rights reserved.
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
11 *
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
12 * See the file LICENSE.TXT for full copyright and licensing information.
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
13 */
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
14
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
15 #include "curses.h"
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
16 #include "rogue.h"
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
17
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
18 /*
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
19 * how much food does this ring use up?
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
20 */
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
21 ring_eat(hand)
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
22 register int hand;
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
23 {
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
24 if (cur_ring[hand] == NULL)
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
25 return 0;
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
26 switch (cur_ring[hand]->o_which) {
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
27 case R_VAMPREGEN:
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
28 return 3;
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
29 case R_REGEN:
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
30 return 2;
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
31 case R_HEALTH:
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
32 case R_SUSABILITY:
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
33 return 1;
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
34 case R_SEARCH:
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
35 case R_SEEINVIS:
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
36 return (rnd(100) < 33);
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
37 case R_DIGEST:
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
38 if (cur_ring[hand]->o_ac >= 0)
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
39 return (-(cur_ring[hand]->o_ac)-1);
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
40 else
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
41 return (-(cur_ring[hand]->o_ac));
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
42 }
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
43 return 0;
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
44 }
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
45
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
46 ring_on(obj)
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
47 register struct object *obj;
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
48 {
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
49 register int save_max;
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
50 char buf[LINELEN];
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
51
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
52 /*
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
53 * Calculate the effect it has on the poor guy.
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
54 */
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
55 switch (obj->o_which)
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
56 {
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
57 case R_ADDSTR:
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
58 save_max = max_stats.s_str;
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
59 chg_str(obj->o_ac);
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
60 max_stats.s_str = save_max;
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
61 when R_ADDHIT:
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
62 pstats.s_dext += obj->o_ac;
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
63 when R_ADDINTEL:
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
64 pstats.s_intel += obj->o_ac;
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
65 when R_ADDWISDOM:
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
66 pstats.s_wisdom += obj->o_ac;
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
67 when R_SEEINVIS:
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
68 turn_on(player, CANSEE);
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
69 msg("Your eyes begin to tingle");
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
70 light(&hero);
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
71 mvwaddch(cw, hero.y, hero.x, PLAYER);
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
72 when R_AGGR:
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
73 aggravate();
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
74 when R_WARMTH:
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
75 turn_on(player, NOCOLD);
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
76 when R_FIRE:
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
77 turn_on(player, NOFIRE);
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
78 when R_LIGHT: {
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
79 if(roomin(&hero) != NULL) {
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
80 light(&hero);
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
81 mvwaddch(cw, hero.y, hero.x, PLAYER);
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
82 }
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
83 }
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
84 when R_SEARCH:
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
85 daemon(ring_search, 0, AFTER);
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
86 when R_TELEPORT:
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
87 daemon(ring_teleport, 0, AFTER);
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
88 }
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
89 status(FALSE);
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
90 if (r_know[obj->o_which] && r_guess[obj->o_which])
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
91 {
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
92 free(r_guess[obj->o_which]);
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
93 r_guess[obj->o_which] = NULL;
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
94 }
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
95 else if (!r_know[obj->o_which] &&
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
96 askme &&
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
97 (obj->o_flags & ISKNOW) == 0 &&
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
98 r_guess[obj->o_which] == NULL) {
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
99 msg(terse ? "Call it: " : "What do you want to call it? ");
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
100 if (get_str(buf, cw) == NORM)
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
101 {
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
102 r_guess[obj->o_which] = new((unsigned int) strlen(buf) + 1);
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
103 strcpy(r_guess[obj->o_which], buf);