AFK Version 2.5 [by Hellfire]
Snippet Posted Wednesday, August 4th @ 11:45:22 AM, by George Greer in the Commands dept.
Hellfire writes, ' I have taken and combined the AFK2 text from Rasdan and the NO_PKILL Text Created By Adam Donofrio aka. Bilbo (adamdonofrio@homtail.com), then repaired a couple minor errors in them and added to the directions some. I applied these to my circle30bpl14 with olc1.6b and dg scripts 1.7 and they seem to work fine. Full credit should go to Rasdan and Bilbo.'
AFK VERSION 2.5

The command is as follows:

AFK with no argument triggers the default string. To add a message to
your AFK do the following

Type   AFK  blah blah blah     and your message will override the
default and take it's place. I like this very much.

There has been discussion in the past about abuse of afk while pkilling
as a way to escape from damage.
Couple ways to get around this is to put a limit on the amount of times
a player can go afk, and/or  add a roomflag that disallows afk (good for
arenas and battlefields etc.)

Also even with the afk check in fight.c and the remove bit in
interpreter.c,  it can still be used as an ambush. This may or may not
be a good thing.

The afk mode saves but if you want the message string to save in pfile,
you will need to modify the character saving/loading functions in db.c

If anyone adds to this and or fixes any bugs , I would appreciate it if
you mail me what you have done.

Peace
Hellfire
bonecrusher@cyberdude.com



AFK VERSION 2 FEATURES :
 * Allows you to set an afk message.
 * Allows a message to be displayed to whoever is telling to you
   that you are afk, and what that message is.
 * Displays to the room your message when you are afk, and informs
   everyone in the room when you are back from AFK.


NO_PKILL Code:
 This code prevents players from pkilling AFK players .


The following should handpatch into circle30bpl14 nicely.
________________________________________________________________

ACT_COMM.C

IN  ACMD(do_tell)

FIND:

 else if (!(vict = get_char_vis(ch, buf)))
    send_to_char(NOPERSON, ch);

ADD BELOW IT::

  else if (PRF_FLAGGED(vict, PRF_AFK)) {
        sprintf(buf, "%s is AFK and may not hear your tell.\r\n",
GET_NAME(vict));
        send_to_char(buf, ch);
        sprintf(buf, "MESSAGE: %s\r\n", GET_AFK(vict));
        send_to_char(buf, ch);
 }

_____________________________________________________________________

ACT_INFORMATIVE.C

IN void list_one_char(struct char_data * i, struct char_data * ch)

FIND:

  if (PLR_FLAGGED(i, PLR_WRITING))
    strcat(buf, " (writing)");

ADD BELOW IT::

  if (PRF_FLAGGED(i, PRF_AFK))
    strcat(buf, " [AFK]");

+++++++++++++++++++++++++++++++++++++++++

THEN IN  do_who

FIND:

      if (PRF_FLAGGED(tch, PRF_NOTELL))
 strcat(buf, " (notell)");

ADD BELOW IT:

      if (PRF_FLAGGED(tch, PRF_AFK))
                strcat(buf, " [AFK]");

_________________________________________________________________________



ACT_OTHER.C

ADD AT THE BOTTOM OF THE FILE:

ACMD(do_afk)
{
  int result;

  if (IS_NPC(ch)) {
    send_to_char("Mobs don't have keyboards, go away.\r\n", ch);
    return;
  }

  skip_spaces(&argument);

  if (PRF_FLAGGED(ch, PRF_AFK)) {
    result = FALSE;
    REMOVE_BIT(PRF_FLAGS(ch), PRF_AFK);
  } else {
    result = TRUE;
    SET_BIT(PRF_FLAGS(ch), PRF_AFK);
  }
  set_afk(ch, argument, result);
}
____________________________________________________________

COMM.C

ADD:

#include "screen.h"

++++++++++++++++++++++++++++

IN char *make_prompt(struct descriptor_data *d)

FIND:

    if (GET_INVIS_LEV(d->character))
      sprintf(prompt, "i%d ", GET_INVIS_LEV(d->character));

ADD BELOW IT:

 if (PRF_FLAGGED(d->character, PRF_AFK))
      sprintf(prompt, "%s%s[AFK]%s", prompt, CCCYN(d->character, C_SPR),

                CCNRM(d->character, C_SPR));
________________________________________________________________________

FIGHT.C

