[Code]Saving Throws generator

From: Rob Baumstark (shirak@CONNECT.AB.CA)
Date: 07/02/98


Here's a much smaller version of the saving thow code that was new in BPL13.
It will return almost the same values as the old array did (within 2/90),
but allows for much easier additions and modifications.  Feel free to use it
anywhere, so long as you leave the comment with my name in it (You don't
need to add it to the credits or anything, but it would be nice :)
----- Begin Code -----
/*
 * Saving throws for:
 * MCTW
 *   PARA, ROD, PETRI, BREATH, SPELL
 *
 * Drop in replacement for Circle BPL13A saving_throws() by Rob Baumstark
 *  Small function that replaces about 1000 lines of array.
 *  Now automatically adjusts to the number of levels, and is easier to
 *  adjust the ranges, or add new classes or saving rolls.
 *
 * Do not forget to change extern declaration in magic.c if you add to this.
 */

byte saving_throws(int class_num, int type, int level)
{
  int top_level, high_val, low_val;

  switch(class_num)
  {
  case CLASS_MAGIC_USER:
    top_level = (int)(LVL_IMPL*0.88);
    switch(type)
    {
    case SAVING_PARA:   high_val = 70; low_val = 28; break;
    case SAVING_ROD:    high_val = 55; low_val = 9; break;
    case SAVING_PETRI:  high_val = 65; low_val = 13; break;
    case SAVING_BREATH: high_val = 75; low_val = 23; break;
    case SAVING_SPELL:  high_val = 60; low_val = 8; break;
    default: log("SYSERR: Invalid saving throw type."); return 99;
    }
    break;
  case CLASS_CLERIC:
    top_level = (int)(LVL_IMPL*0.88);
    switch(type)
    {
    case SAVING_PARA:   high_val = 60; low_val = 7; break;
    case SAVING_ROD:    high_val = 70; low_val = 27; break;
    case SAVING_PETRI:  high_val = 65; low_val = 22; break;
    case SAVING_BREATH: high_val = 80; low_val = 37; break;
    case SAVING_SPELL:  high_val = 75; low_val = 32; break;
    default: log("SYSERR: Invalid saving throw type."); return 99;
    }
    break;
  case CLASS_THIEF:
    top_level = (int)(LVL_IMPL*0.88);
    switch(type)
    {
    case SAVING_PARA:   high_val = 65; low_val = 36; break;
    case SAVING_ROD:    high_val = 70; low_val = 13; break;
    case SAVING_PETRI:  high_val = 60; low_val = 31; break;
    case SAVING_BREATH: high_val = 80; low_val = 51; break;
    case SAVING_SPELL:  high_val = 75; low_val = 17; break;
    default: log("SYSERR: Invalid saving throw type."); return 99;
    }
    break;
  case CLASS_WARRIOR:
    top_level = LVL_IMPL;
    switch(type)
    {
    case SAVING_PARA:   high_val = 70; low_val = 8; break;
    case SAVING_ROD:    high_val = 80; low_val = 14; break;
    case SAVING_PETRI:  high_val = 75; low_val = 13; break;
    case SAVING_BREATH: high_val = 85; low_val = 13; break;
    case SAVING_SPELL:  high_val = 85; low_val = 19; break;
    default: log("SYSERR: Invalid saving throw type."); return 99;
    }
    break;
  default:
    log("SYSERR: Invalid class passed to saving throw.");
    return 99;
  }
  if(level > top_level)
    return 0;
  else
    return ((high_val - low_val * (-level))/top_level + high_val);
}
----- End Code -----
------------------------------------------------------------
G:  "If we do happen to step on a mine, Sir, what do we do?"
EB: "Normal procedure, Lieutenant, is to jump 200 feet in
     the air and scatter oneself over a wide area."
-- Somewhere in No Man's Land, BA4
------------------------------------------------------------
     Rob Baumstark:   shirak@connect.ab.ca
                      cst0656@nait.ab.ca
------------------------------------------------------------


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