because so it will use the default slay message.
On Tue, 23 Apr 2002, Edwin Groothuis wrote:
> > void do_slay( CHAR_DATA *ch, char *argument )
> > {
> > CHAR_DATA *victim;
> > char arg[MAX_INPUT_LENGTH];
> > char buf[MSL];
> >
> > one_argument( argument, arg );
> > if ( arg[0] == '\0' )
> > {
> > send_to_char( "Slay whom?\n\r", ch );
> > return;
> > }
> >
> > if ( ( victim = get_char_room( ch, arg ) ) == NULL )
> > {
> > send_to_char( "They aren't here.\n\r", ch );
> > return;
> > }
> >
> > if (ch->pcdata->pslay ==NULL)
> > {
> > send_to_char("You must atleast set one of your slay
> > arguments!\n\r",ch);
> > return;
> > }
>
> Why not checking for all slay arguments to be set?
>
> > if ( ch == victim )
> > {
> > send_to_char( "Suicide is a mortal sin.\n\r", ch );
> > return;
> > }
> >
> > if (IS_IMMORTAL(victim))
> > {
> > send_to_char( "Slaying another immortal would be
> > useless.\n\r",ch);
> > return;
> > }
> >
> > if ( !IS_NPC(victim) && victim->level >= get_trust(ch) )
> > {
> > send_to_char( "You failed.\n\r", ch );
> > return;
> > }
>
> If slay is only for immortals, this second check isn't needed since
> it would never occur.
>
> > if (ch->pcdata->pslay ||
> > ch->pcdata->pslay2 ||
> > ch->pcdata->pslay3 == NULL)
>
> so pslay should be non-NULL, pslay2 should be non-NULL and pslay3
> should be NULL? Also, they all should be non-NULL, not one of them
> (&& instead of ||), otherwise the output of the sprintf()'s is
> weird.
>
> > {
> > sprintf(buf, "%s\n\r", ch->pcdata->pslay);
> > act(buf, ch, NULL, victim, TO_CHAR );
> > sprintf(buf, "%s\n\r", ch->pcdata->pslay2);
> > act(buf, ch, NULL, victim, TO_VICT );
> > sprintf(buf, "%s\n\r", ch->pcdata->pslay3);
> > act(buf, ch, NULL, victim, TO_NOTVICT );
> > raw_kill( victim);
> > return;
> > }
> > else
> > act( "{1You slay $M in cold blood!{x", ch, NULL, victim, TO_CHAR
> > );
> > act( "{1$n slays you in cold blood!{x", ch, NULL, victim, TO_VICT
> > );
> > act( "{1$n slays $N in cold blood!{x", ch, NULL, victim,
> > TO_NOTVICT );
> > raw_kill( victim );
> > return;
> > }
> >
> > next: add these commands
> >
> > void do_pslay( CHAR_DATA *ch, char *argument )
> > {
> > char buf[MAX_STRING_LENGTH];
> >
> > if ( !IS_NPC(ch) )
> > {
> > smash_tilde( argument );
> >
> > if (argument[0] == '\0')
> > {
> > sprintf(buf,"Your poofslay To You is:
> > %s\n\r",ch->pcdata->pslay);
> > send_to_char(buf,ch);
> > return;
> > }
> >
> > free_string( ch->pcdata->pslay );
> > ch->pcdata->pslay = str_dup( argument );
> >
> > sprintf(buf,"Your poofslay To Them is now:
> > %s\n\r",ch->pcdata->pslay);
> > send_to_char(buf,ch);
> > }
> > return;
> > }
> >
> > void do_pslay2( CHAR_DATA *ch, char *argument )
> > {
> > char buf[MAX_STRING_LENGTH];
> >
> > if ( !IS_NPC(ch) )
> > {
> > smash_tilde( argument );
> > if (argument[0] == '\0')
> > {
> > sprintf(buf,"Your poofslay To the one your slaying is:
> > %s\n\r",ch->pcdata->pslay2);
> > send_to_char(buf,ch);
> > return;
> > }
> >
> > free_string( ch->pcdata->pslay2 );
> > ch->pcdata->pslay2 = str_dup( argument );
> >
> > sprintf(buf,"Your poofslay to the one your slaying is:
> > %s\n\r",ch->pcdata->pslay2);
> > send_to_char(buf,ch);
> > }
> > return;
> > }
> >
> > void do_pslay3( CHAR_DATA *ch, char *argument )
> > {
> > char buf[MAX_STRING_LENGTH];
> >
> > if ( !IS_NPC(ch) )
> > {
> > smash_tilde( argument );
> >
> > if (argument[0] == '\0')
> > {
> > sprintf(buf,"Your poofslay to people in the room is:
> > %s\n\r",ch->pcdata->pslay3);
> > send_to_char(buf,ch);
> > return;
> > }
> >
> > free_string( ch->pcdata->pslay3 );
> > ch->pcdata->pslay3 = str_dup( argument );
> >
> > sprintf(buf,"Your poofslay to people in the room is now:
> > %s\n\r",ch->pcdata->pslay3);
> > send_to_char(buf,ch);
> > }
> > return;
> > }
> >
> > /*Replaces 3 commands for for lack of string management*/
> > void do_poofslay( CHAR_DATA *ch,char *argument)
> > {
> > char arg[MAX_INPUT_LENGTH];
> > char buf[MAX_STRING_LENGTH];
> >
> > argument = one_argument(argument,arg);
> >
> > if ( arg[0] == '\0' )
> > {
> > sprintf(buf,"Your poofslay To You is: %s\n\r",ch->pcdata->pslay);
> > send_to_char(buf,ch);
> > sprintf(buf,"Your poofslay To The person your slaying:
> > %s\n\r",ch->pcdata->pslay2);
> > send_to_char(buf,ch);
> > sprintf(buf,"Your poofslay To people in the room:
> > %s\n\r",ch->pcdata->pslay3);
> > send_to_char(buf,ch);
> > return;
> > }
> > if (!str_prefix(arg,"1"))
> > {
> > do_function(ch, &do_pslay, argument);
> > return;
> > }
>
> Why are you not sending the "1" to the function as an argument?
> Yes, then it wouldn't be a do_function() anymore, but it would save
> you a duplication of code (triplication in this case)
>
> > if (!str_prefix(arg,"2"))
> > {
> > do_function(ch, &do_pslay2, argument);
> > return;
> > }
> >
> > if (!str_prefix(arg,"3"))
> > {
> > do_function(ch, &do_pslay3, argument);
> > return;
> > }
> > do_function(ch, &do_poofslay, "");
> > }
>
> > next: open up merc.h and find pc_data struct
> > and add somewhere in that mess:
> >
> > char * pslay;
> > char * pslay2;
> > char * pslay3;
>
> What is wrong with char *pslay[3]?
>
> I'm missing the allocation and deallocation of it in the new_pcdata()
> and free_pcdata().
>
> For a free lunch:
>
> void set_pslay( CHAR_DATA *ch, int number, char *argument ) {
> char buf[MAX_STRING_LENGTH];
>
> smash_tilde( argument );
> free_string(ch->pcdata->pslay[number]);
> ch->pcdata->pslay[number]=str_dup(argument);
> }
>
> void do_poofslay( CHAR_DATA *ch,char *argument)
> {
> char arg[MAX_INPUT_LENGTH];
> char buf[MAX_STRING_LENGTH];
> int number;
>
> argument = one_argument(argument,arg);
>
> if ( arg[0] == '\0' ) {
> sprintf(buf,"Your poofslay To You is: %s\n\r",ch->pcdata->pslay);
> send_to_char(buf,ch);
> sprintf(buf,"Your poofslay To The person your slaying:
> %s\n\r",ch->pcdata->pslay2);
> send_to_char(buf,ch);
> sprintf(buf,"Your poofslay To people in the room:
> %s\n\r",ch->pcdata->pslay3);
> send_to_char(buf,ch);
> return;
> }
>
> if (!is_number(arg)) {
> send_to_char("usage: poofslay <number> <text>\n\r",ch);
> return;
> }
>
> number=atoi(arg);
> if (number<0 || number>2) {
> send_to_char("usahe: poofslay <number> <text>\n\r",ch);
> return;
> }
> set_pslay(ch,number,argument);
> send_to_char("The slay to ",ch);
> switch (number) {
> case 0: send_to_char("you ",ch);break;
> case 1: send_to_char("them ",ch);break;
> case 2: send_to_char("room ",ch);break;
> }
> send_to_char("is set to ",ch);
> send_to_char(argument,ch);
> }
>
> Edwin
>
>