Think command for RP

This commit is contained in:
kinther 2025-08-30 19:35:52 -07:00
parent a793607b11
commit 5bdcba2a30
3 changed files with 52 additions and 0 deletions

View file

@ -198,6 +198,56 @@ ACMD(do_feel)
send_to_char(ch, "You feel %s\r\n", rendered);
}
ACMD(do_think)
{
char thought[MAX_INPUT_LENGTH];
char feeling[MAX_INPUT_LENGTH];
char *p = argument; /* must be mutable for skip_spaces */
char *close;
thought[0] = '\0';
feeling[0] = '\0';
skip_spaces(&p);
if (!*p) {
send_to_char(ch, "Think what?\r\n");
return;
}
/* Optional leading "(...)" becomes the feeling block. */
if (*p == '(') {
close = strchr(p + 1, ')');
if (close) {
size_t len = (size_t)(close - (p + 1));
if (len >= sizeof(feeling)) len = sizeof(feeling) - 1;
strncpy(feeling, p + 1, len);
feeling[len] = '\0';
p = close + 1; /* move past ')' */
while (*p && isspace((unsigned char)*p)) p++; /* skip spaces after ) */
}
/* If there's no closing ')', we ignore and treat entire line as thought. */
}
if (!*p) {
send_to_char(ch, "Think what?\r\n");
return;
}
/* The rest is the thought text */
strlcpy(thought, p, sizeof(thought));
delete_doubledollar(thought);
if (*feeling) delete_doubledollar(feeling);
/* Output (two lines; second indented two spaces) */
if (*feeling) {
send_to_char(ch, "You think, feeling %s,\r\n \"%s\"\r\n", feeling, thought);
} else {
send_to_char(ch, "You think,\r\n \"%s\"\r\n", thought);
}
}
static void perform_tell(struct char_data *ch, struct char_data *vict, char *arg)
{
char buf[MAX_STRING_LENGTH], *msg;

View file

@ -39,6 +39,7 @@ ACMD(do_spec_comm);
ACMD(do_say);
ACMD(do_ooc);
ACMD(do_feel);
ACMD(do_think);
ACMD(do_page);
ACMD(do_reply);
ACMD(do_tell);

View file

@ -297,6 +297,7 @@ cpp_extern const struct command_info cmd_info[] = {
{ "teleport" , "tele" , POS_DEAD , do_teleport , LVL_BUILDER, 0 },
{ "tedit" , "tedit" , POS_DEAD , do_tedit , LVL_GOD, 0 }, /* XXX: Oasisify */
{ "thaw" , "thaw" , POS_DEAD , do_wizutil , LVL_GRGOD, SCMD_THAW },
{ "think" , "thin" , POS_RESTING , do_think , 0, 0 },
{ "title" , "title" , POS_DEAD , do_title , LVL_IMMORT, 0 },
{ "time" , "time" , POS_DEAD , do_time , 0, 0 },
{ "toggle" , "toggle" , POS_DEAD , do_toggle , 0, 0 },