summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-05 14:04:39 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-05 14:04:39 +0000
commita57d484bd70f19a06271202fd5e5a9d0be914d18 (patch)
tree2d4e1edd7666c7c3f07164104d3753a477af5b5b /crawl-ref
parent70e12c754c318dc3e7b513d45c9cca91c94147ca (diff)
downloadcrawl-ref-a57d484bd70f19a06271202fd5e5a9d0be914d18.tar.gz
crawl-ref-a57d484bd70f19a06271202fd5e5a9d0be914d18.zip
Fix mimics not teleporting when attacked by reaching or airstrike, and a
few (really) minor adjustments on monster pathfinding. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5487 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/beam.cc9
-rw-r--r--crawl-ref/source/dat/database/rand_wpn.txt2
-rw-r--r--crawl-ref/source/debug.cc11
-rw-r--r--crawl-ref/source/fight.cc2
-rw-r--r--crawl-ref/source/it_use3.cc28
-rw-r--r--crawl-ref/source/monplace.cc8
-rw-r--r--crawl-ref/source/mstuff2.cc10
-rw-r--r--crawl-ref/source/spells3.cc8
8 files changed, 57 insertions, 21 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index ffe74d553b..7727b70f7d 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -2807,6 +2807,9 @@ bool check_line_of_sight( int sx, int sy, int tx, int ty )
// monster_teleport() in mstuff2.cc.
void mimic_alert(monsters *mimic)
{
+ if (!mimic->alive())
+ return;
+
bool should_id = !testbits(mimic->flags, MF_KNOWN_MIMIC)
&& player_monster_visible(mimic) && mons_near(mimic);
@@ -2823,10 +2826,10 @@ void mimic_alert(monsters *mimic)
const bool instant_tele = !one_chance_in(3);
monster_teleport( mimic, instant_tele );
- // at least for this short while, we know it's a mimic
+ // At least for this short while, we know it's a mimic.
if (!instant_tele && should_id)
mimic->flags |= MF_KNOWN_MIMIC;
-} // end mimic_alert()
+}
static bool _isBouncy(bolt &beam, unsigned char gridtype)
{
@@ -2854,7 +2857,7 @@ static void _beam_explodes(bolt &beam, int x, int y)
beam.target_x = x;
beam.target_y = y;
- // generic explosion
+ // Generic explosion.
if (beam.is_explosion) // beam.flavour == BEAM_EXPLOSION || beam.flavour == BEAM_HOLY)
{
_explosion1(beam);
diff --git a/crawl-ref/source/dat/database/rand_wpn.txt b/crawl-ref/source/dat/database/rand_wpn.txt
index 153777990c..9eff63d4d8 100644
--- a/crawl-ref/source/dat/database/rand_wpn.txt
+++ b/crawl-ref/source/dat/database/rand_wpn.txt
@@ -812,6 +812,8 @@ Giant
Beetle
Jelly
+
+@player_genus@
%%%%
monster_name
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index 7337faa475..30fdcbf26b 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -4070,16 +4070,21 @@ void debug_pathfind(int mid)
return;
mpr("Choose a destination!");
-#ifdef USE_TILE
+#ifndef USE_TILE
more();
#endif
coord_def dest;
show_map(dest, true);
redraw_screen();
+ if (!dest.x)
+ {
+ canned_msg(MSG_OK);
+ return;
+ }
monsters &mon = menv[mid];
- mprf("Attempting to calculate a path from (%d, %d) to (%d, %d)...",
- mon.x, mon.y, dest.x, dest.y);
+ mprf("Attempting to calculate a path from (%d, %d) to (%d, %d)...",
+ mon.x, mon.y, dest.x, dest.y);
monster_pathfind mp;
bool success = mp.start_pathfind(&mon, dest, true);
if (success)
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 07d7087389..9b2a31a6ef 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -3994,7 +3994,7 @@ bool you_attack(int monster_attacked, bool unarmed_attacks)
// We're trying to hit a monster, break out of travel/explore now.
interrupt_activity(AI_HIT_MONSTER, defender);
- // check if the player is fighting with something unsuitable
+ // Check if the player is fighting with something unsuitable.
wielded_weapon_check(attk.weapon);
bool attack = attk.attack();
diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc
index 8207395be4..28598708e0 100644
--- a/crawl-ref/source/it_use3.cc
+++ b/crawl-ref/source/it_use3.cc
@@ -288,13 +288,12 @@ static bool reaching_weapon_attack(const item_def& wpn)
// here to prevent scumming...but that would just encourage
// finding popcorn monsters.
mpr("You attack empty space.");
- return true;
+ return (true);
}
- /* BCR - Added a check for monsters in the way. Only checks cardinal
- * directions. Knight moves are ignored. Assume the weapon
- * slips between the squares.
- */
+ // BCR - Added a check for monsters in the way. Only checks cardinal
+ // directions. Knight moves are ignored. Assume the weapon
+ // slips between the squares.
// If we're attacking more than a space away...
if (x_distance > 1 || y_distance > 1)
@@ -302,6 +301,7 @@ static bool reaching_weapon_attack(const item_def& wpn)
const int x_middle = MAX(beam.tx, you.x_pos) - (x_distance / 2);
const int y_middle = MAX(beam.ty, you.y_pos) - (y_distance / 2);
+ bool success = false;
// If either the x or the y is the same, we should check for
// a monster:
if ((beam.tx == you.x_pos || beam.ty == you.y_pos)
@@ -312,24 +312,34 @@ static bool reaching_weapon_attack(const item_def& wpn)
if ((5 + (3 * skill)) > random2(40))
{
mpr("You reach to attack!");
- you_attack(mgrd[beam.tx][beam.ty], false);
+ success = you_attack(mgrd[beam.tx][beam.ty], false);
}
else
{
mpr("You could not reach far enough!");
- return true;
+ return (true);
}
}
else
{
mpr("You reach to attack!");
- you_attack(mgrd[beam.tx][beam.ty], false);
+ success = you_attack(mgrd[beam.tx][beam.ty], false);
+ }
+ if (success)
+ {
+ int mid = mgrd[beam.tx][beam.ty];
+ if (mid != NON_MONSTER)
+ {
+ monsters *mon = &menv[mgrd[beam.tx][beam.ty]];
+ if (mons_is_mimic( mon->type ))
+ mimic_alert(mon);
+ }
}
}
else
you_attack(mgrd[beam.tx][beam.ty], false);
- return true;
+ return (true);
} // end reaching_weapon_attack()
static bool evoke_horn_of_geryon()
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc
index 9dfeb99694..e5db0f0915 100644
--- a/crawl-ref/source/monplace.cc
+++ b/crawl-ref/source/monplace.cc
@@ -2295,7 +2295,13 @@ bool monster_pathfind::calc_path_to_neighbours()
// mprf("in calc_path_to_neighbours() for (%d,%d)", pos.x, pos.y);
coord_def npos;
int distance, old_dist, total;
- for (int dir = 0; dir < 8; dir++)
+
+ // For each point, we look at all neighbour points. Check the orthogonals
+ // last, so that, should an orthogonal and a diagonal direction have the
+ // same total travel cost, the orthogonal will be picked first, and thus
+ // zigzagging should be avoided. This means directions are looked at, in
+ // order: 1, 3, 5, 7, 0, 2, 4, 6. (dir = 0) is an intentional assignment.
+ for (int dir = 1; dir < 8; (dir += 2) == 9 && (dir = 0))
{
npos = pos + Compass[dir];
diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc
index 37f0973796..b090a1e68b 100644
--- a/crawl-ref/source/mstuff2.cc
+++ b/crawl-ref/source/mstuff2.cc
@@ -971,6 +971,7 @@ void monster_teleport(struct monsters *monster, bool instan, bool silent)
{
if (!silent)
simple_monster_message(monster, " looks slightly unstable.");
+
monster->add_ench( mon_enchant(ENCH_TP, 0, KC_OTHER,
random_range(20, 30)) );
}
@@ -1013,11 +1014,18 @@ void monster_teleport(struct monsters *monster, bool instan, bool silent)
mgrd[monster->x][monster->y] = monster_index(monster);
- /* Mimics change form/colour when t'ported */
+ // Mimics change form/colour when teleported.
if (mons_is_mimic( monster->type ))
{
+ int old_type = monster->type;
monster->type = MONS_GOLD_MIMIC + random2(5);
monster->colour = get_mimic_colour( monster );
+
+ // If it's changed form, you won't recognize it.
+ // This assumes that a non-gold mimic turning into another item of
+ // the same description is really, really unlikely.
+ if (old_type != MONS_GOLD_MIMIC || monster->type != MONS_GOLD_MIMIC)
+ was_seen = false;
}
const bool now_visible = mons_near(monster);
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index 78c753a832..43198c02c6 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -261,7 +261,9 @@ int airstrike(int power, dist &beam)
monster->name(DESC_NOCAP_THE).c_str());
behaviour_event(monster, ME_ANNOY, MHITYOU);
- }
+ if (mons_is_mimic( monster->type ))
+ mimic_alert(monster);
+ }
conduct.enabled = true;
@@ -291,7 +293,7 @@ int airstrike(int power, dist &beam)
}
return (success);
-} // end airstrike()
+}
bool cast_bone_shards(int power, bolt &beam)
{
@@ -323,7 +325,7 @@ bool cast_bone_shards(int power, bolt &beam)
}
return (success);
-} // end cast_bone_shards()
+}
void sublimation(int power)
{