Sign Program, Skill Parsing

From: ;P (siv@CYBERENET.NET)
Date: 01/15/98


heya..someone mentioned the sign program a couple of days ago (a prog
that would display a text to a telnet port)..well..apparently, it doesn't
come with freebsd..so, were you guys talking about linux? would someone be
able to send me the source code for it?

siv

ObCircle:
Let's see..i've redone my spell and skill system so that everything uses
a generic parser...i was wondering what others might think of
this..it seemed to me that i cut out a LOT of redundant code, but is
there anything that i might be missing? this is what my skill_command
looks like:

ACMD(do_skill)
{
  if (subcmd) {                 // skills use skill_number as subcmd
    skill = subcmd;
    if (!IS_NPC(ch) && !GET_SKILL(ch, skill)) {
      send_to_char("You don't know how!!\r\n", ch);
      return;
    }
    t = strtok(argument, "\0");
    if (t != NULL) {
      two_arguments(strcpy(arg, t), test1, test2);
      t = strdup(test1);
      npc_percent = strdup(test2);
      skip_spaces(&t);
      skip_spaces(&npc_percent);
    }
  } else {              // came from "cast"...no subcmd
    /* get: blank, spell name, target name */
    s = strtok(argument, "'");
    if (s == NULL) {
      send_to_char("Cast what where?\r\n", ch);
      return;
    }
    s = strtok(NULL, "'");
    if (s == NULL) {
      send_to_char("Spell names... Holy Magic Symbols: '\r\n", ch);
      return;
    }
    t = strtok(NULL, "\0");
    if (t != NULL) {
      two_arguments(strcpy(arg, t), test1, test2);
      t = strdup(test1);
      npc_percent = strdup(test2);
      skip_spaces(&t);
      skip_spaces(&npc_percent);
    }
    skill = find_skill_num(s);
    if ((skill < 1) || (skill > MAX_SPELLS)) {
      send_to_char("Cast what?!?\r\n", ch);
      return;
    }
    if (!IS_NPC(ch) && GET_SKILL(ch, skill) == 0) {
      send_to_char("You are unfamiliar with that spell.\r\n", ch);
      return;
    }
  }
  if (IS_NPC(ch) && !*npc_percent) {
    sprintf(buf, "(MP) No skill percentage - %s", GET_NAME(ch));
    log_info(buf);
    return;
  }
  if (IS_SET(SINFO.targets, targets_char))
    tch = find_target_char(ch, skill, t);
  else if (IS_SET(SINFO.targets, targets_object)) {
    tobj = find_target_object(ch, skill, t);
    targ_is_char = FALSE;
  } else
    tch = ch;

  if (!(tch || tobj)) {
    sprintf(buf, "%s is that?!?\r\n", targ_is_char ? "Who" : "What");
    send_to_char(buf, ch);
    return;
  }
  if (IS_SET(SINFO.targets, TAR_CHAR_GROUP) && !check_group(ch, tch)) {
      send_to_char("You can only do that to members of your group.\r\n", ch);
      return;
  }
  if (tch && SINFO.violent) {
    if ((tch == ch) && !IS_SET(SINFO.targets, TAR_IGNORE)) {
      send_to_char("That would be very hazardous to your health.\r\n", ch);
      return;
    }
    if (!ok_pkill(ch, tch))
      return;
    if (ROOM_FLAGGED(ch->in_room, ROOM_PEACEFUL)) {
      send_to_char("This room just has a peaceful, easy feeling...\r\n", ch);
      return;
    }
    if (MOB_FLAGGED(tch, (MOB_NOFIGHT | MOB_INTANGIBLE))) {
      send_to_char("That wouldn't be very nice..\r\n", ch);
      return;
    }
    if (IS_AFFECTED(ch, AFF_CHARM) && (tch == ch->master)) {
      send_to_char("You would never think about hurting your master!!\r\n", ch);
      return;
    }
    if (!IS_NPC(ch) && FIGHTING(tch) && !check_group(ch, FIGHTING(tch))) {
      send_to_char("It seems that your victim is already fighting.\r\n", ch);
      return;
    }
  }
  if (skill <= MAX_SPELLS)
    if (!cast_spell(ch, tch, tobj, skill))
      return;
  if (SINFO.lag > 0)
    WAIT_STATE(ch, SINFO.lag);

  if ((tmp_int = other_requirements(ch, skill, tch, tobj)) == 1)
    succeed = FALSE;
  else if (tmp_int == 2)
    return;

  if (!skill_cost(ch, skill))
    return;

  if ((succeed == TRUE) && !skill_check(ch, skill, npc_percent))
    succeed = FALSE;

  if (SINFO.delay) {
    if (ch->delayed_skl) {
      send_to_char("You're in the middle of something already.\r\n", ch);
      return;
    }
    CREATE(ev_o, struct del_skl_info, 1);
    ev_o->ch = ch;
    ev_o->tch = tch;
    ev_o->tobj = tobj;
    ev_o->skill = skill;
    ev_o->succeed = succeed;
    ch->delayed_skl = add_event(SINFO.delay, delayed_skill, ev_o, ch);
    return;
  }
  perform_skill(ch, skill, tch, tobj, succeed);
  if (succeed == TRUE)
    improve_skill(ch, skill);
}


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