[CODE-SNIPPET] Talk Command in Oasis MobProgs

From: Chuck Reed (creed@I-55.COM)
Date: 03/09/98


Here's the talk prog I made for OLC mobprogs.  Works fine on my mud.

[Begin snippet]

/***************************************************************
** A talk command - OASIS MOBPROGS NEEDED FOR THIS TO WORK    **
** By Chuck Reed - Ash of Dark Horizon (dh.gator.net 6001)    **
**                                                            **
** Feel free to use this code, distribute it, etc.            **
***************************************************************/

Step 1)
----------------------------------------------------------------

In mobprog.c add the following code to the end of the file:

/* Talk command for Oasis by Chuck Reed - creed@i-55.com */
void mprog_talk_trigger(struct char_data *mob, struct char_data *ch)
{
  MPROG_DATA *mprg;
  mprg = mob_index[mob->nr].mobprogs;

  if (IS_NPC(mob) && mob_index[mob->nr].progtypes & TALK_PROG) {
   act("You talk to $N: \r\n", TRUE, ch, 0, mob, TO_CHAR);
   act("$n attempts to talk to $N.\r\n", TRUE, ch, 0, mob, TO_ROOM);
   mprog_driver(mprg->comlist, mob, ch, NULL, NULL);
   return;
  }
   else
     send_to_char("They don't seem to want to talk to you.\r\n", ch);

   return;
}
/* End of talk trigger */



Step 2)
--------------------------------------------------------------

Now, open act.other.c or act.comm.c, your choice.  Add the following
ACMD function anywhere you like:

/* do_talk by Chuck Reed - creed@i-55.com */
ACMD(do_talk)
{
   void mprog_talk_trigger(struct char_data *mob, struct char_data *ch);
   struct char_data *mob;

   one_argument(argument, arg);

   if(!get_char_room_vis(ch, arg)) {
      send_to_char("They don't seem to be here.\r\n", ch);
      return;
    }
   else
      mob = get_char_room_vis(ch, arg);

   if(!IS_NPC(mob))
      send_to_char("Why don't you just use say?\r\n", ch);
   else if(!*arg)
      send_to_char("Talk to whom?\r\n", ch);
   else if(GET_POS(mob) != POS_STANDING)
      send_to_char("Hmm, they aren't in the right position for that.\r\n",
ch);
   else if(IS_AFFECTED(ch, AFF_SILENCE))
      send_to_char("You are currently silenced.\r\n", ch);
   else
      mprog_talk_trigger(mob, ch);

  return;
}
/* End of do_talk */



Step 3)
---------------------------------------------------------------

Open structs.h and find the defines for all the mob progs.  Under the
last one, add:

#define TALK_PROG <next number>



Step 4)
---------------------------------------------------------------

Increase NUM_PROGS in olc.h by one.



Step 5)
----------------------------------------------------------------

Now, lets deal with putting this in OLC.  Open up medit.c.

Find the case statements for the different progs (search for BRIBE_PROG)
and add a new case like this:

   case TALK_PROG:
      return ">talk_prog";
      break;


Step 6)
-----------------------------------------------------------------


Now open db.c and find the case statements that handle reading the
mprogs from files.  Mine look like this:

if (!str_cmp(name, "bribe_prog"    ))    return BRIBE_PROG;

Add a new one that looks like so:

if (!str_cmp(name, "talk_prog"    ))    return TALK_PROG;



You should be done!
------------------------------------------------------------------
Now, when you have done all that, type make from your src directory
and hope it all works.  Note I'm not giving any guaranty that this
will work for you and I'm not responsible for your code.  If you
have any questions regarding it, you can mail me at creed@i-55.com
or come see me (I'm Ash) at dh.gator.net 6001.  Enjoy.

                                                                                        Chuck
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+
| Chuck Reed                  | Ash of Dark Horizon          |
| creed@i-55.com              | dh.gator.net 6001            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+
"Remember, your probably only still alive because it's illegal
 for me to kill you!"


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST