Goscials.txt
snippets · 3.9 KB · 2010-03-30
Gocial snippet: adds social commands that need TO_MUD in mud.h and act() changes in comm.c.
Download « Back to the snippets list
/*
* For the gocial function, you need to set TO_MUD in mud.h with TO_CHAR, and
* TO_VICT. You also have to change a couple of lines in comm.c in the act()
* function .... change ....
*
* for ( ; to; to = (type == TO_CHAR || type == TO_VICT )
* ? NULL : to->next_in_room )
*
* change that to this .....
*
* for ( ; to; to = (type == TO_MUD) ? to->next : (type == TO_CHAR || type == TO_VICT )
* ? NULL : to->next_in_room )
*
* and also in the act() function above ...
* if ( type == TO_CHAR && to != ch )
* continue;
* add ...
* if ( type == TO_MUD && (to == ch || to == vch) )
* continue;
*
* In act_comm.c change the do_chat function to look like ...
* void do_chat( CHAR_DATA *ch, char *argument )
* {
* if (NOT_AUTHED(ch))
* {
* send_to_char("Huh?\n\r", ch);
* return;
* }
* if (argument[0]=='@')
* {
* char arg[MAX_INPUT_LENGTH],buf[MAX_INPUT_LENGTH];
* int loop;
*
* argument = one_argument(argument,arg);
* for (loop = 0; loop < strlen(arg); loop++)
* {
* buf[loop]=arg[loop+1];
* }
* do_gocial(ch, buf, argument);
* return;
* }
* else
* {
* talk_channel( ch, argument, CHANNEL_CHAT, "chat" );
* return;
* }
* }
*
* This was based on the goscial snippet, but it has been TOTALLY redone to
* make use of a lot of stuff that's actually already in. This is a beta
* version written by LrdElder - necro.mfn.org port 9000
*
*/
#include <sys/types.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "mud.h"
void do_gocial (CHAR_DATA * ch, char *command, char *argument)
{
char arg[MAX_INPUT_LENGTH], buf[MAX_INPUT_LENGTH];
CHAR_DATA *victim;
SOCIALTYPE *social;
if ((social = find_social (command)) == NULL)
{
send_to_char ("That is not a social.\n\r", ch);
return;
}
if (!IS_NPC (ch) && xIS_SET (ch->act, PLR_NO_EMOTE))
{
send_to_char ("You are anti-social!\n\r", ch);
return;
}
switch (ch->position)
{
case POS_DEAD:
send_to_char ("Lie still; you are DEAD.\n\r", ch);
return;
case POS_INCAP:
case POS_MORTAL:
send_to_char ("You are hurt far too bad for that.\n\r", ch);
return;
case POS_STUNNED:
send_to_char ("You are too stunned to do that.\n\r", ch);
return;
case POS_SLEEPING:
/*
* I just know this is the path to a 12" 'if' statement. :(
* But two players asked for it already! -- Furey
*/
if (!str_cmp (social->name, "snore"))
break;
send_to_char ("In your dreams, or what?\n\r", ch);
return;
}
one_argument (argument, arg);
victim = NULL;
if (arg[0] == '\0')
{
sprintf (buf, "[GOSCIAL] %s", social->others_no_arg);
act (AT_SOCIAL, buf, ch, NULL, victim, TO_MUD);
sprintf (buf, "[GOSCIAL] %s", social->char_no_arg);
act (AT_SOCIAL, buf, ch, NULL, victim, TO_CHAR);
return;
}
if ((victim = get_char_world (ch, arg)) == NULL)
{
send_to_char ("You really shouldn't talk about people who aren't logged in.\n\r", ch);
return;
}
if (victim == ch)
{
sprintf (buf, "[GOSCIAL] %s", social->others_auto);
act (AT_SOCIAL, buf, ch, NULL, victim, TO_MUD);
sprintf (buf, "[GOSCIAL] %s", social->char_auto);
act (AT_SOCIAL, buf, ch, NULL, victim, TO_CHAR);
return;
}
else
{
sprintf (buf, "[GOSCIAL] %s", social->others_found);
act (AT_SOCIAL, buf, ch, NULL, victim, TO_MUD);
sprintf (buf, "[GOSCIAL] %s", social->char_found);
act (AT_SOCIAL, buf, ch, NULL, victim, TO_CHAR);
sprintf (buf, "[GOSCIAL] %s", social->vict_found);
act (AT_SOCIAL, buf, ch, NULL, victim, TO_VICT);
return;
}
}