/** * Stack a codified message for the given monster race. You must supply * the description of some monster of this race. You can also supply * different monster descriptions for the same race. * Return TRUE on success. */ bool add_monster_message(const char *mon_name, struct monster *m_ptr, int msg_code, bool delay) { int i; byte mon_flags = 0; int r_idx = m_ptr->r_idx; assert(msg_code >= 0 && msg_code < MAX_MON_MSG); if (redundant_monster_message(m_ptr, msg_code)) return (FALSE); /* Paranoia */ if (!mon_name || !mon_name[0]) mon_name = "it"; /* Save the "hidden" mark, if present */ if (strstr(mon_name, "(hidden)")) mon_flags |= 0x01; /* Save the "offscreen" mark, if present */ if (strstr(mon_name, "(offscreen)")) mon_flags |= 0x02; /* Monster is invisible or out of LOS */ if (streq(mon_name, "it") || streq(mon_name, "something")) mon_flags |= 0x04; /* Query if the message is already stored */ for (i = 0; i < size_mon_msg; i++) { /* We found the race and the message code */ if ((mon_msg[i].mon_race == r_idx) && (mon_msg[i].mon_flags == mon_flags) && (mon_msg[i].msg_code == msg_code)) { /* Can we increment the counter? */ if (mon_msg[i].mon_count < MAX_UCHAR) { /* Stack the message */ ++(mon_msg[i].mon_count); } /* Success */ return (TRUE); } } /* The message isn't stored. Check free space */ if (size_mon_msg >= MAX_STORED_MON_MSG) return (FALSE); /* Assign the message data to the free slot */ mon_msg[i].mon_race = r_idx; mon_msg[i].mon_flags = mon_flags; mon_msg[i].msg_code = msg_code; mon_msg[i].delay = delay; /* Just this monster so far */ mon_msg[i].mon_count = 1; /* One more entry */ ++size_mon_msg; p_ptr->notice |= PN_MON_MESSAGE; /* record which monster had this message stored */ if (size_mon_hist >= MAX_STORED_MON_CODES) return (TRUE); mon_message_hist[size_mon_hist].mon = m_ptr; mon_message_hist[size_mon_hist].message_code = msg_code; size_mon_hist++; /* Success */ return (TRUE); }
/** * Stack a codified message for the given monster race. You must supply * the description of some monster of this race. You can also supply * different monster descriptions for the same race. * Return TRUE on success. */ bool add_monster_message(const char *mon_name, struct monster *m_ptr, int msg_code, bool delay) { int i; byte mon_flags = 0; assert(msg_code >= 0 && msg_code < MON_MSG_MAX); if (redundant_monster_message(m_ptr, msg_code)) return (FALSE); /* Paranoia */ if (!mon_name || !mon_name[0]) mon_name = "it"; /* Save the "hidden" mark, if present */ if (strstr(mon_name, "(hidden)")) mon_flags |= MON_MSG_FLAG_HIDDEN; /* Save the "offscreen" mark, if present */ if (strstr(mon_name, "(offscreen)")) mon_flags |= MON_MSG_FLAG_OFFSCREEN; /* Monster is invisible or out of LOS */ if (streq(mon_name, "it") || streq(mon_name, "something")) mon_flags |= MON_MSG_FLAG_INVISIBLE; /* Query if the message is already stored */ for (i = 0; i < size_mon_msg; i++) { /* We found the race and the message code */ if ((mon_msg[i].race == m_ptr->race) && (mon_msg[i].mon_flags == mon_flags) && (mon_msg[i].msg_code == msg_code)) { /* Can we increment the counter? */ if (mon_msg[i].mon_count < MAX_UCHAR) { /* Stack the message */ ++(mon_msg[i].mon_count); } /* Success */ return (TRUE); } } /* The message isn't stored. Check free space */ if (size_mon_msg >= MAX_STORED_MON_MSG) return (FALSE); /* Assign the message data to the free slot */ mon_msg[i].race = m_ptr->race; mon_msg[i].mon_flags = mon_flags; mon_msg[i].msg_code = msg_code; mon_msg[i].delay = delay; mon_msg[i].delay_tag = MON_DELAY_TAG_DEFAULT; /* Just this monster so far */ mon_msg[i].mon_count = 1; /* Force all death messages to go at the end of the group for * logical presentation */ if (msg_code == MON_MSG_DIE || msg_code == MON_MSG_DESTROYED) { mon_msg[i].delay = TRUE; mon_msg[i].delay_tag = MON_DELAY_TAG_DEATH; } /* One more entry */ ++size_mon_msg; player->upkeep->notice |= PN_MON_MESSAGE; /* record which monster had this message stored */ if (size_mon_hist >= MAX_STORED_MON_CODES) return (TRUE); mon_message_hist[size_mon_hist].mon = m_ptr; mon_message_hist[size_mon_hist].message_code = msg_code; size_mon_hist++; /* Success */ return (TRUE); }