Re: [code][newbie]modifying int damage and void hit in fight.c

From: Robert Moon (LegalWriter@earthlink.net)
Date: 08/08/99


At 11:33 AM 8/8/99 -0400, you wrote:
>Again, no errors, no crashes.... but how do I know 1)that the dwarves
>are actually getting the bonus, 2) are others getting the bonus, 3) is
>there a better way to add in the bonus rather than throwing in the +1
>into the line with GET_WIS?

If you don't know how to use a debugging program like gdb, where you can
access the value of variables at any given time, among other things, a
quick "poor man's" debugging solution is to add send_to_char lines that
print out those values to the acting character when they are used in a
routine.  When you're confident about your coding, take out the extra
send_to_char lines.  And yes, your code is flawed with respect to adding
the THAC0 bonus into the wisdom modifier.  It is completely unnecessary to
duplicate the entire "Calculate THACO" section of "void hit(ch, victim,
type)" specifically for giant slayers.  You only need one such
determination for all players.  Just one new line is required to check for
the bonus for giant slayers rather than duplicating the 10 or so lines that
you did.  Erase what you added and just change the one section of
"Calculate THAC0," as follows:

  /* Calculate the THAC0 of the attacker */
  if (!IS_NPC(ch))
    calc_thaco = thaco((int) GET_CLASS(ch), (int) GET_LEVEL(ch));
  else          /* THAC0 for monsters is set in the HitRoll */
    calc_thaco = 20;
  calc_thaco -= str_app[STRENGTH_APPLY_INDEX(ch)].tohit;
  calc_thaco -= GET_HITROLL(ch);
  calc_thaco -= (int) ((GET_INT(ch) - 13) / 1.5);   /* Intelligence helps! */
  calc_thaco -= (int) ((GET_WIS(ch) - 13) / 1.5);   /* So does wisdom */
  if (AFF_FLAGGED(ch, AFF_GIANT_SLAYER) && MOB_FLAGGED(victim, MOB_GIANTSZ)) {
    calc_thaco--;    /* +1 to hit for giant slayers */
    send_to_char ("DUBUGGING INFO:  Giant Slayer "to hit" bonus of +1
added.\r\n", ch);
  }

The "calc_thaco--;" line is the same as:
   calc_thaco += 1;
which is the same as:
   calc_thaco = calc_thaco +1;

Further, if you want to check to see if your damage bonus is being applied
properly, change your giant slayer bonus check as follows:

 /* putting bonus to damage if giantslayer */
 if (AFF_FLAGGED(ch, AFF_GIANT_SLAYER) && MOB_FLAGGED(victim, MOB_GIANTSZ)) {
  dam += 2;
  send_to_char ("DUBUGGING INFO:  Giant Slayer damage bonus of +2
added.\r\n", ch);
  }

None of your character should then get the "DUBUGGING INFO" lines unless
they are (a) flagged as a giant slayer and (b) are attacking a mob that is
flagged a giant.  When you are confident that your code is operating
correctly, remove the extra send_to_char debugging lines and the PAIR of
braces that were added to each of those "if" statements.  If you only
remove one brace and try to compile, your screen will scroll with dozens of
pages of errors.  Good luck.

--Rob.
-------
ICQ:  14598527


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