[SNIPPET] Profficiency

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


Here's the small backbone of my proficiency system.  It basicly implements
the ability to store profficiencies, but doesn't actually implement any.
They are used similarly to skills, but are learned (in my mud at least) by
special trainers in the land.  If you can't read the code and understand
it, I'd probably suggest not using it.  However, it QUITE simple and should
be no prob.  They do have a few examples of proficiencies coded in, but
very few.

STEP 1
------
Add these two files in your src directory:

/*****************************************************************
** File: Prof.c      Usage: Handles the new profeciency system  **
** By Chuck Reed - Ash of Dark Horizon                          **
** Email: ash@dh.gator.net                                      **
*****************************************************************/

#include "conf.h"
#include "sysdep.h"

#include "structs.h"
#include "utils.h"
#include "spells.h"
#include "comm.h"
#include "interpreter.h"
#include "prof.h"
#include "db.h"

extern struct room_data *world;
extern const char *dirs[];

int check_prof(struct char_data *ch, int num)
{
   int i;

   for(i=0;i <= MAX_PROFS;i++)
      if(GET_PROF(ch, i) == num)
         return TRUE;

return FALSE;
}

int learn_prof(struct char_data *ch, int num)
{
   int i;

  for(i=0;i <= MAX_PROFS;i++)
    if(GET_PROF(ch, i) == num) {
      send_to_char("You already know how to do that!\r\n", ch);
      return FALSE;
    }

  if(GET_PROF_SLOTS(ch) > 0) {
   for(i=0;i <= MAX_PROFS;i++)
        if(GET_PROF(ch, i) == 0) {
           GET_PROF(ch, i) = num;
           return TRUE;
         }

 /* A check to see if someone slipped by and got too many prof slots. */
   send_to_char("You have learned the maximum amount of proficiencies you
can.\r\n", ch);
   return FALSE;
    }
   else
     send_to_char("You aren't able to learn another proficiency at the
moment.\r\n", ch);

 return FALSE;
}

void check_sense_danger(struct char_data *ch)
{
   int door;

   for (door = 0; door < NUM_OF_DIRS; door++)
    if (EXIT(ch, door) && EXIT(ch, door)->to_room != NOWHERE &&
        IS_SET(ROOM_FLAGS(EXIT(ch, door)->to_room), ROOM_TRAP)) {

      if(number(1, 20) <= GET_WIS(ch)) {
       sprintf(buf, "\\c01You sense danger %s from here!\\c00\r\n",
dirs[door]);
       send_to_char(buf, ch);
     }
   }
}

const char *prof_name[] = {
"Swimming",
"Blind Fighting",
"Ambidexterity",
"Endurance",
"First Aid",
"Sense Danger"
};

*************************************************************************
NEXT FILE
*************************************************************************

/*****************************************************************
** File: Prof.h      Usage: Defines for the profeciency system  **
** By Chuck Reed - Ash of Dark Horizon                          **
** Email: ash@dh.gator.net                                      **
*****************************************************************/

#define GET_PROF(ch, i)    ((ch)->player_specials->saved.proficiencies[i])
#define GET_PROF_SLOTS(ch) ((ch)->player_specials->saved.prof_slots)

/* Here's the list of proficiencies you can have, change to fit your needs */
#define PROF_SWIMMING                                           0
#define PROF_BLIND_FIGHTING                                     1
#define PROF_AMBIDEXTERITY                                              2
#define PROF_ENDURANCE                                          3
#define PROF_FIRST_AID                                          4
#define PROF_SENSE_DANGER                                               5

STEP 2
------
Edit your makefile adding to your objfiles

prof.o

somewhere in the list.

Also, you must add this to the bottom of the file as well:

prof.o : prof.c prof.h structs.h
        $(CC) -c $(CFLAGS) prof.c
^^^^^^^^
this space must be a <TAB>

That should be all you need to get you started.  I hope this helps you out
with what you want.

Chuck


     +------------------------------------------------------------+
     | 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