[CODE] Small Problem

From: Brian Guilbault (guil9964@nova.gmi.edu)
Date: 10/03/96


Hi All-

I wrote this litte Zap command for a fun way to remind mortals who's in
charge.
Well, apparently gcc tells me that "victim" might be used uninitialized in
the
function, which I know is true because of the way it works (not comparing
levels correctly, etc). I don't know what's wrong because I've written
commands
like this many times before and did it nearly identically and never had
initialization
problems. I thought the struct char_data *victim line took care of that.
Anyway here's
the code. Any help is appreciated.

    -Brian


ACMD(do_zap)
{
  struct char_data *victim;
  int zap_points;

  one_argument(argument, arg);

  if (!*arg) {
    send_to_char("Who do you want to zap?\r\n", ch);
    return;
  }
  if (IS_NPC(victim)) {
    send_to_char("You can't zap a mob!\r\n", ch);
    return;
  }
  if (GET_LEVEL(victim) >= GET_LEVEL(ch)) {
    send_to_char("Probably not a good idea.\r\n", ch);
    return;
  }
  switch (GET_LEVEL(ch)) {
    case LVL_IMMORT:    zap_points = GET_HIT(victim) / 10; break;
    case LVL_LDTY:
    case LVL_QTOR:      zap_points = GET_HIT(victim) / 6; break;
    case LVL_QMST:
    case LVL_DTY:       zap_points = GET_HIT(victim) / 5; break;
    case LVL_GDTY:      zap_points = GET_HIT(victim) / 4; break;
    case LVL_GOD:       zap_points = GET_HIT(victim) / 3; break;
    case LVL_GRGOD:
    case LVL_IMPL:      zap_points = GET_HIT(victim) / 2; break;
    default:            zap_points = 0; break;
  }
  send_to_all("The clouds part and a powerful bolt of lightning arcs from 
the s$  sprintf(buf, "%s is struck down by the unholy wrath of %s!\r\n",
    GET_NAME(victim), GET_NAME(ch));
  send_to_all(buf);
  sprintf(buf, "(GC) %s ZAPPED %s for %i damage.", GET_NAME(ch),
    GET_NAME(victim), zap_points);
  mudlog(buf, NRM, LVL_HERO, FALSE);

  GET_HIT(victim) -= zap_points;
}
+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST