Re: [NEWBIE][LONG] Skills learnable by all

From: Welcor (welcor@dune.net)
Date: 01/29/02


That's quite a list of changes you want there. Some are quite easy,
others will take a lot of coding to get in. I'll give you some ideas...

----- Original Message -----
From: Nick Shaw
> I was wondering if someone could help me by pointing out whats files i
> should change or even what i should do if i wanted to make all the player
> skills available to any class (not spells though). Ive been fiddling
> around but havent managed to do it. e.g. a warrior could go to a thief
> teacher and learn thief skills etc.

Change the init_spell_levels call to initialise skills for all classes;

for (i = 0;i<NUM_CLASSES;i++) {
  spell_level(SKILL_SNEAK, i, 1);
  ...
}

> and how can i set it up that the
> thief teacher will only teach and list thief skills, warrior warrior
> skills and so on.

You'll need to change the spell_info_type() structure in spells.h, so
it includes a class bitvector, and properly initialise it in
spell_parser.c by changing the spello calls;

in spells.h:
  int allowed_classes; /* classes allowed to learn this */

change spello to:
void spello(int spl, const char *name, int max_mana, int min_mana,
 int mana_change, int minpos, int targets, int violent, int routines,
 const char *wearoff, int classes)
{
  int i;

  for (i = 0; i < NUM_CLASSES; i++)
    spell_info[spl].min_level[i] = LVL_IMMORT;
  spell_info[spl].mana_max = max_mana;
  spell_info[spl].mana_min = min_mana;
  spell_info[spl].mana_change = mana_change;
  spell_info[spl].min_position = minpos;
  spell_info[spl].targets = targets;
  spell_info[spl].violent = violent;
  spell_info[spl].routines = routines;
  spell_info[spl].name = name;
  spell_info[spl].wear_off_msg = wearoff;
  spell_info[spl].allowed_classes = classes;
}
(Fix unused_spell() too)

Change skillo() to this definition instead:
#define skillo(skill, name) spello(skill, name, 0, 0, 0, 0, 0, 0, 0, NULL, \
(1<<CLASS_MAGIC_USER) | (1<<CLASS_CLERIC) | (1<<CLASS_WARRIOR) |
(1<<CLASS_THIEF));

Then change all of your spello calls like this example:
 spello(SPELL_ANIMATE_DEAD, "animate dead", 35, 10, 3, POS_STANDING,
   TAR_OBJ_ROOM, FALSE, MAG_SUMMONS,
   NULL, (1<<CLASS_MAGIC_USER) | (1<<CLASS_CLERIC) );
Of course only add the classes you wish to be able to learn the spell.

Having initialised the spell_info[] array, your next task will be
to change the guild spec proc in spec_procs.c

Make an array for guildmasters:

struct guild_master_type {
  mob_vnum my_vnum;   /* vnum of guildmaster */
  int classes_taught; /* which classes will he teach */
} guild_masters = {
  {3020, (1<<CLASS_MAGIC_USER)},
  {3021, (1<<CLASS_CLERIC)},
...
  {-1, 0}
}

Change
list_skills(struct char_data *ch)
to
list_skills(struct char_data *ch, struct char_data *gm)
and add a check like this:
  int i, classes_taught = -1;

  if (gm) {
    for (i=0;guild_masters[i]!=-1;i++) {
      if (GET_MOB_VNUM(gm) == guild_masters[i].my_vnum)
        classes_taught = guild_masters[i].classes_taught;
    }
  }
  for (sortpos = 1; sortpos <= MAX_SKILLS; sortpos++) {
    i = spell_sort_info[sortpos];
    if (strlen(buf2) >= MAX_STRING_LENGTH - 32) {
      strcat(buf2, "**OVERFLOW**\r\n");
      break;
    }
    if (GET_LEVEL(ch) >= spell_info[i].min_level[(int) GET_CLASS(ch)] &&
       ((classes_taught == -1) ||  /* all classes taught here / no gm */
       ((1<<GET_CLASS(ch)) & spell_info[i].classes_allowed)) {
      sprintf(buf, "%-20s %s\r\n", spell_info[i].name,
how_good(GET_SKILL(ch, i)));
      strcat(buf2, buf); /* The above, ^ should always be safe to do. */
    }
  }

Now list_skills will only list skill taught to the class specified in
the struct above.

Finally, in SPECIAL(guild)
make sure list_skills is called as list_skills(ch, (struct char_data *)me);
and in do_practice, it should be called as list_skills(ch, NULL)

add a final check:

  if (!((1<<GET_CLASS(ch)) & spell_info[skill_num].allowed_classes) {
    sprintf(buf, "You do not know of that %s.\r\n", SPLSKL(ch));
    send_to_char(buf, ch);
    return (1);
  }




> Also how do i  get it to only list the skills you
> have learnt when you type practice rather than all the skills available
> to you.

in the above (list_skills) make a check for whether you're at a gm
and list all in that case, or are typing 'prac' and then only list
those with GET_SKILL(ch, skill_num);

    if (GET_LEVEL(ch) >= spell_info[i].min_level[(int) GET_CLASS(ch)] &&
       ((classes_taught == -1) ||  /* all classes taught here / no gm */
       ((1<<GET_CLASS(ch)) & spell_info[i].classes_allowed)) {

becomes:

    if (GET_LEVEL(ch) >= spell_info[i].min_level[(int) GET_CLASS(ch)] &&
       ((classes_taught == -1) ||  /* all classes taught here / no gm */
       ((1<<GET_CLASS(ch)) & spell_info[i].classes_allowed) &&
       ((gm) || GET_SKILL(ch, i))) {

> It seems a bit silly to me that you have it on your list if you
> havent learned it. And one last thing (since ive been asking so much),
> how can i make it so that the magicuser class can practice both spells
> and skills, not just one or the other.

That's primarily a cosmetic issue. I'll leave it as an excercise :P

Mind you, the above is VERY much mailer code (and if you have trouble
understanding what it does, tinker with it :)

Welcor
--
Paranoid schizophrenics outnumber their enemies at least two to one.

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT