Repository navigation
Expand file tree
/
Copy pathmisc.c
More file actions
2018 lines (1789 loc) · 48.6 KB
/
Copy pathmisc.c
File metadata and controls
2018 lines (1789 loc) · 48.6 KB
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
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "mud.h"
extern int top_exit;
void do_buyhome( CHAR_DATA *ch, char *argument )
{
ROOM_INDEX_DATA *room;
AREA_DATA *pArea;
PLANET_DATA *planet;
ROOM_INDEX_DATA *rooma;
int cost = 0;
if ( !ch->in_room )
return;
if ( !ch->in_room->area )
{
send_to_char( "> &Rthis is not a safe place to live&w\n\r", ch);
return;
}
planet = ch->in_room->area->planet;
if ( !IS_SET( planet->flags, PLANET_NOCAP ) )
{
if ( !ch->pcdata->clan )
{
send_to_char( "> &Ryou do not belong to an organization&w\n\r", ch );
return;
}
}
else
{
if ( ch->pcdata->clan )
{
send_to_char( "> &Ryou cannot buy a home node in this system&w\n\r", ch );
return;
}
}
if ( IS_NPC(ch) || !ch->pcdata )
return;
if ( ch->plr_home != NULL )
{
cost = 10000;
rooma = ch->plr_home;
STRFREE( rooma->name );
rooma->name = STRALLOC( "unusedhome" );
REMOVE_BIT( rooma->room_flags , ROOM_PLR_HOME );
REMOVE_BIT( rooma->room_flags , ROOM_NOPEDIT );
SET_BIT( rooma->room_flags , ROOM_EMPTY_HOME );
SET_BIT( rooma->room_flags , ROOM_SAFE );
STRFREE( rooma->description );
rooma->description = STRALLOC( "use BUYHOME to buy this node for 10.000 credits. if you do not have a home node yet it will be free." );
if ( rooma->area )
fold_area( rooma->area, rooma->area->filename, FALSE );
}
room = ch->in_room;
for ( pArea = first_bsort; pArea; pArea = pArea->next_sort )
{
if ( room->area == pArea )
{
send_to_char( "&R> this area is not installed yet\n\r&w", ch);
return;
}
}
if ( !IS_SET( room->room_flags , ROOM_EMPTY_HOME ) )
{
send_to_char( "&R> this room is not for sale\n\r&w", ch);
return;
}
if ( ch->gold < cost )
{
send_to_char( "&R> this room costs 10.000 credits\n\r&w", ch);
return;
}
if ( argument[0] == '\0' )
{
send_to_char( "> set the node name - a single-line node description\n\r", ch );
send_to_char( "> syntax: buyhome <node name>\n\r", ch );
send_to_char( "> cost: 10,000c if you do have a home already\n\r", ch );
return;
}
STRFREE( room->name );
room->name = STRALLOC( argument );
STRFREE( room->description );
room->description = STRALLOC( "home, sweet home." );
ch->gold -= cost;
REMOVE_BIT( room->room_flags , ROOM_EMPTY_HOME );
SET_BIT( room->room_flags , ROOM_PLR_HOME );
SET_BIT( room->room_flags , ROOM_NOPEDIT );
fold_area( room->area, room->area->filename, FALSE );
ch->plr_home = room;
do_save( ch , "" );
}
void do_ammo( CHAR_DATA *ch, char *argument )
{
OBJ_DATA *wield;
OBJ_DATA *obj;
bool checkammo = FALSE;
int charge =0;
obj = NULL;
wield = get_eq_char( ch, WEAR_WIELD );
if (wield)
{
obj = get_eq_char( ch, WEAR_DUAL_WIELD );
if (!obj)
obj = get_eq_char( ch, WEAR_HOLD );
}
else
{
wield = get_eq_char( ch, WEAR_HOLD );
obj = NULL;
}
if (!wield || wield->item_type != ITEM_WEAPON )
{
send_to_char( "&R> you do not seem to be holding a weapon\n\r&w", ch);
return;
}
if ( wield->value[3] == WEAPON_BLASTER )
{
if ( obj && obj->item_type != ITEM_AMMO )
{
send_to_char( "&R> your hands are too full to reload your blaster\n\r&w", ch);
return;
}
if (obj)
{
if ( obj->value[0] > wield->value[5] )
{
send_to_char( "> that patch is not suitable for your blaster", ch);
return;
}
unequip_char( ch, obj );
checkammo = TRUE;
charge = obj->value[0];
separate_obj( obj );
extract_obj( obj );
}
else
{
for ( obj = ch->last_carrying; obj; obj = obj->prev_content )
{
if ( obj->item_type == ITEM_AMMO)
{
if ( obj->value[0] > wield->value[5] )
{
send_to_char( "> that patch is not suitable for your blaster", ch);
continue;
}
checkammo = TRUE;
charge = obj->value[0];
separate_obj( obj );
extract_obj( obj );
break;
}
}
}
if (!checkammo)
{
send_to_char( "&R> you do not seem to have any patch to reload your blaster with\n\r&w", ch);
return;
}
ch_printf( ch, "> you patch your blaster\n\r> your blaster is charged with %d shots at high power to %d shots on low\n\r", charge/5, charge );
act( AT_PLAIN, "> $n patches their $p", ch, wield, NULL, TO_ROOM );
}
else
{
if ( obj && obj->item_type != ITEM_BATTERY )
{
send_to_char( "&R> your hands are too full to patch that\n\r&w", ch);
return;
}
if (obj)
{
unequip_char( ch, obj );
checkammo = TRUE;
charge = obj->value[0];
separate_obj( obj );
extract_obj( obj );
}
else
{
for ( obj = ch->last_carrying; obj; obj = obj->prev_content )
{
if ( obj->item_type == ITEM_BATTERY)
{
checkammo = TRUE;
charge = obj->value[0];
separate_obj( obj );
extract_obj( obj );
break;
}
}
}
if (!checkammo)
{
send_to_char( "&R> you do not seem to have a suitable patch\n\r&w", ch);
return;
}
if (wield->value[3] == WEAPON_LIGHTSABER )
{
ch_printf( ch, "> you replace your power cell\n\rYour lightsaber is charged to %d/%d units\n\r", charge, charge );
act( AT_PLAIN, "> $n replaces the power cell in $p", ch, wield, NULL, TO_ROOM );
act( AT_PLAIN, "> $p ignites with a bright glow", ch, wield, NULL, TO_ROOM );
}
else if (wield->value[3] == WEAPON_VIBRO_BLADE )
{
ch_printf( ch, "> you patch your blade\n\r> your blade module is charged to %d/%d units\n\r", charge, charge );
act( AT_PLAIN, "> $n patches their $p", ch, wield, NULL, TO_ROOM );
}
else
{
ch_printf( ch, "> you feel very foolish\n\r" );
act( AT_PLAIN, "> $n tries to patch their $p", ch, wield, NULL, TO_ROOM );
}
}
wield->value[4] = charge;
}
void do_setblaster( CHAR_DATA *ch, char *argument )
{
OBJ_DATA *wield;
OBJ_DATA *wield2;
wield = get_eq_char( ch, WEAR_WIELD );
if( wield && !( wield->item_type == ITEM_WEAPON && wield->value[3] == WEAPON_BLASTER ) )
wield = NULL;
wield2 = get_eq_char( ch, WEAR_DUAL_WIELD );
if( wield2 && !( wield2->item_type == ITEM_WEAPON && wield2->value[3] == WEAPON_BLASTER ) )
wield2 = NULL;
if ( !wield && !wield2 )
{
send_to_char( "&R> you do not seem to be wielding a blaster\n\r&w", ch);
return;
}
if ( argument[0] == '\0' )
{
send_to_char( "&R> syntax: setblaster <full|high|normal|half|low|stun>\n\r&w", ch);
return;
}
if ( wield )
act( AT_PLAIN, "> $n adjusts the settings on $p", ch, wield, NULL, TO_ROOM );
if ( wield2 )
act( AT_PLAIN, "> $n adjusts the settings on $p", ch, wield2, NULL, TO_ROOM );
if ( !str_cmp( argument, "full" ) )
{
if (wield)
{
wield->blaster_setting = BLASTER_FULL;
send_to_char( "&Y> wielded blaster set to full power\n\r&w", ch);
}
if (wield2)
{
wield2->blaster_setting = BLASTER_FULL;
send_to_char( "&Y> dualwielded blaster set to full power\n\r&w", ch);
}
return;
}
if ( !str_cmp( argument, "high" ) )
{
if (wield)
{
wield->blaster_setting = BLASTER_HIGH;
send_to_char( "&Y> wielded blaster set to high power\n\r&w", ch);
}
if (wield2)
{
wield2->blaster_setting = BLASTER_HIGH;
send_to_char( "&Y> dualwielded blaster set to high power\n\r&w", ch);
}
return;
}
if ( !str_cmp( argument, "normal" ) )
{
if (wield)
{
wield->blaster_setting = BLASTER_NORMAL;
send_to_char( "&Y> wielded blaster set to normal power\n\r&w", ch);
}
if (wield2)
{
wield2->blaster_setting = BLASTER_NORMAL;
send_to_char( "&Y> dualwielded blaster set to normal power\n\r&w", ch);
}
return;
}
if ( !str_cmp( argument, "half" ) )
{
if (wield)
{
wield->blaster_setting = BLASTER_HALF;
send_to_char( "&Y> wielded blaster set to half power\n\r&w", ch);
}
if (wield2)
{
wield2->blaster_setting = BLASTER_HALF;
send_to_char( "&Y> dualwielded blaster set to half power\n\r&w", ch);
}
return;
}
if ( !str_cmp( argument, "low" ) )
{
if (wield)
{
wield->blaster_setting = BLASTER_LOW;
send_to_char( "&Y> wielded blaster set to low power\n\r&w", ch);
}
if (wield2)
{
wield2->blaster_setting = BLASTER_LOW;
send_to_char( "&Y> dualwielded blaster set to low power\n\r&w", ch);
}
return;
}
if ( !str_cmp( argument, "stun" ) )
{
if (wield)
{
wield->blaster_setting = BLASTER_STUN;
send_to_char( "&Y> wielded blaster set to stun\n\r&w", ch);
}
if (wield2)
{
wield2->blaster_setting = BLASTER_STUN;
send_to_char( "&Y> dualwielded blaster set to stun\n\r&w", ch);
}
return;
}
else
do_setblaster( ch , "" );
}
void do_use( CHAR_DATA *ch, char *argument )
{
char arg[MAX_INPUT_LENGTH];
char argd[MAX_INPUT_LENGTH];
CHAR_DATA *victim;
OBJ_DATA *device;
OBJ_DATA *obj;
ch_ret retcode;
argument = one_argument( argument, argd );
argument = one_argument( argument, arg );
if ( !str_cmp( arg , "on" ) )
argument = one_argument( argument, arg );
if ( argd[0] == '\0' )
{
send_to_char( "> use what\n\r", ch );
return;
}
if ( ( device = get_eq_char( ch, WEAR_HOLD ) ) == NULL ||
!nifty_is_name(argd, device->name) )
{
return;
}
if ( device->item_type != ITEM_DEVICE )
{
send_to_char( "> you cannot figure out what it is your supposed to do with it\n\r", ch );
return;
}
if ( device->value[2] <= 0 )
{
send_to_char( "> it has no more charge left", ch);
return;
}
obj = NULL;
if ( arg[0] == '\0' )
{
if ( ch->fighting )
{
victim = who_fighting( ch );
}
else
{
send_to_char( "> use on whom or what\n\r", ch );
return;
}
}
else
{
if ( ( victim = get_char_room ( ch, arg ) ) == NULL
&& ( obj = get_obj_here ( ch, arg ) ) == NULL )
{
send_to_char( "> you cannot find your target\n\r", ch );
return;
}
}
WAIT_STATE( ch, 1 * PULSE_VIOLENCE );
if ( device->value[2] > 0 )
{
device->value[2]--;
if ( victim )
{
if ( !oprog_use_trigger( ch, device, victim, NULL, NULL ) )
{
act( AT_MAGIC, "> $n uses $p on $N", ch, device, victim, TO_ROOM );
act( AT_MAGIC, "> you use $p on $N", ch, device, victim, TO_CHAR );
}
}
else
{
if ( !oprog_use_trigger( ch, device, NULL, obj, NULL ) )
{
act( AT_MAGIC, "> $n uses $p on $P", ch, device, obj, TO_ROOM );
act( AT_MAGIC, "> you use $p on $P", ch, device, obj, TO_CHAR );
}
}
retcode = obj_cast_spell( device->value[3], device->value[0], ch, victim, obj );
if ( retcode == rCHAR_DIED || retcode == rBOTH_DIED )
{
bug( "do_use: char died", 0 );
return;
}
}
return;
}
/*
* Fill a container
* Many enhancements added by Thoric (ie: filling non-drink containers)
*/
void do_fill( CHAR_DATA *ch, char *argument )
{
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
OBJ_DATA *obj;
OBJ_DATA *source;
sh_int dest_item, src_item1, src_item2, src_item3, src_item4;
int diff;
bool all = FALSE;
argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
/* munch optional words */
if ( (!str_cmp( arg2, "from" ) || !str_cmp( arg2, "with" ))
&& argument[0] != '\0' )
argument = one_argument( argument, arg2 );
if ( arg1[0] == '\0' )
{
send_to_char( "> fill what\n\r", ch );
return;
}
if ( ms_find_obj(ch) )
return;
if ( ( obj = get_obj_carry( ch, arg1 ) ) == NULL )
{
send_to_char( "> you do not have that item\n\r", ch );
return;
}
else
dest_item = obj->item_type;
src_item1 = src_item2 = src_item3 = src_item4 = -1;
switch( dest_item )
{
default:
act( AT_ACTION, "> $n tries to fill $p", ch, obj, NULL, TO_ROOM );
send_to_char( "> you cannot fill that\n\r", ch );
return;
/* place all fillable item types here */
case ITEM_DRINK_CON:
src_item1 = ITEM_FOUNTAIN;
case ITEM_CONTAINER:
src_item1 = ITEM_CONTAINER; src_item2 = ITEM_CORPSE_NPC;
src_item3 = ITEM_CORPSE_PC; src_item4 = ITEM_CORPSE_NPC; break;
}
if ( dest_item == ITEM_CONTAINER )
{
if ( IS_SET(obj->value[1], CONT_CLOSED) )
{
act( AT_PLAIN, "> the $d is closed", ch, NULL, obj->name, TO_CHAR );
return;
}
if ( get_obj_weight( obj ) / obj->count
>= obj->value[0] )
{
send_to_char( "> it is already full as it can be\n\r", ch );
return;
}
}
else
{
diff = obj->value[0] - obj->value[1];
if ( diff < 1 || obj->value[1] >= obj->value[0] )
{
send_to_char( "> it is already full as it can be\n\r", ch );
return;
}
}
if ( arg2[0] != '\0' )
{
if ( dest_item == ITEM_CONTAINER
&& (!str_cmp( arg2, "all" ) || !str_prefix( "all", arg2 )) )
{
all = TRUE;
source = NULL;
}
else
{
if ( ( source = get_obj_here( ch, arg2 ) ) == NULL )
{
send_to_char( "> you cannot find that item\n\r", ch );
return;
}
}
}
else
source = NULL;
if ( !source )
{
bool found = FALSE;
OBJ_DATA *src_next;
found = FALSE;
separate_obj( obj );
for ( source = ch->in_room->first_content;
source;
source = src_next )
{
src_next = source->next_content;
if (dest_item == ITEM_CONTAINER)
{
if ( !CAN_WEAR(source, ITEM_TAKE)
|| (IS_OBJ_STAT( source, ITEM_PROTOTYPE) && !can_take_proto(ch))
|| ch->carry_weight + get_obj_weight(source) > can_carry_w(ch)
|| (get_obj_weight(source) + get_obj_weight(obj)/obj->count)
> obj->value[0] )
continue;
if ( all && arg2[3] == '.'
&& !nifty_is_name( &arg2[4], source->name ) )
continue;
obj_from_room(source);
if ( source->item_type == ITEM_MONEY )
{
ch->gold += source->value[0];
extract_obj( source );
}
else
obj_to_obj(source, obj);
found = TRUE;
}
else
if (source->item_type == src_item1
|| source->item_type == src_item2
|| source->item_type == src_item3
|| source->item_type == src_item4 )
{
found = TRUE;
break;
}
}
if ( !found )
{
switch( src_item1 )
{
default:
send_to_char( "> there is nothing appropriate here\n\r", ch );
return;
case ITEM_FOUNTAIN:
send_to_char( "> there is no fountain or pool here\n\r", ch );
return;
}
}
if (dest_item == ITEM_CONTAINER)
{
act( AT_ACTION, "> you fill $p", ch, obj, NULL, TO_CHAR );
act( AT_ACTION, "> $n fills $p", ch, obj, NULL, TO_ROOM );
return;
}
}
if (dest_item == ITEM_CONTAINER)
{
OBJ_DATA *otmp, *otmp_next;
char name[MAX_INPUT_LENGTH];
CHAR_DATA *gch;
char *pd;
bool found = FALSE;
if ( source == obj )
{
send_to_char( "> you cannot fill something with itself\n\r", ch );
return;
}
switch( source->item_type )
{
default: /* put something in container */
if ( !source->in_room /* disallow inventory items */
|| !CAN_WEAR(source, ITEM_TAKE)
|| (IS_OBJ_STAT( source, ITEM_PROTOTYPE) && !can_take_proto(ch))
|| ch->carry_weight + get_obj_weight(source) > can_carry_w(ch)
|| (get_obj_weight(source) + get_obj_weight(obj)/obj->count)
> obj->value[0] )
{
send_to_char( "> invalid command\n\r", ch );
return;
}
separate_obj( obj );
act( AT_ACTION, "> you take $P and put it inside $p", ch, obj, source, TO_CHAR );
act( AT_ACTION, "> $n takes $P and puts it inside $p", ch, obj, source, TO_ROOM );
obj_from_room(source);
obj_to_obj(source, obj);
break;
case ITEM_MONEY:
send_to_char( "> invalid command\n\r", ch );
break;
case ITEM_CORPSE_PC:
if ( IS_NPC(ch) )
{
send_to_char( "> invalid command\n\r", ch );
return;
}
pd = source->short_descr;
pd = one_argument( pd, name );
pd = one_argument( pd, name );
pd = one_argument( pd, name );
pd = one_argument( pd, name );
if ( str_cmp( name, ch->name ) && !IS_IMMORTAL(ch) )
{
bool fGroup;
fGroup = FALSE;
for ( gch = first_char; gch; gch = gch->next )
{
if ( !IS_NPC(gch)
&& is_same_group( ch, gch )
&& !str_cmp( name, gch->name ) )
{
fGroup = TRUE;
break;
}
}
if ( !fGroup )
{
send_to_char( "> that is someone else's corpse\n\r", ch );
return;
}
}
case ITEM_CONTAINER:
if ( source->item_type == ITEM_CONTAINER /* do not remove */
&& IS_SET(source->value[1], CONT_CLOSED) )
{
act( AT_PLAIN, "> the $d is closed", ch, NULL, source->name, TO_CHAR );
return;
}
case ITEM_DROID_CORPSE:
case ITEM_CORPSE_NPC:
if ( (otmp=source->first_content) == NULL )
{
send_to_char( "> it is empty\n\r", ch );
return;
}
separate_obj( obj );
for ( ; otmp; otmp = otmp_next )
{
otmp_next = otmp->next_content;
if ( !CAN_WEAR(otmp, ITEM_TAKE)
|| (IS_OBJ_STAT( otmp, ITEM_PROTOTYPE) && !can_take_proto(ch))
|| ch->carry_number + otmp->count > can_carry_n(ch)
|| ch->carry_weight + get_obj_weight(otmp) > can_carry_w(ch)
|| (get_obj_weight(source) + get_obj_weight(obj)/obj->count)
> obj->value[0] )
continue;
obj_from_obj(otmp);
obj_to_obj(otmp, obj);
found = TRUE;
}
if ( found )
{
act( AT_ACTION, "> you fill $p from $P", ch, obj, source, TO_CHAR );
act( AT_ACTION, "> $n fills $p from $P", ch, obj, source, TO_ROOM );
}
else
send_to_char( "> there is nothing appropriate in there\n\r", ch );
break;
}
return;
}
if ( source->value[1] < 1 )
{
send_to_char( "> there's none left\n\r", ch );
return;
}
if ( source->count > 1 && source->item_type != ITEM_FOUNTAIN )
separate_obj( source );
separate_obj( obj );
switch( source->item_type )
{
default:
bug( "do_fill: got bad item type: %d", source->item_type );
send_to_char( "> something went wrong\n\r", ch );
return;
case ITEM_FOUNTAIN:
if ( obj->value[1] != 0 && obj->value[2] != 0 )
{
send_to_char( "> there is already another liquid in it\n\r", ch );
return;
}
obj->value[2] = 0;
obj->value[1] = obj->value[0];
act( AT_ACTION, "> you fill $p from $P", ch, obj, source, TO_CHAR );
act( AT_ACTION, "> $n fills $p from $P", ch, obj, source, TO_ROOM );
return;
case ITEM_DRINK_CON:
if ( obj->value[1] != 0 && obj->value[2] != source->value[2] )
{
send_to_char( "> there is already another liquid in it\n\r", ch );
return;
}
obj->value[2] = source->value[2];
if ( source->value[1] < diff )
diff = source->value[1];
obj->value[1] += diff;
source->value[1] -= diff;
act( AT_ACTION, "> you fill $p from $P", ch, obj, source, TO_CHAR );
act( AT_ACTION, "> $n fills $p from $P", ch, obj, source, TO_ROOM );
return;
}
}
void do_drink( CHAR_DATA *ch, char *argument )
{
char arg[MAX_INPUT_LENGTH];
OBJ_DATA *obj;
int amount;
int liquid;
argument = one_argument( argument, arg );
/* munch optional words */
if ( !str_cmp( arg, "from" ) && argument[0] != '\0' )
argument = one_argument( argument, arg );
if ( arg[0] == '\0' )
{
for ( obj = ch->in_room->first_content; obj; obj = obj->next_content )
if ( (obj->item_type == ITEM_FOUNTAIN) )
break;
if ( !obj )
{
send_to_char( "> drink what\n\r", ch );
return;
}
}
else
{
if ( ( obj = get_obj_here( ch, arg ) ) == NULL )
{
send_to_char( "> you cannot find it\n\r", ch );
return;
}
}
if ( obj->count > 1 && obj->item_type != ITEM_FOUNTAIN )
separate_obj(obj);
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_DRUNK] > 40 )
{
send_to_char( "> you fail to reach your mouth\n\r", ch );
return;
}
switch ( obj->item_type )
{
default:
if ( obj->carried_by == ch )
{
act( AT_ACTION, "> $n lifts $p up to $s mouth and tries to drink from it", ch, obj, NULL, TO_ROOM );
act( AT_ACTION, "> you bring $p up to your mouth and try to drink from it", ch, obj, NULL, TO_CHAR );
}
else
{
act( AT_ACTION, "> $n gets down and tries to drink from $p... (is $e feeling ok?)", ch, obj, NULL, TO_ROOM );
act( AT_ACTION, "> you get down on the ground and try to drink from $p", ch, obj, NULL, TO_CHAR );
}
break;
case ITEM_FOUNTAIN:
if ( !oprog_use_trigger( ch, obj, NULL, NULL, NULL ) )
{
act( AT_ACTION, "> $n drinks from the fountain", ch, NULL, NULL, TO_ROOM );
send_to_char( "> you take a long thirst quenching drink\n\r", ch );
}
if ( !IS_NPC(ch) )
ch->pcdata->condition[COND_THIRST] = 40;
break;
case ITEM_DRINK_CON:
if ( obj->value[1] <= 0 )
{
send_to_char( "> it is already empty\n\r", ch );
return;
}
if ( ( liquid = obj->value[2] ) >= LIQ_MAX )
{
bug( "Do_drink: bad liquid number %d", liquid );
liquid = obj->value[2] = 0;
}
if ( !oprog_use_trigger( ch, obj, NULL, NULL, NULL ) )
{
act( AT_ACTION, "> $n drinks $T from $p",
ch, obj, liq_table[liquid].liq_name, TO_ROOM );
act( AT_ACTION, "> you drink $T from $p",
ch, obj, liq_table[liquid].liq_name, TO_CHAR );
}
amount = 1; /* UMIN(amount, obj->value[1]); */
/* what was this? concentrated drinks? concentrated water
too I suppose... sheesh! */
gain_condition( ch, COND_DRUNK,
amount * liq_table[liquid].liq_affect[COND_DRUNK ] );
gain_condition( ch, COND_FULL,
amount * liq_table[liquid].liq_affect[COND_FULL ] );
gain_condition( ch, COND_THIRST,
amount * liq_table[liquid].liq_affect[COND_THIRST ] );
if ( !IS_NPC(ch) )
{
if ( ch->pcdata->condition[COND_DRUNK] > 24 )
send_to_char( "> you feel quite sloshed\n\r", ch );
else
if ( ch->pcdata->condition[COND_DRUNK] > 18 )
send_to_char( "> you feel very drunk\n\r", ch );
else
if ( ch->pcdata->condition[COND_DRUNK] > 12 )
send_to_char( "> you feel drunk\n\r", ch );
else
if ( ch->pcdata->condition[COND_DRUNK] > 8 )
send_to_char( "> you feel a little drunk\n\r", ch );
else
if ( ch->pcdata->condition[COND_DRUNK] > 5 )
send_to_char( "> you feel light headed\n\r", ch );
if ( ch->pcdata->condition[COND_FULL] > 40 )
send_to_char( "> you are full\n\r", ch );
if ( ch->pcdata->condition[COND_THIRST] > 40 )
send_to_char( "> you feel bloated\n\r", ch );
else
if ( ch->pcdata->condition[COND_THIRST] > 36 )
send_to_char( "> your stomach is sloshing around\n\r", ch );
else
if ( ch->pcdata->condition[COND_THIRST] > 30 )
send_to_char( "> you do not feel thirsty\n\r", ch );
}
if ( obj->value[3] )
{
/* The drink was poisoned! */
AFFECT_DATA af;
act( AT_POISON, "> $n sputters and gags", ch, NULL, NULL, TO_ROOM );
act( AT_POISON, "> you sputter and gag", ch, NULL, NULL, TO_CHAR );
ch->mental_state = URANGE( 20, ch->mental_state + 5, 100 );
af.type = gsn_poison;
af.duration = 3 * obj->value[3];
af.location = APPLY_NONE;
af.modifier = 0;
af.bitvector = AFF_POISON;
affect_join( ch, &af );
}
obj->value[1] -= amount;
break;
}
WAIT_STATE(ch, PULSE_PER_SECOND );
return;
}
void do_eat( CHAR_DATA *ch, char *argument )
{
OBJ_DATA *obj;
int foodcond;
if ( argument[0] == '\0' )
{
send_to_char( "> eat what\n\r", ch );
return;
}
if ( IS_NPC(ch) || ch->pcdata->condition[COND_FULL] > 5 )
if ( ms_find_obj(ch) )
return;
if ( (obj = find_obj(ch, argument, TRUE)) == NULL )
return;
if ( !IS_IMMORTAL(ch) )
{
if ( obj->item_type != ITEM_FOOD )
{
act( AT_ACTION, "> $n starts to nibble on $p ($e must really be hungry)", ch, obj, NULL, TO_ROOM );
act( AT_ACTION, "> you try to nibble on $p", ch, obj, NULL, TO_CHAR );
return;
}
if ( !IS_NPC(ch) && !IS_SET( ch->pcdata->cyber, CYBER_REACTOR ) && ch->pcdata->condition[COND_FULL] > 40 )
{
send_to_char( "> you are too full to eat more\n\r", ch );
return;
}
}
/* required due to object grouping */
separate_obj( obj );
WAIT_STATE( ch, PULSE_PER_SECOND/2 );
if ( obj->in_obj )
{
act( AT_PLAIN, "> you take $p from $P", ch, obj, obj->in_obj, TO_CHAR );
act( AT_PLAIN, "> $n takes $p from $P", ch, obj, obj->in_obj, TO_ROOM );
}
if ( !oprog_use_trigger( ch, obj, NULL, NULL, NULL ) )
{
if ( !obj->action_desc || obj->action_desc[0]=='\0' )
{
act( AT_ACTION, "> $n eats $p", ch, obj, NULL, TO_ROOM );
act( AT_ACTION, "> you eat $p", ch, obj, NULL, TO_CHAR );
}
else
actiondesc( ch, obj, NULL );
}