-
Notifications
You must be signed in to change notification settings - Fork 23
/
dg_mobcmd.c
executable file
·1429 lines (1212 loc) · 30.7 KB
/
dg_mobcmd.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
/**************************************************************************
* File: dg_mobcmd.c Part of LuminariMUD *
* Usage: Contains the mobile script commands. *
* *
* $Author: N'Atas-ha/Mark A. Heilpern/egreen/Welcor $ *
* $Date: 2004/10/11 12:07:00$ *
* $Revision: 1.0.14 $ *
**************************************************************************/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "screen.h"
#include "dg_scripts.h"
#include "db.h"
#include "handler.h"
#include "interpreter.h"
#include "comm.h"
#include "spells.h"
#include "constants.h"
#include "genzon.h" /* for real_zone_by_thing */
#include "act.h"
#include "fight.h"
#include "shop.h" /* shop keepers and mhunt */
/* Local file scope functions. */
static void mob_log(char_data *mob, const char *format, ...);
/* attaches mob's name and vnum to msg and sends it to script_log */
static void mob_log(char_data *mob, const char *format, ...)
{
va_list args;
char output[MAX_STRING_LENGTH] = {'\0'};
snprintf(output, sizeof(output), "Mob (%s, VNum %d):: %s",
GET_SHORT(mob), GET_MOB_VNUM(mob), format);
va_start(args, format);
script_vlog(output, args);
va_end(args);
}
/* Macro to determine if a mob is permitted to use these commands. */
#define MOB_OR_IMPL(ch) \
((IS_NPC(ch) && (!(ch)->desc || GET_LEVEL((ch)->desc->original) >= LVL_IMPL)) || (SCRIPT(ch) && TRIGGERS(SCRIPT(ch))))
#define MOB_OR_PLAYER(ch) (GET_LEVEL(ch) > 0)
/* mob commands */
/* prints the argument to all the rooms aroud the mobile */
ACMDU(do_masound)
{
room_rnum was_in_room;
int door;
if (!MOB_OR_IMPL(ch))
{
send_to_char(ch, "Huh?!?\r\n");
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
if (!*argument)
{
mob_log(ch, "masound called with no argument");
return;
}
skip_spaces(&argument);
was_in_room = IN_ROOM(ch);
for (door = 0; door < DIR_COUNT; door++)
{
struct room_direction_data *newexit;
if (((newexit = world[was_in_room].dir_option[door]) != NULL) &&
newexit->to_room != NOWHERE && newexit->to_room != was_in_room)
{
IN_ROOM(ch) = newexit->to_room;
sub_write(argument, ch, TRUE, TO_ROOM);
}
}
IN_ROOM(ch) = was_in_room;
}
/* lets the mobile kill any player or mobile */
ACMD(do_mkill)
{
char arg[MAX_INPUT_LENGTH] = {'\0'};
char_data *victim;
if (!MOB_OR_IMPL(ch))
{
send_to_char(ch, "Huh?!?\r\n");
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
one_argument(argument, arg, sizeof(arg));
if (!*arg)
{
mob_log(ch, "mkill called with no argument");
return;
}
if (*arg == UID_CHAR)
{
if (!(victim = get_char(arg)))
{
mob_log(ch, "mkill: victim (%s) not found", arg);
return;
}
}
else if (!(victim = get_char_room_vis(ch, arg, NULL)))
{
mob_log(ch, "mkill: victim (%s) not found", arg);
return;
}
if (victim == ch)
{
mob_log(ch, "mkill: victim is self");
return;
}
if (!IS_NPC(victim) && PRF_FLAGGED(victim, PRF_NOHASSLE))
{
mob_log(ch, "mkill: target has nohassle on");
return;
}
if (FIGHTING(ch))
{
mob_log(ch, "mkill: already fighting");
return;
}
hit(ch, victim, TYPE_UNDEFINED, DAM_RESERVED_DBC, 0, FALSE);
return;
}
/* Lets the mobile destroy an object in its inventory it can also destroy a
* worn object and it can destroy items using all.xxxxx or just plain all of
* them. */
ACMD(do_mjunk)
{
char arg[MAX_INPUT_LENGTH] = {'\0'};
int pos, junk_all = 0;
obj_data *obj;
obj_data *obj_next;
if (!MOB_OR_IMPL(ch))
{
send_to_char(ch, "Huh?!?\r\n");
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
one_argument(argument, arg, sizeof(arg));
if (!*arg)
{
mob_log(ch, "mjunk called with no argument");
return;
}
if (!str_cmp(arg, "all"))
junk_all = 1;
if ((find_all_dots(arg) != FIND_INDIV) && !junk_all)
{
/* Thanks to Carlos Myers for fixing the line below */
if ((pos = get_obj_pos_in_equip_vis(ch, arg, NULL, ch->equipment)) >= 0)
{
extract_obj(unequip_char(ch, pos));
return;
}
if ((obj = get_obj_in_list_vis(ch, arg, NULL, ch->carrying)) != NULL)
extract_obj(obj);
return;
}
else
{
for (obj = ch->carrying; obj != NULL; obj = obj_next)
{
obj_next = obj->next_content;
if (arg[3] == '\0' || isname(arg + 4, obj->name))
{
extract_obj(obj);
}
}
/* Thanks to Carlos Myers for fixing the line below */
while ((pos = get_obj_pos_in_equip_vis(ch, arg, NULL, ch->equipment)) >= 0)
extract_obj(unequip_char(ch, pos));
}
return;
}
/* prints the message to everyone in the room other than the mob and victim */
ACMDU(do_mechoaround)
{
char arg[MAX_INPUT_LENGTH] = {'\0'};
char_data *victim;
char *p;
if (!MOB_OR_IMPL(ch))
{
send_to_char(ch, "Huh?!?\r\n");
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
p = one_argument_u(argument, arg);
skip_spaces(&p);
if (!*arg)
{
mob_log(ch, "mechoaround called with no argument");
return;
}
if (*arg == UID_CHAR)
{
if (!(victim = get_char(arg)))
{
mob_log(ch, "mechoaround: victim (%s) does not exist", arg);
return;
}
}
else if (!(victim = get_char_room_vis(ch, arg, NULL)))
{
mob_log(ch, "mechoaround: victim (%s) does not exist", arg);
return;
}
sub_write(p, victim, TRUE, TO_ROOM);
}
/* sends the message to only the victim */
ACMDU(do_msend)
{
char arg[MAX_INPUT_LENGTH] = {'\0'};
char_data *victim;
char *p;
if (!MOB_OR_IMPL(ch))
{
send_to_char(ch, "Huh?!?\r\n");
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
p = one_argument_u(argument, arg);
skip_spaces(&p);
if (!*arg)
{
mob_log(ch, "msend called with no argument");
return;
}
if (*arg == UID_CHAR)
{
if (!(victim = get_char(arg)))
{
mob_log(ch, "msend: victim (%s) does not exist", arg);
return;
}
}
else if (!(victim = get_char_room_vis(ch, arg, NULL)))
{
mob_log(ch, "msend: victim (%s) does not exist", arg);
return;
}
sub_write(p, victim, TRUE, TO_CHAR);
}
/* prints the message to the room at large */
ACMDU(do_mecho)
{
char *p;
if (!MOB_OR_IMPL(ch))
{
send_to_char(ch, "Huh?!?\r\n");
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
if (!*argument)
{
mob_log(ch, "mecho called with no arguments");
return;
}
p = argument;
skip_spaces(&p);
sub_write(p, ch, TRUE, TO_ROOM);
sub_write(p, ch, TRUE, TO_CHAR);
}
ACMD(do_mgecho)
{
const char *p;
if (!*argument)
{
mob_log(ch, "mgecho called with no args");
return;
}
p = argument;
skip_spaces_c(&p);
send_to_world(p);
}
ACMD(do_mzoneecho)
{
int zone;
char room_number[MAX_INPUT_LENGTH] = {'\0'}, buf[MAX_INPUT_LENGTH] = {'\0'};
const char *msg;
if (!MOB_OR_IMPL(ch))
{
send_to_char(ch, "Huh?!?\r\n");
return;
}
msg = any_one_arg_c(argument, room_number, sizeof(room_number));
skip_spaces_c(&msg);
if (!*room_number || !*msg)
mob_log(ch, "mzoneecho called with too few args");
else if ((zone = real_zone_by_thing(atoi(room_number))) == NOWHERE)
mob_log(ch, "mzoneecho called for nonexistant zone");
else
{
snprintf(buf, sizeof(buf), "%s\r\n", msg);
send_to_zone(buf, zone);
}
}
/* Lets the mobile load an item or mobile. All items are loaded into
* inventory, unless it is NO-TAKE. */
ACMD(do_mload)
{
char arg1[MAX_INPUT_LENGTH] = {'\0'}, arg2[MAX_INPUT_LENGTH] = {'\0'};
int number = 0;
char_data *mob;
obj_data *object;
const char *target;
char_data *tch;
obj_data *cnt;
int pos;
if (!MOB_OR_IMPL(ch))
{
send_to_char(ch, "Huh?!?\r\n");
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
if (ch->desc && GET_LEVEL(ch->desc->original) < LVL_IMPL)
return;
target = two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2));
if (!*arg1 || !*arg2 || !is_number(arg2) || ((number = atoi(arg2)) < 0))
{
mob_log(ch, "mload: bad syntax");
return;
}
/* load mob to target room - Jamie Nelson, April 13 2004 */
if (is_abbrev(arg1, "mob"))
{
room_rnum rnum;
if (!target || !*target)
{
rnum = IN_ROOM(ch);
}
else
{
if (!isdigit(*target) || (rnum = real_room(atoi(target))) == NOWHERE)
{
mob_log(ch, "mload: room target vnum doesn't exist "
"(loading mob vnum %d to room %s)",
number, target);
return;
}
}
if ((mob = read_mobile(number, VIRTUAL)) == NULL)
{
mob_log(ch, "mload: bad mob vnum");
return;
}
if (ZONE_FLAGGED(GET_ROOM_ZONE(rnum), ZONE_WILDERNESS))
{
X_LOC(mob) = world[rnum].coords[0];
Y_LOC(mob) = world[rnum].coords[1];
}
char_to_room(mob, rnum);
if (SCRIPT(ch))
{ /* It _should_ have, but it might be detached. */
char buf[MAX_INPUT_LENGTH] = {'\0'};
snprintf(buf, sizeof(buf), "%c%ld", UID_CHAR, GET_ID(mob));
add_var(&(SCRIPT(ch)->global_vars), "lastloaded", buf, 0);
}
load_mtrigger(mob);
}
else if (is_abbrev(arg1, "obj"))
{
if ((object = read_object(number, VIRTUAL)) == NULL)
{
mob_log(ch, "mload: bad object vnum");
return;
}
if (SCRIPT(ch))
{ /* It _should_ have, but it might be detached. */
char buf[MAX_INPUT_LENGTH] = {'\0'};
snprintf(buf, sizeof(buf), "%c%ld", UID_CHAR, GET_ID(object));
add_var(&(SCRIPT(ch)->global_vars), "lastloaded", buf, 0);
}
/* special handling to make objects able to load on a person/in a container/worn etc. */
if (!target || !*target)
{
if (CAN_WEAR(object, ITEM_WEAR_TAKE))
{
obj_to_char(object, ch);
}
else
{
obj_to_room(object, IN_ROOM(ch));
}
load_otrigger(object);
return;
}
two_arguments(target, arg1, sizeof(arg1), arg2, sizeof(arg2)); /* recycling ... */
tch = (arg1 != NULL && *arg1 == UID_CHAR) ? get_char(arg1) : get_char_room_vis(ch, arg1, NULL);
if (tch)
{
if (arg2 != NULL && *arg2 && (pos = find_eq_pos_script(arg2)) >= 0 &&
!GET_EQ(tch, pos) && can_wear_on_pos(object, pos))
{
equip_char(tch, object, pos);
load_otrigger(object);
return;
}
obj_to_char(object, tch);
load_otrigger(object);
return;
}
cnt = (arg1 != NULL && *arg1 == UID_CHAR) ? get_obj(arg1) : get_obj_vis(ch, arg1, NULL);
if (cnt && (GET_OBJ_TYPE(cnt) == ITEM_CONTAINER ||
GET_OBJ_TYPE(cnt) == ITEM_AMMO_POUCH))
{
obj_to_obj(object, cnt);
load_otrigger(object);
return;
}
/* neither char nor container found - just dump it in room */
obj_to_room(object, IN_ROOM(ch));
load_otrigger(object);
return;
}
else
mob_log(ch, "mload: bad type");
}
/* Lets the mobile purge all objects and other npcs in the room, or purge a
* specified object or mob in the room. It can purge itself, but this will
* be the last command it does. */
ACMD(do_mpurge)
{
char arg[MAX_INPUT_LENGTH] = {'\0'};
char_data *victim;
obj_data *obj;
if (!MOB_OR_IMPL(ch))
{
send_to_char(ch, "Huh?!?\r\n");
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
if (ch->desc)
if (ch->desc->original)
if (GET_LEVEL(ch->desc->original) < LVL_IMPL)
return;
one_argument(argument, arg, sizeof(arg));
if (!*arg)
{
/* 'purge' */
char_data *vnext;
obj_data *obj_next;
for (victim = world[IN_ROOM(ch)].people; victim; victim = vnext)
{
vnext = victim->next_in_room;
if (IS_NPC(victim) && victim != ch)
extract_char(victim);
}
for (obj = world[IN_ROOM(ch)].contents; obj; obj = obj_next)
{
obj_next = obj->next_content;
extract_obj(obj);
}
return;
}
if (*arg == UID_CHAR)
victim = get_char(arg);
else
victim = get_char_room_vis(ch, arg, NULL);
if (victim == NULL)
{
if (*arg == UID_CHAR)
obj = get_obj(arg);
else
obj = get_obj_vis(ch, arg, NULL);
if (obj)
{
extract_obj(obj);
obj = NULL;
}
else
mob_log(ch, "mpurge: bad argument");
return;
}
if (!IS_NPC(victim))
{
mob_log(ch, "mpurge: purging a PC");
return;
}
if (victim == ch)
dg_owner_purged = 1;
extract_char(victim);
}
/* lets the mobile goto any location it wishes that is not private */
ACMD(do_mgoto)
{
char arg[MAX_INPUT_LENGTH] = {'\0'};
room_rnum location;
if (!MOB_OR_IMPL(ch))
{
send_to_char(ch, "Huh?!?\r\n");
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
one_argument(argument, arg, sizeof(arg));
if (!*arg)
{
mob_log(ch, "mgoto called with no argument");
return;
}
if ((location = find_target_room(ch, arg)) == NOWHERE)
{
mob_log(ch, "mgoto: invalid location");
return;
}
if (FIGHTING(ch))
stop_fighting(ch);
char_from_room(ch);
if (ZONE_FLAGGED(GET_ROOM_ZONE(location), ZONE_WILDERNESS))
{
X_LOC(ch) = world[location].coords[0];
Y_LOC(ch) = world[location].coords[1];
}
char_to_room(ch, location);
enter_wtrigger(&world[IN_ROOM(ch)], ch, -1);
}
/* lets the mobile do a command at another location. Very useful */
ACMDU(do_mat)
{
char arg[MAX_INPUT_LENGTH] = {'\0'};
room_rnum location, original;
int orig_x, orig_y;
if (!MOB_OR_IMPL(ch))
{
send_to_char(ch, "Huh?!?\r\n");
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
argument = one_argument_u(argument, arg);
if (!*arg || !*argument)
{
mob_log(ch, "mat: bad argument");
return;
}
if ((location = find_target_room(ch, arg)) == NOWHERE)
{
mob_log(ch, "mat: invalid location");
return;
}
original = IN_ROOM(ch);
orig_x = X_LOC(ch);
orig_y = Y_LOC(ch);
char_from_room(ch);
if (ZONE_FLAGGED(GET_ROOM_ZONE(location), ZONE_WILDERNESS))
{
X_LOC(ch) = world[location].coords[0];
Y_LOC(ch) = world[location].coords[1];
}
char_to_room(ch, location);
command_interpreter(ch, argument);
/* See if 'ch' still exists before continuing! Handles 'at XXXX quit' case. */
if (IN_ROOM(ch) == location)
{
char_from_room(ch);
X_LOC(ch) = orig_x;
Y_LOC(ch) = orig_y;
char_to_room(ch, original);
}
}
/* Lets the mobile transfer people. The all argument transfers everyone in the
* current room to the specified location. */
ACMD(do_mteleport)
{
char arg1[MAX_INPUT_LENGTH] = {'\0'}, arg2[MAX_INPUT_LENGTH] = {'\0'};
room_rnum target = NOWHERE;
char_data *vict = NULL, *next_ch = NULL;
if (!MOB_OR_IMPL(ch))
{
send_to_char(ch, "Huh?!?\r\n");
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
argument = two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2));
if (!*arg1 || !*arg2)
{
mob_log(ch, "mteleport: bad syntax");
return;
}
target = find_target_room(ch, arg2);
if (target == NOWHERE)
{
mob_log(ch, "mteleport target is an invalid room");
return;
}
if (!str_cmp(arg1, "all"))
{
if (target == IN_ROOM(ch))
{
mob_log(ch, "mteleport all target is itself");
return;
}
for (vict = world[IN_ROOM(ch)].people; vict; vict = next_ch)
{
next_ch = vict->next_in_room;
if (valid_dg_target(vict, DG_ALLOW_STAFFS))
{
char_from_room(vict);
/* check for wilderness movement */
if (ZONE_FLAGGED(GET_ROOM_ZONE(target), ZONE_WILDERNESS))
{
X_LOC(vict) = world[target].coords[0];
Y_LOC(vict) = world[target].coords[1];
}
/* we have to check this carefully! -zusuk */
char_to_room(vict, target);
char_pets_to_char_loc(vict);
enter_wtrigger(&world[IN_ROOM(ch)], ch, -1);
}
}
}
else
{
if (*arg1 == UID_CHAR)
{
if (!(vict = get_char(arg1)))
{
mob_log(ch, "mteleport: victim (%s) does not exist", arg1);
return;
}
}
else if (!(vict = get_char_vis(ch, arg1, NULL, FIND_CHAR_WORLD)))
{
mob_log(ch, "mteleport: victim (%s) does not exist", arg1);
return;
}
if (valid_dg_target(ch, DG_ALLOW_STAFFS))
{
char_from_room(vict);
/* check for wilderness movement */
if (ZONE_FLAGGED(GET_ROOM_ZONE(target), ZONE_WILDERNESS))
{
X_LOC(vict) = world[target].coords[0];
Y_LOC(vict) = world[target].coords[1];
}
/* we have to check this carefully! -zusuk */
char_to_room(vict, target);
char_pets_to_char_loc(ch);
enter_wtrigger(&world[IN_ROOM(ch)], ch, -1);
}
}
}
ACMD(do_mdamage)
{
char name[MAX_INPUT_LENGTH] = {'\0'}, amount[MAX_INPUT_LENGTH] = {'\0'};
int dam = 0;
char_data *vict;
if (!MOB_OR_IMPL(ch))
{
send_to_char(ch, "Huh?!?\r\n");
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
two_arguments(argument, name, sizeof(name), amount, sizeof(amount));
/* who cares if it's a number ? if not it'll just be 0 */
if (!*name || !*amount)
{
mob_log(ch, "mdamage: bad syntax");
return;
}
dam = atoi(amount);
if (*name == UID_CHAR)
{
if (!(vict = get_char(name)))
{
mob_log(ch, "mdamage: victim (%s) does not exist", name);
return;
}
}
else if (!(vict = get_char_room_vis(ch, name, NULL)))
{
mob_log(ch, "mdamage: victim (%s) does not exist", name);
return;
}
script_damage(vict, dam);
}
/* Lets the mobile force someone to do something. must be mortal level and the
* all argument only affects those in the room with the mobile. */
ACMDU(do_mforce)
{
char arg[MAX_INPUT_LENGTH] = {'\0'};
if (!MOB_OR_IMPL(ch))
{
send_to_char(ch, "Huh?!?\r\n");
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
if (ch->desc && (GET_LEVEL(ch->desc->original) < LVL_IMPL))
return;
argument = one_argument_u(argument, arg);
if (!*arg || !*argument)
{
mob_log(ch, "mforce: bad syntax");
return;
}
if (!str_cmp(arg, "all"))
{
struct descriptor_data *i;
char_data *vch;
for (i = descriptor_list; i; i = i->next)
{
if ((i->character != ch) && !i->connected &&
(IN_ROOM(i->character) == IN_ROOM(ch)))
{
vch = i->character;
if (GET_LEVEL(vch) < GET_LEVEL(ch) && CAN_SEE(ch, vch) &&
valid_dg_target(vch, 0))
{
command_interpreter(vch, argument);
}
}
}
}
else
{
char_data *victim;
if (*arg == UID_CHAR)
{
if (!(victim = get_char(arg)))
{
mob_log(ch, "mforce: victim (%s) does not exist", arg);
return;
}
}
else if ((victim = get_char_room_vis(ch, arg, NULL)) == NULL)
{
mob_log(ch, "mforce: no such victim");
return;
}
if (victim == ch)
{
mob_log(ch, "mforce: forcing self");
return;
}
if (valid_dg_target(victim, 0))
command_interpreter(victim, argument);
}
}
/* hunt for someone */
ACMD(do_mhunt)
{
char_data *victim;
char arg[MAX_INPUT_LENGTH] = {'\0'};
if (!MOB_OR_IMPL(ch))
{
send_to_char(ch, "Huh?!?\r\n");
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM))
{
send_to_char(ch, "You are loyal to someone right now, hunting isn't a good idea...\r\n");
return;
}
if (ch->desc && (GET_LEVEL(ch->desc->original) < LVL_IMPL))
{
send_to_char(ch, "Someone is inhabiting your body, you can not hunt right now...\r\n");
return;
}
if (MOB_FLAGGED(ch, MOB_NOKILL))
{
send_to_char(ch, "You are a protected mob, it doesn't make sense for you to hunt!\r\n");
return;
}
one_argument(argument, arg, sizeof(arg));
if (!*arg)
{
mob_log(ch, "mhunt called with no argument");
return;
}
if (FIGHTING(ch))
return;
if (*arg == UID_CHAR)
{
if (!(victim = get_char(arg)))
{
mob_log(ch, "mhunt: victim (%s) does not exist", arg);
return;
}
}
else if (!(victim = get_char_vis(ch, arg, NULL, FIND_CHAR_WORLD)))
{
mob_log(ch, "mhunt: victim (%s) does not exist", arg);
return;
}
/* we have a target now */
if (!ok_damage_shopkeeper(victim, ch))
{
send_to_char(ch, "You are a shopkeeper (that can't be damaged), it doesn't make sense for you to hunt!\r\n");
return;
}
/*
if (!is_mission_mob(victim, ch))
{
send_to_char(ch, "You are a mission mob, it doesn't make sense for you to hunt!\r\n");
return;
}
*/
HUNTING(ch) = victim;
}
/* place someone into the mob's memory list */
ACMD(do_mremember)
{
char_data *victim;
struct script_memory *mem;
char arg[MAX_INPUT_LENGTH] = {'\0'};
if (!MOB_OR_IMPL(ch))
{
send_to_char(ch, "Huh?!?\r\n");
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
if (ch->desc && (GET_LEVEL(ch->desc->original) < LVL_IMPL))
return;
argument = one_argument(argument, arg, sizeof(arg));
if (!*arg)
{
mob_log(ch, "mremember: bad syntax");
return;
}
if (*arg == UID_CHAR)
{
if (!(victim = get_char(arg)))
{
mob_log(ch, "mremember: victim (%s) does not exist", arg);
return;
}
}
else if (!(victim = get_char_vis(ch, arg, NULL, FIND_CHAR_WORLD)))
{
mob_log(ch, "mremember: victim (%s) does not exist", arg);
return;