[CODE] THAC0 function replacement

From: Eric Jones (fpicard@mindless.com)
Date: 04/19/99


I was wading through the stock bpl15 code and decided I would try to slim down
some of the class.c functions.  I was able to replace the HUGE switch
statements in class.c's thaco function with a few formulas.  The formulas give
the exact same results as the stock switch statements, with the exception that
I made every level from LVL_IMMORT on up get a THAC0 of 1 automatically.

---cut here ---
/* THAC0 for classes and levels.  (To Hit Armor Class 0) */
int thaco(int class_num, int level)
{
  switch (class_num) {
  case CLASS_MAGIC_USER:
    if (level < 1)
        return (100);
    if (level >= LVL_IMMORT)
        return (1);
    return (20 - ((level - 1) / 3));
  case CLASS_CLERIC:
    if (level < 1)
        return (100);
    if (level >= LVL_IMMORT)
        return (1);
    if (level < 4)
        return (20 - ((level - 1) / 3));
    return (20 - ((level - 1) / 3) - ((level - 1) / 3));
  case CLASS_THIEF:
    if (level < 1)
        return (100);
    if (level >= LVL_IMMORT)
        return (1);
    return (20 - ((level - 1) / 2));
  case CLASS_WARRIOR:
    if (level < 1)
        return (100);
    if (level >= 21)
        return (1);
    if (level < 8)
        return (20 - (level - 1));
    return (20 - (level - 2));
  default:
    log("SYSERR: Unknown class in thac0 chart.");
  }

---
Eric Jones +++ fpicard@mindless.com
"Barbarus hic ego sum, qui non intelligor illis." - OVID
Running and building CircleMUD under Win32.


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