-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.cpp
7264 lines (6047 loc) · 170 KB
/
commands.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
/***************************************************************************
* 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. *
***************************************************************************/
/*
MurkMUD++ - A Windows compatible, C++ compatible Merc 2.2 Mud.
\author Jon A. Lambert
\date 01/02/2007
\version 1.5
\remarks
This source code copyright (C) 2005, 2006, 2007 by Jon A. Lambert
All rights reserved.
Use governed by the MurkMUD++ public license found in license.murk++
*/
#include "os.hpp"
#include "config.hpp"
#include "globals.hpp"
#include "io.hpp"
#include "utils.hpp"
#include "pcdata.hpp"
#include "affect.hpp"
#include "area.hpp"
#include "room.hpp"
#include "mobproto.hpp"
#include "objproto.hpp"
#include "exit.hpp"
#include "extra.hpp"
#include "object.hpp"
#include "descriptor.hpp"
#include "ban.hpp"
#include "shop.hpp"
#include "reset.hpp"
#include "note.hpp"
#include "database.hpp"
#include "world.hpp"
// Temp externs
extern Room *find_location (Character * ch, const std::string & arg);
extern Character *find_keeper (Character * ch);
extern int get_cost (Character * keeper, Object * obj, bool fBuy);
extern std::string extra_bit_name (int extra_flags);
extern void obj_cast_spell (int sn, int level, Character * ch, Character * victim,
Object * obj);
extern void talk_channel (Character * ch, const std::string & argument, int channel,
const char *verb);
extern void multi_hit(Character *ch, Character *victim, int dt);
extern void say_spell (Character * ch, int sn);
extern void raw_kill (Character * victim);
extern bool is_same_group (Character * ach, Character * bch);
extern std::string affect_loc_name (int location);
extern std::string affect_bit_name (int vector);
extern void mprog_bribe_trigger (Character * mob, Character * ch, int amount);
extern void mprog_speech_trigger (const std::string & txt, Character * mob);
extern void mprog_give_trigger (Character * mob, Character * ch, Object * obj);
extern Object *create_money (int amount);
extern void note_attach (Character * ch);
extern void note_remove (Character * ch, Note * pnote);
extern void damage(Character *ch, Character *victim, int dam, int dt);
extern void check_killer (Character * ch, Character * victim);
extern std::string get_extra_descr (const std::string & name, std::list<ExtraDescription *> & ed);
extern bool is_safe (Character * ch, Character * victim);
extern void disarm (Character * ch, Character * victim);
void Character::do_areas (std::string argument)
{
send_to_char (g_world->list_areas());
return;
}
void Character::do_memory (std::string argument)
{
char buf[MAX_STRING_LENGTH];
snprintf (buf, sizeof buf, "Affects %5d\r\n", Affect::top_affect);
send_to_char (buf);
snprintf (buf, sizeof buf, "Areas %5d\r\n", Area::top_area);
send_to_char (buf);
snprintf (buf, sizeof buf, "ExDes %5d\r\n", ExtraDescription::top_ed);
send_to_char (buf);
snprintf (buf, sizeof buf, "Exits %5d\r\n", Exit::top_exit);
send_to_char (buf);
snprintf (buf, sizeof buf, "Mobs %5d\r\n", MobPrototype::top_mob);
send_to_char (buf);
snprintf (buf, sizeof buf, "Objs %5d\r\n", ObjectPrototype::top_obj);
send_to_char (buf);
snprintf (buf, sizeof buf, "Resets %5d\r\n", Reset::top_reset);
send_to_char (buf);
snprintf (buf, sizeof buf, "Rooms %5d\r\n", Room::top_room);
send_to_char (buf);
snprintf (buf, sizeof buf, "Shops %5d\r\n", Shop::top_shop);
send_to_char (buf);
return;
}
void Character::do_kill (std::string argument)
{
std::string arg;
one_argument (argument, arg);
if (arg.empty()) {
send_to_char ("Kill whom?\r\n");
return;
}
Character *victim;
if ((victim = get_char_room (arg)) == NULL) {
send_to_char ("They aren't here.\r\n");
return;
}
if (!victim->is_npc ()) {
if (!IS_SET (victim->actflags, PLR_KILLER)
&& !IS_SET (victim->actflags, PLR_THIEF)) {
send_to_char ("You must MURDER a player.\r\n");
return;
}
} else {
if (victim->is_affected (AFF_CHARM) && victim->master != NULL) {
send_to_char ("You must MURDER a charmed creature.\r\n");
return;
}
}
if (victim == this) {
send_to_char ("You hit yourself. Ouch!\r\n");
multi_hit (this, this, TYPE_UNDEFINED);
return;
}
if (is_safe (this, victim))
return;
if (is_affected (AFF_CHARM) && master == victim) {
act ("$N is your beloved master.", NULL, victim, TO_CHAR);
return;
}
if (position == POS_FIGHTING) {
send_to_char ("You do the best you can!\r\n");
return;
}
wait_state (1 * PULSE_VIOLENCE);
check_killer (this, victim);
multi_hit (this, victim, TYPE_UNDEFINED);
return;
}
void Character::do_murde (std::string argument)
{
send_to_char ("If you want to MURDER, spell it out.\r\n");
return;
}
void Character::do_murder (std::string argument)
{
std::string arg, buf;
one_argument (argument, arg);
if (arg.empty()) {
send_to_char ("Murder whom?\r\n");
return;
}
Character *victim;
if ((victim = get_char_room (arg)) == NULL) {
send_to_char ("They aren't here.\r\n");
return;
}
if (victim == this) {
send_to_char ("Suicide is a mortal sin.\r\n");
return;
}
if (is_safe (this, victim))
return;
if (is_affected (AFF_CHARM) && master == victim) {
act ("$N is your beloved master.", NULL, victim, TO_CHAR);
return;
}
if (position == POS_FIGHTING) {
send_to_char ("You do the best you can!\r\n");
return;
}
wait_state (1 * PULSE_VIOLENCE);
buf += "Help! I am being attacked by " + name + "!";
victim->do_shout (buf);
check_killer (this, victim);
multi_hit (this, victim, TYPE_UNDEFINED);
return;
}
void Character::do_backstab (std::string argument)
{
std::string arg;
if (!is_npc ()
&& level < skill_table[skill_lookup("backstab")].skill_level[klass]) {
send_to_char ("You better leave the assassin trade to thieves.\r\n");
return;
}
one_argument (argument, arg);
if (arg.empty()) {
send_to_char ("Backstab whom?\r\n");
return;
}
Character *victim;
if ((victim = get_char_room (arg)) == NULL) {
send_to_char ("They aren't here.\r\n");
return;
}
if (victim == this) {
send_to_char ("How can you sneak up on yourself?\r\n");
return;
}
if (is_safe (this, victim))
return;
Object *obj;
if ((obj = get_eq_char (WEAR_WIELD)) == NULL || obj->value[3] != 11) {
send_to_char ("You need to wield a piercing weapon.\r\n");
return;
}
if (victim->fighting != NULL) {
send_to_char ("You can't backstab a fighting person.\r\n");
return;
}
if (victim->hit < victim->max_hit) {
act ("$N is hurt and suspicious ... you can't sneak up.",
NULL, victim, TO_CHAR);
return;
}
check_killer (this, victim);
int bck = skill_lookup("backstab");
wait_state (skill_table[bck].beats);
if (!victim->is_awake ()
|| is_npc ()
|| number_percent () < pcdata->learned[bck])
multi_hit (this, victim, bck);
else
damage (this, victim, 0, bck);
return;
}
void Character::do_flee (std::string argument)
{
if (fighting == NULL) {
if (position == POS_FIGHTING)
position = POS_STANDING;
send_to_char ("You aren't fighting anyone.\r\n");
return;
}
Room *now_in;
Room* was_in = in_room;
for (int attempt = 0; attempt < 6; attempt++) {
Exit *pexit;
int door;
door = number_door ();
if ((pexit = was_in->exit[door]) == 0
|| pexit->to_room == NULL || IS_SET (pexit->exit_info, EX_CLOSED)
|| (is_npc ()
&& (IS_SET (pexit->to_room->room_flags, ROOM_NO_MOB)
|| (IS_SET (actflags, ACT_STAY_AREA)
&& pexit->to_room->area != in_room->area))))
continue;
move_char (door);
if ((now_in = in_room) == was_in)
continue;
in_room = was_in;
act ("$n has fled!", NULL, NULL, TO_ROOM);
in_room = now_in;
if (!is_npc ()) {
send_to_char ("You flee from combat! You lose 25 exps.\r\n");
gain_exp(-25);
}
stop_fighting(true);
return;
}
send_to_char ("You failed! You lose 10 exps.\r\n");
gain_exp(-10);
return;
}
void Character::do_rescue (std::string argument)
{
if (!is_npc ()
&& level < skill_table[skill_lookup("rescue")].skill_level[klass]) {
send_to_char ("You better leave the heroic acts to warriors.\r\n");
return;
}
std::string arg;
one_argument (argument, arg);
if (arg.empty()) {
send_to_char ("Rescue whom?\r\n");
return;
}
Character *victim;
if ((victim = get_char_room (arg)) == NULL) {
send_to_char ("They aren't here.\r\n");
return;
}
if (victim == this) {
send_to_char ("What about fleeing instead?\r\n");
return;
}
if (!is_npc () && victim->is_npc ()) {
send_to_char ("Doesn't need your help!\r\n");
return;
}
if (fighting == victim) {
send_to_char ("Too late.\r\n");
return;
}
Character *fch;
if ((fch = victim->fighting) == NULL) {
send_to_char ("That person is not fighting right now.\r\n");
return;
}
int rsc = skill_lookup("rescue");
wait_state (skill_table[rsc].beats);
if (!is_npc () && number_percent () > pcdata->learned[rsc]) {
send_to_char ("You fail the rescue.\r\n");
return;
}
act ("You rescue $N!", NULL, victim, TO_CHAR);
act ("$n rescues you!", NULL, victim, TO_VICT);
act ("$n rescues $N!", NULL, victim, TO_NOTVICT);
fch->stop_fighting(false);
victim->stop_fighting(false);
check_killer (this, fch);
set_fighting(fch);
fch->set_fighting(this);
return;
}
void Character::do_kick (std::string argument)
{
if (!is_npc ()
&& level < skill_table[skill_lookup("kick")].skill_level[klass]) {
send_to_char ("You better leave the martial arts to fighters.\r\n");
return;
}
Character *victim;
if ((victim = fighting) == NULL) {
send_to_char ("You aren't fighting anyone.\r\n");
return;
}
int kck = skill_lookup("kick");
wait_state (skill_table[kck].beats);
if (is_npc () || number_percent () < pcdata->learned[kck])
damage (this, victim, number_range (1, level), kck);
else
damage (this, victim, 0, kck);
return;
}
void Character::do_disarm (std::string argument)
{
if (!is_npc ()
&& level < skill_table[skill_lookup("disarm")].skill_level[klass]) {
send_to_char ("You don't know how to disarm opponents.\r\n");
return;
}
if (get_eq_char (WEAR_WIELD) == NULL) {
send_to_char ("You must wield a weapon to disarm.\r\n");
return;
}
Character *victim;
if ((victim = fighting) == NULL) {
send_to_char ("You aren't fighting anyone.\r\n");
return;
}
if (victim->get_eq_char (WEAR_WIELD) == NULL) {
send_to_char ("Your opponent is not wielding a weapon.\r\n");
return;
}
wait_state (skill_table[skill_lookup("disarm")].beats);
int percent = number_percent () + victim->level - level;
if (is_npc () || percent < pcdata->learned[skill_lookup("disarm")] * 2 / 3)
disarm (this, victim);
else
send_to_char ("You failed.\r\n");
return;
}
void Character::do_sla (std::string argument)
{
send_to_char ("If you want to SLAY, spell it out.\r\n");
return;
}
void Character::do_slay (std::string argument)
{
std::string arg;
one_argument (argument, arg);
if (arg.empty()) {
send_to_char ("Slay whom?\r\n");
return;
}
Character *victim;
if ((victim = get_char_room (arg)) == NULL) {
send_to_char ("They aren't here.\r\n");
return;
}
if (this == victim) {
send_to_char ("Suicide is a mortal sin.\r\n");
return;
}
if (!victim->is_npc () && victim->level >= level) {
send_to_char ("You failed.\r\n");
return;
}
act ("You slay $M in cold blood!", NULL, victim, TO_CHAR);
act ("$n slays you in cold blood!", NULL, victim, TO_VICT);
act ("$n slays $N in cold blood!", NULL, victim, TO_NOTVICT);
raw_kill (victim);
return;
}
void Character::do_cast (std::string argument)
{
/*
* Only MOBprogrammed mobs not charmed can cast spells
* like PC's
*/
if (is_npc ()
&& (!pIndexData->progtypes || is_affected (AFF_CHARM)))
return;
std::string arg1, arg2;
target_name = one_argument (argument, arg1);
one_argument (target_name, arg2);
if (arg1.empty()) {
send_to_char ("Cast which what where?\r\n");
return;
}
int sn;
if ((sn = skill_lookup (arg1)) < 0
|| (!is_npc () && level < skill_table[sn].skill_level[klass])) {
send_to_char ("You can't do that.\r\n");
return;
}
if (position < skill_table[sn].minimum_position) {
send_to_char ("You can't concentrate enough.\r\n");
return;
}
int mn = mana_cost (sn);
/*
* Locate targets.
*/
Character *victim = NULL;
Object *obj;
void *vo = NULL;
switch (skill_table[sn].target) {
default:
bug_printf ("Do_cast: bad target for sn %d.", sn);
return;
case TAR_IGNORE:
break;
case TAR_CHAR_OFFENSIVE:
if (arg2.empty()) {
if ((victim = fighting) == NULL) {
send_to_char ("Cast the spell on whom?\r\n");
return;
}
} else {
if ((victim = get_char_room (arg2)) == NULL) {
send_to_char ("They aren't here.\r\n");
return;
}
}
vo = (void *) victim;
break;
case TAR_CHAR_DEFENSIVE:
if (arg2.empty()) {
victim = this;
} else {
if ((victim = get_char_room (arg2)) == NULL) {
send_to_char ("They aren't here.\r\n");
return;
}
}
vo = (void *) victim;
break;
case TAR_CHAR_SELF:
if (!arg2.empty() && !is_name (arg2, name)) {
send_to_char ("You cannot cast this spell on another.\r\n");
return;
}
vo = (void *) this;
break;
case TAR_OBJ_INV:
if (arg2.empty()) {
send_to_char ("What should the spell be cast upon?\r\n");
return;
}
if ((obj = get_obj_carry (arg2)) == NULL) {
send_to_char ("You are not carrying that.\r\n");
return;
}
vo = (void *) obj;
break;
}
if (!is_npc () && mana < mn) {
send_to_char ("You don't have enough mana.\r\n");
return;
}
if (str_cmp (skill_table[sn].name, "ventriloquate"))
say_spell (this, sn);
wait_state (skill_table[sn].beats);
if (!is_npc () && number_percent () > pcdata->learned[sn]) {
send_to_char ("You lost your concentration.\r\n");
mana -= mn / 2;
} else {
mana -= mn;
(this->*(skill_table[sn].spell_fun)) (sn, level, vo);
}
if (skill_table[sn].target == TAR_CHAR_OFFENSIVE
&& victim->master != this && victim != this) {
Character *vch;
CharIter rch, next;
for (rch = in_room->people.begin(); rch != in_room->people.end(); rch = next) {
vch = *rch;
next = ++rch;
if (victim == vch && victim->fighting == NULL) {
multi_hit (victim, this, TYPE_UNDEFINED);
break;
}
}
}
return;
}
/* Date stamp idea comes from Alander of ROM */
void Character::do_note (std::string argument)
{
if (is_npc ())
return;
std::string arg, buf1;
argument = one_argument (argument, arg);
smash_tilde (argument);
if (arg.empty()) {
do_note ("read");
return;
}
char buf[MAX_STRING_LENGTH];
int vnum;
int anum;
if (!str_cmp (arg, "list")) {
vnum = 0;
for (std::list<Note*>::iterator p = note_list.begin();
p != note_list.end(); p++) {
if ((*p)->is_note_to (this)) {
snprintf (buf, sizeof buf, "[%3d%s] %s: %s\r\n",
vnum,
((*p)->date_stamp > last_note
&& str_cmp ((*p)->sender, name)) ? "N" : " ",
(*p)->sender.c_str(), (*p)->subject.c_str());
buf1.append(buf);
vnum++;
}
}
send_to_char (buf1);
return;
}
if (!str_cmp (arg, "read")) {
bool fAll;
if (!str_cmp (argument, "all")) {
fAll = true;
anum = 0;
} else if (argument.empty() || !str_prefix (argument, "next"))
/* read next unread note */
{
vnum = 0;
for (std::list<Note*>::iterator p = note_list.begin();
p != note_list.end(); p++) {
if ((*p)->is_note_to (this)
&& str_cmp (name, (*p)->sender)
&& last_note < (*p)->date_stamp) {
snprintf (buf, sizeof buf, "[%3d] %s: %s\r\n%s\r\nTo: %s\r\n",
vnum, (*p)->sender.c_str(), (*p)->subject.c_str(),
(*p)->date.c_str(), (*p)->to_list.c_str());
buf1.append(buf);
buf1.append((*p)->text);
last_note = std::max (last_note, (*p)->date_stamp);
send_to_char (buf1);
return;
} else
vnum++;
}
send_to_char ("You have no unread notes.\r\n");
return;
} else if (is_number (argument)) {
fAll = false;
anum = std::atoi (argument.c_str());
} else {
send_to_char ("Note read which number?\r\n");
return;
}
vnum = 0;
for (std::list<Note*>::iterator p = note_list.begin();
p != note_list.end(); p++) {
if ((*p)->is_note_to (this) && (vnum++ == anum || fAll)) {
snprintf (buf, sizeof buf, "[%3d] %s: %s\r\n%s\r\nTo: %s\r\n",
vnum - 1,
(*p)->sender.c_str(), (*p)->subject.c_str(),
(*p)->date.c_str(), (*p)->to_list.c_str());
buf1.append(buf);
buf1.append((*p)->text);
send_to_char (buf1);
last_note = std::max (last_note, (*p)->date_stamp);
return;
}
}
send_to_char ("No such note.\r\n");
return;
}
if (!str_cmp (arg, "+")) {
note_attach (this);
strncpy (buf, pnote->text.c_str(), sizeof buf);
if (strlen (buf) + argument.size() >= MAX_STRING_LENGTH - 200) {
send_to_char ("Note too long.\r\n");
return;
}
strncat (buf, argument.c_str(), sizeof buf - argument.size());
strncat (buf, "\r\n", sizeof buf - strlen("\r\n"));
pnote->text = buf;
send_to_char ("Ok.\r\n");
return;
}
if (!str_cmp (arg, "subject")) {
note_attach (this);
pnote->subject = argument;
send_to_char ("Ok.\r\n");
return;
}
if (!str_cmp (arg, "to")) {
note_attach (this);
pnote->to_list = argument;
send_to_char ("Ok.\r\n");
return;
}
if (!str_cmp (arg, "clear")) {
if (pnote != NULL) {
delete pnote;
pnote = NULL;
}
send_to_char ("Ok.\r\n");
return;
}
if (!str_cmp (arg, "show")) {
if (pnote == NULL) {
send_to_char ("You have no note in progress.\r\n");
return;
}
snprintf (buf, sizeof buf, "%s: %s\r\nTo: %s\r\n",
pnote->sender.c_str(), pnote->subject.c_str(), pnote->to_list.c_str());
send_to_char (buf);
send_to_char (pnote->text);
return;
}
if (!str_cmp (arg, "post") || !str_prefix (arg, "send")) {
if (pnote == NULL) {
send_to_char ("You have no note in progress.\r\n");
return;
}
if (!str_cmp (pnote->to_list, "")) {
send_to_char
("You need to provide a recipient (name, all, or immortal).\r\n");
return;
}
if (!str_cmp (pnote->subject, "")) {
send_to_char ("You need to provide a subject.\r\n");
return;
}
pnote->date = g_world->get_time_text();
pnote->date_stamp = g_world->get_current_time();
note_list.push_back(pnote);
std::ofstream notefile;
notefile.open (NOTE_FILE, std::ofstream::out | std::ofstream::app | std::ofstream::binary);
if (!notefile.is_open()) {
std::perror (NOTE_FILE);
} else {
notefile << "Sender " << pnote->sender << "~\n";
notefile << "Date " << pnote->date << "~\n";
notefile << "Stamp " << pnote->date_stamp << "\n";
notefile << "To " << pnote->to_list << "~\n";
notefile << "Subject " << pnote->subject << "~\n";
notefile << "Text\n" << pnote->text << "~\n\n";
notefile.close();
}
pnote = NULL;
send_to_char ("Ok.\r\n");
return;
}
if (!str_cmp (arg, "remove")) {
if (!is_number (argument)) {
send_to_char ("Note remove which number?\r\n");
return;
}
anum = std::atoi (argument.c_str());
vnum = 0;
std::list<Note*>::iterator next;
for (std::list<Note*>::iterator p = note_list.begin();
p != note_list.end(); p = next) {
Note* curr = *p;
next = ++p;
if (curr->is_note_to (this) && vnum++ == anum) {
note_remove (this, curr);
send_to_char ("Ok.\r\n");
return;
}
}
send_to_char ("No such note.\r\n");
return;
}
send_to_char ("Huh? Type 'help note' for usage.\r\n");
return;
}
void Character::do_auction (std::string argument)
{
talk_channel (this, argument, CHANNEL_AUCTION, "auction");
return;
}
void Character::do_chat (std::string argument)
{
talk_channel (this, argument, CHANNEL_CHAT, "chat");
return;
}
/*
* Alander's new channels.
*/
void Character::do_music (std::string argument)
{
talk_channel (this, argument, CHANNEL_MUSIC, "music");
return;
}
void Character::do_question (std::string argument)
{
talk_channel (this, argument, CHANNEL_QUESTION, "question");
return;
}
void Character::do_answer (std::string argument)
{
talk_channel (this, argument, CHANNEL_QUESTION, "answer");
return;
}
void Character::do_shout (std::string argument)
{
talk_channel (this, argument, CHANNEL_SHOUT, "shout");
wait_state (12);
return;
}
void Character::do_yell (std::string argument)
{
talk_channel (this, argument, CHANNEL_YELL, "yell");
return;
}
void Character::do_immtalk (std::string argument)
{
talk_channel (this, argument, CHANNEL_IMMTALK, "immtalk");
return;
}
void Character::do_say (std::string argument)
{
if (argument.empty()) {
send_to_char ("Say what?\r\n");
return;
}
act ("$n says '$T'.", NULL, argument.c_str(), TO_ROOM);
act ("You say '$T'.", NULL, argument.c_str(), TO_CHAR);
mprog_speech_trigger (argument, this);
return;
}
void Character::do_tell (std::string argument)
{
if (!is_npc () && IS_SET (actflags, PLR_SILENCE)) {
send_to_char ("Your message didn't get through.\r\n");
return;
}
std::string arg;
argument = one_argument (argument, arg);
if (arg.empty() || argument.empty()) {
send_to_char ("Tell whom what?\r\n");
return;
}
/*
* Can tell to PC's anywhere, but NPC's only in same room.
* -- Furey
*/
Character *victim;
if ((victim = get_char_world (arg)) == NULL
|| (victim->is_npc () && victim->in_room != in_room)) {
send_to_char ("They aren't here.\r\n");
return;
}
if (!is_immortal() && !victim->is_awake ()) {
act ("$E can't hear you.", 0, victim, TO_CHAR);
return;
}
act ("You tell $N '$t'.", argument.c_str(), victim, TO_CHAR);
int savepos = victim->position;
victim->position = POS_STANDING;
act ("$n tells you '$t'.", argument.c_str(), victim, TO_VICT);
victim->position = savepos;
victim->reply = this;
return;
}
void Character::do_reply (std::string argument)
{
if (!is_npc () && IS_SET (actflags, PLR_SILENCE)) {
send_to_char ("Your message didn't get through.\r\n");
return;
}
Character *victim;
if ((victim = reply) == NULL) {
send_to_char ("They aren't here.\r\n");
return;
}
if (!is_immortal() && !victim->is_awake ()) {
act ("$E can't hear you.", 0, victim, TO_CHAR);
return;
}
act ("You tell $N '$t'.", argument.c_str(), victim, TO_CHAR);
int savepos = victim->position;
victim->position = POS_STANDING;
act ("$n tells you '$t'.", argument.c_str(), victim, TO_VICT);
victim->position = savepos;
victim->reply = this;
return;
}
void Character::do_emote (std::string argument)
{
if (!is_npc () && IS_SET (actflags, PLR_NO_EMOTE)) {
send_to_char ("You can't show your emotions.\r\n");
return;
}
if (argument.empty()) {
send_to_char ("Emote what?\r\n");
return;
}
if (isalpha(argument[argument.size()-1]))
argument += ".";
act ("$n $T", NULL, argument.c_str(), TO_ROOM);
act ("$n $T", NULL, argument.c_str(), TO_CHAR);
return;
}
void Character::do_bug (std::string argument)
{
append_file (BUG_FILE, argument);
send_to_char ("Ok. Thanks.\r\n");
return;
}
void Character::do_idea (std::string argument)
{
append_file (IDEA_FILE, argument);