-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathcrafting_new.c
4722 lines (4155 loc) · 158 KB
/
crafting_new.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
// New LuminariMUD Crafting System by Steve Squires aka Gicker
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "mysql.h"
#include "utils.h"
#include "comm.h"
#include "spells.h"
#include "interpreter.h"
#include "constants.h"
#include "handler.h"
#include "db.h"
#include "craft.h"
#include "spells.h"
#include "mud_event.h"
#include "modify.h" // for parse_at()
#include "treasure.h"
#include "mudlim.h"
#include "spec_procs.h" /* For GET_ABILITY() */
#include "item.h"
#include "quest.h"
#include "assign_wpn_armor.h"
#include "genolc.h"
#include "crafting_new.h"
#include "oasis.h"
#include "feats.h"
#include "class.h"
#include "improved-edit.h"
#include "crafting_recipes.h"
int copy_object(struct obj_data *to, struct obj_data *from);
int materials_sort_info[NUM_CRAFT_MATS];
#define NEWCRAFT_RESIZE_SYNTAX "Syntax is as follows: resize (object-name|add|remove|show|bagin) (new-size)\r\n"
#define CRAFT_MOTE_NOARG "Please specity add or remove, and the bonus slot.\r\n" \
"Eg. craft motes add 1\r\n" \
"-- This will add the required type and number of motes to bonus slot 1.\r\n"
#define NEWCRAFT_CREATE_NOARG1 "See HELP CRAFTING for more information on how to craft new items.\r\n" \
"Options are:\r\n" \
"craft itemtype (weapon|armor|jewelry|instrument|misc)\r\n" \
"craft specifictype (type)\r\n" \
"craft variant (variant name)\r\n" \
"craft keywords (keyword string)\r\n" \
"craft shortdesc (short desc string)\r\n" \
"craft roomdesc (room desc string)\r\n" \
"craft extradesc (extra desc string\r\n" \
"craft bonuses (slot) (bonus location) (bonus type) (modifier) (specific)\r\n" \
"craft enhancement (enhancement modifier\r\n" \
"craft materials (add|remove) (material type)\r\n" \
"craft motes (add|remove) (enhancement|bonus slot #)\r\n" \
"craft score\r\n" \
"craft show\r\n" \
"craft check\r\n" \
"craft reset\r\n" \
"craft start\r\n"
#define NEWCRAFT_CREATE_TYPES ("What item type do you wish to make?\r\n" \
"-- armor includes shields\r\n" \
"-- weapons all types\r\n" \
"-- instruments lyres, drums, etc. for bards\r\n" \
"-- misc rings, necklaces, earrings, cloaks, belts, etc.\r\n")
#define NEWCRAFT_CREATE_BONUSES_NOARG "You need to specify all of the bonus information:\r\n" \
"Eg. craft bonuses (slot) (bonus location) (bonus type) (modifier) (specific)\r\n" \
"-- slot needs to be 1-6 as an item can only have 6 bonuses total\r\n" \
"-- bonus location is what the bonus affects. Eg. strength, hit-points, reflex-save, etc.\r\n" \
"-- bonus type is either enhancement or universal. See HELP CRAFTING for more info\r\n" \
"-- modifier is how much the bonus will affect that associated stat\r\n" \
"-- specific is only required for feat, skill, and spell slot bonus types\r\n" \
"\r\n" \
"To reset a bonus slot type: craft bonus [slot] reset\r\n"
#define SUPPLY_ORDER_NOARG1 "Please specify what supply order action you'd like to take.\r\n" \
"supplyorder request : Request a new supply order project.\r\n" \
"supplyorder info : Show information on current supply order project.\r\n" \
"supplyorder material: Add materials to current project\r\n" \
"supplyorder reset : Reset current supply order project to default values.\r\n" \
"supplyorder complete: Turn in a completed supply order for reward.\r\n" \
"supplyorder abandon : Cancel existing supply order project entirely.\r\n" \
"\r\n"
#define HARVEST_NODE_PERCENT_CHANCE 33
#define HARVEST_BASE_TIME 10
#define CREATE_BASE_TIME 10
#define SURVEY_BASE_TIME 3
#define HARVEST_BASE_DC 5
#define CREATE_BASE_DC 5
#define RESIZE_BASE_DC 10
#define HARVEST_MOTE_DICE_SIZE 4
#define HARVEST_MOTE_CHANCE 10
#define HARVEST_BASE_AMOUNT dice(2, 2)
#define HARVEST_BASE_EXP 20
#define CREATE_BASE_EXP 50
#define RESIZE_BASE_EXP 10
#define REFINE_BASE_EXP 10
void assign_harvest_materials_to_word(void)
{
ssize_t cnt = 0;
for (cnt = 0; cnt <= top_of_world; cnt++)
{
// erase all harvest materials
wipe_room_harvest_materials(cnt);
// check valid sector type
if (!is_valid_harvesting_sector(world[cnt].sector_type))
continue;
// check random chance
if (!will_room_have_harvest_materials(cnt))
continue;
// assign materials
assign_harvest_materials_to_room(cnt);
}
}
void assign_harvest_materials_to_room(room_rnum room)
{
if (room == NOWHERE) return;
int material_type = determine_harvest_material_for_room(room);
if (material_type != CRAFT_MAT_NONE)
{
world[room].harvest_material = material_type;
world[room].harvest_material_amount = determine_number_of_harvest_units_for_room();
}
}
int determine_harvest_material_for_room(room_rnum room)
{
if (room == NOWHERE) return 0;
int zone_low = zone_table[world[room].zone].min_level;
int zone_high = zone_table[world[room].zone].min_level;
int zone_level = MIN(30, MAX(1, ((zone_high - zone_low) / 2) + zone_low));
int grade = determine_grade_by_zone_level(zone_level);
int group = determine_random_material_group_by_sector_type(world[room].sector_type);
grade = determine_random_grade(grade);
// small chance for the grade level to be bumped up by one
if (dice(1, 20) == 1)
{
grade++;
}
grade = MAX(1, grade);
int material = determine_material_type_by_group_and_grade(group, grade);
return material;
}
int determine_material_type_by_group_and_grade(int group, int grade)
{
switch (group)
{
case CRAFT_GROUP_HARD_METALS:
switch (grade)
{
case 1: case 2: return dice(1, 2) == 1 ? CRAFT_MAT_ZINC : CRAFT_MAT_TIN;
case 3: case 4: return dice(1, 3) == 1 ? CRAFT_MAT_COAL : CRAFT_MAT_IRON;
case 5: return dice(1, 2) == 1 ? CRAFT_MAT_MITHRIL : CRAFT_MAT_ADAMANTINE;
}
break;
case CRAFT_GROUP_SOFT_METALS:
switch (grade)
{
case 1: case 2: return CRAFT_MAT_COPPER;
case 3: return CRAFT_MAT_SILVER;
case 4: return CRAFT_MAT_GOLD;
case 5: return CRAFT_MAT_PLATINUM;
}
break;
case CRAFT_GROUP_WOOD:
switch (grade)
{
case 1: return CRAFT_MAT_ASH_WOOD;
case 2: return CRAFT_MAT_MAPLE_WOOD;
case 3: return CRAFT_MAT_MAHAGONY_WOOD;
case 4: return CRAFT_MAT_VALENWOOD;
case 5: return CRAFT_MAT_IRONWOOD;
}
break;
case CRAFT_GROUP_HIDES:
switch (grade)
{
case 1: return CRAFT_MAT_LOW_GRADE_HIDE;
case 2: return CRAFT_MAT_MEDIUM_GRADE_HIDE;
case 3: return CRAFT_MAT_HIGH_GRADE_HIDE;
case 4: case 5: return CRAFT_MAT_PRISTINE_GRADE_HIDE;
}
break;
case CRAFT_GROUP_CLOTH:
switch (grade)
{
case 1: return CRAFT_MAT_HEMP;
case 2: return CRAFT_MAT_FLAX;
case 3: return CRAFT_MAT_WOOL;
case 4: return CRAFT_MAT_COTTON;
case 5: return CRAFT_MAT_SILK;
}
break;
}
return CRAFT_MAT_NONE;
}
int craft_material_level_adjustment(int material)
{
switch (material)
{
case CRAFT_MAT_TIN: return -2;
case CRAFT_MAT_BRONZE:
case CRAFT_MAT_COPPER:
case CRAFT_MAT_LOW_GRADE_HIDE:
case CRAFT_MAT_ASH_WOOD:
case CRAFT_MAT_HEMP:
return 0;
case CRAFT_MAT_IRON:
case CRAFT_MAT_BRASS:
case CRAFT_MAT_MEDIUM_GRADE_HIDE:
case CRAFT_MAT_MAPLE_WOOD:
case CRAFT_MAT_WOOL:
return 2;
case CRAFT_MAT_STEEL:
case CRAFT_MAT_SILVER:
case CRAFT_MAT_MAHAGONY_WOOD:
case CRAFT_MAT_LINEN:
return 4;
case CRAFT_MAT_COLD_IRON:
case CRAFT_MAT_ALCHEMAL_SILVER:
case CRAFT_MAT_GOLD:
case CRAFT_MAT_HIGH_GRADE_HIDE:
case CRAFT_MAT_VALENWOOD:
case CRAFT_MAT_COTTON:
return 5;
case CRAFT_MAT_MITHRIL:
case CRAFT_MAT_SILK:
return 7;
case CRAFT_MAT_ADAMANTINE:
case CRAFT_MAT_PLATINUM:
case CRAFT_MAT_PRISTINE_GRADE_HIDE:
case CRAFT_MAT_IRONWOOD:
case CRAFT_MAT_SATIN:
return 8;
case CRAFT_MAT_DRAGONMETAL:
case CRAFT_MAT_DRAGONSCALE:
case CRAFT_MAT_DRAGONBONE:
return 10;
}
return 0;
}
int harvesting_skill_by_material(int material)
{
switch (material)
{
case CRAFT_MAT_TIN:
case CRAFT_MAT_BRONZE:
case CRAFT_MAT_IRON:
case CRAFT_MAT_STEEL:
case CRAFT_MAT_COLD_IRON:
case CRAFT_MAT_ALCHEMAL_SILVER:
case CRAFT_MAT_MITHRIL:
case CRAFT_MAT_ADAMANTINE:
case CRAFT_MAT_DRAGONMETAL:
case CRAFT_MAT_COPPER:
case CRAFT_MAT_SILVER:
case CRAFT_MAT_GOLD:
case CRAFT_MAT_PLATINUM:
case CRAFT_MAT_COAL:
case CRAFT_MAT_ZINC:
return ABILITY_HARVEST_MINING;
case CRAFT_MAT_LOW_GRADE_HIDE:
case CRAFT_MAT_MEDIUM_GRADE_HIDE:
case CRAFT_MAT_HIGH_GRADE_HIDE:
case CRAFT_MAT_PRISTINE_GRADE_HIDE:
case CRAFT_MAT_DRAGONSCALE:
return ABILITY_HARVEST_HUNTING;
case CRAFT_MAT_ASH_WOOD:
case CRAFT_MAT_MAPLE_WOOD:
case CRAFT_MAT_MAHAGONY_WOOD:
case CRAFT_MAT_VALENWOOD:
case CRAFT_MAT_IRONWOOD:
case CRAFT_MAT_DRAGONBONE:
return ABILITY_HARVEST_FORESTRY;
case CRAFT_MAT_HEMP:
case CRAFT_MAT_WOOL:
case CRAFT_MAT_LINEN:
case CRAFT_MAT_FLAX:
case CRAFT_MAT_SATIN:
case CRAFT_MAT_COTTON:
case CRAFT_MAT_SILK:
return ABILITY_HARVEST_GATHERING;
}
return 0;
}
int determine_random_material_group_by_sector_type(room_rnum sector)
{
int chance = dice(1, 100);
switch (sector)
{
case SECT_FIELD:
if (chance <= 75)
return CRAFT_GROUP_CLOTH;
else
return CRAFT_GROUP_HIDES;
case SECT_FOREST:
case SECT_TAIGA:
if (chance <= 75)
return CRAFT_GROUP_WOOD;
else
return CRAFT_GROUP_HIDES;
case SECT_HILLS:
case SECT_UD_WILD:
if (chance <= 25)
return CRAFT_GROUP_CLOTH;
else if (chance <= 50)
return CRAFT_GROUP_HIDES;
else if (chance <= 75)
return CRAFT_GROUP_HARD_METALS;
else
return CRAFT_GROUP_SOFT_METALS;
case SECT_MOUNTAIN:
if (chance <= 20)
return CRAFT_GROUP_HIDES;
else if (chance <= 60)
return CRAFT_GROUP_HARD_METALS;
else
return CRAFT_GROUP_SOFT_METALS;
case SECT_HIGH_MOUNTAIN:
if (chance <= 50)
return CRAFT_GROUP_HARD_METALS;
else
return CRAFT_GROUP_SOFT_METALS;
case SECT_DESERT:
if (chance <= 25)
return CRAFT_GROUP_CLOTH;
else
return CRAFT_GROUP_HIDES;
case SECT_MARSHLAND:
if (chance <= 25)
return CRAFT_GROUP_CLOTH;
else if (chance <= 50)
return CRAFT_GROUP_WOOD;
else
return CRAFT_GROUP_HIDES;
case SECT_CAVE:
if (chance <= 50)
return CRAFT_GROUP_HARD_METALS;
else
return CRAFT_GROUP_SOFT_METALS;
case SECT_JUNGLE:
if (chance <= 25)
return CRAFT_GROUP_CLOTH;
else if (chance <= 50)
return CRAFT_GROUP_HIDES;
else
return CRAFT_GROUP_WOOD;
case SECT_TUNDRA:
if (chance <= 60)
return CRAFT_GROUP_HIDES;
else if (chance <= 80)
return CRAFT_GROUP_HARD_METALS;
else
return CRAFT_GROUP_SOFT_METALS;
// case SECT_BEACH:
// case SECT_RIVER:
// case SECT_UD_WATER:
// case SECT_OCEAN:
// case SECT_WATER_SWIM:
// case SECT_WATER_NOSWIM:
// case SECT_UNDERWATER:
}
return CRAFT_GROUP_NONE;
}
int determine_random_grade(int grade)
{
int chance = dice(1, 100);
switch (grade)
{
case 1:
return 1;
case 2:
if (chance <= 66)
return 1;
else
return 2;
case 3:
if (chance <= 50)
return 1;
else if (chance <= 85)
return 2;
else
return 3;
case 4:
if (chance <= 30)
return 1;
else if (chance <= 60)
return 2;
else if (chance <= 85)
return 3;
else
return 4;
case 5:
if (chance <= 25)
return 1;
else if (chance <= 50)
return 2;
else if (chance <= 70)
return 3;
else if (chance <= 85)
return 4;
else
return 5;
}
return 1;
}
int determine_grade_by_zone_level(int zone_level)
{
if (zone_level <= 6)
return 1;
else if (zone_level <= 12)
return 2;
else if (zone_level <= 18)
return 3;
else if (zone_level <= 24)
return 4;
else
return 5;
}
int determine_number_of_harvest_units_for_room(void)
{
return dice(2, 6);
}
bool will_room_have_harvest_materials(room_rnum room)
{
if (room == NOWHERE)
return false;
if (ROOM_FLAGGED(room, ROOM_HARVEST_NODE))
return true;
int chance = HARVEST_NODE_PERCENT_CHANCE;
if (dice(1, 100) <= chance)
return true;
return false;
}
bool is_valid_harvesting_sector(int sector)
{
switch (sector)
{
case SECT_FIELD:
case SECT_FOREST:
case SECT_HILLS:
case SECT_MOUNTAIN:
case SECT_DESERT:
case SECT_MARSHLAND:
case SECT_HIGH_MOUNTAIN:
case SECT_UD_WILD:
case SECT_CAVE:
case SECT_JUNGLE:
case SECT_TUNDRA:
case SECT_TAIGA:
// case SECT_UD_WATER:
// case SECT_BEACH:
// case SECT_RIVER:
// case SECT_OCEAN:
// case SECT_WATER_SWIM:
// case SECT_WATER_NOSWIM:
// case SECT_UNDERWATER:
return true;
}
return false;
}
bool room_has_harvest_materials(room_rnum room)
{
if (room == NOWHERE) return false;
int i = 0;
for (i = 1; i < NUM_CRAFT_MATS; i++)
if (world[room].harvest_material > 0)
return true;
return false;
}
void wipe_room_harvest_materials(room_rnum room)
{
if (room == NOWHERE) return;
int i = 0;
for (i = 1; i < NUM_CRAFT_MATS; i++)
world[room].harvest_material = 0;
}
int material_grade(int material)
{
switch (material)
{
case CRAFT_MAT_COPPER:
case CRAFT_MAT_TIN:
case CRAFT_MAT_LOW_GRADE_HIDE:
case CRAFT_MAT_ASH_WOOD:
case CRAFT_MAT_HEMP:
case CRAFT_MAT_ZINC:
return 1;
case CRAFT_MAT_BRONZE:
case CRAFT_MAT_MEDIUM_GRADE_HIDE:
case CRAFT_MAT_MAPLE_WOOD:
case CRAFT_MAT_LINEN:
case CRAFT_MAT_FLAX:
return 2;
case CRAFT_MAT_IRON:
case CRAFT_MAT_COAL:
case CRAFT_MAT_SILVER:
case CRAFT_MAT_HIGH_GRADE_HIDE:
case CRAFT_MAT_MAHAGONY_WOOD:
case CRAFT_MAT_WOOL:
return 3;
case CRAFT_MAT_STEEL:
case CRAFT_MAT_COLD_IRON:
case CRAFT_MAT_ALCHEMAL_SILVER:
case CRAFT_MAT_GOLD:
case CRAFT_MAT_PRISTINE_GRADE_HIDE:
case CRAFT_MAT_VALENWOOD:
case CRAFT_MAT_SILK:
return 4;
case CRAFT_MAT_MITHRIL:
case CRAFT_MAT_PLATINUM:
case CRAFT_MAT_ADAMANTINE:
case CRAFT_MAT_DRAGONSCALE:
case CRAFT_MAT_DRAGONBONE:
case CRAFT_MAT_IRONWOOD:
case CRAFT_MAT_SATIN:
return 5;
case CRAFT_MAT_DRAGONMETAL:
return 6;
}
return 0;
}
int craft_group_by_material(int material)
{
switch (material)
{
case CRAFT_MAT_TIN:
case CRAFT_MAT_BRONZE:
case CRAFT_MAT_IRON:
case CRAFT_MAT_STEEL:
case CRAFT_MAT_COLD_IRON:
case CRAFT_MAT_ALCHEMAL_SILVER:
case CRAFT_MAT_MITHRIL:
case CRAFT_MAT_ADAMANTINE:
case CRAFT_MAT_DRAGONMETAL:
case CRAFT_MAT_ZINC:
return CRAFT_GROUP_HARD_METALS;
case CRAFT_MAT_COPPER:
case CRAFT_MAT_BRASS:
case CRAFT_MAT_SILVER:
case CRAFT_MAT_GOLD:
case CRAFT_MAT_PLATINUM:
return CRAFT_GROUP_SOFT_METALS;
case CRAFT_MAT_LOW_GRADE_HIDE:
case CRAFT_MAT_MEDIUM_GRADE_HIDE:
case CRAFT_MAT_HIGH_GRADE_HIDE:
case CRAFT_MAT_PRISTINE_GRADE_HIDE:
case CRAFT_MAT_DRAGONSCALE:
return CRAFT_GROUP_HIDES;
case CRAFT_MAT_ASH_WOOD:
case CRAFT_MAT_MAPLE_WOOD:
case CRAFT_MAT_MAHAGONY_WOOD:
case CRAFT_MAT_VALENWOOD:
case CRAFT_MAT_IRONWOOD:
case CRAFT_MAT_DRAGONBONE:
return CRAFT_GROUP_WOOD;
case CRAFT_MAT_HEMP:
case CRAFT_MAT_WOOL:
case CRAFT_MAT_LINEN:
case CRAFT_MAT_FLAX:
case CRAFT_MAT_COTTON:
case CRAFT_MAT_SATIN:
case CRAFT_MAT_SILK:
return CRAFT_GROUP_CLOTH;
case CRAFT_MAT_COAL:
return CRAFT_GROUP_REFINING;
}
return CRAFT_GROUP_NONE;
}
void survey_complete(struct char_data *ch)
{
ch->player_specials->surveyed_room = true;
if (world[IN_ROOM(ch)].harvest_material != CRAFT_MAT_NONE && world[IN_ROOM(ch)].harvest_material_amount > 0)
{
if (GET_LEVEL(ch) >= LVL_IMMORT)
{
send_to_char(ch, "There are %d units of %s to be harvested here.\r\n",
world[IN_ROOM(ch)].harvest_material_amount,
crafting_materials[world[IN_ROOM(ch)].harvest_material]);
send_to_char(ch, "Players will see:\r\n");
}
send_to_char(ch, "You find %s here.\r\n", crafting_material_nodes[world[IN_ROOM(ch)].harvest_material]);
}
else
{
send_to_char(ch, "There is nothing here to harvest.\r\n");
}
GET_CRAFT(ch).crafting_method = 0;
GET_CRAFT(ch).craft_duration = 0;
act("$n finishes surveying.", FALSE, ch, 0, 0, TO_ROOM);
}
void set_crafting_itemtype(struct char_data *ch, char *arg2)
{
int i = 0;
if (!*arg2)
{
send_to_char(ch, "%s", NEWCRAFT_CREATE_TYPES);
return;
}
for (i = 1; i < NUM_CRAFT_TYPES; i++)
{
if (is_abbrev(arg2, crafting_types[i]))
break;
}
if (i >= NUM_CRAFT_TYPES)
{
send_to_char(ch, "That is not a valid crafting type.\r\n");
send_to_char(ch, "%s", NEWCRAFT_CREATE_TYPES);
return;
}
send_to_char(ch, "Crafting item type set to: %s\r\n", crafting_types[i]);
if (GET_CRAFT(ch).crafting_item_type == CRAFT_TYPE_WEAPON || GET_CRAFT(ch).crafting_item_type == CRAFT_TYPE_ARMOR)
{
if (GET_CRAFT(ch).crafting_item_type != i)
{
send_to_char(ch, "The enhancement bonus has been reset to zero.\r\n");
GET_CRAFT(ch).enhancement = 0;
}
}
GET_CRAFT(ch).crafting_item_type = i;
if (GET_CRAFT(ch).crafting_specific)
{
GET_CRAFT(ch).crafting_specific = 0;
send_to_char(ch, "Your item specific type was reset and will need to be set again with: craft specifictype (type)\r\n");
}
if (GET_CRAFT(ch).craft_variant != -1)
{
GET_CRAFT(ch).craft_variant = -1;
reset_craft_materials(ch, true);
send_to_char(ch, "Your item variant was reset and will need to be set again with: craft variant (type). Any allocated materials have been recovered.\r\n");
}
}
bool is_valid_craft_weapon(int weapon)
{
switch (weapon)
{
case WEAPON_TYPE_COMPOSITE_LONGBOW:
case WEAPON_TYPE_COMPOSITE_LONGBOW_2:
case WEAPON_TYPE_COMPOSITE_LONGBOW_3:
case WEAPON_TYPE_COMPOSITE_LONGBOW_4:
case WEAPON_TYPE_COMPOSITE_SHORTBOW:
case WEAPON_TYPE_COMPOSITE_SHORTBOW_2:
case WEAPON_TYPE_COMPOSITE_SHORTBOW_3:
case WEAPON_TYPE_COMPOSITE_SHORTBOW_4:
return false;
}
return true;
}
void craft_show_weapon_types(struct char_data *ch)
{
int i = 0, count = 0;
for (i = 1; i < NUM_WEAPON_TYPES; i++)
{
if (!is_valid_craft_weapon(i)) continue;
send_to_char(ch, "%-25s ", weapon_list[i].name);
if ((count % 3) == 0) send_to_char(ch, "\r\n");
count++;
}
if ((count % 3) != 0) send_to_char(ch, "\r\n");
}
void set_craft_weapon_type(struct char_data *ch, char *arg2)
{
int i = 0;
if (!*arg2)
{
send_to_char(ch, "\tCYou need to specify a weapon type:\tn\r\n");
craft_show_weapon_types(ch);
return;
}
for (i = 1; i < NUM_WEAPON_TYPES; i++)
{
if (is_abbrev(arg2, weapon_list[i].name))
break;
}
if (i >= NUM_WEAPON_TYPES)
{
send_to_char(ch, "That is not a valid weapon type.\r\n");
craft_show_weapon_types(ch);
return;
}
GET_CRAFT(ch).crafting_specific = i;
send_to_char(ch, "Crafting weapon type set to: %s\r\n", weapon_list[i].name);
if (GET_CRAFT(ch).craft_variant != -1)
{
GET_CRAFT(ch).craft_variant = -1;
reset_craft_materials(ch, true);
send_to_char(ch, "Your item variant was reset and will need to be set again with: craft variant (type). Any allocated materials have been recovered.\r\n");
}
}
void craft_show_armor_types(struct char_data *ch)
{
int i = 0;
for (i = 1; i < NUM_SPEC_ARMOR_TYPES; i++)
{
send_to_char(ch, "%-25s ", armor_list[i].name);
if ((i % 3) == 0) send_to_char(ch, "\r\n");
}
if ((i % 3) != 0) send_to_char(ch, "\r\n");
}
void set_craft_armor_type(struct char_data *ch, char *arg2)
{
int i = 0;
if (!*arg2)
{
send_to_char(ch, "\tCYou need to specify an armor type:\tn\r\n");
craft_show_armor_types(ch);
return;
}
for (i = 1; i < NUM_SPEC_ARMOR_TYPES; i++)
{
if (is_abbrev(arg2, armor_list[i].name))
break;
}
if (i >= NUM_SPEC_ARMOR_TYPES)
{
send_to_char(ch, "That is not a valid armor type.\r\n");
craft_show_armor_types(ch);
return;
}
GET_CRAFT(ch).crafting_specific = i;
send_to_char(ch, "Crafting armor type set to: %s\r\n", armor_list[i].name);
if (GET_CRAFT(ch).craft_variant != -1)
{
GET_CRAFT(ch).craft_variant = -1;
reset_craft_materials(ch, true);
send_to_char(ch, "Your item variant was reset and will need to be set again with: craft variant (type). Any allocated materials have been recovered\r\n");
}
}
void craft_show_instrument_types(struct char_data *ch)
{
int i = 0;
for (i = 1; i < NUM_CRAFT_INSTRUMENT_TYPES; i++)
{
send_to_char(ch, "%-25s ", crafting_instrument_types[i]);
if ((i % 3) == 0) send_to_char(ch, "\r\n");
}
if ((i % 3) != 0) send_to_char(ch, "\r\n");
}
void set_craft_instrument_type(struct char_data *ch, char *arg2)
{
int i = 0;
if (!*arg2)
{
send_to_char(ch, "\tCYou need to specify an instrument type:\tn\r\n");
craft_show_instrument_types(ch);
return;
}
for (i = 1; i < NUM_CRAFT_INSTRUMENT_TYPES; i++)
{
if (is_abbrev(arg2, crafting_instrument_types[i]))
break;
}
if (i >= NUM_CRAFT_INSTRUMENT_TYPES)
{
send_to_char(ch, "That is not a valid instrument type.\r\n");
craft_show_instrument_types(ch);
return;
}
GET_CRAFT(ch).crafting_specific = i;
send_to_char(ch, "Crafting instrument type set to: %s\r\n", crafting_instrument_types[i]);
if (GET_CRAFT(ch).craft_variant != -1)
{
GET_CRAFT(ch).craft_variant = -1;
reset_craft_materials(ch, true);
send_to_char(ch, "Your item variant was reset and will need to be set again with: craft variant (type). Any allocated materials have been recovered\r\n");
}
}
void craft_show_misc_types(struct char_data *ch)
{
int i = 0;
for (i = 1; i < NUM_CRAFT_MISC_TYPES; i++)
{
send_to_char(ch, "%-25s ", crafting_misc_types[i]);
if ((i % 3) == 0) send_to_char(ch, "\r\n");
}
if ((i % 3) != 0) send_to_char(ch, "\r\n");
}
void set_craft_misc_type(struct char_data *ch, char *arg2)
{
int i = 0;
if (!*arg2)
{
send_to_char(ch, "\tCYou need to specify a misc type:\tn\r\n");
craft_show_misc_types(ch);
return;
}
for (i = 1; i < NUM_CRAFT_MISC_TYPES; i++)
{
if (is_abbrev(arg2, crafting_misc_types[i]))
break;
}
if (i >= NUM_CRAFT_MISC_TYPES)
{
send_to_char(ch, "That is not a valid misc type.\r\n");
craft_show_misc_types(ch);
return;
}
GET_CRAFT(ch).crafting_specific = i;
send_to_char(ch, "Crafting misc type set to: %s\r\n", crafting_misc_types[i]);
if (GET_CRAFT(ch).craft_variant != -1)
{
GET_CRAFT(ch).craft_variant = -1;
reset_craft_materials(ch, true);
send_to_char(ch, "Your item variant was reset and will need to be set again with: craft variant (type). Any allocated materials have been recovered\r\n");
}
}
void set_crafting_keywords(struct char_data *ch, const char *arg2)
{
if (!*arg2)
{
send_to_char(ch, "You need to specify the keyword list. Do not add dashes to the keywords.\r\n");
return;
}
if (strstr(arg2, "-"))
{
send_to_char(ch, "Please do not use dashes in the keyword list, as it can affect the ability to target the object.\r\n");
return;
}
if (strlen(arg2) > 100)
{
send_to_char(ch, "The keyword list must be less than 100 characters.\r\n");
return;
}
if (GET_CRAFT(ch).crafting_item_type == 0 || GET_CRAFT(ch).crafting_specific == 0 || GET_CRAFT(ch).craft_variant == -1 || GET_CRAFT(ch).crafting_recipe == 0)
{
send_to_char(ch, "You must set item type, specific type and variant first.\r\n");
return;
}
if (!strstr(arg2, crafting_recipes[GET_CRAFT(ch).crafting_recipe].variant_descriptions[GET_CRAFT(ch).craft_variant]))
{
send_to_char(ch, "You need to have the words '%s' in your keyword list.\r\n", crafting_recipes[GET_CRAFT(ch).crafting_recipe].variant_descriptions[GET_CRAFT(ch).craft_variant]);
return;
}
GET_CRAFT(ch).keywords = strdup(arg2);
send_to_char(ch, "You have set the keywords for your crafting item to:\r\n-- %s\r\n", arg2);
return;
}
void set_crafting_short_desc(struct char_data *ch, const char *arg2)
{
if (!*arg2)
{
send_to_char(ch, "You need to specify the object's short description.\r\n");
return;
}
if (strlen(arg2) > 100)
{
send_to_char(ch, "The short description must be less than 100 characters.\r\n");
return;
}
if (GET_CRAFT(ch).crafting_item_type == 0 || GET_CRAFT(ch).crafting_specific == 0 || GET_CRAFT(ch).craft_variant == -1 || GET_CRAFT(ch).crafting_recipe == 0)
{
send_to_char(ch, "You must set item type, specific type and variant first.\r\n");
return;
}
if (!strstr(arg2, crafting_recipes[GET_CRAFT(ch).crafting_recipe].variant_descriptions[GET_CRAFT(ch).craft_variant]))
{
send_to_char(ch, "You need to have the words '%s' in your short description.\r\n", crafting_recipes[GET_CRAFT(ch).crafting_recipe].variant_descriptions[GET_CRAFT(ch).craft_variant]);
return;
}
GET_CRAFT(ch).short_description = strdup(arg2);
send_to_char(ch, "You have set the short description for your crafting item to:\r\n-- %s\r\n", arg2);
return;
}
void set_crafting_room_desc(struct char_data *ch, const char *arg2)
{
if (!*arg2)
{
send_to_char(ch, "You need to specify the object's short description. This displays as the name of the item.\r\n");
return;
}
if (strlen(arg2) > 120)
{
send_to_char(ch, "The room description must be less than 120 characters. This is what shows when you type 'look' in a room.\r\n");
return;
}
if (GET_CRAFT(ch).crafting_item_type == 0 || GET_CRAFT(ch).crafting_specific == 0 || GET_CRAFT(ch).craft_variant == -1 || GET_CRAFT(ch).crafting_recipe == 0)
{
send_to_char(ch, "You must set item type, specific type and variant first.\r\n");
return;
}