Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7185 | siemargl | 1 | #include "sst.h" |
2 | |||
3 | #ifdef CLOAKING |
||
4 | void cloak(void) { |
||
5 | int key; |
||
6 | enum {NONE, CLON, CLOFF} action = NONE; |
||
7 | |||
8 | if (ship == IHF) { |
||
9 | /* prout("Ye Faerie Queene has no cloaking device.");*/ |
||
10 | prout("На Королеве Фей не установлен генератор невидимости."); |
||
11 | return; |
||
12 | } |
||
13 | |||
14 | key = scan(); |
||
15 | |||
16 | if (key == IHREAL) return; |
||
17 | |||
18 | if (key == IHALPHA) { |
||
19 | if (isit("on")) { |
||
20 | if (iscloaked) { |
||
21 | /* prout("The cloaking device has already been switched on.");*/ |
||
22 | prout("Генератор невидимости уже был включен."); |
||
23 | return; |
||
24 | } |
||
25 | action = CLON; |
||
26 | } |
||
27 | else if (isit("off")) { |
||
28 | if (!iscloaked) { |
||
29 | /* prout("The cloaking device has already been switched off.");*/ |
||
30 | prout("Генератор невидимости уже включен."); |
||
31 | return; |
||
32 | } |
||
33 | action = CLOFF; |
||
34 | } |
||
35 | else { |
||
36 | huh(); |
||
37 | return; |
||
38 | } |
||
39 | } else { |
||
40 | if (!iscloaked) { |
||
41 | /* proutn("Switch cloaking device on?");*/ |
||
42 | prout("Включить генератор невидимости?"); |
||
43 | if (ja()==0) return; |
||
44 | action = CLON; |
||
45 | } |
||
46 | if (iscloaked) { |
||
47 | /* proutn("Switch cloaking device off?");*/ |
||
48 | prout("Отключить генератор невидимости?"); |
||
49 | if (ja()==0) return; |
||
50 | action = CLOFF; |
||
51 | } |
||
52 | if (action == NONE) return; |
||
53 | } |
||
54 | |||
55 | if (action==CLOFF) { |
||
56 | if (irhere && d.date >= ALGERON && !isviolreported) { |
||
57 | /* prout("Spock- \"Captain, the Treaty of Algeron is in effect.\n Are you sure this is wise?\"");*/ |
||
58 | prout("Спок- \"Капитан, мы в зоне действия Алгеронского соглашения.\n Вы уверены, что это разумно?\""); |
||
59 | if (ja() == 0) return; |
||
60 | } |
||
61 | /* prout("Engineer Scott- \"Aye, Sir.\"");*/ |
||
62 | prout("Engineer Scott- \"Так точно, Сэр.\""); |
||
63 | iscloaked = FALSE; |
||
64 | if (irhere && d.date >= ALGERON && !isviolreported) { |
||
65 | /* prout("The Romulan ship discovers you are breaking the Treaty of Algeron!");*/ |
||
66 | prout("Корабль Ромуланцев обнаружил, что вы нарушили Алгеронское соглашение!"); |
||
67 | ncviol++; |
||
68 | isviolreported = TRUE; |
||
69 | } |
||
70 | |||
71 | // if (neutz && d.date >= ALGERON) finish(FCLOAK); |
||
72 | return; |
||
73 | } |
||
74 | |||
75 | if (damage[DCLOAK]!=0) { |
||
76 | /* prout("Engineer Scott- \"The cloaking device is damaged, Sir.\"");*/ |
||
77 | prout("Инженер Скотт- \"Генератор невидимости поврежден, Сэр.\""); |
||
78 | return; |
||
79 | } |
||
80 | |||
81 | if (condit==IHDOCKED) { |
||
82 | /* prout("You cannot cloak while docked.");*/ |
||
83 | prout("При стыковке невозможно включать генератор невидимости."); |
||
84 | return; |
||
85 | } |
||
86 | |||
87 | if (d.date >= ALGERON && !isviolreported) |
||
88 | { |
||
89 | /* prout("Spock- \"Captain, using the cloaking device is be a violation"); |
||
90 | prout(" of the Treaty of Algeron. Considering the alternatives,"); |
||
91 | proutn(" are you sure this is wise?");*/ |
||
92 | prout("Спок- \"Капитан, использование генератора невидимости будет нарушением"); |
||
93 | prout(" Алгеронского соглашения. Рассмотрите альтернативы,"); |
||
94 | proutn(" Вы уверены, что это разумно?"); |
||
95 | if (ja()==0) return; |
||
96 | } |
||
97 | |||
98 | /* prout("Engineer Scott- \"The cloaking device has been engaged, Sir.\"");*/ |
||
99 | prout("Инженер Скотт- \"Генератор невидимости активирован, Сэр.\""); |
||
100 | iscloaking = TRUE; |
||
101 | if (irhere && d.date >= ALGERON && !isviolreported) { |
||
102 | /* prout("The Romulan ship discovers you are breaking the Treaty of Algeron!");*/ |
||
103 | prout("Корабль Ромуланцев обнаружил, что вы нарушили Алгеронское соглашение!"); |
||
104 | ncviol++; |
||
105 | isviolreported = TRUE; |
||
106 | } |
||
107 | } |
||
108 | #endif |
||
109 | |||
110 | void sheild(int i) { |
||
111 | int key; |
||
112 | enum {NONE, SHUP, SHDN, NRG} action = NONE; |
||
113 | |||
114 | ididit = 0; |
||
115 | |||
116 | if (i == 2) action = SHUP; |
||
117 | else { |
||
118 | key = scan(); |
||
119 | if (key == IHALPHA) { |
||
120 | if (isit("transfer")) |
||
121 | action = NRG; |
||
122 | else { |
||
123 | chew(); |
||
124 | if (damage[DSHIELD]) { |
||
125 | prout("Щиты пробиты и отключились.");/*Shields damaged and down.*/ |
||
126 | return; |
||
127 | } |
||
128 | if (isit("up")) |
||
129 | action = SHUP; |
||
130 | else if (isit("down")) |
||
131 | action = SHDN; |
||
132 | } |
||
133 | } |
||
134 | if (action==NONE) { |
||
135 | proutn("Вы хотите изменить напряженность силовых щитов? ");/*Do you wish to change shield energy?*/ |
||
136 | if (ja()) { |
||
137 | proutn("Энергии передать на щиты- ");/*Energy to transfer to shields*/ |
||
138 | action = NRG; |
||
139 | } |
||
140 | else if (damage[DSHIELD]) { |
||
141 | prout("Щиты пробиты и отключились.");/*Shields damaged and down*/ |
||
142 | return; |
||
143 | } |
||
144 | else if (shldup) { |
||
145 | /* proutn("Shields are up. Do you want them down? ");*/ |
||
146 | proutn("Щиты включены, хотите погасить их? "); |
||
147 | if (ja()) action = SHDN; |
||
148 | else { |
||
149 | chew(); |
||
150 | return; |
||
151 | } |
||
152 | } |
||
153 | else { |
||
154 | /* proutn("Shields are down. Do you want them up? ");*/ |
||
155 | proutn("Щиты погашены, хотите активировать их? "); |
||
156 | if (ja()) action = SHUP; |
||
157 | else { |
||
158 | chew(); |
||
159 | return; |
||
160 | } |
||
161 | } |
||
162 | } |
||
163 | } |
||
164 | switch (action) { |
||
165 | case SHUP: /* raise shields */ |
||
166 | if (shldup) { |
||
167 | /* prout("Shields already up.");*/ |
||
168 | prout("Силовые щиты уже активированы."); |
||
169 | return; |
||
170 | } |
||
171 | shldup = 1; |
||
172 | shldchg = 1; |
||
173 | if (condit != IHDOCKED) energy -= 50.0; |
||
174 | prout("Силовые щиты активированы.");/*Shields raised*/ |
||
175 | if (energy <= 0) { |
||
176 | skip(1); |
||
177 | /* prout("Shields raising uses up last of energy.");*/ |
||
178 | prout("На активацию щитов потрачена вся энергия."); |
||
179 | finish(FNRG); |
||
180 | return; |
||
181 | } |
||
182 | ididit=1; |
||
183 | return; |
||
184 | case SHDN: |
||
185 | if (shldup==0) { |
||
186 | prout("Силовые щиты уже погашены."); /*Shields already down*/ |
||
187 | return; |
||
188 | } |
||
189 | shldup=0; |
||
190 | shldchg=1; |
||
191 | prout("Напряженность силовых щитов понижена.");/*Shields lowered*/ |
||
192 | ididit=1; |
||
193 | return; |
||
194 | case NRG: |
||
195 | while (scan() != IHREAL) { |
||
196 | chew(); |
||
197 | /* proutn("Energy to transfer to shields- ");*/ |
||
198 | proutn("Сколько энергии подать на щиты- "); |
||
199 | } |
||
200 | chew(); |
||
201 | if (aaitem==0) return; |
||
202 | if (aaitem > energy) { |
||
203 | prout("Недостаточно энергии на корабле.");/*Insufficient ship energy*/ |
||
204 | return; |
||
205 | } |
||
206 | ididit = 1; |
||
207 | if (shield+aaitem >= inshld) { |
||
208 | prout("Напряженность силовых щитов достигла максимума.");/*Shield energy maximized*/ |
||
209 | if (shield+aaitem > inshld) { |
||
210 | /* prout("Excess energy requested returned to ship energy");*/ |
||
211 | prout("Избыток запрошенной энергии возвращен"); |
||
212 | } |
||
213 | energy -= inshld-shield; |
||
214 | shield = inshld; |
||
215 | return; |
||
216 | } |
||
217 | if (aaitem < 0.0 && energy-aaitem > inenrg) { |
||
218 | /* Prevent shield drain loophole */ |
||
219 | skip(1); |
||
220 | /* prout("Engineering to bridge--"); |
||
221 | prout(" Scott here. Power circuit problem, Captain."); |
||
222 | prout(" I can't drain the shields.");*/ |
||
223 | prout("Инженерный докладывает--"); |
||
224 | prout(" Это Скотт. У нас проблема с силовыми кабелями, Капитан."); |
||
225 | prout(" Я не могу дренировать силовые щиты."); |
||
226 | ididit = 0; |
||
227 | return; |
||
228 | } |
||
229 | if (shield+aaitem < 0) { |
||
230 | /* prout("All shield energy transferred to ship.");*/ |
||
231 | prout("Энергия силовых щитов возвращена на корабль."); |
||
232 | energy += shield; |
||
233 | shield = 0.0; |
||
234 | return; |
||
235 | } |
||
236 | proutn("Скотт- \""); /*Scotty*/ |
||
237 | if (aaitem > 0) |
||
238 | /* prout("Transferring energy to shields.\"");*/ |
||
239 | prout("Передаем энергию на силовые щиты.\""); |
||
240 | else |
||
241 | /* prout("Draining energy from shields.\"");*/ |
||
242 | prout("Дренируем энергию с силовых щитов.\""); |
||
243 | shield += aaitem; |
||
244 | energy -= aaitem; |
||
245 | return; |
||
246 | case NONE: break; |
||
247 | } |
||
248 | } |
||
249 | |||
250 | void ram(int ibumpd, int ienm, int ix, int iy) { |
||
251 | double type = 1.0, extradm; |
||
252 | int icas, l; |
||
253 | |||
254 | prouts("***ОПАСНОСТЬ! ОПАСНОСТЬ!");/*RED ALERT! RED ALERT!*/ |
||
255 | skip(1); |
||
256 | prout("***НЕИЗБЕЖНОЕ СТОЛКНОВЕНИЕ.");/*COLLISION IMMINENT*/ |
||
257 | skip(2); |
||
258 | proutn("***"); |
||
259 | crmshp(); |
||
260 | switch (ienm) { |
||
261 | case IHR: type = 1.5; break; |
||
262 | case IHC: type = 2.0; break; |
||
263 | case IHS: type = 2.5; break; |
||
264 | case IHT: type = 0.5; break; |
||
265 | } |
||
266 | /* proutn(ibumpd ? " rammed by " : " rams ");*/ |
||
267 | proutn(ibumpd ? " столкновение в точке" : " ударов "); |
||
268 | crmena(0, ienm, 2, ix, iy); |
||
269 | if (ibumpd) proutn(" (оригинальное положение)");/*(original position)*/ |
||
270 | skip(1); |
||
271 | deadkl(ix, iy, ienm, sectx, secty); |
||
272 | proutn("***"); |
||
273 | crmshp(); |
||
274 | prout(" тяжело повреждено.");/*heavily damaged*/ |
||
275 | icas = 10.0+20.0*Rand(); |
||
276 | proutn("***Медотсек докладывает ");/*Sickbay reports*/ |
||
277 | crami(icas, 1); |
||
278 | prout(" смертей.");/*casualties*/ |
||
279 | casual += icas; |
||
280 | for (l=1; l <= ndevice; l++) { |
||
281 | if (l == DDRAY) continue; // Don't damage deathray |
||
282 | if (damage[l] < 0) continue; |
||
283 | extradm = (10.0*type*Rand()+1.0)*damfac; |
||
284 | damage[l] += Time + extradm; /* Damage for at least time of travel! */ |
||
285 | } |
||
286 | shldup = 0; |
||
287 | if (d.remkl) { |
||
288 | pause(2); |
||
289 | dreprt(); |
||
290 | } |
||
291 | else finish(FWON); |
||
292 | return; |
||
293 | } |
||
294 | |||
295 | void torpedo(double course, double r, int inx, int iny, double *hit) { |
||
296 | int l, iquad, ix, iy, jx, jy, shoved=0, ll; |
||
297 | double ac=course + 0.25*r; |
||
298 | double angle = (15.0-ac)*0.5235988; |
||
299 | double bullseye = (15.0 - course)*0.5235988; |
||
300 | double deltax=-sin(angle), deltay=cos(angle), x=inx, y=iny, bigger; |
||
301 | double ang, temp, xx, yy, kp, h1; |
||
302 | |||
303 | bigger = fabs(deltax); |
||
304 | if (fabs(deltay) > bigger) bigger = fabs(deltay); |
||
305 | deltax /= bigger; |
||
306 | deltay /= bigger; |
||
307 | |||
308 | /* Loop to move a single torpedo */ |
||
309 | for (l=1; l <= 15; l++) { |
||
310 | x += deltax; |
||
311 | ix = x + 0.5; |
||
312 | if (ix < 1 || ix > 10) break; |
||
313 | y += deltay; |
||
314 | iy = y + 0.5; |
||
315 | if (iy < 1 || iy > 10) break; |
||
316 | if (l==4 || l==9) skip(1); |
||
317 | cramf(x, 0, 1); |
||
318 | proutn(" - "); |
||
319 | cramf(y, 0, 1); |
||
320 | proutn(" "); |
||
321 | iquad=quad[ix][iy]; |
||
322 | if (iquad==IHDOT) continue; |
||
323 | /* hit something */ |
||
324 | skip(1); |
||
325 | switch(iquad) { |
||
326 | case IHE: /* Hit our ship */ |
||
327 | case IHF: |
||
328 | skip(1); |
||
329 | proutn("Торпеда попала в ");/*Torpedo hits*/ |
||
330 | crmshp(); |
||
331 | prout("."); |
||
332 | *hit = 700.0 + 100.0*Rand() - |
||
333 | 1000.0*sqrt(square(ix-inx)+square(iy-iny))* |
||
334 | fabs(sin(bullseye-angle)); |
||
335 | *hit = fabs(*hit); |
||
336 | newcnd(); /* undock */ |
||
337 | /* We may be displaced. */ |
||
338 | if (landed==1) return; /* Cheat if on a planet */ |
||
339 | ang = angle + 2.5*(Rand()-0.5); |
||
340 | temp = fabs(sin(ang)); |
||
341 | if (fabs(cos(ang)) > temp) temp = fabs(cos(ang)); |
||
342 | xx = -sin(ang)/temp; |
||
343 | yy = cos(ang)/temp; |
||
344 | jx=ix+xx+0.5; |
||
345 | jy=iy+yy+0.5; |
||
346 | if (jx<1 || jx>10 || jy<1 ||jy > 10) return; |
||
347 | if (quad[jx][jy]==IHBLANK) { |
||
348 | finish(FHOLE); |
||
349 | return; |
||
350 | } |
||
351 | if (quad[jx][jy]!=IHDOT) { |
||
352 | /* can't move into object */ |
||
353 | return; |
||
354 | } |
||
355 | sectx = jx; |
||
356 | secty = jy; |
||
357 | crmshp(); |
||
358 | shoved = 1; |
||
359 | break; |
||
360 | |||
361 | case IHC: /* Hit a commander */ |
||
362 | case IHS: |
||
363 | if (Rand() <= 0.05) { |
||
364 | crmena(1, iquad, 2, ix, iy); |
||
365 | prout(" использовано анти-фотонное устройство;");/*uses anti-photon device*/ |
||
366 | prout(" торпеда нейтрализована.");/*torpedo neutralized*/ |
||
367 | return; |
||
368 | } |
||
369 | case IHR: /* Hit a regular enemy */ |
||
370 | case IHK: |
||
371 | /* find the enemy */ |
||
372 | for (ll=1; ll <= nenhere; ll++) |
||
373 | if (ix==kx[ll] && iy==ky[ll]) break; |
||
374 | kp = fabs(kpower[ll]); |
||
375 | h1 = 700.0 + 100.0*Rand() - |
||
376 | 1000.0*sqrt(square(ix-inx)+square(iy-iny))* |
||
377 | fabs(sin(bullseye-angle)); |
||
378 | h1 = fabs(h1); |
||
379 | if (kp < h1) h1 = kp; |
||
380 | kpower[ll] -= (kpower[ll]<0 ? -h1 : h1); |
||
381 | if (kpower[ll] == 0) { |
||
382 | deadkl(ix, iy, iquad, ix, iy); |
||
383 | return; |
||
384 | } |
||
385 | crmena(1, iquad, 2, ix, iy); |
||
386 | /* If enemy damaged but not destroyed, try to displace */ |
||
387 | ang = angle + 2.5*(Rand()-0.5); |
||
388 | temp = fabs(sin(ang)); |
||
389 | if (fabs(cos(ang)) > temp) temp = fabs(cos(ang)); |
||
390 | xx = -sin(ang)/temp; |
||
391 | yy = cos(ang)/temp; |
||
392 | jx=ix+xx+0.5; |
||
393 | jy=iy+yy+0.5; |
||
394 | if (jx<1 || jx>10 || jy<1 ||jy > 10) { |
||
395 | prout(" поврежден, но не уничтожен.");/*damaged but not destroyed*/ |
||
396 | return; |
||
397 | } |
||
398 | if (quad[jx][jy]==IHBLANK) { |
||
399 | prout(" отправлен в черную дыру.");/*buffeted into black hole*/ |
||
400 | deadkl(ix, iy, iquad, jx, jy); |
||
401 | return; |
||
402 | } |
||
403 | if (quad[jx][jy]!=IHDOT) { |
||
404 | /* can't move into object */ |
||
405 | prout(" поврежден, но не уничтожен.");/*damaged but not destroyed*/ |
||
406 | return; |
||
407 | } |
||
408 | prout(" поврежден--");/*damaged*/ |
||
409 | kx[ll] = jx; |
||
410 | ky[ll] = jy; |
||
411 | shoved = 1; |
||
412 | break; |
||
413 | case IHB: /* Hit a base */ |
||
414 | prout("***СТАНЦИЯ УНИЧТОЖЕНА..");/*STARBASE DESTROYED*/ |
||
415 | if (starch[quadx][quady] < 0) starch[quadx][quady] = 0; |
||
416 | for (ll=1; ll<=d.rembase; ll++) { |
||
417 | if (d.baseqx[ll]==quadx && d.baseqy[ll]==quady) { |
||
418 | d.baseqx[ll]=d.baseqx[d.rembase]; |
||
419 | d.baseqy[ll]=d.baseqy[d.rembase]; |
||
420 | break; |
||
421 | } |
||
422 | } |
||
423 | quad[ix][iy]=IHDOT; |
||
424 | d.rembase--; |
||
425 | basex=basey=0; |
||
426 | d.galaxy[quadx][quady] -= 10; |
||
427 | d.basekl++; |
||
428 | newcnd(); |
||
429 | return; |
||
430 | case IHP: /* Hit a planet */ |
||
431 | crmena(1, iquad, 2, ix, iy); |
||
432 | prout(" уничтожена.");/*destroyed*/ |
||
433 | d.nplankl++; |
||
434 | d.newstuf[quadx][quady] -= 1; |
||
435 | d.plnets[iplnet] = nulplanet; |
||
436 | iplnet = 0; |
||
437 | plnetx = plnety = 0; |
||
438 | quad[ix][iy] = IHDOT; |
||
439 | if (landed==1) { |
||
440 | /* captain parishes on planet */ |
||
441 | finish(FDPLANET); |
||
442 | } |
||
443 | return; |
||
444 | case IHSTAR: /* Hit a star */ |
||
445 | if (Rand() > 0.10) { |
||
446 | nova(ix, iy); |
||
447 | return; |
||
448 | } |
||
449 | crmena(1, IHSTAR, 2, ix, iy); |
||
450 | prout(" нечувствительна к фотонному взрыву.");/*unaffected by photon blast*/ |
||
451 | return; |
||
452 | case IHQUEST: /* Hit a thingy */ |
||
453 | skip(1); |
||
454 | /* prouts("AAAAIIIIEEEEEEEEAAAAAAAAUUUUUGGGGGHHHHHHHHHHHH!!!");*/ |
||
455 | prouts("УУУУУРРРРРРРРРРРРРРРРРРААААААААААААААААААААААА!!!"); |
||
456 | skip(1); |
||
457 | /* prouts(" HACK! HACK! HACK! *CHOKE!* ");*/ |
||
458 | prouts(" ХЛОП! ХЛОП! ХЛОП! *ШЛЕП!* "); |
||
459 | skip(1); |
||
460 | /* proutn("Mr. Spock-"); |
||
461 | prouts(" \"Facinating!\"");*/ |
||
462 | proutn("Мистер Спок-"); |
||
463 | prouts(" \"Великолепно!\""); |
||
464 | skip(1); |
||
465 | quad[ix][iy] = IHDOT; |
||
466 | return; |
||
467 | case IHBLANK: /* Black hole */ |
||
468 | skip(1); |
||
469 | crmena(1, IHBLANK, 2, ix, iy); |
||
470 | prout(" поглотила торпеду.");/*swallows torpedo*/ |
||
471 | return; |
||
472 | case IHWEB: /* hit the web */ |
||
473 | skip(1); |
||
474 | prout("***Торпеда попала в Толианскую сеть.");/*Torpedo absorbed by Tholian web*/ |
||
475 | return; |
||
476 | case IHT: /* Hit a Tholian */ |
||
477 | skip(1); |
||
478 | crmena(1, IHT, 2, ix, iy); |
||
479 | h1 = 700.0 + 100.0*Rand() - |
||
480 | 1000.0*sqrt(square(ix-inx)+square(iy-iny))* |
||
481 | fabs(sin(bullseye-angle)); |
||
482 | h1 = fabs(h1); |
||
483 | if (h1 >= 600) { |
||
484 | prout(" уничтожен.");/*destroyed*/ |
||
485 | quad[ix][iy] = IHDOT; |
||
486 | ithere = 0; |
||
487 | ithx = ithy = 0; |
||
488 | return; |
||
489 | } |
||
490 | if (Rand() > 0.05) { |
||
491 | prout(" пережил фотонный взрыв.");/*survives photon blast*/ |
||
492 | return; |
||
493 | } |
||
494 | prout(" исчез.");/*disappears*/ |
||
495 | quad[ix][iy] = IHWEB; |
||
496 | ithere = ithx = ithy = 0; |
||
497 | { |
||
498 | int dum, my; |
||
499 | dropin(IHBLANK, &dum, &my); |
||
500 | } |
||
501 | return; |
||
502 | |||
503 | default: /* Problem! */ |
||
504 | skip(1); |
||
505 | /* proutn("Don't know how to handle collision with ");*/ |
||
506 | proutn("Не знаю, как обработать столкновение с "); |
||
507 | crmena(1, iquad, 2, ix, iy); |
||
508 | skip(1); |
||
509 | return; |
||
510 | } |
||
511 | break; |
||
512 | } |
||
513 | if (shoved) { |
||
514 | quad[jx][jy]=iquad; |
||
515 | quad[ix][iy]=IHDOT; |
||
516 | proutn(" отброшено взрывом в");/*displaced by blast to*/ |
||
517 | cramlc(2, jx, jy); |
||
518 | skip(1); |
||
519 | for (ll=1; ll<=nenhere; ll++) |
||
520 | kdist[ll] = kavgd[ll] = sqrt(square(sectx-kx[ll])+square(secty-ky[ll])); |
||
521 | sortkl(); |
||
522 | return; |
||
523 | } |
||
524 | skip(1); |
||
525 | prout("Торпеда прошла мимо."); /*Torpedo missed*/ |
||
526 | return; |
||
527 | } |
||
528 | |||
529 | static void fry(double hit) { |
||
530 | double ncrit, extradm; |
||
531 | int ktr=1, l, ll, j, cdam[6], crptr; |
||
532 | |||
533 | /* a critical hit occured */ |
||
534 | if (hit < (275.0-25.0*skill)*(1.0+0.5*Rand())) return; |
||
535 | |||
536 | ncrit = 1.0 + hit/(500.0+100.0*Rand()); |
||
537 | proutn("***КРИТИЧЕСКОЕ ПОПАДАНИЕ--");/*CRITICAL HIT*/ |
||
538 | /* Select devices and cause damage */ |
||
539 | for (l = 1; l <= ncrit; l++) { |
||
540 | do { |
||
541 | j = ndevice*Rand()+1.0; |
||
542 | /* Cheat to prevent shuttle damage unless on ship */ |
||
543 | } while (damage[j] < 0.0 || (j == DSHUTTL && iscraft != 1) || |
||
544 | #ifdef CLOAKING |
||
545 | (j == DCLOAK && ship != IHE) || |
||
546 | #endif |
||
547 | j == DDRAY); |
||
548 | cdam[l] = j; |
||
549 | extradm = (hit*damfac)/(ncrit*(75.0+25.0*Rand())); |
||
550 | damage[j] += extradm; |
||
551 | if (l > 1) { |
||
552 | for (ll=2; ll<=l && j != cdam[ll-1]; ll++) ; |
||
553 | if (ll<=l) continue; |
||
554 | ktr += 1; |
||
555 | if (ktr==3) skip(1); |
||
556 | proutn(" и ");/*and*/ |
||
557 | } |
||
558 | proutn(device[j]); |
||
559 | } |
||
560 | prout(" поврежден.");/*damaged*/ |
||
561 | if (damage[DSHIELD] && shldup) { |
||
562 | prout("***Силовые щиты пробиты и отключены.");/*Shields knocked down*/ |
||
563 | shldup=0; |
||
564 | } |
||
565 | #ifdef CLOAKING |
||
566 | if (damage[DCLOAK] && iscloaked) |
||
567 | { |
||
568 | /* prout("***Cloaking device rendered inoperative.");*/ |
||
569 | prout("***Генератор невидимости вышел из строя."); |
||
570 | iscloaked = FALSE; |
||
571 | } |
||
572 | #endif |
||
573 | } |
||
574 | |||
575 | void attack(int k) { |
||
576 | /* k == 0 forces use of phasers in an attack */ |
||
577 | int percent, ihurt=0, l, i=0, jx, jy, iquad, itflag; |
||
578 | int atackd = 0, attempt = 0; |
||
579 | double hit; |
||
580 | double pfac, dustfac, hitmax=0.0, hittot=0.0, chgfac=1.0, r; |
||
581 | |||
582 | #ifdef CLOAKING |
||
583 | if (iscloaked && !iscloaking) return; // Nothing happens if we are cloaked |
||
584 | #endif |
||
585 | |||
586 | iattak = 1; |
||
587 | if (alldone) return; |
||
588 | #ifdef DEBUG |
||
589 | if (idebug) prout("ATTACK!"); |
||
590 | #endif |
||
591 | |||
592 | if (ithere) movetho(); |
||
593 | |||
594 | if (neutz) { /* The one chance not to be attacked */ |
||
595 | neutz = 0; |
||
596 | return; |
||
597 | } |
||
598 | if (((comhere || ishere) && (justin == 0)) || skill == SEMERITUS) movcom(); |
||
599 | if (nenhere==0) return; |
||
600 | pfac = 1.0/inshld; |
||
601 | if (shldchg == 1) chgfac = 0.25+0.5*Rand(); |
||
602 | skip(1); |
||
603 | if (skill <= SFAIR) i = 2; |
||
604 | for (l=1; l <= nenhere; l++) { |
||
605 | if (kpower[l] < 0) continue; /* too weak to attack */ |
||
606 | /* compute hit strength and diminsh shield power */ |
||
607 | r = Rand(); |
||
608 | /* Increase chance of photon torpedos if docked or enemy energy low */ |
||
609 | if (condit == IHDOCKED) r *= 0.25; |
||
610 | if (kpower[l] < 500) r *= 0.25; |
||
611 | jx = kx[l]; |
||
612 | jy = ky[l]; |
||
613 | iquad = quad[jx][jy]; |
||
614 | itflag = (iquad == IHK && r > 0.0005) || k == 0 || |
||
615 | (iquad==IHC && r > 0.015) || |
||
616 | (iquad==IHR && r > 0.3) || |
||
617 | (iquad==IHS && r > 0.07); |
||
618 | if (itflag) { |
||
619 | /* Enemy uses phasers */ |
||
620 | if (condit == IHDOCKED) continue; /* Don't waste the effort! */ |
||
621 | attempt = 1; /* Attempt to attack */ |
||
622 | dustfac = 0.8+0.05*Rand(); |
||
623 | hit = kpower[l]*pow(dustfac,kavgd[l]); |
||
624 | kpower[l] *= 0.75; |
||
625 | } |
||
626 | else { /* Enemy used photon torpedo */ |
||
627 | double course = 1.90985*atan2((double)secty-jy, (double)jx-sectx); |
||
628 | hit = 0; |
||
629 | proutn("***ТОРПЕДА ЛЕТИТ");/*TORPEDO INCOMING*/ |
||
630 | if (damage[DSRSENS] <= 0.0) { |
||
631 | proutn(" Из точки ");/*From*/ |
||
632 | crmena(0, iquad, i, jx, jy); |
||
633 | } |
||
634 | attempt = 1; |
||
635 | prout("--"); |
||
636 | r = (Rand()+Rand())*0.5 -0.5; |
||
637 | r += 0.002*kpower[l]*r; |
||
638 | torpedo(course, r, jx, jy, &hit); |
||
639 | if (d.remkl==0) finish(FWON); /* Klingons did themselves in! */ |
||
640 | if (d.galaxy[quadx][quady] == 1000 || |
||
641 | alldone) return; /* Supernova or finished */ |
||
642 | if (hit == 0) continue; |
||
643 | } |
||
644 | if (shldup != 0 || shldchg != 0) { |
||
645 | /* shields will take hits */ |
||
646 | double absorb, hitsh, propor = pfac*shield; |
||
647 | if(propor < 0.1) propor = 0.1; |
||
648 | hitsh = propor*chgfac*hit+1.0; |
||
649 | atackd=1; |
||
650 | absorb = 0.8*hitsh; |
||
651 | if (absorb > shield) absorb = shield; |
||
652 | shield -= absorb; |
||
653 | hit -= hitsh; |
||
654 | if (propor > 0.1 && hit < 0.005*energy) continue; |
||
655 | } |
||
656 | /* It's a hit -- print out hit size */ |
||
657 | atackd = 1; /* We weren't going to check casualties, etc. if |
||
658 | shields were down for some strange reason. This |
||
659 | doesn't make any sense, so I've fixed it */ |
||
660 | ihurt = 1; |
||
661 | cramf(hit, 0, 2); |
||
662 | proutn(" модуль поврежден");/*unit hit*/ |
||
663 | if ((damage[DSRSENS] > 0 && itflag) || skill <= SFAIR) { |
||
664 | proutn(" на стороне ");/*on the*/ |
||
665 | crmshp(); |
||
666 | } |
||
667 | if (damage[DSRSENS] <= 0.0 && itflag) { |
||
668 | proutn(" из точки ");/*from*/ |
||
669 | crmena(0, iquad, i, jx, jy); |
||
670 | } |
||
671 | skip(1); |
||
672 | /* Decide if hit is critical */ |
||
673 | if (hit > hitmax) hitmax = hit; |
||
674 | hittot += hit; |
||
675 | fry(hit); |
||
676 | printf("Урон %g энергия %g\n", hit, energy);/*Hit %g energy %g*/ |
||
677 | energy -= hit; |
||
678 | } |
||
679 | if (energy <= 0) { |
||
680 | /* Returning home upon your shield, not with it... */ |
||
681 | finish(FBATTLE); |
||
682 | return; |
||
683 | } |
||
684 | if (attempt == 0 && condit == IHDOCKED) |
||
685 | /*prout("***Enemies decide against attacking your ship.");*/ |
||
686 | prout("***Враги решили не атаковать ваш корабль."); |
||
687 | if (atackd == 0) return; |
||
688 | percent = 100.0*pfac*shield+0.5; |
||
689 | if (ihurt==0) { |
||
690 | /* Shields fully protect ship */ |
||
691 | /*proutn("Enemy attack reduces shield strength to ");*/ |
||
692 | proutn("Вражеская атака уменьшила силовые щиты до "); |
||
693 | } |
||
694 | else { |
||
695 | /* Print message if starship suffered hit(s) */ |
||
696 | skip(1); |
||
697 | proutn("Энергии осталось ");/*Energy left*/ |
||
698 | cramf(energy, 0, 2); |
||
699 | proutn(" силовые щиты ");/*shields*/ |
||
700 | if (shldup) proutn("активны, ");/*up*/ |
||
701 | else if (damage[DSHIELD] == 0) proutn("погашены, ");/*down*/ |
||
702 | else proutn("повреждены, "); /*damaged*/ |
||
703 | } |
||
704 | crami(percent, 1); |
||
705 | /* proutn("% torpedoes left ");*/ |
||
706 | proutn("% торпед осталось "); |
||
707 | crami(torps, 1); |
||
708 | skip(1); |
||
709 | /* Check if anyone was hurt */ |
||
710 | if (hitmax >= 200 || hittot >= 500) { |
||
711 | int icas= hittot*Rand()*0.015; |
||
712 | if (icas >= 2) { |
||
713 | skip(1); |
||
714 | /* proutn("Mc Coy- \"Sickbay to bridge. We suffered ");*/ |
||
715 | proutn("МакКой- \"Медотсек докладывает. Мы потеряли "); |
||
716 | crami(icas, 1); |
||
717 | prout(" человек");/*casualties*/ |
||
718 | prout(" при последней атаке.\"");/*in that last attack*/ |
||
719 | casual += icas; |
||
720 | } |
||
721 | } |
||
722 | /* After attack, reset average distance to enemies */ |
||
723 | for (l = 1; l <= nenhere; l++) |
||
724 | kavgd[l] = kdist[l]; |
||
725 | sortkl(); |
||
726 | return; |
||
727 | } |
||
728 | |||
729 | void deadkl(int ix, int iy, int type, int ixx, int iyy) { |
||
730 | /* Added ixx and iyy allow enemy to "move" before dying */ |
||
731 | |||
732 | int i,j; |
||
733 | |||
734 | crmena(1, type, 2, ixx, iyy); |
||
735 | /* Decide what kind of enemy it is and update approriately */ |
||
736 | if (type == IHR) { |
||
737 | /* chalk up a Romulan */ |
||
738 | d.newstuf[quadx][quady] -= 10; |
||
739 | irhere--; |
||
740 | d.nromkl++; |
||
741 | d.nromrem--; |
||
742 | } |
||
743 | else if (type == IHT) { |
||
744 | /* Killed a Tholean */ |
||
745 | ithere = 0; |
||
746 | } |
||
747 | else { |
||
748 | /* Some type of a Klingon */ |
||
749 | d.galaxy[quadx][quady] -= 100; |
||
750 | klhere--; |
||
751 | d.remkl--; |
||
752 | switch (type) { |
||
753 | case IHC: |
||
754 | comhere = 0; |
||
755 | for (i=1; i<=d.remcom; i++) |
||
756 | if (d.cx[i]==quadx && d.cy[i]==quady) break; |
||
757 | d.cx[i] = d.cx[d.remcom]; |
||
758 | d.cy[i] = d.cy[d.remcom]; |
||
759 | d.cx[d.remcom] = 0; |
||
760 | d.cy[d.remcom] = 0; |
||
761 | d.remcom--; |
||
762 | future[FTBEAM] = 1e30; |
||
763 | if (d.remcom != 0) |
||
764 | future[FTBEAM] = d.date + expran(1.0*incom/d.remcom); |
||
765 | d.killc++; |
||
766 | break; |
||
767 | case IHK: |
||
768 | d.killk++; |
||
769 | break; |
||
770 | case IHS: |
||
771 | d.nscrem = ishere = d.isx = d.isy = isatb = iscate = 0; |
||
772 | d.nsckill = 1; |
||
773 | future[FSCMOVE] = future[FSCDBAS] = 1e30; |
||
774 | break; |
||
775 | } |
||
776 | } |
||
777 | |||
778 | /* For each kind of enemy, finish message to player */ |
||
779 | prout(" уничтожен.");/*destroyed*/ |
||
780 | quad[ix][iy] = IHDOT; |
||
781 | if (d.remkl==0) return; |
||
782 | |||
783 | d.remtime = d.remres/(d.remkl + 4*d.remcom); |
||
784 | |||
785 | if (type == IHT) return; |
||
786 | |||
787 | /* Remove enemy ship from arrays describing local conditions */ |
||
788 | |||
789 | for (i=1; i<=nenhere; i++) |
||
790 | if (kx[i]==ix && ky[i]==iy) break; |
||
791 | nenhere--; |
||
792 | if (i <= nenhere) { |
||
793 | for (j=i; j<=nenhere; j++) { |
||
794 | kx[j] = kx[j+1]; |
||
795 | ky[j] = ky[j+1]; |
||
796 | kpower[j] = kpower[j+1]; |
||
797 | kavgd[j] = kdist[j] = kdist[j+1]; |
||
798 | } |
||
799 | } |
||
800 | kx[nenhere+1] = 0; |
||
801 | ky[nenhere+1] = 0; |
||
802 | kdist[nenhere+1] = 0; |
||
803 | kavgd[nenhere+1] = 0; |
||
804 | kpower[nenhere+1] = 0; |
||
805 | return; |
||
806 | } |
||
807 | |||
808 | static int targetcheck(double x, double y, double *course) { |
||
809 | double deltx, delty; |
||
810 | /* Return TRUE if target is invalid */ |
||
811 | if (x < 1.0 || x > 10.0 || y < 1.0 || y > 10.0) { |
||
812 | huh(); |
||
813 | return 1; |
||
814 | } |
||
815 | deltx = 0.1*(y - secty); |
||
816 | delty = 0.1*(sectx - x); |
||
817 | if (deltx==0 && delty== 0) { |
||
818 | skip(1); |
||
819 | /* prout("Spock- \"Bridge to sickbay. Dr. McCoy,"); |
||
820 | prout(" I recommend an immediate review of"); |
||
821 | prout(" the Captain's psychological profile.");*/ |
||
822 | prout("Спок- \"Мостик - медотсеку. Доктор МакКой,"); |
||
823 | prout(" Я рекомендую немедленно проверить"); |
||
824 | prout(" психологическое состояние Капитана."); |
||
825 | chew(); |
||
826 | return 1; |
||
827 | } |
||
828 | *course = 1.90985932*atan2(deltx, delty); |
||
829 | return 0; |
||
830 | } |
||
831 | |||
832 | void photon(void) { |
||
833 | double targ[4][3], course[4]; |
||
834 | double r, dummy; |
||
835 | int key, n, i, osuabor; |
||
836 | |||
837 | ididit = 0; |
||
838 | |||
839 | if (damage[DPHOTON]) { |
||
840 | prout("Пусковые установки фотонных торпед повреждены.");/*Photon tubes damaged*/ |
||
841 | chew(); |
||
842 | return; |
||
843 | } |
||
844 | if (torps == 0) { |
||
845 | prout("Торпеды кончились.");/*No torpedoes left*/ |
||
846 | chew(); |
||
847 | return; |
||
848 | } |
||
849 | key = scan(); |
||
850 | for (;;) { |
||
851 | if (key == IHALPHA) { |
||
852 | huh(); |
||
853 | return; |
||
854 | } |
||
855 | else if (key == IHEOL) { |
||
856 | crami(torps,1); |
||
857 | prout(" торпед осталось.");/*torpedoes left*/ |
||
858 | proutn("Сколько торпед выпускать?- ");/*Number of torpedoes to fire*/ |
||
859 | key = scan(); |
||
860 | } |
||
861 | else /* key == IHREAL */ { |
||
862 | n = aaitem + 0.5; |
||
863 | if (n <= 0) { /* abort command */ |
||
864 | chew(); |
||
865 | return; |
||
866 | } |
||
867 | if (n > 3) { |
||
868 | prout("Максимальный залп - 3 торпеды.");/*Maximum of 3 torpedoes per burst*/ |
||
869 | } else if (n <= torps) break; |
||
870 | chew(); |
||
871 | key = IHEOL; |
||
872 | } |
||
873 | } |
||
874 | for (i = 1; i <= n; i++) { |
||
875 | key = scan(); |
||
876 | if (i==1 && key == IHEOL) { |
||
877 | break; /* we will try prompting */ |
||
878 | } |
||
879 | if (i==2 && key == IHEOL) { |
||
880 | /* direct all torpedoes at one target */ |
||
881 | while (i <= n) { |
||
882 | targ[i][1] = targ[1][1]; |
||
883 | targ[i][2] = targ[1][2]; |
||
884 | course[i] = course[1]; |
||
885 | i++; |
||
886 | } |
||
887 | break; |
||
888 | } |
||
889 | if (key != IHREAL) { |
||
890 | huh(); |
||
891 | return; |
||
892 | } |
||
893 | targ[i][1] = aaitem; |
||
894 | key = scan(); |
||
895 | if (key != IHREAL) { |
||
896 | huh(); |
||
897 | return; |
||
898 | } |
||
899 | targ[i][2] = aaitem; |
||
900 | if (targetcheck(targ[i][1], targ[i][2], &course[i])) return; |
||
901 | } |
||
902 | chew(); |
||
903 | if (i == 1 && key == IHEOL) { |
||
904 | /* prompt for each one */ |
||
905 | for (i = 1; i <= n; i++) { |
||
906 | proutn("Сектор прицеливания для торпеды");/*Target sector for torpedo number*/ |
||
907 | crami(i, 2); |
||
908 | proutn("- "); |
||
909 | key = scan(); |
||
910 | if (key != IHREAL) { |
||
911 | huh(); |
||
912 | return; |
||
913 | } |
||
914 | targ[i][1] = aaitem; |
||
915 | key = scan(); |
||
916 | if (key != IHREAL) { |
||
917 | huh(); |
||
918 | return; |
||
919 | } |
||
920 | targ[i][2] = aaitem; |
||
921 | chew(); |
||
922 | if (targetcheck(targ[i][1], targ[i][2], &course[i])) return; |
||
923 | } |
||
924 | } |
||
925 | ididit = 1; |
||
926 | /* Loop for moving |
||
927 | osuabor = 0; |
||
928 | for (i = 1; i <= n && !osuabor; i++) { |
||
929 | if (condit != IHDOCKED) torps--; |
||
930 | r = (Rand()+Rand())*0.5 -0.5; |
||
931 | if (fabs(r) >= 0.47) { |
||
932 | /* misfire! */ |
||
933 | r = (Rand()+1.2) * r; |
||
934 | if (n>1) { |
||
935 | prouts("***ТОРПЕДА");/*TORPEDO NUMBER*/ |
||
936 | crami(i, 2); |
||
937 | prouts(" - СБОЙ ПУСКА.");/*MISFIRES*/ |
||
938 | } |
||
939 | else prouts("***ТОРПЕДА - СБОЙ ПУСКА.");/*TORPEDO MISFIRES*/ |
||
940 | skip(1); |
||
941 | if (i < n) |
||
942 | prout(" Залп прерван.");/*Remainder of burst aborted*/ |
||
943 | osuabor=1; |
||
944 | if (Rand() <= 0.2) { |
||
945 | prout("***Пусковые установки повреждены при сбое.");/*Photon tubes damaged by misfire*/ |
||
946 | damage[DPHOTON] = damfac*(1.0+2.0*Rand()); |
||
947 | break; |
||
948 | } |
||
949 | } |
||
950 | #ifdef CLOAKING |
||
951 | if (iscloaked) r *= 1.2; /* Torpedoes are less accurate */ |
||
952 | else |
||
953 | #endif |
||
954 | if (shldup != 0 || condit == IHDOCKED) r *= 1.0 + 0.0001*shield; /* Torpedos are less accurate */ |
||
955 | |||
956 | if (n != 1) { |
||
957 | skip(1); |
||
958 | proutn("Торпедный след номер");/*Track for torpedo number*/ |
||
959 | crami(i, 2); |
||
960 | proutn("- "); |
||
961 | } |
||
962 | else { |
||
963 | skip(1); |
||
964 | proutn("Торпедный след- ");/*Torpedo track*/ |
||
965 | } |
||
966 | torpedo(course[i], r, sectx, secty, &dummy); |
||
967 | if (alldone || d.galaxy[quadx][quady]==1000) return; |
||
968 | } |
||
969 | if (d.remkl==0) finish(FWON); |
||
970 | } |
||
971 | |||
972 | |||
973 | |||
974 | static void overheat(double rpow) { |
||
975 | if (rpow > 1500) { |
||
976 | double chekbrn = (rpow-1500.)*0.00038; |
||
977 | if (Rand() <= chekbrn) { |
||
978 | /*prout("Weapons officer Sulu- \"Phasers overheated, sir.\"");*/ |
||
979 | prout("Орудийный офицер Сулу- \"Фазеры перегреты, Сэр.\""); |
||
980 | damage[DPHASER] = damfac*(1.0 + Rand()) * (1.0+chekbrn); |
||
981 | } |
||
982 | } |
||
983 | } |
||
984 | |||
985 | static int checkshctrl(double rpow) { |
||
986 | double hit; |
||
987 | int icas; |
||
988 | |||
989 | skip(1); |
||
990 | if (Rand() < .998) { |
||
991 | prout("Силовые щиты ослаблены.");/*Shields lowered*/ |
||
992 | return 0; |
||
993 | } |
||
994 | /* Something bad has happened */ |
||
995 | prouts("***КРАСНАЯ ТРЕВОГА!");/*RED ALERT! RED ALERT!*/ |
||
996 | skip(2); |
||
997 | hit = rpow*shield/inshld; |
||
998 | energy -= rpow+hit*0.8; |
||
999 | shield -= hit*0.2; |
||
1000 | if (energy <= 0.0) { |
||
1001 | /* prouts("Sulu- \"Captain! Shield malf***********************\"");*/ |
||
1002 | prouts("Сулу- \"Капитан! Силовые щиты наеб*****************\""); |
||
1003 | skip(1); |
||
1004 | stars(); |
||
1005 | finish(FPHASER); |
||
1006 | return 1; |
||
1007 | } |
||
1008 | /* prouts("Sulu- \"Captain! Shield malfunction! Phaser fire contained!\"");*/ |
||
1009 | prouts("Сулу- \"Капитан! Силовые щиты повреждены! Огнем фазеров!\""); |
||
1010 | skip(2); |
||
1011 | /* prout("Lt. Uhura- \"Sir, all decks reporting damage.\"");*/ |
||
1012 | prout("Лейтенант Ухура- \"Сэр, все палубы докладывают о повреждениях.\""); |
||
1013 | icas = hit*Rand()*0.012; |
||
1014 | skip(1); |
||
1015 | fry(0.8*hit); |
||
1016 | if (icas) { |
||
1017 | skip(1); |
||
1018 | /* prout("McCoy to bridge- \"Severe radiation burns, Jim.");*/ |
||
1019 | prout("МакКой - мостику- \"Серьезная утечка радиации, Джим."); |
||
1020 | proutn(" "); |
||
1021 | crami(icas, 1); |
||
1022 | prout(" потерь на данный момент.\"");/*casualties so far*/ |
||
1023 | casual += icas; // Changed from -=, October 2013 |
||
1024 | } |
||
1025 | skip(1); |
||
1026 | /* prout("Phaser energy dispersed by shields."); |
||
1027 | prout("Enemy unaffected.");*/ |
||
1028 | prout("Фазерные лучи поглощены щитами."); |
||
1029 | prout("Враг повреждений не получил."); |
||
1030 | overheat(rpow); |
||
1031 | return 1; |
||
1032 | } |
||
1033 | |||
1034 | |||
1035 | void phasers(void) { |
||
1036 | double hits[21], rpow, extra, powrem, over, temp; |
||
1037 | int kz = 0, k=1, i; /* Cheating inhibitor */ |
||
1038 | int ifast=0, no=0, ipoop=1, msgflag = 1; |
||
1039 | enum {NOTSET, MANUAL, FORCEMAN, AUTOMATIC} automode = NOTSET; |
||
1040 | int key; |
||
1041 | |||
1042 | skip(1); |
||
1043 | /* SR sensors and Computer */ |
||
1044 | if (damage[DSRSENS]+damage[DCOMPTR] > 0) ipoop = 0; |
||
1045 | if (condit == IHDOCKED) { |
||
1046 | /* prout("Phasers can't be fired through base shields.");*/ |
||
1047 | prout("Силовое поле станции мешает открыть огонь из фазеров."); |
||
1048 | chew(); |
||
1049 | return; |
||
1050 | } |
||
1051 | if (damage[DPHASER] != 0) { |
||
1052 | prout("Панель управления фазерами повреждена.");/*Phaser control damaged*/ |
||
1053 | chew(); |
||
1054 | return; |
||
1055 | } |
||
1056 | if (shldup) { |
||
1057 | if (damage[DSHCTRL]) { |
||
1058 | prout("Панель быстрого регулирования силовых щитов повреждена.");/*High speed shield control damaged*/ |
||
1059 | chew(); |
||
1060 | return; |
||
1061 | } |
||
1062 | if (energy <= 200.0) { |
||
1063 | /* prout("Insufficient energy to activate high-speed shield control.");*/ |
||
1064 | prout("Недостаточно энергии для режима быстрого регулирования силовых щитов."); |
||
1065 | chew(); |
||
1066 | return; |
||
1067 | } |
||
1068 | /* prout("Weapons Officer Sulu- \"High-speed shield control enabled, sir.\"");*/ |
||
1069 | prout("Орудийный офицер Сулу- \"Режим быстрого регулирования силовых щитов включен, Сэр.\""); |
||
1070 | ifast = 1; |
||
1071 | |||
1072 | } |
||
1073 | ididit = 1; |
||
1074 | /* Original code so convoluted, I re-did it all */ |
||
1075 | while (automode==NOTSET) { |
||
1076 | key=scan(); |
||
1077 | if (key == IHALPHA) { |
||
1078 | if (isit("manual")) { |
||
1079 | if (nenhere==0) { |
||
1080 | prout("Вражеские цели отсутствуют.");/*There is no enemy present to select*/ |
||
1081 | chew(); |
||
1082 | key = IHEOL; |
||
1083 | automode=AUTOMATIC; |
||
1084 | } |
||
1085 | else { |
||
1086 | automode = MANUAL; |
||
1087 | key = scan(); |
||
1088 | } |
||
1089 | } |
||
1090 | else if (isit("automatic")) { |
||
1091 | if ((!ipoop) && nenhere != 0) { |
||
1092 | automode = FORCEMAN; |
||
1093 | } |
||
1094 | else { |
||
1095 | if (nenhere==0) |
||
1096 | prout("Энергия рассеется в космосе.");/*Energy will be expended into space*/ |
||
1097 | automode = AUTOMATIC; |
||
1098 | key = scan(); |
||
1099 | } |
||
1100 | } |
||
1101 | else if (isit("no")) { |
||
1102 | no = 1; |
||
1103 | } |
||
1104 | else { |
||
1105 | huh(); |
||
1106 | ididit = 0; |
||
1107 | return; |
||
1108 | } |
||
1109 | } |
||
1110 | else if (key == IHREAL) { |
||
1111 | if (nenhere==0) { |
||
1112 | prout("Энергия рассеется в космосе.");/*Energy will be expended into space*/ |
||
1113 | automode = AUTOMATIC; |
||
1114 | } |
||
1115 | else if (!ipoop) |
||
1116 | automode = FORCEMAN; |
||
1117 | else |
||
1118 | automode = AUTOMATIC; |
||
1119 | } |
||
1120 | else { |
||
1121 | /* IHEOL */ |
||
1122 | if (nenhere==0) { |
||
1123 | prout("Энергия рассеется в космосе.");/*Energy will be expended into space*/ |
||
1124 | automode = AUTOMATIC; |
||
1125 | } |
||
1126 | else if (!ipoop) |
||
1127 | automode = FORCEMAN; |
||
1128 | else |
||
1129 | proutn("Ручной (manual) или автоматический (automatic)? ");/*Manual or automatic?*/ |
||
1130 | } |
||
1131 | } |
||
1132 | |||
1133 | switch (automode) { |
||
1134 | case AUTOMATIC: |
||
1135 | if (key == IHALPHA && isit("no")) { |
||
1136 | no = 1; |
||
1137 | key = scan(); |
||
1138 | } |
||
1139 | if (key != IHREAL && nenhere != 0) { |
||
1140 | /* proutn("Phasers locked on target. Energy available =");*/ |
||
1141 | proutn("Фазеры наведены на цель. Энергии доступно ="); |
||
1142 | cramf(ifast?energy-200.0:energy,1,2); |
||
1143 | skip(1); |
||
1144 | } |
||
1145 | do { |
||
1146 | while (key != IHREAL) { |
||
1147 | chew(); |
||
1148 | proutn("Мощность выстрела=");/*Units to fire*/ |
||
1149 | key = scan(); |
||
1150 | } |
||
1151 | rpow = aaitem; |
||
1152 | if (rpow >= (ifast?energy-200:energy)) { |
||
1153 | proutn("Энергии доступно= ");/*Energy available*/ |
||
1154 | cramf(ifast?energy-200:energy, 1,2); |
||
1155 | skip(1); |
||
1156 | key = IHEOL; |
||
1157 | } |
||
1158 | } while (rpow >= (ifast?energy-200:energy)); |
||
1159 | if (rpow<=0) { |
||
1160 | /* chicken out */ |
||
1161 | ididit = 0; |
||
1162 | chew(); |
||
1163 | return; |
||
1164 | } |
||
1165 | if ((key=scan()) == IHALPHA && isit("no")) { |
||
1166 | no = 1; |
||
1167 | } |
||
1168 | if (ifast) { |
||
1169 | energy -= 200; /* Go and do it! */ |
||
1170 | if (checkshctrl(rpow)) return; |
||
1171 | } |
||
1172 | chew(); |
||
1173 | energy -= rpow; |
||
1174 | extra = rpow; |
||
1175 | if (nenhere) { |
||
1176 | extra = 0.0; |
||
1177 | powrem = rpow; |
||
1178 | for (i = 1; i <= nenhere; i++) { |
||
1179 | hits[i] = 0.0; |
||
1180 | if (powrem <= 0) continue; |
||
1181 | hits[i] = fabs(kpower[i])/(phasefac*pow(0.90,kdist[i])); |
||
1182 | over = (0.01 + 0.05*Rand())*hits[i]; |
||
1183 | temp = powrem; |
||
1184 | powrem -= hits[i] + over; |
||
1185 | if (powrem <= 0 && temp < hits[i]) hits[i] = temp; |
||
1186 | if (powrem <= 0) over = 0.0; |
||
1187 | extra += over; |
||
1188 | } |
||
1189 | if (powrem > 0.0) extra += powrem; |
||
1190 | hittem(hits); |
||
1191 | } |
||
1192 | if (extra > 0 && alldone == 0) { |
||
1193 | if (ithere) { |
||
1194 | proutn("*** Толианская сеть поглотила ");/*Tholian web absorbs*/ |
||
1195 | if (nenhere>0) proutn("избыток ");/*excess*/ |
||
1196 | prout("энергии фазеров.");/*phaser energy*/ |
||
1197 | } |
||
1198 | else { |
||
1199 | cramf(extra, 0, 2); |
||
1200 | prout(" рассеяна в пустом космосе.");/*expended on empty space*/ |
||
1201 | } |
||
1202 | } |
||
1203 | break; |
||
1204 | |||
1205 | case FORCEMAN: |
||
1206 | chew(); |
||
1207 | key = IHEOL; |
||
1208 | if (damage[DCOMPTR]!=0) |
||
1209 | /* prout("Battle computer damaged, manual file only.");*/ |
||
1210 | prout("Тактический компьютер поврежден, только ручное управление."); |
||
1211 | else { |
||
1212 | skip(1); |
||
1213 | prouts("---ОБРАБОТКА---");/*WORKING*/ |
||
1214 | skip(1); |
||
1215 | /* prout("Short-range-sensors-damaged"); |
||
1216 | prout("Insufficient-data-for-automatic-phaser-fire"); |
||
1217 | prout("Manual-fire-must-be-used");*/ |
||
1218 | prout("Сенсоры-ближнего-радиуса-действия-повреждены"); |
||
1219 | prout("Недостаточно-информации-для-автоматического-управления-фазерами"); |
||
1220 | prout("Ручное-управление-должно-быть-использовано"); |
||
1221 | skip(1); |
||
1222 | } |
||
1223 | case MANUAL: |
||
1224 | rpow = 0.0; |
||
1225 | for (k = 1; k <= nenhere;) { |
||
1226 | int ii = kx[k], jj = ky[k]; |
||
1227 | int ienm = quad[ii][jj]; |
||
1228 | if (msgflag) { |
||
1229 | proutn("Энергии доступно= ");/*Energy available*/ |
||
1230 | cramf(energy-.006-(ifast?200:0), 0, 2); |
||
1231 | skip(1); |
||
1232 | msgflag = 0; |
||
1233 | rpow = 0.0; |
||
1234 | } |
||
1235 | if (damage[DSRSENS] && !(abs(sectx-ii) < 2 && abs(secty-jj) < 2) && |
||
1236 | (ienm == IHC || ienm == IHS)) { |
||
1237 | cramen(ienm); |
||
1238 | /* prout(" can't be located without short range scan.");*/ |
||
1239 | prout(" невозможно обнаружение без сенсоров ближнего радиуса."); |
||
1240 | chew(); |
||
1241 | key = IHEOL; |
||
1242 | hits[k] = 0; /* prevent overflow -- thanks to Alexei Voitenko */ |
||
1243 | k++; |
||
1244 | continue; |
||
1245 | } |
||
1246 | if (key == IHEOL) { |
||
1247 | chew(); |
||
1248 | if (ipoop && k > kz) { |
||
1249 | int irec=(fabs(kpower[k])/(phasefac*pow(0.9,kdist[k])))* |
||
1250 | (1.01+0.05*Rand()) + 1.0; |
||
1251 | kz = k; |
||
1252 | proutn("("); |
||
1253 | crami(irec, 1); |
||
1254 | proutn(") "); |
||
1255 | } |
||
1256 | proutn("единиц затратить по точке ");/*units to fire at*/ |
||
1257 | crmena(0, ienm, 2, ii, jj); |
||
1258 | proutn("- "); |
||
1259 | key = scan(); |
||
1260 | } |
||
1261 | if (key == IHALPHA && isit("no")) { |
||
1262 | no = 1; |
||
1263 | key = scan(); |
||
1264 | continue; |
||
1265 | } |
||
1266 | if (key == IHALPHA) { |
||
1267 | huh(); |
||
1268 | ididit = 0; |
||
1269 | return; |
||
1270 | } |
||
1271 | if (key == IHEOL) { |
||
1272 | if (k==1) { /* Let me say I'm baffled by this */ |
||
1273 | msgflag = 1; |
||
1274 | } |
||
1275 | continue; |
||
1276 | } |
||
1277 | if (aaitem < 0) { |
||
1278 | /* abort out */ |
||
1279 | ididit = 0; |
||
1280 | chew(); |
||
1281 | return; |
||
1282 | } |
||
1283 | hits[k] = aaitem; |
||
1284 | rpow += aaitem; |
||
1285 | /* If total requested is too much, inform and start over */ |
||
1286 | |||
1287 | if (rpow >= (ifast?energy-200:energy)) { |
||
1288 | /* prout("Available energy exceeded -- try again.");*/ |
||
1289 | prout("Превышен запас энергии -- повторите."); |
||
1290 | chew(); |
||
1291 | key = IHEOL; |
||
1292 | k = 1; |
||
1293 | msgflag = 1; |
||
1294 | continue; |
||
1295 | } |
||
1296 | key = scan(); /* scan for next value */ |
||
1297 | k++; |
||
1298 | } |
||
1299 | if (rpow == 0.0) { |
||
1300 | /* zero energy -- abort */ |
||
1301 | ididit = 0; |
||
1302 | chew(); |
||
1303 | return; |
||
1304 | } |
||
1305 | if (key == IHALPHA && isit("no")) { |
||
1306 | no = 1; |
||
1307 | } |
||
1308 | energy -= rpow; |
||
1309 | chew(); |
||
1310 | if (ifast) { |
||
1311 | energy -= 200.0; |
||
1312 | if (checkshctrl(rpow)) return; |
||
1313 | } |
||
1314 | hittem(hits); |
||
1315 | ididit=1; |
||
1316 | break; |
||
1317 | case NOTSET: break; // cannot occur |
||
1318 | } |
||
1319 | /* Say shield raised or malfunction, if necessary */ |
||
1320 | if (alldone) return; |
||
1321 | if (ifast) { |
||
1322 | skip(1); |
||
1323 | if (no == 0) { |
||
1324 | if (Rand() >= 0.99) { |
||
1325 | /* prout("Sulu- \"Sir, the high-speed shield control has malfunctioned . . ."); |
||
1326 | prouts(" CLICK CLICK POP . . ."); |
||
1327 | prout(" No response, sir!");*/ |
||
1328 | prout("Сулу- \"Сэр, панель быстрого регулирования силовых щитов не работает . . ."); |
||
1329 | prouts(" КЛИК КЛИК БУМ . . ."); |
||
1330 | prout(" Не реагирует, Сэр!"); |
||
1331 | shldup = 0; |
||
1332 | } |
||
1333 | else |
||
1334 | prout("Силовые щиты активированы.");/*Shields raised*/ |
||
1335 | } |
||
1336 | else |
||
1337 | shldup = 0; |
||
1338 | } |
||
1339 | overheat(rpow); |
||
1340 | } |
||
1341 | |||
1342 | void hittem(double *hits) { |
||
1343 | double kp, kpow, wham, hit, dustfac, kpini; |
||
1344 | int nenhr2=nenhere, k=1, kk=1, ii, jj, ienm; |
||
1345 | |||
1346 | skip(1); |
||
1347 | |||
1348 | for (; k <= nenhr2; k++, kk++) { |
||
1349 | if ((wham = hits[k])==0) continue; |
||
1350 | dustfac = 0.9 + 0.01*Rand(); |
||
1351 | hit = wham*pow(dustfac,kdist[kk]); |
||
1352 | kpini = kpower[kk]; |
||
1353 | kp = fabs(kpini); |
||
1354 | if (phasefac*hit < kp) kp = phasefac*hit; |
||
1355 | kpower[kk] -= (kpower[kk] < 0 ? -kp: kp); |
||
1356 | kpow = kpower[kk]; |
||
1357 | ii = kx[kk]; |
||
1358 | jj = ky[kk]; |
||
1359 | if (hit > 0.005) { |
||
1360 | cramf(hit, 0, 2); |
||
1361 | proutn(" модуль поврежден в точке ");/*unit hit on*/ |
||
1362 | } |
||
1363 | else |
||
1364 | proutn("Малое повреждение в точке ");/*Very small hit on*/ |
||
1365 | ienm = quad[ii][jj]; |
||
1366 | crmena(0,ienm,2,ii,jj); |
||
1367 | skip(1); |
||
1368 | if (kpow == 0) { |
||
1369 | deadkl(ii, jj, ienm, ii, jj); |
||
1370 | if (d.remkl==0) finish(FWON); |
||
1371 | if (alldone) return; |
||
1372 | kk--; /* don't do the increment */ |
||
1373 | } |
||
1374 | else /* decide whether or not to emasculate klingon */ |
||
1375 | if (kpow > 0 && Rand() >= 0.9 && |
||
1376 | kpow <= ((0.4 + 0.4*Rand())*kpini)) { |
||
1377 | /* proutn("***Mr. Spock- \"Captain, the vessel at");*/ |
||
1378 | proutn("***Мистер Спок- \"Капитан, судно в точке"); |
||
1379 | cramlc(2,ii,jj); |
||
1380 | skip(1); |
||
1381 | prout(" только что лишилось огневой мощи.\"");/*has just lost its firepower*/ |
||
1382 | kpower[kk] = -kpow; |
||
1383 | } |
||
1384 | } |
||
1385 | return; |
||
1386 | } |
||
1387 | |||
1388 | #ifdef CAPTURE |
||
1389 | /* $NetBSD: capture.c,v 1.6 2003/08/07 09:37:50 agc Exp $ */ |
||
1390 | |||
1391 | /* |
||
1392 | * Copyright (c) 1980, 1993 |
||
1393 | * The Regents of the University of California. All rights reserved. |
||
1394 | * |
||
1395 | * Redistribution and use in source and binary forms, with or without |
||
1396 | * modification, are permitted provided that the following conditions |
||
1397 | * are met: |
||
1398 | * 1. Redistributions of source code must retain the above copyright |
||
1399 | * notice, this list of conditions and the following disclaimer. |
||
1400 | * 2. Redistributions in binary form must reproduce the above copyright |
||
1401 | * notice, this list of conditions and the following disclaimer in the |
||
1402 | * documentation and/or other materials provided with the distribution. |
||
1403 | * 3. Neither the name of the University nor the names of its contributors |
||
1404 | * may be used to endorse or promote products derived from this software |
||
1405 | * without specific prior written permission. |
||
1406 | * |
||
1407 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
||
1408 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
1409 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||
1410 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
||
1411 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||
1412 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
||
1413 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
||
1414 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
||
1415 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
||
1416 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||
1417 | * SUCH DAMAGE. |
||
1418 | */ |
||
1419 | |||
1420 | /* |
||
1421 | ** Ask a Klingon To Surrender |
||
1422 | ** |
||
1423 | ** (Fat chance) |
||
1424 | ** |
||
1425 | ** The Subspace Radio is needed to ask a Klingon if he will kindly |
||
1426 | ** surrender. A random Klingon from the ones in the quadrant is |
||
1427 | ** chosen. |
||
1428 | ** |
||
1429 | ** The Klingon is requested to surrender. The probability of this |
||
1430 | ** is a function of that Klingon's remaining power, our power, |
||
1431 | ** etc. |
||
1432 | */ |
||
1433 | |||
1434 | int selectklingon(void); |
||
1435 | |||
1436 | void |
||
1437 | capture(void) |
||
1438 | { |
||
1439 | int i; |
||
1440 | int k; |
||
1441 | double x; |
||
1442 | |||
1443 | ididit = FALSE; // Nothing if we fail |
||
1444 | Time = 0.0; |
||
1445 | |||
1446 | /* Make sure there is room in the brig */ |
||
1447 | if (brigfree == 0) |
||
1448 | { |
||
1449 | /* printf("Security reports the brig is already full.\n");*/ |
||
1450 | printf("Служба безопасности докладывает, что корабль переполнен.\n"); |
||
1451 | return; |
||
1452 | } |
||
1453 | |||
1454 | if (!REPORTS) { |
||
1455 | /* printf("Uhura- \"We have no subspace radio communication, sir.\"\n");*/ |
||
1456 | printf("Ухура- \"Радиосигналы отсутствуют, Сэр.\"\n"); |
||
1457 | return; |
||
1458 | } |
||
1459 | |||
1460 | if (damage[DTRANSP] != 0) { |
||
1461 | /* printf("Scotty- \"Transporter damaged, sir.\"\n");*/ |
||
1462 | printf("Скотти- \"Транспорт поврежден, Сэр.\"\n"); |
||
1463 | return; |
||
1464 | } |
||
1465 | |||
1466 | |||
1467 | |||
1468 | /* find out if there are any at all */ |
||
1469 | if (klhere < 1) |
||
1470 | { |
||
1471 | /* printf("Uhura- \"Getting no response, sir.\"\n");*/ |
||
1472 | printf("Ухура- \"Никто не отвечает, Сэр.\"\n"); |
||
1473 | return; |
||
1474 | } |
||
1475 | |||
1476 | /* if there is more than one Klingon, find out which one */ |
||
1477 | k = selectklingon(); |
||
1478 | Time = 0.05; // This action will take some time |
||
1479 | ididit = TRUE; // So any others can strike back |
||
1480 | |||
1481 | /* check out that Klingon */ |
||
1482 | /* The algorithm isn't that great and could use some more |
||
1483 | * intelligent design */ |
||
1484 | // x = 300 + 25*skill; |
||
1485 | x = energy; |
||
1486 | x /= kpower[k] * nenhere; |
||
1487 | x *= 2.5; /* would originally have been equivalent of 1.4, but we want command to work more often, more humanely */ |
||
1488 | i = x; |
||
1489 | #ifdef DEBUG |
||
1490 | printf("Prob = %d (%.4f)\n", i, x); |
||
1491 | // i = 100; // For testing, of course! |
||
1492 | #endif |
||
1493 | if (i > 100*Rand()) |
||
1494 | { |
||
1495 | /* guess what, he surrendered!!! */ |
||
1496 | /* printf("Klingon captain at %d,%d surrenders\n", kx[k], ky[k]);*/ |
||
1497 | printf("Клингонский капитан в точке %d,%d сдается\n", kx[k], ky[k]); |
||
1498 | i = 200*Rand(); |
||
1499 | if ( i > 0 ) |
||
1500 | /* printf("%d Klingons commit suicide rather than be taken captive\n", 200 - i);*/ |
||
1501 | printf("%d клингонов предпочли самоубийство сдаче в плен\n", 200 - i); |
||
1502 | if (i > brigfree) |
||
1503 | { |
||
1504 | /* printf("%d Klingons die because there is no room for them in the brig.\n", i-brigfree);*/ |
||
1505 | printf("%d клингонов умерло, посколько для них не хватило жилого пространства на корабле.\n", i-brigfree); |
||
1506 | i = brigfree; |
||
1507 | } |
||
1508 | brigfree -= i; |
||
1509 | printf("%d captives taken\n", i); |
||
1510 | deadkl(kx[k], ky[k], quad[kx[k]][ky[k]], kx[k], ky[k]); |
||
1511 | if (d.remkl==0) finish(FWON); |
||
1512 | return; |
||
1513 | } |
||
1514 | |||
1515 | /* big surprise, he refuses to surrender */ |
||
1516 | printf("Большая удача, капитан\n");/*Fat chance, captain*/ |
||
1517 | return; |
||
1518 | } |
||
1519 | |||
1520 | |||
1521 | /* |
||
1522 | ** SELECT A KLINGON |
||
1523 | ** |
||
1524 | ** Cruddy, just takes one at random. Should ask the captain. |
||
1525 | ** Nah, just select the weakest one since it is most likely to |
||
1526 | ** surrender (Tom Almy mod) |
||
1527 | */ |
||
1528 | |||
1529 | int selectklingon() |
||
1530 | { |
||
1531 | int i; |
||
1532 | |||
1533 | if (nenhere < 2) |
||
1534 | i = 1; |
||
1535 | else |
||
1536 | { // Select the weakest one |
||
1537 | double pow = 1e6; |
||
1538 | int j; |
||
1539 | for (j=1; j <= nenhere; j++) |
||
1540 | { |
||
1541 | if (quad[kx[j]][ky[j]] == IHR) continue; // No Romulans surrender |
||
1542 | if (kpower[j]< pow) |
||
1543 | { |
||
1544 | pow = kpower[j]; |
||
1545 | i = j; |
||
1546 | } |
||
1547 | } |
||
1548 | } |
||
1549 | return i; |
||
1550 | } |
||
1551 | |||
1552 | #endif>=>>>=>>>=>>>>=>=>>=>=>=>=0)>=>=>>=>=>>=>=>=>=>=>=>>>=nenhere;>=>=nenhere;>=d.remcom;>=>=>=>=>>>=>>>=>=>=l)>=l>>=>>=nenhere;>=d.rembase;>>1>1>0>>=>=>1>1>>>=>>=>>>=> |