-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinalProjectWindows.c
More file actions
1336 lines (1253 loc) · 35.1 KB
/
Copy pathfinalProjectWindows.c
File metadata and controls
1336 lines (1253 loc) · 35.1 KB
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 <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
int main()
{
int hp = 100, maxHP = 100, encounter = 1, enemyType, enemyHP, enemyMaxHP, choice = 0, attackStrength = 5, damage, critChance = 10, defense = 0, maxDefense = 10, clearBuffer, fishingChance = 50, enemyMove = 0, denarii = 0, denariiFound = 0, damagePrior = 0, enemyFlight = 0, enemyDamageBuff = 0, enemyLazy = 0, levels = 0, heal = 0, bearBuff = 0, enemyBaseDamageBuff = 0, enemyBaseHPBuff = 0, randomCheck = 0, spicyBoost = 0, difficulty = 1, showLog = 0;
char enemy[20];
char chara;
int inventory[10] = {0}, log[10][5] = {{0}};
srand(time(0));
//Though it is not ideal, functions are added inside main() so the variables could be used.
void enemyAttack()
{
//This increases the attack by the damage buff.
damage += enemyDamageBuff;
//This is to tell how much defense to lose.
damagePrior = damage;
//Calculate how much damage gets done.
if (damage - defense < 0)
damage = 0;
else
damage -= defense;
//Calculate and modify how much defense is left
if(defense - damagePrior < 0)
defense = 0;
else
defense -= damagePrior;
//Actually modify health
if(hp - damage < 0)
hp = 0;
else
hp -= damage;
}
void printHealthLeft()
{
if(hp < 21)
printf("You now only have \033[5;31m%d health\033[0m!\n", hp);
else
printf("You now have %d health.\n", hp);
return;
}
void attackResultPrint()
{
if(damage < 1)
printf("You successfully blocked all the \033[31mdamage\033[0m!\n");
else if(damagePrior != damage)
{
printf("You blocked some of the damage, but the %s still deals \033[31m%d damage\033[0m to you.\n", enemy, damage);
printHealthLeft();
}
else
{
printf("The %s attacks you and does \033[31m%d damage\033[0m to you!\n", enemy, damage);
printHealthLeft();
}
}
void critResultPrint()
{
if(damage < 1)
printf("You successfully blocked all the \033[31mdamage\033[0m!\n");
else if(damagePrior != damage)
{
printf("The %s fells a mighty blow! You block some of it, but you still took \033[31m%d damage\033[0m.\n", enemy, damage);
printHealthLeft();
}
else
{
printf("The %s fells a mighty blow and does \033[31m%d damage\033[0m to you!\n", enemy, damage);
printHealthLeft();
}
}
void goFishing() //Used as a function due to it being used in two different encounters.
{
printf("You begin to fish, how far would you like to cast?\n1) Close\n2) Halfway\n3) Far\n");
do
{
if (scanf("%d", &choice) == 1) {}
else
while ((clearBuffer = getchar()) != '\n' && clearBuffer != EOF) { } //This checks to make sure an integer was inputed. Google was used to find out how to do this.
if(choice < 1 || choice > 3)
{
printf("\n\033[31mPlease select an option between 1-3.\033[0m\n\n");
}
} while(choice < 1 || choice > 3);
//The following line clears the input buffer. This removes the enter after a %d or %i. Google was used to find out how to do this.
while ((clearBuffer = getchar()) != '\n' && clearBuffer != EOF) { }
//Now actual fishing starts
if(rand() % 100 + 1 < fishingChance + 1)
{
randomCheck = rand() % 100 + 1;
if(choice == 1)
{
if(randomCheck < 11) //Plain Fish
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 1;
printf("You caught a Plain Fish!\n");
break;
}
}
}
else if(randomCheck < 31) //Small Fish
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 2;
printf("You caught a Small Fish!\n");
break;
}
}
}
else if(randomCheck < 51) //Substatial Fish
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 3;
printf("You caught an Enormous Fish!\n");
break;
}
}
}
else if(randomCheck< 61) //Angry Eel
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 4;
printf("You caught an Angry Eel!\n");
break;
}
}
}
else if(randomCheck < 71) //Spicy Fish
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 5;
printf("You caught a Spicy Fish!\n");
break;
}
}
}
else if(randomCheck < 91) //Clam
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 6;
printf("You caught a Clam!\n");
break;
}
}
}
else if(randomCheck < 100) //Angler
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 7;
printf("You caught an Angler Fish!\n");
break;
}
}
}
else //MEGA Fish. Always a very very low chance of getting this one.
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 8;
printf("You caught a \e[0;33mMEGA GLORIOUS FISH\033[0m!\n");
break;
}
}
}
}
else if (choice == 2)
{
if(randomCheck < 21) //Plain Fish
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 1;
printf("You caught a Plain Fish!\n");
break;
}
}
}
else if(randomCheck < 30) //Small Fish
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 2;
printf("You caught a Small Fish!\n");
break;
}
}
}
else if(randomCheck < 40) //Substatial Fish
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 3;
printf("You caught an Enormous Fish!\n");
break;
}
}
}
else if(randomCheck< 60) //Angry Eel
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 4;
printf("You caught an Angry Eel!\n");
break;
}
}
}
else if(randomCheck < 80) //Spicy Fish
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 5;
printf("You caught a Spicy Fish!\n");
break;
}
}
}
else if(randomCheck < 90) //Clam
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 6;
printf("You caught a Clam!\n");
break;
}
}
}
else if(randomCheck < 99) //Angler
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 7;
printf("You caught an Angler Fish!\n");
break;
}
}
}
else //MEGA Fish. Always a very very low chance of getting this one.
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 8;
printf("You caught a \e[0;33mMEGA GLORIOUS FISH\033[0m!\n");
break;
}
}
}
}
else
{
if(randomCheck < 21) //Plain Fish
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 1;
printf("You caught a Plain Fish!\n");
break;
}
}
}
else if(randomCheck < 31) //Small Fish
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 2;
printf("You caught a Small Fish!\n");
break;
}
}
}
else if(randomCheck < 51) //Substatial Fish
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 3;
printf("You caught an Enormous Fish!\n");
break;
}
}
}
else if(randomCheck< 61) //Angry Eel
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 4;
printf("You caught an Angry Eel!\n");
break;
}
}
}
else if(randomCheck < 71) //Spicy Fish
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 5;
printf("You caught a Spicy Fish!\n");
break;
}
}
}
else if(randomCheck < 81) //Clam
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 6;
printf("You caught a Clam!\n");
break;
}
}
}
else if(randomCheck < 100) //Angler
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 7;
printf("You caught an Angler Fish!\n");
break;
}
}
}
else //MEGA Fish. Always a very very low chance of getting this one.
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 8;
printf("You caught a \e[0;33mMEGA GLORIOUS FISH\033[0m!\n");
break;
}
}
}
}
}
else
printf("You were unable to catching anything.\n");
return;
}
int isInventoryFull()
{
int fullness = 0;
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] != 0)
{
fullness ++;
}
}
if (fullness >= 10)
return 0;
else
return 1;
}
int addToLog(int level, int encounter, int object, int maxhp, int hp)
{
for(int loop = 0; loop < 10; loop ++)
{
if (log[loop][1] == 0)
{
log[loop][1] = level;
log[loop][2] = encounter;
log[loop][3] = object;
log[loop][4] = maxhp;
log[loop][5]= hp;
break;
}
}
for(int loop = 0; loop < 9; loop ++)
{
log[loop][1] = log[loop+1][1];
log[loop][2] = log[loop+1][2];
log[loop][3] = log[loop+1][3];
log[loop][4] = log[loop+1][4];
log[loop][5] = log[loop+1][5];
}
log[9][1] = level;
log[9][2] = encounter;
log[9][3] = object;
log[9][4] = maxhp;
log[9][5]= hp;
}
printf("Welcome to Otter Adventure. You are an otter recently escaped from an otter sactuary and are trying to get through as much of the forest as you can. Good luck!\n");
printf("Press [enter] to advance dialogue.\n");
scanf("%c", &chara);
printf("What difficulty/mode do you want to play?\n1) Normal\n2) Low Health\n3) Medium Health\n4) Master\n");
do
{
if (scanf("%d", &choice) == 1) {} //This checks to make sure an integer was inputed. Google was used to find out how to do this.
else
while ((clearBuffer = getchar()) != '\n' && clearBuffer != EOF) { }
if(choice < 1 || choice > 4)
{
printf("\n\033[31mPlease select an option between 1-4.\033[0m\n\n");
}
} while(choice < 1 || choice > 4);
//The following line clears the input buffer. Google was used to find out how to do this.
while ((clearBuffer = getchar()) != '\n' && clearBuffer != EOF) { }
difficulty = choice;
if(difficulty == 1) //Normal
{
maxHP = 100;
hp = 100;
}
else if (difficulty == 2) //Low Health
{
maxHP = 50;
hp = 50;
}
else if (difficulty == 3) //Medium Health
{
maxHP = 75;
hp = 75;
}
else //Master
{
maxHP = 50;
hp = 50;
enemyBaseHPBuff = 10;
enemyBaseDamageBuff = 1;
}
//Main game loop
while(hp > 0)
{
//The very first encounter will always be an enemy.
if(encounter == 1)
{
//The Enemy Encounter. First it picks what enemy you will fight and sets the stats to correspond.
enemyType = rand() % 100 + 1;
if(enemyType < 20)
{
enemyHP = 10 + enemyBaseHPBuff;
enemyMaxHP = 10 + enemyBaseHPBuff;
strcpy(enemy, "squirrel");
enemyType = 1;
}
else if(enemyType < 50)
{
enemyHP = 20 + enemyBaseHPBuff;
enemyMaxHP = 20 + enemyBaseHPBuff;
strcpy(enemy, "eagle");
enemyType = 2;
}
else if(enemyType < 90)
{
enemyHP = 30 + enemyBaseHPBuff;
enemyMaxHP = 30 + enemyBaseHPBuff;
strcpy(enemy, "coyote");
enemyType = 3;
}
else
{
enemyHP = 35 + enemyBaseHPBuff;
enemyMaxHP = 40 + enemyBaseHPBuff;
strcpy(enemy, "bear");
enemyType = 4;
}
if(strcmp(enemy, "eagle") == 0)
printf("Oh no! You encounter an %s!\n", enemy);
else
printf("Oh no! You encounter a %s!\n", enemy);
scanf("%c", &chara);
//This the the main enemy encounter loop.
while(enemyHP > 0 && hp > 0)
{
if(strcmp(enemy, "eagle") == 0)
printf("You are in combat with an %s!\n", enemy);
else
printf("You are in combat with a %s!\n", enemy);
printf("You have %d health.\nThe %s has %d health.\n", hp, enemy, enemyHP);
do
{
printf("What would you like to do?\n1) Attack (%d - %d damage)\n2) Defend (%d defense)\n3) Food\n4) Observe\n5) Flee (%d%% chance)\n6) Pass\n", attackStrength, attackStrength + 3, maxDefense, maxHP - hp > 50 ? 50 : maxHP - hp);
if (scanf("%d", &choice) == 1) {} //This checks to make sure an integer was inputed. Google was used to find out how to do this.
else
while ((clearBuffer = getchar()) != '\n' && clearBuffer != EOF) { }
if(choice < 1 || choice > 6)
{
printf("\n\033[31mPlease select an option between 1-6.\033[0m\n\n");
}
} while(choice < 1 || choice > 6);
//The following line clears the input buffer. Google was used to find out how to do this.
while ((clearBuffer = getchar()) != '\n' && clearBuffer != EOF) { }
if(choice == 1)
{
//Does damage to the enemy
printf("\n");
if(enemyFlight > 0)
{
printf("The %s is too high in the sky to hit from here!\n", enemy);
}
else
{
if(rand() % 100 + 1 <= critChance)
{
damage = ((rand() % 4 + 1) * 2 + (attackStrength - 1)) + spicyBoost;
printf("You attack with extra vigor and deal more damage!\n");
if(spicyBoost > 0)
printf("Your attack was extra spicy!\n");
}
else
damage = rand() % 4 + attackStrength + spicyBoost;
if(enemyHP - damage < 0)
enemyHP = 0;
else
enemyHP -= damage;
printf("You attack for \033[31m%d damage!\033[0m\nThe %s now has %d health.\n", damage, enemy, enemyHP);
if(spicyBoost > 0)
printf("Your attack was extra spicy!\n");
spicyBoost = 0;
}
scanf("%c", &chara);
}
else if(choice == 2)
{
//Sets defense
defense = maxDefense;
printf("You move to defend.\n");
}
else if(choice == 3)
{
//Shows you the inventory and lets you eat something
printf("What would you like to eat?\n");
//This prints what is in your inventory.
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
printf("%2d) Nothing\n", loop + 1);
else if(inventory[loop] == 1)
printf("%2d) Plain Fish (Heals some health)\n", loop + 1);
else if(inventory[loop] == 2)
printf("%2d) Small Fish (Heals a small amount of health)\n", loop + 1);
else if(inventory[loop] == 3)
printf("%2d) Enormous Fish (Heals a large amount of health)\n", loop + 1);
else if(inventory[loop] == 4)
printf("%2d) Angry Eel (Lose some health, but deals the same damage to the enemy)\n", loop + 1);
else if(inventory[loop] == 5)
printf("%2d) Spicy Fish (Gain a little health and your next attack does more damage)\n", loop + 1);
else if(inventory[loop] == 6)
printf("%2d) Clam (Gain some health and increase your maximum health\n", loop + 1);
else if(inventory[loop] == 7)
printf("%2d) Angler (Lose some denarri but heals an equal amount)\n", loop + 1);
else if(inventory[loop] == 8)
printf("%2d) \e[0;33mMEGA GLORIOUS FISH (Completely refills your health)\033[0m\n", loop + 1);
else
printf("%2d) \e[0;33mHoney (Heals some health)\033[0m\n", loop +1);
}
printf("11) Back\n");
do
{
if (scanf("%d", &choice) == 1) {}
else
while ((clearBuffer = getchar()) != '\n' && clearBuffer != EOF) { }
if(choice < 1 || choice > 11)
printf("\n\033[31mPlease select an option between 1-11.\033[0m\n\n");
else if(choice == 11)
printf("I geuss you are not hungry...\n");
else if(inventory[choice - 1] == 0)
printf("It would be hard to eat nothingness.\n");
} while((choice < 1 || choice > 11));
while ((clearBuffer = getchar()) != '\n' && clearBuffer != EOF) { }
//This is where the food actually takes affect
if(choice == 11)
{
//This is to detect if the user just wants to go back.
}
else
{
if (inventory[choice - 1] == 1) //Plain Fish
{
heal = rand() % 5 + 10;
if (hp + heal > maxHP)
{
hp = maxHP;
heal = maxHP - hp;
}
else
hp += heal;
printf("You eat the Plain Fish and heal \033[32m%d health\033[0m! You now have \033[32m%d health\033[0m.\n", heal, hp);
}
else if(inventory[choice - 1] == 2) //Small Fish
{
heal = rand() % 5 + 8;
if (hp + heal > maxHP)
{
hp = maxHP;
heal = maxHP - hp;
}
else
hp += heal;
printf("You eat the Small Fish and heal \033[32m%d health\033[0m! You now have \033[32m%d health\033[0m.\n", heal, hp);
}
else if(inventory[choice - 1] == 3) //Substantial Fish
{
heal = rand() % 5 + 12;
if (hp + heal > maxHP)
{
hp = maxHP;
heal = maxHP - hp;
}
else
hp += heal;
printf("You eat the Enormous Fish and heal \033[32m%d health\033[0m! You now have \033[32m%d health\033[0m.\n", heal, hp);
}
else if(inventory[choice - 1] == 4) //Angry Eel
{
damage = rand() % 5 + 6;
if(enemyHP - damage < 0)
enemyHP = 0;
else
enemyHP -= damage;
if(hp - damage < 0)
hp = 0;
else
hp -= damage;
printf("You try to eat the Angry Eel and lose \033[31m%d health\033[0m! The Angry Eel also deals \033[31m%d damage\033[0m the the %s.\n You now have \033[31m%d health\033[0m. The %s now has \033[31m%d health\033[0m.\n", damage, damage, enemy, hp, enemy, enemyHP);
}
else if(inventory[choice - 1] == 5) //Spicy Fish
{
spicyBoost = rand() % 3 + 3;
heal = rand() % 5 + 8;
if (hp + heal > maxHP)
{
hp = maxHP;
heal = maxHP - hp;
}
else
hp += heal;
printf("You eat the Spicy Fish and heal \033[32m%d health\033[0m! You now have \033[32m%d health\033[0m. Your next attack will deal %d more damage!\n", heal, hp, spicyBoost);
}
else if(inventory[choice - 1] == 6) //Clam
{
heal = rand() % 5 + 4;
maxHP += heal;
if (hp + heal > maxHP)
{
hp = maxHP;
heal = maxHP - hp;
}
else
hp += heal;
printf("You eat the Clam! You maximum health has increased to \033[32m%d\033[0m! You heal \033[32m%d health\033[0m and now have \033[32m%d health\033[0m.\n", maxHP, heal, hp);
}
else if(inventory[choice - 1] == 7) //Angler
{
heal = rand() % 7 + 12;
if (denarii - heal < 0)
{
heal = denarii;
denarii = 0;
}
else
{
denarii -= heal;
}
if (hp + heal > maxHP)
{
hp = maxHP;
heal = maxHP - hp;
}
else
hp += heal;
printf("You eat the Angler and heal \033[32m%d health\033[0m! You now have \033[32m%d health\033[0m, but you lost \e[0;33m%d denarii\033[0m...\n", heal, hp,denarii);
}
else if(inventory[choice - 1] == 8) //MEGA
{
heal = rand() % 5 + 12;
if (hp + heal > maxHP)
{
hp = maxHP;
heal = maxHP - hp;
}
else
hp += heal;
printf("You ate the \e[0;33mMEGA GLORIOUS FISH\033[0m! Your health has been restored to the \033[32maximum\033[0m!\n");
}
else if(inventory[choice - 1] == 9) //Honey
{
heal = rand() % 5 + 10;
if (hp + heal > maxHP)
{
hp = maxHP;
heal = maxHP - hp;
}
else
hp += heal;
printf("You eat the \e[0;33mHoney\033[0m and heal \033[32m%d health\033[0m! You now have \033[32m%d health\033[0m.\n", heal, hp);
}
inventory[choice - 1] = 0;
}
choice = 3;
scanf("%c", &chara);
}
else if(choice == 4)
{
//Prints stats
if (hp < 21)
printf("\nYou currently have \033[5;31m%d health\033[0m. ", hp);
else
printf("\nYou currently have \033[32m%d health\033[0m. ", hp);
printf("Your max health is \033[32m%d\033[0m.\nThe %s has \033[31m%d health\033[0m and its max health is \033[31m%d\033[0m.\nYou have %d defense currently.\nYou have a %d%% chance of catching fish.\nYou have a \033[31m%d%%\033[0m chance to land a \033[31mvigorous attack\033[0m.\nYou have \e[0;33m%d denarii\033[0m.\n", maxHP, enemy, enemyHP, enemyMaxHP, defense, fishingChance, critChance, denarii);
scanf("%c", &chara);
}
else if (choice == 5)
{
//Possibly lets you flee the battle
printf("\n");
if(rand() % 100 + 1 <= (maxHP - hp > 50 ? 50 : maxHP - hp))
{
printf("You successfully flee from the battle!\n");
choice = 6;
}
else
{
printf("\033[31mOh no! You were not able to escape the fight!\033[0m\n");
}
scanf("%c", &chara);
}
else
{
choice = 5; //Because choice 6 was already taken as a successful flee, this changes the value of choice to 5 which will do "nothing" or act as a failed flee.
}
//Enemy Turn:
if(enemyHP > 0 && choice != 4 && choice != 3 && choice != 6)
{
if(enemyType == 1)
{
enemyMove = rand() % 2 + 1;
if(enemyMove == 1)
{
damage = rand() % 4 + 4;
enemyAttack();
attackResultPrint();
}
else
{
damage = rand() % 20+1;
enemyAttack();
if(damage < 1)
printf("You successfully blocked all the \033[31mdamage\033[0m!\n");
else if(damagePrior != damage)
printf("The %s thows a bunch of nuts at you! You blocked some of the damage, but the nuts still deal \033[31m%d damage\033[0m to you.\n", enemy, damage);
else
printf("The %s throws a bunch of nuts and does \033[31m%d damage\033[0m to you!\n", enemy, damage);
printHealthLeft();
}
}
else if(enemyType == 2)
{
enemyMove = rand() % 3 + 1;
if(enemyMove == 1)
{
damage = rand() % 4 + 5;
enemyAttack();
attackResultPrint();
}
else if(enemyMove == 2)
{
damage = rand() % 6 + 6;
enemyAttack();
critResultPrint();
}
else
{
if(enemyFlight == 0)
{
enemyFlight = 3;
printf("The %s flys high into the sky! Your melee attack can't hit it from here.\n", enemy);
}
else if (enemyFlight > 0)
{
enemyFlight = 3;
printf("The %s flys into an updraft! It will be in the sky longer. Your melee attack can't hit it from here.\n", enemy);
}
}
}
else if(enemyType == 3)
{
enemyMove = rand() % 3 + 1;
if(enemyMove == 1)
{
damage = rand() % 4 + 6;
enemyAttack();
attackResultPrint();
}
else if(enemyMove == 2)
{
damage = rand() % 6 + 7;
enemyAttack();
critResultPrint();
}
else
{
enemyDamageBuff += 1;
printf("The %s howls loudly and gets stronger.\n", enemy);
}
}
else if(enemyType == 4)
{
if(enemyLazy > 2)
{
enemyLazy = 0;
printf("The %s is resting.\n", enemy);
}
else
{
enemyMove = rand() % 4 + 1;
if(enemyMove == 1)
{
damage = rand() % 4 + 6;
enemyAttack();
attackResultPrint();
enemyDamageBuff -= bearBuff;
bearBuff = 0;
}
else if(enemyMove == 2)
{
damage = rand() % 6 + 7;
enemyAttack();
critResultPrint();
enemyDamageBuff -= bearBuff;
bearBuff = 0;
}
else if(enemyMove == 3)
{
bearBuff = rand() % 4 + 3;
enemyDamageBuff += bearBuff;
printf("The %s is gearing up for a more powerful attack!\n", enemy);
}
else
{
heal = rand() % 6 + 5;
if(heal + enemyHP > enemyMaxHP)
enemyHP = enemyMaxHP;
else
enemyHP += heal;
printf("The %s eats some \033[33mhoney\033[0m and regains \033[32m%d health\033[0m. The %s now has %d health.\n", enemy, heal, enemy, enemyHP);
}
enemyLazy ++;
}
}
scanf("%c", &chara);
//This lowers the enemy's flight.
if(enemyFlight > 0)
{
enemyFlight --;
if(enemyFlight == 0)
{
printf("The %s has landed.\n", enemy);
scanf("%c", &chara);
}
}
}
else
{
if(choice == 6)
{
enemyHP = 0;
}
else if(enemyHP <= 0)
{
printf("You defeated the %s!\n", enemy);
denariiFound = rand() % 10 + 1;
if(enemyType == 4) //If you defeat the bear you either get more denarii or you get honey.
{
if (rand() % 2 + 1 == 1 && isInventoryFull() == 1)
{
for(int loop = 0; loop < 10; loop ++)
{
if(inventory[loop] == 0)
{
inventory[loop] = 9;
break;
}
}
printf("The %s left behind some of its \e[0;33mhoney\033[0m!\n",enemy);
}
else
{
denariiFound += 5;
denarii += denariiFound;
printf("You collected \e[0;33m%d denarii\033[0m! You now have \e[0;33m%d denarii\033[0m.\n", denariiFound, denarii);
}
}
else
{