-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathclass.c
executable file
·9886 lines (9123 loc) · 463 KB
/
class.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
/**************************************************************************
* File: class.c Part of LuminariMUD *
* Usage: Source file for class-specific code. *
* Author: Circle, rewritten by Zusuk *
* All rights reserved. See license for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
**************************************************************************/
/** Help buffer the global variable definitions */
#define __CLASS_C__
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "db.h"
#include "spells.h"
#include "interpreter.h"
#include "constants.h"
#include "act.h"
#include "handler.h"
#include "comm.h"
#include "mud_event.h"
#include "mudlim.h"
#include "feats.h"
#include "class.h"
#include "assign_wpn_armor.h"
#include "pfdefaults.h"
#include "domains_schools.h"
#include "modify.h"
#include "spell_prep.h"
#include "race.h"
#include "alchemy.h"
#include "premadebuilds.h"
#include "evolutions.h"
#include "backgrounds.h"
/** LOCAL DEFINES **/
// good/bad
#define G 1 // good
#define B 0 // bad
// yes/no
#define Y 1 // yes
#define N 0 // no
// high/medium/low
#define H 2 // high
#define M 1 // medium
#define L 0 // low
// spell vs skill
#define SP 0 // spell
#define SK 1 // skill
// skill availability by class
#define NA 0 // not available
#define CC 1 // cross class
#define CA 2 // class ability
/* absolute xp cap */
#define EXP_MAX 2100000000
/* modes for dealing with class listing / restrictions */
#define MODE_CLASSLIST_NORMAL 0
#define MODE_CLASSLIST_RESPEC 1
/* here is our class_list declare */
struct class_table class_list[NUM_CLASSES];
/* SET OF UTILITY FUNCTIONS for the purpose of class prereqs */
/* create/allocate memory for a pre-req struct, then assign the prereqs */
struct class_prerequisite *create_prereq(int prereq_type, int val1,
int val2, int val3)
{
struct class_prerequisite *prereq = NULL;
CREATE(prereq, struct class_prerequisite, 1);
prereq->prerequisite_type = prereq_type;
prereq->values[0] = val1;
prereq->values[1] = val2;
prereq->values[2] = val3;
return prereq;
}
void class_prereq_attribute(int class_num, int attribute, int value)
{
struct class_prerequisite *prereq = NULL;
char buf[80];
const char *attribute_abbr[7] = {
"None",
"Str",
"Dex",
"Int",
"Wis",
"Con",
"Cha"};
prereq = create_prereq(CLASS_PREREQ_ATTRIBUTE, attribute, value, 0);
/* Generate the description. */
snprintf(buf, sizeof(buf), "%s: %d", attribute_abbr[attribute], value);
prereq->description = strdup(buf);
/* Link it up. */
prereq->next = class_list[class_num].prereq_list;
class_list[class_num].prereq_list = prereq;
}
void class_prereq_class_level(int class_num, int cl, int level)
{
struct class_prerequisite *prereq = NULL;
char buf[80];
prereq = create_prereq(CLASS_PREREQ_CLASS_LEVEL, cl, level, 0);
/* Generate the description */
snprintf(buf, sizeof(buf), "%s level %d", CLSLIST_NAME(cl), level);
prereq->description = strdup(buf);
/* Link it up */
prereq->next = class_list[class_num].prereq_list;
class_list[class_num].prereq_list = prereq;
}
void class_prereq_feat(int class_num, int feat, int ranks)
{
struct class_prerequisite *prereq = NULL;
char buf[80];
prereq = create_prereq(CLASS_PREREQ_FEAT, feat, ranks, 0);
/* Generate the description. */
if (ranks > 1)
snprintf(buf, sizeof(buf), "%s (%d ranks)", feat_list[feat].name, ranks);
else
snprintf(buf, sizeof(buf), "%s", feat_list[feat].name);
prereq->description = strdup(buf);
/* Link it up. */
prereq->next = class_list[class_num].prereq_list;
class_list[class_num].prereq_list = prereq;
}
void class_prereq_cfeat(int class_num, int feat, int special)
{
struct class_prerequisite *prereq = NULL;
char buf[80];
const char *cfeat_special[NUM_CFEAT_SPECIAL] = {
"no special circumstance",
"in ranged weapons",
};
prereq = create_prereq(CLASS_PREREQ_CFEAT, feat, special, 0);
snprintf(buf, sizeof(buf), "%s (%s)", feat_list[feat].name, cfeat_special[special]);
prereq->description = strdup(buf);
/* Link it up. */
prereq->next = class_list[class_num].prereq_list;
class_list[class_num].prereq_list = prereq;
}
void class_prereq_ability(int class_num, int ability, int ranks)
{
struct class_prerequisite *prereq = NULL;
char buf[80];
prereq = create_prereq(CLASS_PREREQ_ABILITY, ability, ranks, 0);
snprintf(buf, sizeof(buf), "%d ranks in %s", ranks, ability_names[ability]);
prereq->description = strdup(buf);
/* Link it up. */
prereq->next = class_list[class_num].prereq_list;
class_list[class_num].prereq_list = prereq;
}
void class_prereq_spellcasting(int class_num, int casting_type, int prep_type, int circle)
{
struct class_prerequisite *prereq = NULL;
char buf[80];
const char *casting_types[4] = {
"None",
"Arcane",
"Divine",
"Any"};
const char *spell_preparation_types[4] = {
"None",
"Prepared",
"Spontaneous",
"Any"};
prereq = create_prereq(CLASS_PREREQ_SPELLCASTING, casting_type, prep_type, circle);
snprintf(buf, sizeof(buf), "Has %s %s (circle) %d spells", casting_types[casting_type],
spell_preparation_types[prep_type], circle);
prereq->description = strdup(buf);
/* Link it up. */
prereq->next = class_list[class_num].prereq_list;
class_list[class_num].prereq_list = prereq;
}
void class_prereq_race(int class_num, int race)
{
struct class_prerequisite *prereq = NULL;
char buf[80];
prereq = create_prereq(CLASS_PREREQ_RACE, race, 0, 0);
snprintf(buf, sizeof(buf), "Race: %s", race_list[race].type);
prereq->description = strdup(buf);
/* Link it up. */
prereq->next = class_list[class_num].prereq_list;
class_list[class_num].prereq_list = prereq;
}
void class_prereq_bab(int class_num, int bab)
{
struct class_prerequisite *prereq = NULL;
char buf[80];
prereq = create_prereq(CLASS_PREREQ_BAB, bab, 0, 0);
snprintf(buf, sizeof(buf), "Min. BAB +%d", bab);
prereq->description = strdup(buf);
/* Link it up */
prereq->next = class_list[class_num].prereq_list;
class_list[class_num].prereq_list = prereq;
}
/* alignment is a list of RESTRICTED alignments */
void class_prereq_align(int class_num, int alignment)
{
struct class_prerequisite *prereq = NULL;
char buf[80];
prereq = create_prereq(CLASS_PREREQ_ALIGN, alignment, 0, 0);
/* #define LAWFUL_GOOD 0
#define NEUTRAL_GOOD 1
#define CHAOTIC_GOOD 2
#define LAWFUL_NEUTRAL 3
#define TRUE_NEUTRAL 4
#define CHAOTIC_NEUTRAL 5
#define LAWFUL_EVIL 6
#define NEUTRAL_EVIL 7
#define CHAOTIC_EVIL 8 */
snprintf(buf, sizeof(buf), "Align: %s", alignment_names_nocolor[alignment]);
prereq->description = strdup(buf);
/* Link it up */
prereq->next = class_list[class_num].prereq_list;
class_list[class_num].prereq_list = prereq;
}
void class_prereq_weapon_proficiency(int class_num)
{
struct class_prerequisite *prereq = NULL;
char buf[80];
prereq = create_prereq(CLASS_PREREQ_WEAPON_PROFICIENCY, 0, 0, 0);
snprintf(buf, sizeof(buf), "Proficiency in same weapon");
prereq->description = strdup(buf);
/* Link it up */
prereq->next = class_list[class_num].prereq_list;
class_list[class_num].prereq_list = prereq;
}
/* our little mini struct series for assigning spells to a class and to assigning
minimum-level for those spells */
/* create/allocate memory for the spellassign struct */
struct class_spell_assign *create_spell_assign(int spell_num, int level)
{
struct class_spell_assign *spell_asign = NULL;
CREATE(spell_asign, struct class_spell_assign, 1);
spell_asign->spell_num = spell_num;
spell_asign->level = level;
return spell_asign;
}
/* actual function called to perform the spell assignment */
void spell_assignment(int class_num, int spell_num, int level)
{
struct class_spell_assign *spell_asign = NULL;
spell_asign = create_spell_assign(spell_num, level);
/* Link it up. */
spell_asign->next = class_list[class_num].spellassign_list;
class_list[class_num].spellassign_list = spell_asign;
}
/* our little mini struct series for assigning feats to a class and to assigning
class-feats to a class */
/* create/allocate memory for the spellassign struct */
struct class_feat_assign *create_feat_assign(int feat_num, bool is_classfeat,
int level_received, bool stacks)
{
struct class_feat_assign *feat_assign = NULL;
CREATE(feat_assign, struct class_feat_assign, 1);
feat_assign->feat_num = feat_num;
feat_assign->is_classfeat = is_classfeat;
feat_assign->level_received = level_received;
feat_assign->stacks = stacks;
return feat_assign;
}
/* actual function called to perform the feat assignment */
/* when assigning class feats use this format:
feat_assignment(CLASS_blah, FEAT_blah_blah, Y, NOASSIGN_FEAT, N); */
void feat_assignment(int class_num, int feat_num, bool is_classfeat,
int level_received, bool stacks)
{
struct class_feat_assign *feat_assign = NULL;
feat_assign = create_feat_assign(feat_num, is_classfeat, level_received, stacks);
/* Link it up. */
feat_assign->next = class_list[class_num].featassign_list;
class_list[class_num].featassign_list = feat_assign;
}
/* function that will assign a list of values to a given class */
void classo(int class_num, const char *name, const char *abbrev, const char *colored_abbrev,
const char *menu_name, int max_level, bool locked_class, int prestige_class,
int base_attack_bonus, int hit_dice, int psp_gain, int move_gain,
int trains_gain, bool in_game, int unlock_cost, int epic_feat_progression,
const char *spell_prog, const char *primary_attribute, const char *descrip)
{
class_list[class_num].name = name;
class_list[class_num].abbrev = abbrev;
class_list[class_num].colored_abbrev = colored_abbrev;
class_list[class_num].menu_name = menu_name;
class_list[class_num].max_level = max_level;
class_list[class_num].locked_class = locked_class;
class_list[class_num].prestige_class = prestige_class;
class_list[class_num].base_attack_bonus = base_attack_bonus;
class_list[class_num].hit_dice = hit_dice;
class_list[class_num].psp_gain = psp_gain;
class_list[class_num].move_gain = move_gain;
class_list[class_num].trains_gain = trains_gain;
class_list[class_num].in_game = in_game;
class_list[class_num].unlock_cost = unlock_cost;
class_list[class_num].epic_feat_progression = epic_feat_progression;
class_list[class_num].prestige_spell_progression = spell_prog;
class_list[class_num].primary_attribute = primary_attribute;
class_list[class_num].descrip = descrip;
/* list of prereqs */
class_list[class_num].prereq_list = NULL;
/* list of spell assignments */
class_list[class_num].spellassign_list = NULL;
/* list of feat assignments */
class_list[class_num].featassign_list = NULL;
}
/* function used for assigning a classes titles */
static void assign_class_titles(
int class_num, const char *title_4, const char *title_9, const char *title_14,
const char *title_19, const char *title_24, const char *title_29, const char *title_30, const char *title_imm,
const char *title_stf, const char *title_gstf, const char *title_default)
{
class_list[class_num].titles[0] = title_4;
class_list[class_num].titles[1] = title_9;
class_list[class_num].titles[2] = title_14;
class_list[class_num].titles[3] = title_19;
class_list[class_num].titles[4] = title_24;
class_list[class_num].titles[5] = title_29;
class_list[class_num].titles[6] = title_30;
class_list[class_num].titles[7] = title_imm;
class_list[class_num].titles[8] = title_stf;
class_list[class_num].titles[9] = title_gstf;
class_list[class_num].titles[10] = title_default;
}
/* function used for assigned a classes 'preferred' saves */
void assign_class_saves(int class_num, int save_fort, int save_refl, int save_will,
int save_posn, int save_deth)
{
class_list[class_num].preferred_saves[SAVING_FORT] = save_fort;
class_list[class_num].preferred_saves[SAVING_REFL] = save_refl;
class_list[class_num].preferred_saves[SAVING_WILL] = save_will;
class_list[class_num].preferred_saves[SAVING_POISON] = save_posn;
class_list[class_num].preferred_saves[SAVING_DEATH] = save_deth;
}
/* function used for assigning whether a given ability is not-available, cross-class
or class-skill */
void assign_class_abils(int class_num,
int acrobatics, int stealth, int perception, int heal, int intimidate,
int concentration, int spellcraft, int appraise, int discipline,
int total_defense, int lore, int ride, int climb, int sleight_of_hand,
int bluff, int diplomacy, int disable_device, int disguise, int escape_artist,
int handle_animal, int sense_motive, int survival, int swim, int use_magic_device,
int perform)
{
class_list[class_num].class_abil[ABILITY_ACROBATICS] = acrobatics;
class_list[class_num].class_abil[ABILITY_STEALTH] = stealth;
class_list[class_num].class_abil[ABILITY_PERCEPTION] = perception;
class_list[class_num].class_abil[ABILITY_HEAL] = heal;
class_list[class_num].class_abil[ABILITY_INTIMIDATE] = intimidate;
class_list[class_num].class_abil[ABILITY_CONCENTRATION] = concentration;
class_list[class_num].class_abil[ABILITY_SPELLCRAFT] = spellcraft;
class_list[class_num].class_abil[ABILITY_APPRAISE] = appraise;
class_list[class_num].class_abil[ABILITY_DISCIPLINE] = discipline;
class_list[class_num].class_abil[ABILITY_TOTAL_DEFENSE] = total_defense;
class_list[class_num].class_abil[ABILITY_ARCANA] = CA;
class_list[class_num].class_abil[ABILITY_RELIGION] = CA;
class_list[class_num].class_abil[ABILITY_HISTORY] = CA;
class_list[class_num].class_abil[ABILITY_RIDE] = ride;
class_list[class_num].class_abil[ABILITY_ATHLETICS] = climb;
class_list[class_num].class_abil[ABILITY_SLEIGHT_OF_HAND] = sleight_of_hand;
class_list[class_num].class_abil[ABILITY_BLUFF] = bluff;
class_list[class_num].class_abil[ABILITY_DIPLOMACY] = diplomacy;
class_list[class_num].class_abil[ABILITY_DISABLE_DEVICE] = disable_device;
class_list[class_num].class_abil[ABILITY_DISGUISE] = disguise;
class_list[class_num].class_abil[ABILITY_ESCAPE_ARTIST] = escape_artist;
class_list[class_num].class_abil[ABILITY_HANDLE_ANIMAL] = handle_animal;
class_list[class_num].class_abil[ABILITY_SENSE_MOTIVE] = sense_motive;
class_list[class_num].class_abil[ABILITY_SURVIVAL] = CA;
class_list[class_num].class_abil[ABILITY_USE_MAGIC_DEVICE] = use_magic_device;
class_list[class_num].class_abil[ABILITY_PERFORM] = perform;
class_list[class_num].class_abil[ABILITY_LINGUISTICS] = CA;
}
/* function to give default values for a class before assignment */
void init_class_list(int class_num)
{
class_list[class_num].name = "unusedclass";
class_list[class_num].abbrev = "???";
class_list[class_num].colored_abbrev = "???";
class_list[class_num].menu_name = "???";
class_list[class_num].max_level = -1;
class_list[class_num].locked_class = N;
class_list[class_num].prestige_class = N;
class_list[class_num].base_attack_bonus = L;
class_list[class_num].hit_dice = 4;
class_list[class_num].psp_gain = 0;
class_list[class_num].move_gain = 0;
class_list[class_num].trains_gain = 2;
class_list[class_num].in_game = N;
class_list[class_num].unlock_cost = 0;
class_list[class_num].epic_feat_progression = 5;
class_list[class_num].prestige_spell_progression = "no progression";
class_list[class_num].primary_attribute = "no primary attribute";
class_list[class_num].descrip = "undescribed class";
int i = 0;
for (i = 0; i < NUM_PREFERRED_SAVES; i++)
class_list[class_num].preferred_saves[i] = B;
for (i = 0; i < NUM_ABILITIES; i++)
class_list[class_num].class_abil[i] = NA;
for (i = 0; i < MAX_NUM_TITLES; i++)
class_list[class_num].titles[i] = "";
class_list[class_num].prereq_list = NULL;
class_list[class_num].spellassign_list = NULL;
class_list[class_num].featassign_list = NULL;
}
/* this was created to handle special scenarios for combat feat requirements
for classes */
bool has_special_cfeat(struct char_data *ch, int featnum, int mode)
{
switch (mode)
{
/* featnum in any bow */
case CFEAT_SPECIAL_BOW:
/*
if (!HAS_COMBAT_FEAT(ch, feat_to_cfeat(featnum),
WEAPON_TYPE_LONG_BOW) &&
!HAS_COMBAT_FEAT(ch, feat_to_cfeat(featnum),
WEAPON_TYPE_COMPOSITE_LONGBOW) &&
!HAS_COMBAT_FEAT(ch, feat_to_cfeat(featnum),
WEAPON_TYPE_COMPOSITE_LONGBOW_2) &&
!HAS_COMBAT_FEAT(ch, feat_to_cfeat(featnum),
WEAPON_TYPE_COMPOSITE_LONGBOW_3) &&
!HAS_COMBAT_FEAT(ch, feat_to_cfeat(featnum),
WEAPON_TYPE_COMPOSITE_LONGBOW_4) &&
!HAS_COMBAT_FEAT(ch, feat_to_cfeat(featnum),
WEAPON_TYPE_COMPOSITE_LONGBOW_5) &&
!HAS_COMBAT_FEAT(ch, feat_to_cfeat(featnum),
WEAPON_TYPE_SHORT_BOW) &&
!HAS_COMBAT_FEAT(ch, feat_to_cfeat(featnum),
WEAPON_TYPE_COMPOSITE_SHORTBOW) &&
!HAS_COMBAT_FEAT(ch, feat_to_cfeat(featnum),
WEAPON_TYPE_COMPOSITE_SHORTBOW_2) &&
!HAS_COMBAT_FEAT(ch, feat_to_cfeat(featnum),
WEAPON_TYPE_COMPOSITE_SHORTBOW_3) &&
!HAS_COMBAT_FEAT(ch, feat_to_cfeat(featnum),
WEAPON_TYPE_COMPOSITE_SHORTBOW_4) &&
!HAS_COMBAT_FEAT(ch, feat_to_cfeat(featnum),
WEAPON_TYPE_COMPOSITE_SHORTBOW_5)
) { */
if (!HAS_COMBAT_FEAT(ch, feat_to_cfeat(featnum), WEAPON_FAMILY_RANGED))
{
return FALSE;
}
break;
/* auto pass by default */
case CFEAT_SPECIAL_NONE:
break;
default:
return FALSE;
}
/* success! */
return TRUE;
}
/* Check to see if ch meets the provided class prerequisite.
iarg is for external comparison */
bool meets_class_prerequisite(struct char_data *ch, struct class_prerequisite *prereq, int iarg)
{
switch (prereq->prerequisite_type)
{
case CLASS_PREREQ_NONE:
/* This is a NON-prereq. */
break;
/* valid alignments - special handling since list of valids */
case CLASS_PREREQ_ALIGN:
if (prereq->values[0] != convert_alignment(GET_ALIGNMENT(ch)))
return FALSE;
break;
/* minimum stats */
case CLASS_PREREQ_ATTRIBUTE:
switch (prereq->values[0])
{
case AB_STR:
if (GET_REAL_STR(ch) < prereq->values[1])
return FALSE;
break;
case AB_DEX:
if (GET_REAL_DEX(ch) < prereq->values[1])
return FALSE;
break;
case AB_CON:
if (GET_REAL_CON(ch) < prereq->values[1])
return FALSE;
break;
case AB_WIS:
if (GET_REAL_WIS(ch) < prereq->values[1])
return FALSE;
break;
case AB_INT:
if (GET_REAL_INT(ch) < prereq->values[1])
return FALSE;
break;
case AB_CHA:
if (GET_REAL_CHA(ch) < prereq->values[1])
return FALSE;
break;
default:
log("SYSERR: meets_class_prerequisite() - Bad Attribute prerequisite %d", prereq->values[0]);
return FALSE;
}
break;
/* min. class level */
case CLASS_PREREQ_CLASS_LEVEL:
if (CLASS_LEVEL(ch, prereq->values[0]) < prereq->values[1])
return FALSE;
break;
/* feat requirement */
case CLASS_PREREQ_FEAT:
if (has_feat_requirement_check(ch, prereq->values[0]) < prereq->values[1])
return FALSE;
break;
/* required ability */
case CLASS_PREREQ_ABILITY:
if (GET_ABILITY(ch, prereq->values[0]) < prereq->values[1])
return FALSE;
break;
/* spellcasting type and preparation type */
case CLASS_PREREQ_SPELLCASTING:
switch (prereq->values[0])
{
case CASTING_TYPE_NONE:
if (IS_SPELLCASTER(ch))
return FALSE;
break;
case CASTING_TYPE_ARCANE:
if (!(IS_WIZARD(ch) ||
IS_SORCERER(ch) ||
IS_SUMMONER(ch) ||
IS_BARD(ch)))
return FALSE;
/* This stuff is all messed up - fix. */
if (prereq->values[2] > 0)
{
if (compute_slots_by_circle(ch, CLASS_WIZARD, prereq->values[2]) == 0 &&
compute_slots_by_circle(ch, CLASS_SORCERER, prereq->values[2]) == 0 &&
compute_slots_by_circle(ch, CLASS_BARD, prereq->values[2]) == 0)
return FALSE;
}
break;
case CASTING_TYPE_DIVINE:
if (!(IS_CLERIC(ch) ||
IS_DRUID(ch) ||
IS_INQUISITOR(ch) ||
IS_PALADIN(ch) ||
(CLASS_LEVEL(ch, CLASS_BLACKGUARD) > 0) ||
IS_RANGER(ch)))
return FALSE;
if (prereq->values[2] > 0)
{
if (compute_slots_by_circle(ch, CLASS_CLERIC, prereq->values[2]) == 0 &&
compute_slots_by_circle(ch, CLASS_PALADIN, prereq->values[2]) == 0 &&
compute_slots_by_circle(ch, CLASS_INQUISITOR, prereq->values[2]) == 0 &&
compute_slots_by_circle(ch, CLASS_BLACKGUARD, prereq->values[2]) == 0 &&
compute_slots_by_circle(ch, CLASS_DRUID, prereq->values[2]) == 0 &&
compute_slots_by_circle(ch, CLASS_RANGER, prereq->values[2]) == 0)
return FALSE;
}
break;
case CASTING_TYPE_ANY:
if (!IS_SPELLCASTER(ch))
return FALSE;
if (prereq->values[2] > 0)
{
if (!(compute_slots_by_circle(ch, CLASS_WIZARD, prereq->values[2]) == 0 ||
compute_slots_by_circle(ch, CLASS_SORCERER, prereq->values[2]) == 0 ||
compute_slots_by_circle(ch, CLASS_BARD, prereq->values[2]) == 0 ||
compute_slots_by_circle(ch, CLASS_INQUISITOR, prereq->values[2]) == 0 ||
compute_slots_by_circle(ch, CLASS_CLERIC, prereq->values[2]) == 0 ||
compute_slots_by_circle(ch, CLASS_PALADIN, prereq->values[2]) == 0 ||
compute_slots_by_circle(ch, CLASS_DRUID, prereq->values[2]) == 0 ||
compute_slots_by_circle(ch, CLASS_RANGER, prereq->values[2]) == 0))
return FALSE;
}
break;
default:
log("SYSERR: meets_class_prerequisite() - Bad Casting Type prerequisite %d", prereq->values[0]);
return FALSE;
}
switch (prereq->values[1])
{
case PREP_TYPE_NONE:
return FALSE;
case PREP_TYPE_PREPARED:
if (!IS_MEM_BASED_CASTER(ch))
return FALSE;
break;
case PREP_TYPE_SPONTANEOUS:
if (IS_MEM_BASED_CASTER(ch))
return FALSE;
break;
case PREP_TYPE_ANY:
break;
default:
log("SYSERR: meets_class_prerequisite() - Bad Preparation type prerequisite %d", prereq->values[1]);
return FALSE;
}
break;
/* valid races - special handling since list of valids */
case CLASS_PREREQ_RACE:
if (!IS_NPC(ch) && GET_RACE(ch) != prereq->values[0])
return FALSE;
break;
/* minimum BAB requirement */
case CLASS_PREREQ_BAB:
if (ACTUAL_BAB(ch) < prereq->values[0])
return FALSE;
break;
/* combat feat */
case CLASS_PREREQ_CFEAT:
/* SPECIAL CASE - You must have a feat, and it must be the cfeat for the chosen weapon. */
if (iarg && !has_combat_feat(ch, feat_to_cfeat(prereq->values[0]), iarg))
return FALSE;
/* when not using iarg, we use the 'special' value - CFEAT_SPECIAL_ and
use has_special_cfeat() for processing */
if (!iarg && !has_special_cfeat(ch, prereq->values[0], prereq->values[1]))
return FALSE;
break;
/* weapon proficiency requirement */
case CLASS_PREREQ_WEAPON_PROFICIENCY:
if (iarg && !is_proficient_with_weapon(ch, iarg))
return FALSE;
break;
default:
log("SYSERR: meets_class_prerequisite() - Bad prerequisite type %d", prereq->prerequisite_type);
return FALSE;
}
return TRUE;
}
/* a display specific to identify prereqs for a given class */
bool display_class_prereqs(struct char_data *ch, const char *classname)
{
int class = CLASS_UNDEFINED;
struct class_prerequisite *prereq = NULL;
static int line_length = 80;
char buf[MAX_STRING_LENGTH] = {'\0'};
bool meets_prereqs = FALSE, found = FALSE;
skip_spaces_c(&classname);
class = parse_class_long(classname);
if (class == CLASS_UNDEFINED)
{
return FALSE;
}
/* do some math to check if we have max levels in a given class */
int max_class_level = CLSLIST_MAXLVL(class);
if (max_class_level == -1) /* no limit */
max_class_level = LVL_IMMORT - 1;
/* display top */
send_to_char(ch, "\tC\r\n");
draw_line(ch, line_length, '-', '-');
/* basic info */
send_to_char(ch, "\tcClass Name : \tn%s\r\n", CLSLIST_NAME(class));
send_to_char(ch, "\tcMax Level in Class: \tn%d - %s\r\n", max_class_level,
(CLASS_LEVEL(ch, class) >= max_class_level) ? "\trCap reached!\tn" : "\tWLevel cap not reached!\tn");
send_to_char(ch, "\tcUnlock Cost : \tn%d Account XP - %s\r\n", CLSLIST_COST(class),
has_unlocked_class(ch, class) ? "\tWUnlocked!\tn" : "\trLocked!\tn");
send_to_char(ch, "\tcClass in the Game?: \tn%s\r\n", CLSLIST_INGAME(class) ? "\tWYes\tn" : "\trNo\tn");
/* prereqs, start with text line */
send_to_char(ch, "\tC");
send_to_char(ch, "%s", text_line_string("\tcRequirements\tC", line_length, '-', '-'));
send_to_char(ch, "\tn");
send_to_char(ch, "\tcNote: you only need to meet one prereq for race and align:\tn\r\n\r\n");
/* here we process our prereq linked list for each class */
for (prereq = class_list[class].prereq_list; prereq != NULL; prereq = prereq->next)
{
meets_prereqs = FALSE;
if (meets_class_prerequisite(ch, prereq, NO_IARG))
meets_prereqs = TRUE;
snprintf(buf, sizeof(buf), "\tn%s%s%s - %s\r\n",
(meets_prereqs ? "\tn" : "\tr"), prereq->description, "\tn",
(meets_prereqs ? "\tWFulfilled!\tn" : "\trMissing\tn"));
send_to_char(ch, "%s", buf);
found = TRUE;
}
if (!found)
send_to_char(ch, "\tWNo requirements!\tn\r\n");
/* close prereq display */
send_to_char(ch, "\tC");
draw_line(ch, line_length, '-', '-');
send_to_char(ch, "\tn");
if (class_is_available(ch, class, 0, NULL))
{
send_to_char(ch, "\tWClass IS AVAILABLE!\tn\r\n");
}
else
{
send_to_char(ch, "\trClass is not available!\tn\r\n");
}
/* close display */
send_to_char(ch, "\tC");
draw_line(ch, line_length, '-', '-');
send_to_char(ch, "\tn");
// send_to_char(ch, "\tcNote: Epic races currently can not multi-class\tn\r\n\r\n");
return TRUE;
}
/* this will be a general list of all classes and indication whether
selectable by CH based on prereqs */
void display_all_classes(struct char_data *ch)
{
struct descriptor_data *d = ch->desc;
int counter, columns = 0;
write_to_output(d, "\r\n");
for (counter = 0; counter < NUM_CLASSES; counter++)
{
write_to_output(d, "%s%-20.20s %s",
class_is_available(ch, counter, MODE_CLASSLIST_NORMAL, NULL) ? " " : "*",
CLSLIST_NAME(counter),
!(++columns % 3) ? "\r\n" : "");
}
write_to_output(d, "\r\n");
write_to_output(d, "* - not qualified 'class prereqs <class name>' for details\r\n");
write_to_output(d, "\r\n");
}
/* determines if ch qualifies for a class */
bool class_is_available(struct char_data *ch, int classnum, int iarg, char *sarg)
{
struct class_prerequisite *prereq = NULL;
int i = 0, max_class_level = CLSLIST_MAXLVL(classnum);
bool has_alignment_restrictions = FALSE, has_valid_alignment = FALSE;
bool has_race_restrictions = FALSE, has_valid_race = FALSE;
/* dumb-dumb check */
if (classnum < 0 || classnum >= NUM_CLASSES)
return FALSE;
/* is this class even in the game? */
if (!CLSLIST_INGAME(classnum))
return FALSE;
/* cap for class ranks */
if (max_class_level == -1) /* no limit */
max_class_level = LVL_IMMORT - 1;
if (CLASS_LEVEL(ch, classnum) >= max_class_level)
{
return FALSE;
}
/* prevent epic race from currently multi-classing */
/* disabled! */
if (iarg == MODE_CLASSLIST_NORMAL)
{
for (i = 0; i < NUM_CLASSES; i++)
if (CLASS_LEVEL(ch, i)) /* found char current class */
break;
switch (GET_REAL_RACE(ch))
{
/*
case RACE_CRYSTAL_DWARF:
if (classnum == i) // char class selection and current class match?
;
else
return FALSE;
case RACE_TRELUX:
if (classnum == i) // char class selection and current class match?
;
else
return FALSE;
*/
default:
break;
}
}
/* locked class that has been unlocked yet? */
if (!has_unlocked_class(ch, classnum))
return FALSE;
/* class prerequisites list */
if (class_list[classnum].prereq_list != NULL)
{
/* This class has prerequisites. Traverse the list and check. */
for (prereq = class_list[classnum].prereq_list; prereq != NULL; prereq = prereq->next)
{
/* we have to check for valid lists, like a list of valid alignments or races */
switch (prereq->prerequisite_type)
{
/* has align restriction? well any qualification will work */
case CLASS_PREREQ_ALIGN:
has_alignment_restrictions = TRUE;
if (meets_class_prerequisite(ch, prereq, iarg) == TRUE)
has_valid_alignment = TRUE;
break;
/* has race restriction? well any qualification will work */
case CLASS_PREREQ_RACE:
has_race_restrictions = TRUE;
if (meets_class_prerequisite(ch, prereq, iarg) == TRUE)
has_valid_race = TRUE;
break;
/* our default normal case, instant disqualification */
default:
if (meets_class_prerequisite(ch, prereq, iarg) == FALSE)
return FALSE; /* these are instant disqualifications */
break;
}
} /* finished transversing list */
/* final check for 'valid lists' such as alignment / race list */
if (has_alignment_restrictions && !has_valid_alignment)
return FALSE; /* doesn't mean alignment reqs */
if (has_race_restrictions && !has_valid_race)
return FALSE; /* doesn't mean race reqs */
}
/* made it! */
return TRUE;
}
/* display a specific weapon details */
bool display_weapon_info(struct char_data *ch, const char *weapon)
{
int i = 0;
for (i = 0; i < NUM_WEAPON_TYPES; i++)
{
if (is_abbrev(weapon, weapon_list[i].name))
break;
}
if (i < 0 || i >= NUM_WEAPON_TYPES)
{
return FALSE;
}
do_weaponinfo(ch, weapon, 0, 0);
return TRUE;
}
/* display specific region details */
bool display_region_info(struct char_data *ch, int region)
{
if (!ch || region <= REGION_NONE || region > NUM_REGIONS || !is_selectable_region(region))
{
return FALSE;
}
char buf[MAX_STRING_LENGTH];
/* This we will need to buffer and wrap so that it will fit in the space provided. */
send_to_char(ch, "\tc%s\r\n", regions[region]);
send_to_char(ch, "\tcLanguage: \tn%s\r\n", languages[get_region_language(region)]);
send_to_char(ch, "\tcDescription: \tn\r\n");
snprintf(buf, sizeof(buf), "%s", get_region_info(region));
send_to_char(ch, "%s", strfrmt(buf, 80, 1, FALSE, FALSE, FALSE));
return TRUE;
}
/* display a specific armor type details */
bool display_armor_info(struct char_data *ch, const char *armor)
{
int i = 0;
for (i = 1; i < NUM_SPEC_ARMOR_SUIT_TYPES; i++)
{
if (is_abbrev(armor, armor_list[i].name))
break;
}
if (i < 0 || i >= NUM_SPEC_ARMOR_SUIT_TYPES)
{
return FALSE;
}
do_armorinfo(ch, armor, 0, 0);
return TRUE;
}
/* display a specific classes details */
bool display_class_info(struct char_data *ch, const char *classname)
{
int class = -1, i = 0;
char buf[MAX_STRING_LENGTH] = {'\0'};
char buf2[MAX_STRING_LENGTH] = {'\0'};
static int line_length = 80;
bool first_skill = TRUE;
size_t len = 0;
skip_spaces_c(&classname);
class = parse_class_long(classname);
if (class == -1 || class >= NUM_CLASSES)
{
/* Not found - Maybe put in a soundex list here? */
return FALSE;
}
/* We found the class, and the class number is stored in 'class'. */
/* Display the class info, formatted. */
send_to_char(ch, "\tC\r\n");
draw_line(ch, line_length, '-', '-');
send_to_char(ch, "\tcClass Name : \tn%s\r\n", CLSLIST_NAME(class));