Files
tbamud/src/act.comm.c
Rumble ebc985f010 jeremyosborne | 2008-04-04 02:36:38 +0200 (Fri, 04 Apr 2008) | 1 line
Minor Bugfix: All game configuration settings now reference the world config 
structure, not the individual config variables found in config.c.
------------------------------------------------------------------------
 rumble | 2008-03-22 13:27:00 +0100 (Sat, 22 Mar 2008) | 1 line

Added lib/world/qst/ directory, index, index.mini, and 0.qst.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-08 03:27:51 +0100 (Sat, 08 Mar 2008) | 3 lines

Bugfix: the include directory (for .h files) is now referenced correctly in the
depend statement.
Deletion: listrent.c removed as a separate utility.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-08 03:08:51 +0100 (Sat, 08 Mar 2008) | 1 line

Enhancement: utils/ Makefile will now use a depends file, and looks for dependen
cies in the ../ directory (shrinks the necessary information to make each utilit
y).
------------------------------------------------------------------------
 Rumble | 2008-03-06 23:39:35 +0100 (Thu, 06 Mar 2008) | 1 line

Made TBA specific changes. do_cheat, removed help level checking, and advance to
level 32.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 18:37:12 +0100 (Thu, 06 Mar 2008) | 1 line

Minor Update: Changed header of Makefile.in to read 'tbaMUD' and also added in a
ttribution for the changes. (Thanks seqwith.)
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 18:31:07 +0100 (Thu, 06 Mar 2008) | 4 lines

Changed Makefile.in to use glob expressions when building the objects. This 
translates into no longer a need to update Makefile.in whenever a new .c file 
is added to the mud code. Other Makefile.* have not yet been changed (and 
need review, anyway).

All CXREF cruft left in Makefile.in has been removed. tbaMUD is now using 
Doxygen. Technically, CXREF provides a bit more auto-documentation than Doxygen
does, however the tbaMUD (and legacy circle code) has never been marked-up with 
the special CXREF codes required to effectively use the program. Since Doxygen 
is easier to use, and provides almost as much functionality as CXREF, CXREF 
support has been dropped.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 08:31:02 +0100 (Thu, 06 Mar 2008) | 1 line

Bug Fix: asciiflag_conv* functions now can handle a negative numeric value.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 08:16:06 +0100 (Thu, 06 Mar 2008) | 1 line

Bug fix/enhancement: Charmed mobs (specifically charmed mobs with a ->master) 
will no longer attempt to wander off.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 08:13:38 +0100 (Thu, 06 Mar 2008) | 6 lines

Based on the compiler warning about mag_materials being an unused function, and
the clone spell being unused.

Bug fix: Clone can now be cast. It is an 'ignore' target spell.

Fix and Modification: Clone, being an effectively unused spell that is only used
by mortal Magic Users at level 30, is now implemented as very simple example of
how to use mag_materials(). The item required by mag_materials is vnum 161, 
which in stock tbaMUD is some sacrificial entrails.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-05 01:43:09 +0100 (Wed, 05 Mar 2008) | 3 lines

Bug Fix for "Did you mean:" including DG commands.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-05 01:29:18 +0100 (Wed, 05 Mar 2008) | 3 lines

Bug Fix: do_simple_move slightly rewritten to handle Leave triggers that purge a
 door.

Documentation: do_simple_move documented.
------------------------------------------------------------------------
 Laoris | 2008-03-01 08:22:12 +0100 (Sat, 01 Mar 2008) | 1 line

Trial run of columnizer function on commands list to see how people like it.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-26 22:36:17 +0100 (Tue, 26 Feb 2008) | 1 line

asciimap, an in game automap, along with a couple of minor bug fixes to do with
the automap, patched in (Thanks Jamdog).
------------------------------------------------------------------------
 jeremyosborne | 2008-02-22 04:08:05 +0100 (Fri, 22 Feb 2008) | 1 line

Minor update: Relocate local variable declaration to the top of ACMD(do_help)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-22 04:04:37 +0100 (Fri, 22 Feb 2008) | 6 lines

Checked in the following placeholders for do_gen_tog:
#define SCMD_AUTOLOOT   24
#define SCMD_AUTOGOLD   25
#define SCMD_AUTOSPLIT  26
#define SCMD_AUTOSAC    27
#define SCMD_AUTOASSIST 28
------------------------------------------------------------------------
 jeremyosborne | 2008-02-22 03:57:06 +0100 (Fri, 22 Feb 2008) | 1 line

