-
Notifications
You must be signed in to change notification settings - Fork 23
/
craft.c
3554 lines (3174 loc) · 99.9 KB
/
craft.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
/*/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
\
/ Luminari Crafting System, Inspired by D20mud's Craft System
/ Created By: Zusuk, original d20 code from Gicker
\
/ using craft.h as the header file currently
\
/
\ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /*/
/*
* Hard metal -> Mining
* Leather -> Hunting
* Wood -> Foresting
* Cloth -> Knitting
* Crystals / Essences -> Chemistry
*/
#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 compute_ability() */
#include "item.h"
#include "quest.h"
#include "assign_wpn_armor.h"
#include "genolc.h"
extern MYSQL *conn;
/* global variables */
int mining_nodes = 0;
int farming_nodes = 0;
int hunting_nodes = 0;
int foresting_nodes = 0;
/***********************************/
/* crafting local utility functions*/
/***********************************/
/* charts for weapon resize, if weapon dice don't fall on any of these, invalid */
int weapon_damage_a[NUM_SIZES][2] = {
/* num_dice, siz_dice */
{
0,
0,
}, /* SIZE_RESERVED */
{
1,
2,
}, // fine
{
1,
3,
}, /* diminutive */
{
1,
4,
}, /* tiny */
{
1,
6,
}, /* small */
{
1,
8,
}, /* medium */
{
1,
12,
}, /* large */
{
4,
4,
}, /* huge */
{
4,
6,
}, /* gargantuan */
{
6,
6,
}, // colossal
};
int weapon_damage_b[NUM_SIZES][2] = {
/* num_dice, siz_dice */
{
0,
0,
}, /* SIZE_RESERVED */
{
1,
1,
}, // fine
{
2,
1,
}, /* diminutive */
{
2,
3,
}, /* tiny */
{
1,
7,
}, /* small */
{
2,
4,
}, /* medium */
{
2,
6,
}, /* large */
{
3,
6,
}, /* huge */
{
6,
4,
}, /* gargantuan */
{
5,
8,
}, // colossal
};
int weapon_damage_c[NUM_SIZES][2] = {
/* num_dice, siz_dice */
{
0,
0,
}, /* SIZE_RESERVED */
{
0,
0,
}, /* invalid (fine) */
{
3,
1,
}, // diminiutive
{
2,
2,
}, /* tiny */
{
3,
2,
}, /* small */
{
1,
9,
}, /* medium */
{
1,
10,
}, /* large */
{
2,
8,
}, /* huge */
{
3,
8,
}, /* gargantuan */
{
4,
8,
}, // colossal
};
/* the primary use of this function is to modify a weapons damage on resize
* weapon: object, needs to be a weapon
* we have 3 charts above trying to accomodate most weapons you could
* possibly ecnounter
* returns TRUE if successful, FALSE if failed */
bool scale_damage(struct char_data *ch, struct obj_data *weapon, int new_size)
{
int num_of_dice = 0; // number-of-dice rolled for weapon dam
int size_of_dice = 0; // size-of-dice rolled for weapon dam
int size = SIZE_UNDEFINED; // old size of weapon
int counter = 0;
int size_shift = SIZE_UNDEFINED;
/* wha?! no object? */
if (!weapon)
{
send_to_char(ch, "You do not seem to have an object for resizing!\r\n");
return FALSE;
}
/* this only works for weapons */
if (GET_OBJ_TYPE(weapon) != ITEM_WEAPON)
{
send_to_char(ch, "You do not seem to have a weapon for resizing!\r\n");
return FALSE;
}
/* assigned for ease-of-use */
num_of_dice = GET_OBJ_VAL(weapon, 1); /* how many dice are we rolling on old size */
size_of_dice = GET_OBJ_VAL(weapon, 2); /* how big is the current dice roll on old size */
size = GET_OBJ_SIZE(weapon); /* what is current size of weapon? */
size_shift = new_size - size; /* how many size classes to shift in charts */
/* first check to make sure we have this value on one of the charts, if
not we are calling it invalid */
for (counter = 0; counter < NUM_SIZES; counter++)
{
/* check our charts - chart A */
if (weapon_damage_a[counter][0] == num_of_dice &&
weapon_damage_a[counter][1] == size_of_dice)
{
/* valid shift in chart? calculate our new location on chart */
if (counter + size_shift >= NUM_SIZES ||
counter + size_shift <= SIZE_RESERVED)
{
send_to_char(ch, "Invalid resize!\r\n");
return FALSE;
}
/* valid! set and exit clean */
GET_OBJ_VAL(weapon, 1) = weapon_damage_a[counter + size_shift][0];
GET_OBJ_VAL(weapon, 2) = weapon_damage_a[counter + size_shift][1];
GET_OBJ_SIZE(weapon) = new_size;
return TRUE;
}
/* check our charts - chart B */
if (weapon_damage_b[counter][0] == num_of_dice &&
weapon_damage_b[counter][1] == size_of_dice)
{
/* valid shift in chart? calculate our new location on chart */
if (counter + size_shift >= NUM_SIZES ||
counter + size_shift <= SIZE_RESERVED)
{
send_to_char(ch, "Invalid resize!\r\n");
return FALSE;
}
/* valid! set and exit clean */
GET_OBJ_VAL(weapon, 1) = weapon_damage_b[counter + size_shift][0];
GET_OBJ_VAL(weapon, 2) = weapon_damage_b[counter + size_shift][1];
GET_OBJ_SIZE(weapon) = new_size;
return TRUE;
}
/* check our charts - chart C */
if (weapon_damage_c[counter][0] == num_of_dice &&
weapon_damage_c[counter][1] == size_of_dice)
{
/* valid shift in chart? calculate our new location on chart */
if (counter + size_shift >= NUM_SIZES ||
counter + size_shift <= SIZE_FINE)
{ /* no 'fine' value for this weapon */
send_to_char(ch, "Invalid resize!\r\n");
return FALSE;
}
/* valid! set and exit clean */
GET_OBJ_VAL(weapon, 1) = weapon_damage_c[counter + size_shift][0];
GET_OBJ_VAL(weapon, 2) = weapon_damage_c[counter + size_shift][1];
GET_OBJ_SIZE(weapon) = new_size;
save_char(ch, 0);
Crash_crashsave(ch);
return TRUE;
}
}
/* couldn't find anything on the charts! */
send_to_char(ch, "Could not find your weapon on any of the charts! You "
"should turn this weapon in to a builder-staff member to adjust.\r\n");
return FALSE;
}
/* this function will switch the material of an item based on the
conversion crafting system
*/
int convert_material(int material)
{
switch (material)
{
case MATERIAL_IRON:
return MATERIAL_COLD_IRON;
case MATERIAL_SILVER:
return MATERIAL_ALCHEMAL_SILVER;
default:
return material;
}
return material;
}
/* simple function to reset craft data */
void reset_craft(struct char_data *ch)
{
/* initialize values */
GET_CRAFTING_TYPE(ch) = 0; // SCMD_ of craft
GET_CRAFTING_TICKS(ch) = 0;
GET_CRAFTING_OBJ(ch) = NULL;
GET_CRAFTING_REPEAT(ch) = 0;
}
/* simple function to reset auto craft data */
void reset_acraft(struct char_data *ch)
{
/* initialize values */
GET_AUTOCQUEST_VNUM(ch) = 0;
GET_AUTOCQUEST_MAKENUM(ch) = 0;
GET_AUTOCQUEST_QP(ch) = 0;
GET_AUTOCQUEST_EXP(ch) = 0;
GET_AUTOCQUEST_GOLD(ch) = 0;
GET_AUTOCQUEST_MATERIAL(ch) = 0;
if (GET_AUTOCQUEST_DESC(ch))
free(GET_AUTOCQUEST_DESC(ch));
GET_AUTOCQUEST_DESC(ch) = strdup("nothing");
}
/* compartmentalized auto-quest crafting reporting since its done
a few times in the code */
void cquest_report(struct char_data *ch)
{
if (GET_AUTOCQUEST_VNUM(ch))
{
if (GET_AUTOCQUEST_MAKENUM(ch) <= 0)
send_to_char(ch, "You have completed your supply order for %s.\r\n",
GET_AUTOCQUEST_DESC(ch));
else
send_to_char(ch, "You have not yet completed your supply order "
"for %s.\r\n"
"You still need to make %d more.\r\n",
GET_AUTOCQUEST_DESC(ch), GET_AUTOCQUEST_MAKENUM(ch));
send_to_char(ch, "Once completed/turned-in you will receive the"
" following:\r\n"
"You will receive %d reputation points.\r\n"
"%d gold will be awarded to you.\r\n"
"You will receive %d experience points.\r\n"
"(type 'supplyorder complete' at the supply office)\r\n",
GET_AUTOCQUEST_QP(ch), GET_AUTOCQUEST_GOLD(ch),
GET_AUTOCQUEST_EXP(ch));
}
else
send_to_char(ch, "Type 'supplyorder new' for a new supply order, "
"'supplyorder complete' to finish your supply "
"order and receive your reward or 'supplyorder quit' "
"to quit your current supply order.\r\n");
}
/*
* Our current list of materials distributed in this manner:
METALS (hard)
* bronze
* iron
* steel
* cold iron
* alchemal silver
* mithril
* adamantine
METALS (precious)
* copper
* brass
* silver
* gold
* platinum
LEATHERS
* leather
* dragonhide
WOODS
* wood
* darkwood
CLOTH
* burlap
* hemp
* cotton
* wool
* velvet
* satin
* silk
*/
/* this function returns an appropriate keyword(s) based on material */
char *node_keywords(int material)
{
/* reference */
/* steel - vein of dull ore */
/* cold iron - vein of ore */
/* mithril - vein of bright ore */
/* adamantine - vein of sparkling ore */
/* silver - vein of dull speckled ore */
/* gold - vein of yellowish ore */
switch (material)
{
case MATERIAL_STEEL:
return strdup("vein of dull ore");
case MATERIAL_COLD_IRON:
return strdup("vein of ore");
case MATERIAL_MITHRIL:
return strdup("vein of bright ore");
case MATERIAL_ADAMANTINE:
return strdup("vein of sparkling ore");
case MATERIAL_SILVER:
return strdup("vein dull speckled ore");
case MATERIAL_GOLD:
return strdup("vein of yellowish ore");
case MATERIAL_WOOD:
return strdup("wood harvest tree");
case MATERIAL_DARKWOOD:
return strdup("wood harvest tree quality");
case MATERIAL_LEATHER:
return strdup("game live area");
case MATERIAL_DRAGONHIDE:
return strdup("game live area exotic");
case MATERIAL_HEMP:
return strdup("cloth raw material basic");
case MATERIAL_COTTON:
return strdup("cloth raw material simple");
case MATERIAL_WOOL:
return strdup("cloth raw material");
case MATERIAL_VELVET:
return strdup("cloth raw material quality");
case MATERIAL_SATIN:
return strdup("cloth raw material high quality");
case MATERIAL_SILK:
return strdup("cloth raw material rich");
}
return strdup("node harvesting");
}
/* this function returns an appropriate short-desc based on material */
char *node_sdesc(int material)
{
/* reference */
/* steel - vein of dull ore */
/* cold iron - vein of ore */
/* mithril - vein of bright ore */
/* adamantine - vein of sparkling ore */
/* silver - vein of dull speckled ore */
/* gold - vein of yellowish ore */
switch (material)
{
case MATERIAL_STEEL:
return strdup("a vein of dull ore");
case MATERIAL_COLD_IRON:
return strdup("a vein of ore");
case MATERIAL_MITHRIL:
return strdup("a vein of bright ore");
case MATERIAL_ADAMANTINE:
return strdup("a vein of sparkling ore");
case MATERIAL_SILVER:
return strdup("a vein of dull speckled ore");
case MATERIAL_GOLD:
return strdup("a vein of yellowish ore");
case MATERIAL_WOOD:
return strdup("a wood harvest");
case MATERIAL_DARKWOOD:
return strdup("a quality wood harvest");
case MATERIAL_LEATHER:
return strdup("an area of live game");
case MATERIAL_DRAGONHIDE:
return strdup("an area of live exotic game");
case MATERIAL_HEMP:
return strdup("raw material for basic cloth");
case MATERIAL_COTTON:
return strdup("raw material for simple cloth");
case MATERIAL_WOOL:
return strdup("raw material for cloth");
case MATERIAL_VELVET:
return strdup("raw material for quality cloth");
case MATERIAL_SATIN:
return strdup("raw material for high quality");
case MATERIAL_SILK:
return strdup("raw material for rich cloth");
}
return strdup("a harvesting node");
}
/* this function returns an appropriate desc based on material */
char *node_desc(int material)
{
/* reference */
/* steel - vein of dull ore */
/* cold iron - vein of ore */
/* mithril - vein of bright ore */
/* adamantine - vein of sparkling ore */
/* silver - vein of dull speckled ore */
/* gold - vein of yellowish ore */
switch (material)
{
case MATERIAL_STEEL:
return strdup("There are veins of dull ore here. \tn(\tYharvest\tn)");
case MATERIAL_COLD_IRON:
return strdup("There are veins of ore here. \tn(\tYharvest\tn)");
case MATERIAL_MITHRIL:
return strdup("There are veins of bright ore here. \tn(\tYharvest\tn)");
case MATERIAL_ADAMANTINE:
return strdup("There are veins of sparkling ore here. \tn(\tYharvest\tn)");
case MATERIAL_SILVER:
return strdup("There are veins of dull speckled ore here. \tn(\tYharvest\tn)");
case MATERIAL_GOLD:
return strdup("There are veins of yellowish ore here. \tn(\tYharvest\tn)");
case MATERIAL_WOOD:
return strdup("The area here looks ideal for harvesting wood. \tn(\tYharvest\tn)");
case MATERIAL_DARKWOOD:
return strdup("The area here looks ideal for harvesting quality wood. \tn(\tYharvest\tn)");
case MATERIAL_LEATHER:
return strdup("The area is live with game. \tn(\tYharvest\tn)");
case MATERIAL_DRAGONHIDE:
return strdup("The area is live with exotic game. \tn(\tYharvest\tn)");
case MATERIAL_HEMP:
return strdup("There is enough raw material for basic cloth here. \tn(\tYharvest\tn)");
case MATERIAL_COTTON:
return strdup("There is enough raw material for simple cloth here. \tn(\tYharvest\tn)");
case MATERIAL_WOOL:
return strdup("There is enough raw material for cloth here. \tn(\tYharvest\tn)");
case MATERIAL_VELVET:
return strdup("There is enough raw material for quality cloth here. \tn(\tYharvest\tn)");
case MATERIAL_SATIN:
return strdup("There is enough raw material for high quality cloth here. \tn(\tYharvest\tn)");
case MATERIAL_SILK:
return strdup("There is enough raw material for rich cloth here. \tn(\tYharvest\tn)");
}
return strdup("A harvesting node is here. Please inform an imm, this is an error.");
}
/* a function to try and make an intelligent(?) decision
about what material a harvesting node should be */
int random_node_material(int allowed)
{
int rand = 0;
if (mining_nodes >= (allowed * 2) && foresting_nodes >= allowed &&
farming_nodes >= allowed && hunting_nodes >= allowed)
return MATERIAL_STEEL;
rand = rand_number(1, 100);
/* 34% mining, blacksmithing or goldsmithing */
if (rand <= 34)
{
// mining
if (mining_nodes >= (allowed * 2))
return random_node_material(allowed);
rand = rand_number(1, 100);
/* 80% chance of blacksmithing (iron/steel/cold-iron/mithril/adamantine */
if (rand <= 80)
{
rand = rand_number(1, 100);
// blacksmithing
if (rand <= 85)
return MATERIAL_STEEL;
else if (rand <= 93)
return MATERIAL_COLD_IRON;
else if (rand <= 98)
return MATERIAL_MITHRIL;
else
return MATERIAL_ADAMANTINE;
/* 20% of goldsmithing (silver/gold) */
}
else
{
// goldsmithing
if (rand_number(1, 100) <= 90)
return MATERIAL_SILVER;
else
return MATERIAL_GOLD;
}
/* 33% farming (hemp/cotton/wool/velvet/satin/silk) */
}
else if (rand <= 67)
{
rand = rand_number(1, 100);
// farming
if (farming_nodes >= allowed)
return random_node_material(allowed);
if (rand <= 30)
return MATERIAL_HEMP;
else if (rand <= 70)
return MATERIAL_COTTON;
else if (rand <= 85)
return MATERIAL_WOOL;
else if (rand <= 96)
return MATERIAL_VELVET;
else if (rand <= 98)
return MATERIAL_SATIN;
else
return MATERIAL_SILK;
/* 33% foresting (leather/dragonhide/wood/darkwood) */
}
else
{
// foresting
if (foresting_nodes >= allowed)
return random_node_material(allowed);
rand = dice(1, 100);
if (rand <= 50)
{
rand = dice(1, 100);
if (rand <= 99)
return MATERIAL_LEATHER;
else
return MATERIAL_DRAGONHIDE;
}
else
{
rand = dice(1, 100);
if (rand <= 99)
return MATERIAL_WOOD;
else
return MATERIAL_DARKWOOD;
}
}
/* default steel */
return MATERIAL_STEEL;
}
/* this is called in db.c on boot-up
harvesting nodes are placed by this function randomly(?)
throughout the world
*/
void reset_harvesting_rooms(void)
{
int cnt = 0;
int num_rooms = 0;
int nodes_allowed = 0;
struct obj_data *obj = NULL;
for (cnt = 0; cnt <= top_of_world; cnt++)
{
if (ROOM_FLAGGED(cnt, ROOM_HOUSE))
continue;
if (ROOM_FLAGGED(cnt, ROOM_FLY_NEEDED))
continue;
if (ROOM_FLAGGED(cnt, ROOM_CLIMB_NEEDED))
continue;
if (world[cnt].sector_type == SECT_CITY)
continue;
if (world[cnt].sector_type == SECT_INSIDE)
continue;
if (world[cnt].sector_type == SECT_INSIDE_ROOM)
continue;
if (world[cnt].sector_type == SECT_WATER_NOSWIM)
continue;
if (world[cnt].sector_type == SECT_OUTTER_PLANES)
continue;
if (world[cnt].sector_type == SECT_UD_CITY)
continue;
if (world[cnt].sector_type == SECT_UD_INSIDE)
continue;
if (world[cnt].sector_type == SECT_UD_WATER_NOSWIM)
continue;
num_rooms++;
}
nodes_allowed = num_rooms / NODE_CAP_FACTOR;
if (mining_nodes >= (nodes_allowed * 2) && foresting_nodes >= nodes_allowed &&
farming_nodes >= nodes_allowed && hunting_nodes >= nodes_allowed)
return;
for (cnt = 0; cnt < top_of_world; cnt++)
{
if (ROOM_FLAGGED(cnt, ROOM_HOUSE))
continue;
if (ROOM_FLAGGED(cnt, ROOM_FLY_NEEDED))
continue;
if (ROOM_FLAGGED(cnt, ROOM_CLIMB_NEEDED))
continue;
if (world[cnt].sector_type == SECT_CITY)
continue;
if (world[cnt].sector_type == SECT_INSIDE)
continue;
if (world[cnt].sector_type == SECT_INSIDE_ROOM)
continue;
if (world[cnt].sector_type == SECT_WATER_NOSWIM)
continue;
if (world[cnt].sector_type == SECT_OUTTER_PLANES)
continue;
if (world[cnt].sector_type == SECT_UD_CITY)
continue;
if (world[cnt].sector_type == SECT_UD_INSIDE)
continue;
if (world[cnt].sector_type == SECT_UD_WATER_NOSWIM)
continue;
if (dice(1, 33) == 1)
{
obj = read_object(HARVESTING_NODE, VIRTUAL);
if (!obj)
continue;
GET_OBJ_MATERIAL(obj) = random_node_material(nodes_allowed);
switch (GET_OBJ_MATERIAL(obj))
{
case MATERIAL_STEEL:
case MATERIAL_COLD_IRON:
case MATERIAL_MITHRIL:
case MATERIAL_ADAMANTINE:
case MATERIAL_SILVER:
case MATERIAL_GOLD:
if (mining_nodes >= nodes_allowed)
{
obj_to_room(obj, cnt);
extract_obj(obj);
continue;
}
else
mining_nodes++;
break;
case MATERIAL_WOOD:
case MATERIAL_DARKWOOD:
case MATERIAL_LEATHER:
case MATERIAL_DRAGONHIDE:
if (foresting_nodes >= nodes_allowed)
{
obj_to_room(obj, cnt);
extract_obj(obj);
continue;
}
else
foresting_nodes++;
case MATERIAL_HEMP:
case MATERIAL_COTTON:
case MATERIAL_WOOL:
case MATERIAL_VELVET:
case MATERIAL_SATIN:
case MATERIAL_SILK:
if (farming_nodes >= nodes_allowed)
{
obj_to_room(obj, cnt);
extract_obj(obj);
continue;
}
else
farming_nodes++;
break;
default:
obj_to_room(obj, cnt);
extract_obj(obj);
continue;
break;
}
GET_OBJ_VAL(obj, 0) = dice(2, 3);
/* strdup()ed in node_foo() functions */
obj->name = node_keywords(GET_OBJ_MATERIAL(obj));
obj->short_description = node_sdesc(GET_OBJ_MATERIAL(obj));
obj->description = node_desc(GET_OBJ_MATERIAL(obj));
obj_to_room(obj, cnt);
}
}
}
/*************************/
/* start primary engines */
/*************************/
// combine essence to make them stronger
int augment(struct obj_data *kit, struct char_data *ch)
{
struct obj_data *obj = NULL, *essence_one = NULL, *essence_two = NULL;
int num_objs = 0, cost = 0, level_diff = 0, success_chance = 0;
int dice_roll = 0, essence_level = 0;
int skill_type = SKILL_CHEMISTRY; // change this to change the skill used
int fast_craft_bonus = GET_SKILL(ch, SKILL_FAST_CRAFTER) / 33;
// Cycle through contents and categorize
for (obj = kit->contains; obj != NULL; obj = obj->next_content)
{
if (obj)
{
num_objs++;
if (num_objs > 2)
{
send_to_char(ch, "Make sure only two items are in the kit.\r\n");
return 1;
}
if (GET_OBJ_TYPE(obj) == ITEM_ESSENCE && !essence_one)
{
essence_one = obj;
}
else if (GET_OBJ_TYPE(obj) == ITEM_ESSENCE && !essence_two)
{
essence_two = obj;
}
}
}
if (num_objs > 2)
{
send_to_char(ch, "Make sure only two items are in the kit.\r\n");
return 1;
}
if (!essence_one || !essence_two)
{
send_to_char(ch, "You need two essences to augment.\r\n");
return 1;
}
if (GET_OBJ_LEVEL(essence_one) >= (LVL_IMMORT - 1) ||
GET_OBJ_LEVEL(essence_two) >= (LVL_IMMORT - 1))
{
send_to_char(ch, "You can not further augment that essence!\r\n");
return 1;
}
level_diff = abs(GET_OBJ_LEVEL(essence_one) - GET_OBJ_LEVEL(essence_two));
/* essence have to be 4 level range of each other */
if (level_diff > 4)
{
send_to_char(ch, "The essence have to be closer in power (level) to each other!\r\n");
return 1;
}
/* what is the level we are adjusting? */
if (GET_OBJ_LEVEL(essence_one) >= GET_OBJ_LEVEL(essence_two))
essence_level = GET_OBJ_LEVEL(essence_one);
else
essence_level = GET_OBJ_LEVEL(essence_two);
/* high enough skill? */
if (essence_level > (GET_SKILL(ch, skill_type) / 3))
{
send_to_char(ch, "The essence level is %d but your %s skill is "
"only capable of creating level %d crystals.\r\n",
essence_level, skill_name(skill_type),
(GET_SKILL(ch, skill_type) / 3));
return 1;
}
cost = essence_level * 500 / 3; // expense for augmenting
if (GET_GOLD(ch) < cost)
{
send_to_char(ch, "You need %d coins on hand for supplies to augment this "
"crystal.\r\n",
cost);
return 1;
}
/* roll the dice! */
dice_roll = dice(1, 100);
/* success is level difference divided by 4, percent */
success_chance = 100 - (level_diff * 10);
success_chance -= essence_level; /* minus level */
/* critical success */
if (dice_roll >= 95)
success_chance = 150;
dice_roll += GET_SKILL(ch, skill_type) / 3;
/* failed our attempt */
if (dice_roll > success_chance)
{
send_to_char(ch, "There seems to be a flaw in your augmentation...\r\n");
}
/* success! */
else
{
essence_level++;
GET_OBJ_LEVEL(essence_one) = essence_level;
}
/* exp bonus for crafting ticks */
GET_CRAFTING_BONUS(ch) = 10 + MIN(30, essence_level);
/* cost */
send_to_char(ch, "It cost you %d coins in supplies to augment this "
"essence.\r\n",
cost);
GET_GOLD(ch) -= cost;
GET_CRAFTING_TYPE(ch) = SCMD_AUGMENT;
GET_CRAFTING_TICKS(ch) = 10 - fast_craft_bonus;
GET_CRAFTING_OBJ(ch) = essence_one;
send_to_char(ch, "You begin to augment %s.\r\n",
essence_one->short_description);
act("$n begins to augment $p.", FALSE, ch, essence_one, 0, TO_ROOM);
/* get rid of the items in the kit */
obj_from_obj(essence_one);
extract_obj(essence_two);
obj_to_char(essence_one, ch);
save_char(ch, 0);
Crash_crashsave(ch);
NEW_EVENT(eCRAFTING, ch, NULL, 1 * PASSES_PER_SEC);
if (!IS_NPC(ch))
increase_skill(ch, skill_type);
return 1;
}
// convert one material into another
// requires multiples of exactly 10 of same mat to do the converstion
/* !! still under construction - zusuk !! */
int convert(struct obj_data *kit, struct char_data *ch)
{
int cost = 500; /* flat cost */
int num_mats = 0, material = -1, obj_vnum = 0;
struct obj_data *new_mat = NULL, *obj = NULL;
int fast_craft_bonus = GET_SKILL(ch, SKILL_FAST_CRAFTER) / 33;
/* Cycle through contents and categorize */
for (obj = kit->contains; obj != NULL; obj = obj->next_content)
{
if (obj)
{
if (GET_OBJ_TYPE(obj) != ITEM_MATERIAL)
{
send_to_char(ch, "Only materials should be inside the kit in"
" order to convert.\r\n");
return 1;
}
else if (GET_OBJ_TYPE(obj) == ITEM_MATERIAL)
{
if (GET_OBJ_VAL(obj, 0) >= 2)
{
send_to_char(ch, "%s is a bundled item, which must first be unbundled before you can use it to craft.\r\n", obj->short_description);
return 1;
}
if (material == -1)
{ /* first item */
new_mat = obj;
material = GET_OBJ_MATERIAL(obj);
}
else if (GET_OBJ_MATERIAL(obj) != material)
{
send_to_char(ch, "You have mixed materials inside the kit, "
"put only the exact same materials for "
"conversion.\r\n");
return 1;
}
num_mats++; /* we found matching material */
obj_vnum = GET_OBJ_VNUM(obj);
}
}
}
if (num_mats)
{
if (num_mats % 10)
{
send_to_char(ch, "You must convert materials in multiple "
"of 10 units exactly.\r\n");
return 1;
}
}
else
{
send_to_char(ch, "There is no material in the kit.\r\n");
return 1;
}
if ((num_mats = convert_material(material)))
send_to_char(ch, "You are converting the material to: %s\r\n",
material_name[num_mats]);
else
{
send_to_char(ch, "You do not have a valid material in the crafting "
"kit.\r\n");
return 1;
}
if (GET_GOLD(ch) < cost)
{
send_to_char(ch, "You need %d gold on hand for supplies to covert these "
"materials.\r\n",
cost);
return 1;