Poof Saves (3.0bpl11, version 3) [by Gary Barnett]
Snippet Posted Wednesday, August 12th @ 11:33:27 PM, by George Greer in the Wizard dept.
Updated May 6, 1997. Click the link below to read it or download it.

From: Gary Barnett <gbarnett@polarnet.com>
Subject: Poof saves snippet?

Some of the builder's on my mud might call be re-write happy.. (Who rewrites
the POS_ code? :-) )  .. but have you tried backing up the source, and yanking
poofs entirely and then adding them back in?

This assumes you are using the improved editor patch. If you aren't, stop
reading :-)

0) yank all references to poofs.

1) create two pointers to a string on your character. I used
player_special_data and called them poofin and poofout.

2) create two macros: (utils.h)

#define POOFIN(ch)

((ch)->player_specials->poofin)
#define POOFOUT(ch)

((ch)->player_specials->poofout)

2) If you use the improved editor patch just create a new command and copy
    the lines from one of the other places it's used and modify to suit.
    Something like this:

ACMD(do_poofset)
{   int poof =0;
    if (subcmd == SCMD_POOFIN) poof=1;
    if (subcmd == SCMD_POOFOUT) poof=2;
    if (!poof) {

send_to_char("Invalid poof set.\r\n",ch);

return;
    }
/* set up editor stats */
    send_to_char("\x1B[H\x1B[J", ch);
    if (poof == 1)
        send_to_char("Edit your POOFIN: (/s saves /h for help)\r\n", ch);
    else
       send_to_char("Edit your POOFOUT: (/s saves /h for help)\r\n", ch);

    ch->desc->backstr = NULL;

    if (poof == 1) {
        if ((ch->player_specials)->poofin) {
            send_to_char((ch->player_specials)->poofin, ch);
            ch->desc->backstr = str_dup((ch->player_specials)->poofin);

        }


ch->desc->str = &ch->player_specials->poofin;

    } else {
       if ((ch->player_specials)->poofout) {
             send_to_char((ch->player_specials)->poofout, ch);
             ch->desc->backstr = str_dup((ch->player_specials)->poofout);
        }



 ch->desc->str = &ch->player_specials->poofout;
   }
    ch->desc->max_str = MAX_STRING_LENGTH;
    ch->desc->mail_to = 0;
    act("$n begins editing one of his poofs.", TRUE, ch, 0, 0, TO_ROOM);
    SET_BIT(PLR_FLAGS(ch), PLR_WRITING);
}

4) create the SCMD_POOFIN and SCMD_POOFOUT defines.. Just use the next
free numbers.

5) create the commands.. poofin and poofout .. use the scmd's to
differentiate... and add the declaration ACMD(do_poofset) -- intepreter.c

6) send the new poofs out in the goto and teleport commands I think. This
works for me:

if (POOFOUT(ch)) {
    sprintf(buf, "%s", POOFOUT(ch));
    if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = '\0';
  } else
    strcpy(buf, "$n disappears.");
 act(buf, TRUE, ch, 0, 0, TO_ROOM);

<move the person to the new room here>

  if (POOFIN(ch)) {
    sprintf(buf, "%s", POOFIN(ch));
    if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = '\0';
  } else
    strcpy(buf, "$n has arrived.");
  act(buf, TRUE, ch, 0, 0, TO_ROOM);

7) free the stuff when you are done with it .. free_char

     if (ch->player_specials->poofin)
      free(ch->player_specials->poofin);
    if (ch->player_specials->poofout)
      free(ch->player_specials->poofout);


8) figure out a way to save them. I use ascii pfiles.. This would be a
good time to plug them :-)

9) Add a policy: That the God's name must appear in the darn poof. :-)

If you aren't ready to convert, you might save them in a file in the obj
save dir called poofs or something.. but that's up to you...maybe use the
spares to store the pointers?

ACMD(do_poofs)
{
   int poof =0;
    if (*argument)

   if ((argument[1] == 'i') || (argument[1] == 'I') ) {

      send_to_char("Edit your POOFIN: (/s saves /h for help)\r\n", ch);

      poof=1;


   } else if ((argument[1] == 'o') || (argument[1] == 'O') ) {

      send_to_char("Edit your POOFOUT: (/s saves /h for help)\r\n", ch);

      poof=2;

       }
    if (!poof) {

   sprintf(buf, "Your POOFIN reads:\r\n\r\n%s\r\n"


            "Your POOFOUT reads:\r\n\r\n%s\r\n"





"\r\n"





"To set poofs: Use POOFS IN or POOFS OUT.\r\n",





POOFIN(ch) ? POOFIN(ch) : "You have no POOFIN!\r\n",





POOFOUT(ch) ? POOFOUT(ch) : "You have no POOFOUT!\r\n");

   send_to_char(buf, ch);

   return;
    }

    ch->desc->backstr = NULL;


if (poof == 1) {
        if ((ch->player_specials)->poofin) {
            send_to_char((ch->player_specials)->poofin, ch);
            ch->desc->backstr = str_dup((ch->player_specials)->poofin);
        }


ch->desc->str = &ch->player_specials->poofin;
    } else {


if ((ch->player_specials)->poofout) {
             send_to_char((ch->player_specials)->poofout, ch);
             ch->desc->backstr = str_dup((ch->player_specials)->poofout);
        }


ch->desc->str = &ch->player_specials->poofout;

}
    ch->desc->max_str = MAX_STRING_LENGTH;
    ch->desc->mail_to = 0;
    act("$n begins editing one of $s poofs.", TRUE, ch, 0, 0, TO_ROOM);
    SET_BIT(PLR_FLAGS(ch), PLR_WRITING);
}

--Mallory


<< Poof Saves (3.0bpl11, version 2) [by Rasdan] | Reply | View as text | Flattened | Poofin/Poofout Saving [by ?] >>

 


Related Links
  download
Related Articles
More by greerga
 
 

CircleMUD Snippets
 
Note: Not all of these snippets will work perfectly with your version of code, so be prepared to fix one or two bugs that may arise, and please let me know what you needed to do to fix it. Sending a corrected version is always welcome.
Finally, if you wish to use any of the snippets from this page, you are more than welcome, just mention the authors in your credits. If you wish to release any of these snippets to the public on another site, contact me FIRST.