[Long] Multi-Class System

From: Mark Vanness Jr. (junior57@worldnet.att.net)
Date: 06/10/99


I have a bug in my multi-class system.  Where if I
create a cleric character, and multi-class to the
mage.  It will multi-class, however when a person
goes to multi-class again to something like the warrior
it tells me I can not repeat a class already completed.

Below is my multi.c file, if anyone can help that would
be great.  Yes, it is sloppy, but hey, Im not perfect! :)

-------------

/*********************************************************************\
 * File  : multi.c                                Based on CircleMUD *
 * Usage : Controls player multi levels                              *
 *                                                                  *
\*********************************************************************/

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

#include "structs.h"
#include "utils.h"
#include "db.h"
#include "interpreter.h"
#include "comm.h"
#include "multi.h"

extern int parse_class(char arg);
extern struct room_data *world;
extern char *pc_class_types[];
void perform_remove(struct char_data * ch, int pos);

char *multi_message =
"\r\n"
"The blessings from the Implementors has been bestowed upon\r\n"
"you in your new class.  All of your powers and skills will stay the
same\r\n"
"and your power will increase as a mortal into your next class.\r\n";

int okay_to_multi(struct char_data * ch, int flag)
{
  int room;

  /* Is the char in the appropriate room? */
  if (MULTI_ROOM >= 0) {
    room = real_room(MULTI_ROOM);
    if (ch->in_room != real_room(MULTI_ROOM)) {
      send_to_char("You are not in the correct room to multi!\r\n", ch);
      return (FALSE);
    }
  }

  /* Is wanted class same as current class? */
  if (flag == GET_CLASS(ch)) {
    sprintf(buf, "You are currently a %s!\r\n",
pc_class_types[(int)GET_CLASS(ch)]);
    send_to_char(buf, ch);
    return (FALSE);
  }

  /* Has char already completed this class? */
  if (HAS_CLASS(ch, flag)) {
    send_to_char("You can not repeat a class already completed.\r\n", ch);
    return (FALSE);
  }

  /* Is the char the right level? */
  if (GET_LEVEL(ch) < MULTI_LEVEL) {
    sprintf(buf, "You are only level %d, you must be at least Level %d
before you can multi.\r\n",
               GET_LEVEL(ch), MULTI_LEVEL);
    send_to_char(buf, ch);
    return (FALSE);
  }

  /* Has player offered the coin? */
  if (!PLR_FLAGGED(ch, PLR_MULTIRDY)) {
    send_to_char("You still need to offer the coin of dreams!\r\n", ch);
    return (FALSE);
  }

  /* Everything else is okay, return TRUE! */
  return (TRUE);
}

void reset_char_stats(struct char_data * ch, int flag, int num_multi)
{
  GET_MAX_HIT(ch) = MULTI_HP;    GET_HIT(ch) = GET_MAX_HIT(ch);
  GET_MAX_MANA(ch) = MULTI_MANA; GET_MOVE(ch) = GET_MAX_MOVE(ch);
  GET_MAX_MOVE(ch) = MULTI_MOVE; GET_MANA(ch) = GET_MAX_MANA(ch);

  GET_LEVEL(ch) = 1;
  GET_MULTI(ch) = GET_MULTI(ch) + 1;
  GET_EXP(ch) = 1;
  GET_TOTAL_LEVEL(ch)++;

  if (GET_REMORT(ch) == 99) {
   GET_REMORT(ch) = (int)GET_CLASS(ch);
   GET_REMORT2(ch) = 99;
   GET_REMORT3(ch) = 99;
  } else if (GET_REMORT(ch) != 99 && GET_REMORT2(ch) == 99) {
   GET_REMORT2(ch) = (int)GET_CLASS(ch);
   GET_REMORT3(ch) = 99;
  } else if (GET_REMORT(ch) != 99 && GET_REMORT2(ch) != 99 &&
GET_REMORT3(ch) == 99) {
   GET_REMORT3(ch) = (int)GET_CLASS(ch);
  } else {
   send_to_char("BUG! REPORT! BUG!", ch);
   return;
  }

  GET_CLASS(ch) = flag;
  send_to_char(multi_message, ch);
}

ACMD(do_multi)
{
  int flag = 0;
  int i;
  int num_multi = 0;

  one_argument(argument, arg);

  if (!*arg) {
    send_to_char("Syntax: multi <class name>\r\n"
    "Choose your next class:\r\n"
    "\r\n"
    "Mage, Cleric, Thief, Warrior\r\n", ch);
    return;
  }
  if (!str_cmp(arg, "mage")) {
    flag = CLASS_MAGIC_USER;
  } else if (!str_cmp(arg, "cleric")) {
    flag = CLASS_CLERIC;
  } else if (!str_cmp(arg, "thief")) {
    flag = CLASS_THIEF;
  } else if (!str_cmp(arg, "warrior")) {
    flag = CLASS_WARRIOR;
  } else {
    send_to_char("Improper class name, please try again.\r\n", ch);
    return;
  }
    for (i = 0; i < NUM_WEARS; i++)
      if (GET_EQ(ch, i)) {
 perform_remove(ch, i);
}
  if (!okay_to_multi(ch, flag))
    return;
   reset_char_stats(ch, flag, num_multi);
   REMOVE_BIT(PLR_FLAGS(ch), PLR_MULTIRDY);

 sprintf(buf, "&R(Multiclass) [%s has multi-classed to %s]&n", GET_NAME(ch),
CLASS_NAME(ch));
    mudlog(buf, NRM, LVL_IMMORT, TRUE);
}


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



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