-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
1529 lines (991 loc) · 21 KB
/
main.c
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 <string.h>
#include <conio.h>
char line[100];
int character;
int accept;
int accept2;
int character2;
int character3;
int character4;
int character5;
int character6;
int character7;
int character8;
int at1;
int at2;
int at3;
int at4;
int at5;
int at6;
int attribute;
int str;
int dex;
int con;
int int2;
int wis;
int cha;
int gaah;
int strength;
int dexterity;
int intelligence;
int charisma;
int wisdom;
int constitution;
int skill;
int skill2;
int wgp;
int sgp;
int rgp;
int wac;
int sac;
int rac;
int nstr;
int ndex;
int ncon;
int nint;
int nwis;
int ncha;
int wdmg;
int sdmg;
int rdmg;
int whp;
int shp;
int rhp;
int ok1;
int ok2;
int ok3;
int ok4;
int ok5;
int ok6;
int ok7;
int ok8;
int ok9;
int mod[16];
int roll_d4()
{
return(rand() % 4 + 1);
}
int roll_2d4()
{
return roll_d4()+roll_d4();
}
int roll_3d4()
{
return roll_d4()+roll_d4()+roll_d4();
}
int roll_4d4()
{
return roll_d4()+roll_d4()+roll_d4()+roll_d4();
}
int roll_d10()
{
return(rand() % 10 + 1);
}
int roll_dice()
{
return(rand() % 6 + 1);
}
int roll_3dice()
{
return roll_dice()+roll_dice()+roll_dice();
}
int main()
{
mod[3] = -4;
mod[4] = -3;
mod[5] = -3;
mod[6] = -2;
mod[7] = -2;
mod[8] = -1;
mod[9] = -1;
mod[10] = +0;
mod[11] = +0;
mod[12] = +1;
mod[13] = +1;
mod[14] = +2;
mod[15] = +2;
mod[16] = +3;
mod[17] = +3;
mod[18] = +4;
srand(time(NULL)); //seed
printf("Welcome to this D&D character generator.\nThis will help you to quickly get a character.\n");
do {
printf("First, you must chose your race: \nThe following races are selectable: \n1.Human\n2.Elf\n3.Dwarf\n4.Gnome\nType the number of the wanted class:\n");
fgets(line,sizeof(line),stdin);
sscanf(line,"%d",&character);
switch (character)
{
case 1:
printf("You have chosen the Human.\nHumans are a neutral race and they are average in all areas.\nNo penaltys or bonuses\n");
break;
case 2:
printf("Ah,you have chosen the elf.\nElfs are a mystical,magical race and they are very graceful. but frail.\n+2 Dexterity -2 Constitution\n");
break;
case 3:
printf("You have chosen the dwarf.\nDwarfs are strong and sturdy,but quite gruff in some situations.\n+2 Constitution -2 Charisma\n");
break;
case 4:
printf(" You have chosen the gnome.\nGnomes are famous engineers who are tough but weak.\n +2 Constitution -2 Strenght");
break;
}
printf("Press 1 To accept your race or 0 to choose a new race:\n");
fgets(line,sizeof(line),stdin);
sscanf(line,"%d",&accept);
} while (accept==0);
if (accept==1)
printf("You have now chosen your race, it is time to set your abilities.\nPress 1 to continue:\n");
fgets(line,sizeof(line),stdin);
sscanf(line,"%d",&character2);
if (character2==1) {
at1 = roll_3dice();
at2 = roll_3dice();
at3 = roll_3dice();
at4 = roll_3dice();
at5 = roll_3dice();
at6 = roll_3dice();
printf("1: %d\n2: %d\n3: %d\n4: %d\n5: %d\n6: %d\nThese are your ability scores.\nYou are going to chose which score that shall be put in which ability.\nThe abilities you can chose from are:\nStrenght(STR) \nDexterity(DEX) \nConstitution(CON) \nIntelligence(INT) \nWisdom(WIS) \nCharisma(CHA) \nPress 1 to continue:\n",at1,at2,at3,at4,at5,at6);
}
fgets(line,sizeof(line),stdin);
sscanf(line,"%d",&character3);
do{
ok1=1;
if(character3=1)
printf("It is time to place the scores in the abilities.\nWe will begin with strenght.\nStrenght is an inportant factor to your damage in close combat.\nWhat ability score do you want to be used as your strenght?\nType the number (1-6) that is behind your ability score:\n");
fgets(line,sizeof(line),stdin);
sscanf(line,"%d",&str);
switch (str) {
case 1:
if (at1 >0) {
strength = at1;
at1=-1;
} else {
printf("You can only use an attribute once\n");
ok1=0;
}
break;
case 2:
if (at2 >0) {
strength = at2;
at2=-1;
} else {
printf("You can only use an attribute once\n");
ok1=0;
}
break;
case 3:
if (at3 >0) {
strength = at3;
at3=-1;
} else {
printf("You can only use an attribute once\n");
ok1=0;
}
break;
case 4:
if (at4 >0) {
strength = at4;
at4=-1;
} else {
printf("You can only use an attribute once\n");
ok1=0;
}
break;
case 5:
if (at5 >0) {
strength = at5;
at5=-1;
} else {
printf("You can only use an attribute once\n");
ok1=0;
}
break;
case 6:
if (at6 >0) {
strength = at6;
at6=-1;
} else {
printf("You can only use an attribute once\n");
ok1=0;
}
break;
default:
printf("Eh...even if you don't 'need' this ability the mechanics of this program forces you to have it..\n");
ok1=0;
break;
}
} while (ok1==0);
do{
ok2=1;
printf("Your strenght is now %d\nLets continue with dexterity, do the same thing here.\nDexterity is what makes your agility and reflexes good:\n",strength);
fgets(line,sizeof(line),stdin);
sscanf(line,"%d",&dex);
switch (dex) {
case 1:
if (at1 >0) {
dexterity = at1;
at1=-1;
} else {
printf("You can only use an attribute once\n");
ok2=0;
}
break;
case 2:
if (at2 >0) {
dexterity = at2;
at2=-1;
} else {
printf("You can only use an attribute once\n");
ok2=0;
}
break;
case 3:
if (at3 >0) {
dexterity = at3;
at3=-1;
} else {
printf("You can only use an attribute once\n");
ok2=0;
}
break;
case 4:
if (at4 >0) {
dexterity = at4;
at4=-1;
} else {
printf("You can only use an attribute once\n");
ok2=0;
}
break;
case 5:
if (at5 >0) {
dexterity = at5;
at5=-1;
} else {
printf("You can only use an attribute once\n");
ok2=0;
}
break;
case 6:
if (at6 >0) {
dexterity = at6;
at6=-1;
} else {
printf("You can only use an attribute once\n");
ok2=0;
}
break;
default:
printf("Eh...even if you don't 'need' this ability the mechanics of this program forces you to have it..\n");
ok2=0;
break;
}
} while (ok2==0);
do{
ok3=1;
printf("Your dexterity is now %d.\nOn to constitution, do the same thing again.\nConstitution represents your health and stamina:\n",dexterity);
fgets(line,sizeof(line),stdin);
sscanf(line,"%d",&con);
switch (con) {
case 1:
if (at1 >0) {
constitution = at1;
at1=-1;
} else {
printf("You can only use an attribute once\n");
ok3=0;
}
break;
case 2:
if (at2 >0) {
constitution = at2;
at2=-1;
} else {
printf("You can only use an attribute once\n");
ok3=0;
}
break;
case 3:
if (at3 >0) {
constitution = at3;
at3=-1;
} else {
printf("You can only use an attribute once\n");
ok3=0;
}
break;
case 4:
if (at4 >0) {
constitution = at4;
at4=-1;
} else {
printf("You can only use an attribute once\n");
ok3=0;
}
break;
case 5:
if (at5 >0) {
constitution = at5;
at5=-1;
} else {
printf("You can only use an attribute once\n");
ok3=0;
}
break;
case 6:
if (at6 >0) {
constitution = at6;
at6=-1;
} else {
printf("You can only use an attribute once\n");
ok3=0;
}
break;
default:
printf("Eh...even if you don't 'need' this ability the mechanics of this program forces you to have it..\n");
ok3=0;
break;
}
} while (ok3==0);
do{
ok4=1;
printf("Your constitution just became %d.\nLets move on with your intelligence (if you have any...).\nIntelligence is the intelligence of your character (big suprise):\n",constitution);
fgets(line,sizeof(line),stdin);
sscanf(line,"%d",&int2);
switch (int2) {
case 1:
if (at1 >0) {
intelligence = at1;
at1=-1;
} else {
printf("You can only use an attribute once\n");
ok4=0;
}
break;
case 2:
if (at2 >0) {
intelligence = at2;
at2=-1;
} else {
printf("You can only use an attribute once\n");
ok4=0;
}
break;
case 3:
if (at3 >0) {
intelligence = at3;
at3=-1;
} else {
printf("You can only use an attribute once\n");
ok4=0;
}
break;
case 4:
if (at4 >0) {
intelligence = at4;
at4=-1;
} else {
printf("You can only use an attribute once\n");
ok4=0;
}
break;
case 5:
if (at5 >0) {
intelligence = at5;
at5=-1;
} else {
printf("You can only use an attribute once\n");
ok4=0;
}
break;
case 6:
if (at6 >0) {
intelligence = at6;
at6=-1;
} else {
printf("You can only use an attribute once\n");
ok4=0;
}
break;
default:
printf("Eh...even if you don't 'need' this ability the mechanics of this program forces you to have it..\n");
ok4=0;
break;
}
} while (ok4==0);
do{
ok5=1;
printf("Your IQ is now %d....or was it your intelligence...?\nAaaaaanyway, on to your wisdom.\nWisdom describes your common sense and perception:\n",intelligence);
fgets(line,sizeof(line),stdin);
sscanf(line,"%d",&wis);
switch (wis) {
case 1:
if (at1 >0) {
wisdom = at1;
at1=-1;
} else {
printf("You can only use an attribute once\n");
ok5=0;
}
break;
case 2:
if (at2 >0) {
wisdom = at2;
at1=-1;
} else {
printf("You can only use an attribute once\n");
ok5=0;
}
break;
case 3:
if (at3 >0) {
wisdom = at3;
at3=-1;
} else {
printf("You can only use an attribute once\n");
ok5=0;
}
break;
case 4:
if (at4 >0) {
wisdom = at4;
at4=-1;
} else {
printf("You can only use an attribute once\n");
ok5=0;
}
break;
case 5:
if (at5 >0) {
wisdom = at5;
at5=-1;
} else {
printf("You can only use an attribute once\n");
ok5=0;
}
break;
case 6:
if (at6 >0) {
wisdom = at6;
at6=-1;
} else {
printf("You can only use an attribute once\n");
ok5=0;
}
break;
default:
printf("Eh...even if you don't 'need' this ability the mechanics of this program forces you to have it..\n");
ok5=0;
break;
}
} while (ok5==0);
do{
ok6=1;
printf("%d is the wisdom score of your character.\nThe last atribute is charisma.\nIt is your personal magnetism, force of personality and persuasiveness:\n",wisdom);
fgets(line,sizeof(line),stdin);
sscanf(line,"%d",&cha);
switch (cha) {
case 1:
if (at1 >0) {
charisma = at1;
at1=-1;
} else {
printf("You can only use an attribute once\n");
ok6=0;
}
break;
case 2:
if (at2 >0) {
charisma = at2;
at2=-1;
} else {
printf("You can only use an attribute once\n");
ok6=0;
}
break;
case 3:
if (at3 >0) {
charisma = at3;
at3=-1;
} else {
printf("You can only use an attribute once\n");
ok6=0;
}
break;
case 4:
if (at4 >0) {
charisma = at4;
at4=-1;
} else {
printf("You can only use an attribute once\n");
ok6=0;
}
break;
case 5:
if (at5 >0) {
charisma = at5;
at5=-1;
} else {
printf("You can only use an attribute once\n");
ok6=0;
}
break;
case 6:
if (at6 >0) {
charisma = at6;
at6=-1;
} else {
printf("You can only use an attribute once\n");
ok6=0;
}
break;
default:
printf("Eh...even if you don't 'need' this ability the mechanics of this program forces you to have it..\n");
ok6=0;
break;
}
} while (ok6==0);
printf("And your final score, will say charisma is %d.\nPress 1 to continue:\n",charisma);
fgets(line,sizeof(line),stdin);
sscanf(line,"%d",&gaah);
if(gaah==1)
switch (character) {
case 1:
printf("Strenght= %d\n",strength);
printf("Dexterity= %d\n",dexterity);
printf("Constitution= %d\n",constitution);
printf("Intelligence= %d\n",intelligence);
printf("Wisdom= %d\n",wisdom);
printf("Charisma= %d\n",charisma);
break;
case 2:
printf("Strenght= %d\n",strength);
printf("Dexterity= %d +2 (Racial)\n",dexterity);
printf("Constitution= %d -2 (Racial)\n",constitution);
printf("Intelligence= %d\n",intelligence);
printf("Wisdom= %d\n",wisdom);
printf("Charisma= %d\n",charisma);
break;
case 3:
printf("Strenght= %d\n",strength);
printf("Dexterity= %d\n",dexterity);
printf("Constitution= %d +2 (Racial)\n",constitution);
printf("Intelligence= %d\n",intelligence);
printf("Wisdom= %d\n",wisdom);
printf("Charisma= %d -2 (Racial)\n",charisma);
break;
case 4:
printf("Strenght= %d -2 (Racial)\n",strength);
printf("Dexterity= %d\n",dexterity);
printf("Constitution= %d +2 (Racial)\n",constitution);
printf("Intelligence= %d\n",intelligence);
printf("Wisdom= %d\n",wisdom);
printf("Charisma= %d\n",charisma);
break;
}
printf("\nIt is now time to chose your class.\nThe following classes are selectable:\n");
do{
printf("1.Warrior\n2.Sorcerer\n3.Rogue\n");
fgets(line,sizeof(line),stdin);
sscanf(line,"%d",&character4);
switch (character4) {
case 1:
printf("The warrior is a strong and (often) fearless close combat fighter\n");
break;
case 2:
printf("The sorcerer is a spellcaster who prefer ranged combat\n");
break;
case 3:
printf("The rogue is also a close combat fighter but he relies on speed and stealth instead of strenght\n");
break;
}
printf("Press 1 To accept your class or 0 to choose a new one:\n");
fgets(line,sizeof(line),stdin);
sscanf(line,"%d",&accept2);
} while (accept2==0);
if (accept2==1)
printf("You have now chosen your class.\nPress 1 to chose your abilities.\n");
fgets(line,sizeof(line),stdin);
sscanf(line,"%d",&character5);
if (character5==1)
do {
ok7=1;
printf("You can chose two of the following abilities:\n1.Toughness (+3 hitpoints)\n2.Cleave (Gain an extra attack when your opponents hp drops below 0)\n3.Endurance (Tougher and more resistant to non-lethal damage, such as fatigue)\n4.Maximize spell (Your spell does its ultimate effect)\n5.Scribe scroll (Capable of sharing spells with others)\n6.Still spell (You can cast your spells without gestures)\n7.Stealthy (+2 on all hide- and move silently checks)\n8.Lightning reflexes (You make extra attacks of opportunity's)\n9.Alertness (+2 on all listen- and spot checks)\n");
fgets(line,sizeof(line),stdin);
sscanf(line,"%d",&skill);
switch (skill) {
case 1:
printf("Your first skill is Toughness.\n");
break;
case 2:
printf("Your first skill is Cleave.\n");
break;
case 3:
printf("Your first skill is Endurance.\n");
break;
case 4:
printf("Your first skill is Maximize spell.\n");
break;
case 5:
printf("Your first skill is Scribe scroll.\n");
break;
case 6:
printf("Your first skill is Still spell.\n");
break;
case 7:
printf("Your first skill is Stealthy.\n");
break;
case 8:
printf("Your first skill is Lightning reflexes.\n");
break;
case 9:
printf("Your first skill is Alertness.\n");
break;
default:
printf("You have to pick a skill.\n");
ok7=0;
break;
}
} while (ok7==0);
printf("Press 1 to chose your second skill, not the same of course...\n");
fgets(line,sizeof(line),stdin);
sscanf(line,"%d",&character6);
if (character6==1)
do{
ok8=1;
printf("1.Toughness (+3 hitpoints)\n2.Cleave (Gain an extra attack when your opponents hp drops below 0)\n3.Endurance (Tougher and more resistant to non-lethal damage, such as fatigue)\n4.Maximize spell (Your spell does its ultimate effect)\n5.Scribe scroll (Capable of sharing spells with others)\n6.Still spell (You can cast your spells without gestures)\n7.Stealthy (+2 on all hide- and move silently checks)\n8.Lightning reflexes (You make extra attacks of opportunity's)\n9.Alertness (+2 on all listen- and spot checks)\n");
fgets(line,sizeof(line),stdin);
sscanf(line,"%d",&skill2);
if (skill2==skill) {
printf("You can only have one of each skill\n");
ok8=0;
} else {
switch (skill2) {
case 1:
printf("Your second skill is Toughness.\n");
break;
case 2:
printf("Your second skill is Cleave.\n");
break;
case 3:
printf("Your second skill is Endurance.\n");
break;
case 4:
printf("Your second skill is Maximize spell.\n");
break;
case 5:
printf("Your second skill is Scribe scroll.\n");
break;
case 6:
printf("Your second skill is Still spell.\n");
break;
case 7:
printf("Your second skill is Stealthy.\n");
break;
case 8:
printf("Your second skill is Lightning reflexes.\n");
break;
case 9:
printf("Your second skill is Alertness.\n");