summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/acr.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-13 13:50:13 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-13 13:50:13 +0000
commit6b3f400a54d573521f844f34ad8a8b223c57c968 (patch)
tree2e916ac4de6cabc5b52ab5dcc2e426a2a65ecd7d /crawl-ref/source/acr.cc
parent884fcefad29a596466ac963ab0aedfc902185960 (diff)
downloadcrawl-ref-6b3f400a54d573521f844f34ad8a8b223c57c968.tar.gz
crawl-ref-6b3f400a54d573521f844f34ad8a8b223c57c968.zip
Implementing merfolk monsters. There are two types, merfolk fighters,
and mermaids. The latter are more interesting. ;) Whenever a mermaid sings there's a chance you get beheld, meaning you cannot move away from the mermaid, that is cannot increase the distance between you and her. (Because of the distance pecularities this means at dist 1 you can only be NSW or E of the mermaid but not the diagonal directions.) If you manage to be beheld by several mermaids at the same time, your movements have to respect the distance to all of them. I've added a vector beheld_by that keeps track of beholding monsters and makes checking distance and updating beholding status easier. Merfolk are immune to the mermaid song. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2453 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/acr.cc')
-rw-r--r--crawl-ref/source/acr.cc46
1 files changed, 40 insertions, 6 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 636a86d41d..09f70c8742 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -648,6 +648,12 @@ static void handle_wizard_command( void )
case 'H':
you.rotting = 0;
you.duration[DUR_POISONING] = 0;
+ if (you.duration[DUR_BEHELD])
+ {
+ you.duration[DUR_BEHELD] = 0;
+ you.beheld_by.clear();
+ }
+ you.duration[DUR_CONF] = 0;
you.disease = 0;
inc_hp( 10, true );
set_hp( you.hp_max, false );
@@ -2458,6 +2464,12 @@ static void decrement_durations()
decrement_a_duration( DUR_SURE_BLADE,
"The bond with your blade fades away." );
+ if ( decrement_a_duration( DUR_BEHELD, "You break out of your daze.",
+ -1, 0, NULL, MSGCH_RECOVERY ))
+ {
+ you.beheld_by.clear();
+ }
+
dec_slow_player();
dec_haste_player();
@@ -3602,6 +3614,34 @@ static void move_player(int move_x, int move_y)
}
} // end of if you.duration[DUR_CONF]
+ const int targ_x = you.x_pos + move_x;
+ const int targ_y = you.y_pos + move_y;
+ const dungeon_feature_type targ_grid = grd[ targ_x ][ targ_y ];
+ const unsigned short targ_monst = mgrd[ targ_x ][ targ_y ];
+ const bool targ_solid = grid_is_solid(targ_grid);
+
+ // cannot move away from mermaid but you CAN fight neighbouring squares
+ if (you.duration[DUR_BEHELD] && !you.duration[DUR_CONF]
+ && (targ_monst == NON_MONSTER || mons_is_submerged(&menv[targ_monst])))
+ {
+ for (unsigned int i = 0; i < you.beheld_by.size(); i++)
+ {
+ coord_def pos = menv[you.beheld_by[i]].pos();
+ int olddist = distance(you.x_pos, you.y_pos, pos.x, pos.y);
+ int newdist = distance(you.x_pos + move_x, you.y_pos + move_y, pos.x, pos.y);
+
+ if (olddist < newdist)
+ {
+ mprf("You cannot move away from %s!",
+ (menv[you.beheld_by[i]]).name(DESC_NOCAP_THE, true).c_str());
+
+ move_x = 0;
+ move_y = 0;
+ return;
+ }
+ }
+ } // end of beholding check
+
if (you.running.check_stop_running())
{
move_x = 0;
@@ -3611,12 +3651,6 @@ static void move_player(int move_x, int move_y)
return;
}
- const int targ_x = you.x_pos + move_x;
- const int targ_y = you.y_pos + move_y;
- const dungeon_feature_type targ_grid = grd[ targ_x ][ targ_y ];
- const unsigned short targ_monst = mgrd[ targ_x ][ targ_y ];
- const bool targ_solid = grid_is_solid(targ_grid);
-
if (targ_monst != NON_MONSTER && !mons_is_submerged(&menv[targ_monst]))
{
struct monsters *mon = &menv[targ_monst];