-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathact.other.c
957 lines (853 loc) · 29.6 KB
/
act.other.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
/**************************************************************************
* File: act.other.c Part of tbaMUD *
* Usage: Miscellaneous player-level commands. *
* *
* All rights reserved. See license for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
**************************************************************************/
/* needed by sysdep.h to allow for definition of <sys/stat.h> */
#define __ACT_OTHER_C__
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "spells.h"
#include "screen.h"
#include "house.h"
#include "constants.h"
#include "dg_scripts.h"
#include "act.h"
#include "spec_procs.h"
#include "class.h"
#include "fight.h"
#include "mail.h" /* for has_mail() */
#include "shop.h"
#include "quest.h"
#include "modify.h"
/* Local defined utility functions */
/* do_group utility functions */
static void print_group(struct char_data *ch);
static void display_group_list(struct char_data * ch);
ACMD(do_quit)
{
if (IS_NPC(ch) || !ch->desc)
return;
if (subcmd != SCMD_QUIT && GET_LEVEL(ch) < LVL_IMMORT)
send_to_char(ch, "You have to type quit--no less, to quit!\r\n");
else if (GET_POS(ch) == POS_FIGHTING)
send_to_char(ch, "No way! You're fighting for your life!\r\n");
else if (GET_POS(ch) < POS_STUNNED) {
send_to_char(ch, "You die before your time...\r\n");
die(ch, NULL);
} else {
act("$n has left the game.", TRUE, ch, 0, 0, TO_ROOM);
mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "%s has quit the game.", GET_NAME(ch));
if (GET_QUEST_TIME(ch) != -1)
quest_timeout(ch);
send_to_char(ch, "Goodbye, friend.. Come back soon!\r\n");
/* We used to check here for duping attempts, but we may as well do it right
* in extract_char(), since there is no check if a player rents out and it
* can leave them in an equally screwy situation. */
if (CONFIG_FREE_RENT)
Crash_rentsave(ch, 0);
GET_LOADROOM(ch) = GET_ROOM_VNUM(IN_ROOM(ch));
/* Stop snooping so you can't see passwords during deletion or change. */
if (ch->desc->snoop_by) {
write_to_output(ch->desc->snoop_by, "Your victim is no longer among us.\r\n");
ch->desc->snoop_by->snooping = NULL;
ch->desc->snoop_by = NULL;
}
extract_char(ch); /* Char is saved before extracting. */
}
}
ACMD(do_save)
{
if (IS_NPC(ch) || !ch->desc)
return;
send_to_char(ch, "Saving %s.\r\n", GET_NAME(ch));
save_char(ch);
Crash_crashsave(ch);
if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_HOUSE_CRASH))
House_crashsave(GET_ROOM_VNUM(IN_ROOM(ch)));
GET_LOADROOM(ch) = GET_ROOM_VNUM(IN_ROOM(ch));
}
/* Generic function for commands which are normally overridden by special
* procedures - i.e., shop commands, mail commands, etc. */
ACMD(do_not_here)
{
send_to_char(ch, "Sorry, but you cannot do that here!\r\n");
}
ACMD(do_sneak)
{
struct affected_type af;
byte percent;
if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_SNEAK)) {
send_to_char(ch, "You have no idea how to do that.\r\n");
return;
}
send_to_char(ch, "Okay, you'll try to move silently for a while.\r\n");
if (AFF_FLAGGED(ch, AFF_SNEAK))
affect_from_char(ch, SKILL_SNEAK);
percent = rand_number(1, 101); /* 101% is a complete failure */
if (percent > GET_SKILL(ch, SKILL_SNEAK) + dex_app_skill[GET_DEX(ch)].sneak)
return;
new_affect(&af);
af.spell = SKILL_SNEAK;
af.duration = GET_LEVEL(ch);
SET_BIT_AR(af.bitvector, AFF_SNEAK);
affect_to_char(ch, &af);
}
ACMD(do_hide)
{
byte percent;
if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_HIDE)) {
send_to_char(ch, "You have no idea how to do that.\r\n");
return;
}
send_to_char(ch, "You attempt to hide yourself.\r\n");
if (AFF_FLAGGED(ch, AFF_HIDE))
REMOVE_BIT_AR(AFF_FLAGS(ch), AFF_HIDE);
percent = rand_number(1, 101); /* 101% is a complete failure */
if (percent > GET_SKILL(ch, SKILL_HIDE) + dex_app_skill[GET_DEX(ch)].hide)
return;
SET_BIT_AR(AFF_FLAGS(ch), AFF_HIDE);
}
ACMD(do_steal)
{
struct char_data *vict;
struct obj_data *obj;
char vict_name[MAX_INPUT_LENGTH], obj_name[MAX_INPUT_LENGTH];
int percent, gold, eq_pos, pcsteal = 0, ohoh = 0;
if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_STEAL)) {
send_to_char(ch, "You have no idea how to do that.\r\n");
return;
}
if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_PEACEFUL)) {
send_to_char(ch, "This room just has such a peaceful, easy feeling...\r\n");
return;
}
two_arguments(argument, obj_name, vict_name);
if (!(vict = get_char_vis(ch, vict_name, NULL, FIND_CHAR_ROOM))) {
send_to_char(ch, "Steal what from who?\r\n");
return;
} else if (vict == ch) {
send_to_char(ch, "Come on now, that's rather stupid!\r\n");
return;
}
/* 101% is a complete failure */
percent = rand_number(1, 101) - dex_app_skill[GET_DEX(ch)].p_pocket;
if (GET_POS(vict) < POS_SLEEPING)
percent = -1; /* ALWAYS SUCCESS, unless heavy object. */
if (!CONFIG_PT_ALLOWED && !IS_NPC(vict))
pcsteal = 1;
if (!AWAKE(vict)) /* Easier to steal from sleeping people. */
percent -= 50;
/* No stealing if not allowed. If it is no stealing from Imm's or Shopkeepers. */
if (GET_LEVEL(vict) >= LVL_IMMORT || pcsteal || GET_MOB_SPEC(vict) == shop_keeper)
percent = 101; /* Failure */
if (str_cmp(obj_name, "coins") && str_cmp(obj_name, "gold")) {
if (!(obj = get_obj_in_list_vis(ch, obj_name, NULL, vict->carrying))) {
for (eq_pos = 0; eq_pos < NUM_WEARS; eq_pos++)
if (GET_EQ(vict, eq_pos) &&
(isname(obj_name, GET_EQ(vict, eq_pos)->name)) &&
CAN_SEE_OBJ(ch, GET_EQ(vict, eq_pos))) {
obj = GET_EQ(vict, eq_pos);
break;
}
if (!obj) {
act("$E hasn't got that item.", FALSE, ch, 0, vict, TO_CHAR);
return;
} else { /* It is equipment */
if ((GET_POS(vict) > POS_STUNNED)) {
send_to_char(ch, "Steal the equipment now? Impossible!\r\n");
return;
} else {
if (!give_otrigger(obj, vict, ch) ||
!receive_mtrigger(ch, vict, obj) ) {
send_to_char(ch, "Impossible!\r\n");
return;
}
act("You unequip $p and steal it.", FALSE, ch, obj, 0, TO_CHAR);
act("$n steals $p from $N.", FALSE, ch, obj, vict, TO_NOTVICT);
obj_to_char(unequip_char(vict, eq_pos), ch);
}
}
} else { /* obj found in inventory */
percent += GET_OBJ_WEIGHT(obj); /* Make heavy harder */
if (percent > GET_SKILL(ch, SKILL_STEAL)) {
ohoh = TRUE;
send_to_char(ch, "Oops..\r\n");
act("$n tried to steal something from you!", FALSE, ch, 0, vict, TO_VICT);
act("$n tries to steal something from $N.", TRUE, ch, 0, vict, TO_NOTVICT);
} else { /* Steal the item */
if (IS_CARRYING_N(ch) + 1 < CAN_CARRY_N(ch)) {
if (!give_otrigger(obj, vict, ch) ||
!receive_mtrigger(ch, vict, obj) ) {
send_to_char(ch, "Impossible!\r\n");
return;
}
if (IS_CARRYING_W(ch) + GET_OBJ_WEIGHT(obj) < CAN_CARRY_W(ch)) {
obj_from_char(obj);
obj_to_char(obj, ch);
send_to_char(ch, "Got it!\r\n");
}
} else
send_to_char(ch, "You cannot carry that much.\r\n");
}
}
} else { /* Steal some coins */
if (AWAKE(vict) && (percent > GET_SKILL(ch, SKILL_STEAL))) {
ohoh = TRUE;
send_to_char(ch, "Oops..\r\n");
act("You discover that $n has $s hands in your wallet.", FALSE, ch, 0, vict, TO_VICT);
act("$n tries to steal gold from $N.", TRUE, ch, 0, vict, TO_NOTVICT);
} else {
/* Steal some gold coins */
gold = (GET_GOLD(vict) * rand_number(1, 10)) / 100;
gold = MIN(1782, gold);
if (gold > 0) {
increase_gold(ch, gold);
decrease_gold(vict, gold);
if (gold > 1)
send_to_char(ch, "Bingo! You got %d gold coins.\r\n", gold);
else
send_to_char(ch, "You manage to swipe a solitary gold coin.\r\n");
} else {
send_to_char(ch, "You couldn't get any gold...\r\n");
}
}
}
if (ohoh && IS_NPC(vict) && AWAKE(vict))
hit(vict, ch, TYPE_UNDEFINED);
}
ACMD(do_practice)
{
char arg[MAX_INPUT_LENGTH];
if (IS_NPC(ch))
return;
one_argument(argument, arg);
if (*arg)
send_to_char(ch, "You can only practice skills in your guild.\r\n");
else
list_skills(ch);
}
ACMD(do_visible)
{
if (GET_LEVEL(ch) >= LVL_IMMORT) {
perform_immort_vis(ch);
return;
}
if AFF_FLAGGED(ch, AFF_INVISIBLE) {
appear(ch);
send_to_char(ch, "You break the spell of invisibility.\r\n");
} else
send_to_char(ch, "You are already visible.\r\n");
}
ACMD(do_title)
{
skip_spaces(&argument);
delete_doubledollar(argument);
parse_at(argument);
if (IS_NPC(ch))
send_to_char(ch, "Your title is fine... go away.\r\n");
else if (PLR_FLAGGED(ch, PLR_NOTITLE))
send_to_char(ch, "You can't title yourself -- you shouldn't have abused it!\r\n");
else if (strstr(argument, "(") || strstr(argument, ")"))
send_to_char(ch, "Titles can't contain the ( or ) characters.\r\n");
else if (strlen(argument) > MAX_TITLE_LENGTH)
send_to_char(ch, "Sorry, titles can't be longer than %d characters.\r\n", MAX_TITLE_LENGTH);
else {
set_title(ch, argument);
send_to_char(ch, "Okay, you're now %s%s%s.\r\n", GET_NAME(ch), *GET_TITLE(ch) ? " " : "", GET_TITLE(ch));
}
}
static void print_group(struct char_data *ch)
{
struct char_data * k;
send_to_char(ch, "Your group consists of:\r\n");
while ((k = (struct char_data *) simple_list(ch->group->members)) != NULL)
send_to_char(ch, "%-*s: %s[%4d/%-4d]H [%4d/%-4d]M [%4d/%-4d]V%s\r\n",
count_color_chars(GET_NAME(k))+22, GET_NAME(k),
GROUP_LEADER(GROUP(ch)) == k ? CBGRN(ch, C_NRM) : CCGRN(ch, C_NRM),
GET_HIT(k), GET_MAX_HIT(k),
GET_MANA(k), GET_MAX_MANA(k),
GET_MOVE(k), GET_MAX_MOVE(k),
CCNRM(ch, C_NRM));
}
static void display_group_list(struct char_data * ch)
{
struct group_data * group;
int count = 0;
if (group_list->iSize) {
send_to_char(ch, "# Group Leader # of Members In Zone\r\n"
"---------------------------------------------------\r\n");
while ((group = (struct group_data *) simple_list(group_list)) != NULL) {
if (IS_SET(GROUP_FLAGS(group), GROUP_NPC))
continue;
if (GROUP_LEADER(group) && !IS_SET(GROUP_FLAGS(group), GROUP_ANON))
send_to_char(ch, "%-2d) %s%-12s %-2d %s%s\r\n",
++count,
IS_SET(GROUP_FLAGS(group), GROUP_OPEN) ? CCGRN(ch, C_NRM) : CCRED(ch, C_NRM),
GET_NAME(GROUP_LEADER(group)), group->members->iSize, zone_table[world[IN_ROOM(GROUP_LEADER(group))].zone].name,
CCNRM(ch, C_NRM));
else
send_to_char(ch, "%-2d) Hidden\r\n", ++count);
}
}
if (count)
send_to_char(ch, "\r\n"
"%sSeeking Members%s\r\n"
"%sClosed%s\r\n",
CCGRN(ch, C_NRM), CCNRM(ch, C_NRM),
CCRED(ch, C_NRM), CCNRM(ch, C_NRM));
else
send_to_char(ch, "\r\n"
"Currently no groups formed.\r\n");
}
/* Vatiken's Group System: Version 1.1 */
ACMD(do_group)
{
char buf[MAX_STRING_LENGTH];
struct char_data *vict;
argument = one_argument(argument, buf);
if (!*buf) {
if (GROUP(ch))
print_group(ch);
else
send_to_char(ch, "You must specify a group option, or type HELP GROUP for more info.\r\n");
return;
}
if (is_abbrev(buf, "new")) {
if (GROUP(ch))
send_to_char(ch, "You are already in a group.\r\n");
else
create_group(ch);
} else if (is_abbrev(buf, "list"))
display_group_list(ch);
else if (is_abbrev(buf, "join")) {
skip_spaces(&argument);
if (!(vict = get_char_vis(ch, argument, NULL, FIND_CHAR_ROOM))) {
send_to_char(ch, "Join who?\r\n");
return;
} else if (vict == ch) {
send_to_char(ch, "That would be one lonely grouping.\r\n");
return;
} else if (GROUP(ch)) {
send_to_char(ch, "But you are already part of a group.\r\n");
return;
} else if (!GROUP(vict)) {
act("$E$u is not a part of a group!", FALSE, ch, 0, vict, TO_CHAR);
return;
} else if (!IS_SET(GROUP_FLAGS(GROUP(vict)), GROUP_OPEN)) {
send_to_char(ch, "That group isn't accepting members.\r\n");
return;
}
join_group(ch, GROUP(vict));
} else if (is_abbrev(buf, "kick")) {
skip_spaces(&argument);
if (!(vict = get_char_vis(ch, argument, NULL, FIND_CHAR_ROOM))) {
send_to_char(ch, "Kick out who?\r\n");
return;
} else if (vict == ch) {
send_to_char(ch, "There are easier ways to leave the group.\r\n");
return;
} else if (!GROUP(ch) ) {
send_to_char(ch, "But you are not part of a group.\r\n");
return;
} else if (GROUP_LEADER(GROUP(ch)) != ch ) {
send_to_char(ch, "Only the group's leader can kick members out.\r\n");
return;
} else if (GROUP(vict) != GROUP(ch)) {
act("$E$u is not a member of your group!", FALSE, ch, 0, vict, TO_CHAR);
return;
}
send_to_char(ch, "You have kicked %s out of the group.\r\n", GET_NAME(vict));
send_to_char(vict, "You have been kicked out of the group.\r\n");
leave_group(vict);
} else if (is_abbrev(buf, "leave")) {
if (!GROUP(ch)) {
send_to_char(ch, "But you aren't apart of a group!\r\n");
return;
}
leave_group(ch);
} else if (is_abbrev(buf, "option")) {
skip_spaces(&argument);
if (!GROUP(ch)) {
send_to_char(ch, "But you aren't part of a group!\r\n");
return;
} else if (GROUP_LEADER(GROUP(ch)) != ch) {
send_to_char(ch, "Only the group leader can adjust the group flags.\r\n");
return;
}
if (is_abbrev(argument, "open")) {
TOGGLE_BIT(GROUP_FLAGS(GROUP(ch)), GROUP_OPEN);
send_to_char(ch, "The group is now %s to new members.\r\n", IS_SET(GROUP_FLAGS(GROUP(ch)), GROUP_OPEN) ? "open" : "closed");
} else if (is_abbrev(argument, "anonymous")) {
TOGGLE_BIT(GROUP_FLAGS(GROUP(ch)), GROUP_ANON);
send_to_char(ch, "The group location is now %s to other players.\r\n", IS_SET(GROUP_FLAGS(GROUP(ch)), GROUP_ANON) ? "invisible" : "visible");
} else
send_to_char(ch, "The flag options are: Open, Anonymous\r\n");
} else {
send_to_char(ch, "You must specify a group option, or type HELP GROUP for more info.\r\n");
}
}
ACMD(do_report)
{
struct group_data *group;
if ((group = GROUP(ch)) == NULL) {
send_to_char(ch, "But you are not a member of any group!\r\n");
return;
}
send_to_group(NULL, group, "%s reports: %d/%dH, %d/%dM, %d/%dV\r\n",
GET_NAME(ch),
GET_HIT(ch), GET_MAX_HIT(ch),
GET_MANA(ch), GET_MAX_MANA(ch),
GET_MOVE(ch), GET_MAX_MOVE(ch));
}
ACMD(do_split)
{
char buf[MAX_INPUT_LENGTH];
int amount, num = 0, share, rest;
size_t len;
struct char_data *k;
if (IS_NPC(ch))
return;
one_argument(argument, buf);
if (is_number(buf)) {
amount = atoi(buf);
if (amount <= 0) {
send_to_char(ch, "Sorry, you can't do that.\r\n");
return;
}
if (amount > GET_GOLD(ch)) {
send_to_char(ch, "You don't seem to have that much gold to split.\r\n");
return;
}
if (GROUP(ch))
while ((k = (struct char_data *) simple_list(GROUP(ch)->members)) != NULL)
if (IN_ROOM(ch) == IN_ROOM(k) && !IS_NPC(k))
num++;
if (num && GROUP(ch)) {
share = amount / num;
rest = amount % num;
} else {
send_to_char(ch, "With whom do you wish to share your gold?\r\n");
return;
}
decrease_gold(ch, share * (num - 1));
/* Abusing signed/unsigned to make sizeof work. */
len = snprintf(buf, sizeof(buf), "%s splits %d coins; you receive %d.\r\n",
GET_NAME(ch), amount, share);
if (rest && len < sizeof(buf)) {
snprintf(buf + len, sizeof(buf) - len,
"%d coin%s %s not splitable, so %s keeps the money.\r\n", rest,
(rest == 1) ? "" : "s", (rest == 1) ? "was" : "were", GET_NAME(ch));
}
while ((k = (struct char_data *) simple_list(GROUP(ch)->members)) != NULL)
if (k != ch && IN_ROOM(ch) == IN_ROOM(k) && !IS_NPC(k)) {
increase_gold(k, share);
send_to_char(k, "%s", buf);
}
send_to_char(ch, "You split %d coins among %d members -- %d coins each.\r\n",
amount, num, share);
if (rest) {
send_to_char(ch, "%d coin%s %s not splitable, so you keep the money.\r\n",
rest, (rest == 1) ? "" : "s", (rest == 1) ? "was" : "were");
increase_gold(ch, rest);
}
} else {
send_to_char(ch, "How many coins do you wish to split with your group?\r\n");
return;
}
}
ACMD(do_use)
{
char buf[MAX_INPUT_LENGTH], arg[MAX_INPUT_LENGTH];
struct obj_data *mag_item;
half_chop(argument, arg, buf);
if (!*arg) {
send_to_char(ch, "What do you want to %s?\r\n", CMD_NAME);
return;
}
mag_item = GET_EQ(ch, WEAR_HOLD);
if (!mag_item || !isname(arg, mag_item->name)) {
switch (subcmd) {
case SCMD_RECITE:
case SCMD_QUAFF:
if (!(mag_item = get_obj_in_list_vis(ch, arg, NULL, ch->carrying))) {
send_to_char(ch, "You don't seem to have %s %s.\r\n", AN(arg), arg);
return;
}
break;
case SCMD_USE:
send_to_char(ch, "You don't seem to be holding %s %s.\r\n", AN(arg), arg);
return;
default:
log("SYSERR: Unknown subcmd %d passed to do_use.", subcmd);
/* SYSERR_DESC: This is the same as the unhandled case in do_gen_ps(),
* but in the function which handles 'quaff', 'recite', and 'use'. */
return;
}
}
switch (subcmd) {
case SCMD_QUAFF:
if (GET_OBJ_TYPE(mag_item) != ITEM_POTION) {
send_to_char(ch, "You can only quaff potions.\r\n");
return;
}
break;
case SCMD_RECITE:
if (GET_OBJ_TYPE(mag_item) != ITEM_SCROLL) {
send_to_char(ch, "You can only recite scrolls.\r\n");
return;
}
break;
case SCMD_USE:
if ((GET_OBJ_TYPE(mag_item) != ITEM_WAND) &&
(GET_OBJ_TYPE(mag_item) != ITEM_STAFF)) {
send_to_char(ch, "You can't seem to figure out how to use it.\r\n");
return;
}
break;
}
mag_objectmagic(ch, mag_item, buf);
}
ACMD(do_display)
{
size_t i;
if (IS_NPC(ch)) {
send_to_char(ch, "Monsters don't need displays. Go away.\r\n");
return;
}
skip_spaces(&argument);
if (!*argument) {
send_to_char(ch, "Usage: prompt { { H | M | V } | all | auto | none }\r\n");
return;
}
if (!str_cmp(argument, "auto")) {
TOGGLE_BIT_AR(PRF_FLAGS(ch), PRF_DISPAUTO);
send_to_char(ch, "Auto prompt %sabled.\r\n", PRF_FLAGGED(ch, PRF_DISPAUTO) ? "en" : "dis");
return;
}
if (!str_cmp(argument, "on") || !str_cmp(argument, "all")) {
SET_BIT_AR(PRF_FLAGS(ch), PRF_DISPHP);
SET_BIT_AR(PRF_FLAGS(ch), PRF_DISPMANA);
SET_BIT_AR(PRF_FLAGS(ch), PRF_DISPMOVE);
} else if (!str_cmp(argument, "off") || !str_cmp(argument, "none")) {
REMOVE_BIT_AR(PRF_FLAGS(ch), PRF_DISPHP);
REMOVE_BIT_AR(PRF_FLAGS(ch), PRF_DISPMANA);
REMOVE_BIT_AR(PRF_FLAGS(ch), PRF_DISPMOVE);
} else {
REMOVE_BIT_AR(PRF_FLAGS(ch), PRF_DISPHP);
REMOVE_BIT_AR(PRF_FLAGS(ch), PRF_DISPMANA);
REMOVE_BIT_AR(PRF_FLAGS(ch), PRF_DISPMOVE);
for (i = 0; i < strlen(argument); i++) {
switch (LOWER(argument[i])) {
case 'h':
SET_BIT_AR(PRF_FLAGS(ch), PRF_DISPHP);
break;
case 'm':
SET_BIT_AR(PRF_FLAGS(ch), PRF_DISPMANA);
break;
case 'v':
SET_BIT_AR(PRF_FLAGS(ch), PRF_DISPMOVE);
break;
default:
send_to_char(ch, "Usage: prompt { { H | M | V } | all | auto | none }\r\n");
return;
}
}
}
send_to_char(ch, "%s", CONFIG_OK);
}
#define TOG_OFF 0
#define TOG_ON 1
ACMD(do_gen_tog)
{
long result;
int i;
char arg[MAX_INPUT_LENGTH];
const char *tog_messages[][2] = {
{"You are now safe from summoning by other players.\r\n",
"You may now be summoned by other players.\r\n"},
{"Nohassle disabled.\r\n",
"Nohassle enabled.\r\n"},
{"Brief mode off.\r\n",
"Brief mode on.\r\n"},
{"Compact mode off.\r\n",
"Compact mode on.\r\n"},
{"You can now hear tells.\r\n",
"You are now deaf to tells.\r\n"},
{"You can now hear auctions.\r\n",
"You are now deaf to auctions.\r\n"},
{"You can now hear shouts.\r\n",
"You are now deaf to shouts.\r\n"},
{"You can now hear gossip.\r\n",
"You are now deaf to gossip.\r\n"},
{"You can now hear the congratulation messages.\r\n",
"You are now deaf to the congratulation messages.\r\n"},
{"You can now hear the Wiz-channel.\r\n",
"You are now deaf to the Wiz-channel.\r\n"},
{"You are no longer part of the Quest.\r\n",
"Okay, you are part of the Quest!\r\n"},
{"You will no longer see the room flags.\r\n",
"You will now see the room flags.\r\n"},
{"You will now have your communication repeated.\r\n",
"You will no longer have your communication repeated.\r\n"},
{"HolyLight mode off.\r\n",
"HolyLight mode on.\r\n"},
{"Nameserver_is_slow changed to NO; IP addresses will now be resolved.\r\n",
"Nameserver_is_slow changed to YES; sitenames will no longer be resolved.\r\n"},
{"Autoexits disabled.\r\n",
"Autoexits enabled.\r\n"},
{"Will no longer track through doors.\r\n",
"Will now track through doors.\r\n"},
{"Will no longer clear screen in OLC.\r\n",
"Will now clear screen in OLC.\r\n"},
{"Buildwalk Off.\r\n",
"Buildwalk On.\r\n"},
{"AFK flag is now off.\r\n",
"AFK flag is now on.\r\n"},
{"Autoloot disabled.\r\n",
"Autoloot enabled.\r\n"},
{"Autogold disabled.\r\n",
"Autogold enabled.\r\n"},
{"Autosplit disabled.\r\n",
"Autosplit enabled.\r\n"},
{"Autosacrifice disabled.\r\n",
"Autosacrifice enabled.\r\n"},
{"Autoassist disabled.\r\n",
"Autoassist enabled.\r\n"},
{"Automap disabled.\r\n",
"Automap enabled.\r\n"},
{"Autokey disabled.\r\n",
"Autokey enabled.\r\n"},
{"Autodoor disabled.\r\n",
"Autodoor enabled.\r\n"}
};
if (IS_NPC(ch))
return;
switch (subcmd) {
case SCMD_NOSUMMON:
result = PRF_TOG_CHK(ch, PRF_SUMMONABLE);
break;
case SCMD_NOHASSLE:
result = PRF_TOG_CHK(ch, PRF_NOHASSLE);
break;
case SCMD_BRIEF:
result = PRF_TOG_CHK(ch, PRF_BRIEF);
break;
case SCMD_COMPACT:
result = PRF_TOG_CHK(ch, PRF_COMPACT);
break;
case SCMD_NOTELL:
result = PRF_TOG_CHK(ch, PRF_NOTELL);
break;
case SCMD_NOAUCTION:
result = PRF_TOG_CHK(ch, PRF_NOAUCT);
break;
case SCMD_NOSHOUT:
result = PRF_TOG_CHK(ch, PRF_NOSHOUT);
break;
case SCMD_NOGOSSIP:
result = PRF_TOG_CHK(ch, PRF_NOGOSS);
break;
case SCMD_NOGRATZ:
result = PRF_TOG_CHK(ch, PRF_NOGRATZ);
break;
case SCMD_NOWIZ:
result = PRF_TOG_CHK(ch, PRF_NOWIZ);
break;
case SCMD_QUEST:
result = PRF_TOG_CHK(ch, PRF_QUEST);
break;
case SCMD_SHOWVNUMS:
result = PRF_TOG_CHK(ch, PRF_SHOWVNUMS);
break;
case SCMD_NOREPEAT:
result = PRF_TOG_CHK(ch, PRF_NOREPEAT);
break;
case SCMD_HOLYLIGHT:
result = PRF_TOG_CHK(ch, PRF_HOLYLIGHT);
break;
case SCMD_AUTOEXIT:
result = PRF_TOG_CHK(ch, PRF_AUTOEXIT);
break;
case SCMD_CLS:
result = PRF_TOG_CHK(ch, PRF_CLS);
break;
case SCMD_BUILDWALK:
if (GET_LEVEL(ch) < LVL_BUILDER) {
send_to_char(ch, "Builders only, sorry.\r\n");
return;
}
result = PRF_TOG_CHK(ch, PRF_BUILDWALK);
if (PRF_FLAGGED(ch, PRF_BUILDWALK)) {
one_argument(argument, arg);
for (i=0; *arg && *(sector_types[i]) != '\n'; i++)
if (is_abbrev(arg, sector_types[i]))
break;
if (*(sector_types[i]) == '\n')
i=0;
GET_BUILDWALK_SECTOR(ch) = i;
send_to_char(ch, "Default sector type is %s\r\n", sector_types[i]);
mudlog(CMP, GET_LEVEL(ch), TRUE,
"OLC: %s turned buildwalk on. Allowed zone %d", GET_NAME(ch), GET_OLC_ZONE(ch));
} else
mudlog(CMP, GET_LEVEL(ch), TRUE,
"OLC: %s turned buildwalk off. Allowed zone %d", GET_NAME(ch), GET_OLC_ZONE(ch));
break;
case SCMD_AFK:
result = PRF_TOG_CHK(ch, PRF_AFK);
if (PRF_FLAGGED(ch, PRF_AFK))
act("$n has gone AFK.", TRUE, ch, 0, 0, TO_ROOM);
else {
act("$n has come back from AFK.", TRUE, ch, 0, 0, TO_ROOM);
if (has_mail(GET_IDNUM(ch)))
send_to_char(ch, "You have mail waiting.\r\n");
}
break;
case SCMD_AUTOLOOT:
result = PRF_TOG_CHK(ch, PRF_AUTOLOOT);
break;
case SCMD_AUTOGOLD:
result = PRF_TOG_CHK(ch, PRF_AUTOGOLD);
break;
case SCMD_AUTOSPLIT:
result = PRF_TOG_CHK(ch, PRF_AUTOSPLIT);
break;
case SCMD_AUTOSAC:
result = PRF_TOG_CHK(ch, PRF_AUTOSAC);
break;
case SCMD_AUTOASSIST:
result = PRF_TOG_CHK(ch, PRF_AUTOASSIST);
break;
case SCMD_AUTOMAP:
result = PRF_TOG_CHK(ch, PRF_AUTOMAP);
break;
case SCMD_AUTOKEY:
result = PRF_TOG_CHK(ch, PRF_AUTOKEY);
break;
case SCMD_AUTODOOR:
result = PRF_TOG_CHK(ch, PRF_AUTODOOR);
break;
default:
log("SYSERR: Unknown subcmd %d in do_gen_toggle.", subcmd);
return;
}
if (result)
send_to_char(ch, "%s", tog_messages[subcmd][TOG_ON]);
else
send_to_char(ch, "%s", tog_messages[subcmd][TOG_OFF]);
return;
}
void show_happyhour(struct char_data *ch)
{
char happyexp[80], happygold[80], happyqp[80];
int secs_left;
if ((IS_HAPPYHOUR) || (GET_LEVEL(ch) >= LVL_GRGOD))
{
if (HAPPY_TIME)
secs_left = ((HAPPY_TIME - 1) * SECS_PER_MUD_HOUR) + next_tick;
else
secs_left = 0;
sprintf(happyqp, "%s+%d%%%s to Questpoints per quest\r\n", CCYEL(ch, C_NRM), HAPPY_QP, CCNRM(ch, C_NRM));
sprintf(happygold, "%s+%d%%%s to Gold gained per kill\r\n", CCYEL(ch, C_NRM), HAPPY_GOLD, CCNRM(ch, C_NRM));
sprintf(happyexp, "%s+%d%%%s to Experience per kill\r\n", CCYEL(ch, C_NRM), HAPPY_EXP, CCNRM(ch, C_NRM));
send_to_char(ch, "tbaMUD Happy Hour!\r\n"
"------------------\r\n"
"%s%s%sTime Remaining: %s%d%s hours %s%d%s mins %s%d%s secs\r\n",
(IS_HAPPYEXP || (GET_LEVEL(ch) >= LVL_GOD)) ? happyexp : "",
(IS_HAPPYGOLD || (GET_LEVEL(ch) >= LVL_GOD)) ? happygold : "",
(IS_HAPPYQP || (GET_LEVEL(ch) >= LVL_GOD)) ? happyqp : "",
CCYEL(ch, C_NRM), (secs_left / 3600), CCNRM(ch, C_NRM),
CCYEL(ch, C_NRM), (secs_left % 3600) / 60, CCNRM(ch, C_NRM),
CCYEL(ch, C_NRM), (secs_left % 60), CCNRM(ch, C_NRM) );
}
else
{
send_to_char(ch, "Sorry, there is currently no happy hour!\r\n");
}
}
ACMD(do_happyhour)
{
char arg[MAX_INPUT_LENGTH], val[MAX_INPUT_LENGTH];
int num;
if (GET_LEVEL(ch) < LVL_GOD)
{
show_happyhour(ch);
return;
}
/* Only Imms get here, so check args */
two_arguments(argument, arg, val);
if (is_abbrev(arg, "experience"))
{
num = MIN(MAX((atoi(val)), 0), 1000);
HAPPY_EXP = num;
send_to_char(ch, "Happy Hour Exp rate set to +%d%%\r\n", HAPPY_EXP);
}
else if ((is_abbrev(arg, "gold")) || (is_abbrev(arg, "coins")))
{
num = MIN(MAX((atoi(val)), 0), 1000);
HAPPY_GOLD = num;
send_to_char(ch, "Happy Hour Gold rate set to +%d%%\r\n", HAPPY_GOLD);
}
else if ((is_abbrev(arg, "time")) || (is_abbrev(arg, "ticks")))
{
num = MIN(MAX((atoi(val)), 0), 1000);
if (HAPPY_TIME && !num)
game_info("Happyhour has been stopped!");
else if (!HAPPY_TIME && num)
game_info("A Happyhour has started!");
HAPPY_TIME = num;
send_to_char(ch, "Happy Hour Time set to %d ticks (%d hours %d mins and %d secs)\r\n",
HAPPY_TIME,
(HAPPY_TIME*SECS_PER_MUD_HOUR)/3600,
((HAPPY_TIME*SECS_PER_MUD_HOUR)%3600) / 60,
(HAPPY_TIME*SECS_PER_MUD_HOUR)%60 );
}
else if ((is_abbrev(arg, "qp")) || (is_abbrev(arg, "questpoints")))
{
num = MIN(MAX((atoi(val)), 0), 1000);
HAPPY_QP = num;
send_to_char(ch, "Happy Hour Questpoints rate set to +%d%%\r\n", HAPPY_QP);
}
else if (is_abbrev(arg, "show"))
{
show_happyhour(ch);
}
else if (is_abbrev(arg, "default"))
{
HAPPY_EXP = 100;
HAPPY_GOLD = 50;
HAPPY_QP = 50;
HAPPY_TIME = 48;
game_info("A Happyhour has started!");
}
else
{
send_to_char(ch, "Usage: %shappyhour %s- show usage (this info)\r\n"
" %shappyhour show %s- display current settings (what mortals see)\r\n"
" %shappyhour time <ticks> %s- set happyhour time and start timer\r\n"
" %shappyhour qp <num> %s- set qp percentage gain\r\n"
" %shappyhour exp <num> %s- set exp percentage gain\r\n"
" %shappyhour gold <num> %s- set gold percentage gain\r\n"
" \tyhappyhour default \tw- sets a default setting for happyhour\r\n\r\n"
"Configure the happyhour settings and start a happyhour.\r\n"
"Currently 1 hour IRL = %d ticks\r\n"
"If no number is specified, 0 (off) is assumed.\r\nThe command \tyhappyhour time\tn will therefore stop the happyhour timer.\r\n",
CCYEL(ch, C_NRM), CCNRM(ch, C_NRM),
CCYEL(ch, C_NRM), CCNRM(ch, C_NRM),
CCYEL(ch, C_NRM), CCNRM(ch, C_NRM),
CCYEL(ch, C_NRM), CCNRM(ch, C_NRM),
CCYEL(ch, C_NRM), CCNRM(ch, C_NRM),
CCYEL(ch, C_NRM), CCNRM(ch, C_NRM),
(3600 / SECS_PER_MUD_HOUR) );
}
}