This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zas.cpp
1836 lines (1612 loc) · 55.8 KB
/
zas.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
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include<string.h>
#include<dos.h>
#include<process.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<fstream.h>
#include<graphics.h>
#include<iostream.h>
class Profile
{
public:
int pfvalid;
char pfname[25];
char password[7];
int passvalid;
int mcount;
int hghscr;
int lstscr;
int zcount;
Profile()
{
pfvalid = 1;
strcpy(pfname, "default_profile");
passvalid = 0;
strcpy(password, "000000");
mcount = 0;
hghscr = 0;
lstscr = 0;
zcount = 0;
}
void ini()
{
pfvalid = 1;
strcpy(pfname, "default_profile");
passvalid = 0;
strcpy(password, "000000");
mcount = 0;
hghscr = 0;
lstscr = 0;
zcount = 0;
}
void storeCdata(char sstring[], char sstring2[], int cpassvalid)
{
pfvalid = 1;
passvalid = cpassvalid;
strcpy(pfname, sstring);
strcpy(password, sstring2);
}
void putdata()
{
cout<<"PROFILE: "<<pfname<<endl;
cout<<"TOTAL MATCHES PLAYED: "<<mcount<<endl;
cout<<"TOTAL ZOMBIES KILLED: "<<zcount<<endl;
cout<<"HIGHEST SCORE: "<<hghscr<<endl;
cout<<"LAST SCORE: "<<lstscr<<endl;
cout<<endl<<"<PRESS ENTER>"<<endl;
}
void restorepswrd(char pswrdrecovery[])
{
strcpy(password,pswrdrecovery);
}
void incmcount()
{
(this->mcount)++;
}
void deletepf()
{
pfvalid = 0;
strcpy(pfname, "NULL");
passvalid = 0;
strcpy(password, "000000");
mcount = 0;
hghscr = 0;
lstscr = 0;
zcount = 0;
}
};
class Obj
{
public:
char objname[15];
char title[50];
char descript[110];
char bravo[110];
int dref;
int valid;
float armour;
float health;
float attack;
int maxammo;
Obj(
char Cobjname[],
char Ctitle[],
char Cdescript[],
char Cbravo[],
int Cdref,
int Cvalid,
float Carmour,
float Chealth,
float Cattack,
int Cmaxammo)
{
strcpy(objname, Cobjname);
strcpy(title, Ctitle);
strcpy(descript, Cdescript);
strcpy(bravo, Cbravo);
dref = Cdref;
valid = Cvalid;
armour = Carmour;
health = Chealth;
attack = Cattack;
maxammo = Cmaxammo;
}
Obj()
{
strcpy(objname, "\n");
strcpy(title, "\n");
strcpy(descript, "\n");
strcpy(bravo, "\n");
dref = 0;
valid = 0;
armour = 0.0;
health = 0.0;
attack = 0.0;
maxammo = 0;
}
};
class RoomSlots
{
public:
char objname[15];
char title[50];
char descript[110];
char bravo[110];
int dref;
int valid;
float armour;
float health;
float attack;
int maxammo;
RoomSlots(
char Cobjname[],
char Ctitle[],
char Cdescript[],
char Cbravo[],
int Cdref,
int Cvalid,
float Carmour,
float Chealth,
float Cattack,
int Cmaxammo)
{
strcpy(objname, Cobjname);
strcpy(title, Ctitle);
strcpy(descript, Cdescript);
strcpy(bravo, Cbravo);
dref = Cdref;
valid = Cvalid;
armour = Carmour;
health = Chealth;
attack = Cattack;
maxammo = Cmaxammo;
}
RoomSlots()
{
strcpy(objname, "\n");
strcpy(title, "\n");
strcpy(descript, "\n");
strcpy(bravo, "\n");
dref = 0;
valid = 0;
armour = 0.0;
health = 0.0;
attack = 0.0;
maxammo = 0;
}
}; //LivingRoom[],Kitchen[],Backyard[],LocalInfirmary[],Streets[],Church[],PoliceStation[]
class Enemy
{
public:
char btype[25];
float zhealth;
float zattack;
Enemy(
char Cbtype[],
float Czhealth,
float Czattack)
{
strcpy(btype, Cbtype);
zhealth = Czhealth;
zattack = Czattack;
}
Enemy()
{
strcpy(btype, "\n");
zhealth = 0.0;
zattack = 0.0;
}
};
Enemy Zombie[3] = {
Enemy("LEAN AND THIN ZOMBIE",15,2),
Enemy("FAT ZOMBIE",20,3),
Enemy("ACID ZOMBIE",100,15)
};
//i. DATABASE INI.
fstream file("PLAYPROF.dat", ios::in|ios::out|ios::binary);
Profile player;
//ii. OBJECT INI.
//livingroom
Obj infinitystone0999("INFINITY STONE","","You found an Infinity Stone at a secret location.","Picked up Infinity Stone. ATTACK:40.0",999,1,0,999,40.0,999);
Obj torch1000("LIGHT-TORCH","A PHOSPHORUS TORCH","UTILITY: increase surrounding awareness","You picked up torch, which enhances visibility and thus, attack potential. ATTACK:2.5",1000,1,0,15,2.5,15);
Obj redbull1001("REDBULL CAN","A REDBULL CAN","Redbull is an Energy Drink!","You got wings. HEALTH:+2.0",1001,1,0,2.0,0,0);
Obj tv1002("TV","TV MONITOR","TV, turn on/off (!turning on may attract zombies from the streets)","\n",1002,1,0,0,0,0);
Obj bed1003("BED","BED","Bed? Take a nap.","You took a nap, your vital signs look good. HEALTH:+0.2",1003,1,0,0.2,0,0);
Obj umbrella1004("UMBRELLA","OLD TORN UMBRELLA","Umbrella, good-to-go weapon.","You picked up UMBRELLA. ATTACK:3.0",1004,1,0,16,3.0,16);
//kitchen
Obj stalebread1005("STALE BREAD","SOME STALE BREAD","Stale bread, take a taste","You ate the bread. HEALTH:+2.0",1005,1,0,2.0,0,0);
Obj knife1006("KNIFE","A BUTCHER'S KNIFE","Zombie-Butcher!","You picked up a knife. ATTACK:6.0",1006,1,0,12,6.0,12);
Obj cookies1007("COOKIES","SCATTERED BAKED COOKIES","Fresh cookies, have some maybe?","You ate cookies. HEALTH:+3.0",1007,1,0,3.0,0,0);
Obj fork1008("FORK","A FORK ON THE CROKERY HANGER","Fork?...is a very small weapon.","You picked up a fork. ATTACK:1.5",1008,1,0,5,1.5,5);
Obj oldjacket1009("OLD JACKET","AN OLD JACKET","Thick, old, jacket. Hard to penetrate.","You put the jacket on. ARMOUR LEVEL 1",1009,1,1.08,0,0,0);
Obj vinegar1010("VINEGAR","SPILLED VINEGAR","Vinegar has strong stench. Apply to cover scent and distract attacking zombies.","You used Vinegar. HEALTH:+0.80",1010,1,0,0.8,0,0);
Obj tap1011("WATER TAP","LEAKING WATER TAP","Drink Water.","You drank water. HEALTH:+0.25",1011,1,0,0.25,0,0);
Obj china1012("CHINAWARE","CHINAWARE ON THE CROCKERY HANGER","Examine.","Expensive, shiny, china bowl.",1012,1,0,0,0,0);
Obj molotov1013("MOLOTOVS","PETROL BOMBS","Explosives, what are you thinking?","You picked up Molotovs. ATTACK:7.0",1013,1,0,4,7,4);
Obj cell1014("CELL PHONE","CELL PHONE NEAR THE STOVE","Examine.","Battery is dead. Cell phone cannot be used.",1014,1,0,0,0,0);
//backyard
Obj leaf1015("LEAF","GREEN MAPLE LEAF","Maple leaf has medicinal value.","You extracted health. HEALTH:+10.0",1015,1,0,10,0,0);
//localinfirmary
Obj medikit1016("MEDIKIT","MEDIKIT ON THE DESK","Medikit will help you gain health.","You gained health. HEALTH:+15.0",1016,1,0,15,0,0);
Obj rottenapple1017("APPLE","AN APPLE ON THE FLOOR","Pick it up.","The Apple is too rotten to be eaten.",1017,1,0,0,0,0);
Obj gun1018("DESERT EAGLE","A COLT PISTOL","It's a loaded Desert Eagle pistol!","You picked up a pistol. ATTACK:10.0",1018,1,0,15,10,15);
Obj policevest1019("POLICE-VEST","BLOOD STAINED POLICE-VEST","Police-Vest is a Professional Armour.","You put Polive-vest on. ARMOUR LEVEL 2",1019,1,1.15,0,0,0);
Obj bandages1020("BANDAGES","A PAIR OF BANDAGES","You gain health when you apply bandages.","You applied bandages. HEALTH:+2.0",1020,1,0,2.0,0,0);
Obj books1021("BOOKS","BOOKS ON THE SHELF","Read Contents.","Books of a medical practitioner.",1021,1,0,0,0,0);
//streets
Obj rod1022("IRON ROD","A BROKEN IRON ROD","It's heavy and broken sharp at one end... could be a weapon.","You picked up the rod. ATTACK:8.0",1022,1,0,50,8,50);
Obj garbage1023("GARBAGE","AN ERECT GARBAGE TIN BY THE SIDE OF THE STREET","Look in.","There is a slurry of orange zombie blood.",1023,1,0,0,0,0);
Obj car1024("CAR","A BROKEN DOWN CAR AT THE END OF THE STREET","Look into it.","Dead person on the seat, infected with the zombie virus.\nWill turn into a zombie soon.",1024,1,0,0,0,0);
//church
Obj dagger1025("DAGGER","A DAGGER","Dagger is sharp to cut.","You picked up the dagger. ATTACK:8.0",1025,1,0,30,8,30);
Obj photo1026("PHOTOGRAPH","PHOTOGRAPH ON THE WALL","Take a look.","Painting of \'The Last Supper\'.",1026,1,0,0,0,0);
Obj dead1027("DEAD","A DEAD BODY NEAR THE ALTAR","Take a close look.","The body has been melted with what seems to be a kind of smoking, green slurry.",1027,1,0,0,0,0);
Obj medikit1028("MEDIKIT","MEDIKIT","Medikit will help you gain health.","You gained health. HEALTH+15.0",1028,1,0,15,0,0);
//ps
Obj rifle1029("WINCHESTER-94","A RIFLE","WINCHESTER-94 SHRAPNEL THROWER is a professional zombie killer!","You picked up the Winchester Rifle. ATTACK:15.0",1029,1,0,0,15,25);
Obj shrapnel1030("AMMO","AMMO CRATE","Open.","You picked up 12 shrapnels for Win-94.",1030,1,0,20,0,12);
Obj acidstain1031("STAIN","SOME GREEN STAIN ON THE FLOOR,","Examine.","There have been acid stains before. Why are they here?",1031,1,0,0,0,0);
Obj dirt1032("DIRT","UNUSUAL GOOEY DIRT ON THE FLOOR AT ANOTHER PLACE","Examine.","The lumps have presence of zombie-blood.",1032,1,0,0,0,0);
Obj medikit1033("MEDIKIT","AN UNLOCKED MEDIKIT","Medikit will help you gain health.","You gained health. HEALTH:+15.0",1033,1,0,15,0,0);
Obj dead1034("DEAD","ANOTHER DEAD BODY (OF A POLICEMAN)","Examine.","His pocket might have car keys. He was trying to escape.\nThere is a police car parked outside.",1034,1,0,0,0,0);
Obj keys1035("KEYS","SOMETHING UNDER THE OFFICER'S HAND","Examine.","Car Keys.",1035,1,0,0,0,0);
//FIRST PERSON GLOBAL PARAMETERS
float health = 10;
Obj slotobj[2] = {Obj("hand is free","empty","empty","empty",0,0,0.0,0.0,1.0,0),
Obj("hand is free","empty","empty","empty",0,0,0.0,0.0,1.0,0)};
Obj armourobj("empty","empty","empty","empty",0,0,1.0,0.0,0.0,0);
int points = 0;
int kills = 0;
char in[20];
//default OBJECT STATIONS INI.
RoomSlots LivingRoom[6];
RoomSlots Kitchen[10];
RoomSlots Backyard[1];
RoomSlots LocalInfirmary[10];
RoomSlots Streets[3];
RoomSlots Church[4];
RoomSlots PS[8];
//MISC. VARIABLES
char ch=' ';
char str[30];
char gpassword[15];
char gpassvalid;
char input[15];
int i_temp;
int alertflag = 0;
int flag = 0;
int c = 0;
Obj temp;
int _swap;
//FUNCTIONS INI.
void infoscrn(void);
void loadscrn(void);
void initialise(void);
void smenu(void);
int noprofile(void);
void updatestat(void);
void titlebox(void);
char cmdinp(char);
void introd(void);
void inventory(void);
int ceil(float);
void numbar(float, int);
void askswap(void);
void battle(int);
void gameover(void);
void replenish(int);
void zkillACue(void);
void gamelostACue(void);
void gamewinACue(void);
void livingroom(void);
void kitchen(void);
void backyard(void);
void localinfirmary(void);
void streets(void);
void church(void);
void ps(void);
void livingroomtext(void);
void kitchentext(void);
void backyardtext(void);
void localinfirmarytext(void);
void streetstext(void);
void churchtext(void);
void pstext(int);
//FUNCTION DEFINITIONS
void main() { loadscrn(); while(1) smenu(); }
void loadscrn()
{
int gd2 = DETECT, gm2;
initgraph(&gd2,&gm2,"c:\\turboc3\\bgi");
int c = 67, x = 310, y = 185;
setbkcolor(0);
for (int i = 1; i <= c; i++)
{
clrscr();
int points[]=
{
x-75,y+125,x-100,y-75,x-75,y-67,x-72,y-84,x-69,y-94,x-50,y-119,
x-8,y-140,x+40,y-138,x+64,y-127,x+78,y-115,x+90,y-99,x+100,y-75,
x+125,y-60,x+100,y+125,x+35,y+125,x+35,y+100,x+30,y+5,x+25,y+18,
x+32,y-75,x+19,y-87,x+24,y-76,x+18,y-48,x+18,y-75,x-8,y-89,x+3,
y-75,x+3,y-46,x-13,y-80,x-45,y-78,x-23,y-75,x-10,y-48,x-35,y-65,
x-52,y-50,x-33,y-52,x-15,y-30,x-15,y-10,x-32,y-5,x-50,y-18,x-36,
y+9,x-13,y+13,x-13,y+27,x-16,y+23,x-18,y+125,x-75,y+125
};
setcolor(0);
setfillstyle(1,0);
bar(x-115,y-155,x+138,y+190);
setcolor(0);
setfillstyle(9,15);
fillpoly(43,points);
setcolor(0);
setfillstyle(1,0);
fillellipse(x-40,y+125,25,25);
fillellipse(x-10,y+120,25,25);
fillellipse(x+25,y+135,25,25);
fillellipse(x+55,y+125,25,25);
setcolor(15);
settextstyle(0,HORIZ_DIR,4);
outtextxy(x-82,y+145,"ZOMBIE");
settextstyle(0,HORIZ_DIR,1);
outtextxy(x-78,y+178,"APOCALYPSE SURVIVOR 1.1");
line(x-115,y+135,x+138,y+135);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n ";
for (int j = 1; j <= i; j++) { if(i == 1) break; cout<<char(178); }
for (int k = i+1; k <= c; k++) { cout<<char(176); }
cout<<endl;
if(i == 1) { cout<<"\t\t\t Waiting to Load..."; delay(1000); }
else if(i<67)
cout<<"\t\t\t\tLoading...( "<<int(i/67.0*100.0)<<"% )";
else
{
cout<<"\t\t\t\tLoading...( "<<int(i/67.0*100.0)<<"% )"<<endl;
cout<<"\t\t < LOADING COMPLETE : PRESS ENTER >";
}
delay(25);
}
getch();
}
void initialise()
{
memcpy(&LivingRoom[0],&torch1000,sizeof(torch1000));
memcpy(&LivingRoom[1],&redbull1001,sizeof(redbull1001));
memcpy(&LivingRoom[2],&tv1002,sizeof(tv1002));
memcpy(&LivingRoom[3],&bed1003,sizeof(bed1003));
memcpy(&LivingRoom[4],&umbrella1004,sizeof(umbrella1004));
memcpy(&LivingRoom[5],&infinitystone0999,sizeof(infinitystone0999));
memcpy(&Kitchen[0],&stalebread1005,sizeof(stalebread1005));
memcpy(&Kitchen[1],&knife1006,sizeof(knife1006));
memcpy(&Kitchen[2],&cookies1007,sizeof(cookies1007));
memcpy(&Kitchen[3],&fork1008,sizeof(fork1008));
memcpy(&Kitchen[4],&oldjacket1009,sizeof(oldjacket1009));
memcpy(&Kitchen[5],&vinegar1010,sizeof(vinegar1010));
memcpy(&Kitchen[6],&tap1011,sizeof(tap1011));
memcpy(&Kitchen[7],&china1012,sizeof(china1012));
memcpy(&Kitchen[8],&molotov1013,sizeof(molotov1013));
memcpy(&Kitchen[9],&cell1014,sizeof(cell1014));
memcpy(&Backyard[0],&leaf1015,sizeof(leaf1015));
memcpy(&LocalInfirmary[0],&medikit1016,sizeof(medikit1016));
memcpy(&LocalInfirmary[1],&rottenapple1017,sizeof(rottenapple1017));
memcpy(&LocalInfirmary[2],&gun1018,sizeof(gun1018));
memcpy(&LocalInfirmary[3],&policevest1019,sizeof(policevest1019));
memcpy(&LocalInfirmary[4],&bandages1020,sizeof(bandages1020));
memcpy(&LocalInfirmary[5],&books1021,sizeof(books1021));
memcpy(&Streets[0],&rod1022,sizeof(rod1022));
memcpy(&Streets[1],&garbage1023,sizeof(garbage1023));
memcpy(&Streets[2],&car1024,sizeof(car1024));
memcpy(&Church[0],&dagger1025,sizeof(dagger1025));
memcpy(&Church[1],&photo1026,sizeof(photo1026));
memcpy(&Church[2],&dead1027,sizeof(dead1027));
memcpy(&Church[3],&medikit1028,sizeof(medikit1028));
memcpy(&PS[0],&rifle1029,sizeof(rifle1029));
memcpy(&PS[1],&shrapnel1030,sizeof(shrapnel1030));
memcpy(&PS[2],&acidstain1031,sizeof(acidstain1031));
memcpy(&PS[3],&dirt1032,sizeof(dirt1032));
memcpy(&PS[4],&medikit1033,sizeof(medikit1033));
memcpy(&PS[5],&dead1034,sizeof(dead1034));
memcpy(&PS[6],&keys1035,sizeof(keys1035));
}
void smenu()
{
clrscr();
titlebox();
flag = 0;
int _cpass;
i_temp = 0;
c = 0;
char dec;
int i_o;
file.seekg(0, ios::beg);
cout<<"\t\t\t <-A-> <-CREATE_NEW_PROFILE->"<<endl<<endl;
cout<<"\t\t\t\t :START GAME: "<<endl<<endl;
cout<<"\t\t\t <-B-> <-USE_EXISTING_PROFILE->"<<endl<<endl;
cout<<"\t\t\t\t :EXPLORE: "<<endl<<endl;
cout<<"\t\t\t<-C-> <-ERASE_EXISTING_PROFILE->"<<endl<<endl;
cout<<"\t\t\t <-D-> <-VIEW_STATISTICS->"<<endl<<endl;
cout<<"\t\t\t <-E-> <-HALL_OF_FAME->"<<endl<<endl;
cout<<"\t\t\t <-F-> <-CREDITS->"<<endl<<endl;
cout<<"\t\t\t <-Q-> <-QUIT->"<<endl<<endl<<endl;
cout<<"\t\t\t+> ";
ch = cmdinp('m');
switch(ch)
{
case 'a' : flag = 0;
dec=' ';
i_o=1;
_cpass=0;
gpassvalid=0;
clrscr();
titlebox();
cout<<endl<<"Enter profile name:\n +> ";
gets(str);
if (strlen(str)>20 || strlen(str)<1)
{
cout<<"Max. and min. characters are 20 and 1, repectively. Please try again.\n<PRESS ENTER>";
getch();
smenu();
}
while(file.read((char*)&player, sizeof(player)))
{ c++; if(player.pfvalid && !strcmpi(player.pfname,str)) { cout<<"Profile name already exists. Please try again.\n<PRESS ENTER>"; getch(); i_o=0; break; } }
for (int i=5 ; (dec!='Y' && dec!='y' && dec!='N' && dec!='n' && i_o==1) ; i++)
{
cout<<"\nDo you want to protect your profile with a password <Y/N> ? ";
cin>>dec;
if (dec=='Y' || dec=='y')
{
cout<<"Enter new password of 6 characters : "; gets(gpassword);
for (int j=5;j>1 && (strlen(gpassword)!=6);j++)
{
cout<<"Password should be of 6 characters. Enter password again : ";
gets(gpassword);
if(strlen(gpassword)==6) { gpassvalid=1; break; }
}
gpassvalid=1;
_cpass=1;
}
else if(dec!='Y' && dec!='y' && dec!='N' && dec!='n') { cout<<"Wrong choice!\n<PRESS ENTER>\n"; getch(); break; }
else { _cpass=2; gpassvalid=0; }
}
if(file.eof()) file.clear();
if(_cpass)
{
player.ini();
player.storeCdata(str,gpassword,gpassvalid);
updatestat();
cout<<"\nNew profile is created.\n<PRESS ENTER>";
getch();
}
smenu();
break;
case 'b' : flag = 0;
clrscr();
titlebox();
_cpass=0;
if(noprofile()) break;
cout<<"Existing profiles:\n\n";
while(file.read((char*)&player, sizeof(player)))
if(player.pfvalid) cout<<++i_temp<<". "<<player.pfname<<endl;
file.clear();
file.seekg(0, ios::beg);
cout<<endl<<"Enter profile name:\n +> ";
gets(str);
i_temp = 0;
while(file.read((char*)&player, sizeof(player)))
{
c++;
if(player.pfvalid && !strcmpi(player.pfname,str))
{
flag = 1;
if(player.passvalid==1)
{
cout<<"Enter profile password : ";
gets(gpassword);
if(!strcmp(player.password,gpassword)) { _cpass=1; break; }
else { break; }
}
else { _cpass=1; break; }
}
}
if(file.eof()) file.clear();
if(flag && _cpass) { cout<<"\nWelcome!"; delay(800); file.seekg((c-1)*(sizeof(player))); introd(); }
else if(flag && _cpass==0) { cout<<"Incorrect Password. Please try again.\n<PRESS ENTER>\n"; getch(); }
else { cout<<"Player not found. Try again! <PRESS ENTER>"; getch(); }
smenu();
break;
case 'c' : flag = 0;
clrscr();
titlebox();
_cpass=0;
if(noprofile()) break;
cout<<"Existing profiles:\n\n";
while(file.read((char*)&player, sizeof(player)))
if(player.pfvalid) cout<<++i_temp<<". "<<player.pfname<<endl;
file.clear();
i_temp = 0;
file.seekg(0, ios::beg);
cout<<endl<<"Enter profile to be removed:\n +> ";
gets(str);
i_o=0;
while(file.read((char*)&player, sizeof(player)))
{
c++;
if(player.pfvalid && !strcmpi(player.pfname,str))
{
flag = 1;
if(player.passvalid==1)
{
cout<<"Enter profile password : ";
gets(gpassword);
if(!strcmp(player.password,gpassword)) { _cpass=1; break; }
else { break; }
}
else { _cpass=1; break; }
}
else i_o=1;
}
if(file.eof()) file.clear();
if(flag && _cpass) { file.seekg((c-1)*(sizeof(player))); player.deletepf(); updatestat();
cout<<"Profile is succesfully deleted.\n<PRESS ENTER>";getch(); smenu(); }
else if(flag && _cpass==0) { cout<<"Incorrect Password. Please try again.\n<PRESS ENTER>\n"; getch(); smenu(); }
else if(i_o) { cout<<"Player not found. Try again! <PRESS ENTER>"; getch(); smenu(); }
break;
case 'd' : flag = 0;
clrscr();
titlebox();
if(noprofile()) break;
cout<<"Existing profiles:\n\n";
while(file.read((char*)&player, sizeof(player)))
if(player.pfvalid) cout<<++i_temp<<". "<<player.pfname<<endl;
file.clear();
i_temp = 0;
file.seekg(0, ios::beg);
cout<<endl<<"Enter profile name:\n +> ";
gets(str);
while(file.read((char*)&player, sizeof(player)))
if(player.pfvalid && !strcmpi(player.pfname,str)) { flag = 1; break; }
if(file.eof()) file.clear();
if(flag) { cout<<endl; player.putdata(); getch(); }
else { cout<<"Player not found. Try again! <PRESS ENTER>"; getch(); smenu(); }
smenu();
break;
case 'e' : clrscr();
titlebox();
if(noprofile()) break;
while(file.read((char*)&player, sizeof(player))) { if(player.pfvalid) { player.putdata(); getch(); } }
cout<<"\n\n<PRESS ENTER>\n\n";
if(file.eof()) file.clear();
smenu();
break;
case 'i' : clrscr();
titlebox();
while(file.read((char*)&player, sizeof(player))) { cout<<"PFVALID: "<<player.pfvalid<<" PASSVALID: "<<player.passvalid<<" PASSWORD: "<<player.password<<endl; player.putdata(); getch(); }
cout<<"\n\n<PRESS ENTER>\n\n";
if(file.eof()) file.clear();
smenu();
break;
case 'f' : clrscr();
titlebox();
setbkcolor(15);
cout<<" Designed, composed, programmed, and tested by :\n\n\t(1) Abesh Roy ([email protected]),\n\n\t(2) Jayanta Pandit ([email protected])\n\n\t(3) Sourish Mandal\n\n\t(4) Kunal Samanta";
getch();
smenu();
break;
case 'q' : setbkcolor(0); system("CLS"); exit(0);
default : cout<<"Please provide a valid choice. <PRESS ENTER>";
getch();
smenu();
}
}
int noprofile()
{
c=0;
file.seekg(0, ios::end);
if(!file.tellg()) { cout<<"No existing profiles found.\nPlease create a new one and come back to continue :)\n<PRESS ENTER>"; getch(); file.seekg(0); return 1; }
file.seekg(0);
while(file.read((char*)&player, sizeof(player)))
if(player.pfvalid) { file.seekg(0); return 0; }
cout<<"No existing profiles found.\nPlease create a new one and come back to continue :)\n<PRESS ENTER>";
getch();
file.seekg(0);
if(file.eof()) file.clear();
return 1;
}
void updatestat() { file.write((char*)&player, sizeof(player)); player.ini(); file.seekg(0); }
void titlebox()
{
clrscr();
system("CLS");
setbkcolor(4);
for(int i = 1; i <= 23; i++) cout<<char(219);
cout<<"> ZOMBIE APOCALYPSE SURVIVOR 1.1 <";
for(i = 1; i <= 23; i++) cout<<char(219);
cout<<endl<<endl;
}
char cmdinp(char iota)
{
gets(input);
if(iota == 'g')
{
if(!strcmpi(input,"1")) return '1';
else if(!strcmpi(input,"2")) return '2';
else if(!strcmpi(input,"3")) return '3';
else if(!strcmpi(input,"4")) return '4';
else if(!strcmpi(input,"5")) return '5';
else if(!strcmpi(input,"6")) return '6';
else if(!strcmpi(input,"7")) return '7';
else if(!strcmpi(input,"8")) return '8';
else if(!strcmpi(input,"9")) return '9';
else if(!strcmpi(input,"0")) return '0';
else if(!strcmpi(input,"i")) return 'i';
else if(!strcmpi(input,"e")) return 'e';
else if(!strcmpi(input,"r")) return 'r';
else if(!strcmpi(input,"h")) return 'h';
else if(!strcmpi(input,"t")) return 't';
else if(!strcmpi(input,"c")) return 'c';
else if(!strcmpi(input,"infinityfun")) return 'z';
else if(!strcmpi(input,"icanjump")) return 'y';
else if(!strcmpi(input,"makemehealthy")) return 'm';
else return 'x';
}
else if(iota == 'b')
{
if(!strcmpi(input,"1")) return '1';
else if(!strcmpi(input,"2")) return '2';
else return 'x';
}
else if(iota == 'm')
{
if(!strcmpi(input,"a")) return 'a';
else if(!strcmpi(input,"b")) return 'b';
else if(!strcmpi(input,"c")) return 'c';
else if(!strcmpi(input,"d")) return 'd';
else if(!strcmpi(input,"e")) return 'e';
else if(!strcmpi(input,"f")) return 'f';
else if(!strcmpi(input,"q")) return 'q';
else if(!strcmpi(input,"i")) return 'i';
}
}
void introd()
{
initialise();
replenish(2);
titlebox();
setbkcolor(BLUE);
cout<<"\n<PRESS ENTER>"<<endl<<endl; getch();
cout<<"A dark world."<<endl;
cout<<"It has been 84 days since the experimental bio-weapon exploded in the Genetics Research Laboratory, located in NorthWest Downtown of the City, releasing a deadly bioengineered virus in the locality. This virus is turning common people into Zombies. Most of the people have been evacuated from the city, leaving only a few including you and others who couldn't survive and succumbed to transform into the living dead. You need to save your life, remain in the shadows, use all available resources and push through to reach the Police Headquarter some 500 metres to your location. You will likely find some help there."<<endl;
cout<<"\n<PRESS ENTER>"<<endl; getch();
cout<<endl;
cout<<"Let\'s do this "<<player.pfname<<"!"<<endl;
cout<<"\n<PRESS ENTER>"<<endl; getch();
cout<<endl<<"You are in a dark room, in your house. Lights must remain off, as not to alert the zombies in the streets of human presence. You are hungry, thirsty, and too weak to fight. Your supplies have exhausted. You need to go out and do something. Go now, and explore: take the things that are necessary."<<endl;
cout<<"\n<PRESS ENTER>"<<endl; getch();
cout<<endl;
cout<<"Things you can do:\n Press I for displaying inventory\n Press R for redisplaying room description\n Press E for exiting from the game.\n Rest of the interactions can be done through number keys."<<endl;
cout<<"\n<PRESS ENTER>\n";
getch();
livingroom();
}
void inventory()
{
cout<<endl<<"ROOM :"<<endl;
cout<<" "<<in<<endl;
cout<<"INVENTORY:"<<endl;
cout<<" HEALTH > ";
numbar(health, 80);
cout<<endl;
if(armourobj.armour>1)
{
cout<<" ARMOUR > LEVEL ";
if(armourobj.armour<1.1) cout<<"1";
else cout<<2;
cout<<endl;
}
cout<<" ATTACK > "<<slotobj[0].attack+slotobj[1].attack<<endl;
cout<<"YOU ARE CARRYING: \nWEAPON(S): <"<<slotobj[0].objname<<":"<<((slotobj[0].health<=0)?0:slotobj[0].health)<<"/"<<slotobj[0].maxammo<<"> <"<<slotobj[1].objname<<":"<<((slotobj[1].health<=0)?0:slotobj[1].health)<<"/"<<slotobj[1].maxammo<<">";
cout<<endl<<"ARMOUR: <"<<armourobj.objname<<">"<<endl;
}
int ceil(float _fmp) { return (int(_fmp)+1); }
void numbar(float lim1, int lim2)
{
int counter;
counter = 1;
cout<<"< ";
while(counter<=ceil(lim1/2.5)) { if(lim1==0) break; cout<<(char)178; counter++; }
while(counter<=(int)(lim2/2.5)) { cout<<(char)176; counter++; }
cout<<" >";
}
void askswap()
{
char _k;
cout<<endl<<"CHOOSE SLOT : "<<endl;
cout<<"(1) <"<<slotobj[0].objname<<":"<<slotobj[0].health<<"/"<<slotobj[0].maxammo<<">"<<endl;
cout<<"(2) <"<<slotobj[1].objname<<":"<<slotobj[1].health<<"/"<<slotobj[1].maxammo<<">"<<endl;
cout<<"\n +> ";
cin>>_k;
if(_k!='1' && _k!='2') { cout<<"Please retry."; askswap(); }
else _swap = ((_k=='1')?0:1);
_k=0;
cout<<endl;
}
void battle(int fmp)
{
setbkcolor(0);
if(fmp==0)
{
int q; int p;
cout<<"\n<PRESS ENTER>"<<endl<<endl;
getch();
randomize();
q = random(1000)%2;
cout<<"Zombie type: "<<Zombie[q].btype<<endl;
cout<<"Zombie health : "<<Zombie[q].zhealth<<endl;
cout<<"Zombie attack : "<<Zombie[q].zattack<<endl<<endl<<"<PRESS ENTER>"<<endl;
getch();
while(Zombie[q].zhealth>0 && health>0)
{
cout<<"\nPress 1 to attack.\nPress 2 to try to dodge its attacks."<<endl;
cout<<"\n +> ";
ch = cmdinp('b');
switch(ch)
{
case '1' :
randomize(); p = random(1000)%2; cout<<"\nPerforming attack with <"<<slotobj[p].objname<<":"<<(((slotobj[p].health)>0)?slotobj[p].health:0)<<"/"<<slotobj[p].maxammo<<">";
cout<<" <PRESS ENTER>"<<endl; getch();
if(slotobj[p].health<=0) { slotobj[p].attack = 1.0; if(slotobj[p].dref!=0) cout<<"\nWeapon depleted. "; cout<<"Using melee. ATTACK:1.0"<<endl; getch(); }
else cout<<"USES REMAINING: "<<slotobj[p].health-1<<endl;
slotobj[p].health--;
Zombie[q].zhealth-=(slotobj[p].attack + ((alertflag>0)?-0.5:0));
randomize();
if((random(1000)%2)==0) health-=(Zombie[q].zattack/(2+armourobj.armour));
cout<<endl<<"Your Health: ";
((health>0)?numbar(health, 80):numbar(0,80));
cout<<endl<<endl;;
cout<<endl<<"Zombie's health: ";
((((Zombie[q].zhealth)>0)?numbar(Zombie[q].zhealth,((q==0)?15:20)):numbar(0,((q==0)?15:20))));
cout<<endl<<endl;
break;
case '2' :
randomize(); if((random(1000)%3)==0) health-=((Zombie[q].zattack)/armourobj.armour);
cout<<"\nYour Health: ";
((health>0)?numbar(health, 80):numbar(0,80));
cout<<endl<<endl;
cout<<"Zombie's health: ";
(((Zombie[q].zhealth)>0)?numbar(Zombie[q].zhealth,((q==0)?15:20)):numbar(0,((q==0)?15:20)));
cout<<endl<<endl;
break;
case 'e' : gameover(); smenu();
case 'i' : inventory(); break;
default :
cout<<"\nProvide a valid choice. Hurry up, the zombie is attacking you."<<endl<<endl;
health-=((Zombie[q].zattack)/armourobj.armour);
cout<<"Your Health: ";
((health>0)?numbar(health, 80):numbar(0,80));
cout<<endl<<endl;
cout<<"Zombie's health: ";
(((Zombie[q].zhealth)>0)?numbar(Zombie[q].zhealth,((q==0)?15:20)):numbar(0,((q==0)?15:20)));
cout<<endl<<endl;
break;
}
}
if (health<=0) { cout<<"Game over! You died.\n<PRESS ENTER>"<<endl; gamelostACue();getch(); gameover(); smenu(); }
cout<<"You killed the zombie."<<endl; zkillACue();
cout<<"Consider checking your health and weapon status. <PRESS ENTER>"<<endl;
getch();
kills++;
if(q == 0) points += 10;
else points += 15;
replenish(1);
}
else
{
int p;
cout<<"\n<PRESS ENTER>"<<endl<<endl;
getch();
cout<<"Zombie type: "<<Zombie[2].btype<<endl;
cout<<"Zombie health : "<<Zombie[2].zhealth<<endl;
cout<<"Zombie attack : "<<Zombie[2].zattack<<endl<<"\n\n<PRESS ENTER>"<<endl<<endl;
getch();
while(Zombie[2].zhealth>0 && health>0)
{
cout<<"\nPress 1 to attack.\nPress 2 to try to dodge its attacks."<<endl;
cout<<"\n +> ";
ch = cmdinp('b');
switch(ch)
{
case '1' :
randomize(); p = random(1000)%2; cout<<"Performing attack with <"<<slotobj[p].objname<<":"<<(((slotobj[p].health)>0)?slotobj[p].health:0)<<"/"<<slotobj[p].maxammo<<">";
cout<<" <PRESS ENTER>"<<endl; getch();
if(slotobj[p].health<=0) { slotobj[p].attack = 1.0; if(slotobj[p].dref!=0) cout<<"\nWeapon depleted. "; cout<<"Using melee. ATTACK:1.0"<<endl; getch(); }
else cout<<"USES REMAINING: "<<slotobj[p].health-1<<endl;
(slotobj[p].health)--;
Zombie[2].zhealth-=(slotobj[p].attack + ((alertflag>0)?-0.5:0));
health-=(Zombie[2].zattack/(2+armourobj.armour));
cout<<"Your Health: ";
((health>0)?numbar(health, 80):numbar(0,80));
cout<<endl<<endl;
cout<<"Zombie's health: ";
(((Zombie[2].zhealth)>0)?numbar(Zombie[2].zhealth,100):numbar(0,100));
cout<<endl<<endl;
break;
case '2' :
randomize(); if((random(1000)%3)==0)
health-=((Zombie[2].zattack)/armourobj.armour);
cout<<"\nYour Health: ";
((health>0)?numbar(health, 80):numbar(0,80));
cout<<endl<<endl;
cout<<"Zombie's health: ";
(((Zombie[2].zhealth)>0)?numbar(Zombie[2].zhealth,100):numbar(0,100));
cout<<endl<<endl;
break;
case 'e' : gameover(); smenu();
case 'i' : inventory(); break;
default :
cout<<"\nProvide a valid choice. Hurry up, the acid zombie is attacking you."<<endl<<endl;
health-=((Zombie[2].zattack)/armourobj.armour);
cout<<"Your Health: ";
((health>0)?numbar(health, 80):numbar(0,80));
cout<<endl<<endl;
cout<<"Zombie's health: ";
(((Zombie[2].zhealth)>0)?numbar(Zombie[2].zhealth,100):numbar(0,100));
cout<<endl<<endl;
break;
}
}
if (health<=0) { cout<<"Game over! You struggled, but died.\n\n\n<PRESS ENTER>"<<endl; gamelostACue(); getch(); gameover(); smenu(); }
cout<<"You killed the zombie."<<endl; zkillACue();
cout<<"Consider checking your health and weapon status. <PRESS ENTER>"<<endl;
getch();
kills++;
points += 50;
replenish(1);
}
}
void gameover()
{
system("CLS");
titlebox();
setbkcolor(1);
cout<<"Thank you for playing.\n\n";
cout<<"SCORE: "<<points<<endl;
cout<<"ZOMBIES KILLED: "<<kills<<endl;
player.zcount += kills;
if(points>player.hghscr) player.hghscr = points;
player.lstscr = points;
cout<<endl<<"Current Statistics: "<<endl;
player.restorepswrd(gpassword);
player.incmcount();
player.putdata();
getch();
file.write((char*)&player,sizeof(player));
player.ini();
smenu();
}
void replenish(int param_)
{
if(param_ == 1) { Zombie[0].zhealth = 15; Zombie[1].zhealth = 20; }
else {
Zombie[0].zhealth = 15;
Zombie[1].zhealth = 20;
Zombie[2].zhealth = 100;
health = 10;
alertflag = 0;
strcpy(slotobj[0].objname, "hand is free");
strcpy(slotobj[0].title, "empty");
strcpy(slotobj[0].descript, "empty");
strcpy(slotobj[0].bravo, "empty");
slotobj[0].dref = 0;