/
act_obj.c
9040 lines (7781 loc) · 248 KB
/
act_obj.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
/***************************************************************************
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. *
* *
* Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* *
* In order to use any part of this Merc Diku Mud, you must comply with *
* both the original Diku license in 'license.doc' as well the Merc *
* license in 'license.txt'. In particular, you may not remove either of *
* these copyright notices. *
* *
* Much time and thought has gone into this software and you are *
* benefitting. We hope that you share your changes too. What goes *
* around, comes around. *
***************************************************************************/
/***************************************************************************
* ROM 2.4 is copyright 1993-1996 Russ Taylor *
* ROM has been brought to you by the ROM consortium *
* Russ Taylor (rtaylor@efn.org) *
* Gabrielle Taylor *
* Brian Moore (zump@rom.org) *
* By using this code, you have agreed to follow the terms of the *
* ROM license, in the file Rom24/doc/rom.license *
***************************************************************************/
#if defined(macintosh)
#include <types.h>
#include <time.h>
#else
#include <sys/types.h>
#endif
#if defined(unix)
#include <sys/time.h>
#else
#include <time.h>
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include "merc.h"
#include "recycle.h"
#include "lookup.h"
#include "olc.h"
#include "tables.h"
#include "languages.h"
#include "alchemy.h"
#include "PyreInfo.h"
#include "spells_spirit.h"
#include "spells_spirit_earth.h"
#include "spells_air_earth.h"
#include "spells_water_earth.h"
#include "spells_void.h"
#include "Luck.h"
#include "NameMaps.h"
#include "Encumbrance.h"
/* command procedures needed */
DECLARE_DO_FUN(do_split );
DECLARE_DO_FUN(do_yell );
DECLARE_DO_FUN(do_autoyell );
DECLARE_DO_FUN(do_say );
DECLARE_DO_FUN(do_wake );
DECLARE_DO_FUN(do_hide );
DECLARE_DO_FUN(do_tell );
DECLARE_DO_FUN(do_withdraw );
DECLARE_DO_FUN(do_look );
/*
* Local functions.
*/
#define CD CHAR_DATA
#define OD OBJ_DATA
bool remove_obj_slot args( (CHAR_DATA *ch, int slot, bool fReplace) );
CD * find_keeper args( (CHAR_DATA *ch ) );
long base_cost args( (OBJ_DATA *obj ) );
long get_cost args( (CHAR_DATA *keeper, OBJ_DATA *obj, bool fBuy ) );
void obj_to_keeper args( (OBJ_DATA *obj, CHAR_DATA *ch ) );
OD * get_obj_keeper args( (CHAR_DATA *ch,CHAR_DATA *keeper,char *argument));
void do_drop args( ( CHAR_DATA *ch, char *argument ));
int hands_free args( (CHAR_DATA *ch) );
void desiccate_corpse args( (OBJ_DATA *corpse) );
int letsmakeadeal(CHAR_DATA *ch, CHAR_DATA *keeper, int cost, bool buy);
extern bool spell_protection_good args((int sn,int level,CHAR_DATA *ch,void *vo,int target));
extern bool check_social args( ( CHAR_DATA *ch, char *command,
char *argument ) );
extern int get_moon_state args( ( int moon_num, bool get_size ) );
extern void levelize_mobile args((CHAR_DATA *mob, int level));
extern void check_heirloom_level(CHAR_DATA *ch, OBJ_DATA *obj);
extern void do_pray(CHAR_DATA *ch, char *argument);
extern void do_bug( CHAR_DATA *ch, char *argument );
extern bool unassume_form(CHAR_DATA *ch);
extern bool damage_from_obj args( ( CHAR_DATA *ch, CHAR_DATA *victim, OBJ_DATA *obj, int dam, int dt, int dam_type, bool show) );
extern int elemental_lookup args((char * argument));
extern int make_bin args((int prebin));
extern const struct wear_type wear_table[];
int item_svalue[6] = { 1, 3, 6, 12, 36, 72 };
#undef OD
#undef CD
/* RT part of the corpse looting code */
/* MW hahaha. */
bool can_loot(CHAR_DATA *ch, OBJ_DATA *obj)
{
if (ch == NULL || obj == NULL) return FALSE;
if (!obj->owner) return TRUE;
if (!IS_NPC(ch) && (ch->level > 10 || !strcmp(ch->name, obj->owner))) return TRUE;
return FALSE;
/* Loot like mad bitches, unless you're a newbie */
}
bool check_aura(CHAR_DATA *ch, OBJ_DATA *obj, bool damage)
{
if (obj_is_affected(obj, gsn_aura) && IS_EVIL(ch))
{
act( "You are zapped by $p and drop it.", ch, obj, NULL, TO_CHAR );
act( "$n is zapped by $p and drops it.", ch, obj, NULL, TO_ROOM );
obj_from_char( obj );
obj_to_room( obj, ch->in_room );
if (damage)
damage_old(ch,ch,number_range(ch->level,2*ch->level),gsn_aura,DAM_HOLY,TRUE);
return TRUE;
}
else
return FALSE;
}
int get_cur_capacity(CHAR_DATA *ch)
{
int c = 0;
OBJ_DATA *obj;
if (obj = ch->carrying)
for (; obj; obj = obj->next_content)
if (!obj->worn_on)
c += item_svalue[obj->size];
return c;
}
int get_max_capacity(CHAR_DATA *ch)
{
return INT_MAX;
// return 45 + (ch->size * 5);
}
void get_obj( CHAR_DATA *ch, OBJ_DATA *obj, OBJ_DATA *container )
{
/* variables for AUTOSPLIT */
bool cvalid = TRUE;
CHAR_DATA *pMob;
CHAR_DATA *gch;
int members;
char buffer[100];
int i;
bool ghostly;
if (ch == NULL || obj == NULL)
return;
if ( !CAN_WEAR(obj, ITEM_TAKE) )
{
send_to_char( "You can't take that.\n\r", ch );
return;
}
if ( IS_PAFFECTED(ch, AFF_VOIDWALK) || is_affected(ch, gsn_astralprojection))
{
act("Your immaterial hands pass through $d.", ch, NULL, obj->short_descr, TO_CHAR);
return;
}
if ( is_affected(ch, gsn_frostbite) && number_bits(1) == 0)
{
act("Your hands shiver and you can't quite pick up $p.", ch, obj, NULL, TO_CHAR);
return;
}
if (!IS_NPC(ch) && !IS_IMMORTAL(ch)
&& (get_cur_capacity(ch) + item_svalue[obj->size]) > get_max_capacity(ch))
{
send_to_char("You lack the room to carry that.\n\r", ch);
return;
}
if (ch->carry_number + 1 > static_cast<int>(Encumbrance::CarryCountCapacity(*ch)))
{
act( "$p: you can't carry that many items.", ch, obj, NULL, TO_CHAR );
return;
}
if ((!obj->in_obj || obj->in_obj->carried_by != ch)
&& (get_carry_weight(*ch) + get_obj_weight(obj) > static_cast<int>(Encumbrance::CarryWeightCapacity(*ch))))
{
act( "$p: you can't carry that much weight.", ch, obj, NULL, TO_CHAR );
return;
}
if (!can_loot(ch,obj))
{
act("Corpse looting is not permitted.",ch,NULL,NULL,TO_CHAR );
return;
}
if (obj_is_affected(obj, gsn_dispatchlodestone))
{
act("$p bobs in the air, avoiding your grasp.", ch, obj, NULL, TO_CHAR);
return;
}
if (obj->in_room != NULL)
{
for (gch = obj->in_room->people; gch != NULL; gch = gch->next_in_room)
if (gch->on == obj)
{
act("$N appears to be using $p.",
ch,obj,gch,TO_CHAR);
return;
}
}
if (IS_NPC(ch) && IS_SET(ch->act, ACT_ILLUSION))
{
if (ch->master != NULL)
act("$N tries to get $p, but cannot since $E isn't real.", ch->master, obj, ch, TO_CHAR);
return;
}
if (!IS_NPC(ch) && IS_OAFFECTED(ch, AFF_GHOST))
{
ghostly = TRUE;
if (ch->perm_stat[STAT_CON] >= 4)
{
for (i = 0; i < MAX_LASTOWNER; i++)
if ((obj->lastowner[i][0] != '\0') && !str_cmp(ch->name, obj->lastowner[i]))
{
ghostly = FALSE;
break;
}
}
if (ghostly)
{
act("Your ghostly hands pass through $p.", ch, obj, NULL, TO_CHAR);
return;
}
}
if ( container != NULL )
{
if (!IS_AFFECTED(ch, AFF_SNEAK) && !is_affected(ch, gsn_lessertentaclegrowth))
act( "$n gets $p from $P.", ch, obj, container, TO_ROOM );
act( "You get $p from $P.", ch, obj, container, TO_CHAR );
REMOVE_BIT(obj->extra_flags[0],ITEM_HAD_TIMER);
if (ch && obj && obj->in_obj && obj->in_obj->owner && !strcmp(ch->name, obj->in_obj->owner))
cvalid = FALSE;
obj_from_obj( obj );
}
else
{
if (!IS_AFFECTED(ch, AFF_SNEAK))
act( "$n gets $p.", ch, obj, container, TO_ROOM );
act( "You get $p.", ch, obj, container, TO_CHAR );
obj_from_room( obj );
if (obj_is_affected(obj, gsn_runeoffire))
{
act("With a blast of flame, a rune of fire on $p explodes at $n!", ch, obj, NULL, TO_ROOM);
act("With a blast of flame, a rune of fire on $p explodes at you!", ch, obj, NULL, TO_CHAR);
damage(ch,ch,number_range(ch->level, ch->level*4),gsn_runeoffire,DAM_FIRE,TRUE);
object_affect_strip(obj, gsn_runeoffire);
}
REMOVE_BIT(obj->extra_flags[0],ITEM_HIDDEN);
REMOVE_BIT(obj->extra_flags[0],ITEM_STASHED);
}
if ( obj->item_type == ITEM_MONEY)
{
coins_to_char(ch, obj->value[0], obj->value[1]);
if (IS_SET(ch->act,PLR_AUTOSPLIT))
{ /* AUTOSPLIT code */
members = 0;
for (gch = ch->in_room->people; gch != NULL; gch = gch->next_in_room )
{
if (!IS_AFFECTED(gch,AFF_CHARM) && !IS_NPC(gch) && is_same_group( gch, ch ) )
members++;
}
if ( members > 1 && (obj->value[0] > 1 || obj->value[1]))
{
sprintf(buffer,"%d %s",obj->value[0],coin_table[obj->value[1]].name);
do_split(ch,buffer);
}
}
oprog_take_trigger( obj, ch, obj );
for (pMob = ch->in_room->people ; pMob != NULL; pMob = pMob->next_in_room)
{
mprog_take_trigger( pMob, ch, obj );
}
extract_obj( obj );
}
else
{
obj_to_char( obj, ch );
/* if (!IS_NPC(ch) && cvalid)
{
ch->objlevels += obj->level;
if (ch->objlevels > ch->level * 10 && ch->objlevels > 100
&& obj->level > 1)
{
sprintf(buf,"%s took %s [level %d] in room %d. Total levels: %ld.",
ch->name, obj->short_descr, obj->level, ch->in_room ? ch->in_room->vnum : -1, ch->objlevels);
log_string(buf);
sprintf(buf, "Overlimit: %s took %s [level %d] in room %d. Total levels: %ld.", ch->name, obj->short_descr, obj->level, ch->in_room ? ch->in_room->vnum : -1, ch->objlevels);
ch->objlevels -= 100;
wiznet(buf,NULL,NULL,WIZ_CHEATING,0,0);
}
}*/
oprog_take_trigger( obj, ch, obj );
for (pMob = ch->in_room->people ; pMob != NULL; pMob = pMob->next_in_room)
{
mprog_take_trigger( pMob, ch, obj );
}
}
check_aura(ch, obj, TRUE);
return;
}
void do_get( CHAR_DATA *ch, char *argument )
{
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
OBJ_DATA *obj;
OBJ_DATA *obj_next;
OBJ_DATA *container;
bool found;
int num_canloot; //For working with 'get all corpse'.
argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
if (!str_cmp(arg2,"from"))
return;
/* Get type. */
if ( arg1[0] == '\0' )
{
send_to_char( "Get what?\n\r", ch );
return;
}
if ( arg2[0] == '\0' )
{
if ( str_cmp( arg1, "all" ) && str_prefix( "all.", arg1 ) )
{
/* 'get obj' */
obj = get_obj_list( ch, arg1, ch->in_room->contents );
if ( obj == NULL )
{
act( "I see no $T here.", ch, NULL, arg1, TO_CHAR );
return;
}
if (ch->fighting && (IS_NPC(ch) || !BIT_GET(ch->pcdata->traits, TRAIT_FLEET))
&& number_bits(2) != 0)
{
act( "You're too busy fighting to get $p.",ch,obj,NULL, TO_CHAR);
return;
}
else
{
get_obj( ch, obj, NULL );
}
}
else
{
if (ch->fighting)
{
send_to_char("You're too busy fighting to get everything on the ground.\n\r",ch);
return;
}
/* 'get all' or 'get all.obj' */
found = FALSE;
for ( obj = ch->in_room->contents; obj != NULL; obj = obj_next )
{
obj_next = obj->next_content;
if ( ( arg1[3] == '\0' || is_name( &arg1[4], obj->name ) )
&& can_see_obj( ch, obj )
&& CAN_WEAR(obj, ITEM_TAKE)
&& !IS_OBJ_STAT(obj, ITEM_NOLONG) )
{
found = TRUE;
get_obj( ch, obj, NULL );
}
}
if ( !found )
{
if ( arg1[3] == '\0' )
send_to_char( "I see nothing here.\n\r", ch );
else
act( "I see no $T here.", ch, NULL, &arg1[4], TO_CHAR );
}
}
}
else
{
/* 'get ... container' */
if ( !str_cmp( arg2, "all" ) || !str_prefix( "all.", arg2 ) )
{
send_to_char( "You can't do that.\n\r", ch );
return;
}
if ( ( container = get_obj_here( ch, arg2 ) ) == NULL )
{
act( "I see no $T here.", ch, NULL, arg2, TO_CHAR );
return;
}
switch ( container->item_type )
{
default:
send_to_char( "That's not a container.\n\r", ch );
return;
case ITEM_CONTAINER:
{
if (ch->fighting && container->carried_by != ch
&& number_bits(1) == 0)
{
send_to_char("You're too busy fighting!\n\r",ch);
return;
}
}
break;
case ITEM_CORPSE_NPC:
{
if (ch->fighting && ch->class_num != 15)
{
send_to_char("You're too busy fighting to loot a corpse.\n\r",ch);
return;
}
}
break;
case ITEM_CORPSE_PC:
{
if (ch->fighting && ch->class_num != 15)
{
send_to_char("You're too busy fighting to loot a corpse.\n\r",ch);
return;
}
if (!can_loot(ch,container))
{
send_to_char( "You can't do that.\n\r", ch );
return;
}
}
break;
}
if ((container->item_type == ITEM_CONTAINER) && IS_SET(container->value[1], CONT_CLOSED))
{
act( "$d is closed.", ch, NULL, container->short_descr, TO_CHAR );
return;
}
if (container->in_room && ((container->item_type == ITEM_CORPSE_PC) || (container->item_type == ITEM_CORPSE_NPC)))
{
CHAR_DATA *wch;
for (wch = container->in_room->people; wch; wch = wch->next_in_room)
if (IS_NPC(wch)
&& (wch->pIndexData->vnum == MOB_VNUM_DEMON_GUARDIAN)
&& (wch->memfocus[0] != ch)
&& (container->objfocus[0] == wch->memfocus[0]))
{
act("$n moves protectively in front of the corpse.", wch, NULL, NULL, TO_ROOM);
return;
}
}
if ( str_cmp( arg1, "all" ) && str_prefix( "all.", arg1 ) )
{
/* 'get obj container' */
obj = get_obj_list( ch, arg1, container->contains );
if ( obj == NULL )
{
act( "I see nothing like that in the $T.", ch, NULL, arg2, TO_CHAR );
return;
}
get_obj( ch, obj, container );
if (container->item_type == ITEM_CORPSE_PC)
WAIT_STATE(ch, UMAX(ch->wait, PULSE_VIOLENCE));
}
else
{
num_canloot = -1;
if ((container->item_type == ITEM_CORPSE_PC) && !IS_IMMORTAL(ch))
{
num_canloot = (str_cmp(container->owner, ch->name) ? 1 : 3 + (number_percent() < 50));
if (Luck::Check(*ch) == Luck::Lucky)
++num_canloot;
}
/* 'get all container' or 'get all.obj container' */
found = FALSE;
for ( obj = container->contains; obj != NULL && num_canloot != 0; obj = obj_next )
{
obj_next = obj->next_content;
if ( ( arg1[3] == '\0' || is_name( &arg1[4], obj->name ) )
&& can_see_obj( ch, obj ) )
{
found = TRUE;
get_obj( ch, obj, container );
num_canloot--;
}
}
if (container->item_type == ITEM_CORPSE_PC)
{
save_char_obj(ch);
WAIT_STATE(ch, UMAX(ch->wait, PULSE_VIOLENCE));
}
if ( !found )
{
if ( arg1[3] == '\0' )
act( "I see nothing in the $T.",
ch, NULL, arg2, TO_CHAR );
else
act( "I see nothing like that in the $T.",
ch, NULL, arg2, TO_CHAR );
}
}
}
}
void do_put( CHAR_DATA *ch, char *argument )
{
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
OBJ_DATA *container;
OBJ_DATA *obj;
OBJ_DATA *obj_next;
argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
if (!str_cmp(arg2,"in") || !str_cmp(arg2,"on"))
argument = one_argument(argument,arg2);
if ( arg1[0] == '\0' || arg2[0] == '\0' )
{
send_to_char( "Put what in what?\n\r", ch );
return;
}
if ( !str_cmp( arg2, "all" ) || !str_prefix( "all.", arg2 ) )
{
send_to_char( "You can't do that.\n\r", ch );
return;
}
if ( ( container = get_obj_here( ch, arg2 ) ) == NULL )
{
act( "I see no $T here.", ch, NULL, arg2, TO_CHAR );
return;
}
if ( container->item_type != ITEM_CONTAINER )
{
send_to_char( "That's not a container.\n\r", ch );
return;
}
if ( IS_SET(container->value[1], CONT_CLOSED) )
{
act( "$d is closed.", ch, NULL, container->short_descr, TO_CHAR );
return;
}
if ( str_cmp( arg1, "all" ) && str_prefix( "all.", arg1 ) )
{
/* 'put obj container' */
if ( ( obj = get_obj_carry( ch, arg1, ch ) ) == NULL )
{
send_to_char( "You do not have that item.\n\r", ch );
return;
}
if (IS_PAFFECTED(ch, AFF_VOIDWALK))
{
act("Your immaterial hands pass through $d.", ch, NULL, obj->short_descr, TO_CHAR);
return;
}
if ( obj == container )
{
send_to_char( "You can't fold it into itself.\n\r", ch );
return;
}
if ( !can_drop_obj( ch, obj ) )
{
send_to_char( "You can't let go of it.\n\r", ch );
return;
}
if (obj->item_type == ITEM_CONTAINER)
{
send_to_char("You cannot place containers inside of containers.\n\r", ch);
return;
}
if (WEIGHT_MULT(obj) != 100)
{
send_to_char("You have a feeling that would be a bad idea.\n\r",ch);
return;
}
if ((get_obj_weight(obj) + get_weight_contents(*container)) > container->value[0] * 10 || (get_obj_weight(obj) > (container->value[3] * 10)))
{
send_to_char("It won't fit.\n", ch);
return;
}
if ((container->pIndexData->vnum == OBJ_VNUM_DISC || container->pIndexData->vnum == OBJ_VNUM_WATERWHEEL)
&& container->contains != NULL)
{
act("$p isn't big enough for more than one item.", ch, container, NULL, TO_CHAR);
return;
}
if (obj->pIndexData->limit > 0 && container->pIndexData->vnum != OBJ_VNUM_RAIDER_BELT
&& container->pIndexData->vnum != OBJ_VNUM_DISC && (container->wear_flags & ITEM_TAKE))
{
send_to_char("That item is too powerful to place in such a container.\n\r", ch);
return;
}
if (obj == ch->nocked)
{
if (is_affected(ch,gsn_ready))
{
act("You stop readying a shot.",ch,NULL,NULL,TO_CHAR);
act("$n stops readying a shot.",ch,NULL,NULL,TO_ROOM);
affect_strip(ch,gsn_ready);
}
ch->nocked = NULL;
}
obj_from_char( obj );
obj_to_obj( obj, container );
if (IS_SET(container->value[1],CONT_PUT_ON))
{
if (!IS_AFFECTED(ch, AFF_SNEAK))
act("$n puts $p on $P.",ch,obj,container, TO_ROOM);
act("You put $p on $P.",ch,obj,container, TO_CHAR);
}
else
{
if (!IS_AFFECTED(ch, AFF_SNEAK))
act( "$n puts $p in $P.", ch, obj, container, TO_ROOM );
act( "You put $p in $P.", ch, obj, container, TO_CHAR );
}
}
else
{
/* 'put all container' or 'put all.obj container' */
for ( obj = ch->carrying; obj != NULL; obj = obj_next )
{
obj_next = obj->next_content;
if ( ( arg1[3] == '\0' || is_name( &arg1[4], obj->name ) )
&& can_see_obj( ch, obj )
&& WEIGHT_MULT(obj) == 100
&& !obj->worn_on
&& obj != container
&& obj->item_type != ITEM_CONTAINER
&& can_drop_obj( ch, obj )
&& get_obj_weight( obj ) + get_weight_contents(*container)
<= (container->value[0] * 10)
&& get_obj_weight(obj) < (container->value[3] * 10))
{
if (obj->pIndexData->limit > 0 && container->pIndexData->vnum != OBJ_VNUM_RAIDER_BELT
&& container->pIndexData->vnum != OBJ_VNUM_DISC && (container->wear_flags & ITEM_TAKE))
{
send_to_char("That item is too powerful to place in such a container.\n\r", ch);
continue;
}
if ((container->pIndexData->vnum == OBJ_VNUM_DISC || container->pIndexData->vnum == OBJ_VNUM_WATERWHEEL)
&& container->contains != NULL)
{
act("$p isn't big enough for more than one item.", ch, container, NULL, TO_CHAR);
continue;
}
obj_from_char( obj );
obj_to_obj( obj, container );
if (IS_SET(container->value[1],CONT_PUT_ON))
{
if (!IS_AFFECTED(ch, AFF_SNEAK))
act("$n puts $p on $P.",ch,obj,container, TO_ROOM);
act("You put $p on $P.",ch,obj,container, TO_CHAR);
}
else
{
if (!IS_AFFECTED(ch, AFF_SNEAK))
act( "$n puts $p in $P.", ch, obj, container, TO_ROOM );
act( "You put $p in $P.", ch, obj, container, TO_CHAR );
}
}
}
}
}
void do_search( CHAR_DATA *ch, char *argument)
{
OBJ_DATA *pObj;
char buf[MAX_STRING_LENGTH];
send_to_char("You go over the surrounding area inch by inch.\n\r", ch);
act("$n goes over the surrounding area inch by inch.", ch, NULL, NULL, TO_ROOM);
for (pObj = ch->in_room->contents ; pObj != NULL ; pObj = pObj->next_content)
{
if (IS_SET(pObj->extra_flags[0],ITEM_STASHED))
{
if (ch->class_num == global_int_class_bandit || ch->class_num == global_int_class_watcher
|| number_percent() < 20 + get_curr_stat(ch,STAT_INT) + get_curr_stat(ch,STAT_WIS))
{
sprintf(buf, "You uncover %s while searching about.\n\r", pObj->short_descr);
send_to_char(buf, ch);
REMOVE_BIT(pObj->extra_flags[0], ITEM_STASHED);
}
}
}
WAIT_STATE(ch, UMAX(ch->wait, 2*PULSE_VIOLENCE));
}
void do_craftdart(CHAR_DATA *ch, char *argument)
{
int skill, mod;
int type = 0;
AFFECT_DATA af;
af.valid = TRUE;
af.point = NULL;
OBJ_DATA *vial = NULL, *darts;
if ((skill = get_skill(ch,gsn_craftdart)) == 0)
{
send_to_char("Huh?\n\r", ch);
return;
}
if ((vial = get_obj_carry(ch, argument, ch)) == NULL)
{
send_to_char("You aren't carrying that.\n\r", ch);
return;
}
if (vial->pIndexData->vnum != OBJ_VNUM_POISON_VIAL)
{
send_to_char("You can only make darts from a poison vial.\n\r", ch);
return;
}
for (type = 0;poison_table[type].spell_fun;type++)
if (obj_is_affected(vial,*(poison_table[type].sn)))
break;
if (poison_table[type].spell_fun == NULL)
{
send_to_char("You can't create poison from that.\n\r",ch);
return;
}
mod = get_modifier(vial->affected, *(poison_table[type].sn));
extract_obj(vial);
WAIT_STATE(ch, UMAX(ch->wait, skill_table[gsn_craftdart].beats));
if (number_percent() > skill)
{
check_improve(ch,NULL,gsn_craftdart,FALSE,2);
act("You try to coat a dart with poison, but fail and ruin the components.", ch, NULL, NULL, TO_CHAR);
act("$n tries to coat a dart with poison, but fails and ruins the components.", ch, NULL, NULL, TO_ROOM);
return;
}
darts = create_object(get_obj_index(OBJ_VNUM_POISON_DART), 0);
act("$n carefully crafts and poisons a dart.", ch, NULL, NULL, TO_ROOM);
act("You deftly craft and poison a dart.", ch, NULL, NULL, TO_CHAR);
check_improve(ch,NULL,gsn_craftdart,TRUE,1);
af.where = TO_OBJECT;
af.type = *(poison_table[type].sn);
af.level = ch->level;
af.duration = -1;
af.location = 0;
af.modifier = 0;
af.bitvector = 0;
affect_to_obj(darts, &af);
darts->timer = mod+3;
obj_to_char(darts, ch);
}
void do_identifyowner(CHAR_DATA *ch, char *argument)
{
int skill;
OBJ_DATA *obj;
char buf[MAX_STRING_LENGTH];
int i;
if ((skill = get_skill(ch,gsn_identifyowner)) == 0)
{
send_to_char("Huh?\n\r", ch);
return;
}
if ((obj = get_obj_carry(ch, argument, ch)) == NULL)
{
send_to_char("You aren't carrying that.\n\r", ch);
return;
}
if (skill < number_percent())
{
send_to_char("You failed to identify the owner.\n\r", ch);
for (i = 0; i < MAX_LASTOWNER; i++)
{
free_string(obj->lastowner[i]);
obj->lastowner[i] = str_dup("");
}
check_improve(ch,NULL,gsn_identifyowner,FALSE,2);
return;
}
if (obj->lastowner[0][0] == '\0')
{
send_to_char("You can't seem to tell who owned this last.\n\r", ch);
return;
}
sprintf(buf, "This seems to have last been in the possession of %s.\n\r", obj->lastowner[0]);
send_to_char(buf, ch);
if (obj->lastowner[1][0] != '\0')
{
sprintf(buf, "Before that, it seems to have been owned by %s.\n\r", obj->lastowner[1]);
send_to_char(buf, ch);
}
}
void do_swordrepair(CHAR_DATA * ch, char * argument)
{
int skill, impmod;
OBJ_DATA * obj;
OBJ_DATA * obj2;
OBJ_DATA * obj3;
OBJ_DATA * obj4;
char arg[MAX_INPUT_LENGTH];
impmod = 0;
if ((skill = get_skill(ch, gsn_swordrepair)) == 0)
{
send_to_char("Huh?\n\r", ch);
return;
}
argument = one_argument(argument, arg);
if ((obj = get_obj_carry(ch, arg, ch)) == NULL)
{
send_to_char("You are not carrying that.\n\r", ch);
return;
}
if (obj->pIndexData->vnum == 22721 || obj->pIndexData->vnum == 22722 || obj->pIndexData->vnum == 22723)
{
argument = one_argument(argument, arg);
if (arg[0] == '\0'
|| ((obj2 = get_obj_carry(ch, arg, ch)) == NULL)
|| (obj2 == obj)
|| (obj2->pIndexData->vnum != 22721 && obj2->pIndexData->vnum != 22722 && obj2->pIndexData->vnum != 22723))
{
send_to_char("You can only fix broken swords if you use all the pieces.\n\r", ch);
return;
}
argument = one_argument(argument, arg);
if (arg[0] == '\0'
|| ((obj3 = get_obj_carry(ch, arg, ch)) == NULL)
|| (obj3 == obj2 || obj3 == obj)
|| (obj3->pIndexData->vnum != 22721 && obj3->pIndexData->vnum != 22722 && obj3->pIndexData->vnum != 22723))
{
send_to_char("You can only fix broken swords if you use all the pieces.\n\r", ch);
return;
}
if ((obj4 = get_obj_carry(ch, "focusing", ch)) == NULL || obj4->pIndexData->vnum != 22614)
{
send_to_char("You must be carrying a gem of the proper type to bind into this sword.\n\r", ch);
return;
}
if (skill < 100)
{
send_to_char("With a sword this intricate, only a master should even attempt to repair it.\n\r", ch);
return;
}
act("$N masterfully repairs a sword, then touches its hilt with a perfectly-formed diamond.",
ch, NULL, NULL, TO_ROOM);
act("When $e pulls the diamond away, a tiny but perfect copy of it has been left in the hilt of the blade.",
ch, NULL, NULL, TO_ROOM);
act("You masterfully repair a sword, then touch its hilt with a perfectly-formed diamond.",
ch, NULL, NULL, TO_CHAR);
act("When you pull the diamond away, a tiny but perfect copy of it has been left in the hilt of the blade.",
ch, NULL, NULL, TO_CHAR);
extract_obj(obj);
extract_obj(obj2);
extract_obj(obj3);
obj = create_object(get_obj_index(22724), 51);
obj_to_char(obj, ch);
return;
}
if (obj->item_type != ITEM_WEAPON || obj->value[0] != WEAPON_SWORD)
{
send_to_char("You only know how to repair swords.\n\r", ch);
return;
}
if (ch->mana < skill_table[gsn_swordrepair].min_mana)
{
send_to_char("You don't have the mental focus right now to repair a sword.\n\r", ch);
return;
}
if (obj->condition >= 100)
{
send_to_char("That sword is already in excellent shape, but you attempt to hone its edge.\n\r", ch);
impmod = 3;
}
WAIT_STATE(ch, skill_table[gsn_swordrepair].beats);
expend_mana(ch, skill_table[gsn_swordrepair].min_mana);
if (number_percent() < skill)
{
act("Your efforts to repair $p improve it slightly!", ch, obj, NULL, TO_CHAR);
act("$n's efforts to repair $p improve it slightly!", ch, obj, NULL, TO_ROOM);
obj->condition += (impmod == 0 ? 2 : 0);
check_improve(ch, NULL, gsn_swordrepair, TRUE, UMAX(6 + impmod - (obj->level / 10), 1));
}
else
{
if (number_percent() < 50)
{
act("Your efforts to repair $p degrade it slightly!", ch, obj, NULL, TO_CHAR);
act("$n's efforts to repair $p degrade it slightly!", ch, obj, NULL, TO_ROOM);
obj->condition -= 1;
}
else
{
act("Your efforts to repair $p have no effect upon it.", ch, obj, NULL, TO_CHAR);
act("$n's efforts to repair $p have no effect upon it.", ch, obj, NULL, TO_ROOM);
}
check_improve(ch, NULL, gsn_swordrepair, FALSE, UMAX(6 + impmod - (obj->level / 10), 1));
}
}