-
Notifications
You must be signed in to change notification settings - Fork 1
/
places.cpp
670 lines (598 loc) · 17.9 KB
/
places.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
#include "monster.h"
#include "map.h"
#include "keyboard.h"
#include "actions.h"
#include "system.h"
#include "global.h"
#include "directions.h"
#include "options.h"
#include "attrib.h"
#include "level.h"
#include "places.h"
#include "parser.h"
extern GAME game;
extern KEYBOARD keyboard;
extern LEVEL level;
extern MYSCREEN screen;
extern DEFINITIONS definitions;
extern class OPTIONS options;
void PLACES :: print_on_terminal(int x, int y, string text)
{
for (size_t a=0;a<text.size();a++)
{
char character = text[a];
if (character!=' ')
set_color(10);
else
{
set_color(2);
character='.';
}
print_character(x+4+a,y+4,character);
}
}
void PLACES :: draw_terminal()
{
screen.clear_all();
int x,y;
int sizex=57,sizey=21;
for (x=2;x<=sizex;x++)
{
for (y=2;y<=sizey;y++)
{
if (x==2 || x==sizex || y==2 || y==sizey)
set_color(2);
else
set_color(2);
print_character(x,y,'.');
}
}
set_color(8);
for (x=3;x<=sizex+1;x++)
print_character(x,sizey+1,'.');
for (y=3;y<=sizey+1;y++)
print_character(sizex+1,y,'.');
}
void PLACES :: print_laboratory()
{
draw_terminal();
set_color(10);
int px,py;
px = 0;
py = 0;
string text;
print_on_terminal(px,py++,"홀로그램 터미널 ver.0.7a");
py++;
switch (random(5))
{
case 0: text="박사님, 안녕하세요.";
break;
case 1: text="박사님, 또 오셨네요.";
break;
case 2: text="박사님, 오랜만이에요.";
break;
case 3: text="박사님, 반가워요.";
break;
case 4: text="박사님, 명령을 내려주세요.";
break;
}
print_on_terminal(px,py++,text);
switch (random(5))
{
case 0: text="명령이 무엇입니까?";
break;
case 1: text="어떤 프로그램을 실행합니까?";
break;
case 2: text="가능한 프로젝트:";
break;
case 3: text="선택해주세요:";
break;
case 4: text="무엇을 열까요?";
break;
}
print_on_terminal(px,py++,text);
py++;
print_on_terminal(px,py++,">1.생물체 재설계 7");
print_on_terminal(px,py++,">2.DNA 조작");
print_on_terminal(px,py++,">3.DI 227BS - DNA 결합");
print_on_terminal(px,py++,">4.개인 일지");
myrefresh();
}
bool PLACES::GeneticLaboratory()
{
taken_DNA = "";
print_laboratory();
while(1)
{
int key = keyboard.wait_for_key();
if (key == keyboard.escape || key == keyboard.readmore || key == keyboard.readmore2)
{
break;
}
else if (key == '1')
{
if (GenLabBioRebuild()==true)
return true;
print_laboratory();
}
else if (key == '2')
{
if (GenLabDNAModif()==true)
return true;
print_laboratory();
}
else if (key == '3')
{
if (GenLabIntegration()==true)
return true;
print_laboratory();
}
else if (key == '4')
{
GenLabPersonalLog();
print_laboratory();
}
}
return false;
}
void PLACES::print_program_1()
{
int px,py;
px=0,py=0;
draw_terminal();
print_on_terminal(px,py++,"-= 생물체 재설계 프로그램 =- ver. 7.12.24");
py++;
print_on_terminal(px,py++,"최종 수정: 2081-02-05");
py++;
print_on_terminal(px,py++,"자가 진단... CRC OK.");
py++;
print_on_terminal(px,py++,"하드웨어 점검:");
py++;
print_on_terminal(px,py++,"생물체 생성기 시험중... OK.");
print_on_terminal(px,py++,"DNA 추출기 시험중... OK.");
print_on_terminal(px,py++,"하드웨어 점검 완료.");
py++;
py++;
print_on_terminal(px,py++,"사용자 옵션:");
print_on_terminal(px,py++,">1.DNA를 사용한 생물체 재설계.");
myrefresh();
}
void PLACES::print_program_2()
{
int px,py;
px=0,py=0;
draw_terminal();
print_on_terminal(px,py++,"오류: 설정 파일이 존재하지 않습니다.");
print_on_terminal(px,py++,"새로운 설정 파일을 업로드하십시오.");
myrefresh();
}
void PLACES::print_program_3()
{
int px,py;
px=0,py=0;
draw_terminal();
print_on_terminal(px,py++,"실험 DI 227BS");
print_on_terminal(px,py++,"DNA 결합");
py++;
if (taken_DNA=="")
print_on_terminal(px,py++,"실험을 위한 DNA 샘플이 존재하지 않습니다.");
else
print_on_terminal(px,py++,"DNA 추출 " + taken_DNA);
py++;
print_on_terminal(px,py++,">1.DNA를 추출할 생물체 선택.");
if (taken_DNA=="")
print_on_terminal(px,py++," 2.살아 있는 생물체에 추출한 DNA 결합.");
else
print_on_terminal(px,py++,">2.살아 있는 생물체에 추출한 DNA 결합.");
myrefresh();
}
void PLACES::print_program_4(int page)
{
int px,py;
px=0,py=0;
draw_terminal();
switch(page) {
case 1:
print_on_terminal(px,py++,"[ED 06-12-2189]");
print_on_terminal(px,py++,"드디어 성공이다! 유전자기계도 잘 작동하고,");
print_on_terminal(px,py++,"DNA 합성도 잘 이루어지고 있다. 예상대로다.");
print_on_terminal(px,py++,"이제 화물선이 도착할 때까지 기다리는 일만 남았다.");
print_on_terminal(px,py++,"화물선 이름이 뭐였지? \"아틀라스\"라고 했던가?");
print_on_terminal(px,py++,"제발 빨리만 도착해 다오.");
print_on_terminal(px,17,">2. 다음 쪽");
break;
case 2:
print_on_terminal(px,py++,"[ED 08-12-2189] (1/2)");
print_on_terminal(px,py++,"연구할 수 있는 샘플이라곤 하나도 안 남았는데");
print_on_terminal(px,py++,"연구 결과를 보고하라고? 젠텍 놈들 제정신이 아니군!");
print_on_terminal(px,py++,"화물선이 빨리 도착해야 할텐데.");
print_on_terminal(px,py++,"명목상으로는 광물을 들여오는 거지만, 실제로는");
print_on_terminal(px,py++,"그 속에 실험을 위한 외계 생물체들이 들어 있다.");
print_on_terminal(px,py++,"그러면 내 DNA 실험을 계속 할 수 있겠지!");
print_on_terminal(px,16,">1. 앞 쪽");
print_on_terminal(px,17,">2. 다음 쪽");
break;
case 3:
print_on_terminal(px,py++,"[ED 08-12-2189] (2/2)");
print_on_terminal(px,py++,"난 기다리기 지쳤다. 멍청한 광부들 중 실험을 도울");
print_on_terminal(px,py++,"사람을 찾아 보아야 할까? 아냐, 그놈들이 내 연구가");
print_on_terminal(px,py++,"얼마나 중요한지를 이해할 턱이 있나. 한치 앞도 내다보지");
print_on_terminal(px,py++,"못하는 멍청이들! 최근 들어서 몇 가지 의문사가");
print_on_terminal(px,py++,"발생했는데, 그놈들은 내 실험에서 생성된 생물체가");
print_on_terminal(px,py++,"원인이라고 의심한다. 내가 실험체들을 잘 가둬서 엄격하게");
print_on_terminal(px,py++,"관리하고 있다고 그렇게 설명을 했는데도 내 말을 믿지");
print_on_terminal(px,py++,"않는다. 의문사의 원인을 나에게서만 찾다니, 멍청한");
print_on_terminal(px,py++,"광부들 같으니라고. 자기들 중에 피에 환장한 연쇄 살인범이");
print_on_terminal(px,py++,"있을지 누가 알겠나.");
print_on_terminal(px,16,">1. 앞 쪽");
break;
default:;
}
myrefresh();
}
bool PLACES::GenLabBioRebuild()
{
print_program_1();
while(1)
{
int key = keyboard.wait_for_key();
if (key == keyboard.escape || key == keyboard.readmore || key == keyboard.readmore2)
{
break;
}
else if (key == '1')
{
level.player->hit_points.val = level.player->hit_points.max;
for (int a=0;a<NUMBER_OF_STATES;a++)
level.player->state[a]=0;
screen.console.add("테이블 위에 눕는다. 기계가 주사를 놓는다. 긴 꿈을 꾸기 시작한다...",7);
screen.console.add("악몽을 꾼다... 한참동안 긴 시간이 지난다. 몇 시간이 지났는지 알 수 없다. 지금은 아주 상쾌한 기분이다.",7);
level.player->wait(random(200)+100);
level.is_player_on_level = false;
level.monsters.remove(level.player);
level.map.setBlockMove(level.player->pX(),level.player->pY());
return true;
}
}
return false;
}
bool PLACES::GenLabDNAModif()
{
print_program_2();
while(1)
{
int key = keyboard.wait_for_key();
if (key == keyboard.escape || key == keyboard.readmore || key == keyboard.readmore2)
{
break;
}
}
return false;
}
bool PLACES::GenLabIntegration()
{
int character;
ITEM *temp;
CORPSE *cialo;
MONSTER *monster;
string text;
int zwracana;
print_program_3();
while(1)
{
int key = keyboard.wait_for_key();
if (key == keyboard.escape || key == keyboard.readmore || key == keyboard.readmore2)
{
break;
}
else if (key == '1')
{
level.player->show_backpack(NULL,INV_SHOW_HIGHLIGHT_CORPSES);
set_color(10);
text = " 어느 시체에서 DNA를 추출합니까? ";
level.player->adaptation_points = 6;
print_text(40-text.size()/2,0,text);
myrefresh();
while (1)
{
character=keyboard.wait_for_key();
if ((character>='a' && character<='z') || (character>='A' && character<='Z'))
{
temp=level.player->choose_item_from_backpack(character);
if (temp!=NULL) // gdy cos wybrano
{
cialo = temp->IsCorpse();
if (cialo!=NULL)
{
taken_DNA = cialo->of_what;
cialo->death();
print_program_3();
break;
}
}
}
else if (character==keyboard.escape || character==keyboard.readmore || character==keyboard.readmore2)
{
print_program_3();
break;
}
}
}
else if (key == '2')
{
if (taken_DNA!="")
{
monster = definitions.find_monster(taken_DNA);
draw_terminal();
int px=0,py=0;
print_on_terminal(px,py++,"박사님!");
print_on_terminal(px,py++,"이곳에 있는 생물은 당신 뿐입니다!");
print_on_terminal(px,py++,"정말로 당신을 합성 재료로 사용합니까?");
py++;
print_on_terminal(px,py++,"(y/n)");
py++;
print_on_terminal(px,py++,"(위험성을 깨달으셨습니까?)");
myrefresh();
zwracana=keyboard.wait_for_key();
if (zwracana!='y' && zwracana!='Y')
{
print_program_3();
break;
}
print_on_terminal(6,4,"Y");
myrefresh();
if (level.player->adaptation_points<1)
{
print_on_terminal(px,py++,"당신의 조직에는 이 DNA를 적용할 수 없습니다.");
myrefresh();
keyboard.wait_for_key();
print_program_3();
break;
}
print_on_terminal(px,py++,"시작합니다...");
delay(150);
myrefresh();
if (IntegratePlayerWith(monster)==false)
return false;
level.player->wait(random(500)+500);
level.is_player_on_level = false;
level.monsters.remove(level.player);
level.map.setBlockMove(level.player->pX(),level.player->pY());
return true;
}
}
}
return false;
}
#define LOG_PAGES 3
bool PLACES::GenLabPersonalLog()
{
int page = 1;
print_program_4(page);
while(1)
{
int key = keyboard.wait_for_key();
if (key == '1' && page>1)
page--;
else if (key == '2' && page<LOG_PAGES)
page++;
else if (key == keyboard.escape || key == keyboard.readmore || key == keyboard.readmore2)
{
break;
}
print_program_4(page);
}
return false;
}
bool PLACES::IntegratePlayerWith(MONSTER *monster)
{
if (monster==NULL)
return false;
level.player->adaptation_points--;
screen.console.add(" \"실험: DNA 합성을 시작합니다.\".\n",11);
screen.console.add("잠이 든다...\n",7);
screen.console.add("... ... ... ...\n",7);
screen.console.add("한참이 지난 후 잠에서 깨어난다.\n",7);
int random_value;
int new_value;
// power
if (level.player->strength.val < monster->strength.val)
screen.console.add("힘이 강해진 느낌이다...",7);
else if (level.player->strength.val > monster->strength.val)
screen.console.add("힘이 약해진 느낌이다...",7);
new_value = (level.player->strength.max + monster->strength.max)/2;
level.player->strength.val += new_value - level.player->strength.max;
level.player->strength.max = new_value;
// zrecznosc
if (level.player->dexterity.val < monster->dexterity.val)
screen.console.add("몸이 유연해진 느낌이다...",7);
else if (level.player->dexterity.val > monster->dexterity.val)
screen.console.add("몸이 경직된 느낌이다...",7);
new_value = (level.player->dexterity.max + monster->dexterity.max)/2;
level.player->dexterity.val += new_value - level.player->dexterity.max;
level.player->dexterity.max = new_value;
// wytrzymalosc
if (level.player->endurance.val < monster->endurance.val)
screen.console.add("몸이 강인해진 느낌이다...",7);
else if (level.player->endurance.val > monster->endurance.val)
screen.console.add("몸이 허약해진 느낌이다...",7);
new_value = (level.player->endurance.max + monster->endurance.max)/2;
level.player->endurance.val += new_value - level.player->endurance.max;
level.player->endurance.max = new_value;
// inteligencja
if (level.player->intelligence.val < monster->intelligence.val)
screen.console.add("사고가 명확해졌다...",7);
else if (level.player->intelligence.val > monster->intelligence.val)
screen.console.add("집중이 잘 안 된다...",7);
new_value = (level.player->intelligence.max + monster->intelligence.max)/2;
level.player->intelligence.val += new_value - level.player->intelligence.max;
level.player->intelligence.max = new_value;
// szybko
if (level.player->speed.val < monster->speed.val)
screen.console.add("행동이 재빨라졌다...",7);
else if (level.player->intelligence.val > monster->intelligence.val)
screen.console.add("행동이 둔해졌다...",7);
new_value = (level.player->speed.max + monster->speed.max)/2;
level.player->speed.val += new_value - level.player->speed.max;
level.player->speed.max = new_value;
// hit points
if (level.player->hit_points.max < monster->hit_points.max)
screen.console.add("생명력이 증가한 느낌이다...",7);
else if (level.player->hit_points.max > monster->hit_points.max)
screen.console.add("생명력이 감소한 느낌이다...",7);
new_value = (level.player->hit_points.max + monster->hit_points.max)/2;
level.player->hit_points.val += new_value - level.player->hit_points.max;
level.player->hit_points.max = new_value;
if (level.player->hit_points.val<=0)
level.player->hit_points.val=1;
// metabolizm
random_value = level.player->metabolism.val - monster->metabolism.val;
if (random_value>0) // player szybszy
{
if (random_value>4)
random_value=4;
random_value = random(random_value-1)+1;
level.player->metabolism.val-=random_value;
level.player->metabolism.val-=random_value;
}
else if (random_value<0) // player wolniejszy
{
if (random_value<4)
random_value=-4;
random_value = random(random_value-1)+1;
level.player->metabolism.val+=random_value;
level.player->metabolism.val+=random_value;
}
// skora
bool change = false;
if (level.player->no_armor.name != monster->no_armor.name)
{
if (level.player->no_armor.ARM < monster->no_armor.ARM)
{
level.player->no_armor.ARM++;
change = true;
}
else if (level.player->no_armor.ARM > monster->no_armor.ARM)
{
level.player->no_armor.ARM--;
change = true;
}
else // ARM jest takie samo, nabiera properties
{
for (PROPERTIES a=1;a!=TYPE_LAST_UNUSED;a+=a)
{
if (monster->no_armor.properties&a) // gdy ma ceche
{
if (!level.player->no_armor.properties&a) // gdy cechy nie ma
if (random(3)==0)
{
level.player->no_armor.properties^=a; // ustawiamy bit
change = true;
break;
}
}
else if (!monster->no_armor.properties&a) // gdy nie ma cechy
{
if (level.player->no_armor.properties&a) // gdy ma ceche
if (random(3)==0)
{
level.player->no_armor.properties^=a; // zerujemy w ten sposob dany bit
change = true;
break;
}
}
}
}
if (monster->no_armor.ARM == level.player->no_armor.ARM &&
monster->no_armor.properties == level.player->no_armor.properties)
{
screen.console.add(level.player->no_armor.name + "이 " + monster->no_armor.name + "으로 변형되었다.",7);
level.player->no_armor.name = monster->no_armor.name;
level.player->no_armor.color = monster->no_armor.color;
}
else if (change)
screen.console.add(level.player->no_armor.name + "이 " + monster->no_armor.name + "으로 변형되었다.",7);
}
// gole rece
change = false;
if (level.player->unarmed.name != monster->unarmed.name)
{
if (level.player->unarmed.DEF < monster->unarmed.DEF)
{
level.player->unarmed.DEF++;
change = true;
}
else if (level.player->unarmed.DEF > monster->unarmed.DEF)
{
level.player->unarmed.DEF--;
change = true;
}
if (level.player->unarmed.HIT < monster->unarmed.HIT)
{
level.player->unarmed.HIT++;
change = true;
}
else if (level.player->unarmed.HIT > monster->unarmed.HIT)
{
level.player->unarmed.HIT--;
change = true;
}
if (level.player->unarmed.DMG < monster->unarmed.DMG)
{
level.player->unarmed.DMG++;
change = true;
}
else if (level.player->unarmed.DMG > monster->unarmed.DMG)
{
level.player->unarmed.DMG--;
change = true;
}
for (PROPERTIES a=1;a<=TYPE_LAST_UNUSED;a+=a)
{
if (monster->unarmed.properties&a) // gdy ma ceche
{
if ((level.player->unarmed.properties&a)==0) // gdy cechy nie ma
{
change = true;
if (random(5)==0)
{
level.player->unarmed.properties^=a; // ustawiamy bit
break;
}
}
}
else if (!monster->unarmed.properties&a) // gdy nie ma cechy
{
if ((level.player->unarmed.properties&a)==0) // gdy cechy nie ma
{
change = true;
if (random(5)==0)
{
level.player->unarmed.properties^=a; // zerujemy w ten sposob dany bit
break;
}
}
}
}
if (change)
screen.console.add(level.player->unarmed.name + "은 변이를 일으킨다...",7);
else
{
screen.console.add(level.player->unarmed.name + "은 " + monster->unarmed.name + "으로 변형되었다!",7);
level.player->unarmed.name = monster->unarmed.name;
level.player->unarmed.color = monster->unarmed.color;
}
}
// resisty
for (int b=0;b<NUMBER_OF_RESISTS;b++)
{
if (level.player->resist[b]<monster->resist[b])
level.player->resist[b] += random(min(3,monster->resist[b] - level.player->resist[b]));
else if (level.player->resist[b]>monster->resist[b])
level.player->resist[b] -= random(min(3,level.player->resist[b] - monster->resist[b]));
}
level.player->set_weapon(&level.player->unarmed);
level.player->set_armor(&level.player->no_armor);
screen.console.add("\n \"DNA 합성이 완료되었습니다.\".",11);
return true;
}