-
Notifications
You must be signed in to change notification settings - Fork 0
/
mud_comm.cpp
executable file
·2848 lines (2384 loc) · 65.4 KB
/
mud_comm.cpp
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
/****************************************************************************
* [S]imulated [M]edieval [A]dventure multi[U]ser [G]ame | \\._.// *
* -----------------------------------------------------------| (0...0) *
* SMAUG 1.0 (C) 1994, 1995, 1996 by Derek Snider | ).:.( *
* -----------------------------------------------------------| {o o} *
* SMAUG code team: Thoric, Altrag, Blodkai, Narn, Haus, | / ' ' \ *
* Scryn, Rennard, Swordbearer, Gorog, Grishnakh and Tricops |~'~.VxvxV.~'~*
****************************************************************************
* The MUDprograms are heavily based on the original MOBprogram code that *
* was written by N'Atas-ha. *
****************************************************************************/
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include "globals.h"
#include "mud.h"
#include "connection.h"
#include "World.h"
#include "commands.h"
#define BFS_ERROR -1
#define BFS_ALREADY_THERE -2
#define BFS_NO_PATH -3
#define BFS_MARK ROOM_TRACK_MARK
ch_ret simple_damage( CHAR_DATA *ch, CHAR_DATA *victim, int dam, int dt );
const char *mprog_type_to_name( int64 type )
{
if (type==USE_PROG)
return("use_prog"); /* this should be redundant */
switch ( type )
{
case IN_FILE_PROG: return "in_file_prog";
case ACT_PROG: return "act_prog";
case SPEECH_PROG: return "speech_prog";
case RAND_PROG: return "rand_prog";
case FIGHT_PROG: return "fight_prog";
case HITPRCNT_PROG: return "hitprcnt_prog";
case DEATH_PROG: return "death_prog";
case ENTRY_PROG: return "entry_prog";
case GREET_PROG: return "greet_prog";
case GREET_DIR_PROG: return "greet_dir_prog";
case ALL_GREET_PROG: return "all_greet_prog";
case YELL_PROG: return "yell_prog";
case MPWALK_FINISHED_PROG: return "mpwalk_finished_prog";
case GIVE_PROG: return "give_prog";
case BRIBE_PROG: return "bribe_prog";
case HOUR_PROG: return "hour_prog";
case TIME_PROG: return "time_prog";
case WEAR_PROG: return "wear_prog";
case REMOVE_PROG: return "remove_prog";
case SAC_PROG : return "sac_prog";
case LOOK_PROG: return "look_prog";
case EXA_PROG: return "exa_prog";
case ZAP_PROG: return "zap_prog";
case GET_PROG: return "get_prog";
case DROP_PROG: return "drop_prog";
case REPAIR_PROG: return "repair_prog";
case DAMAGE_PROG: return "damage_prog";
case PULL_PROG: return "pull_prog";
case PUSH_PROG: return "push_prog";
case SCRIPT_PROG: return "script_prog";
case SLEEP_PROG: return "sleep_prog";
case REST_PROG: return "rest_prog";
case LEAVE_PROG: return "leave_prog";
case USE_PROG: return "use_prog";
case COMMAND_PROG: return "command_prog";
case STEAL_PROG: return "steal_prog";
case OTHERDEATH_PROG: return "otherdeath_prog";
case SEARCH_PROG: return "search_prog";
default: return "ERROR_PROG";
}
}
/* A trivial rehack of do_mstat. This doesnt show all the data, but just
* enough to identify the mob and give its basic condition. It does however,
* show the MUDprograms which are set.
*/
void do_mpstat(CHAR_DATA *ch, const char* argument)
{
char arg[MAX_INPUT_LENGTH];
MPROG_DATA *mprg;
CHAR_DATA *victim;
int i;
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "MProg stat whom?\n\r", ch );
return;
}
if ( ( victim = get_char_world( ch, arg ) ) == NULL )
{
send_to_char( "They aren't here.\n\r", ch );
return;
}
if ( !IS_NPC( victim ) )
{
send_to_char( "Only Mobiles can have MobPrograms!\n\r", ch);
return;
}
if ( !( victim->pIndexData->progtypes ) )
{
send_to_char( "That Mobile has no Programs set.\n\r", ch);
return;
}
ch_printf( ch, "Name: %s. Vnum: %s.\n\r",
victim->getName().c_str(), vnum_to_dotted(victim->pIndexData->vnum) );
ch_printf( ch, "Short description: %s.\n\rLong description: %s",
victim->getShort(false).c_str(),
victim->longDesc_.length() > 0 ?
victim->longDesc_.c_str() : "(none).\n\r" );
ch_printf( ch, "Hp: %d/%d. Mana: %d/%d. Move: %d/%d. \n\r",
victim->hit, victim->max_hit,
victim->mana, victim->max_mana,
victim->move, victim->max_move );
ch_printf( ch,
"Lv: %d. Class: %d. Align: %d. AC: %d. Gold: %d. Exp: %d.\n\r",
victim->level, victim->Class, victim->alignment,
victim->getAC(), victim->gold, victim->exp );
ch_printf( ch,
"Mpwalk Target -- Vnum: %s -- Ch: %s\n",
vnum_to_dotted(victim->vnum_destination),
victim->GetDestinationChar() ? victim->GetDestinationChar()->getName().c_str() :
"(None)");
for ( i = 1, mprg = victim->pIndexData->mudprogs; mprg; i++, mprg = mprg->next )
ch_printf( ch, "%2d>%s %s\n\r%s\n\r",
i,
mprog_type_to_name( mprg->type ),
mprg->arglist,
mprg->comlist );
return;
}
/* great to have a mob walk to a specific room */
/* --Matthew 1/26/98 Added support for mpwalk char name... */
void do_mpwalk(CHAR_DATA *ch, const char* argument)
{
ROOM_INDEX_DATA *destination;
char arg[MAX_INPUT_LENGTH];
/* Charmed means player might have ordered him! */
if ( IS_AFFECTED( ch, AFF_CHARM ) )
{
return;
}
/* Check to make sure that we are messing with a mob here... */
/* If there is a desc (pc, or switched is the only way), and the */
/* mob is the supermob, then desc is AOK */
if ( !IS_NPC( ch ) || ((ch->GetConnection()) && (ch != supermob)))
{
send_to_char( "Huh?\n\r", ch );
return;
}
/* Get the first argument */
/* Check to see if it is. */
one_argument(argument, arg);
if ( arg[0]=='\0' )
{
send_to_char("No vnum or name supplied\n\r", ch);
return;
}
/* If the argument is a number, then it is a VNUM. */
/* Vnums and name args are handled diff. */
int vnum = dotted_to_vnum(ch->GetInRoom()->vnum, arg);
if ( vnum != -1 ) // -1 == error
{
/* If get_room_index fails (NULL), then the room isn't there */
if ( !(destination = get_room_index(vnum)) )
{
progbug("mpwalk - vnum not found", ch);
send_to_char("That room doesn't exist.\n\r", ch);
return;
}
else
{ /* Else, assign the vnum to ch->vnum_destination */
ch->vnum_destination = vnum;
ch->DestinationCharId = 0;
}
}
else
{ /* Not a number argument, so is it a mob/pc? */
/* If get_char_world fails (NULL), then no char/pc of that name exists. */
ch->DestinationCharId = get_char_world(ch, arg)->GetId();
if ( ch->DestinationCharId == 0 )
{
progbug("mpwalk - victim not found", ch);
ch->DestinationCharId = 0;
ch->vnum_destination = 0;
}
else
{
ch->vnum_destination = ch->GetDestinationChar()->GetInRoom()->vnum;
}
}
}
void auto_walk( CHAR_DATA *ch)
{
ROOM_INDEX_DATA *destination;
ExitData *pexit;
int dir, maxdist;
int current_room;
/* Did we get here by accident? */
if (!ch->vnum_destination && !ch->GetDestinationChar())
{
return;
}
/* Update the vnum if chasing a mob/pc. */
if ( ch->GetDestinationChar() )
{
ch->vnum_destination = ch->GetDestinationChar()->GetInRoom()->vnum;
}
/* While fighting, you get a little distracted... */
if (ch->IsFighting())
{
ch->vnum_destination = 0;
ch->DestinationCharId = 0;
return;
}
/* Nope. Not while charmed. */
if ( IS_AFFECTED( ch, AFF_CHARM ) )
{
return;
}
/* Only time a pc can do this is if he is supermob... */
if (( !IS_NPC( ch ) || ch->GetConnection()) && ( ch != supermob ))
{
ch->vnum_destination = 0;
ch->DestinationCharId = 0;
return;
}
/* The room is gone? */
if (!(destination = get_room_index(ch->vnum_destination)))
{
mpwalk_finished_trigger(ch, FALSE);
ch->vnum_destination = 0;
ch->DestinationCharId = 0;
return;
}
/* While your sleeping, you can't walk. */
/* When you wake up, you've forgotten... */
if ( ch->position < POS_SLEEPING )
{
mpwalk_finished_trigger(ch, FALSE);
ch->vnum_destination = 0;
ch->DestinationCharId = 0;
return;
}
/* You will, however, remember to stand! */
if ( ch->position < POS_STANDING )
{
do_stand (ch, "");
}
dir = 0;
maxdist = 10000 + ch->level * 30;
dir = find_first_step(ch->GetInRoom(), destination, maxdist);
switch(dir)
{
case BFS_ALREADY_THERE:
{
mpwalk_finished_trigger(ch, TRUE);
ch->vnum_destination = 0;
ch->DestinationCharId = 0;
return;
}
case BFS_ERROR:
{
send_to_char("Hmm... something seems to be wrong.\n\r", ch);
progbug( "auto_walk - BFS_ERROR", ch );
mpwalk_finished_trigger(ch, FALSE);
ch->vnum_destination = 0;
ch->DestinationCharId = 0;
return;
}
case BFS_NO_PATH:
{
mpwalk_finished_trigger(ch, FALSE);
act( AT_ACTION, "$n sighs.", ch, NULL, NULL, TO_ROOM );
ch->vnum_destination = 0;
ch->DestinationCharId = 0;
return;
}
default:
{ /* The code comes to here if the exit is found */
current_room = ch->GetInRoom()->vnum;
pexit = get_exit( ch->GetInRoom(), dir );
/* Is the door locked? */
if ( IS_SET(pexit->exit_info, EX_LOCKED) )
{
/* If it is, then skip it */
if ( !has_key( ch, pexit->key) || !IS_SET(pexit->exit_info, EX_SECRET))
{
/* Change it to just ch->vnum_dest = 0, ch->ch_dest = NULL if you want. */
mpwalk_finished_trigger(ch, FALSE);
ch->vnum_destination = 0;
ch->DestinationCharId = 0;
return;
}
else
{ /* Kewl, he has the key! */
send_to_char( "*Click*\n\r", ch );
act( AT_ACTION, "$n unlocks the $d.", ch, NULL, pexit->keyword_.c_str(), TO_ROOM );
remove_bexit_flag( pexit, EX_LOCKED );
}
}
mob_open(ch, pexit);
/* Check to see if the way is blocked and if the mob can open it*/
move_char( ch, get_exit( ch->GetInRoom(), dir ), 0 );
if (current_room == ch->GetInRoom()->vnum)
{
mpwalk_finished_trigger(ch, TRUE);
ch->vnum_destination = 0;
ch->DestinationCharId = 0;
return;
}
break;
}
}
return;
}
/* Opstat - Scryn 8/12*/
void do_opstat(CHAR_DATA *ch, const char* argument)
{
char arg[MAX_INPUT_LENGTH];
MPROG_DATA *mprg;
OBJ_DATA *obj;
int i;
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "OProg stat what?\n\r", ch );
return;
}
if ( ( obj = get_obj_world( ch, arg ) ) == NULL )
{
send_to_char( "You cannot find that.\n\r", ch );
return;
}
if ( !( obj->pIndexData->progtypes ) )
{
send_to_char( "That object has no programs set.\n\r", ch);
return;
}
ch_printf( ch, "Name: %s. Vnum: %s.\n\r",
obj->name_.c_str(), vnum_to_dotted(obj->pIndexData->vnum) );
ch_printf( ch, "Short description: %s.\n\r",
obj->shortDesc_.c_str() );
for ( i = 1, mprg = obj->pIndexData->mudprogs; mprg; mprg = mprg->next, i++ )
ch_printf( ch, "%2d>%s %s\n\r%s\n\r",
i,
mprog_type_to_name( mprg->type ),
mprg->arglist,
mprg->comlist );
return;
}
/* Rpstat - Scryn 8/12 */
void do_rpstat(CHAR_DATA *ch, const char* argument)
{
MPROG_DATA *mprg;
int i;
if ( !( ch->GetInRoom()->progtypes ) )
{
send_to_char( "This room has no programs set.\n\r", ch);
return;
}
ch_printf( ch, "Name: %s. Vnum: %s.\n\r",
ch->GetInRoom()->name_.c_str(), vnum_to_dotted(ch->GetInRoom()->vnum) );
for ( i = 1, mprg = ch->GetInRoom()->mudprogs; mprg; mprg = mprg->next, i++ )
ch_printf( ch, "%2d>%s %s\n\r%s\n\r",
i,
mprog_type_to_name( mprg->type ),
mprg->arglist,
mprg->comlist );
return;
}
/* Prints the argument to all the rooms around the mobile */
void do_mpasound(CHAR_DATA *ch, const char* argument)
{
ROOM_INDEX_DATA *was_in_room;
ExitData *pexit;
int actflags;
if (!ch )
{
bug("Nonexistent ch in do_mpasound!",0);
return;
}
if ( IS_AFFECTED( ch, AFF_CHARM ) )
return;
if ( !IS_NPC( ch ) )
{
send_to_char( "Huh?\n\r", ch );
return;
}
if ( argument[0] == '\0' )
{
progbug( "Mpasound - No argument", ch );
return;
}
actflags = ch->act;
REMOVE_BIT(ch->act, ACT_SECRETIVE);
was_in_room = ch->GetInRoom();
for ( pexit = was_in_room->first_exit; pexit; pexit = pexit->next )
{
if ( pexit->to_room
&& pexit->to_room != was_in_room )
{
ch->InRoomId = pexit->to_room->GetId();
MOBtrigger = FALSE;
act( AT_SAY, argument, ch, NULL, NULL, TO_ROOM );
}
}
ch->act = actflags;
ch->InRoomId = was_in_room->GetId();
return;
}
/* lets the mobile kill any player or mobile without murder*/
void do_mpkill(CHAR_DATA *ch, const char* argument)
{
char arg[ MAX_INPUT_LENGTH ];
CHAR_DATA *victim;
if (!ch )
{
bug( "Nonexistent ch in do_mpkill!", 0 );
return;
}
if ( IS_AFFECTED( ch, AFF_CHARM ) )
return;
if ( !IS_NPC( ch ) )
{
send_to_char( "Huh?\n\r", ch );
return;
}
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
progbug( "MpKill - no argument", ch );
return;
}
if ( ( victim = get_char_room( ch, arg ) ) == NULL )
{
progbug( "MpKill - Victim not in room", ch );
return;
}
if ( victim == ch )
{
progbug( "MpKill - Bad victim to attack", ch );
return;
}
if ( IS_AFFECTED( ch, AFF_CHARM ) && ch->MasterId == victim->GetId() )
{
progbug( "MpKill - Charmed mob attacking master", ch );
return;
}
if ( ch->position == POS_FIGHTING )
{
progbug( "MpKill - Already fighting", ch );
return;
}
multi_hit( ch, victim, TYPE_UNDEFINED );
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 */
void do_mpjunk(CHAR_DATA *ch, const char* argument)
{
char arg[ MAX_INPUT_LENGTH ];
OBJ_DATA *obj;
OBJ_DATA *obj_next;
if ( IS_AFFECTED( ch, AFF_CHARM ) )
return;
if (!ch)
{
progbug("Mpjunk - being called with ch argument!!!", supermob );
return;
}
if ( !IS_NPC( ch ) )
{
send_to_char( "Huh?\n\r", ch );
return;
}
if ( ch == supermob )
{
OBJ_DATA * in_obj;
/*
* If the person calling us is the supermob, then
* the object calling mpjunk is the spare pointer, set in
* set_supermob. (If it was a room calling mpjunk,
* then mppurge should have been used, oops.)
*/
if (supermob->tempnum != TEMPNUM_OBJ)
{
progbug( "Mpjunk - not being called from an object, but supermob exists!", ch );
return;
}
obj = (OBJ_DATA *) supermob->spare_ptr;
for ( in_obj = obj; in_obj->GetInObj(); in_obj = in_obj->GetInObj())
; // get the topmost object
Character * newch = in_obj->GetCarriedBy();
if ( !newch )
{
progbug( "Mpjunk - could not find who carries object!", ch);
return;
}
ch = newch;
}
one_argument( argument, arg );
if ( arg[0] == '\0')
{
progbug( "Mpjunk - No argument", ch );
return;
}
if ( str_cmp( arg, "all" ) && str_prefix( "all.", arg ) )
{
if ( ( obj = get_obj_wear( ch, arg ) ) != NULL )
{
unequip_char( ch, obj );
extract_obj( obj, TRUE );
return;
}
if ( ( obj = get_obj_carry( ch, arg ) ) == NULL )
return;
extract_obj( obj, TRUE );
}
else
{
for ( obj = ch->first_carrying; obj; obj = obj_next )
{
obj_next = obj->next_content;
if ( arg[3] == '\0' || is_name( &arg[4], obj->name_.c_str() ) )
{
if ( obj->wear_loc != WEAR_NONE)
unequip_char( ch, obj );
extract_obj( obj, TRUE );
}
}
return;
}
}
/*
* This function examines a text string to see if the first "word" is a
* color indicator (e.g. _red, _whi_, _blu). - Gorog
*/
int get_color(const char *argument) /* get color code from command string */
{
char color[MAX_INPUT_LENGTH];
const char *cptr;
static const char * color_list =
"_bla_blo_dgr_ora_dbl_pur_cya_gry_dgy_red_gre_ylw_blu_pnk_lbl_wht"
"_foo_pla_act_say_gos_yel_tel_hit_htm_imm_hrt_fal_dng_mag_con_rep"
"_poi_soc_dyn_ded_skl_crn_dmg_fle_rmn_rmd_obj_prs_lst_bye_gld_gtl"
"_nte_hng_tst_fir_sbr_wer_ext_scr_rst_log_dim_war_ana_mse_tnk_avt"
"_ooc";
static const char * blink_list =
"*bla*blo*dgr*ora*dbl*pur*cya*gry*dgy*red*gre*ylw*blu*pnk*lbl*wht"
"*foo*pla*act*say*gos*yel*tel*hit*htm*imm*hrt*fal*dng*mag*con*rep"
"*poi*soc*dyn*ded*skl*crn*dmg*fle*rmn*rmd*obj*prs*lst*bye*gld*gtl"
"*nte*hng*tst*fir*sbr*wer*ext*scr*rst*log*dim*war*ana*mse*tnk*avt"
"*ooc";
one_argument (argument, color);
if (color[0]!='_' && color[0]!='*') return 0;
if ( (cptr = strstr(color_list, color)) )
return (cptr - color_list) / 4;
if ( (cptr = strstr(blink_list, color)) )
return (cptr - blink_list) / 4 + AT_BLINK;
return 0;
}
/* prints the message to all players in the area - Ksilyan */
void do_mpareaecho(CHAR_DATA * ch, const char* argument)
{
char arg[MAX_INPUT_LENGTH];
CHAR_DATA * vch;
int actflags;
sh_int color;
if ( !IS_NPC(ch) )
{
send_to_char( "Huh?\n\r", ch);
return;
}
actflags = ch->act;
REMOVE_BIT(ch->act, ACT_SECRETIVE);
if ( argument[0] == '\0' )
{
progbug( "Mpechoarea: no argument", ch );
return;
}
itorSocketId itor;
for ( itor = gTheWorld->GetBeginConnection(); itor != gTheWorld->GetEndConnection(); itor++ )
{
// we know that the world's player connection list only holds player connections IDs,
// so we can safely cast it to PlayerConnection*
PlayerConnection * d = (PlayerConnection *) SocketMap[*itor];
vch = d->GetCharacter();
if (!vch)
continue;
if ( ch->GetInRoom()->area == vch->GetInRoom()->area )
{
if ( (color = get_color(argument)) )
{
argument = one_argument( argument, arg );
act( color, argument, ch, NULL, vch, TO_VICT );
}
else
act( AT_ACTION, argument, ch, NULL, vch, TO_VICT );
}
}
ch->act = actflags;
return;
}
/* prints the message to everyone in the room other than the mob and victim */
void do_mpechoaround(CHAR_DATA *ch, const char* argument)
{
char arg[ MAX_INPUT_LENGTH ];
CHAR_DATA *victim;
int actflags;
sh_int color;
if ( IS_AFFECTED( ch, AFF_CHARM ) )
return;
if ( !IS_NPC( ch ) )
{
send_to_char( "Huh?\n\r", ch );
return;
}
argument = one_argument( argument, arg );
if ( arg[0] == '\0' )
{
progbug( "Mpechoaround - No argument", ch );
return;
}
if ( !( victim=get_char_room( ch, arg ) ) )
{
progbug( "Mpechoaround - victim does not exist", ch );
return;
}
actflags = ch->act;
REMOVE_BIT(ch->act, ACT_SECRETIVE);
if ( (color = get_color(argument)) )
{
argument = one_argument( argument, arg );
act( color, argument, ch, NULL, victim, TO_NOTVICT );
}
else
act( AT_ACTION, argument, ch, NULL, victim, TO_NOTVICT );
ch->act = actflags;
}
/* prints message only to victim */
void do_mpechoat(CHAR_DATA *ch, const char* argument)
{
char arg[ MAX_INPUT_LENGTH ];
CHAR_DATA *victim;
int actflags;
sh_int color;
if ( IS_AFFECTED( ch, AFF_CHARM ) )
return;
if ( !IS_NPC( ch ) )
{
send_to_char( "Huh?\n\r", ch );
return;
}
argument = one_argument( argument, arg );
if ( arg[0] == '\0' || argument[0] == '\0' )
{
progbug( "Mpechoat - No argument", ch );
return;
}
if ( !( victim = get_char_room( ch, arg ) ) )
{
progbug( "Mpechoat - victim does not exist", ch );
return;
}
actflags = ch->act;
REMOVE_BIT(ch->act, ACT_SECRETIVE);
if ( (color = get_color(argument)) )
{
argument = one_argument( argument, arg );
act( color, argument, ch, NULL, victim, TO_VICT );
}
else
act( AT_ACTION, argument, ch, NULL, victim, TO_VICT );
ch->act = actflags;
}
/* prints message to room at large. */
void do_mpecho(CHAR_DATA *ch, const char* argument)
{
char arg1 [MAX_INPUT_LENGTH];
sh_int color;
int actflags;
if ( IS_AFFECTED( ch, AFF_CHARM ) )
return;
if ( !IS_NPC(ch) )
{
send_to_char( "Huh?\n\r", ch );
return;
}
if ( argument[0] == '\0' )
{
progbug( "Mpecho - called w/o argument", ch );
return;
}
actflags = ch->act;
REMOVE_BIT(ch->act, ACT_SECRETIVE);
if ( (color = get_color(argument)) )
{
argument = one_argument ( argument, arg1 );
act( color, argument, ch, NULL, NULL, TO_ROOM );
}
else
act( AT_ACTION, argument, ch, NULL, NULL, TO_ROOM );
ch->act = actflags;
}
/* lets the mobile load an item or mobile. All items
are loaded into inventory. you can specify a level with
the load object portion as well. */
void do_mpmload(CHAR_DATA *ch, const char* argument)
{
char arg[ MAX_INPUT_LENGTH ];
MOB_INDEX_DATA *pMobIndex;
CHAR_DATA *victim;
if ( IS_AFFECTED( ch, AFF_CHARM ) )
return;
if ( !IS_NPC( ch ) )
{
send_to_char( "Huh?\n\r", ch );
return;
}
one_argument( argument, arg );
if ( arg[0] == '\0' || (dotted_to_vnum(ch->GetInRoom()->vnum, arg) <= 0) )
{
progbug( "Mpmload - Bad vnum as arg", ch );
return;
}
if ( ( pMobIndex = get_mob_index( dotted_to_vnum(ch->GetInRoom()->vnum, arg) ) ) == NULL )
{
progbug( "Mpmload - Bad mob vnum", ch );
return;
}
victim = create_mobile( pMobIndex );
char_to_room( victim, ch->GetInRoom() );
return;
}
void do_mpoload(CHAR_DATA *ch, const char* argument)
{
char arg1[ MAX_INPUT_LENGTH ];
char arg2[ MAX_INPUT_LENGTH ];
OBJ_INDEX_DATA *pObjIndex;
OBJ_DATA *obj;
int level;
int timer = 0;
int vnum;
if ( IS_AFFECTED( ch, AFF_CHARM ) )
return;
if ( !IS_NPC( ch ) )
{
send_to_char( "Huh?\n\r", ch );
return;
}
argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
vnum = dotted_to_vnum(ch->GetInRoom()->vnum, arg1);
if ( arg1[0] == '\0' || vnum == -1 )
{
progbug( "Mpoload - Bad syntax", ch );
return;
}
if ( arg2[0] == '\0' )
level = get_trust( ch );
else
{
/*
* New feature from Alander.
*/
if ( !is_number( arg2 ) )
{
progbug( "Mpoload - Bad level syntax", ch );
return;
}
level = atoi( arg2 );
if ( level < 0 || level > get_trust( ch ) )
{
progbug( "Mpoload - Bad level", ch );
return;
}
/*
* New feature from Thoric.
*/
timer = atoi( argument );
if ( timer < 0 )
{
progbug( "Mpoload - Bad timer", ch );
return;
}
}
if ( ( pObjIndex = get_obj_index( vnum ) ) == NULL )
{
progbug( "Mpoload - Bad vnum arg", ch );
return;
}
obj = create_object( pObjIndex, level );
obj->timer = timer;
if ( CAN_WEAR(obj, ITEM_TAKE) )
obj_to_char( obj, ch );
else
obj_to_room( obj, ch->GetInRoom() );
return;
}
/* 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 had best be the last command in the MUDprogram
otherwise ugly stuff will happen */
void do_mppurge(CHAR_DATA *ch, const char* argument)
{
char arg[ MAX_INPUT_LENGTH ];
CHAR_DATA *victim;
OBJ_DATA *obj;
if ( IS_AFFECTED( ch, AFF_CHARM ) )
return;
if ( !IS_NPC( ch ) )
{
send_to_char( "Huh?\n\r", ch );
return;
}
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
/* 'purge' */
CHAR_DATA *vnext;
for ( victim = ch->GetInRoom()->first_person; victim; victim = vnext )
{
vnext = victim->next_in_room;
if ( IS_NPC( victim ) && victim != ch )
extract_char( victim, TRUE );
}
while ( ch->GetInRoom()->first_content )
extract_obj( ch->GetInRoom()->first_content, TRUE );
return;
}
if ( (victim = get_char_room( ch, arg )) == NULL )
{
if ( (obj = get_obj_here( ch, arg )) != NULL )
{
extract_obj( obj, TRUE );
}
else
{
progbug( "Mppurge - Bad argument", ch );
}
return;
}
if ( !IS_NPC( victim ) )