Re: Skills and spells learning

From: Karl Buchner (blaizeofshadow@juno.com)
Date: 03/05/01


On Sat, 3 Mar 2001 15:02:32 -0000 Alex Mann <alex4501@HOTMAIL.COM>
writes:
>[...]
> I don't want players to get skills/spells when they level i want
> them to be able learn spells for various sources such as mobiles
> and objects, but they won't be able to unless they have a high
> enough level to do so. Thats the theory!
There is definitly a better way of doing this!
In the commands by which character's can learn skills, do a check
if (spell_info[skillnum].level[GET_CLASS(ch)] > GET_LEVEL(ch)){
  send_to_char("You cant learn that skill!", ch);
  return;
}

> This may have been look at before with the idea of learning from
> scroll or spell books.

incidently, feel free to use my spellbook code (i havn't coded scribe yet,
so that's up to you... )  This code uses study to set a character's spells as
learned or not...i've heavily modified my spell system, so you might have to
port my code to what you have...spells are given to an object in it's exdescrs,
which is the only way to set them right now...(havn't coded scribe)  You have
to define ITEM_SPELLBOOK and make spellbook objects for character's to learn
from.

ACMD(do_study)
{
  int spell_num, mana_cost;
  skip_spaces(&argument);
  if(*argument){

        if((spell_num = find_spell_num(argument)) < 1){
          send_to_char("&rStudy what spell?&n", ch);
          return;
        }


        if (spell_num < 1 || spell_num >NUM_SPELLS ||\
 spell_info[spell_num].level[GET_CLASS(ch)] > GET_LEVEL(ch)) {
      send_to_char("&rThat is not a spell you can memorize!&n\r\n", ch);
      return;
    }

        if (GET_SPELL(ch, spell_num) > 95) {
      send_to_char("You cannot study that spell anymore\r\n", ch);
      return;
    }

        if(!find_spell_in_book(ch, spell_info[spell_num].name)){
          send_to_char("&rYou do not have that spell recorded in a spellbook&n",
ch);
          return;
        }

        if (PRACTICES(ch) < 1) {
      send_to_char("You cannot learn this spell, your mind is too
full!\r\n", ch);
      return;
    }


    send_to_char("You begin studying...\r\n", ch);

    PRACTICES(ch)--

    GET_SKILL(ch, spell_num) = MIN(GET_SKILL(ch, spell_num) + number(10,
GET_INT(ch)), 95);

    return;
  }
  list_spells(ch);
}

int find_spell_in_text(char *name, char *text){
  char *s;
  s = NULL;
  for(s = NULL; text != NULL; text++)
        if(*text =='\''){
          if(!s)
            s = text + 1;
          else{
                *text = '\0';
                if(!strcmp(name, s))
                  return 1;
                s = NULL;
          }
    }
  return 0;
}

int find_spell_in_book(struct char_data *ch, char *spell)
{
  int i;
  char *desc;
  struct obj_data *temp;
  for (i = 0; i < NUM_WEARS; i++)
        if (GET_EQ(ch, i) && GET_OBJ_TYPE(GET_EQ(ch, i)) == ITEM_SPELLBOOK){
          temp = GET_EQ(ch, i);
          desc = find_exdesc("spells", temp->ex_description);
          if(find_spell_in_text(spell, desc))
            return 1;
    }
  for (temp = ch->carrying; temp; temp = temp->next_content)
        if(GET_OBJ_TYPE(temp) == ITEM_SPELLBOOK){
          desc = find_exdesc("spells", temp->ex_description);
          if(find_spell_in_text(spell, desc))
            return 1;
    }
  return 0;
}
________________________________________________________________
GET INTERNET ACCESS FROM JUNO!
Juno offers FREE or PREMIUM Internet access for less!
Join Juno today!  For your FREE software, visit:
http://dl.www.juno.com/get/tagj.

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/04/01 PST