FIND:

  /* peaceful rooms */
  if (ch->nr != real_mobile(DG_CASTER_PROXY) &&
      ch != victim && ROOM_FLAGGED(ch->in_room, ROOM_PEACEFUL)) {
    send_to_char("This room just has such a peaceful, easy
feeling...\r\n", ch);
    return 0;
  }

ADD BELOW IT:

  /* no pkilling AFK ppl*/
  if (PRF_FLAGGED (victim, PRF_AFK)){ /*this varies*/
  send_to_char("How cheap!  Can't you see the AFK flag?!?  You make me
sick!\r\n", ch);
  SET_BIT(PLR_FLAGS(ch), PLR_KILLER);
  return;
  }

__________________________________________________________________________

INTERPRETER.C

FIND:

prototypes for all do_x functions

ADD IN LIST:

ACMD(do_afk);

++++++++++++++++++++++++++

ADD INTO COMMAND INFO:

  { "afk" , "afk" , POS_DEAD , do_afk  , 0,0 },

+++++++++++++++++++++++++++


FIND:

  REMOVE_BIT(AFF_FLAGS(ch), AFF_HIDE);

ADD BELOW IT:

  if (PRF_FLAGGED(ch, PRF_AFK)) {
     REMOVE_BIT(PRF_FLAGS(ch), PRF_AFK);
     act("You are no longer AFK.", FALSE, ch, 0, 0, TO_CHAR);
     act("$n is no longer AFK.", FALSE, ch, 0, 0, TO_ROOM);
   }

____________________________________________________________________

LIMITS.C

ADD TO BOTTOM OF FILE:

void set_afk(struct char_data * ch, char *afk_message, int result)
{
  if (!*afk_message)
    sprintf(buf1, "%s", AFK_DEFAULT);
  else
    sprintf(buf1, "%s", afk_message);

  if (strlen(buf1) > MAX_POOF_LENGTH) {
    send_to_char("Afk message too long, using default.\r\n", ch);
    sprintf(buf1, "%s", AFK_DEFAULT);
  }

  if (GET_AFK(ch))
    free(GET_AFK(ch));
  GET_AFK(ch) = NULL;
  GET_AFK(ch) = str_dup(buf1);

  if (result) {
    sprintf(buf, "$n has just gone AFK: %s", GET_AFK(ch));
    act(buf, FALSE, ch, 0, 0, TO_ROOM);
    sprintf(buf, "You have just gone AFK: %s", GET_AFK(ch));
    act(buf, FALSE, ch, 0, 0, TO_CHAR);
  } else {
    act("$n is back from AFK!", FALSE, ch, 0, 0, TO_ROOM);
    act("You are back from AFK!", FALSE, ch, 0, 0, TO_CHAR);
  }
}

____________________________________________________

STRUCTS.H

ADD AT THE END OF THE PRF DEFINES:

#define PRF_AFK         (1 << **)       /* Player is AFK */

Note: ** = the number of your last PRF +1

++++++++++++++++++++++++++++++++++

IN struct char_player_data {

FIND:

   char *title;        /* PC / NPC's title                     */

ADD BELOW THAT:

   char *afk_message;  /* PC / NPC's AFK MESSAGE     */

+++++++++++++++++++++++++++++++++++

IN struct char_file_u {

FIND:

   char title[MAX_TITLE_LENGTH+1];

ADD BELOW IT:

   char afk_message[MAX_POOF_LENGTH + 1]; /*AFK Message*/

+++++++++++++++++++++++++++++++++++++

FIND:

#define MAX_TITLE_LENGTH 80  /* Used in char_file_u *DO*NOT*CHANGE* */

ADD BELOW IT:

#define MAX_POOF_LENGTH     120 /*used for afk message*/

___________________________________________________________________

UTILS.H

IN THE FUNCTION PROTOTYPES AT THE TOP

FIND:

char *stripcr(char *dest, const char *src);

ADD BELOW IT:

void    set_afk(struct char_data *ch, char *afk_message, int result);

++++++++++++++++++++++++++++++++++

FIND:

#define GET_LAST_TELL(ch) CHECK_PLAYER_SPECIAL((ch),
((ch)->player_specials->last_tell))

ADD BELOW IT:

#define AFK_DEFAULT     "I am afk, not looking at keyboard"
#define GET_AFK(ch)     ((ch)->player.afk_message)

___________________________________________________________________________

OK NOW:

1) Compile
2) Fix any warnings or errors.
3) Zap your pfile.
4) Mail me any fixes, additions or changes :)
5) Log on and have a blast.


<< CVS Documentation | Reply | View as text | Flattened | Linked-list world version of CircleMUD available >>

 


Related Links
  Hellfire
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.
 
 


AFK stuff
by Mike Melo (michael@thepies.com) on Wednesday, August 30th @ 02:32:11 PM
http://
i really don't think you need to make a change to char_file_u to do this - why would you save AFK information anyway?

couldn't you just stuff the AFk string into player_specials?
[ Reply to this comment ]