Casting Times

From: Brett Williams (OKJinx@AOL.COM)
Date: 08/28/98


Ok. I've incorporated casting times before, now I am trying to recreate them
with a little easier code rather than a bunch of cut and paste duplicate code
all over. Problem is now it crashes as soon as u enter "cast '<spell>'..."

I have tried to narrow down the problem... here's clips from spell_parser::

ACMD(do_cast)
{
  struct char_data *tch = NULL;
  struct obj_data *tobj = NULL;
  char *s, *t;
  int spellnum, target = 0;

...(the normal beginning of do_cast down to here)...

    send_to_char("You are unfamiliar with that spell.\r\n", ch);
    return;
  }
  target = spell_target(ch, t, spellnum, tch, tobj);
  CASTING_TARGET(ch) = t;
  CASTING_SPELLNUM(ch) = spellnum;
  CASTING_TIME(ch) = SINFO.casting_time;
  act("&CYou begin casting.", TRUE, ch, 0, 0, TO_CHAR);
  if (GET_SKILL(ch, SINFO.skill) < number(80,100))     /* Silent casting */
    act("&C$n begins casting.", TRUE, ch, 0, 0, TO_ROOM);
  SET_BIT(PLR_FLAGS(ch), PLR_CASTING);
}

K, I have reason to believe its in spell_target, just cause thats the new
thing I'm trying... Heres spell_target::

int spell_target(struct char_data * ch, char *t, int spellnum, struct
char_data * tch, struct obj_data * tobj)
{
  int target = 0, i;

  /* Find the target */
  if (t != NULL) {
    one_argument(strcpy(arg, t), t);
    skip_spaces(&t);
  }
  if (IS_SET(SINFO.targets, TAR_IGNORE)) {
    target = TRUE;
  } else if (t != NULL && *t) {
    if (!target && (IS_SET(SINFO.targets, TAR_CHAR_ROOM))) {
      if ((tch = get_char_room_vis(ch, t)) != NULL)
        target = TRUE;
    }
    if (!target && IS_SET(SINFO.targets, TAR_CHAR_WORLD))
      if ((tch = get_char_vis(ch, t)))
        target = TRUE;

    if (!target && IS_SET(SINFO.targets, TAR_OBJ_INV))
      if ((tobj = get_obj_in_list_vis(ch, t, ch->carrying)))
        target = TRUE;

    if (!target && IS_SET(SINFO.targets, TAR_OBJ_EQUIP)) {
      for (i = 0; !target && i < NUM_WEARS; i++)
        if (GET_EQ(ch, i) && isname(t, GET_EQ(ch, i)->name)) {
          tobj = GET_EQ(ch, i);
          target = TRUE;
        }
    }
    if (!target && IS_SET(SINFO.targets, TAR_OBJ_ROOM))
      if ((tobj = get_obj_in_list_vis(ch, t, world[ch->in_room].contents)))
        target = TRUE;

    if (!target && IS_SET(SINFO.targets, TAR_OBJ_WORLD))
      if ((tobj = get_obj_vis(ch, t)))
        target = TRUE;

  } else {                      /* if target string is empty */
    if (!target && IS_SET(SINFO.targets, TAR_FIGHT_SELF))
      if (FIGHTING(ch) != NULL) {
        tch = ch;
        target = TRUE;
      }
    if (!target && IS_SET(SINFO.targets, TAR_FIGHT_VICT))
      if (FIGHTING(ch) != NULL) {
        tch = FIGHTING(ch);
        target = TRUE;
      }
    /* if no target specified, and the spell isn't violent, default to self */
    if (!target && IS_SET(SINFO.targets, TAR_CHAR_ROOM) &&
        !SINFO.violent) {
      tch = ch;
      target = TRUE;
    }
  }
  return target;
}

SORRY for all the code but I feel its kinda necessary? ... Ok, well it could
also be in pulse_casting, which happens every second to check casting times
...
pulse_casting::

void pulse_casting(void)
{
  struct char_data *i = NULL, *next_char;

  for (i = character_list; i; i = next_char) {
    next_char = i->next;
    if (PLR_FLAGGED(i, PLR_CASTING)) {
      CASTING_TIME(i)--;
      if (!CASTING_TIME(i))
        casting_complete(i);
    }
  }
}


Alright ... I'm not going to paste anymore code cuz its not worth it ...
anyway, i am totally lost all it know is it crashes right after you type
"cast"

Thanx bunch.

Okay,
    JinX


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