The Autoquest patch, along with a couple of minor bug fixes, has been integrated
into tbaMUD. (Thanks Jamdog, Kenneth Ray and Morgaelin.)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-18 21:46:45 +0100 (Mon, 18 Feb 2008) | 2 lines

Minor Fix:
Casted NOWHERE, NOTHING, NOBODY and NOFLAG as IDXTYPE for the signed short int 
index types.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-18 03:36:16 +0100 (Mon, 18 Feb 2008) | 7 lines

Added a new atoidx() conversion function for dealing with string to IDXTYPE 
conversions (in utils.c, prototype exported through utils.h).
Added IDXTYPE_MIN and IDXTYPE_MAX defines (in structs.h).
Replaced atoi references with atoidx in do_oasis_zedit (in zedit.c).
------------------------------------------------------------------------
 Rumble | 2008-02-18 01:44:13 +0100 (Mon, 18 Feb 2008) | 1 line

Fixed direction mapping to give readable directions instead of sub commands. 
------------------------------------------------------------------------
 jeremyosborne | 2008-02-18 00:26:15 +0100 (Mon, 18 Feb 2008) | 5 lines

Since general olc editing are automatically saved to disk, 'shutdown reboot' has
been changed to not-autosave by default. (Small change made to do_shutdown in 
act.wizard.c).
------------------------------------------------------------------------
 jeremyosborne | 2008-02-18 00:12:12 +0100 (Mon, 18 Feb 2008) | 3 lines

Changed:
struct attack_hit_type moved to fight.h
attack_hit_text exported through fight.h
------------------------------------------------------------------------
 jeremyosborne | 2008-02-17 22:32:51 +0100 (Sun, 17 Feb 2008) | 7 lines

- do_file heads or tails files correctly and has also been enhanced to return 
file info (act.wizard.c)
- defines made for common log files created by autorun, and those used by 
do_file (db.h)
- utility functions added: file_head(), file_tail(), file_sizeof(), and 
file_numlines() (defined utils.c and exported through utils.h)
------------------------------------------------------------------------
 Rumble | 2008-02-16 23:24:05 +0100 (Sat, 16 Feb 2008) | 1 line

Fixed export command. (thanks Kyle)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-16 22:42:46 +0100 (Sat, 16 Feb 2008) | 1 line

Files are now tagged as executable. Should be able to be checked out from subver
sion and executed without running chmod.
------------------------------------------------------------------------
 Rumble | 2008-02-15 17:03:06 +0100 (Fri, 15 Feb 2008) | 1 line

 Fixed strcat() writing out of bounds in cedit.c since strdup() only malloc() 
strlen(str)+1 bytes. (thanks Buggo) and moved attack_hit_text back.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-13 20:41:02 +0100 (Wed, 13 Feb 2008) | 1 line

Event queue function definitions, global variables and defines doxygenated.
------------------------------------------------------------------------
 Rumble | 2008-02-12 00:23:38 +0100 (Tue, 12 Feb 2008) | 1 line

Updated levels command to use an arg/range and added color parsing to greetings.
 (thanks Jamdog)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-11 21:06:10 +0100 (Mon, 11 Feb 2008) | 1 line

Doxygen comments completed for weather.c
------------------------------------------------------------------------
 Rumble | 2008-02-11 03:52:50 +0100 (Mon, 11 Feb 2008) | 1 line

Corrected several 64-bit warnings. (thanks Buggo)
------------------------------------------------------------------------
 Rumble | 2008-02-10 22:56:56 +0100 (Sun, 10 Feb 2008) | 1 line

Added get_flag_by_name allowing for new trigedit variable checks like 
%actor.pref(FLAG)% checks. (thanks Jamdog)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-08 21:22:26 +0100 (Fri, 08 Feb 2008) | 3 lines

COMPLETE: tbaMUD code re-org of global and local scope function and variable 
declarations. There may be a few things that I did not catch (some non extern 
keyword declarations of function prototypes within other functions, for 
example).

BUG FIX: Unused functions encrypt_hex() and decrypt_hex() removed from mail.c.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-05 23:31:09 +0100 (Tue, 05 Feb 2008) | 2 lines

