Re: [CODE] THAC0 function replacement

From: Joshua Crawford (joshuacrawford@rocketmail.com)
Date: 04/19/99


---Eric Jones <fpicard@mindless.com> wrote:
>
> 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.
>

You may already have realised it, but you can trim this
down quite a bit more:-

> ---cut here ---
/* THAC0 for classes and levels.  (To Hit Armor Class 0) */
int thaco(int class_num, int level)
{
  if (level < 1)
      return (100);
  if (level >= LVL_IMMORT)
      return (1);

  switch (class_num) {
    case CLASS_MAGIC_USER:
      return (20 - ((level - 1) / 3));
    case CLASS_CLERIC:
      if (level < 4)
        return (20 - ((level - 1) / 3));
      return (20 - ((level - 1) / 3) - ((level - 1) / 3));
    case CLASS_THIEF:
      return (20 - ((level - 1) / 2));
    case CLASS_WARRIOR:
      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.
>
--
*----------------------------------------*
| Joshua Crawford - bruce@audiophile.com |
| Mobile: +61 414 790173                 |
*----------------------------------------*

_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com


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