-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.cpp
1652 lines (1486 loc) · 41.4 KB
/
functions.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"functions.h"
#include"rlutil.h"
#include"unistd.h"
#include"termios.h"
#include<string>
#include<ctime>
#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<fstream>
#include<cstring>
#include<cmath>
//MENU FUNCTIONS
//Border functions
void border(void)
{
rlutil::setColor(2);
std::cout << "|| ||\n";
}
void border2(void)
{
rlutil::setColor(11);
std::cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
}
void border3(void)
{
rlutil::setColor(10);
std::cout << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n";
}
void border4(void)
{
rlutil::setColor(3);
std::cout << "___________________________________________\n";
}
void versus(void)
{
rlutil::setColor(5);
std::cout << "< V V SSS >\n";
std::cout << "< V V S >\n";
std::cout << "< V V SSS >\n";
std::cout << "< VV .. S >\n";
std::cout << "< V .. SSS >\n";
}
void clear_screen(void)
{
std::cout << "\033[2J\033[1;1H";
}
void standby(void)
{
struct termios old_tio, new_tio;
unsigned char input;
tcgetattr(STDIN_FILENO, &old_tio);
new_tio = old_tio;
new_tio.c_lflag &= (~ICANON & ~ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &new_tio);
std::cout << "\nPress any key to continue...\n";
std::getchar();
std::cin.ignore();
std::cin.clear();
//OLD SETTINGS: buffered
tcsetattr(STDIN_FILENO, TCSANOW, &old_tio);
}
//Main Menu
void main_menu(void)
{
clear_screen();
border2();
border();
std::cout << "|| MAIN MENU ||\n";
border();
border2();
rlutil::setColor(7);
std::cout << "\n(1): Create a new character\n";
std::cout << "(2): Login to an existing character\n\n";
std::cout << "(Q): Quit\n\n";
border2();
}
void character_menu(void)
{
clear_screen();
border3();
border();
std::cout << "|| CHARACTER MENU ||\n";
border();
border3();
rlutil::setColor(7);
std::cout << "\n(1): View character statistics\n";
std::cout << "(2): Spend skill points\n\n";
// std::cout << "(3): View inventory\n";
std::cout << "(4): Return to map\n\n";
std::cout << "(S): Shop\n";
std::cout << "(Q): Logout\n\n";
border3();
}
void shop_menu(Character c)
{
//FULL RESTORE COST
long int cost1;
cost1 = ((c.get_max_mana() - c.get_mana())*2) + ((c.get_max_hp() - c.get_hp())*2);
//RICHNESS LEVEL COST
long int cost2;
if(c.get_rich_num() == 0)
{
cost2 = 200;
}
else if(c.get_rich_num() == 1)
{
cost2 = 400;
}
else if(c.get_rich_num() == 2)
{
cost2 = 1200;
}
else if(c.get_rich_num() == 3)
{
cost2 = 20000;
}
//GOLD MULTIPLIER COST
long int cost3;
cost3 = 25 * ((c.get_gold_mult()/0.25)-3);
clear_screen();
border3();
border();
std::cout << "|| SHOP MENU ||\n";
border();
std::cout << "|| ";
rlutil::setColor(14);
std::cout << "Current Gold: ";
rlutil::setColor(2);
std::cout << std::setw(15) << std::left << c.get_gold() << "||\n";
border();
border3();
rlutil::setColor(10);
std::cout << "\n (1): FULL RESTORE\n";
rlutil::setColor(7);
std::cout << "\t -> COST: " << cost1 << "\n";
rlutil::setColor(13);
std::cout << "\n (2): QUICK RESTORE\n";
rlutil::setColor(7);
std::cout << "\t -> COST: " << 25 << "\n";
rlutil::setColor(11);
std::cout << "\n (3): INCREASE GOLD MULTIPLIER\n";
rlutil::setColor(7);
std::cout << "\t -> COST: " << cost3 << "\n";
if(c.get_rich_num() < 4)
{
rlutil::setColor(14);
std::cout << "\n (4): INCREASE RICHNESS LEVEL\n";
rlutil::setColor(7);
std::cout << "\t -> COST: " << cost2 << "\n\n";
}
std::cout << "\n (Q): Return to CHARACTER MENU\n\n";
border3();
}
void magic_menu(Character c)
{
clear_screen();
border3();
border2();
rlutil::setColor(7);
std::cout << "\nCurrent Magic Stat: ";
rlutil::setColor(11);
std::cout << c.get_magic();
rlutil::setColor(7);
std::cout << "\n\nMana: (" << c.get_mana() << " / " << c.get_max_mana() << ")\n";
c.get_mana_bar();
rlutil::setColor(7);
if(c.get_magic() < 3)
{
std::cout << "\n You have no spells unlocked yet!\n\n";
}
if(c.get_magic() >= 3)
{
rlutil::setColor(10);
std::cout << "\n (1): HEAL";
rlutil::setColor(7);
std::cout << "\n\t -> COST: 5 Mana";
std::cout << "\n\t -> Heals between " << c.get_magic() - 2 << " - " << c.get_magic() + 2 << "\n\n";
}
if(c.get_magic() >= 5)
{
rlutil::setColor(9);
std::cout << " (2): RESEARCH MONSTER";
rlutil::setColor(7);
std::cout << "\n\t -> COST: 2 Mana";
std::cout << "\n\t -> Reveals monster information\n\n";
}
if(c.get_magic() >= 10)
{
rlutil::setColor(12);
std::cout << " (3): TARGETED COMBUSTION";
rlutil::setColor(7);
std::cout << "\n\t -> COST: 10 Mana";
std::cout << "\n\t -> Successfully deals " << 15 + c.get_magic() << " damage\n\n";
}
if(c.get_magic() >= 12)
{
rlutil::setColor(11);
std::cout << " (4): EMPOWERED LIFESTEAL";
rlutil::setColor(7);
std::cout << "\n\t -> COST: 7 Mana";
std::cout << "\n\t -> Empowers next attack with\n\t\t 100% Lifesteal\n\n";
}
if(c.get_magic() >= 20)
{
rlutil::setColor(14);
std::cout << " (5): JACKPOT HIT";
rlutil::setColor(7);
std::cout << "\n\t -> COST: 12 Mana";
std::cout << "\n\t -> Empowers next attack with\n\t\t" << 100 + (25 * ((c.get_gold_mult()/0.25)-4)) << "% Gold-gain\n\n";
}
std::cout << " (Q): Return to Battle\n\n";
border2();
border3();
}
//CHARACTER FUNCTIONS
bool isCharacter(std::string name, std::fstream& chars)
{
chars.close();
chars.open("Characters.txt");
Character temp;
bool exist = false;
while(chars >> temp)
{
if(temp.get_char_name() == name)
{
exist = true;
}
}
return exist;
}
//save character to file
void save_char(Character c, std::fstream& chars)
{
chars.close();
chars.open("Characters.txt", std::ios::app);
chars << c;
}
void remove_char(std::string cnm, std::fstream& chars, std::fstream& temp)
{
chars.close();
chars.open("Characters.txt");
temp.open("temp.txt", std::ios::app);
Character del;
while(chars >> del)
{
if(del.get_char_name() == cnm)
{
}
else
{
temp << del;
}
}
temp.close();
chars.close();
std::remove("Characters.txt");
std::rename("temp.txt", "Characters.txt");
}
void create_char(std::fstream& chars)
{
clear_screen();
chars.close();
chars.open("Characters.txt", std::ios::app);
std::string cname;
int pn;
char ans;
//Name of the new character
name:
std::cout << "Enter the name of your character ('Q' for Main Menu):\n\t";
if(!(std::cin >> cname))
{
std::cout << "Input Error: Unnacceptable name, please retry.\n";
std::cin.clear();
std::cin.ignore(10000, '\n');
goto name;
}
if(cname == "Q" || cname == "q")
{
return;
}
if(isCharacter(cname, chars))
{
std::cout << "That name is already in use, please choose another!\n";
goto name;
}
//Users pin (unencrypted LOL)
pin:
std::cout << "Enter your new PIN for your character:\n";
std::cout << "(This will be what you use to login, REMEMBER IT)\n";
if(!(std::cin >> pn))
{
std::cout << "Input Error: Pin must be number (0-9) combination, please retry.\n";
std::cin.clear();
std::cin.ignore(10000, '\n');
goto pin;
}
sure:
std::cout << "Continue (Y/N)?\n\n";
std::cout << "Character Name:\t" << cname << std::endl;
std::cout << "Character Pin:\t" << pn << std::endl;
if(!(std::cin >> ans))
{
std::cout << "Input Error: Enter Y or N, please retry.\n";
std::cin.clear();
std::cin.ignore(10000, '\n');
goto sure;
}
if(ans == 'Y' || ans == 'y')
{
Character new_char(cname, pn);
new_char.validate_char();
save_char(new_char, chars);
return;
}
else if(ans == 'n' || ans == 'N')
{
return;
}
else
{
goto sure;
}
}
//fetch character from file
Character fetch_char(std::string name, std::fstream& chars)
{
chars.close();
chars.open("Characters.txt");
Character fetch;
while(chars >> fetch)
{
if(fetch.get_char_name() == name)
{
return fetch;
}
}
// std::cout << "Could not find any character named '" << name <<"'\n";
Character NULLc("NULL_CHAR_NAME", 0001);
return NULLc;
}
//login to character
Character login(std::fstream& chars)
{
clear_screen();
Character chr;
std::string cname;
int pn;
bool flag = true;
login:
std::cout << "Character Name:\n\t";
if(!(std::cin >> cname))
{
std::cout << "Input Error: Invalid input, please retry.\n";
std::cin.clear();
std::cin.ignore(10000, '\n');
goto login;
}
chr = fetch_char(cname, chars);
if(chr.get_char_name() == "NULL_CHAR_NAME")
{
flag = false;
}
std::cout << "Character PIN:\n\t";
if(!(std::cin >> pn))
{
std::cout << "Input Error: Invalid input, please retry.\n";
std::cin.clear();
std::cin.ignore(10000, '\n');
goto login;
}
if(pn == chr.get_pin() && flag == true)
{
std::cout << "LOGIN SUCCESSFUL\n";
standby();
return chr;
}
else
{
std::cout << "INCORRECT CHARACTER NAME OR PIN\n";
Character NULLc("NULL_CHAR_NAME", 0001);
standby();
return NULLc;
}
}
//print character stats
void print_char(Character c)
{
clear_screen();
border3();
border2();
border4();
std::cout << std::endl;
rlutil::setColor(7);
std::cout << "Character Name:\n\t" << c.get_char_name();
std::cout << "\n\nLEVEL " << c.get_level();
std::cout << "\n\nExperience:\t" << c.get_exp() << " / " << c.get_etn() << "\n";
c.get_exp_bar();
std::cout << "\nTotal Experience:\t";
rlutil::setColor(7);
std::cout << c.get_total_exp() << "\n";
border4();
std::cout << std::endl;
border2();
border4();
rlutil::setColor(7);
std::cout << std::endl;
std::cout << "Hit Points:\t" << c.get_hp() << " / " << c.get_max_hp() << std::endl;
c.get_hp_bar();
rlutil::setColor(7);
std::cout << "\nMana:\t\t" << c.get_mana() << " / " << c.get_max_mana() << std::endl;
c.get_mana_bar();
rlutil::setColor(10);
std::cout << "\nAttack Range:\t";
rlutil::setColor(7);
std::cout << c.get_att_range(0) << " - " << c.get_att_range(1);
rlutil::setColor(9);
std::cout << "\n\nStrength:\t";
rlutil::setColor(7);
std::cout << c.get_str();
rlutil::setColor(9);
std::cout << "\nMagic:\t\t";
rlutil::setColor(7);
std::cout << c.get_magic();
rlutil::setColor(9);
std::cout << "\nDexterity:\t";
rlutil::setColor(7);
std::cout << c.get_dex();
rlutil::setColor(11);
std::cout << "\n\nAccuracy:\t";
rlutil::setColor(7);
std::cout << c.get_acc()*100 << "%";
//std::cout << "\nAvoidability:\t" << c.get_avoid()*100 << "%";
rlutil::setColor(13);
std::cout << "\n\nSkill Points:\t";
rlutil::setColor(7);
std::cout << c.get_s_points() << "\n\n";
rlutil::setColor(14);
std::cout << "Gold:\t\t\t";
rlutil::setColor(7);
std::cout << c.get_gold() << "\n";
rlutil::setColor(14);
std::cout << "Gold Multiplier:\tx ";
rlutil::setColor(7);
std::cout << c.get_gold_mult() << "\n";
rlutil::setColor(14);
std::cout << "Richness Rating:\t";
rlutil::setColor(7);
std::cout << c.get_rich() << "\n";
border4();
border2();
border3();
standby();
}
//used to spend skill points
void spend_s_points(Character c)
{
clear_screen();
border2();
border3();
rlutil::setColor(7);
std::cout << "\nSKILL POINTS AVAILABLE: " << c.get_s_points() << " SP";
std::cout << "\n\n(1): Raise STRENGTH\n";
std::cout << "\t(Current: " << c.get_str() << ")\n\n";
std::cout << "(2): Raise MAGIC\n";
std::cout << "\t(Current: " << c.get_magic() << ")\n\n";
std::cout << "(3): Raise DEXTERITY\n";
std::cout << "\t(Current: " << c.get_dex() << ")\n\n";
std::cout << "(4): Raise ACCURACY\n";
std::cout << "\t(Current: " << c.get_acc()*100 << "%)\n\n\n";
// std::cout << "(3): Raise avoidability\n";
// std::cout << "\t(Current: " << c.get_avoid()*100 << "%)\n\n\n";
std::cout << "(Q): Return to CHARACTER MENU\n\n";
border3();
border2();
}
//MONSTER FUNCTIONS
Monster create_mon_name(void)
{
//BUG INC
Monster new_monf("", 0);
int rt, ri;
int num_mon_types = 16; //this must always match the number of types
std::string mon_types[num_mon_types] = {"Stickbug", "Nugget", "Goop",
"Sqworp", "Dragon", "Kitten",
"Glib-Glob III", "Snake", "Dog",
"Skeleton", "Wormy", "Snailo",
"Rockmon", "Zombo", "Dude", "LeCroy Johnson"};
rt = rand() % (num_mon_types - 0) - 0;
int num_mon_ident = 16; //this must always match the number of identifiers
std::string mon_ident[num_mon_ident] = {"Blue", "Bumpy", "Squirmy",
"Giant-Ass", "Fiery", "Teeny-Tiny",
"Chocolate", "Spooky", "Unfriendly",
"Questionable", "Ugly", "Screaming",
"Mildly-Upset", "Passive-Aggressive", "Mortifying", "Legendary"};
ri = rand() % (num_mon_ident - 0) - 0;
new_monf.set_mon_ident(mon_ident[ri]);
new_monf.set_mon_type(mon_types[rt]);
new_monf.set_char_name(mon_ident[ri] + " " + mon_types[rt]);
return new_monf;
}
//BATTLE SCENE VERSION 2
//return type int:
//returns: 0 if quit
// 1 if hero wins
// 2 if hero dies
//
//return type Character:
//return hero
Character battle_scene_v2(Battle* btl)
{
srand(time(NULL));
struct termios old_tio, new_tio;
unsigned char input;
tcgetattr(STDIN_FILENO, &old_tio);
new_tio = old_tio;
new_tio.c_lflag &=(~ICANON & ~ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &new_tio);
Character hero;
hero = btl->get_hero();
Monster enemy;
enemy = btl->get_enemy();
double att_dmg; //dmg dealt by successful attack
double heal; //amount healed
int att_hit; //does attack hit?
int turn = -1; //-1 = battle start
//0 = hero turn
//1 = monster turn
//2 = end battle
int gold_earned; //gold earned
int exp_gained; //base exp
int exp_gained_m; //monster exo bonus
int total_exp; //exp_gained + exp_gained_m
int prior_exp;
char ans;
bool defended_this_turn; //true = has
//false = has not
bool isMonsterResearched = false; //true = yes
//false = no
bool isLifesteal = false; //true = lifesteal next hit
//false = no lifesteal
bool isGoldgain = false; //true = gold-gain next hit
//false = no gold-gain
/*****************************************************************
* ITEM DROPS. Continues into the hero's turn in battle. *
*****************************************************************/
// Chance to get an item (currently 1 in 3 (33%)) at end of combat
int item_chance = 1;
int item_category = rand() % 3; // for determining whether to drop a weapon, armor, or boots. 0 = weapon, 1 = armor, 2 = boots
int weapon_drop = rand() % 10; // decide which weapon to give
int armor_drop = rand() % 4; // decide which armor to give
int boots_drop = rand() % 4; // decide which boots to give
int special_choice = rand() % 4; // decide which special modifier to give
int special_item = rand() % 8; // 1 in 8 chance for a special item
int describer_choice; // determines which tier to give based on p level
double dmg; // different weapon types deal more damage (greatswords obviously hurt more than a dagger)
double def; // different armor and boots will grant difference levels of defense
// How many of each item exist in our game
int num_modifiers = 4;
int num_describers = 5;
int num_weapons = 10;
int num_armor = 4;
int num_boots = 4;
int num_misc = 4;
int num_stats = 4;
// Adjectives used to describe weapons, armor, boots, etc.
string modifiers[num_modifiers] = {"Fiery ", "Freezing ", "Shocking ", "Lucky "};
string armor_modifiers[num_modifiers] = {"Protective ", "Aggressive ", "Quick ", "Intelligent "};
string describers[num_describers] = {"Bronze ", "Steel ", "Mithril ", "Adamantite ", "Rune "};
// All possible item drops from monsters
string weapons[num_weapons] = {"sword", "dagger", "spear", "katana",
"staff", "mace", "greatsword", "greataxe",
"wand", "whip"};
string armor[num_armor] = {"vest", "chestplate", "tunic", "robe" };
string boots[num_boots] = {"sandals", "plateboots", "leather boots", "sock"};
string misc[num_misc] = {"Health potion I", "Health potion II", "Gold", "Rock"};
// Base damage values of all weapons
double sword = 1.10;
double dagger = 0.60;
double spear = 0.95;
double katana = 0.90;
double staff = 0.40;
double mace = 1.20;
double greatsword = 1.60;
double greataxe = 1.80;
double battleaxe = 1.30;
double whip = 0.50;
// Base damage def of all armor
double vest = 0.90;
double chestplate = 1.25;
double tunic = 0.60;
double robe = 0.35;
// Base damage def of all boots
double sandals = 0.10;
double plateboots = 0.40;
double leather_boots = 0.25;
double sock = 0.05;
// Scaling values for all weapons. Str/dex/int/resistance
double weapon_scaling[num_weapons][num_stats] = {
{0.40, 0.40, 0.00, 0.00}, // Sword
{0.10, 0.80, 0.00, 0.00}, // Dagger
{0.25, 0.50, 0.00, 0.00}, // Spear
{0.30, 0.50, 0.00, 0.00}, // Katana
{0.15, 0.10, 0.70, 0.00}, // Staff
{0.50, 0.15, 0.00, 0.00}, // Mace
{0.80, 0.15, 0.00, 0.00}, // Greatsword
{0.90, 0.05, 0.00, 0.00}, // Greataxe
{0.05, 0.15, 0.40, 0.00}, // Wand
{0.10, 0.45, 0.00, 0.00} // Whip
};
// Scaling def values for all armor. Scales off of a resistance stat.
double armor_scaling[num_armor][num_stats] = {
{0.00, 0.00, 0.00, 1.10}, // Vest
{0.00, 0.00, 0.00, 1.90}, // Chestplate
{0.00, 0.00, 0.00, 1.30}, // Tunic
{0.00, 0.00, 0.00, 0.65} // Robe
};
// Scaling def values for all boots. Scales off a resistance stat.
double boots_scaling[num_boots][num_stats] = {
{0.00, 0.00, 0.00, 0.35}, // Sandals
{0.00, 0.00, 0.00, 0.75}, // Plateboots
{0.00, 0.00, 0.00, 0.55}, // Leather boots
{0.00, 0.00, 0.00, 1.20} // Sock (op as fuck? lmao)
};
// Which scaling values to use, depending on which equipment was generated
double str_scaling;
double dex_scaling;
double int_scaling;
double res_scaling;
// Weapon
if(item_category == 0) {
str_scaling = weapon_scaling[weapon_drop][0];
dex_scaling = weapon_scaling[weapon_drop][1];
int_scaling = weapon_scaling[weapon_drop][2];
res_scaling = weapon_scaling[weapon_drop][3];
}
// Which item we're on
int weapon_item_num = hero.get_weapons_length() + 1;
int armor_item_num = hero.get_armor_length() + 1;
int boots_item_num = hero.get_boots_length() + 1;
int misc_item_num = hero.get_misc_length() + 1;
// Armor
if(item_category == 1) {
str_scaling = armor_scaling[armor_drop][0];
dex_scaling = armor_scaling[armor_drop][1];
int_scaling = armor_scaling[armor_drop][2];
res_scaling = armor_scaling[armor_drop][3];
}
// Boots
if(item_category == 2) {
str_scaling = boots_scaling[boots_drop][0];
dex_scaling = boots_scaling[boots_drop][1];
int_scaling = boots_scaling[boots_drop][2];
res_scaling = boots_scaling[boots_drop][3];
}
// What tier of items to give
// Copper
if(hero.get_level() >= 1 && hero.get_level() <= 4)
describer_choice = 0;
// Steel
else if(hero.get_level() >= 5 && hero.get_level() <= 11)
describer_choice = 1;
// Mithril
else if(hero.get_level() >= 12 && hero.get_level() <= 17)
describer_choice = 2;
// Adamantite
else if(hero.get_level() >= 18 && hero.get_level() <= 24)
describer_choice = 3;
// Rune
else if(hero.get_level() >= 25)
describer_choice = 4;
// What modifier to apply to a weapon drop
string modifier = modifiers[special_choice];
// What modifier to apply to an armor drop
string a_modifier = armor_modifiers[special_choice];
// what modifier to apply to boots drop
string b_modifier = armor_modifiers[special_choice];
// What tier we will apply to the item drop
string describer = describers[describer_choice];
// Combine all of those strings into one for weapons
char weapon_result[50] = "";
// Combine all of those strings into one for armor
char armor_result[50] = "";
// Combine all of those strings into one for boots
char boots_result[50] = "";
/**********************************************
* WEAPON *
*********************************************/
// make weapon name
string weapon_option = weapons[weapon_drop];
// If the item will be special, give it a special modifier
if(special_item == 1) {
strcat(weapon_result, modifier.c_str());
strcat(weapon_result, describer.c_str());
}
else // Otherwise, don't
strcat(weapon_result, describer.c_str());
strcat(weapon_result, weapon_option.c_str());
/*********************************************
* ARMOR *
*********************************************/
// make armor name
string armor_option = armor[armor_drop];
// If armor will be special, give it a special modifier
if(special_item == 1) {
strcat(armor_result, a_modifier.c_str());
strcat(armor_result, describer.c_str());
}
else
strcat(armor_result, describer.c_str());
strcat(armor_result, armor_option.c_str());
/*********************************************
* BOOTS *
*********************************************/
// make boots name
string boots_option = boots[boots_drop];
// If boots will be special, give them a special modifier
if(special_item == 1) {
strcat(boots_result, b_modifier.c_str());
strcat(boots_result, describer.c_str());
}
else
strcat(boots_result, describer.c_str());
strcat(boots_result, boots_option.c_str());
/*********************************************
* MISC *
*********************************************/
//record exp before battle
prior_exp = hero.get_exp();
while(turn != 2)
{
//isLifesteal = false;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// INTRO TURN(WIP) //
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if(turn == -1)
{
clear_screen();
border2();
border();
rlutil::setColor(14);
std::cout << "\n\t" << hero.get_char_name();
std::cout << "\n\tLevel " << hero.get_level();
rlutil::setColor(7);
std::cout << "\n\nHP ( " << hero.get_hp() << " / " << hero.get_max_hp() << " ):\n";
hero.get_hp_bar();
rlutil::setColor(7);
std::cout << "\n\nEXP ( " << hero.get_exp() << " / " << hero.get_etn() << " ):\n";
hero.get_exp_bar();
std::cout << "\n";
border();
border2();
versus();
border2();
border();
rlutil::setColor(14);
std::cout << "\t" << enemy.get_char_name();
std::cout << "\n\tLevel " << enemy.get_level();
rlutil::setColor(7);
std::cout << "\n";
border();
border2();
standby();
turn = 0;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// HERO TURN //
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
else if(turn == 0)
{
hero_turn:
clear_screen();
border2();
border();
rlutil::setColor(14);
std::cout << "\n\t" << hero.get_char_name();
std::cout << "\n\tLevel " << hero.get_level();
rlutil::setColor(7);
std::cout << "\n\nHP ( " << hero.get_hp() << " / " << hero.get_max_hp() << " ):\n";
hero.get_hp_bar();
rlutil::setColor(7);
std::cout << "\n\nEXP ( " << hero.get_exp() << " / " << hero.get_etn() << " ):\n";
hero.get_exp_bar();
std::cout << "\n";
border();
border2();
border();
rlutil::setColor(14);
std::cout << "\n\t" << enemy.get_char_name();
std::cout << "\n\tLevel " << enemy.get_level();
rlutil::setColor(7);
std::cout << "\n\nHP ";
if(isMonsterResearched == true)
{
std::cout << "( " << enemy.get_hp() << " / " << enemy.get_max_hp() << " ):";
}
std::cout << "\n";
enemy.get_hp_bar();
std::cout << "\n";
border();
border2();
border4();
border4();
rlutil::setColor(2);
std::cout << "\n (1): ATTACK\t (2): SPELLS\n\n (I): INVENTORY";
rlutil::setColor(14);
std::cout << "\n\n (R): RUN (COST: " << enemy.get_level() * 5 << " gold)\n";
border4();
border4();
input = getchar();
if(input == '1')
{
clear_screen();
border3();
rlutil::setColor(3);
std::cout << std::endl;
att_hit = btl->doesAttackHit(0);
if(att_hit == 0)
{
rlutil::setColor(7);
std::cout << "> " << hero.get_char_name() << "'s attack ";
rlutil::setColor(12);
std::cout << "MISSED";
rlutil::setColor(7);
std::cout << "!\n";
}
if(att_hit == 1 || att_hit == 2)
{
rlutil::setColor(7);
std::cout << "> " << hero.get_char_name() << "'s attack ";
rlutil::setColor(10);
std::cout << "HIT";
rlutil::setColor(7);
std::cout << "!\n";
if(att_hit == 1)
{
att_dmg = btl->generate_attack(hero.get_att_range(0), hero.get_att_range(1));
std::cout << "> Attack hit for ";
rlutil::setColor(11);
std::cout << att_dmg;
rlutil::setColor(7);
std::cout << " damage.\n";
if(isLifesteal)
{
std::cout << "> You healed ";
rlutil::setColor(10);
std::cout << att_dmg;
rlutil::setColor(7);
std::cout << "!\n";
hero.inc_hp(att_dmg);
isLifesteal = false;
}
if(isGoldgain)
{
std::cout << "> You gained ";
rlutil::setColor(14);
std::cout << (long int)(att_dmg * hero.get_gold_mult());
rlutil::setColor(7);
std::cout << " gold!\n";
hero.inc_gold((long int)(att_dmg * hero.get_gold_mult()));
isGoldgain = false;
}
}
else if(att_hit == 2)
{
att_dmg = btl->generate_attack(hero.get_att_range(0), hero.get_att_range(1)) * 2;
std::cout << "> Attack hit CRITICALLY for ";
rlutil::setColor(14);
std::cout << att_dmg;
rlutil::setColor(7);
std::cout << " damage (";
rlutil::setColor(11);
std::cout << att_dmg/2;
rlutil::setColor(7);
std::cout << " x 2).\n";
if(isLifesteal)
{
std::cout << "> You healed ";
rlutil::setColor(10);
std::cout << att_dmg;
rlutil::setColor(7);
std::cout << "!\n";
hero.inc_hp(att_dmg);
isLifesteal = false;
}
if(isGoldgain)
{
std::cout << "> You gained ";
rlutil::setColor(14);
std::cout << (long int)(att_dmg * hero.get_gold_mult());