#define HURT_CHANCE 16
-static bool cave_monster_teleportable_bold(int m_idx, int y, int x, bool passive)
+static bool cave_monster_teleportable_bold(int m_idx, int y, int x, u32b mode)
{
monster_type *m_ptr = &m_list[m_idx];
cave_type *c_ptr = &cave[y][x];
if (is_glyph_grid(c_ptr)) return FALSE;
if (is_explosive_rune_grid(c_ptr)) return FALSE;
- if (!passive)
+ if (!(mode & TELEPORT_PASSIVE))
{
if (!monster_can_cross_terrain(c_ptr->feat, &r_info[m_ptr->r_idx], 0)) return FALSE;
}
*
* But allow variation to prevent infinite loops.
*/
-bool teleport_away(int m_idx, int dis, bool dec_valour, bool passive)
+bool teleport_away(int m_idx, int dis, u32b mode)
{
int oy, ox, d, i, min;
int tries = 0;
/* Minimum distance */
min = dis / 2;
- if (dec_valour &&
+ if ((mode & TELEPORT_DEC_VALOUR) &&
(((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
(4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
{
/* Ignore illegal locations */
if (!in_bounds(ny, nx)) continue;
- if (!cave_monster_teleportable_bold(m_idx, ny, nx, passive)) continue;
+ if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
/* No teleporting into vaults and such */
if (!(p_ptr->inside_quest || p_ptr->inside_arena))
/* Sound */
sound(SOUND_TPOTHER);
- /* Update the new location */
- cave[ny][nx].m_idx = m_idx;
-
/* Update the old location */
cave[oy][ox].m_idx = 0;
+ /* Update the new location */
+ cave[ny][nx].m_idx = m_idx;
+
/* Move the monster */
m_ptr->fy = ny;
m_ptr->fx = nx;
/*
* Teleport monster next to a grid near the given location
*/
-void teleport_monster_to(int m_idx, int ty, int tx, int power, bool passive)
+void teleport_monster_to(int m_idx, int ty, int tx, int power, u32b mode)
{
int ny, nx, oy, ox, d, i, min;
int attempts = 500;
/* Ignore illegal locations */
if (!in_bounds(ny, nx)) continue;
- if (!cave_monster_teleportable_bold(m_idx, ny, nx, passive)) continue;
+ if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
/* No teleporting into vaults and such */
/* if (cave[ny][nx].info & (CAVE_ICKY)) continue; */
/* Sound */
sound(SOUND_TPOTHER);
- /* Update the new location */
- cave[ny][nx].m_idx = m_idx;
-
/* Update the old location */
cave[oy][ox].m_idx = 0;
+ /* Update the new location */
+ cave[ny][nx].m_idx = m_idx;
+
/* Move the monster */
m_ptr->fy = ny;
m_ptr->fx = nx;
}
-bool cave_player_teleportable_bold(int y, int x, bool passive, bool nonmagical)
+bool cave_player_teleportable_bold(int y, int x, u32b mode)
{
cave_type *c_ptr = &cave[y][x];
feature_type *f_ptr = &f_info[c_ptr->feat];
if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
/* No magical teleporting into vaults and such */
- if (!nonmagical && (c_ptr->info & CAVE_ICKY)) return FALSE;
+ if (!(mode & TELEPORT_NONMAGICAL) && (c_ptr->info & CAVE_ICKY)) return FALSE;
if (c_ptr->m_idx && (c_ptr->m_idx != p_ptr->riding)) return FALSE;
- if (!passive)
+ /* don't teleport on a trap. */
+ if (have_flag(f_ptr->flags, FF_HIT_TRAP)) return FALSE;
+
+ if (!(mode & TELEPORT_PASSIVE))
{
if (!player_can_enter(c_ptr->feat, 0)) return FALSE;
if (!p_ptr->levitation) return FALSE;
}
- if (have_flag(f_ptr->flags, FF_HIT_TRAP))
- {
- if (!is_known_trap(c_ptr) || !trap_can_be_ignored(c_ptr->feat)) return FALSE;
- }
}
return TRUE;
* If no such spaces are readily available, the distance may increase.
* Try very hard to move the player at least a quarter that distance.
*
- * When long-range teleport effects are considered, there is a nasty
- * tendency to "bounce" the player between two or three different spots
- * because these are the only spots that are "far enough" way to satisfy
- * the algorithm. Therefore, if the teleport distance is more than 50,
- * we decrease the minimum acceptable distance to try to increase randomness.
- * -GJW
+ * There was a nasty tendency for a long time; which was causing the
+ * player to "bounce" between two or three different spots because
+ * these are the only spots that are "far enough" way to satisfy the
+ * algorithm.
+ *
+ * But this tendency is now removed; in the new algorithm, a list of
+ * candidates is selected first, which includes at least 50% of all
+ * floor grids within the distance, and any single grid in this list
+ * of candidates has equal possibility to be choosen as a destination.
*/
-void teleport_player(int dis, bool passive)
-{
- int d, i, min, ox, oy;
- int tries = 0;
- int xx, yy;
+#define MAX_TELEPORT_DISTANCE 200
- /* Initialize */
- int y = py;
- int x = px;
+bool teleport_player_aux(int dis, u32b mode)
+{
+ int candidates_at[MAX_TELEPORT_DISTANCE + 1];
+ int total_candidates, cur_candidates;
+ int y = 0, x = 0, min, pick, i;
- bool look = TRUE;
+ int left = MAX(1, px - dis);
+ int right = MIN(cur_wid - 2, px + dis);
+ int top = MAX(1, py - dis);
+ int bottom = MIN(cur_hgt - 2, py + dis);
- if (p_ptr->wild_mode) return;
+ if (p_ptr->wild_mode) return FALSE;
- if (p_ptr->anti_tele)
+ if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
{
#ifdef JP
-msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
+ msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
#else
msg_print("A mysterious force prevents you from teleporting!");
#endif
- return;
+ return FALSE;
}
- if (dis > 200) dis = 200; /* To be on the safe side... */
+ /* Initialize counters */
+ total_candidates = 0;
+ for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
+ candidates_at[i] = 0;
- /* Minimum distance */
- min = dis / (dis > 50 ? 3 : 2);
+ /* Limit the distance */
+ if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
- /* Look until done */
- while (look)
+ /* Search valid locations */
+ for (y = top; y <= bottom; y++)
{
- tries++;
-
- /* Verify max distance */
- if (dis > 200) dis = 200;
-
- /* Try several locations */
- for (i = 0; i < 500; i++)
+ for (x = left; x <= right; x++)
{
- /* Pick a (possibly illegal) location */
- while (1)
- {
- y = rand_spread(py, dis);
- x = rand_spread(px, dis);
- d = distance(py, px, y, x);
- if ((d >= min) && (d <= dis)) break;
- }
+ int d;
- /* Ignore illegal locations */
- if (!in_bounds(y, x)) continue;
+ /* Skip illegal locations */
+ if (!cave_player_teleportable_bold(y, x, mode)) continue;
- if (!cave_player_teleportable_bold(y, x, passive, FALSE)) continue;
+ /* Calculate distance */
+ d = distance(py, px, y, x);
- /* This grid looks good */
- look = FALSE;
+ /* Skip too far locations */
+ if (d > dis) continue;
- /* Stop looking */
- break;
+ /* Count the total number of candidates */
+ total_candidates++;
+
+ /* Count the number of candidates in this circumference */
+ candidates_at[d]++;
}
+ }
- /* Increase the maximum distance */
- dis = dis * 2;
+ /* No valid location! */
+ if (0 == total_candidates) return FALSE;
- /* Decrease the minimum distance */
- min = min / 2;
+ /* Fix the minimum distance */
+ for (cur_candidates = 0, min = dis; min >= 0; min--)
+ {
+ cur_candidates += candidates_at[min];
- /* Stop after MAX_TRIES tries */
- if (tries > MAX_TRIES) return;
+ /* 50% of all candidates will have an equal chance to be choosen. */
+ if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
+ }
+
+ /* Pick up a single location randomly */
+ pick = randint1(cur_candidates);
+
+ /* Search again the choosen location */
+ for (y = top; y <= bottom; y++)
+ {
+ for (x = left; x <= right; x++)
+ {
+ int d;
+
+ /* Skip illegal locations */
+ if (!cave_player_teleportable_bold(y, x, mode)) continue;
+
+ /* Calculate distance */
+ d = distance(py, px, y, x);
+
+ /* Skip too far locations */
+ if (d > dis) continue;
+
+ /* Skip too close locations */
+ if (d < min) continue;
+
+ /* This grid was picked up? */
+ pick--;
+ if (!pick) break;
+ }
+
+ /* Exit the loop */
+ if (!pick) break;
}
+ if (player_bold(y, x)) return FALSE;
+
/* Sound */
sound(SOUND_TELEPORT);
msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
#endif
- /* Save the old location */
- oy = py;
- ox = px;
-
/* Move the player */
(void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
+ return TRUE;
+}
+
+void teleport_player(int dis, u32b mode)
+{
+ int yy, xx;
+
+ /* Save the old location */
+ int oy = py;
+ int ox = px;
+
+ if (!teleport_player_aux(dis, mode)) return;
+
/* Monsters with teleport ability may follow the player */
for (xx = -1; xx < 2; xx++)
{
int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
/* A monster except your mount may follow */
- if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
+ if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
{
monster_type *m_ptr = &m_list[tmp_m_idx];
monster_race *r_ptr = &r_info[m_ptr->r_idx];
if ((r_ptr->flags6 & RF6_TPORT) &&
!(r_ptr->flagsr & RFR_RES_TELE))
{
- if (!m_ptr->csleep) teleport_monster_to(tmp_m_idx, y, x, r_ptr->level, FALSE);
+ if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level, 0L);
}
}
}
}
+void teleport_player_away(int m_idx, int dis)
+{
+ int yy, xx;
+
+ /* Save the old location */
+ int oy = py;
+ int ox = px;
+
+ if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
+
+ /* Monsters with teleport ability may follow the player */
+ for (xx = -1; xx < 2; xx++)
+ {
+ for (yy = -1; yy < 2; yy++)
+ {
+ int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
+
+ /* A monster except your mount or caster may follow */
+ if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
+ {
+ monster_type *m_ptr = &m_list[tmp_m_idx];
+ monster_race *r_ptr = &r_info[m_ptr->r_idx];
+
+ /*
+ * The latter limitation is to avoid
+ * totally unkillable suckers...
+ */
+ if ((r_ptr->flags6 & RF6_TPORT) &&
+ !(r_ptr->flagsr & RFR_RES_TELE))
+ {
+ if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level, 0L);
+ }
+ }
+ }
+ }
+}
+
/*
* Teleport player to a grid near the given location
* This function is slightly obsessive about correctness.
* This function allows teleporting into vaults (!)
*/
-void teleport_player_to(int ny, int nx, bool no_tele, bool passive)
+void teleport_player_to(int ny, int nx, u32b mode)
{
int y, x, dis = 0, ctr = 0;
- if (p_ptr->anti_tele && no_tele)
+ if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
{
#ifdef JP
msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
}
/* Accept any grid when wizard mode */
- if (p_ptr->wizard && (!cave[y][x].m_idx || (cave[y][x].m_idx == p_ptr->riding))) break;
+ if (p_ptr->wizard && !(mode & TELEPORT_PASSIVE) && (!cave[y][x].m_idx || (cave[y][x].m_idx == p_ptr->riding))) break;
/* Accept teleportable floor grids */
- if (cave_player_teleportable_bold(y, x, passive, !no_tele)) break;
+ if (cave_player_teleportable_bold(y, x, mode)) break;
/* Occasionally advance the distance */
if (++ctr > (4 * dis * dis + 4 * dis + 1))
}
+void teleport_away_followable(int m_idx)
+{
+ monster_type *m_ptr = &m_list[m_idx];
+ int oldfy = m_ptr->fy;
+ int oldfx = m_ptr->fx;
+ bool old_ml = m_ptr->ml;
+ int old_cdis = m_ptr->cdis;
+
+ teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
+
+ if (old_ml && (old_cdis <= MAX_SIGHT) && !world_monster && !p_ptr->inside_battle && los(py, px, oldfy, oldfx))
+ {
+ bool follow = FALSE;
+
+ if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
+ else
+ {
+ u32b flgs[TR_FLAG_SIZE];
+ object_type *o_ptr;
+ int i;
+
+ for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
+ {
+ o_ptr = &inventory[i];
+ if (o_ptr->k_idx && !object_is_cursed(o_ptr))
+ {
+ object_flags(o_ptr, flgs);
+ if (have_flag(flgs, TR_TELEPORT))
+ {
+ follow = TRUE;
+ break;
+ }
+ }
+ }
+ }
+
+ if (follow)
+ {
+#ifdef JP
+ if (get_check_strict("¤Ä¤¤¤Æ¤¤¤¤Þ¤¹¤«¡©", CHECK_OKAY_CANCEL))
+#else
+ if (get_check_strict("Do you follow it? ", CHECK_OKAY_CANCEL))
+#endif
+ {
+ if (one_in_(3))
+ {
+ teleport_player(200, TELEPORT_PASSIVE);
+#ifdef JP
+ msg_print("¼ºÇÔ¡ª");
+#else
+ msg_print("Failed!");
+#endif
+ }
+ else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
+ p_ptr->energy_need += ENERGY_NEED();
+ }
+ }
+ }
+}
+
/*
* Teleport the player one level up or down (random when legal)
/* Check for quest completion */
check_quest_completion(m_ptr);
+ if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
+ {
+ char m2_name[80];
+
+ monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
+ do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
+ }
+
delete_monster_idx(m_idx);
}
{
case 1: case 2: case 3:
{
- teleport_player(200, TRUE);
+ teleport_player(200, TELEPORT_PASSIVE);
break;
}
case 4: case 5:
{
- teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE, TRUE);
+ teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
break;
}
o_ptr->name2 = EGO_SHARPNESS;
o_ptr->pval = m_bonus(5, dun_level) + 1;
+
+ if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
+ o_ptr->pval = 2;
}
else
{
m_ptr = &m_list[c_ptr->m_idx];
/* Awake monster */
- if (c_ptr->m_idx && m_ptr->csleep)
+ if (c_ptr->m_idx && MON_CSLEEP(m_ptr))
{
/* Reset sleep counter */
- m_ptr->csleep = 0;
+ (void)set_monster_csleep(c_ptr->m_idx, 0);
/* Notice the "waking up" */
- if (is_seen(m_ptr))
+ if (m_ptr->ml)
{
/* Acquire the monster name */
monster_desc(m_name, m_ptr, 0);
msg_format("%^s wakes up.", m_name);
#endif
}
-
- if (m_ptr->ml)
- {
- /* Redraw the health bar */
- if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
- if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
- }
}
/* Process all walls, doors and patterns */
/* Create a glyph */
cave[py][px].info |= CAVE_OBJECT;
- cave[py][px].mimic = FEAT_GLYPH;
+ cave[py][px].mimic = feat_glyph;
/* Notice */
note_spot(py, px);
/* Create a mirror */
cave[py][px].info |= CAVE_OBJECT;
- cave[py][px].mimic = FEAT_MIRROR;
+ cave[py][px].mimic = feat_mirror;
/* Turn on the light */
cave[py][px].info |= CAVE_GLOW;
/* Create a glyph */
cave[py][px].info |= CAVE_OBJECT;
- cave[py][px].mimic = FEAT_MINOR_GLYPH;
+ cave[py][px].mimic = feat_explosive_rune;
/* Notice */
note_spot(py, px);
object_aware(o_ptr);
object_known(o_ptr);
+ /* Player touches it */
+ o_ptr->marked |= OM_TOUCHED;
+
/* Recalculate bonuses */
p_ptr->update |= (PU_BONUS);
else
item_tester_hook = item_tester_hook_identify;
- if (!can_get_item())
+ if (can_get_item())
+ {
+#ifdef JP
+ q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
+#else
+ q = "Identify which item? ";
+#endif
+ }
+ else
{
if (only_equip)
- {
item_tester_hook = object_is_weapon_armour_ammo;
- }
else
- {
item_tester_hook = NULL;
- }
+
+#ifdef JP
+ q = "¤¹¤Ù¤Æ´ÕÄêºÑ¤ß¤Ç¤¹¡£ ";
+#else
+ q = "All items are identified. ";
+#endif
}
/* Get an item */
#ifdef JP
-q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
-s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
+ s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
#else
- q = "Identify which item? ";
s = "You have nothing to identify.";
#endif
else
item_tester_hook = item_tester_hook_identify_fully;
- if (!can_get_item())
+ if (can_get_item())
+ {
+#ifdef JP
+ q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò*´ÕÄê*¤·¤Þ¤¹¤«? ";
+#else
+ q = "*Identify* which item? ";
+#endif
+ }
+ else
{
if (only_equip)
item_tester_hook = object_is_weapon_armour_ammo;
else
item_tester_hook = NULL;
+
+#ifdef JP
+ q = "¤¹¤Ù¤Æ*´ÕÄê*ºÑ¤ß¤Ç¤¹¡£ ";
+#else
+ q = "All items are *identified*. ";
+#endif
}
/* Get an item */
#ifdef JP
-q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
-s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
+ s = "*´ÕÄê*¤¹¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
#else
- q = "Identify which item? ";
- s = "You have nothing to identify.";
+ s = "You have nothing to *identify*.";
#endif
if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
}
/* Describe it fully */
- (void)screen_object(o_ptr, TRUE);
+ (void)screen_object(o_ptr, 0L);
/* Auto-inscription/destroy */
autopick_alter_item(item, (bool)(destroy_identify && !old_known));
if (object_is_cursed(o_ptr))
{
if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
+ have_flag(flgs, TR_ADD_L_CURSE) ||
+ have_flag(flgs, TR_ADD_H_CURSE) ||
(o_ptr->curse_flags & TRC_PERMA_CURSE))
{
#ifdef JP
int i, j;
int y, x;
int m[9];
- magic_type *s_ptr;
+ const magic_type *s_ptr;
char name[80];
char out_val[160];
if (p_ptr->pclass == CLASS_SORCERER) return;
if (p_ptr->pclass == CLASS_RED_MAGE) return;
+ /* Snipers */
+ if (p_ptr->pclass == CLASS_SNIPER)
+ {
+ display_snipe_list();
+ return;
+ }
+
/* mind.c type classes */
if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
(p_ptr->pclass == CLASS_BERSERKER) ||
s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
}
- strcpy(name, do_spell(spell_id_from((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32), SPELL_NAME));
+ strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
/* Illegible */
if (s_ptr->slevel >= 99)
s16b spell_chance(int spell, int use_realm)
{
int chance, minfail;
- magic_type *s_ptr;
+ const magic_type *s_ptr;
int need_mana;
int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
chance = mod_spell_chance_1(chance);
- if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
- if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
- if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
+ /* Goodness or evilness gives a penalty to failure rate */
+ switch (use_realm)
+ {
+ case REALM_NATURE:
+ if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
+ break;
+ case REALM_LIFE: case REALM_CRUSADE:
+ if (p_ptr->align < -20) chance += penalty;
+ break;
+ case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
+ if (p_ptr->align > 20) chance += penalty;
+ break;
+ }
/* Minimum failure rate */
if (chance < minfail) chance = minfail;
*/
bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
{
- magic_type *s_ptr;
+ const magic_type *s_ptr;
/* Access the spell */
if (!is_magic(use_realm))
void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
{
int i, spell, exp_level, increment = 64;
- magic_type *s_ptr;
+ const magic_type *s_ptr;
cptr comment;
char info[80];
char out_val[160];
/* XXX XXX Could label spells above the players level */
/* Get extra info */
- strcpy(info, do_spell(spell_id_from(use_realm, spell), SPELL_INFO));
+ strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
/* Use that info */
comment = info;
if (use_realm == REALM_HISSATSU)
{
strcat(out_val, format("%-25s %2d %4d",
- do_spell(spell_id_from(use_realm, spell), SPELL_NAME), /* realm, spell */
+ do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
s_ptr->slevel, need_mana));
}
else
{
strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
- do_spell(spell_id_from(use_realm, spell), SPELL_NAME), /* realm, spell */
+ do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
(max ? '!' : ' '), ryakuji,
s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
}
case TV_DEATH_BOOK:
case TV_TRUMP_BOOK:
case TV_ARCANE_BOOK:
- case TV_ENCHANT_BOOK:
+ case TV_CRAFT_BOOK:
case TV_DAEMON_BOOK:
case TV_CRUSADE_BOOK:
case TV_MUSIC_BOOK:
case TV_HISSATSU_BOOK:
+ case TV_HEX_BOOK:
{
return (TRUE);
}
object_type *o_ptr;
char o_name[MAX_NLEN];
- /* Multishadow effects is determined by turn */
- if( p_ptr->multishadow && (turn & 1) )return 0;
+ if (CHECK_MULTISHADOW()) return 0;
if (p_ptr->inside_arena) return 0;
if (p_ptr->resist_acid) dam = (dam + 2) / 3;
if (double_resist) dam = (dam + 2) / 3;
- if ((!(double_resist || p_ptr->resist_acid)) &&
- one_in_(HURT_CHANCE))
- (void)do_dec_stat(A_CHR);
+ if (!CHECK_MULTISHADOW())
+ {
+ if ((!(double_resist || p_ptr->resist_acid)) &&
+ one_in_(HURT_CHANCE))
+ (void)do_dec_stat(A_CHR);
- /* If any armor gets hit, defend the player */
- if (minus_ac()) dam = (dam + 1) / 2;
+ /* If any armor gets hit, defend the player */
+ if (minus_ac()) dam = (dam + 1) / 2;
+ }
/* Take damage */
- get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
+ get_damage = take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
/* Inventory damage */
if (!(double_resist && p_ptr->resist_acid))
if (double_resist) dam = (dam + 2) / 3;
if ((!(double_resist || p_ptr->resist_elec)) &&
- one_in_(HURT_CHANCE))
+ one_in_(HURT_CHANCE) && !CHECK_MULTISHADOW())
(void)do_dec_stat(A_DEX);
/* Take damage */
- get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
+ get_damage = take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
/* Inventory damage */
if (!(double_resist && p_ptr->resist_elec))
if (double_resist) dam = (dam + 2) / 3;
if ((!(double_resist || p_ptr->resist_fire)) &&
- one_in_(HURT_CHANCE))
+ one_in_(HURT_CHANCE) && !CHECK_MULTISHADOW())
(void)do_dec_stat(A_STR);
/* Take damage */
- get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
+ get_damage = take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
/* Inventory damage */
if (!(double_resist && p_ptr->resist_fire))
if (double_resist) dam = (dam + 2) / 3;
if ((!(double_resist || p_ptr->resist_cold)) &&
- one_in_(HURT_CHANCE))
+ one_in_(HURT_CHANCE) && !CHECK_MULTISHADOW())
(void)do_dec_stat(A_STR);
/* Take damage */
- get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
+ get_damage = take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
/* Inventory damage */
if (!(double_resist && p_ptr->resist_cold))
/*
* Curse the players weapon
*/
-bool curse_weapon(bool force, int slot)
+bool curse_weapon_object(bool force, object_type *o_ptr)
{
int i;
-
- object_type *o_ptr;
-
char o_name[MAX_NLEN];
-
- /* Curse the weapon */
- o_ptr = &inventory[slot];
-
/* Nothing to curse */
if (!o_ptr->k_idx) return (FALSE);
-
/* Describe */
object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
{
/* Cool */
#ifdef JP
-msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
-"¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
+ msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
+ "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
#else
msg_format("A %s tries to %s, but your %s resists the effects!",
- "terrible black aura", "surround your weapon", o_name);
+ "terrible black aura", "surround your weapon", o_name);
#endif
-
}
/* not artifact or failed save... */
{
/* Oops */
#ifdef JP
-if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
+ if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
#else
if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
#endif
-
chg_virtue(V_ENCHANT, -5);
/* Shatter the weapon */
for (i = 0; i < TR_FLAG_SIZE; i++)
o_ptr->art_flags[i] = 0;
-
/* Curse it */
o_ptr->curse_flags = TRC_CURSED;
return (TRUE);
}
+bool curse_weapon(bool force, int slot)
+{
+ /* Curse the weapon */
+ return curse_weapon_object(force, &inventory[slot]);
+}
+
/*
* Enchant some bolts
if (new_r_idx != old_r_idx)
{
u32b mode = 0L;
+ bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
+ s16b this_o_idx, next_o_idx = 0;
/* Get the monsters attitude */
if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
+ /* Mega-hack -- ignore held objects */
+ m_ptr->hold_o_idx = 0;
+
/* "Kill" the "old" monster */
delete_monster_idx(c_ptr->m_idx);
/* Create a new monster (no groups) */
if (place_monster_aux(0, y, x, new_r_idx, mode))
{
+ m_list[hack_m_idx_ii].nickname = back_m.nickname;
+ m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
+ m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
+
/* Success */
polymorphed = TRUE;
}
{
/* Placing the new monster failed */
if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
+ {
m_list[hack_m_idx_ii] = back_m;
+
+ /* Re-initialize monster process */
+ mproc_init();
+ }
+ else preserve_hold_objects = FALSE;
+ }
+
+ /* Mega-hack -- preserve held objects */
+ if (preserve_hold_objects)
+ {
+ for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
+ {
+ /* Acquire object */
+ object_type *o_ptr = &o_list[this_o_idx];
+
+ /* Acquire next object */
+ next_o_idx = o_ptr->next_o_idx;
+
+ /* Held by new monster */
+ o_ptr->held_m_idx = hack_m_idx_ii;
+ }
+ }
+ else if (back_m.hold_o_idx) /* Failed (paranoia) */
+ {
+ /* Delete objects */
+ for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
+ {
+ /* Acquire next object */
+ next_o_idx = o_list[this_o_idx].next_o_idx;
+
+ /* Delete the object */
+ delete_object_idx(this_o_idx);
+ }
}
if (targeted) target_who = hack_m_idx_ii;
p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
- if (!cave_player_teleportable_bold(y, x, FALSE, FALSE) ||
+ if (!cave_player_teleportable_bold(y, x, 0L) ||
(distance(y, x, py, px) > plev / 2 + 10) ||
(!randint0(plev / 10 + 10)))
{
p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
- teleport_player((plev + 2) * 2, TRUE);
+ teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
/* Failed */
return FALSE;
}
else
{
- teleport_player_to(y, x, TRUE, FALSE);
+ teleport_player_to(y, x, 0L);
/* Success */
return TRUE;
case RACE_NIBELUNG:
case RACE_DARK_ELF:
case RACE_MIND_FLAYER:
- case RACE_KUTA:
+ case RACE_KUTAR:
case RACE_S_FAIRY:
summon_kin_type = 'h';
break;