forked from triem/Electric-Dreams
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbit.c
2259 lines (2061 loc) · 92.7 KB
/
bit.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
#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"
char * element_type_name( int element )
{
if ( element == ELEMENT_FIRE ) return "`Rfire`w";
if ( element == ELEMENT_WATER ) return "`Bwater`w";
if ( element == ELEMENT_EARTH ) return "`Gearth`w";
if ( element == ELEMENT_WIND ) return "`Cwind`w";
if ( element == ELEMENT_SPIRIT ) return "`Wspirit`w";
return "none";
}
char * mineral_type_name( int mineral )
{
if ( mineral == MINERAL_STEEL ) return "`wSteel`w";
if ( mineral == MINERAL_GOLD ) return "`YGold`w";
if ( mineral == MINERAL_SILVER ) return "`wSilver`w";
if ( mineral == MINERAL_IRON ) return "`KIron`w";
if ( mineral == MINERAL_BRONZE ) return "`yBronze`w";
if ( mineral == MINERAL_COPPER ) return "`yCopper`w";
if ( mineral == MINERAL_RUBY ) return "`RRuby`w";
if ( mineral == MINERAL_SAPPHIRE ) return "`BSapphire`w";
if ( mineral == MINERAL_EMERALD ) return "`gEmerald`w";
if ( mineral == MINERAL_ALABASTER ) return "`wAlabaster`w";
if ( mineral == MINERAL_ADAMANTITE ) return "`wAdamantite`w";
if ( mineral == MINERAL_TITANIUM ) return "`WTitanium`w";
if ( mineral == MINERAL_PLATINUM ) return "`KPlatinum`w";
if ( mineral == MINERAL_OBSIDIAN ) return "`bObsidian`w";
if ( mineral == MINERAL_MITHRIL ) return "`CMithril`w";
if ( mineral == MINERAL_DIAMOND ) return "`WDiamond`w";
return "none";
}
char * bit_type_name( int bit_type, long bit_vector )
{
if ( bit_type == BIT_IMM ) return imm_bit_name(bit_vector);
if ( bit_type == BIT_AFFECT ) return affect_bit_name(bit_vector);
if ( bit_type == BIT_VULN ) return vuln_bit_name(bit_vector);
if ( bit_type == BIT_AFFECT2 ) return affect_bit_name_2(bit_vector);
if ( bit_type == BIT_RES ) return res_bit_name(bit_vector);
return "none";
}
char * get_bit_name( int bit_type )
{
if ( bit_type == BIT_IMM ) return "immunity";
if ( bit_type == BIT_AFFECT ) return "affect";
if ( bit_type == BIT_VULN ) return "vulnerbility";
if ( bit_type == BIT_AFFECT2 ) return "affect";
if ( bit_type == BIT_RES ) return "resistance";
return "none";
}
char * get_quest_name( int bit_type )
{
if ( bit_type == STEP1 ) return "step1";
if ( bit_type == STEP2 ) return "step2";
if ( bit_type == STEP3 ) return "step3";
if ( bit_type == STEP4 ) return "step4";
if ( bit_type == STEP5 ) return "step5";
if ( bit_type == STEP6 ) return "step6";
if ( bit_type == STEP7 ) return "step7";
if ( bit_type == STEP8 ) return "step8";
if ( bit_type == STEP9 ) return "step9";
if ( bit_type == STEP10 ) return "step10";
if ( bit_type == STEP11 ) return "step11";
if ( bit_type == STEP12 ) return "step12";
if ( bit_type == STEP13 ) return "step13";
if ( bit_type == STEP14 ) return "step14";
if ( bit_type == STEP15 ) return "step15";
if ( bit_type == STEP16 ) return "step16";
if ( bit_type == STEP17 ) return "step17";
if ( bit_type == STEP18 ) return "step18";
if ( bit_type == STEP19 ) return "step19";
if ( bit_type == STEP20 ) return "step20";
if ( bit_type == QUEST_COMPLETED ) return "completed";
return "none";
}
int get_element_type( char * arg )
{
if ( !str_cmp( arg, "fire" ) ) return ELEMENT_FIRE;
if ( !str_cmp( arg, "water" ) ) return ELEMENT_WATER;
if ( !str_cmp( arg, "earth" ) ) return ELEMENT_EARTH;
if ( !str_cmp( arg, "wind" ) ) return ELEMENT_WIND;
if ( !str_cmp( arg, "spirit") ) return ELEMENT_SPIRIT;
return -1;
}
int get_mineral_type( char * arg )
{
if ( !str_cmp( arg, "steel" ) ) return MINERAL_STEEL;
if ( !str_cmp( arg, "gold" ) ) return MINERAL_GOLD;
if ( !str_cmp( arg, "silver" ) ) return MINERAL_SILVER;
if ( !str_cmp( arg, "iron" ) ) return MINERAL_IRON;
if ( !str_cmp( arg, "copper" ) ) return MINERAL_COPPER;
if ( !str_cmp( arg, "bronze" ) ) return MINERAL_BRONZE;
if ( !str_cmp( arg, "diamond" ) ) return MINERAL_DIAMOND;
if ( !str_cmp( arg, "ruby" ) ) return MINERAL_RUBY;
if ( !str_cmp( arg, "sapphire" ) ) return MINERAL_SAPPHIRE;
if ( !str_cmp( arg, "emerald" ) ) return MINERAL_EMERALD;
if ( !str_cmp( arg, "obsidian" ) ) return MINERAL_OBSIDIAN;
if ( !str_cmp( arg, "platinum" ) ) return MINERAL_PLATINUM;
if ( !str_cmp( arg, "mithril" ) ) return MINERAL_MITHRIL;
if ( !str_cmp( arg, "adamantite" ) ) return MINERAL_ADAMANTITE;
if ( !str_cmp( arg, "alabaster" ) ) return MINERAL_ALABASTER;
if ( !str_cmp( arg, "titanium" ) ) return MINERAL_TITANIUM;
return -1;
}
char * cmd_group_type_name( int group )
{
static char buf[512];
buf[0] = '\0';
if ( group & CMD_GROUP_ADMIN ) strcat(buf, " `Cadmin`w" );
if ( group & CMD_GROUP_BASIC_BUILD ) strcat(buf, " `Cbasic_build`w" );
if ( group & CMD_GROUP_ADVANCE_BUILD ) strcat(buf, " `Cadvance_build`w" );
if ( group & CMD_GROUP_INFO ) strcat(buf, " `Cinfo`w" );
if ( group & CMD_GROUP_DEFAULT ) strcat(buf, " `Cdefault`w" );
if ( group & CMD_GROUP_GAME_CONTROL ) strcat(buf, " `Cgame_control`w" );
if ( group & CMD_GROUP_ADVANCE_PHELP ) strcat(buf, " `Cadvance_phelp`w" );
if ( group & CMD_GROUP_BASIC_PHELP ) strcat(buf, " `Cbasic_phelp`w" );
if ( group & CMD_GROUP_PLAYER ) strcat(buf, " `Cplayer`w" );
if ( group & CMD_GROUP_MOBILE ) strcat(buf, " `Cmobile`w" );
return ( buf[0] != '\0' ) ? buf+1 : str_dup("none");
}
int get_cmd_group_type( char * arg )
{
if ( !str_cmp( arg, "admin" ) ) return CMD_GROUP_ADMIN;
if ( !str_cmp( arg, "basic_build" ) ) return CMD_GROUP_BASIC_BUILD;
if ( !str_cmp( arg, "info" ) ) return CMD_GROUP_INFO;
if ( !str_cmp( arg, "default" ) ) return CMD_GROUP_DEFAULT;
if ( !str_cmp( arg, "game_control" ) ) return CMD_GROUP_GAME_CONTROL;
if ( !str_cmp( arg, "advance_phelp" ) ) return CMD_GROUP_ADVANCE_PHELP;
if ( !str_cmp( arg, "advance_build" ) ) return CMD_GROUP_ADVANCE_BUILD;
if ( !str_cmp( arg, "basic_phelp" ) ) return CMD_GROUP_BASIC_PHELP;
if ( !str_cmp( arg, "player" ) ) return CMD_GROUP_PLAYER;
if ( !str_cmp( arg, "mobile" ) ) return CMD_GROUP_MOBILE;
return -1;
}
int get_quest_flags( char * arg )
{
if ( !str_cmp( arg, "step1" ) ) return STEP1;
if ( !str_cmp( arg, "step2" ) ) return STEP2;
if ( !str_cmp( arg, "step3" ) ) return STEP3;
if ( !str_cmp( arg, "step4" ) ) return STEP4;
if ( !str_cmp( arg, "step5" ) ) return STEP5;
if ( !str_cmp( arg, "step6" ) ) return STEP6;
if ( !str_cmp( arg, "step7" ) ) return STEP7;
if ( !str_cmp( arg, "step8" ) ) return STEP8;
if ( !str_cmp( arg, "step9" ) ) return STEP9;
if ( !str_cmp( arg, "step10") ) return STEP10;
if ( !str_cmp( arg, "step11") ) return STEP11;
if ( !str_cmp( arg, "step12") ) return STEP12;
if ( !str_cmp( arg, "step13") ) return STEP13;
if ( !str_cmp( arg, "step14") ) return STEP14;
if ( !str_cmp( arg, "step15") ) return STEP15;
if ( !str_cmp( arg, "step16") ) return STEP16;
if ( !str_cmp( arg, "step17") ) return STEP17;
if ( !str_cmp( arg, "step18") ) return STEP18;
if ( !str_cmp( arg, "step19") ) return STEP19;
if ( !str_cmp( arg, "step20") ) return STEP20;
if ( !str_cmp( arg, "completed" ) ) return QUEST_COMPLETED;
return -1;
}
char * target_type_name( int target )
{
static char buf[512];
buf[0] = '\0';
if ( target & TAR_IGNORE ) strcat(buf, " ignore" );
if ( target & TAR_CHAR_SELF ) strcat(buf, " char_self" );
if ( target & TAR_CHAR_OTHER ) strcat(buf, " char_other" );
if ( target & TAR_OBJ_INV ) strcat(buf, " obj_inventory" );
if ( target & TAR_CHAR_OFFENSIVE ) strcat(buf, " char_offensive" );
if ( target & TAR_CHAR_DEFENSIVE ) strcat(buf, " char_defensive" );
if ( target & TAR_CHAR_CURATIVE ) strcat(buf, " char_curative" );
if ( target & TAR_CHAR_DAMAGING ) strcat(buf, " char_damaging" );
if ( target & TAR_CHAR_CANCEL ) strcat(buf, " char_cancel" );
if ( target & TAR_AREA ) strcat(buf, " area" );
if ( target & START_FIGHTING ) strcat(buf, " start_fighting" );
if ( target & SPELL_SILENT ) strcat(buf, " silent" );
if ( target & SKILL_STATIC ) strcat(buf, " static" );
return ( buf[0] != '\0' ) ? buf+1 : str_dup("none");
}
char * trig_type_name( int trig )
{
if ( trig == TRIG_COMMAND ) return "command";
if ( trig == TRIG_EACH_PULSE ) return "each_pulse";
if ( trig == TRIG_COMBAT ) return "combat";
if ( trig == TRIG_TICK_PULSE ) return "tick_pulse";
if ( trig == TRIG_BORN ) return "born";
if ( trig == TRIG_GETS ) return "gets";
if ( trig == TRIG_SAY ) return "say";
if ( trig == TRIG_TELL ) return "tell";
if ( trig == TRIG_KILLS_PLAYER ) return "kills_player";
if ( trig == TRIG_DIES ) return "dies";
if ( trig == TRIG_ENTER ) return "enter";
if ( trig == TRIG_MOVES ) return "moves";
if ( trig == TRIG_KILLS_MOB ) return "kills_mob";
if ( trig == TRIG_LEAVES ) return "leaves";
if ( trig == TRIG_LOOK ) return "look";
if ( trig == TRIG_WEAR ) return "wear";
if ( trig == TRIG_GIVE ) return "give";
if ( trig == TRIG_DROP ) return "drop";
if ( trig == TRIG_WIELD ) return "wield";
if ( trig == TRIG_TROOM ) return "troom";
if ( trig == TRIG_DOOR_OPEN ) return "door_open";
if ( trig == TRIG_GAINS ) return "gains";
return "none";
}
int get_trig_type( char * arg )
{
if ( !str_cmp( arg, "command" ) ) return TRIG_COMMAND;
if ( !str_cmp( arg, "each_pulse" ) ) return TRIG_EACH_PULSE;
if ( !str_cmp( arg, "each" ) ) return TRIG_EACH_PULSE;
if ( !str_cmp( arg, "combat" ) ) return TRIG_COMBAT;
if ( !str_cmp( arg, "tick_pulse" ) ) return TRIG_TICK_PULSE;
if ( !str_cmp( arg, "tick" ) ) return TRIG_TICK_PULSE;
if ( !str_cmp( arg, "born" ) ) return TRIG_BORN;
if ( !str_cmp( arg, "gets" ) ) return TRIG_GETS;
if ( !str_cmp( arg, "get" ) ) return TRIG_GETS;
if ( !str_cmp( arg, "say" ) ) return TRIG_SAY;
if ( !str_cmp( arg, "tell" ) ) return TRIG_TELL;
if ( !str_cmp( arg, "kills_player" ) ) return TRIG_KILLS_PLAYER;
if ( !str_cmp( arg, "pkills" ) ) return TRIG_KILLS_PLAYER;
if ( !str_cmp( arg, "pk" ) ) return TRIG_KILLS_PLAYER;
if ( !str_cmp( arg, "dies" ) ) return TRIG_DIES;
if ( !str_cmp( arg, "die" ) ) return TRIG_DIES;
if ( !str_cmp( arg, "death" ) ) return TRIG_DIES;
if ( !str_cmp( arg, "enter" ) ) return TRIG_ENTER;
if ( !str_cmp( arg, "moves" ) ) return TRIG_MOVES;
if ( !str_cmp( arg, "move" ) ) return TRIG_MOVES;
if ( !str_cmp( arg, "kills_mob" ) ) return TRIG_KILLS_MOB;
if ( !str_cmp( arg, "mkills" ) ) return TRIG_KILLS_MOB;
if ( !str_cmp( arg, "mk" ) ) return TRIG_KILLS_MOB;
if ( !str_cmp( arg, "leaves" ) ) return TRIG_LEAVES;
if ( !str_cmp( arg, "leave" ) ) return TRIG_LEAVES;
if ( !str_cmp( arg, "looks" ) ) return TRIG_LOOK;
if ( !str_cmp( arg, "look" ) ) return TRIG_LOOK;
if ( !str_cmp( arg, "wear" ) ) return TRIG_WEAR;
if ( !str_cmp( arg, "wield" ) ) return TRIG_WIELD;
if ( !str_cmp( arg, "give" ) ) return TRIG_GIVE;
if ( !str_cmp( arg, "gives" ) ) return TRIG_GIVE;
if ( !str_cmp( arg, "drop" ) ) return TRIG_DROP;
if ( !str_cmp( arg, "drops" ) ) return TRIG_DROP;
if ( !str_cmp( arg, "troom" ) ) return TRIG_TROOM;
if ( !str_cmp( arg, "door" ) ) return TRIG_DOOR_OPEN;
if ( !str_cmp( arg, "door_open" ) ) return TRIG_DOOR_OPEN;
if ( !str_cmp( arg, "gain" ) ) return TRIG_GAINS;
if ( !str_cmp( arg, "gains" ) ) return TRIG_GAINS;
return -1;
}
int get_material_type( char * arg )
{
if ( !str_cmp( arg, "steel" ) ) return MAT_STEEL;
if ( !str_cmp( arg, "mithril" ) ) return MAT_MITHRIL;
if ( !str_cmp( arg, "obsidian" ) ) return MAT_OBSIDIAN;
if ( !str_cmp( arg, "stainless" ) ) return MAT_STAINLESS_STEEL;
if ( !str_cmp( arg, "stainless_steel" ) ) return MAT_STAINLESS_STEEL;
if ( !str_cmp( arg, "stainlesssteel" ) ) return MAT_STAINLESS_STEEL;
if ( !str_cmp( arg, "silver" ) ) return MAT_SILVER;
if ( !str_cmp( arg, "ruby" ) ) return MAT_RUBY;
if ( !str_cmp( arg, "gold" ) ) return MAT_GOLD;
if ( !str_cmp( arg, "bronze" ) ) return MAT_BRONZE;
if ( !str_cmp( arg, "sapphire" ) ) return MAT_SAPPHIRE;
if ( !str_cmp( arg, "copper" ) ) return MAT_COPPER;
if ( !str_cmp( arg, "titanium" ) ) return MAT_TITANIUM;
if ( !str_cmp( arg, "emerald" ) ) return MAT_EMERALD;
if ( !str_cmp( arg, "adamantite" ) ) return MAT_ADAMANTITE;
if ( !str_cmp( arg, "alabaster" ) ) return MAT_ALABASTER;
if ( !str_cmp( arg, "diamond" ) ) return MAT_DIAMOND;
if ( !str_cmp( arg, "paper" ) ) return MAT_PAPER;
if ( !str_cmp( arg, "glass" ) ) return MAT_GLASS;
if ( !str_cmp( arg, "platinum" ) ) return MAT_PLATINUM;
if ( !str_cmp( arg, "gem" ) ) return MAT_GEM_STONE;
if ( !str_cmp( arg, "gem_stone" ) ) return MAT_GEM_STONE;
if ( !str_cmp( arg, "gemstone" ) ) return MAT_GEM_STONE;
if ( !str_cmp( arg, "wood" ) ) return MAT_WOOD;
if ( !str_cmp( arg, "leather" ) ) return MAT_LEATHER;
if ( !str_cmp( arg, "silk" ) ) return MAT_SILK;
if ( !str_cmp( arg, "iron" ) ) return MAT_IRON;
if ( !str_cmp( arg, "bone" ) ) return MAT_BONE;
if ( !str_cmp( arg, "clay" ) ) return MAT_CLAY;
if ( !str_cmp( arg, "rock" ) ) return MAT_ROCK;
if ( !str_cmp( arg, "coral" ) ) return MAT_CORAL;
if ( !str_cmp( arg, "stone" ) ) return MAT_STONE;
if ( !str_cmp( arg, "cloth" ) ) return MAT_CLOTH;
if ( !str_cmp( arg, "canvas" ) ) return MAT_CANVAS;
if ( !str_cmp( arg, "fish" ) ) return MAT_FISH_SKIN;
if ( !str_cmp( arg, "fish_skin" ) ) return MAT_FISH_SKIN;
if ( !str_cmp( arg, "fishskin" ) ) return MAT_FISH_SKIN;
if ( !str_cmp( arg, "pearl" ) ) return MAT_PEARL;
return 0;
}
char * material_type_name( int arg )
{
if ( arg == MAT_STEEL ) return "steel";
if ( arg == MAT_MITHRIL ) return "mithril";
if ( arg == MAT_OBSIDIAN ) return "obsidian";
if ( arg == MAT_STAINLESS_STEEL ) return "stainless_steel";
if ( arg == MAT_SILVER ) return "silver";
if ( arg == MAT_RUBY ) return "ruby";
if ( arg == MAT_GOLD ) return "gold";
if ( arg == MAT_BRONZE ) return "brone";
if ( arg == MAT_EMERALD ) return "emerald";
if ( arg == MAT_COPPER ) return "copper";
if ( arg == MAT_TITANIUM ) return "titanium";
if ( arg == MAT_SAPPHIRE ) return "sapphire";
if ( arg == MAT_ADAMANTITE ) return "adamantite";
if ( arg == MAT_ALABASTER ) return "alabaster";
if ( arg == MAT_DIAMOND ) return "diamond";
if ( arg == MAT_PAPER ) return "paper";
if ( arg == MAT_GLASS ) return "glass";
if ( arg == MAT_PLATINUM ) return "platinum";
if ( arg == MAT_GEM_STONE ) return "gem_stone";
if ( arg == MAT_WOOD ) return "wood";
if ( arg == MAT_LEATHER ) return "leather";
if ( arg == MAT_SILK ) return "silk";
if ( arg == MAT_IRON ) return "iron";
if ( arg == MAT_BONE ) return "bone";
if ( arg == MAT_CLAY ) return "clay";
if ( arg == MAT_ROCK ) return "rock";
if ( arg == MAT_CORAL ) return "coral";
if ( arg == MAT_STONE ) return "stone";
if ( arg == MAT_CLOTH ) return "cloth";
if ( arg == MAT_CANVAS ) return "canvas";
if ( arg == MAT_FISH_SKIN ) return "fish_skin";
if ( arg == MAT_PEARL ) return "pearl";
return "none";
}
char * note_flag_name( int arg )
{
static char buf[MAX_INPUT_LENGTH];
buf[0] = '\0';
if ( IS_SET( arg, NOTE_NO_DELETE ) ) strcat( buf, " no_delete" );
if ( IS_SET( arg, NOTE_RECIEPT ) ) strcat( buf, " reciept" );
return ( buf[0] == '\0' ? str_dup("none") : &buf[1] );
}
int get_note_flag ( char * arg )
{
if ( !str_cmp( arg, "no_delete" ) ) return NOTE_NO_DELETE;
if ( !str_cmp( arg, "nodelete" ) ) return NOTE_NO_DELETE;
if ( !str_cmp( arg, "receipt" ) ) return NOTE_RECIEPT;
return 0;
}
int position_value( char * arg )
{
if ( !str_prefix( arg, "mortally" ) ) return POS_MORTAL;
if ( !str_prefix( arg, "wounded" ) ) return POS_MORTAL;
if ( !str_prefix( arg, "incapacitated" ) ) return POS_INCAP;
if ( !str_prefix( arg, "stunned" ) ) return POS_STUNNED;
if ( !str_prefix( arg, "sleeping" ) ) return POS_SLEEPING;
if ( !str_prefix( arg, "resting" ) ) return POS_RESTING;
if ( !str_prefix( arg, "sitting" ) ) return POS_SITTING;
if ( !str_prefix( arg, "fighting" ) ) return POS_FIGHTING;
if ( !str_prefix( arg, "standing" ) ) return POS_STANDING;
return -1;
}
char *get_pos_name( int pos )
{
if ( pos == POS_MORTAL ) return "Mortally wounded";
if ( pos == POS_INCAP ) return "Incapacitated";
if ( pos == POS_STUNNED ) return "Stunned";
if ( pos == POS_SLEEPING ) return "Sleeping";
if ( pos == POS_RESTING ) return "Resting";
if ( pos == POS_SITTING ) return "Sitting";
if ( pos == POS_FIGHTING ) return "Fighting";
if ( pos == POS_STANDING ) return "Standing";
return "Dead";
}
char *shop_type_name( int arg )
{
static char buf[MAX_INPUT_LENGTH];
buf[0]='\0';
if ( IS_SET( arg, SHOP_BAKER ) ) strcat( buf, " baker" );
if ( IS_SET( arg, SHOP_MAGIC ) ) strcat( buf, " magic" );
if ( IS_SET( arg, SHOP_BAR ) ) strcat( buf, " bar" );
if ( IS_SET( arg, SHOP_ARMOUR ) ) strcat( buf, " armor" );
if ( IS_SET( arg, SHOP_WEAPON ) ) strcat( buf, " weapon" );
if ( IS_SET( arg, SHOP_JEWELLER ) ) strcat( buf, " jeweller" );
if ( IS_SET( arg, SHOP_GROCER ) ) strcat( buf, " grocer" );
if ( IS_SET( arg, SHOP_BOAT ) ) strcat( buf, " boat" );
if ( IS_SET( arg, SHOP_FURNITURE ) ) strcat( buf, " furniture" );
if ( IS_SET( arg, SHOP_BARDING ) ) strcat( buf, " barding" );
/* if ( IS_SET( arg, SHOP_OWNABLE ) ) strcat( buf, " ownable" ); */
return ( buf[0] == ' ' ? &buf[1] : str_dup("none") );
}
int shop_name_type(char *arg)
{
if ( !str_cmp( arg, "baker" ) ) return SHOP_BAKER;
if ( !str_cmp( arg, "magic" ) ) return SHOP_MAGIC;
if ( !str_cmp( arg, "magician" ) ) return SHOP_MAGIC;
if ( !str_cmp( arg, "bar" ) ) return SHOP_BAR;
if ( !str_cmp( arg, "bartender" ) ) return SHOP_BAR;
if ( !str_cmp( arg, "armour" ) ) return SHOP_ARMOUR;
if ( !str_cmp( arg, "armourer" ) ) return SHOP_ARMOUR;
if ( !str_cmp( arg, "armor" ) ) return SHOP_ARMOUR;
if ( !str_cmp( arg, "armorer" ) ) return SHOP_ARMOUR;
if ( !str_cmp( arg, "weapon" ) ) return SHOP_WEAPON;
if ( !str_cmp( arg, "weaponsmith" ) ) return SHOP_WEAPON;
if ( !str_cmp( arg, "jeweller" ) ) return SHOP_JEWELLER;
if ( !str_cmp( arg, "grocer" ) ) return SHOP_GROCER;
if ( !str_cmp( arg, "furniture" ) ) return SHOP_FURNITURE;
if ( !str_cmp( arg, "boat" ) ) return SHOP_BOAT;
if ( !str_cmp( arg, "barding" ) ) return SHOP_BARDING;
/* if ( !str_cmp( arg, "ownable" ) ) return SHOP_OWNABLE; */
return 0;
}
int item_name_type(char *name)
{
/* done */
if ( !str_cmp( name, "scroll" ) ) return ITEM_SCROLL;
if ( !str_cmp( name, "wand" ) ) return ITEM_WAND;
if ( !str_cmp( name, "staff" ) ) return ITEM_STAFF;
if ( !str_cmp( name, "weapon" ) ) return ITEM_WEAPON;
if ( !str_cmp( name, "armor" ) ) return ITEM_ARMOR;
if ( !str_cmp( name, "potion" ) ) return ITEM_POTION;
if ( !str_cmp( name, "drink" ) ) return ITEM_DRINK_CON;
if ( !str_cmp( name, "fountain" ) ) return ITEM_FOUNTAIN;
if ( !str_cmp( name, "food" ) ) return ITEM_FOOD;
if ( !str_cmp( name, "gate" ) ) return ITEM_GATE;
if ( !str_cmp( name, "key" ) ) return ITEM_KEY;
if ( !str_cmp( name, "map" ) ) return ITEM_MAP;
if ( !str_cmp( name, "money" ) ) return ITEM_MONEY;
if ( !str_cmp( name, "clothing" ) ) return ITEM_CLOTHING;
if ( !str_cmp( name, "furniture" ) ) return ITEM_FURNITURE;
if ( !str_cmp( name, "trash" ) ) return ITEM_TRASH;
if ( !str_cmp( name, "treasure" ) ) return ITEM_TREASURE;
if ( !str_cmp( name, "protect" ) ) return ITEM_PROTECT;
if ( !str_cmp( name, "pc" ) ) return ITEM_PC;
if ( !str_cmp( name, "no_food" ) ) return ITEM_NO_FOOD_REQ;
if ( !str_cmp( name, "no_water" ) ) return ITEM_NO_WATER_REQ;
if ( !str_cmp( name, "no_food_water") ) return ITEM_NO_FOOD_OR_WATER;
if ( !str_cmp( name, "poisoned" ) ) return ITEM_POISONED;
if ( !str_cmp( name, "container" ) ) return ITEM_CONTAINER;
if ( !str_cmp( name, "corpse_npc" ) ) return ITEM_CORPSE_NPC;
if ( !str_cmp( name, "corpse_pc" ) ) return ITEM_CORPSE_PC;
if ( !str_cmp( name, "boat" ) ) return ITEM_BOAT;
if ( !str_cmp( name, "barding" ) ) return ITEM_TYPE_BARDING;
if ( !str_cmp( name, "light" ) ) return ITEM_LIGHT;
if ( !str_cmp( name, "fuel" ) ) return ITEM_FUEL;
if ( !str_cmp( name, "lighter" ) ) return ITEM_LIGHTER;
return 0;
}
int special_name_bit( char* buf )
{
if (!str_cmp( buf, "stringshare" ) ) return ITEM_SPEC_STRING ;
return 0;
}
int extra_name_bit( char* buf )
{
if (!str_cmp( buf, "glow" ) ) return ITEM_GLOW ;
if (!str_cmp( buf, "hum" ) ) return ITEM_HUM ;
if (!str_cmp( buf, "no_show" ) ) return ITEM_NO_SHOW ;
if (!str_cmp( buf, "buckler" ) ) return ITEM_BUCKLER ;
if (!str_cmp( buf, "hammer" ) ) return ITEM_HAMMER ;
if (!str_cmp( buf, "shadowform" ) ) return ITEM_SHADOWFORM ;
if (!str_cmp( buf, "magic" ) ) return ITEM_MAGIC ;
if (!str_cmp( buf, "nodrop" ) ) return ITEM_NODROP ;
if (!str_cmp( buf, "anti_nenkemen" ) ) return ITEM_ANTI_NENKEMEN;
if (!str_cmp( buf, "anti_maegmenel" ) ) return ITEM_ANTI_MAEGMENEL;
if (!str_cmp( buf, "anti_lithdor" ) ) return ITEM_ANTI_LITHDOR;
if (!str_cmp( buf, "noremove" ) ) return ITEM_NOREMOVE ;
if (!str_cmp( buf, "stay_on_death" ) ) return ITEM_STAY_ON_DEATH ;
if (!str_cmp( buf, "inventory" ) ) return ITEM_INVENTORY ;
if (!str_cmp( buf, "poisoned" ) ) return ITEM_POISONED ;
if (!str_cmp( buf, "nopurge" ) ) return ITEM_NOPURGE ;
if (!str_cmp( buf, "rot_death" ) ) return ITEM_ROT_DEATH ;
if (!str_cmp( buf, "vis_death" ) ) return ITEM_VIS_DEATH ;
if (!str_cmp( buf, "lit" ) ) return ITEM_LIT ;
if (!str_cmp( buf, "magic_lit" ) ) return ITEM_MAGIC_LIT ;
if (!str_cmp( buf, "no_save" ) ) return ITEM_NO_SAVE ;
if (!str_cmp( buf, "no_locate" ) ) return ITEM_NO_LOCATE ;
if (!str_cmp( buf, "assayed" ) ) return ITEM_ASSAYED;
if (!str_cmp( buf, "buried" ) ) return ITEM_BURIED;
if (!str_cmp( buf, "no_identify" ) ) return ITEM_NO_IDENTIFY ;
if (!str_cmp( buf, "float" ) ) return ITEM_FLOAT;
if (!str_cmp( buf, "barding" ) ) return ITEM_BARDING;
if (!str_cmp( buf, "mob_inside" ) ) return ITEM_MOB_INSIDE;
if (!str_cmp( buf, "home" ) ) return ITEM_HOME;
if (!str_cmp( buf, "newbie" ) ) return ITEM_NEWBIE;
if (!str_cmp( buf, "pick" ) ) return ITEM_PICK;
return 0;
}
char *gate_flag_name( int flag )
{
static char buf[512];
buf[0] ='\0';
if ( IS_SET( flag, GATE_STAY_ROOM ) ) strcat( buf, " stay_room" );
if ( IS_SET( flag, GATE_STAY_AREA ) ) strcat( buf, " stay_area" );
if ( IS_SET( flag, GATE_STAY_WORLD ) ) strcat( buf, " stay_world" );
if ( IS_SET( flag, GATE_TO_STAY_ROOM ) ) strcat( buf, " to_stay_room" );
if ( IS_SET( flag, GATE_TO_STAY_AREA ) ) strcat( buf, " to_stay_area" );
if ( IS_SET( flag, GATE_TO_STAY_WORLD ) ) strcat( buf, " to_stay_world" );
if ( IS_SET( flag, GATE_OPAQUE ) ) strcat( buf, " opaque" );
if ( IS_SET( flag, GATE_UNSTABLE ) ) strcat( buf, " unstable" );
if ( IS_SET( flag, GATE_TO_OBJ ) ) strcat( buf, " to_obj" );
if ( IS_SET( flag, GATE_TO_MOB ) ) strcat( buf, " to_mob" );
return ( buf[0] != '\0' ) ? buf+1 : str_dup("none");
}
char *light_flag_name( int flag )
{
static char buf[512];
buf[0] ='\0';
if ( IS_SET( flag, LIGHT_MAGIC_LIT ) ) strcat( buf, " magic_lit" );
if ( IS_SET( flag, LIGHT_LIT ) ) strcat( buf, " lit" );
if ( IS_SET( flag, LIGHT_BURNING ) ) strcat( buf, " burning" );
if ( IS_SET( flag, LIGHT_LIGHTABLE ) ) strcat( buf, " lightable" );
if ( IS_SET( flag, LIGHT_REFUELABLE ) ) strcat( buf, " refuelable" );
if ( IS_SET( flag, LIGHT_FUEL ) ) strcat( buf, " fuel" );
return ( buf[0] != '\0' ) ? buf+1 : str_dup("none");
}
int get_light_flag( char * arg )
{
if ( !str_cmp( arg, "magic_lit" ) ) return LIGHT_MAGIC_LIT;
if ( !str_cmp( arg, "lit" ) ) return LIGHT_LIT;
if ( !str_cmp( arg, "burning" ) ) return LIGHT_BURNING;
if ( !str_cmp( arg, "lightable" ) ) return LIGHT_LIGHTABLE;
if ( !str_cmp( arg, "refuelable" ) ) return LIGHT_REFUELABLE;
if ( !str_cmp( arg, "fuel" ) ) return LIGHT_FUEL;
return 0;
}
int get_gate_flag( char * arg )
{
if ( !str_cmp( arg, "stay_room" ) ) return GATE_STAY_ROOM;
if ( !str_cmp( arg, "stay_area" ) ) return GATE_STAY_AREA;
if ( !str_cmp( arg, "stay_world" ) ) return GATE_STAY_WORLD;
if ( !str_cmp( arg, "to_stay_room" ) ) return GATE_TO_STAY_ROOM;
if ( !str_cmp( arg, "to_stay_area" ) ) return GATE_TO_STAY_AREA;
if ( !str_cmp( arg, "to_stay_world" ) ) return GATE_TO_STAY_WORLD;
if ( !str_cmp( arg, "unstable" ) ) return GATE_UNSTABLE;
if ( !str_cmp( arg, "opaque" ) ) return GATE_OPAQUE;
if ( !str_cmp( arg, "to_mob" ) ) return GATE_TO_MOB;
if ( !str_cmp( arg, "to_obj" ) ) return GATE_TO_OBJ;
return 0;
}
char *edible_flag_list_name( int flag )
{
static char buf[512];
buf[0] ='\0';
if ( IS_SET( flag, FOOD_POISONED ) ) strcat( buf, " poisoned" );
if ( IS_SET( flag, FOOD_UNCOOKED ) ) strcat( buf, " uncooked" );
if ( IS_SET( flag, FOOD_EDIBLE ) ) strcat( buf, " food" );
if ( IS_SET( flag, FOOD_DRINK ) ) strcat( buf, " drink" );
return ( buf[0] != '\0' ) ? buf+1 : str_dup("none");
}
char *edible_flag_name( int flag )
{
static char buf[512];
buf[0] ='\0';
if ( IS_SET( flag, FOOD_POISONED ) ) strcat( buf, " poisoned" );
if ( IS_SET( flag, FOOD_UNCOOKED ) ) strcat( buf, " uncooked" );
if ( IS_SET( flag, FOOD_EDIBLE ) ) strcat( buf, " food" );
else strcat( buf, " drink" );
return ( buf[0] != '\0' ) ? buf+1 : str_dup("none");
}
int get_edible_type( char * arg )
{
int type;
for ( type = 0 ; type < LIQ_MAX ; type++ )
if ( is_name( arg, liq_table[ type ].liq_name ) )
return type;
return -1;
}
int get_edible_flag( char * arg )
{
if ( !str_cmp( arg, "poisoned" ) ) return FOOD_POISONED;
if ( !str_cmp( arg, "food" ) ) return FOOD_EDIBLE;
if ( !str_cmp( arg, "drink" ) ) return FOOD_DRINK;
if ( !str_cmp( arg, "uncooked" ) ) return FOOD_UNCOOKED;
return 0;
}
char *magical_flag_name( int arg )
{
static char buf[512];
buf[0] ='\0';
if ( IS_SET( arg, ROT_USED ) ) strcat( buf, " rot_used" );
return ( buf[0] != '\0' ) ? buf+1 : str_dup("none");
}
char *magical_type_name( int arg )
{
if ( arg == MAGIC_WAND ) return "Wand ";
if ( arg == MAGIC_STAFF ) return "Staff ";
if ( arg == MAGIC_SCROLL ) return "Scroll ";
return "(unset magical type)";
}
int get_magical_flag( char *arg )
{
if ( !str_cmp( arg, "rot_used" ) ) return ROT_USED;
return 0;
}
int get_magical_type( char *arg )
{
if (!str_cmp( arg, "staff" ) ) return MAGIC_STAFF;
if (!str_cmp( arg, "wand" ) ) return MAGIC_WAND;
if (!str_cmp( arg, "scroll" ) ) return MAGIC_SCROLL;
return 0;
}
int get_storm_type( char *arg )
{
if (!str_prefix( arg, "lightning" ) ) return SKY_LIGHTNING;
if (!str_prefix( arg, "blizzard" ) ) return SKY_BLIZZARD;
if (!str_prefix( arg, "huricane" ) ) return SKY_HURICANE;
if (!str_prefix( arg, "tornado" ) ) return SKY_TORNADO;
if (!str_prefix( arg, "sandstorm" ) ) return SKY_SANDSTORM;
return -1;
}
/*
* Returns the name of a wear bit.
*/
char *wear_bit_name_1( int wear )
{
static char buf[512];
buf[0] = '\0';
if ( wear & ITEM_TAKE ) strcat( buf, " take" );
if ( wear & ITEM_WEAR_FINGER ) strcat( buf, " finger" );
if ( wear & ITEM_WEAR_EAR ) strcat( buf, " ear" );
if ( wear & ITEM_WEAR_NECK ) strcat( buf, " neck" );
if ( wear & ITEM_WEAR_BODY ) strcat( buf, " body" );
if ( wear & ITEM_WEAR_HEAD ) strcat( buf, " head" );
if ( wear & ITEM_WEAR_LEGS ) strcat( buf, " legs" );
if ( wear & ITEM_WEAR_FEET ) strcat( buf, " feet" );
if ( wear & ITEM_WEAR_HANDS ) strcat( buf, " hands" );
if ( wear & ITEM_WEAR_ARMS ) strcat( buf, " arms" );
if ( wear & ITEM_WEAR_SHIELD ) strcat( buf, " shield" );
if ( wear & ITEM_WEAR_ABOUT ) strcat( buf, " about" );
if ( wear & ITEM_WEAR_WAIST ) strcat( buf, " waist" );
if ( wear & ITEM_WEAR_WRIST ) strcat( buf, " wrist" );
if ( wear & ITEM_WIELD ) strcat( buf, " wield" );
if ( wear & ITEM_HOLD ) strcat( buf, " hold" );
if ( wear & ITEM_TWO_HANDS ) strcat( buf, " two_hands" );
if ( wear & ITEM_MONEY_0 ) strcat( buf, " crowns" );
if ( wear & ITEM_MONEY_1 ) strcat( buf, " duckets" );
if ( wear & ITEM_MONEY_2 ) strcat( buf, " wheels" );
if ( wear & ITEM_MONEY_3 ) strcat( buf, " greckles" );
if ( wear & ITEM_WEAR_LIGHT ) strcat( buf, " light" );
return ( buf[0] != '\0' ) ? buf+1 : str_dup("none");
}
char *get_event_flags( int event )
{
static char buf[512];
buf[0] = '\0';
if ( event & EVENT_ON_BOOT ) strcat( buf, " on_boot" );
if ( event & EVENT_ON_RESET ) strcat( buf, " on_reset" );
if ( event & EVENT_INVALID ) strcat( buf, " invalid" );
return ( buf[0] != '\0' ) ? buf+1 : str_dup("none");
}
int get_flags_event( char *arg )
{
if (!str_cmp( arg, "boot" ) ) return EVENT_ON_BOOT;
if (!str_cmp( arg, "on_boot" ) ) return EVENT_ON_BOOT;
if (!str_cmp( arg, "reset" ) ) return EVENT_ON_RESET;
if (!str_cmp( arg, "on_reset" ) ) return EVENT_ON_RESET;
if (!str_cmp( arg, "invalid" ) ) return EVENT_INVALID;
return 0;
}
char *get_equip_flags( int equip )
{
static char buf[512];
buf[0] = '\0';
if ( equip & EQUIP_ON_BOOT ) strcat( buf, " on_boot" );
if ( equip & EQUIP_ON_RESET ) strcat( buf, " on_reset" );
if ( equip & EQUIP_INVALID ) strcat( buf, " invalid" );
if ( equip & EQUIP_INVENTORY ) strcat( buf, " inventory" );
if ( equip & EQUIP_REPLACE ) strcat( buf, " replace" );
if ( equip & EQUIP_ON_CREATION ) strcat( buf, " creation" );
return ( buf[0] != '\0' ) ? buf+1 : str_dup("none");
}
int get_flags_equip( char *arg )
{
if (!str_cmp( arg, "boot" ) ) return EQUIP_ON_BOOT;
if (!str_cmp( arg, "on_boot" ) ) return EQUIP_ON_BOOT;
if (!str_cmp( arg, "reset" ) ) return EQUIP_ON_RESET;
if (!str_cmp( arg, "on_reset" ) ) return EQUIP_ON_RESET;
if (!str_cmp( arg, "invalid" ) ) return EQUIP_INVALID;
if (!str_cmp( arg, "inventory" ) ) return EQUIP_INVENTORY;
if (!str_cmp( arg, "inv" ) ) return EQUIP_INVENTORY;
if (!str_cmp( arg, "creation" ) ) return EQUIP_ON_CREATION;
if (!str_cmp( arg, "replace" ) ) return EQUIP_REPLACE;
return 0;
}
char *clan_flag_name( int clan_info )
{
static char buf[512];
buf[0] = '\0';
if ( clan_info & CLAN_UNLISTED ) strcat( buf, " unlisted" );
return ( buf[0] != '\0' ) ? buf+1 : str_dup("none");
}
int wear_location_flag( int wear )
{
switch( wear )
{
default: return 0;
case WEAR_NONE: return 0;
case WEAR_LIGHT: return ITEM_WEAR_LIGHT;
case WEAR_FINGER_L: return ITEM_WEAR_FINGER;
case WEAR_FINGER_R: return ITEM_WEAR_FINGER;
case WEAR_EAR_L: return ITEM_WEAR_EAR;
case WEAR_EAR_R: return ITEM_WEAR_EAR;
case WEAR_NECK_1: return ITEM_WEAR_NECK;
case WEAR_NECK_2: return ITEM_WEAR_NECK;
case WEAR_BODY: return ITEM_WEAR_BODY;
case WEAR_HEAD: return ITEM_WEAR_HEAD;
case WEAR_LEGS: return ITEM_WEAR_LEGS;
case WEAR_FEET: return ITEM_WEAR_FEET;
case WEAR_HANDS: return ITEM_WEAR_HANDS;
case WEAR_ARMS: return ITEM_WEAR_ARMS;
case WEAR_SHIELD: return ITEM_WEAR_SHIELD;
case WEAR_ABOUT: return ITEM_WEAR_ABOUT;
case WEAR_WAIST: return ITEM_WEAR_WAIST;
case WEAR_WRIST_L: return ITEM_WEAR_WRIST;
case WEAR_WRIST_R: return ITEM_WEAR_WRIST;
case WEAR_WIELD_R: return ITEM_WIELD;
case WEAR_WIELD_L: return ITEM_WIELD;
case WEAR_HOLD: return ITEM_HOLD;
case WEAR_WIELD_TWO_HANDED: return ITEM_TWO_HANDS;
}
}
/*
* Returns the location of a wear bit.
*/
int wear_bit_location( int wear )
{
if ( wear & ITEM_WEAR_FINGER ) return WEAR_FINGER_L;
if ( wear & ITEM_WEAR_EAR ) return WEAR_EAR_L;
if ( wear & ITEM_WEAR_NECK ) return WEAR_NECK_1;
if ( wear & ITEM_WEAR_BODY ) return WEAR_BODY;
if ( wear & ITEM_WEAR_HEAD ) return WEAR_HEAD;
if ( wear & ITEM_WEAR_LEGS ) return WEAR_LEGS;
if ( wear & ITEM_WEAR_FEET ) return WEAR_FEET;
if ( wear & ITEM_WEAR_HANDS ) return WEAR_HANDS;
if ( wear & ITEM_WEAR_ARMS ) return WEAR_ARMS;
if ( wear & ITEM_WEAR_SHIELD ) return WEAR_SHIELD;
if ( wear & ITEM_WEAR_ABOUT ) return WEAR_ABOUT;
if ( wear & ITEM_WEAR_WAIST ) return WEAR_WAIST;
if ( wear & ITEM_WEAR_WRIST ) return WEAR_WRIST_L;
if ( wear & ITEM_WIELD ) return WEAR_WIELD;
if ( wear & ITEM_HOLD ) return WEAR_HOLD;
if ( wear & ITEM_TWO_HANDS ) return WEAR_WIELD_TWO_HANDED;
return WEAR_NONE;
}
int wear_bit_location_2( int wear )
{
if ( wear & ITEM_WEAR_FINGER ) return WEAR_FINGER_R;
if ( wear & ITEM_WEAR_FINGER ) return WEAR_FINGER_R;
if ( wear & ITEM_WEAR_EAR ) return WEAR_EAR_R;
if ( wear & ITEM_WEAR_EAR ) return WEAR_EAR_R;
if ( wear & ITEM_WEAR_NECK ) return WEAR_NECK_2;
if ( wear & ITEM_WEAR_BODY ) return WEAR_BODY;
if ( wear & ITEM_WEAR_HEAD ) return WEAR_HEAD;
if ( wear & ITEM_WEAR_LEGS ) return WEAR_LEGS;
if ( wear & ITEM_WEAR_FEET ) return WEAR_FEET;
if ( wear & ITEM_WEAR_HANDS ) return WEAR_HANDS;
if ( wear & ITEM_WEAR_ARMS ) return WEAR_ARMS;
if ( wear & ITEM_WEAR_SHIELD ) return WEAR_SHIELD;
if ( wear & ITEM_WEAR_ABOUT ) return WEAR_ABOUT;
if ( wear & ITEM_WEAR_WAIST ) return WEAR_WAIST;
if ( wear & ITEM_WEAR_WRIST ) return WEAR_WRIST_R;
if ( wear & ITEM_WIELD ) return WEAR_WIELD;
if ( wear & ITEM_HOLD ) return WEAR_HOLD;
if ( wear & ITEM_TWO_HANDS ) return WEAR_WIELD_TWO_HANDED;
return WEAR_NONE;
}
/*
* Returns the bit, given a certain name.
*/
int wear_name_bit( char* buf )
{
if (!str_cmp( buf, "take" ) ) return ITEM_TAKE;
if (!str_cmp( buf, "finger" ) ) return ITEM_WEAR_FINGER;
if (!str_cmp( buf, "ear" ) ) return ITEM_WEAR_EAR;
if (!str_cmp( buf, "neck" ) ) return ITEM_WEAR_NECK;
if (!str_cmp( buf, "body" ) ) return ITEM_WEAR_BODY;
if (!str_cmp( buf, "head" ) ) return ITEM_WEAR_HEAD;
if (!str_cmp( buf, "legs" ) ) return ITEM_WEAR_LEGS;
if (!str_cmp( buf, "feet" ) ) return ITEM_WEAR_FEET;
if (!str_cmp( buf, "hands" ) ) return ITEM_WEAR_HANDS;
if (!str_cmp( buf, "arms" ) ) return ITEM_WEAR_ARMS;
if (!str_cmp( buf, "shield" ) ) return ITEM_WEAR_SHIELD;
if (!str_cmp( buf, "about" ) ) return ITEM_WEAR_ABOUT;
if (!str_cmp( buf, "waist" ) ) return ITEM_WEAR_WAIST;
if (!str_cmp( buf, "wrist" ) ) return ITEM_WEAR_WRIST;
if (!str_cmp( buf, "wield" ) ) return ITEM_WIELD;
if (!str_cmp( buf, "hold" ) ) return ITEM_HOLD;
if (!str_cmp( buf, "two_hands" ) ) return ITEM_TWO_HANDS;
if (!str_cmp( buf, "crowns" ) ) return ITEM_MONEY_0;
if (!str_cmp( buf, "duckets" ) ) return ITEM_MONEY_1;
if (!str_cmp( buf, "wheels" ) ) return ITEM_MONEY_2;
if (!str_cmp( buf, "greckles" ) ) return ITEM_MONEY_3;
if (!str_cmp( buf, "crown" ) ) return ITEM_MONEY_0;
if (!str_cmp( buf, "ducket" ) ) return ITEM_MONEY_1;
if (!str_cmp( buf, "wheel" ) ) return ITEM_MONEY_2;
if (!str_cmp( buf, "greckle" ) ) return ITEM_MONEY_3;
if (!str_cmp( buf, "light" ) ) return ITEM_WEAR_LIGHT;
return 0;
}
int res_name_bit( char* buf )
{
if ( !str_cmp( buf, "control_mind" ) ) return RES_CONTROL_MIND;
if ( !str_cmp( buf, "magic" ) ) return RES_MAGIC;
if ( !str_cmp( buf, "weapon" ) ) return RES_WEAPON;
if ( !str_cmp( buf, "blunt" ) ) return RES_BASH;
if ( !str_cmp( buf, "pierce" ) ) return RES_PIERCE;
if ( !str_cmp( buf, "slash" ) ) return RES_SLASH;
if ( !str_cmp( buf, "fire" ) ) return RES_FIRE;
if ( !str_cmp( buf, "lightning" ) ) return RES_LIGHTNING;
if ( !str_cmp( buf, "acid" ) ) return RES_ACID;
if ( !str_cmp( buf, "poison" ) ) return RES_POISON;
if ( !str_cmp( buf, "energy" ) ) return RES_ENERGY;
if ( !str_cmp( buf, "mental" ) ) return RES_MENTAL;
if ( !str_cmp( buf, "disease" ) ) return RES_DISEASE;
if ( !str_cmp( buf, "drowning" ) ) return RES_DROWNING;
if ( !str_cmp( buf, "light" ) ) return RES_LIGHT;
if ( !str_cmp( buf, "wind" ) ) return RES_WIND;
if ( !str_cmp( buf, "water" ) ) return RES_WATER;
if ( !str_cmp( buf, "spirit" ) ) return RES_SPIRIT;
if ( !str_cmp( buf, "earth" ) ) return RES_EARTH;
return 0;
}
int vuln_name_bit( char* buf )
{
if ( !str_cmp( buf, "magic" ) ) return VULN_MAGIC;
if ( !str_cmp( buf, "weapon" ) ) return VULN_WEAPON;
if ( !str_cmp( buf, "blunt" ) ) return VULN_BASH;
if ( !str_cmp( buf, "pierce" ) ) return VULN_PIERCE;
if ( !str_cmp( buf, "slash" ) ) return VULN_SLASH;
if ( !str_cmp( buf, "fire" ) ) return VULN_FIRE;
if ( !str_cmp( buf, "lightning" ) ) return VULN_LIGHTNING;
if ( !str_cmp( buf, "acid" ) ) return VULN_ACID;
if ( !str_cmp( buf, "poison" ) ) return VULN_POISON;
if ( !str_cmp( buf, "energy" ) ) return VULN_ENERGY;
if ( !str_cmp( buf, "mental" ) ) return VULN_MENTAL;
if ( !str_cmp( buf, "disease" ) ) return VULN_DISEASE;
if ( !str_cmp( buf, "drowning" ) ) return VULN_DROWNING;
if ( !str_cmp( buf, "light" ) ) return VULN_LIGHT;
if ( !str_cmp( buf, "wind" ) ) return VULN_WIND;
if ( !str_cmp( buf, "water" ) ) return VULN_WATER;
if ( !str_cmp( buf, "spirit" ) ) return VULN_SPIRIT;
if ( !str_cmp( buf, "earth" ) ) return VULN_EARTH;
return 0;
}
int imm_name_bit( char* buf )
{
if ( !str_cmp( buf, "summon" ) ) return IMM_SUMMON;
if ( !str_cmp( buf, "control_mind" ) ) return IMM_CONTROL_MIND;
if ( !str_cmp( buf, "magic" ) ) return IMM_MAGIC;
if ( !str_cmp( buf, "weapon" ) ) return IMM_WEAPON;
if ( !str_cmp( buf, "blunt" ) ) return IMM_BASH;
if ( !str_cmp( buf, "pierce" ) ) return IMM_PIERCE;
if ( !str_cmp( buf, "slash" ) ) return IMM_SLASH;
if ( !str_cmp( buf, "fire" ) ) return IMM_FIRE;
if ( !str_cmp( buf, "lightning" ) ) return IMM_LIGHTNING;
if ( !str_cmp( buf, "acid" ) ) return IMM_ACID;
if ( !str_cmp( buf, "poison" ) ) return IMM_POISON;
if ( !str_cmp( buf, "energy" ) ) return IMM_ENERGY;
if ( !str_cmp( buf, "mental" ) ) return IMM_MENTAL;
if ( !str_cmp( buf, "disease" ) ) return IMM_DISEASE;
if ( !str_cmp( buf, "drowning" ) ) return IMM_DROWNING;
if ( !str_cmp( buf, "light" ) ) return IMM_LIGHT;
if ( !str_cmp( buf, "wind" ) ) return IMM_WIND;
if ( !str_cmp( buf, "water" ) ) return IMM_WATER;
if ( !str_cmp( buf, "spirit" ) ) return IMM_SPIRIT;
if ( !str_cmp( buf, "earth" ) ) return IMM_EARTH;
return 0;
}
int guild_name_bit( char* buf )
{
int guild;
for ( guild = 0 ; guild < MAX_GUILD ; guild++ )
if ( !str_cmp( buf, guild_table[ guild ].name ) ) return guild_table[ guild ].flag;
return 0;
}
char *guild_bit_name( int guild_flags )
{
static char buf[512];
int guild;
buf[0] = '\0';
for ( guild = 0 ; guild < MAX_GUILD ; guild++ )
if (guild_flags & guild_table[ guild ].flag )
{
strcat( buf, " " );
strcat(buf, guild_table[ guild ].name );
}
return ( buf[0] != '\0' ) ? buf+1 : str_dup("none");
}
char *guild_bit_name_2(int guild_flags)
{
static char buf[512];
int guild;
buf[0] = '\0';
for ( guild = 0 ; guild < MAX_GUILD ; guild++ )
if (guild_flags & guild_table[ guild ].flag )
{
strcat( buf, " " );
strcat(buf, guild_table[ guild ].title );
}
return ( buf[0] != '\0' ) ? buf+1 : str_dup("none");
}
/*
* Return bit vector
*/
long affect_name_bit( char* buf )
{
if (!str_cmp( buf, "blind" )) return AFF_BLIND;
if (!str_cmp( buf, "shadowform" )) return AFF_SHADOWFORM;
if (!str_cmp( buf, "detect_world" )) return AFF_DETECT_WORLD;
if (!str_cmp( buf, "detect_shadowform" )) return AFF_DETECT_SHADOWFORM;
if (!str_cmp( buf, "detect_magic" )) return AFF_DETECT_MAGIC;
if (!str_cmp( buf, "detect_hidden" )) return AFF_DETECT_HIDDEN;
if (!str_cmp( buf, "tongues" )) return AFF_TONGUES;
if (!str_cmp( buf, "sanctuary" )) return AFF_SANCTUARY;