Re: did anyone ever actually post the memorise snippet?

From: ironfist (ironfist@texas.net)
Date: 04/07/01


I 'm not sure if anyone posted a snippet, but I have some code for
memorization available if you are interested.  Send me an email and
I will send you what I have.  Its a little messy at the moment, but
it seems to work so far.

It uses a linked list similiar to an affect list to store spells that
are being memorized.  Once the countdown to memorization is complete,
it stores the spellnum in an array of memorized spells.  This array is
then saved to the player file when he/she quits out.  The memorization
time could also be saved under a parallel array if you don't want a
character to lose the time he spent partially memorizing a spell.

I simply use spell_info[spellnum].mana_max to store the level of the
spell (1-8 or however many spell levels you want).  Where the mana
check is in spell_parser.c, you simply check for the spellnum in the
memorized array and then remove it.  I also created an automem toggle
(which I saw on another mud) that asks a function to rememorize the spell
with the appropriate time.

To calculate the hours, (there may be a better way), I figure out the
hours it would take to memorize the spell in the standing position (this is
the slowest time) and use this in the time to memorize slot.  When a
character is sitting, they memorize the fastest so multiple hours are
subtracted from the time to memorize.

   Memorization time for each spell is equal to the level of the spell + 2
   multiplied by 5 at POS_STANDING.  A level one spell would take
   (1+2)*5=15 hours(ticks) to memorize when standing.

   POS_SITTING and POS_RESTING simulate the reduction in time by multiplying
   the number subtracted from the MEMTIME each tick by 5.

   A character who has 15 hours(ticks) to memorize a spell standing will see
   this on his display.  When he is sitting, he will have 15 hours in MEMTIME,
   but the display will divide by the value returned in find_memspeed to show
   a value of 15/5 --> 3 hours sitting time.

   If a tick occurs while sitting, update_mem will subtract 5 hours of
   "standing time" which is one hour of "sitting time" from the timer.

I hope that made sense ;-)

To calculate the number of spell lvls I simply use a chart such as below...
/************************************/
/*          Spell Levels            */
/*  1   2   3   4   5   6   7   8   */
/************************************/
          /* Mage */
int spell_lvlmax[(NUM_CLASSES * 31)][8] = {
  { 0,  0,  0,  0,  0,  0,  0,  0 },
  { 1,  0,  0,  0,  0,  0,  0,  0 },
  { 2,  0,  0,  0,  0,  0,  0,  0 },
  { 2,  0,  0,  0,  0,  0,  0,  0 },
  { 3,  1,  0,  0,  0,  0,  0,  0 },
  { 3,  1,  0,  0,  0,  0,  0,  0 }, /* lvl 5  */
  { 3,  2,  0,  0,  0,  0,  0,  0 },
  { 4,  2,  1,  0,  0,  0,  0,  0 },
  { 4,  2,  1,  0,  0,  0,  0,  0 },
  { 4,  3,  2,  0,  0,  0,  0,  0 },
  { 4,  3,  2,  1,  0,  0,  0,  0 }, /* lvl 10 */
  { 5,  3,  2,  1,  0,  0,  0,  0 },
  { 5,  3,  3,  2,  0,  0,  0,  0 },
  { 5,  4,  3,  2,  1,  0,  0,  0 },
  { 5,  4,  3,  2,  1,  0,  0,  0 },
  { 5,  4,  3,  3,  2,  0,  0,  0 }, /* lvl 15 */
  { 5,  4,  4,  3,  2,  1,  0,  0 },
  { 5,  4,  4,  3,  2,  1,  0,  0 },
  { 5,  5,  4,  3,  3,  1,  0,  0 },
  { 5,  5,  4,  4,  3,  2,  1,  0 },
  { 5,  5,  4,  4,  3,  2,  1,  0 }, /* lvl 20 */
  { 5,  5,  5,  4,  3,  2,  1,  0 },
  { 5,  5,  5,  4,  4,  2,  1,  1 },
  { 5,  5,  5,  4,  4,  3,  1,  1 },
  { 5,  5,  5,  5,  4,  3,  1,  1 },
  { 5,  5,  5,  5,  4,  3,  2,  1 }, /* lvl 25 */
  { 5,  5,  5,  5,  4,  3,  2,  1 },
  { 5,  5,  5,  5,  4,  3,  2,  1 },
  { 5,  5,  5,  5,  4,  3,  2,  1 },
  { 5,  5,  5,  5,  4,  3,  2,  1 },
  { 5,  5,  5,  5,  4,  3,  3,  2 }, /* lvl 30 */

          /* Cleric */

  { 0,  0,  0,  0,  0,  0,  0,  0 },
  { 1,  0,  0,  0,  0,  0,  0,  0 },
  { 2,  0,  0,  0,  0,  0,  0,  0 },
  { 2,  0,  0,  0,  0,  0,  0,  0 },


................... and so on ... and then there is a similiar chart for a
wisbonus to spells(but it is just one chart for all classes).  This gets
rather long if you have a lot of classes and levels, so I am thinking of
using an algorithm or perhaps a smaller chart whose information can be messed
about with to get any class' slots.

There are the commands "forget", "stop", and "memorize" which forget a spell
that is memorized, stop memorizing a spell being memorized, and memorize a
spell respectively.

Hope this helps,

Robert Mattern
ironfist@texas.net
strife.betterbox.net 4100

--
   +---------------------------------------------------------------+
   | 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/05/01 PST