Re: skill/spell messages

From: Edward Felch (dustlos@hotmail.com)
Date: 03/29/01


im pretty sure i didnt make any changes that would affect the message structure
MAX_MESSAGES is set at 90 which is plenty for it now, and the file is in the
write place and is readable
from fight.c

void load_messages(void)
{
  FILE *fl;
  int i, type;
  struct message_type *messages;
  char chk[128];

  if (!(fl = fopen(MESS_FILE, "r"))) {
    sprintf(buf2, "SYSERR: Error reading combat message file %s",
MESS_FILE);
    perror(buf2);
    exit(1);
  }
  for (i = 0; i < MAX_MESSAGES; i++) {
    fight_messages[i].a_type = 0;
    fight_messages[i].number_of_attacks = 0;
    fight_messages[i].msg = 0;
  }


  fgets(chk, 128, fl);
  while (!feof(fl) && (*chk == '\n' || *chk == '*'))
    fgets(chk, 128, fl);

  while (*chk == 'M') {
    fgets(chk, 128, fl);
    sscanf(chk, " %d\n", &type);
    for (i = 0; (i < MAX_MESSAGES) && (fight_messages[i].a_type != type) &&
  (fight_messages[i].a_type); i++);
    if (i >= MAX_MESSAGES) {
      log("SYSERR: Too many combat messages.  Increase MAX_MESSAGES and
recompile.");
      exit(1);
    }
    CREATE(messages, struct message_type, 1);
    fight_messages[i].number_of_attacks++;
    fight_messages[i].a_type = type;
    messages->next = fight_messages[i].msg;
    fight_messages[i].msg = messages;

    messages->die_msg.attacker_msg = fread_action(fl, i);
    messages->die_msg.victim_msg = fread_action(fl, i);
    messages->die_msg.room_msg = fread_action(fl, i);
    messages->miss_msg.attacker_msg = fread_action(fl, i);
    messages->miss_msg.victim_msg = fread_action(fl, i);
    messages->miss_msg.room_msg = fread_action(fl, i);
    messages->hit_msg.attacker_msg = fread_action(fl, i);
    messages->hit_msg.victim_msg = fread_action(fl, i);
    messages->hit_msg.room_msg = fread_action(fl, i);
    messages->god_msg.attacker_msg = fread_action(fl, i);
    messages->god_msg.victim_msg = fread_action(fl, i);
    messages->god_msg.room_msg = fread_action(fl, i);
    fgets(chk, 128, fl);
    while (!feof(fl) && (*chk == '\n' || *chk == '*'))
      fgets(chk, 128, fl);
  }

  fclose(fl);
}


/*
 * message for doing damage with a spell or skill
 *  C3.0: Also used for weapon damage on miss and death blows
 */
int skill_message(int dam, struct char_data * ch, struct char_data * vict,
        int attacktype)
{
  int i, j, nr;
  struct message_type *msg;

  struct obj_data *weap = GET_EQ(ch, WEAR_WIELD);

  for (i = 0; i < MAX_MESSAGES; i++) {
    if (fight_messages[i].a_type == attacktype) {
      nr = dice(1, fight_messages[i].number_of_attacks);
      for (j = 1, msg = fight_messages[i].msg; (j < nr) && msg; j++)
 msg = msg->next;

      if (!IS_NPC(vict) && (GET_LEVEL(vict) >= LVL_IMMORT)) {
 act(msg->god_msg.attacker_msg, FALSE, ch, weap, vict, TO_CHAR);
 act(msg->god_msg.victim_msg, FALSE, ch, weap, vict, TO_VICT);
 act(msg->god_msg.room_msg, FALSE, ch, weap, vict, TO_NOTVICT);
      } else if (dam != 0) {
 if (GET_POS(vict) == POS_DEAD) {
   send_to_char(CCYEL(ch, C_CMP), ch);
          sprintf(buf2, "&y(&Y%-3d&y) ", dam);
          send_to_char(buf2,ch);
   act(msg->die_msg.attacker_msg, FALSE, ch, weap, vict, TO_CHAR);
   send_to_char(CCNRM(ch, C_CMP), ch);

   send_to_char(CCRED(vict, C_CMP), vict);
          sprintf(buf2, "&r(&R%-3d&r) ", dam);
          send_to_char(buf2,vict);
   act(msg->die_msg.victim_msg, FALSE, ch, weap, vict, TO_VICT | TO_SLEEP);
   send_to_char(CCNRM(vict, C_CMP), vict);

   act(msg->die_msg.room_msg, FALSE, ch, weap, vict, TO_NOTVICT);
 } else {
   send_to_char(CCYEL(ch, C_CMP), ch);
          sprintf(buf2, "&y(&Y%-3d&y) ", dam);
          send_to_char(buf2,ch);
   act(msg->hit_msg.attacker_msg, FALSE, ch, weap, vict, TO_CHAR);
   send_to_char(CCNRM(ch, C_CMP), ch);

   send_to_char(CCRED(vict, C_CMP), vict);
          sprintf(buf2, "&r(&R%-3d&r) ", dam);
          send_to_char(buf2,vict);
   act(msg->hit_msg.victim_msg, FALSE, ch, weap, vict, TO_VICT | TO_SLEEP);
   send_to_char(CCNRM(vict, C_CMP), vict);

   act(msg->hit_msg.room_msg, FALSE, ch, weap, vict, TO_NOTVICT);
 }
      } else if (ch != vict) { /* Dam == 0 */
        if (ch->in_room != vict->in_room) return 0;

 send_to_char(CCYEL(ch, C_CMP), ch);
        sprintf(buf2, "&y(&Y%-3d&y) ", dam);
        send_to_char(buf2,ch);
 act(msg->miss_msg.attacker_msg, FALSE, ch, weap, vict, TO_CHAR);
 send_to_char(CCNRM(ch, C_CMP), ch);

 send_to_char(CCRED(vict, C_CMP), vict);
        sprintf(buf2, "&r(&R%-3d&r) ", dam);
        send_to_char(buf2,vict);
 act(msg->miss_msg.victim_msg, FALSE, ch, weap, vict, TO_VICT | TO_SLEEP);
 send_to_char(CCNRM(vict, C_CMP), vict);

 act(msg->miss_msg.room_msg, FALSE, ch, weap, vict, TO_NOTVICT);
      }
      return 1;
    }
  }
  return 0;
}

and from structs.h
struct msg_type {
   char *attacker_msg;  /* message to attacker */
   char *victim_msg;    /* message to victim   */
   char *room_msg;      /* message to room     */
};


struct message_type {
   struct msg_type die_msg; /* messages when death   */
   struct msg_type miss_msg; /* messages when miss   */
   struct msg_type hit_msg; /* messages when hit   */
   struct msg_type god_msg; /* messages when hit on god  */
   struct message_type *next; /* to next messages of this kind. */
};


struct message_list {
   int a_type;   /* Attack type    */
   int number_of_attacks; /* How many attack messages to chose from. */
   struct message_type *msg; /* List of messages.   */
};

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/04/01 PST