Commit | Line | Data |
---|---|---|
6bd0a3e3 | 1 | #ifndef lint |
a7c71d1e | 2 | static char sccsid[] = "@(#)com1.c 1.2 %G%"; |
6bd0a3e3 EW |
3 | #endif |
4 | ||
5 | #include "externs.h" | |
6 | ||
7 | move(thataway, token) | |
8 | int thataway, token; | |
9 | { | |
10 | wordnumber++; | |
11 | if ((!notes[CANTMOVE] && !notes[LAUNCHED]) || testbit(location[position].objects, LAND) || fuel > 0 && notes[LAUNCHED]) | |
12 | if (thataway) { | |
13 | position = thataway; | |
14 | newway(token); | |
15 | time++; | |
16 | } | |
17 | else { | |
18 | puts("You can't go this way."); | |
19 | newway(token); | |
20 | whichway(location[position]); | |
21 | return(0); | |
22 | } | |
23 | else if (notes[CANTMOVE] && !notes[LAUNCHED]) | |
a7c71d1e | 24 | puts("You aren't able to move; you better drop something."); |
6bd0a3e3 | 25 | else |
a7c71d1e | 26 | puts("You are out of fuel; now you will rot in space forever!"); |
6bd0a3e3 EW |
27 | return(1); |
28 | } | |
29 | ||
30 | convert(tothis) /* Converts day to night and vice versa. */ | |
31 | int tothis; /* Day objects are permanent. Night objects are added*/ | |
32 | { /* at dusk, and subtracted at dawn. */ | |
33 | register struct objs *p; | |
a7c71d1e | 34 | register i, j; |
6bd0a3e3 | 35 | |
a7c71d1e EW |
36 | if (tothis == TONIGHT) { |
37 | for (i = 1; i <= NUMOFROOMS; i++) | |
38 | for (j = 0; j < NUMOFWORDS; j++) | |
39 | nightfile[i].objects[j] = dayfile[i].objects[j]; | |
6bd0a3e3 | 40 | for (p = nightobjs; p->room != 0; p++) |
a7c71d1e EW |
41 | setbit(nightfile[p->room].objects, p->obj); |
42 | location = nightfile; | |
6bd0a3e3 | 43 | } else { |
a7c71d1e EW |
44 | for (i = 1; i <= NUMOFROOMS; i++) |
45 | for (j = 0; j < NUMOFWORDS; j++) | |
46 | dayfile[i].objects[j] = nightfile[i].objects[j]; | |
6bd0a3e3 | 47 | for (p = nightobjs; p->room != 0; p++) |
a7c71d1e EW |
48 | clearbit(dayfile[p->room].objects, p->obj); |
49 | location = dayfile; | |
6bd0a3e3 EW |
50 | } |
51 | } | |
52 | ||
53 | news() | |
54 | { | |
55 | register int n; | |
56 | int hurt; | |
57 | ||
58 | if (time > 30 && position < 32){ | |
59 | puts("An explosion of shuddering magnitude splinters bulkheads and"); | |
60 | puts("ruptures the battlestar's hull. You are sucked out into the"); | |
a7c71d1e | 61 | puts("frozen void of space and killed."); |
6bd0a3e3 EW |
62 | die(); |
63 | } | |
64 | if (time > 20 && position < 32) | |
65 | puts("Explosions rock the battlestar."); | |
66 | if (time > snooze){ | |
67 | puts("You drop from exhaustion..."); | |
68 | zzz(); | |
69 | } | |
70 | if (time > snooze - 5) | |
a7c71d1e EW |
71 | puts("You're getting tired."); |
72 | if (time > (rythmn + CYCLE)) { | |
73 | if (location == nightfile) { | |
74 | convert(TODAY); | |
75 | if (OUTSIDE && time - rythmn - CYCLE < 10) { | |
76 | puts("Dew lit sunbeams stretch out from a watery sunrise and herald the dawn."); | |
77 | puts("You awake from a misty dream-world into stark reality."); | |
78 | puts("It is day."); | |
79 | } | |
80 | } else { | |
81 | convert(TONIGHT); | |
82 | clearbit(location[POOLS].objects, BATHGOD); | |
83 | if (OUTSIDE && time - rythmn - CYCLE < 10) { | |
84 | puts("The dying sun sinks into the ocean, leaving a blood stained sunset."); | |
85 | puts("The sky slowly fades from orange to violet to black. A few stars"); | |
86 | puts("flicker on, and it is night."); | |
87 | puts("The world seems completly different at night."); | |
88 | } | |
6bd0a3e3 | 89 | } |
a7c71d1e | 90 | rythmn = time - time % CYCLE; |
6bd0a3e3 EW |
91 | } |
92 | if (!wiz && !tempwiz) | |
93 | if ((testbit(inven,TALISMAN) || testbit(wear,TALISMAN)) && (testbit(inven,MEDALION) || testbit(wear,MEDALION)) && (testbit(inven,AMULET) || testbit(wear,AMULET))){ | |
94 | tempwiz = 1; | |
a7c71d1e | 95 | puts("The three amulets glow and reenforce each other in power.\nYou are now a wizard."); |
6bd0a3e3 EW |
96 | } |
97 | if (testbit(location[position].objects,ELF)){ | |
98 | printf("%s\n",objdes[ELF]); | |
99 | fight(ELF,rnd(30)); | |
100 | } | |
101 | if (testbit(location[position].objects,DARK)){ | |
102 | printf("%s\n",objdes[DARK]); | |
103 | fight(DARK,100); | |
104 | } | |
105 | if (testbit(location[position].objects,WOODSMAN)){ | |
106 | printf("%s\n",objdes[WOODSMAN]); | |
107 | fight(WOODSMAN,50); | |
108 | } | |
109 | switch(position){ | |
110 | ||
111 | case 267: | |
112 | case 257: /* entering a cave */ | |
113 | case 274: | |
114 | case 246: | |
115 | notes[CANTSEE] = 1; | |
116 | break; | |
117 | case 160: | |
118 | case 216: /* leaving a cave */ | |
119 | case 230: | |
120 | case 231: | |
121 | case 232: | |
122 | notes[CANTSEE] = 0; | |
123 | break; | |
124 | } | |
125 | if (testbit(location[position].objects, GIRL)) | |
126 | meetgirl = 1; | |
127 | if (meetgirl && CYCLE * 1.5 - time < 10){ | |
128 | setbit(location[GARDEN].objects,GIRLTALK); | |
129 | setbit(location[GARDEN].objects,LAMPON); | |
130 | setbit(location[GARDEN].objects,ROPE); | |
131 | } | |
132 | if (position == DOCK && (beenthere[position] || time > CYCLE)){ | |
133 | clearbit(location[DOCK].objects, GIRL); | |
134 | clearbit(location[DOCK].objects,MAN); | |
135 | } | |
136 | if (meetgirl && time - CYCLE * 1.5 > 10){ | |
137 | clearbit(location[GARDEN].objects,GIRLTALK); | |
138 | clearbit(location[GARDEN].objects,LAMPON); | |
139 | clearbit(location[GARDEN].objects,ROPE); | |
140 | meetgirl = 0; | |
141 | } | |
142 | if (testbit(location[position].objects,CYLON)){ | |
143 | puts("Oh my God, you're being shot at by an alien spacecraft!"); | |
144 | printf("The targeting computer says we have %d seconds to attack!\n",clock); | |
145 | fflush(stdout); | |
a7c71d1e | 146 | sleep(1); |
6bd0a3e3 EW |
147 | if (!visual()){ |
148 | hurt = rnd(NUMOFINJURIES); | |
149 | injuries[hurt] = 1; | |
a7c71d1e | 150 | puts("Laser blasts sear the cockpit, and the alien veers off in a victory roll."); |
6bd0a3e3 EW |
151 | puts("The viper shudders under a terrible explosion."); |
152 | printf("I'm afraid you have suffered %s.\n", ouch[hurt]); | |
153 | } | |
154 | else | |
155 | clearbit(location[position].objects,CYLON); | |
156 | } | |
157 | if (injuries[SKULL] && injuries[INCISE] && injuries[NECK]){ | |
158 | puts("I'm afraid you have suffered fatal injuries."); | |
159 | die(); | |
160 | } | |
161 | for (n=0; n < NUMOFINJURIES; n++) | |
162 | if (injuries[n] == 1){ | |
163 | injuries[n] = 2; | |
164 | if (WEIGHT > 5) | |
165 | WEIGHT -= 5; | |
166 | else | |
167 | WEIGHT = 0; | |
168 | } | |
169 | if (injuries[ARM] == 2){ | |
170 | CUMBER -= 5; | |
171 | injuries[ARM]++; | |
172 | } | |
173 | if (injuries[RIBS] == 2){ | |
174 | CUMBER -= 2; | |
175 | injuries[RIBS]++; | |
176 | } | |
177 | if (injuries[SPINE] == 2){ | |
178 | WEIGHT = 0; | |
179 | injuries[SPINE]++; | |
180 | } | |
181 | if (carrying > WEIGHT || encumber > CUMBER) | |
182 | notes[CANTMOVE] = 1; | |
183 | else | |
184 | notes[CANTMOVE] = 0; | |
185 | } | |
186 | ||
187 | crash() | |
188 | { | |
189 | int hurt1,hurt2; | |
190 | ||
191 | fuel--; | |
192 | if (!location[position].flyhere || (testbit(location[position].objects,LAND) && fuel <= 0)){ | |
193 | if (!location[position].flyhere) | |
194 | puts("You're flying too low. We're going to crash!"); | |
195 | else{ | |
196 | puts("You're out of fuel. We'll have to crash land!"); | |
197 | if (!location[position].down){ | |
a7c71d1e | 198 | puts("Your viper strikes the ground and explodes into firey fragments."); |
6bd0a3e3 EW |
199 | puts("Thick black smoke billows up from the wreckage."); |
200 | die(); | |
201 | } | |
202 | position = location[position].down; | |
203 | } | |
204 | notes[LAUNCHED] = 0; | |
205 | setbit(location[position].objects,CRASH); | |
206 | time += rnd(CYCLE/4); | |
207 | puts("The viper explodes into the ground and you lose consciousness..."); | |
208 | zzz(); | |
209 | hurt1 = rnd(NUMOFINJURIES - 2) + 2; | |
210 | hurt2 = rnd(NUMOFINJURIES - 2) + 2; | |
211 | injuries[hurt1] = 1; | |
212 | injuries[hurt2] = 1; | |
213 | injuries[0] = 1; /* abrasions */ | |
214 | injuries[1] = 1; /* lacerations */ | |
215 | printf("I'm afraid you have suffered %s and %s.\n",ouch[hurt1],ouch[hurt2]); | |
216 | } | |
217 | } |