/* File: monster2.c */
-/* Purpose: misc code for monsters */
-
/*
- * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
*
- * This software may be copied and distributed for educational, research, and
- * not for profit purposes provided that this copyright and statement are
- * included in all such copies.
+ * This software may be copied and distributed for educational, research,
+ * and not for profit purposes provided that this copyright and statement
+ * are included in all such copies. Other copyrights may also apply.
*/
+/* Purpose: misc code for monsters */
+
#include "angband.h"
#define HORDE_NOGOOD 0x01
#define HORDE_NOEVIL 0x02
-bool is_kage = FALSE;
-u16b horde_align = 0;
-
cptr horror_desc[MAX_SAN_HORROR] =
{
#ifdef JP
/*
+ * Set the target of counter attack
+ */
+void set_target(monster_type *m_ptr, int y, int x)
+{
+ m_ptr->target_y = y;
+ m_ptr->target_x = x;
+}
+
+
+/*
+ * Reset the target of counter attack
+ */
+void reset_target(monster_type *m_ptr)
+{
+ set_target(m_ptr, 0, 0);
+}
+
+
+/*
+ * Extract monster race pointer of a monster's true form
+ */
+monster_race *real_r_ptr(monster_type *m_ptr)
+{
+ monster_race *r_ptr = &r_info[m_ptr->r_idx];
+
+ /* Extract real race */
+ if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
+ {
+ if (r_ptr->flags1 & RF1_UNIQUE)
+ return &r_info[MON_CHAMELEON_K];
+ else
+ return &r_info[MON_CHAMELEON];
+ }
+ else
+ {
+ return r_ptr;
+ }
+}
+
+
+/*
* Delete a monster by index.
*
* When a monster is deleted, all of its objects are deleted.
/* Hack -- Reduce the racial counter */
- if (m_ptr->mflag2 & MFLAG_CHAMELEON)
- {
- if (r_ptr->flags1 & RF1_UNIQUE)
- r_info[MON_CHAMELEON_K].cur_num--;
- else
- r_info[MON_CHAMELEON].cur_num--;
- }
- else
- {
- r_ptr->cur_num--;
- }
+ real_r_ptr(m_ptr)->cur_num--;
/* Hack -- count the number of "reproducers" */
if (r_ptr->flags2 & (RF2_MULTIPLY)) num_repro--;
/* Acquire next object */
next_o_idx = o_ptr->next_o_idx;
- /* Hack -- efficiency */
- o_ptr->held_m_idx = 0;
+ /*
+ * o_ptr->held_m_idx is needed in delete_object_idx()
+ * to prevent calling lite_spot()
+ */
/* Delete the object */
delete_object_idx(this_o_idx);
/* Visual update */
lite_spot(y, x);
+
+ /* Update some things */
+ if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
+ p_ptr->update |= (PU_MON_LITE);
}
*/
static void compact_monsters_aux(int i1, int i2)
{
- int y, x;
+ int y, x, i;
cave_type *c_ptr;
/* Hack -- Update the health bar */
if (p_ptr->health_who == i1) health_track(i2);
+ /* Hack -- Update parent index */
+ if (is_pet(m_ptr))
+ {
+ for (i = 1; i < m_max; i++)
+ {
+ monster_type *m2_ptr = &m_list[i];
+
+ if (m2_ptr->parent_m_idx == i1)
+ m2_ptr->parent_m_idx = i2;
+ }
+ }
+
/* Structure copy */
COPY(&m_list[i2], &m_list[i1], monster_type);
if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
/* All monsters get a saving throw */
- if (rand_int(100) < chance) continue;
+ if (randint0(100) < chance) continue;
/* Delete the monster */
delete_monster_idx(i);
{
monster_type *m_ptr = &m_list[i];
- monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
/* Skip dead monsters */
if (!m_ptr->r_idx) continue;
- /* Mega-Hack -- preserve Unique's XXX XXX XXX */
-
- /* Hack -- Reduce the racial counter */
- if (m_ptr->mflag2 & MFLAG_CHAMELEON)
- {
- if (r_ptr->flags1 & RF1_UNIQUE)
- r_info[MON_CHAMELEON_K].cur_num = 0;
- else
- r_info[MON_CHAMELEON].cur_num = 0;
- }
- else
- r_ptr->cur_num = 0;
-
/* Monster is gone */
cave[m_ptr->fy][m_ptr->fx].m_idx = 0;
}
+ /*
+ * Wiping racial counters of all monsters and incrementing of racial
+ * counters of monsters in party_mon[] is required to prevent multiple
+ * generation of unique monster who is the minion of player.
+ */
+
+ /* Hack -- Wipe the racial counter of all monster races */
+ for (i = 1; i < max_r_idx; i++) r_info[i].cur_num = 0;
+
/* Reset "m_max" */
m_max = 1;
static int summon_specific_who = -1;
-/*
- * Hack -- the hostility of the summoned monster
- */
-static int summon_specific_hostile = TRUE;
-
static bool summon_unique_okay = FALSE;
case SUMMON_HI_UNDEAD:
{
okay = ((r_ptr->d_char == 'L') ||
- (r_ptr->d_char == 'V') ||
- (r_ptr->d_char == 'W'));
+ (r_ptr->d_char == 'V') ||
+ (r_ptr->d_char == 'W'));
break;
}
case SUMMON_BIZARRE6:
{
okay = ((r_ptr->d_char == '!') ||
- (r_ptr->d_char == '?') ||
- (r_ptr->d_char == '=') ||
- (r_ptr->d_char == '$') ||
- (r_ptr->d_char == '|'));
+ (r_ptr->d_char == '?') ||
+ (r_ptr->d_char == '=') ||
+ (r_ptr->d_char == '$') ||
+ (r_ptr->d_char == '|'));
break;
}
case SUMMON_CYBER:
{
okay = ((r_ptr->d_char == 'U') &&
- (r_ptr->flags4 & RF4_ROCKET));
+ (r_ptr->flags4 & RF4_ROCKET));
break;
}
case SUMMON_ANIMAL_RANGER:
{
okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
- (strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
+ (my_strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
!(r_ptr->flags3 & (RF3_DRAGON)) &&
!(r_ptr->flags3 & (RF3_EVIL)) &&
!(r_ptr->flags3 & (RF3_UNDEAD)) &&
case SUMMON_HI_DRAGON_LIVING:
{
- okay = ((r_ptr->d_char == 'D') &&
- !(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)));
+ okay = ((r_ptr->d_char == 'D') && monster_living(r_ptr));
break;
}
case SUMMON_LIVING:
{
- okay = (!(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)));
+ okay = monster_living(r_ptr);
break;
}
for (i = 0; i < 4; i++)
if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
- okay = (okay && (!(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING))));
+ okay = (okay && monster_living(r_ptr));
break;
}
okay = (r_ptr->flags7 & RF7_GUARDIAN);
break;
}
+
+ case SUMMON_KNIGHTS:
+ {
+ okay = ((r_idx == MON_NOV_PALADIN) ||
+ (r_idx == MON_NOV_PALADIN_G) ||
+ (r_idx == MON_PALADIN) ||
+ (r_idx == MON_W_KNIGHT) ||
+ (r_idx == MON_ULTRA_PALADIN) ||
+ (r_idx == MON_KNI_TEMPLAR));
+ break;
+ }
+
+ case SUMMON_EAGLES:
+ {
+ okay = (r_ptr->d_char == 'B' &&
+ (r_ptr->flags8 & RF8_WILD_MOUNTAIN) &&
+ (r_ptr->flags8 & RF8_WILD_ONLY));
+ break;
+ }
+
+ case SUMMON_PIRANHAS:
+ {
+ okay = (r_idx == MON_PIRANHA);
+ break;
+ }
+
+ case SUMMON_ARMAGE_GOOD:
+ {
+ okay = (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_GOOD));
+ break;
+ }
+
+ case SUMMON_ARMAGE_EVIL:
+ {
+ okay = ((r_ptr->flags3 & RF3_DEMON) ||
+ (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_EVIL)));
+ break;
+ }
}
/* Result */
}
-static bool chameleon_change = FALSE;
+static int chameleon_change_m_idx = 0;
/*
{
dungeon_info_type *d_ptr = &d_info[dungeon_type];
monster_race *r_ptr = &r_info[r_idx];
- byte a;
+ byte a;
if (d_ptr->flags1 & DF1_CHAMELEON)
{
- if (chameleon_change) return TRUE;
+ if (chameleon_change_m_idx) return TRUE;
}
if (d_ptr->flags1 & DF1_NO_MAGIC)
{
- if (r_idx == MON_CHAMELEON) return TRUE;
- if (r_ptr->freq_spell && !(r_ptr->flags4 & RF4_NOMAGIC_MASK) && !(r_ptr->flags5 & RF5_NOMAGIC_MASK) && !(r_ptr->flags6 & RF6_NOMAGIC_MASK))
+ if (r_idx != MON_CHAMELEON &&
+ r_ptr->freq_spell &&
+ !(r_ptr->flags4 & RF4_NOMAGIC_MASK) &&
+ !(r_ptr->flags5 & RF5_NOMAGIC_MASK) &&
+ !(r_ptr->flags6 & RF6_NOMAGIC_MASK))
return FALSE;
- else return TRUE;
}
if (d_ptr->flags1 & DF1_NO_MELEE)
{
!(r_ptr->flags5 & (RF5_BOLT_MASK | RF5_BEAM_MASK | RF5_BALL_MASK | RF5_CAUSE_1 | RF5_CAUSE_2 | RF5_CAUSE_3 | RF5_CAUSE_4 | RF5_MIND_BLAST | RF5_BRAIN_SMASH)) &&
!(r_ptr->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
return FALSE;
- else return TRUE;
}
if (d_ptr->flags1 & DF1_BEGINNER)
{
if (r_ptr->level > dun_level)
return FALSE;
- else return TRUE;
}
- if (d_ptr->special_div == 64) return TRUE;
+ if (d_ptr->special_div >= 64) return TRUE;
if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
- if(d_ptr->mode == DUNGEON_MODE_AND)
- {
- if (d_ptr->mflags1)
+ switch (d_ptr->mode)
+ {
+ case DUNGEON_MODE_AND:
+ if (d_ptr->mflags1)
+ {
+ if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
+ return FALSE;
+ }
+ if (d_ptr->mflags2)
{
- if((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
- return FALSE;
+ if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
+ return FALSE;
}
- if (d_ptr->mflags2)
+ if (d_ptr->mflags3)
{
- if((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
- return FALSE;
+ if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
+ return FALSE;
}
- if (d_ptr->mflags3)
+ if (d_ptr->mflags4)
{
- if((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
- return FALSE;
+ if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
+ return FALSE;
}
- if (d_ptr->mflags4)
+ if (d_ptr->mflags5)
{
- if((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
- return FALSE;
+ if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
+ return FALSE;
}
- if (d_ptr->mflags5)
+ if (d_ptr->mflags6)
{
- if((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
- return FALSE;
+ if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
+ return FALSE;
}
- if (d_ptr->mflags6)
+ if (d_ptr->mflags7)
{
- if((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
- return FALSE;
+ if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
+ return FALSE;
}
- if (d_ptr->mflags7)
+ if (d_ptr->mflags8)
{
- if((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
- return FALSE;
+ if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
+ return FALSE;
}
- if (d_ptr->mflags8)
+ if (d_ptr->mflags9)
{
- if((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
- return FALSE;
+ if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
+ return FALSE;
}
- if (d_ptr->mflags9)
+ if (d_ptr->mflagsr)
{
- if((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
- return FALSE;
+ if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
+ return FALSE;
}
- for(a = 0; a < 5; a++)
- if(d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
- }
- else if(d_ptr->mode == DUNGEON_MODE_NAND)
- {
- byte ok[9 + 5], i = 0, j = 0;
-
- if (d_ptr->mflags1)
+ for (a = 0; a < 5; a++)
+ if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
+
+ return TRUE;
+
+ case DUNGEON_MODE_NAND:
+ if (d_ptr->mflags1)
{
- i++;
- if(d_ptr->mflags1 & r_ptr->flags1)
- ok[0] = 1;
+ if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
+ return TRUE;
}
- if (d_ptr->mflags2)
+ if (d_ptr->mflags2)
{
- i++;
- if(d_ptr->mflags2 & r_ptr->flags2)
- ok[1] = 1;
+ if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
+ return TRUE;
}
- if (d_ptr->mflags3)
+ if (d_ptr->mflags3)
{
- i++;
- if(d_ptr->mflags3 & r_ptr->flags3)
- ok[2] = 1;
+ if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
+ return TRUE;
}
- if (d_ptr->mflags4)
+ if (d_ptr->mflags4)
{
- i++;
- if(d_ptr->mflags4 & r_ptr->flags4)
- ok[3] = 1;
+ if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
+ return TRUE;
}
- if (d_ptr->mflags5)
+ if (d_ptr->mflags5)
{
- i++;
- if(d_ptr->mflags5 & r_ptr->flags5)
- ok[4] = 1;
+ if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
+ return TRUE;
}
- if (d_ptr->mflags6)
+ if (d_ptr->mflags6)
{
- i++;
- if(d_ptr->mflags6 & r_ptr->flags6)
- ok[5] = 1;
+ if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
+ return TRUE;
}
- if (d_ptr->mflags7)
+ if (d_ptr->mflags7)
{
- i++;
- if(d_ptr->mflags7 & r_ptr->flags7)
- ok[6] = 1;
+ if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
+ return TRUE;
}
- if (d_ptr->mflags8)
+ if (d_ptr->mflags8)
{
- i++;
- if(d_ptr->mflags8 & r_ptr->flags8)
- ok[7] = 1;
+ if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
+ return TRUE;
}
- if (d_ptr->mflags9)
+ if (d_ptr->mflags9)
{
- i++;
- if(d_ptr->mflags9 & r_ptr->flags9)
- ok[8] = 1;
+ if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
+ return TRUE;
}
+ if (d_ptr->mflagsr)
+ {
+ if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
+ return TRUE;
+ }
+ for (a = 0; a < 5; a++)
+ if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return TRUE;
- for(a = 0; a < 5; a++)
- {
- if(d_ptr->r_char[a])
- {
- i++;
- if (d_ptr->r_char[a] != r_ptr->d_char) ok[9 + a] = 1;
- }
- }
-
- j = ok[0] + ok[1] + ok[2] + ok[3] + ok[4] + ok[5] + ok[6] + ok[7] + ok[8] + ok[9] + ok[10] + ok[11] + ok[12] + ok[13];
-
- if(i == j) return FALSE;
- }
- else if(d_ptr->mode == DUNGEON_MODE_OR)
- {
- byte ok = FALSE, i;
- s32b flag;
-
- for(i = 0; i < 32; i++)
- {
- flag = d_ptr->mflags1 & (1 << i);
- if(r_ptr->flags1 & flag) ok = TRUE;
-
- flag = d_ptr->mflags2 & (1 << i);
- if(r_ptr->flags2 & flag) ok = TRUE;
-
- flag = d_ptr->mflags3 & (1 << i);
- if(r_ptr->flags3 & flag) ok = TRUE;
-
- flag = d_ptr->mflags4 & (1 << i);
- if(r_ptr->flags4 & flag) ok = TRUE;
-
- flag = d_ptr->mflags5 & (1 << i);
- if(r_ptr->flags5 & flag) ok = TRUE;
-
- flag = d_ptr->mflags6 & (1 << i);
- if(r_ptr->flags6 & flag) ok = TRUE;
-
- flag = d_ptr->mflags7 & (1 << i);
- if(r_ptr->flags7 & flag) ok = TRUE;
-
- flag = d_ptr->mflags8 & (1 << i);
- if(r_ptr->flags8 & flag) ok = TRUE;
-
- flag = d_ptr->mflags9 & (1 << i);
- if(r_ptr->flags9 & flag) ok = TRUE;
- }
- for(a = 0; a < 5; a++)
- if(d_ptr->r_char[a] == r_ptr->d_char) ok = TRUE;
-
- return ok;
- }
- else if(d_ptr->mode == DUNGEON_MODE_NOR)
- {
- byte ok = TRUE, i;
- s32b flag;
-
- for(i = 0; i < 32; i++)
- {
- flag = d_ptr->mflags1 & (1 << i);
- if(r_ptr->flags1 & flag) ok = FALSE;
-
- flag = d_ptr->mflags2 & (1 << i);
- if(r_ptr->flags2 & flag) ok = FALSE;
-
- flag = d_ptr->mflags3 & (1 << i);
- if(r_ptr->flags3 & flag) ok = FALSE;
-
- flag = d_ptr->mflags4 & (1 << i);
- if(r_ptr->flags4 & flag) ok = FALSE;
-
- flag = d_ptr->mflags5 & (1 << i);
- if(r_ptr->flags5 & flag) ok = FALSE;
-
- flag = d_ptr->mflags6 & (1 << i);
- if(r_ptr->flags6 & flag) ok = FALSE;
+ return FALSE;
- flag = d_ptr->mflags7 & (1 << i);
- if(r_ptr->flags7 & flag) ok = FALSE;
+ case DUNGEON_MODE_OR:
+ if (r_ptr->flags1 & d_ptr->mflags1) return TRUE;
+ if (r_ptr->flags2 & d_ptr->mflags2) return TRUE;
+ if (r_ptr->flags3 & d_ptr->mflags3) return TRUE;
+ if (r_ptr->flags4 & d_ptr->mflags4) return TRUE;
+ if (r_ptr->flags5 & d_ptr->mflags5) return TRUE;
+ if (r_ptr->flags6 & d_ptr->mflags6) return TRUE;
+ if (r_ptr->flags7 & d_ptr->mflags7) return TRUE;
+ if (r_ptr->flags8 & d_ptr->mflags8) return TRUE;
+ if (r_ptr->flags9 & d_ptr->mflags9) return TRUE;
+ if (r_ptr->flagsr & d_ptr->mflagsr) return TRUE;
+ for (a = 0; a < 5; a++)
+ if (d_ptr->r_char[a] == r_ptr->d_char) return TRUE;
- flag = d_ptr->mflags8 & (1 << i);
- if(r_ptr->flags8 & flag) ok = FALSE;
+ return FALSE;
- flag = d_ptr->mflags9 & (1 << i);
- if(r_ptr->flags9 & flag) ok = FALSE;
- }
- for(a = 0; a < 5; a++)
- if(d_ptr->r_char[a] == r_ptr->d_char) ok = FALSE;
- return ok;
- }
+ case DUNGEON_MODE_NOR:
+ if (r_ptr->flags1 & d_ptr->mflags1) return FALSE;
+ if (r_ptr->flags2 & d_ptr->mflags2) return FALSE;
+ if (r_ptr->flags3 & d_ptr->mflags3) return FALSE;
+ if (r_ptr->flags4 & d_ptr->mflags4) return FALSE;
+ if (r_ptr->flags5 & d_ptr->mflags5) return FALSE;
+ if (r_ptr->flags6 & d_ptr->mflags6) return FALSE;
+ if (r_ptr->flags7 & d_ptr->mflags7) return FALSE;
+ if (r_ptr->flags8 & d_ptr->mflags8) return FALSE;
+ if (r_ptr->flags9 & d_ptr->mflags9) return FALSE;
+ if (r_ptr->flagsr & d_ptr->mflagsr) return FALSE;
+ for (a = 0; a < 5; a++)
+ if (d_ptr->r_char[a] == r_ptr->d_char) return FALSE;
+
+ return TRUE;
+ }
- return TRUE;
+ return TRUE;
}
/*
(get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
continue;
- if (!p_ptr->inside_battle && !chameleon_change &&
+ if (!p_ptr->inside_battle && !chameleon_change_m_idx &&
summon_specific_type != SUMMON_GUARDIANS)
{
/* Hack -- don't create questors */
if (r_ptr->flags7 & RF7_GUARDIAN)
continue;
-
+
/* Depth Monsters never appear out of depth */
if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
(r_ptr->level > dun_level))
/* Accept this monster */
entry->prob2 = entry->prob1;
- if (dun_level && (!p_ptr->inside_quest || p_ptr->inside_quest < MIN_RANDOM_QUEST) && !restrict_monster_to_dungeon(entry->index) && !p_ptr->inside_battle)
+ if (dun_level && (!p_ptr->inside_quest || is_fixed_quest_idx(p_ptr->inside_quest)) && !restrict_monster_to_dungeon(entry->index) && !p_ptr->inside_battle)
{
int hoge = entry->prob2 * d_info[dungeon_type].special_div;
entry->prob2 = hoge / 64;
- if (rand_int(64) < (hoge & 0x3f)) entry->prob2++;
+ if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
}
}
if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
- if ((dungeon_turn > hoge*10000L) && !level)
+ if ((dungeon_turn > hoge*(TURNS_PER_TICK*500L)) && !level)
{
- pls_kakuritu = MAX(2, NASTY_MON-((dungeon_turn/50000L-hoge/10)));
- pls_level = MIN(8,3 + dungeon_turn/400000L-hoge/40);
+ pls_kakuritu = MAX(2, NASTY_MON-((dungeon_turn/(TURNS_PER_TICK*2500L)-hoge/10)));
+ pls_level = MIN(8,3 + dungeon_turn/(TURNS_PER_TICK*20000L)-hoge/40);
}
else
{
if ((level > 0) && !p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
{
/* Nightmare mode allows more out-of depth monsters */
- if (ironman_nightmare && !rand_int(pls_kakuritu))
+ if (ironman_nightmare && !randint0(pls_kakuritu))
{
/* What a bizarre calculation */
- level = 1 + (level * MAX_DEPTH / randint(MAX_DEPTH));
+ level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
}
else
{
/* Occasional "nasty" monster */
- if (!rand_int(pls_kakuritu))
+ if (!randint0(pls_kakuritu))
{
/* Pick a level bonus */
int d = MIN(5, level/10) + pls_level;
}
/* Occasional "nasty" monster */
- if (!rand_int(pls_kakuritu))
+ if (!randint0(pls_kakuritu))
{
/* Pick a level bonus */
int d = MIN(5, level/10) + pls_level;
/* Access the actual race */
r_ptr = &r_info[r_idx];
- if (!p_ptr->inside_battle && !chameleon_change)
+ if (!p_ptr->inside_battle && !chameleon_change_m_idx)
{
/* Hack -- "unique" monsters must be "unique" */
if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
- (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
+ (r_ptr->flags7 & (RF7_NAZGUL))) &&
(r_ptr->cur_num >= r_ptr->max_num))
{
continue;
if (r_info[MON_LUPART].cur_num > 0) continue;
}
}
- else if (!p_ptr->inside_battle && chameleon_change
- && (r_ptr->flags1 & (RF1_UNIQUE)))
- {
- /* Hack -- Chameleon Lord must be "unique" */
- if (r_info[MON_CHAMELEON_K].cur_num >= r_ptr->max_num)
- continue;
- }
/* Accept */
table[i].prob3 = table[i].prob2;
/* Pick a monster */
- value = rand_int(total);
+ value = randint0(total);
/* Find the monster */
for (i = 0; i < alloc_race_size; i++)
/* Power boost */
- p = rand_int(100);
+ p = randint0(100);
/* Try for a "harder" monster once (50%) or twice (10%) */
if (p < 60)
j = i;
/* Pick a monster */
- value = rand_int(total);
+ value = randint0(total);
/* Find the monster */
for (i = 0; i < alloc_race_size; i++)
j = i;
/* Pick a monster */
- value = rand_int(total);
+ value = randint0(total);
/* Find the monster */
for (i = 0; i < alloc_race_size; i++)
* so that "char desc[80];" is sufficiently large for any result.
*
* Mode Flags:
- * 0x01 --> Objective (or Reflexive)
- * 0x02 --> Possessive (or Reflexive)
- * 0x04 --> Use indefinites for hidden monsters ("something")
- * 0x08 --> Use indefinites for visible monsters ("a kobold")
- * 0x10 --> Pronominalize hidden monsters
- * 0x20 --> Pronominalize visible monsters
- * 0x40 --> Assume the monster is hidden
- * 0x80 --> Assume the monster is visible
+ * MD_OBJECTIVE --> Objective (or Reflexive)
+ * MD_POSSESSIVE --> Possessive (or Reflexive)
+ * MD_INDEF_HIDDEN --> Use indefinites for hidden monsters ("something")
+ * MD_INDEF_VISIBLE --> Use indefinites for visible monsters ("a kobold")
+ * MD_PRON_HIDDEN --> Pronominalize hidden monsters
+ * MD_PRON_VISIBLE --> Pronominalize visible monsters
+ * MD_ASSUME_HIDDEN --> Assume the monster is hidden
+ * MD_ASSUME_VISIBLE --> Assume the monster is visible
+ * MD_TRUE_NAME --> Chameleon's true name
+ * MD_IGNORE_HALLU --> Ignore hallucination, and penetrate shape change
*
* Useful Modes:
- * 0x00 --> Full nominative name ("the kobold") or "it"
- * 0x04 --> Full nominative name ("the kobold") or "something"
- * 0x80 --> Genocide resistance name ("the kobold")
- * 0x88 --> Killing name ("a kobold")
- * 0x22 --> Possessive, genderized if visable ("his") or "its"
- * 0x23 --> Reflexive, genderized if visable ("himself") or "itself"
+ * 0x00 --> Full nominative name ("the kobold") or "it"
+ * MD_INDEF_HIDDEN --> Full nominative name ("the kobold") or "something"
+ * MD_ASSUME_VISIBLE --> Genocide resistance name ("the kobold")
+ * MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE --> Killing name ("a kobold")
+ * MD_PRON_VISIBLE | MD_POSSESSIVE
+ * --> Possessive, genderized if visable ("his") or "its"
+ * MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE
+ * --> Reflexive, genderized if visable ("himself") or "itself"
*/
void monster_desc(char *desc, monster_type *m_ptr, int mode)
{
bool seen, pron;
bool named = FALSE;
- if (m_ptr->mflag2 & MFLAG_KAGE) r_ptr = &r_info[MON_KAGE];
- else r_ptr = &r_info[m_ptr->r_idx];
+ r_ptr = &r_info[m_ptr->ap_r_idx];
- if ((mode & 0x100) && (m_ptr->mflag2 & MFLAG_CHAMELEON))
- {
- if (r_ptr->flags1 & RF1_UNIQUE) name = (r_name + r_info[MON_CHAMELEON_K].name);
- else name = (r_name + r_info[MON_CHAMELEON].name);
- }
+ /* Mode of MD_TRUE_NAME will reveal Chameleon's true name */
+ if (mode & MD_TRUE_NAME) name = (r_name + real_r_ptr(m_ptr)->name);
else name = (r_name + r_ptr->name);
/* Are we hallucinating? (Idea from Nethack...) */
- if (p_ptr->image)
+ if (p_ptr->image && !(mode & MD_IGNORE_HALLU))
{
- if (randint(2) == 1)
+ if (one_in_(2))
{
#ifdef JP
-if (!get_rnd_line("silly_j.txt", m_ptr->r_idx, silly_name))
+ if (!get_rnd_line("silly_j.txt", m_ptr->r_idx, silly_name))
#else
if (!get_rnd_line("silly.txt", m_ptr->r_idx, silly_name))
#endif
do
{
- hallu_race = &r_info[randint(max_r_idx - 1)];
+ hallu_race = &r_info[randint1(max_r_idx - 1)];
}
while (hallu_race->flags1 & RF1_UNIQUE);
}
/* Can we "see" it (exists + forced, or visible + not unforced) */
- seen = (m_ptr && ((mode & 0x80) || (!(mode & 0x40) && m_ptr->ml)));
+ seen = (m_ptr && ((mode & MD_ASSUME_VISIBLE) || (!(mode & MD_ASSUME_HIDDEN) && m_ptr->ml)));
/* Sexed Pronouns (seen and allowed, or unseen and allowed) */
- pron = (m_ptr && ((seen && (mode & 0x20)) || (!seen && (mode & 0x10))));
+ pron = (m_ptr && ((seen && (mode & MD_PRON_VISIBLE)) || (!seen && (mode & MD_PRON_HIDDEN))));
/* First, try using pronouns, or describing hidden monsters */
/* Brute force: split on the possibilities */
- switch (kind + (mode & 0x07))
+ switch (kind + (mode & (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE)))
{
/* Neuter, or unknown */
#ifdef JP
- case 0x00: res = "²¿¤«"; break;
- case 0x01: res = "²¿¤«"; break;
- case 0x02: res = "²¿¤«¤Î"; break;
- case 0x03: res = "²¿¤«¼«¿È"; break;
- case 0x04: res = "²¿¤«"; break;
- case 0x05: res = "²¿¤«"; break;
- case 0x06: res = "²¿¤«"; break;
- case 0x07: res = "¤½¤ì¼«¿È"; break;
+ case 0x00: res = "²¿¤«"; break;
+ case 0x00 + (MD_OBJECTIVE): res = "²¿¤«"; break;
+ case 0x00 + (MD_POSSESSIVE): res = "²¿¤«¤Î"; break;
+ case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "²¿¤«¼«¿È"; break;
+ case 0x00 + (MD_INDEF_HIDDEN): res = "²¿¤«"; break;
+ case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "²¿¤«"; break;
+ case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "²¿¤«"; break;
+ case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "¤½¤ì¼«¿È"; break;
#else
- case 0x00: res = "it"; break;
- case 0x01: res = "it"; break;
- case 0x02: res = "its"; break;
- case 0x03: res = "itself"; break;
- case 0x04: res = "something"; break;
- case 0x05: res = "something"; break;
- case 0x06: res = "something's"; break;
- case 0x07: res = "itself"; break;
+ case 0x00: res = "it"; break;
+ case 0x00 + (MD_OBJECTIVE): res = "it"; break;
+ case 0x00 + (MD_POSSESSIVE): res = "its"; break;
+ case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
+ case 0x00 + (MD_INDEF_HIDDEN): res = "something"; break;
+ case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "something"; break;
+ case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "something's"; break;
+ case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
#endif
/* Male (assume human if vague) */
#ifdef JP
- case 0x10: res = "Èà"; break;
- case 0x11: res = "Èà"; break;
- case 0x12: res = "Èà¤Î"; break;
- case 0x13: res = "È༫¿È"; break;
- case 0x14: res = "狼"; break;
- case 0x15: res = "狼"; break;
- case 0x16: res = "狼¤Î"; break;
- case 0x17: res = "È༫¿È"; break;
+ case 0x10: res = "Èà"; break;
+ case 0x10 + (MD_OBJECTIVE): res = "Èà"; break;
+ case 0x10 + (MD_POSSESSIVE): res = "Èà¤Î"; break;
+ case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "È༫¿È"; break;
+ case 0x10 + (MD_INDEF_HIDDEN): res = "狼"; break;
+ case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "狼"; break;
+ case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "狼¤Î"; break;
+ case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "È༫¿È"; break;
#else
- case 0x10: res = "he"; break;
- case 0x11: res = "him"; break;
- case 0x12: res = "his"; break;
- case 0x13: res = "himself"; break;
- case 0x14: res = "someone"; break;
- case 0x15: res = "someone"; break;
- case 0x16: res = "someone's"; break;
- case 0x17: res = "himself"; break;
+ case 0x10: res = "he"; break;
+ case 0x10 + (MD_OBJECTIVE): res = "him"; break;
+ case 0x10 + (MD_POSSESSIVE): res = "his"; break;
+ case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
+ case 0x10 + (MD_INDEF_HIDDEN): res = "someone"; break;
+ case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
+ case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
+ case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
#endif
/* Female (assume human if vague) */
#ifdef JP
- case 0x20: res = "Èà½÷"; break;
- case 0x21: res = "Èà½÷"; break;
- case 0x22: res = "Èà½÷¤Î"; break;
- case 0x23: res = "Èà½÷¼«¿È"; break;
- case 0x24: res = "狼"; break;
- case 0x25: res = "狼"; break;
- case 0x26: res = "狼¤Î"; break;
- case 0x27: res = "Èà½÷¼«¿È"; break;
+ case 0x20: res = "Èà½÷"; break;
+ case 0x20 + (MD_OBJECTIVE): res = "Èà½÷"; break;
+ case 0x20 + (MD_POSSESSIVE): res = "Èà½÷¤Î"; break;
+ case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "Èà½÷¼«¿È"; break;
+ case 0x20 + (MD_INDEF_HIDDEN): res = "狼"; break;
+ case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "狼"; break;
+ case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "狼¤Î"; break;
+ case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "Èà½÷¼«¿È"; break;
#else
- case 0x20: res = "she"; break;
- case 0x21: res = "her"; break;
- case 0x22: res = "her"; break;
- case 0x23: res = "herself"; break;
- case 0x24: res = "someone"; break;
- case 0x25: res = "someone"; break;
- case 0x26: res = "someone's"; break;
- case 0x27: res = "herself"; break;
+ case 0x20: res = "she"; break;
+ case 0x20 + (MD_OBJECTIVE): res = "her"; break;
+ case 0x20 + (MD_POSSESSIVE): res = "her"; break;
+ case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
+ case 0x20 + (MD_INDEF_HIDDEN): res = "someone"; break;
+ case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
+ case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
+ case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
#endif
-
}
/* Copy the result */
/* Handle visible monsters, "reflexive" request */
- else if ((mode & 0x02) && (mode & 0x01))
+ else if ((mode & (MD_POSSESSIVE | MD_OBJECTIVE)) == (MD_POSSESSIVE | MD_OBJECTIVE))
{
/* The monster is visible, so use its gender */
#ifdef JP
- if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "Èà½÷¼«¿È");
- else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "È༫¿È");
- else strcpy(desc, "¤½¤ì¼«¿È");
+ if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "Èà½÷¼«¿È");
+ else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "È༫¿È");
+ else strcpy(desc, "¤½¤ì¼«¿È");
#else
if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
else strcpy(desc, "itself");
#endif
-
}
/* Handle all other visible monster requests */
else
{
+ /* Tanuki? */
+ if (is_pet(m_ptr) && m_ptr->ap_r_idx != m_ptr->r_idx)
+ {
+#ifdef JP
+ char *t;
+ strcpy(buf, name);
+ t = buf;
+ while(strncmp(t, "¡Ù", 2) && *t) t++;
+ if (*t)
+ {
+ *t = '\0';
+ (void)sprintf(desc, "%s¡©¡Ù", buf);
+ }
+ else
+ (void)sprintf(desc, "%s¡©", name);
+#else
+ (void)sprintf(desc, "%s?", name);
+#endif
+ }
+ else
+
/* It could be a Unique */
- if ((r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->image)
+ if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & MD_IGNORE_HALLU)))
{
/* Start with the name (thus nominative and objective) */
- if ((m_ptr->mflag2 & MFLAG_CHAMELEON) && !(mode & 0x100))
+ if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && !(mode & MD_TRUE_NAME))
{
#ifdef JP
char *t;
strcpy(buf, name);
t = buf;
- while(strncmp(t, "¡Ù", 2) && *t) t++;
+ while (strncmp(t, "¡Ù", 2) && *t) t++;
if (*t)
{
*t = '\0';
}
/* It could be an indefinite monster */
- else if (mode & 0x08)
+ else if (mode & MD_INDEF_VISIBLE)
{
/* XXX Check plurality for "some" */
#endif
(void)strcat(desc, name);
-
- if (m_ptr->nickname)
- {
-#ifdef JP
- sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
-#else
- sprintf(buf," called %s",quark_str(m_ptr->nickname));
-#endif
- strcat(desc,buf);
- }
}
/* It could be a normal, definite, monster */
#endif
(void)strcat(desc, name);
+ }
- if (m_ptr->nickname)
- {
+ if (m_ptr->nickname)
+ {
#ifdef JP
- sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
+ sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
#else
- sprintf(buf," called %s",quark_str(m_ptr->nickname));
+ sprintf(buf," called %s",quark_str(m_ptr->nickname));
#endif
- strcat(desc,buf);
- }
+ strcat(desc,buf);
+ }
- if ((m_ptr->fy == py) && (m_ptr->fx == px))
+ if (player_bold(m_ptr->fy, m_ptr->fx))
+ {
#ifdef JP
- strcat(desc,"(¾èÇÏÃæ)");
+ strcat(desc,"(¾èÇÏÃæ)");
#else
- strcat(desc,"(riding)");
+ strcat(desc,"(riding)");
#endif
- if ((mode & 0x200) && (m_ptr->mflag2 & MFLAG_CHAMELEON))
+ }
+
+ if ((mode & MD_IGNORE_HALLU) && (m_ptr->mflag2 & MFLAG2_CHAMELEON))
+ {
+ if (r_ptr->flags1 & RF1_UNIQUE)
{
- if (r_ptr->flags1 & RF1_UNIQUE)
#ifdef JP
- strcat(desc,"(¥«¥á¥ì¥ª¥ó¤Î²¦)");
+ strcat(desc,"(¥«¥á¥ì¥ª¥ó¤Î²¦)");
#else
- strcat(desc,"(Chameleon Lord)");
+ strcat(desc,"(Chameleon Lord)");
#endif
- else
+ }
+ else
+ {
#ifdef JP
- strcat(desc,"(¥«¥á¥ì¥ª¥ó)");
+ strcat(desc,"(¥«¥á¥ì¥ª¥ó)");
#else
- strcat(desc,"(Chameleon)");
+ strcat(desc,"(Chameleon)");
#endif
}
}
+ if ((mode & MD_IGNORE_HALLU) && m_ptr->ap_r_idx != m_ptr->r_idx)
+ {
+ strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
+ }
+
/* Handle the Possessive as a special afterthought */
- if (mode & 0x02)
+ if (mode & MD_POSSESSIVE)
{
/* XXX Check for trailing "s" */
-
+
/* Simply append "apostrophe" and "s" */
#ifdef JP
(void)strcat(desc, "¤Î");
#else
(void)strcat(desc, "'s");
#endif
-
}
}
}
/*
* Learn about a monster (by "probing" it)
+ *
+ * Return the number of new flags learnt. -Mogami-
*/
-void lore_do_probe(int m_idx)
+int lore_do_probe(int r_idx)
{
- monster_type *m_ptr = &m_list[m_idx];
+ monster_race *r_ptr = &r_info[r_idx];
+ int i, n = 0;
+ byte tmp_byte;
- monster_race *r_ptr = &r_info[m_ptr->r_idx];
+ /* Maximal info about awareness */
+ if (r_ptr->r_wake != MAX_UCHAR) n++;
+ if (r_ptr->r_ignore != MAX_UCHAR) n++;
+ r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
+
+ /* Observe "maximal" attacks */
+ for (i = 0; i < 4; i++)
+ {
+ /* Examine "actual" blows */
+ if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
+ {
+ /* Maximal observations */
+ if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
+ r_ptr->r_blows[i] = MAX_UCHAR;
+ }
+ }
+
+ /* Maximal drops */
+ tmp_byte =
+ (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
+ ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
+ ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
+ ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
+ ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
+ ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
+
+ /* Only "valid" drops */
+ if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
+ {
+ if (r_ptr->r_drop_item != tmp_byte) n++;
+ r_ptr->r_drop_item = tmp_byte;
+ }
+ if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
+ {
+ if (r_ptr->r_drop_gold != tmp_byte) n++;
+ r_ptr->r_drop_gold = tmp_byte;
+ }
+
+ /* Observe many spells */
+ if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
+ r_ptr->r_cast_spell = MAX_UCHAR;
+
+ /* Count unknown flags */
+ for (i = 0; i < 32; i++)
+ {
+ if (!(r_ptr->r_flags1 & (1L << i)) &&
+ (r_ptr->flags1 & (1L << i))) n++;
+ if (!(r_ptr->r_flags2 & (1L << i)) &&
+ (r_ptr->flags2 & (1L << i))) n++;
+ if (!(r_ptr->r_flags3 & (1L << i)) &&
+ (r_ptr->flags3 & (1L << i))) n++;
+ if (!(r_ptr->r_flags4 & (1L << i)) &&
+ (r_ptr->flags4 & (1L << i))) n++;
+ if (!(r_ptr->r_flags5 & (1L << i)) &&
+ (r_ptr->flags5 & (1L << i))) n++;
+ if (!(r_ptr->r_flags6 & (1L << i)) &&
+ (r_ptr->flags6 & (1L << i))) n++;
+ if (!(r_ptr->r_flagsr & (1L << i)) &&
+ (r_ptr->flagsr & (1L << i))) n++;
+
+ /* r_flags7 is actually unused */
+#if 0
+ if (!(r_ptr->r_flags7 & (1L << i)) &&
+ (r_ptr->flags7 & (1L << i))) n++;
+#endif
+ }
- /* Hack -- Memorize some flags */
+ /* Know all the flags */
r_ptr->r_flags1 = r_ptr->flags1;
r_ptr->r_flags2 = r_ptr->flags2;
r_ptr->r_flags3 = r_ptr->flags3;
+ r_ptr->r_flags4 = r_ptr->flags4;
+ r_ptr->r_flags5 = r_ptr->flags5;
+ r_ptr->r_flags6 = r_ptr->flags6;
+ r_ptr->r_flagsr = r_ptr->flagsr;
+
+ /* r_flags7 is actually unused */
+ /* r_ptr->r_flags7 = r_ptr->flags7; */
+
+ /* Know about evolution */
+ if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
+ r_ptr->r_xtra1 |= MR1_SINKA;
/* Update monster recall window */
- if (p_ptr->monster_race_idx == m_ptr->r_idx)
+ if (p_ptr->monster_race_idx == r_idx)
{
/* Window stuff */
p_ptr->window |= (PW_MONSTER);
}
+
+ /* Return the number of new flags learnt */
+ return n;
}
monster_race *r_ptr = &r_info[m_ptr->r_idx];
+ /* If the monster doesn't have original appearance, don't note */
+ if (!is_original_ap(m_ptr)) return;
+
/* Note the number of things dropped */
if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
if (!necro)
{
char m_name[80];
- monster_race *r_ptr = &r_info[m_ptr->r_idx];
+ monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
power = r_ptr->level / 2;
if (is_pet(m_ptr))
return; /* Pet eldritch horrors are safe most of the time */
- if (randint(100) > power) return;
+ if (randint1(100) > power) return;
if (saving_throw(p_ptr->skill_sav - power))
{
{
/* Something silly happens... */
#ifdef JP
-msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
+ msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
+ funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
#else
msg_format("You behold the %s visage of %s!",
+ funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
#endif
- funny_desc[rand_int(MAX_SAN_FUNNY)], m_name);
- if (randint(3) == 1)
+ if (one_in_(3))
{
- msg_print(funny_comments[rand_int(MAX_SAN_COMMENT)]);
- p_ptr->image = p_ptr->image + randint(r_ptr->level);
+ msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
+ p_ptr->image = p_ptr->image + randint1(r_ptr->level);
}
return; /* Never mind; we can't see it clearly enough */
/* Something frightening happens... */
#ifdef JP
-msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
+ msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
+ horror_desc[randint0(MAX_SAN_HORROR)], m_name);
#else
msg_format("You behold the %s visage of %s!",
+ horror_desc[randint0(MAX_SAN_HORROR)], m_name);
#endif
- horror_desc[rand_int(MAX_SAN_HORROR)], m_name);
-
r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
/* Demon characters are unaffected */
- if ((p_ptr->prace == RACE_IMP) || (p_ptr->prace == RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
- if (wizard) return;
+ if (prace_is_(RACE_IMP) || prace_is_(RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
+ if (p_ptr->wizard) return;
/* Undead characters are 50% likely to be unaffected */
- if ((p_ptr->prace == RACE_SKELETON) || (p_ptr->prace == RACE_ZOMBIE)
- || (p_ptr->prace == RACE_VAMPIRE) || (p_ptr->prace == RACE_SPECTRE) ||
+ if (prace_is_(RACE_SKELETON) || prace_is_(RACE_ZOMBIE)
+ || prace_is_(RACE_VAMPIRE) || prace_is_(RACE_SPECTRE) ||
(mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
{
if (saving_throw(25 + p_ptr->lev)) return;
{
if (!p_ptr->resist_conf)
{
- (void)set_confused(p_ptr->confused + rand_int(4) + 4);
+ (void)set_confused(p_ptr->confused + randint0(4) + 4);
}
if (!p_ptr->resist_chaos && one_in_(3))
{
- (void)set_image(p_ptr->image + rand_int(250) + 150);
+ (void)set_image(p_ptr->image + randint0(250) + 150);
}
return;
}
{
if (!p_ptr->resist_conf)
{
- (void)set_confused(p_ptr->confused + rand_int(4) + 4);
+ (void)set_confused(p_ptr->confused + randint0(4) + 4);
}
if (!p_ptr->free_act)
{
- (void)set_paralyzed(p_ptr->paralyzed + rand_int(4) + 4);
+ (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
}
- while (rand_int(100) > p_ptr->skill_sav)
+ while (randint0(100) > p_ptr->skill_sav)
(void)do_dec_stat(A_INT);
- while (rand_int(100) > p_ptr->skill_sav)
+ while (randint0(100) > p_ptr->skill_sav)
(void)do_dec_stat(A_WIS);
if (!p_ptr->resist_chaos)
{
- (void)set_image(p_ptr->image + rand_int(250) + 150);
+ (void)set_image(p_ptr->image + randint0(250) + 150);
}
return;
}
while (!happened)
{
- switch (randint(21))
+ switch (randint1(21))
{
case 1:
if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
monster_race *r_ptr = &r_info[m_ptr->r_idx];
+ bool do_disturb = disturb_move;
+
int d;
/* Current location */
/* Seen by vision */
bool easy = FALSE;
+ /* Non-Ninja player in the darkness */
+ bool in_darkness = (d_info[dungeon_type].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
+
+ /* Do disturb? */
+ if (disturb_high)
+ {
+ monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
+
+ if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
+ do_disturb = TRUE;
+ }
/* Compute distance */
if (full)
/* Detected */
- if (m_ptr->mflag & (MFLAG_MARK)) flag = TRUE;
+ if (m_ptr->mflag2 & (MFLAG2_MARK)) flag = TRUE;
/* Nearby */
- if (d <= ((d_info[dungeon_type].flags1 & DF1_DARKNESS) ? MAX_SIGHT / 2 : MAX_SIGHT))
+ if (d <= (in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT))
{
- if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS) || (d <= MAX_SIGHT / 4))
+ if (!in_darkness || (d <= MAX_SIGHT / 4))
{
if (p_ptr->special_defense & KATA_MUSOU)
{
/* Detectable */
flag = TRUE;
- /* Hack -- Memorize mental flags */
- if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
- if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
+ if (is_original_ap(m_ptr))
+ {
+ /* Hack -- Memorize mental flags */
+ if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
+ if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
+ }
}
/* Basic telepathy */
if (r_ptr->flags2 & (RF2_EMPTY_MIND))
{
/* Memorize flags */
- r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
+ if (is_original_ap(m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
}
/* Weird mind, occasional telepathy */
/* Detectable */
flag = TRUE;
- /* Memorize flags */
- r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
+ if (is_original_ap(m_ptr))
+ {
+ /* Memorize flags */
+ r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
- /* Hack -- Memorize mental flags */
- if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
- if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
+ /* Hack -- Memorize mental flags */
+ if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
+ if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
+ }
}
}
/* Detectable */
flag = TRUE;
- /* Hack -- Memorize mental flags */
- if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
- if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
+ if (is_original_ap(m_ptr))
+ {
+ /* Hack -- Memorize mental flags */
+ if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
+ if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
+ }
}
}
+
+ /* Magical sensing */
+ if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
+ {
+ flag = TRUE;
+ if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_ANIMAL);
+ }
+
+ /* Magical sensing */
+ if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
+ {
+ flag = TRUE;
+ if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
+ }
+
+ /* Magical sensing */
+ if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
+ {
+ flag = TRUE;
+ if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_DEMON);
+ }
+
+ /* Magical sensing */
+ if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
+ {
+ flag = TRUE;
+ if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_ORC);
+ }
+
+ /* Magical sensing */
+ if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
+ {
+ flag = TRUE;
+ if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_TROLL);
+ }
+
+ /* Magical sensing */
+ if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
+ {
+ flag = TRUE;
+ if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_GIANT);
+ }
+
+ /* Magical sensing */
+ if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
+ {
+ flag = TRUE;
+ if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_DRAGON);
+ }
+
+ /* Magical sensing */
+ if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
+ {
+ flag = TRUE;
+ if (is_original_ap(m_ptr)) r_ptr->r_flags2 |= (RF2_HUMAN);
+ }
+
+ /* Magical sensing */
+ if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
+ {
+ flag = TRUE;
+ if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
+ }
+
+ /* Magical sensing */
+ if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
+ {
+ flag = TRUE;
+ if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_GOOD);
+ }
+
+ /* Magical sensing */
+ if ((p_ptr->esp_nonliving) &&
+ ((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) == RF3_NONLIVING))
+ {
+ flag = TRUE;
+ if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_NONLIVING);
+ }
+
+ /* Magical sensing */
+ if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
+ {
+ flag = TRUE;
+ if (is_original_ap(m_ptr)) r_ptr->r_flags1 |= (RF1_UNIQUE);
+ }
}
/* Normal line of sight, and not blind */
if (d <= p_ptr->see_infra)
{
/* Handle "cold blooded" monsters */
- if (r_ptr->flags2 & (RF2_COLD_BLOOD))
+ if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
{
/* Take note */
do_cold_blood = TRUE;
/* Visible */
if (flag)
{
- /* Memorize flags */
- if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
- if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
+ if (is_original_ap(m_ptr))
+ {
+ /* Memorize flags */
+ if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
+ if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
+ }
}
}
}
if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
/* Hack -- Count "fresh" sightings */
- if ((m_ptr->mflag2 & MFLAG_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
+ if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
r_info[MON_KAGE].r_sights++;
- else if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
+ else if (m_ptr->ap_r_idx == m_ptr->r_idx &&
+ r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
/* Eldritch Horror */
if (r_ptr->flags2 & RF2_ELDRITCH_HORROR)
if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
/* Disturb on disappearance */
- if (disturb_move)
+ if (do_disturb)
{
if (disturb_pets || is_hostile(m_ptr))
disturb(1, 0);
m_ptr->mflag |= (MFLAG_VIEW);
/* Disturb on appearance */
- if (disturb_move)
+ if (do_disturb)
{
if (disturb_pets || is_hostile(m_ptr))
disturb(1, 0);
m_ptr->mflag &= ~(MFLAG_VIEW);
/* Disturb on disappearance */
- if (disturb_move)
+ if (do_disturb)
{
if (disturb_pets || is_hostile(m_ptr))
disturb(1, 0);
}
+/*
+ * Hack -- the index of the summoning monster
+ */
static bool monster_hook_chameleon_lord(int r_idx)
{
monster_race *r_ptr = &r_info[r_idx];
+ monster_type *m_ptr = &m_list[chameleon_change_m_idx];
+ monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
if ((r_ptr->blow[0].method == RBM_EXPLODE) || (r_ptr->blow[1].method == RBM_EXPLODE) || (r_ptr->blow[2].method == RBM_EXPLODE) || (r_ptr->blow[3].method == RBM_EXPLODE))
return FALSE;
+ if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
+
+ /* Not born */
+ if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
+ {
+ if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
+ }
+
+ /* Born now */
+ else if (summon_specific_who > 0)
+ {
+ if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
+ }
+
return TRUE;
}
static bool monster_hook_chameleon(int r_idx)
{
monster_race *r_ptr = &r_info[r_idx];
+ monster_type *m_ptr = &m_list[chameleon_change_m_idx];
+ monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
if ((r_ptr->blow[0].method == RBM_EXPLODE) || (r_ptr->blow[1].method == RBM_EXPLODE) || (r_ptr->blow[2].method == RBM_EXPLODE) || (r_ptr->blow[3].method == RBM_EXPLODE))
return FALSE;
+ if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
+
+ /* Not born */
+ if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
+ {
+ if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
+ if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
+ if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
+ }
+
+ /* Born now */
+ else if (summon_specific_who > 0)
+ {
+ if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
+ }
+
return (*(get_monster_hook()))(r_idx);
}
void choose_new_monster(int m_idx, bool born, int r_idx)
{
- int attempt = 5000;
- int oldmaxhp, i;
+ int oldmaxhp;
monster_type *m_ptr = &m_list[m_idx];
monster_race *r_ptr;
char old_m_name[80];
- int old_r_idx = m_ptr->r_idx;
bool old_unique = FALSE;
- if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE) old_unique = TRUE;
+ if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
+ old_unique = TRUE;
if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
r_ptr = &r_info[r_idx];
if (!r_idx)
{
- chameleon_change = TRUE;
+ int level;
+
+ chameleon_change_m_idx = m_idx;
if (old_unique)
get_mon_num_prep(monster_hook_chameleon_lord, NULL);
else
get_mon_num_prep(monster_hook_chameleon, NULL);
- while (attempt--)
- {
- int level;
+ if (old_unique)
+ level = r_info[MON_CHAMELEON_K].level;
+ else if (!dun_level)
+ level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
+ else
+ level = dun_level;
- if (old_unique)
- level = r_info[MON_CHAMELEON_K].level;
- else if (!dun_level)
- level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
- else
- level = dun_level;
+ if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
- if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint(3);
- r_idx = get_mon_num(level);
- r_ptr = &r_info[r_idx];
+ r_idx = get_mon_num(level);
+ r_ptr = &r_info[r_idx];
- if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) continue;
- if (!born && !old_unique)
- {
- if ((r_info[old_r_idx].flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) continue;
- if ((r_info[old_r_idx].flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) continue;
- if (!(r_info[old_r_idx].flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) continue;
- }
- break;
- }
- chameleon_change = FALSE;
- if (!attempt) return;
+ chameleon_change_m_idx = 0;
+
+ /* Paranoia */
+ if (!r_idx) return;
}
m_ptr->r_idx = r_idx;
+ m_ptr->ap_r_idx = r_idx;
update_mon(m_idx, FALSE);
lite_spot(m_ptr->fy, m_ptr->fx);
- if (born) return;
+ if (born)
+ {
+ /* Sub-alignment of a chameleon */
+ if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
+ {
+ m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
+ if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
+ if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
+ }
+ return;
+ }
if (m_idx == p_ptr->riding)
{
}
/* Extract the monster base speed */
- m_ptr->mspeed = r_ptr->speed;
- /* Hack -- small racial variety */
- /* Allow some small variation per monster */
- if(rand_int(4) == 1){
- i = extract_energy[r_ptr->speed] / 3;
- if (i) m_ptr->mspeed += rand_spread(0, i);
- }
- else{
- i = extract_energy[r_ptr->speed] / 10;
- if (i) m_ptr->mspeed += rand_spread(0, i);
- }
+ m_ptr->mspeed = get_mspeed(r_ptr);
oldmaxhp = m_ptr->max_maxhp;
/* Assign maximal hitpoints */
/*
+ * Hook for Tanuki
+ */
+static bool monster_hook_tanuki(int r_idx)
+{
+ monster_race *r_ptr = &r_info[r_idx];
+
+ if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
+ if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
+ if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
+ if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
+
+ if ((r_ptr->blow[0].method == RBM_EXPLODE) || (r_ptr->blow[1].method == RBM_EXPLODE) || (r_ptr->blow[2].method == RBM_EXPLODE) || (r_ptr->blow[3].method == RBM_EXPLODE))
+ return FALSE;
+
+ return (*(get_monster_hook()))(r_idx);
+}
+
+
+/*
+ * Set initial racial appearance of a monster
+ */
+static int initial_r_appearance(int r_idx)
+{
+ int attempts = 1000;
+
+ int ap_r_idx;
+ int min = MIN(base_level-5, 50);
+
+ if (!(r_info[r_idx].flags7 & RF7_TANUKI))
+ return r_idx;
+
+ get_mon_num_prep(monster_hook_tanuki, NULL);
+
+ while (--attempts)
+ {
+ ap_r_idx = get_mon_num(base_level + 10);
+ if (r_info[ap_r_idx].level >= min) return ap_r_idx;
+ }
+
+ return r_idx;
+}
+
+
+/*
+ * Get initial monster speed
+ */
+byte get_mspeed(monster_race *r_ptr)
+{
+ /* Extract the monster base speed */
+ int mspeed = r_ptr->speed;
+
+ /* Hack -- small racial variety */
+ if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
+ {
+ /* Allow some small variation per monster */
+ int i = SPEED_TO_ENERGY(r_ptr->speed) / (one_in_(4) ? 3 : 10);
+ if (i) mspeed += rand_spread(0, i);
+ }
+
+ if (mspeed > 199) mspeed = 199;
+
+ return (byte)mspeed;
+}
+
+
+/*
* Attempt to place a monster of the given race at the given location.
*
* To give the player a sporting chance, any monster that appears in
* This is the only function which may place a monster in the dungeon,
* except for the savefile loading code.
*/
-bool place_monster_one(int y, int x, int r_idx, bool slp, bool friendly, bool pet, bool no_pet)
+static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
{
- int i;
- int rune_dam = 0;
-
- cave_type *c_ptr;
+ /* Access the location */
+ cave_type *c_ptr = &cave[y][x];
monster_type *m_ptr;
cptr name = (r_name + r_ptr->name);
- /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
- if(p_ptr->wild_mode) return FALSE;
+ /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
+ if(p_ptr->wild_mode) return FALSE;
/* Verify location */
if (!in_bounds(y, x)) return (FALSE);
/* Require empty space (if not ghostly) */
- if (!(!dun_level && (cave[y][x].feat == FEAT_MOUNTAIN) && ((r_ptr->flags8 & RF8_WILD_MOUNTAIN) || (r_ptr->flags7 & RF7_CAN_FLY))) &&
- !cave_empty_bold2(y, x) &&
+ if (!(!dun_level && (c_ptr->feat == FEAT_MOUNTAIN) && ((r_ptr->flags8 & RF8_WILD_MOUNTAIN) || (r_ptr->flags7 & RF7_CAN_FLY))) &&
+ !(cave_empty_bold2(y, x) || (mode & PM_IGNORE_TERRAIN)) &&
!((r_ptr->flags2 & RF2_PASS_WALL) &&
- !(cave_perma_bold(y, x) || cave[y][x].m_idx ||
- ((y == py) && (x == px))))) return (FALSE);
+ !(cave_perma_bold(y, x) || c_ptr->m_idx ||
+ player_bold(y, x)))) return (FALSE);
/* Paranoia */
if (!r_idx) return (FALSE);
/* Paranoia */
if (!r_ptr->name) return (FALSE);
-#if 0
- /* Hack -- no creation on glyph of warding */
- if (cave[y][x].feat == FEAT_GLYPH) return (FALSE);
- if (cave[y][x].feat == FEAT_MINOR_GLYPH) return (FALSE);
-#endif
-
/* Nor on the Pattern */
- if ((cave[y][x].feat >= FEAT_PATTERN_START)
- && (cave[y][x].feat <= FEAT_PATTERN_XTRA2))
+ if ((c_ptr->feat >= FEAT_PATTERN_START)
+ && (c_ptr->feat <= FEAT_PATTERN_XTRA2))
return (FALSE);
- if (monster_terrain_sensitive &&
- !monster_can_cross_terrain(cave[y][x].feat, r_ptr))
+ if (!(mode & PM_IGNORE_TERRAIN) &&
+ !monster_can_cross_terrain(c_ptr->feat, r_ptr))
{
return FALSE;
}
{
/* Hack -- "unique" monsters must be "unique" */
if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
- (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
+ (r_ptr->flags7 & (RF7_NAZGUL))) &&
(r_ptr->cur_num >= r_ptr->max_num))
{
/* Cannot create */
return (FALSE);
}
-
+
if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
(r_ptr->cur_num >= 1))
{
if (r_info[MON_BANOR].cur_num > 0) return FALSE;
if (r_info[MON_LUPART].cur_num > 0) return FALSE;
}
-
+
/* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
(!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
}
}
- if(quest_number(dun_level))
+ if (quest_number(dun_level))
{
int hoge = quest_number(dun_level);
- if((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
+ if ((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
{
if(r_idx == quest[hoge].r_idx)
{
}
}
- /* Access the location */
- c_ptr = &cave[y][x];
-
- if (c_ptr->feat == FEAT_GLYPH)
+ if (is_glyph_grid(c_ptr))
{
- if (randint(BREAK_GLYPH) < (r_ptr->level+20))
+ if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
{
/* Describe observable breakage */
if (c_ptr->info & CAVE_MARK)
c_ptr->info &= ~(CAVE_MARK);
/* Break the rune */
- c_ptr->feat = floor_type[rand_int(100)];
- c_ptr->info &= ~(CAVE_MASK);
- c_ptr->info |= CAVE_FLOOR;
+ c_ptr->info &= ~(CAVE_OBJECT);
+ c_ptr->mimic = 0;
/* Notice */
note_spot(y, x);
- rune_dam = 1000;
}
else return FALSE;
}
}
- if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7) || (r_ptr->level < 10)) is_kage = FALSE;
+ if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL) || (r_ptr->level < 10)) mode &= ~PM_KAGE;
/* Make a new monster */
c_ptr->m_idx = m_pop();
/* Save the race */
m_ptr->r_idx = r_idx;
+ m_ptr->ap_r_idx = initial_r_appearance(r_idx);
+
+ /* Sub-alignment of a monster */
+ if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
+ m_ptr->sub_align = m_list[who].sub_align;
+ else
+ {
+ m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
+ if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
+ if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
+ }
/* Place the monster at the location */
m_ptr->fy = y;
/* Unknown distance */
m_ptr->cdis = 0;
- m_ptr->target_y = 0;
- m_ptr->target_x = 0;
+ reset_target(m_ptr);
m_ptr->nickname = 0;
m_ptr->mflag = 0;
m_ptr->mflag2 = 0;
+
+ /* Your pet summons its pet. */
+ if (who > 0 && is_pet(&m_list[who]))
+ {
+ mode |= PM_FORCE_PET;
+ m_ptr->parent_m_idx = who;
+ }
+ else
+ {
+ m_ptr->parent_m_idx = 0;
+ }
+
if (r_ptr->flags7 & RF7_CHAMELEON)
{
choose_new_monster(c_ptr->m_idx, TRUE, 0);
r_ptr = &r_info[m_ptr->r_idx];
- m_ptr->mflag2 |= MFLAG_CHAMELEON;
+ m_ptr->mflag2 |= MFLAG2_CHAMELEON;
rating++;
+
+ /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
+ if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
+ m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
}
- else if (is_kage) m_ptr->mflag2 |= MFLAG_KAGE;
- if (no_pet) m_ptr->mflag2 |= MFLAG_NOPET;
+ else if ((mode & PM_KAGE) && !(mode & PM_FORCE_PET))
+ {
+ m_ptr->ap_r_idx = MON_KAGE;
+ m_ptr->mflag2 |= MFLAG2_KAGE;
+ }
+
+ if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG2_NOPET;
/* Not visible */
m_ptr->ml = FALSE;
/* Pet? */
- if (pet)
+ if (mode & PM_FORCE_PET)
{
set_pet(m_ptr);
}
/* Friendly? */
- else if ((friendly || (r_ptr->flags7 & RF7_FRIENDLY)) &&
- !(p_ptr->align >= 0 && (r_ptr->flags3 & RF3_EVIL)) &&
- !(p_ptr->align < 0 && (r_ptr->flags3 & RF3_GOOD)))
+ else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
+ (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
{
- set_friendly(m_ptr);
+ if (!monster_has_hostile_align(NULL, 0, -1, r_ptr)) set_friendly(m_ptr);
}
/* Assume no sleeping */
m_ptr->csleep = 0;
/* Enforce sleeping if needed */
- if (slp && r_ptr->sleep && !ironman_nightmare)
+ if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
{
int val = r_ptr->sleep;
- m_ptr->csleep = ((val * 2) + randint(val * 10));
+ m_ptr->csleep = ((val * 2) + randint1(val * 10));
}
/* Assign maximal hitpoints */
/* Extract the monster base speed */
- m_ptr->mspeed = r_ptr->speed;
+ m_ptr->mspeed = get_mspeed(r_ptr);
- /* Hack -- small racial variety */
- if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
- {
- /* Allow some small variation per monster */
- if(rand_int(4) == 1){
- i = extract_energy[r_ptr->speed] / 3;
- if (i) m_ptr->mspeed += rand_spread(0, i);
- }
- else{
- i = extract_energy[r_ptr->speed] / 10;
- if (i) m_ptr->mspeed += rand_spread(0, i);
- }
- }
-
- if (m_ptr->mspeed > 199) m_ptr->mspeed = 199;
+ if (mode & PM_HASTE) m_ptr->fast = 100;
/* Give a random starting energy */
- m_ptr->energy = (byte)rand_int(100);
-
- /* Nightmare monsters are more prepared */
- if (ironman_nightmare)
+ if (!ironman_nightmare)
+ {
+ m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
+ }
+ else
{
- m_ptr->energy *= 2;
+ /* Nightmare monsters are more prepared */
+ m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
}
/* Force monster to wait for player, unless in Nightmare mode */
}
+ if (r_ptr->flags7 & RF7_SELF_LD_MASK)
+ p_ptr->update |= (PU_MON_LITE);
+ else if ((r_ptr->flags7 & RF7_HAS_LD_MASK) && !m_ptr->csleep)
+ p_ptr->update |= (PU_MON_LITE);
+
/* Update the monster */
update_mon(c_ptr->m_idx, TRUE);
- /* Hack -- Count the monsters on the level */
- if (m_ptr->mflag2 & MFLAG_CHAMELEON)
- r_info[r_idx].cur_num++;
- else
- r_ptr->cur_num++;
+ /* Count the monsters on the level */
+ real_r_ptr(m_ptr)->cur_num++;
+ /*
+ * Memorize location of the unique monster in saved floors.
+ * A unique monster move from old saved floor.
+ */
+ if (character_dungeon &&
+ ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)))
+ real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
/* Hack -- Count the number of "reproducers" */
if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
/* Hack -- Notice new multi-hued monsters */
- if (r_ptr->flags1 & RF1_ATTR_MULTI) shimmer_monsters = TRUE;
+ {
+ monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
+ if (ap_r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER))
+ shimmer_monsters = TRUE;
+ }
if (p_ptr->warning && character_dungeon)
{
- cptr color;
if (r_ptr->flags1 & RF1_UNIQUE)
{
+ cptr color;
+ object_type *o_ptr;
+ char o_name[MAX_NLEN];
+
if (r_ptr->level > p_ptr->lev + 30)
#ifdef JP
color = "¹õ¤¯";
#ifdef JP
color = "»ç¿§¤Ë";
#else
- color = "perple";
+ color = "purple";
#endif
else if (r_ptr->level > p_ptr->lev + 5)
#ifdef JP
#else
color = "white";
#endif
+
+ o_ptr = choose_warning_item();
+ if (o_ptr)
+ {
+ object_desc(o_name, o_ptr, FALSE, 0);
+#ifdef JP
+ msg_format("%s¤Ï%s¸÷¤Ã¤¿¡£", o_name, color);
+#else
+ msg_format("%s glows %s.", o_name, color);
+#endif
+ }
+ else
+ {
#ifdef JP
- msg_format("»ØÎؤÏ%s¸÷¤Ã¤¿¡£",color);
+ msg_format("s%¸÷¤ëʪ¤¬Æ¬¤ËÉ⤫¤ó¤À¡£", color);
#else
- msg_format("Your ring glows %s.",color);
+ msg_format("An %s image forms in your mind.");
#endif
+ }
}
}
- if (c_ptr->feat == FEAT_MINOR_GLYPH)
+ if (is_explosive_rune_grid(c_ptr))
{
/* Break the ward */
- if (randint(BREAK_MINOR_GLYPH) > r_ptr->level)
+ if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
{
/* Describe observable breakage */
if (c_ptr->info & CAVE_MARK)
msg_print("The rune explodes!");
#endif
- project(0, 2, y, x, 2 * (p_ptr->lev + damroll(7, 7)), GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_REF | PROJECT_NO_HANGEKI), -1);
+ project(0, 2, y, x, 2 * (p_ptr->lev + damroll(7, 7)), GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
}
}
else
c_ptr->info &= ~(CAVE_MARK);
/* Break the rune */
- c_ptr->feat = floor_type[rand_int(100)];
- c_ptr->info &= ~(CAVE_MASK);
- c_ptr->info |= CAVE_FLOOR;
+ c_ptr->info &= ~(CAVE_OBJECT);
+ c_ptr->mimic = 0;
+
note_spot(y, x);
lite_spot(y, x);
}
{
/* Ignore annoying locations */
if (!in_bounds(ny, nx)) continue;
-
+
/* Require "line of sight" */
if (!los(y, x, ny, nx)) continue;
-
+
/* Walls and Monsters block flow */
if (!cave_empty_bold2(ny, nx)) continue;
- if (cave[ny][nx].m_idx) continue;
- if ((ny == py) && (nx == px)) continue;
-
-#if 0
- /* Hack -- no summon on glyph of warding */
- if (cave[ny][nx].feat == FEAT_GLYPH) continue;
- if (cave[ny][nx].feat == FEAT_MINOR_GLYPH) continue;
-#endif
-
+
/* ... nor on the Pattern */
if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
(cave[ny][nx].feat <= FEAT_PATTERN_XTRA2))
continue;
-
+
i = distance(y, x, ny, nx);
if (i > max_dist)
continue;
-
+
num[i]++;
/* random swap */
place_x[i] = nx;
place_y[i] = ny;
}
-
}
i = 0;
/*
* Attempt to place a "group" of monsters around the given location
*/
-static bool place_monster_group(int y, int x, int r_idx, bool slp, bool friendly, bool pet, bool no_pet)
+static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode)
{
monster_race *r_ptr = &r_info[r_idx];
/* Pick a group size */
- total = randint(10);
+ total = randint1(10);
/* Hard monsters, small groups */
if (r_ptr->level > dun_level)
{
extra = r_ptr->level - dun_level;
- extra = 0 - randint(extra);
+ extra = 0 - randint1(extra);
}
/* Easy monsters, large groups */
else if (r_ptr->level < dun_level)
{
extra = dun_level - r_ptr->level;
- extra = randint(extra);
+ extra = randint1(extra);
}
/* Hack -- limit group reduction */
if (!cave_empty_bold2(my, mx)) continue;
/* Attempt to place another monster */
- if (place_monster_one(my, mx, r_idx, slp, friendly, pet, no_pet))
+ if (place_monster_one(who, my, mx, r_idx, mode))
{
/* Add it to the "hack" set */
hack_y[hack_n] = my;
* Hack -- help pick an escort type
*/
static int place_monster_idx = 0;
+static int place_monster_m_idx = 0;
/*
* Hack -- help pick an escort type
static bool place_monster_okay(int r_idx)
{
monster_race *r_ptr = &r_info[place_monster_idx];
+ monster_type *m_ptr = &m_list[place_monster_m_idx];
monster_race *z_ptr = &r_info[r_idx];
/* Hack - Escorts have to have the same dungeon flag */
- if (monster_dungeon(place_monster_idx) != monster_dungeon(r_idx)) return (FALSE);
+ if (mon_hook_dungeon(place_monster_idx) != mon_hook_dungeon(r_idx)) return (FALSE);
/* Require similar "race" */
if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
if (place_monster_idx == r_idx) return (FALSE);
/* Skip different alignment */
- if (((r_ptr->flags3 & RF3_EVIL) && (z_ptr->flags3 & RF3_GOOD)) ||
- ((r_ptr->flags3 & RF3_GOOD) && (r_ptr->flags3 & RF3_EVIL)))
- return FALSE;
+ if (monster_has_hostile_align(m_ptr, 0, 0, z_ptr)) return FALSE;
if (r_ptr->flags7 & RF7_FRIENDLY)
{
- if (((p_ptr->align < 0) && (z_ptr->flags3 & RF3_GOOD)) ||
- ((p_ptr->align > 0) && (z_ptr->flags3 & RF3_EVIL)))
- return FALSE;
+ if (monster_has_hostile_align(NULL, 1, -1, z_ptr)) return FALSE;
}
+ if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
+ return FALSE;
+
/* Okay */
return (TRUE);
}
* Note the use of the new "monster allocation table" code to restrict
* the "get_mon_num()" function to "legal" escort types.
*/
-bool place_monster_aux(int y, int x, int r_idx, bool slp, bool grp, bool friendly, bool pet, bool no_kage, bool no_pet)
+bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
{
int i;
monster_race *r_ptr = &r_info[r_idx];
- if (one_in_(333) && !no_kage && !pet) is_kage = TRUE;
- else is_kage = FALSE;
+ if (!(mode & PM_NO_KAGE) && one_in_(333))
+ mode |= PM_KAGE;
/* Place one monster, or fail */
- if (!place_monster_one(y, x, r_idx, slp, friendly, pet, no_pet)) return (FALSE);
+ if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
/* Require the "group" flag */
- if (!grp) return (TRUE);
+ if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
+ place_monster_m_idx = hack_m_idx_ii;
/* Friends for certain monsters */
if (r_ptr->flags1 & (RF1_FRIENDS))
{
/* Attempt to place a group */
- (void)place_monster_group(y, x, r_idx, slp, friendly, pet, no_pet);
+ (void)place_monster_group(who, y, x, r_idx, mode);
}
if (!z) break;
/* Place a single escort */
- (void)place_monster_one(ny, nx, z, slp, friendly, pet, no_pet);
+ (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
/* Place a "group" of escorts if needed */
if ((r_info[z].flags1 & RF1_FRIENDS) ||
(r_ptr->flags1 & RF1_ESCORTS))
{
/* Place a group of monsters */
- (void)place_monster_group(ny, nx, z, slp, friendly, pet, no_pet);
+ (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
}
}
}
*
* Attempt to find a monster appropriate to the "monster_level"
*/
-bool place_monster(int y, int x, bool slp, bool grp)
+bool place_monster(int y, int x, u32b mode)
{
int r_idx;
if (!r_idx) return (FALSE);
/* Attempt to place the monster */
- if (place_monster_aux(y, x, r_idx, slp, grp, FALSE, FALSE, FALSE, FALSE)) return (TRUE);
+ if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
/* Oops */
return (FALSE);
}
if (attempts < 1) return FALSE;
- if (r_ptr->flags3 & RF3_GOOD) horde_align |= HORDE_NOEVIL;
- if (r_ptr->flags3 & RF3_EVIL) horde_align |= HORDE_NOGOOD;
-
attempts = 1000;
while (--attempts)
{
/* Attempt to place the monster */
- if (place_monster_aux(y, x, r_idx, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE)) break;
+ if (place_monster_aux(0, y, x, r_idx, 0L)) break;
}
- if (attempts < 1) {horde_align = 0;return FALSE;}
+ if (attempts < 1) return FALSE;
m_idx = cave[y][x].m_idx;
- if (m_list[m_idx].mflag2 & MFLAG_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
+ if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
summon_kin_type = r_ptr->d_char;
- for (attempts = randint(10) + 5; attempts; attempts--)
+ for (attempts = randint1(10) + 5; attempts; attempts--)
{
scatter(&cy, &cx, y, x, 5, 0);
- (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, TRUE, FALSE, FALSE, FALSE, FALSE);
+ (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
y = cy;
x = cx;
}
- horde_align = 0;
return TRUE;
}
#endif /* MONSTER_HORDES */
+/*
+ * Put the Guardian
+ */
+bool alloc_guardian(void)
+{
+ int guardian = d_info[dungeon_type].final_guardian;
+
+ if (guardian && (d_info[dungeon_type].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
+ {
+ int oy;
+ int ox;
+ int try = 4000;
+
+ /* Find a good position */
+ while (try)
+ {
+ /* Get a random spot */
+ oy = randint1(cur_hgt - 4) + 2;
+ ox = randint1(cur_wid - 4) + 2;
+
+ /* Is it a good spot ? */
+ if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian]))
+ {
+ /* Place the guardian */
+ if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) return TRUE;
+ }
+
+ /* One less try */
+ try--;
+ }
+ }
+
+ return FALSE;
+}
+
/*
* Attempt to allocate a random monster in the dungeon.
*
* Use "monster_level" for the monster level
*/
-bool alloc_monster(int dis, bool slp)
+bool alloc_monster(int dis, u32b mode)
{
int y = 0, x = 0;
int attempts_left = 10000;
+ /* Put the Guardian */
+ if (alloc_guardian()) return TRUE;
+
/* Find a legal, distant, unoccupied, space */
while (attempts_left--)
{
/* Pick a location */
- y = rand_int(cur_hgt);
- x = rand_int(cur_wid);
+ y = randint0(cur_hgt);
+ x = randint0(cur_wid);
/* Require empty floor grid (was "naked") */
if (dun_level || (wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].terrain != TERRAIN_MOUNTAIN))
#ifdef MONSTER_HORDES
- if (randint(5000) <= dun_level)
+ if (randint1(5000) <= dun_level)
{
if (alloc_horde(y, x))
{
#ifdef JP
-if (cheat_hear) msg_print("¥â¥ó¥¹¥¿¡¼¤ÎÂç·²");
+ if (cheat_hear) msg_format("¥â¥ó¥¹¥¿¡¼¤ÎÂç·²(%c)", summon_kin_type);
#else
- if (cheat_hear) msg_print("Monster horde.");
+ if (cheat_hear) msg_format("Monster horde (%c).", summon_kin_type);
#endif
return (TRUE);
#endif /* MONSTER_HORDES */
/* Attempt to place the monster, allow groups */
- if (place_monster(y, x, slp, TRUE)) return (TRUE);
+ if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
#ifdef MONSTER_HORDES
}
monster_race *r_ptr = &r_info[r_idx];
/* Hack - Only summon dungeon monsters */
- if (!monster_dungeon(r_idx)) return (FALSE);
+ if (!mon_hook_dungeon(r_idx)) return (FALSE);
/* Hack -- identify the summoning monster */
if (summon_specific_who > 0)
{
monster_type *m_ptr = &m_list[summon_specific_who];
- monster_race *s_ptr = &r_info[m_ptr->r_idx];
/* Do not summon enemies */
/* Friendly vs. opposite aligned normal or pet */
- if (((r_ptr->flags3 & RF3_EVIL) &&
- (s_ptr->flags3 & RF3_GOOD)) ||
- ((r_ptr->flags3 & RF3_GOOD) &&
- (s_ptr->flags3 & RF3_EVIL)))
- {
- return FALSE;
- }
-
- /* Hostile vs. non-hostile */
- if (is_hostile(m_ptr) != summon_specific_hostile)
- {
- return FALSE;
- }
+ if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
}
/* Use the player's alignment */
else if (summon_specific_who < 0)
{
/* Do not summon enemies of the pets */
- if ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))
+ if (monster_has_hostile_align(NULL, 10, -10, r_ptr))
{
- if (!(one_in_((0-p_ptr->align)/2+1))) return FALSE;
- }
- else if ((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL))
- {
- if (!(one_in_(p_ptr->align/2+1))) return FALSE;
+ if (!one_in_(ABS(p_ptr->align) / 2 + 1)) return FALSE;
}
}
/* Hack -- no specific type specified */
if (!summon_specific_type) return (TRUE);
- if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7))) return FALSE;
+ if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))) return FALSE;
if ((summon_specific_who < 0) &&
- ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)) &&
- (((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL)) ||
- ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))))
+ ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) &&
+ monster_has_hostile_align(NULL, 10, -10, r_ptr))
return FALSE;
- if ((horde_align & HORDE_NOGOOD) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
- if ((horde_align & HORDE_NOEVIL) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
-
if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
return (summon_specific_aux(r_idx));
*
* Note that this function may not succeed, though this is very rare.
*/
-bool summon_specific(int who, int y1, int x1, int lev, int type, bool group, bool friendly, bool pet, bool unique_okay, bool no_pet)
+bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode)
{
int x, y, r_idx;
- bool no_kage = FALSE;
-
if (p_ptr->inside_arena) return (FALSE);
if (!mon_scatter(&y, &x, y1, x1, 2)) return FALSE;
/* Save the "summon" type */
summon_specific_type = type;
- summon_unique_okay = unique_okay;
-
- /* Save the hostility */
- summon_specific_hostile = (!friendly && !pet);
+ summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
/* Prepare allocation table */
get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
return (FALSE);
}
- if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) no_kage = TRUE;
+ if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
/* Attempt to place the monster (awake, allow groups) */
- if (!place_monster_aux(y, x, r_idx, FALSE, group, friendly, pet, no_kage, no_pet))
+ if (!place_monster_aux(who, y, x, r_idx, mode))
{
summon_specific_type = 0;
return (FALSE);
}
/* A "dangerous" function, creates a pet of the specified type */
-bool summon_named_creature (int oy, int ox, int r_idx, bool slp, bool group_ok, bool friendly, bool pet)
+bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode)
{
int x, y;
if (!mon_scatter(&y, &x, oy, ox, 2)) return FALSE;
/* Place it (allow groups) */
- return place_monster_aux(y, x, r_idx, slp, group_ok, friendly, pet, TRUE, FALSE);
+ return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
}
*
* Note that "reproduction" REQUIRES empty space.
*/
-bool multiply_monster(int m_idx, bool clone, bool friendly, bool pet)
+bool multiply_monster(int m_idx, bool clone, u32b mode)
{
monster_type *m_ptr = &m_list[m_idx];
if (!mon_scatter(&y, &x, m_ptr->fy, m_ptr->fx, 1))
return FALSE;
+ if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
+
+ /* Hack -- Shadower spawns Shadower */
+ if (m_ptr->mflag2 & MFLAG2_KAGE) mode |= PM_KAGE;
+
/* Create a new monster (awake, no groups) */
- if (!place_monster_aux(y, x, m_ptr->r_idx, FALSE, FALSE, friendly, pet, TRUE, (bool)(m_ptr->mflag2 & MFLAG_NOPET)))
+ if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE)))
return FALSE;
- if (clone)
+ /* Hack -- Transfer "clone" flag */
+ if (clone || (m_ptr->smart & SM_CLONED))
{
m_list[hack_m_idx_ii].smart |= SM_CLONED;
- m_list[hack_m_idx_ii].mflag2 |= MFLAG_NOPET;
+ m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
}
+ /* Hack -- Appearance transfer */
+ if (!is_original_ap(m_ptr)) m_list[hack_m_idx_ii].ap_r_idx = m_ptr->ap_r_idx;
+
return TRUE;
}
/* Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs */
- if (strchr(",ejmvwQ", r_ptr->d_char))
+ if (my_strchr(",ejmvwQ", r_ptr->d_char))
{
#ifdef JP
if (percentage > 95)
/* Fish */
- else if (strchr("l", r_ptr->d_char))
+ else if (my_strchr("l", r_ptr->d_char))
{
if (percentage > 95)
#ifdef JP
/* Golems, Walls, Doors, Stairs */
- else if (strchr("g#+<>", r_ptr->d_char))
+ else if (my_strchr("g#+<>", r_ptr->d_char))
{
if (percentage > 95)
#ifdef JP
/* Snakes, Hydrae, Reptiles, Mimics */
- else if (strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char))
+ else if (my_strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char))
{
if (percentage > 95)
#ifdef JP
/* Felines */
- else if (strchr("f", r_ptr->d_char))
+ else if (my_strchr("f", r_ptr->d_char))
{
if (percentage > 95)
#ifdef JP
/* Ants, Centipedes, Flies, Insects, Beetles, Spiders */
- else if (strchr("acFIKS", r_ptr->d_char))
+ else if (my_strchr("acFIKS", r_ptr->d_char))
{
if (percentage > 95)
#ifdef JP
/* Birds */
- else if (strchr("B", r_ptr->d_char))
+ else if (my_strchr("B", r_ptr->d_char))
{
if (percentage > 95)
#ifdef JP
/* Dragons, Demons, High Undead */
- else if (strchr("duDLUW", r_ptr->d_char))
+ else if (my_strchr("duDLUW", r_ptr->d_char))
{
if (percentage > 95)
#ifdef JP
/* Skeletons */
- else if (strchr("s", r_ptr->d_char))
+ else if (my_strchr("s", r_ptr->d_char))
{
if (percentage > 95)
#ifdef JP
/* Zombies */
- else if (strchr("z", r_ptr->d_char))
+ else if (my_strchr("z", r_ptr->d_char))
{
if (percentage > 95)
#ifdef JP
/* Ghosts */
- else if (strchr("G", r_ptr->d_char))
+ else if (my_strchr("G", r_ptr->d_char))
{
if (percentage > 95)
/* Dogs and Hounds */
- else if (strchr("CZ", r_ptr->d_char))
+ else if (my_strchr("CZ", r_ptr->d_char))
{
#ifdef JP
if (percentage > 95)
}
/* One type of monsters (ignore,squeal,shriek) */
- else if (strchr("Xbilqrt", r_ptr->d_char))
+ else if (my_strchr("Xbilqrt", r_ptr->d_char))
{
#ifdef JP
if (percentage > 95)
*/
void update_smart_learn(int m_idx, int what)
{
-#ifdef DRS_SMART_OPTIONS
-
monster_type *m_ptr = &m_list[m_idx];
monster_race *r_ptr = &r_info[m_ptr->r_idx];
if (r_ptr->flags2 & (RF2_STUPID)) return;
/* Not intelligent, only learn sometimes */
- if (!(r_ptr->flags2 & (RF2_SMART)) && (rand_int(100) < 50)) return;
+ if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
/* XXX XXX XXX */
{
case DRS_ACID:
if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
- if (p_ptr->oppose_acid) m_ptr->smart |= (SM_OPP_ACID);
+ if (IS_OPPOSE_ACID()) m_ptr->smart |= (SM_OPP_ACID);
if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
break;
case DRS_ELEC:
if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
- if (p_ptr->oppose_elec) m_ptr->smart |= (SM_OPP_ELEC);
+ if (IS_OPPOSE_ELEC()) m_ptr->smart |= (SM_OPP_ELEC);
if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
break;
case DRS_FIRE:
if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
- if (p_ptr->oppose_fire) m_ptr->smart |= (SM_OPP_FIRE);
+ if (IS_OPPOSE_FIRE()) m_ptr->smart |= (SM_OPP_FIRE);
if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
break;
case DRS_COLD:
if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
- if (p_ptr->oppose_cold) m_ptr->smart |= (SM_OPP_COLD);
+ if (IS_OPPOSE_COLD()) m_ptr->smart |= (SM_OPP_COLD);
if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
break;
case DRS_POIS:
if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
- if (p_ptr->oppose_pois) m_ptr->smart |= (SM_OPP_POIS);
+ if (IS_OPPOSE_POIS()) m_ptr->smart |= (SM_OPP_POIS);
break;
if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
break;
}
-
-#endif /* DRS_SMART_OPTIONS */
-
}
/* Acquire next object */
next_o_idx = o_ptr->next_o_idx;
- /* Paranoia */
- o_ptr->held_m_idx = 0;
-
/* Get local object */
q_ptr = &forge;
/* Copy the object */
object_copy(q_ptr, o_ptr);
+ /* Forget monster */
+ q_ptr->held_m_idx = 0;
+
/* Delete the object */
delete_object_idx(this_o_idx);