Continued clean-up of 'extern' references to functions and variables.
BUG UNCOVERED: set_title() in class.c incorrectly handles the const nature of 
the char * returned from title_female and title_male.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-05 19:38:17 +0100 (Tue, 05 Feb 2008) | 3 lines

More work on mud clean-up.
New file: spec_procs.h
Created this file to house the legacy special procedures (spec_procs.c and 
castle.c) and special feature assignment in general.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-05 00:59:44 +0100 (Tue, 05 Feb 2008) | 3 lines

- Minor Bugfix: Fixed parse error in mobact.c
- Minor Bugfix: act.h is now included in all of the act functions. Forgot to do
that the first time :(
- Additions: ban.h has been added as the external entry point into the ban.c 
globals and functions. Files needing ban.h have been updated.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-04 20:02:11 +0100 (Mon, 04 Feb 2008) | 1 line

All act*.c functions, defines and globals have been prototyped/declared in 
act.h. The file act.h does not contain every ACMD, only those ACMDs and 
utility functions available within the act*.c files.
------------------------------------------------------------------------
 Rumble | 2008-02-04 17:59:47 +0100 (Mon, 04 Feb 2008) | 1 line

Fixed the last few flags missed for the 128 bit conversion.
------------------------------------------------------------------------
 Laoris | 2008-02-04 07:27:56 +0100 (Mon, 04 Feb 2008) | 3 lines

Adding a column formatter for lists.  Accepts printf-like arguments.
Only used by medit right now.

------------------------------------------------------------------------
 jeremyosborne | 2008-02-04 07:09:19 +0100 (Mon, 04 Feb 2008) | 2 lines

- Changed the 'struct queue' to 'struct dg_queue' to avoid namespace conflicts.
- Ongoing cleanup to mud project.
------------------------------------------------------------------------
 Rumble | 2008-02-04 00:07:09 +0100 (Mon, 04 Feb 2008) | 1 line

Fixed run_autowiz which ran twice on advancement.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-03 03:46:22 +0100 (Sun, 03 Feb 2008) | 1 line

act.h created and added. This header will be the external entry point for the 
functions, function subcommands and variables within the act*.c files. It is 
not designed to be the entry point for all ACMD functions.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-03 02:44:29 +0100 (Sun, 03 Feb 2008) | 1 line

Merge of another part of the code cleanup, the dg script stuff.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-02 08:56:03 +0100 (Sat, 02 Feb 2008) | 1 line

Modularizing and organizing files continues. Committing comm.c and comm.h 
because they are hairy, and I don't want to do them over if my hard drive 
crashes.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-02 07:05:08 +0100 (Sat, 02 Feb 2008) | 4 lines

- Marking all file scope functions as 'static'
- Reorganization of the global variables and functions.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-31 10:20:47 +0100 (Thu, 31 Jan 2008) | 1 line

* Protected the conf.h.* system config files from multiple calls.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-31 09:56:18 +0100 (Thu, 31 Jan 2008) | 1 line

* Removed extraneous references to TRUE / FALSE and YES / NO defines.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-31 09:46:20 +0100 (Thu, 31 Jan 2008) | 2 lines

* BUGFIX: NUM_POSITIONS set to 8 (was incorrectly set to 15 before)
* Migrated NUM_* settings from oasis.h to more appropriate locations near where
they are defined. (For Example: NUM_POSITIONS moved to structs.h next to the 
POSITION_* defines.)
------------------------------------------------------------------------
 jeremyosborne | 2008-01-31 03:58:28 +0100 (Thu, 31 Jan 2008) | 1 line

Added Appendix A - Coder Support. Right now, it simply speaks to the fact that 
we have included doxygen config files, are working to document the source code, 
and provides a rudimentary "do this" guide to create the doxygen cross 
references.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-30 07:12:07 +0100 (Wed, 30 Jan 2008) | 2 lines

- All .h files now have doxygen recognized headers, and the format is slightly 
altered to ease editing of headers.
- Protected all .h files from multiple calls. (Standard format is #ifndef _HEADE
R_H_ #define _HEADER_H_ .... #endif)
------------------------------------------------------------------------
 jeremyosborne | 2008-01-29 11:18:14 +0100 (Tue, 29 Jan 2008) | 1 line

constants.h, structs.h and utils.h now protected from multiple includes. This is
 sometimes overkill, but good practice overall.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-29 10:38:18 +0100 (Tue, 29 Jan 2008) | 1 line

Updated documentation for constants.c and constants.h.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-29 10:15:25 +0100 (Tue, 29 Jan 2008) | 3 lines

The standard Doxygen configuration doxyfiles (config files) for tbaMUD. One is 
to be used with the Graphviz DOT (dox_withGraphs), one is designed to be used if
Graphviz is not available.

Now just need a short document describing the usage of doxygen.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-29 10:11:36 +0100 (Tue, 29 Jan 2008) | 1 line

Minor document correction in struct dex_app_tpe.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-28 20:53:51 +0100 (Mon, 28 Jan 2008) | 1 line

*bugfix* do_drink command: When a container is empty, the correct, "It is 
empty." message is now displayed.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-28 07:58:15 +0100 (Mon, 28 Jan 2008) | 3 lines

Merging changes to trunk for:
* utils.h, utils.c and structs.h doxygen comments
* adding file dox_withGraphs.doxyfile
2008-04-12 01:31:58 +00:00

573 lines
18 KiB
C

/**************************************************************************
* File: act.comm.c Part of tbaMUD *
* Usage: Player-level communication 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. *
**************************************************************************/
#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 "screen.h"
#include "improved-edit.h"
#include "dg_scripts.h"
#include "act.h"
#include "modify.h"
/* prototypes of local functions */
/* do_tell utility functions */
static void perform_tell(struct char_data *ch, struct char_data *vict, char *arg);
static int is_tell_ok(struct char_data *ch, struct char_data *vict);
ACMD(do_say)
{
skip_spaces(&argument);
if (!*argument)
send_to_char(ch, "Yes, but WHAT do you want to say?\r\n");
else {
char buf[MAX_INPUT_LENGTH + 14], *msg;
struct char_data *vict;
snprintf(buf, sizeof(buf), "$n@n says, '%s@n'", argument);
msg = act(buf, FALSE, ch, 0, 0, TO_ROOM | DG_NO_TRIG);
for (vict = world[IN_ROOM(ch)].people; vict; vict = vict->next_in_room)
if (vict != ch && GET_POS(vict) > POS_SLEEPING)
add_history(vict, msg, HIST_SAY);
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", CONFIG_OK);
else {
sprintf(buf, "You say, '%s@n'", argument);
msg = act(buf, FALSE, ch, 0, 0, TO_CHAR | DG_NO_TRIG);
add_history(ch, msg, HIST_SAY);
}
}
/* trigger check */
speech_mtrigger(ch, argument);
speech_wtrigger(ch, argument);
}
ACMD(do_gsay)
{
struct char_data *k;
struct follow_type *f;
skip_spaces(&argument);
if (!AFF_FLAGGED(ch, AFF_GROUP)) {
send_to_char(ch, "But you are not the member of a group!\r\n");
return;
}
if (!*argument)
send_to_char(ch, "Yes, but WHAT do you want to group-say?\r\n");
else {
char buf[MAX_STRING_LENGTH];
if (ch->master)
k = ch->master;
else
k = ch;
snprintf(buf, sizeof(buf), "$n tells the group, '%s@n'", argument);
if (AFF_FLAGGED(k, AFF_GROUP) && (k != ch))
act(buf, FALSE, ch, 0, k, TO_VICT | TO_SLEEP);
for (f = k->followers; f; f = f->next)
if (AFF_FLAGGED(f->follower, AFF_GROUP) && (f->follower != ch))
act(buf, FALSE, ch, 0, f->follower, TO_VICT | TO_SLEEP);
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", CONFIG_OK);
else
send_to_char(ch, "You tell the group, '%s@n'\r\n", argument);
}
}
static void perform_tell(struct char_data *ch, struct char_data *vict, char *arg)
{
char buf[MAX_STRING_LENGTH], *msg;
snprintf(buf, sizeof(buf), "%s$n tells you, '%s'%s", CCRED(vict, C_NRM), arg, CCNRM(vict, C_NRM));
msg = act(buf, FALSE, ch, 0, vict, TO_VICT | TO_SLEEP);
add_history(vict, msg, HIST_TELL);
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", CONFIG_OK);
else {
snprintf(buf, sizeof(buf), "%sYou tell $N, '%s'%s", CCRED(ch, C_NRM), arg, CCNRM(ch, C_NRM));
msg = act(buf, FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP);
add_history(ch, msg, HIST_TELL);
}
if (!IS_NPC(vict) && !IS_NPC(ch))
GET_LAST_TELL(vict) = GET_IDNUM(ch);
}
static int is_tell_ok(struct char_data *ch, struct char_data *vict)
{
if (ch == vict)
send_to_char(ch, "You try to tell yourself something.\r\n");
else if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOTELL))
send_to_char(ch, "You can't tell other people while you have notell on.\r\n");
else if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_SOUNDPROOF) && (GET_LEVEL(ch) < LVL_GOD))
send_to_char(ch, "The walls seem to absorb your words.\r\n");
else if (!IS_NPC(vict) && !vict->desc) /* linkless */
act("$E's linkless at the moment.", FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP);
else if (PLR_FLAGGED(vict, PLR_WRITING))
act("$E's writing a message right now; try again later.", FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP);
else if ((!IS_NPC(vict) && PRF_FLAGGED(vict, PRF_NOTELL)) || (ROOM_FLAGGED(IN_ROOM(vict), ROOM_SOUNDPROOF) && (GET_LEVEL(ch) < LVL_GOD)))
act("$E can't hear you.", FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP);
else
return (TRUE);
return (FALSE);
}
/* Yes, do_tell probably could be combined with whisper and ask, but it is
* called frequently, and should IMHO be kept as tight as possible. */
ACMD(do_tell)
{
struct char_data *vict = NULL;
char buf[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH];
half_chop(argument, buf, buf2);
if (!*buf || !*buf2)
send_to_char(ch, "Who do you wish to tell what??\r\n");
else if (!strcmp(buf, "m-w")) {
char word[MAX_INPUT_LENGTH], *p, *q;
if (last_webster_teller != -1L) {
if (GET_IDNUM(ch) == last_webster_teller) {
send_to_char(ch, "You are still waiting for a response.\r\n");
return;
} else {
send_to_char(ch, "Hold on, m-w is busy. Try again in a couple of seconds.\r\n");
return;
}
}
/* only a-z and +/- allowed */
for (p = buf2, q = word; *p ; p++) {
if ((LOWER(*p) <= 'z' && LOWER(*p) >= 'a') || (*p == '+') || (*p == '-'))
*q++ = *p;
}
*q = '\0';
if (!*word) {
send_to_char(ch, "Sorry, only letters and +/- are allowed characters.\r\n");
return;
}
snprintf(buf, sizeof(buf), "../bin/webster %s %d &", word, (int) getpid());
system(buf);
last_webster_teller = GET_IDNUM(ch);
send_to_char(ch, "You look up '%s' in Merriam-Webster.\r\n", word);
} else if (GET_LEVEL(ch) < LVL_IMMORT && !(vict = get_player_vis(ch, buf, NULL, FIND_CHAR_WORLD)))
send_to_char(ch, "%s", CONFIG_NOPERSON);
else if (GET_LEVEL(ch) >= LVL_IMMORT && !(vict = get_char_vis(ch, buf, NULL, FIND_CHAR_WORLD)))
send_to_char(ch, "%s", CONFIG_NOPERSON);
else if (is_tell_ok(ch, vict))
perform_tell(ch, vict, buf2);
}
ACMD(do_reply)
{
struct char_data *tch = character_list;
if (IS_NPC(ch))
return;
skip_spaces(&argument);
if (GET_LAST_TELL(ch) == NOBODY)
send_to_char(ch, "You have nobody to reply to!\r\n");
else if (!*argument)
send_to_char(ch, "What is your reply?\r\n");
else {
/* Make sure the person you're replying to is still playing by searching
* for them. Note, now last tell is stored as player IDnum instead of
* a pointer, which is much better because it's safer, plus will still
* work if someone logs out and back in again. A descriptor list based
* search would be faster although we could not find link dead people.
* Not that they can hear tells anyway. :) -gg 2/24/98 */
while (tch != NULL && (IS_NPC(tch) || GET_IDNUM(tch) != GET_LAST_TELL(ch)))
tch = tch->next;
if (tch == NULL)
send_to_char(ch, "They are no longer playing.\r\n");
else if (is_tell_ok(ch, tch))
perform_tell(ch, tch, argument);
}
}
ACMD(do_spec_comm)
{
char buf[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH];
struct char_data *vict;
const char *action_sing, *action_plur, *action_others;
switch (subcmd) {
case SCMD_WHISPER:
action_sing = "whisper to";
action_plur = "whispers to";
action_others = "$n whispers something to $N.";
break;
case SCMD_ASK:
action_sing = "ask";
action_plur = "asks";
action_others = "$n asks $N a question.";
break;
default:
action_sing = "oops";
action_plur = "oopses";
action_others = "$n is tongue-tied trying to speak with $N.";
break;
}
half_chop(argument, buf, buf2);
if (!*buf || !*buf2)
send_to_char(ch, "Whom do you want to %s.. and what??\r\n", action_sing);
else if (!(vict = get_char_vis(ch, buf, NULL, FIND_CHAR_ROOM)))
send_to_char(ch, "%s", CONFIG_NOPERSON);
else if (vict == ch)
send_to_char(ch, "You can't get your mouth close enough to your ear...\r\n");
else {
char buf1[MAX_STRING_LENGTH];
snprintf(buf1, sizeof(buf1), "$n %s you, '%s'", action_plur, buf2);
act(buf1, FALSE, ch, 0, vict, TO_VICT);
if ((!IS_NPC(ch)) && (PRF_FLAGGED(ch, PRF_NOREPEAT)))
send_to_char(ch, "%s", CONFIG_OK);
else
send_to_char(ch, "You %s %s, '%s'\r\n", action_sing, GET_NAME(vict), buf2);
act(action_others, FALSE, ch, 0, vict, TO_NOTVICT);
}
}
/* buf1, buf2 = MAX_OBJECT_NAME_LENGTH (if it existed) */
ACMD(do_write)
{
struct obj_data *paper, *pen = NULL;
char *papername, *penname;
char buf1[MAX_STRING_LENGTH], buf2[MAX_STRING_LENGTH];
papername = buf1;
penname = buf2;
two_arguments(argument, papername, penname);
if (!ch->desc)
return;
if (!*papername) { /* nothing was delivered */
send_to_char(ch, "Write? With what? ON what? What are you trying to do?!?\r\n");
return;
}
if (*penname) { /* there were two arguments */
if (!(paper = get_obj_in_list_vis(ch, papername, NULL, ch->carrying))) {
send_to_char(ch, "You have no %s.\r\n", papername);
return;
}
if (!(pen = get_obj_in_list_vis(ch, penname, NULL, ch->carrying))) {
send_to_char(ch, "You have no %s.\r\n", penname);
return;
}
} else { /* there was one arg.. let's see what we can find */
if (!(paper = get_obj_in_list_vis(ch, papername, NULL, ch->carrying))) {
send_to_char(ch, "There is no %s in your inventory.\r\n", papername);
return;
}
if (GET_OBJ_TYPE(paper) == ITEM_PEN) { /* oops, a pen.. */
pen = paper;
paper = NULL;
} else if (GET_OBJ_TYPE(paper) != ITEM_NOTE) {
send_to_char(ch, "That thing has nothing to do with writing.\r\n");
return;
}
/* One object was found.. now for the other one. */
if (!GET_EQ(ch, WEAR_HOLD)) {
send_to_char(ch, "You can't write with %s %s alone.\r\n", AN(papername), papername);
return;
}
if (!CAN_SEE_OBJ(ch, GET_EQ(ch, WEAR_HOLD))) {
send_to_char(ch, "The stuff in your hand is invisible! Yeech!!\r\n");
return;
}
if (pen)
paper = GET_EQ(ch, WEAR_HOLD);
else
pen = GET_EQ(ch, WEAR_HOLD);
}
/* ok.. now let's see what kind of stuff we've found */
if (GET_OBJ_TYPE(pen) != ITEM_PEN)
act("$p is no good for writing with.", FALSE, ch, pen, 0, TO_CHAR);
else if (GET_OBJ_TYPE(paper) != ITEM_NOTE)
act("You can't write on $p.", FALSE, ch, paper, 0, TO_CHAR);
else {
char *backstr = NULL;
/* Something on it, display it as that's in input buffer. */
if (paper->action_description) {
backstr = strdup(paper->action_description);
send_to_char(ch, "There's something written on it already:\r\n");
send_to_char(ch, "%s", paper->action_description);
}
/* we can write - hooray! */
act("$n begins to jot down a note.", TRUE, ch, 0, 0, TO_ROOM);
send_editor_help(ch->desc);
string_write(ch->desc, &paper->action_description, MAX_NOTE_LENGTH, 0, backstr);
}
}
ACMD(do_page)
{
struct descriptor_data *d;
struct char_data *vict;
char buf2[MAX_INPUT_LENGTH], arg[MAX_INPUT_LENGTH];
half_chop(argument, arg, buf2);
if (IS_NPC(ch))
send_to_char(ch, "Monsters can't page.. go away.\r\n");
else if (!*arg)
send_to_char(ch, "Whom do you wish to page?\r\n");
else {
char buf[MAX_STRING_LENGTH];
snprintf(buf, sizeof(buf), "\007\007*$n* %s", buf2);
if (!str_cmp(arg, "all")) {
if (GET_LEVEL(ch) > LVL_GOD) {
for (d = descriptor_list; d; d = d->next)
if (STATE(d) == CON_PLAYING && d->character)
act(buf, FALSE, ch, 0, d->character, TO_VICT);
} else
send_to_char(ch, "You will never be godly enough to do that!\r\n");
return;
}
if ((vict = get_char_vis(ch, arg, NULL, FIND_CHAR_WORLD)) != NULL) {
act(buf, FALSE, ch, 0, vict, TO_VICT);
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", CONFIG_OK);
else
act(buf, FALSE, ch, 0, vict, TO_CHAR);
} else
send_to_char(ch, "There is no such person in the game!\r\n");
}
}
int first_word_is_name(struct char_data *ch, char * argument) {
char buf[MAX_INPUT_LENGTH];
char name_p[MAX_INPUT_LENGTH];
if (argument == NULL || IS_NPC(ch))
return 0;
strlcpy(buf, argument, sizeof(buf));
one_argument(buf, name_p);
return !str_cmp(GET_NAME(ch), name_p);
}
/* generalized communication func, originally by Fred C. Merkel (Torg) */
ACMD(do_gen_comm)
{
struct descriptor_data *i;
char color_on[24];
char buf1[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH], *msg;
bool emoting = FALSE;
/* Array of flags which must _not_ be set in order for comm to be heard */
int channels[] = {
0,
PRF_NOSHOUT,
PRF_NOGOSS,
PRF_NOAUCT,
PRF_NOGRATZ,
PRF_NOGOSS,
0
};
int hist_type[] = {
HIST_HOLLER,
HIST_SHOUT,
HIST_GOSSIP,
HIST_AUCTION,
HIST_GRATS,
};
/* com_msgs: [0] Message if you can't perform the action because of noshout
* [1] name of the action
* [2] message if you're not on the channel
* [3] a color string. */
const char *com_msgs[][4] = {
{"You cannot holler!!\r\n",
"holler",
"",
KYEL},
{"You cannot shout!!\r\n",
"shout",
"Turn off your noshout flag first!\r\n",
KYEL},
{"You cannot gossip!!\r\n",
"gossip",
"You aren't even on the channel!\r\n",
KYEL},
{"You cannot auction!!\r\n",
"auction",
"You aren't even on the channel!\r\n",
KMAG},
{"You cannot congratulate!\r\n",
"congrat",
"You aren't even on the channel!\r\n",
KGRN},
{"You cannot gossip your emotions!\r\n",
"gossip",
"You aren't even on the channel!\r\n",
KYEL}
};
/* to keep pets, etc from being ordered to shout */
if (!ch->desc)
return;
if (PLR_FLAGGED(ch, PLR_NOSHOUT)) {
send_to_char(ch, "%s", com_msgs[subcmd][0]);
return;
}
if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_SOUNDPROOF) && (GET_LEVEL(ch) < LVL_GOD)) {
send_to_char(ch, "The walls seem to absorb your words.\r\n");
return;
}
if (subcmd == SCMD_GOSSIP && *argument == '*') {
subcmd = SCMD_GEMOTE;
}
if (subcmd == SCMD_GEMOTE) {
if (*argument == '*')
do_gmote(ch, argument + 1, 0, 1);
else
do_gmote(ch, argument, 0, 1);
return;
}
/* level_can_shout defined in config.c */
if (GET_LEVEL(ch) < CONFIG_LEVEL_CAN_SHOUT) {
send_to_char(ch, "You must be at least level %d before you can %s.\r\n", CONFIG_LEVEL_CAN_SHOUT, com_msgs[subcmd][1]);
return;
}
/* make sure the char is on the channel */
if (PRF_FLAGGED(ch, channels[subcmd])) {
send_to_char(ch, "%s", com_msgs[subcmd][2]);
return;
}
/* skip leading spaces */
skip_spaces(&argument);
/* make sure that there is something there to say! */
if (!*argument) {
send_to_char(ch, "Yes, %s, fine, %s we must, but WHAT???\r\n", com_msgs[subcmd][1], com_msgs[subcmd][1]);
return;
}
if (subcmd == SCMD_HOLLER) {
if (GET_MOVE(ch) < CONFIG_HOLLER_MOVE_COST) {
send_to_char(ch, "You're too exhausted to holler.\r\n");
return;
} else
GET_MOVE(ch) -= CONFIG_HOLLER_MOVE_COST;
}
/* set up the color on code */
strlcpy(color_on, com_msgs[subcmd][3], sizeof(color_on));
/* first, set up strings to be given to the communicator */
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", CONFIG_OK);
else {
if (!first_word_is_name(ch, argument)) {
snprintf(buf1, sizeof(buf1), "%sYou %s, '%s%s'%s", COLOR_LEV(ch) >= C_CMP ? color_on : "", com_msgs[subcmd][1], argument, COLOR_LEV(ch) >= C_CMP
? color_on : "", CCNRM(ch, C_CMP));
} else {
emoting = TRUE;
snprintf(buf1, sizeof(buf1), "%s%s: %s%s", COLOR_LEV(ch) >= C_CMP ? color_on : "", com_msgs[subcmd][1], CAP(argument), CCNRM(ch, C_CMP));
}
msg = act(buf1, FALSE, ch, 0, 0, TO_CHAR);
add_history(ch, msg, hist_type[subcmd]);
}
if (!emoting)
snprintf(buf1, sizeof(buf1), "$n %ss, '%s'", com_msgs[subcmd][1], argument);
/* now send all the strings out */
for (i = descriptor_list; i; i = i->next) {
if (STATE(i) != CON_PLAYING || i == ch->desc || !i->character )
continue;
if (!IS_NPC(ch) && (PRF_FLAGGED(i->character, channels[subcmd]) || PLR_FLAGGED(i->character, PLR_WRITING)))
continue;
if (ROOM_FLAGGED(IN_ROOM(i->character), ROOM_SOUNDPROOF) && (GET_LEVEL(ch) < LVL_GOD))
continue;
if (subcmd == SCMD_SHOUT &&
((world[IN_ROOM(ch)].zone != world[IN_ROOM(i->character)].zone) ||
!AWAKE(i->character)))
continue;
snprintf(buf2, sizeof(buf2), "%s%s%s", (COLOR_LEV(i->character) >= C_NRM) ? color_on : "", buf1, KNRM);
msg = act(buf2, FALSE, ch, 0, i->character, TO_VICT | TO_SLEEP);
add_history(i->character, msg, hist_type[subcmd]);
}
}
ACMD(do_qcomm)
{
if (!PRF_FLAGGED(ch, PRF_QUEST)) {
send_to_char(ch, "You aren't even part of the quest!\r\n");
return;
}
skip_spaces(&argument);
if (!*argument)
send_to_char(ch, "%c%s? Yes, fine, %s we must, but WHAT??\r\n", UPPER(*CMD_NAME), CMD_NAME + 1, CMD_NAME);
else {
char buf[MAX_STRING_LENGTH];
struct descriptor_data *i;
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", CONFIG_OK);
else if (subcmd == SCMD_QSAY) {
snprintf(buf, sizeof(buf), "You quest-say, '%s'", argument);
act(buf, FALSE, ch, 0, argument, TO_CHAR);
} else
act(argument, FALSE, ch, 0, argument, TO_CHAR);
if (subcmd == SCMD_QSAY)
snprintf(buf, sizeof(buf), "$n quest-says, '%s'", argument);
else {
strlcpy(buf, argument, sizeof(buf));
mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(ch)), TRUE, "(GC) %s qechoed: %s", GET_NAME(ch), argument);
}
for (i = descriptor_list; i; i = i->next)
if (STATE(i) == CON_PLAYING && i != ch->desc && PRF_FLAGGED(i->character, PRF_QUEST))
act(buf, 0, ch, 0, i->character, TO_VICT | TO_SLEEP);
}
}