Skip to content

Commit

Permalink
let the player swim in lava also (beware the hp cost)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellmonk committed Mar 11, 2017
1 parent e4de6d3 commit 3822202
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 38 deletions.
8 changes: 8 additions & 0 deletions crawl-ref/source/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3383,6 +3383,14 @@ static void _move_player(coord_def move)
return;
}

//You can't attack while in lava either
if (grd(you.pos()) == DNGN_LAVA
&& !player_likes_lava() && !you.airborne())
{
mpr("You cannot attack while walking through lava!");
return;
}

// Don't allow the player to freely locate invisible monsters
// with confirmation prompts.
if (!you.can_see(*targ_monst)
Expand Down
79 changes: 49 additions & 30 deletions crawl-ref/source/player.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,17 @@ bool check_moveto_trap(const coord_def& p, const string &move_verb,

static bool _check_moveto_dangerous(const coord_def& p, const string& msg)
{
if (you.can_swim() && feat_is_water(env.grid(p))
if (env.grid(p) == DNGN_LAVA && env.grid(you.pos()) != DNGN_LAVA && !player_likes_lava())
{
if(!yesno("Really immerse yourself in lava?", false, 'n'))
{
mpr("Okay, then.");
return false;
}
else return true;
}

if (you.can_swim() && feat_is_water(env.grid(p))
|| you.airborne() || !is_feat_dangerous(env.grid(p)))
{
return true;
Expand All @@ -233,8 +243,8 @@ bool check_moveto_terrain(const coord_def& p, const string &move_verb,
const string &msg, bool *prompted)
{
if (!_check_moveto_dangerous(p, msg))
return false
;
return false;
if (!need_expiration_warning() && need_expiration_warning(p)
&& !crawl_state.disables[DIS_CONFIRMATIONS])
{
Expand Down Expand Up @@ -265,6 +275,7 @@ bool check_moveto_terrain(const coord_def& p, const string &move_verb,
return false;
}
}

return true;
}

Expand Down Expand Up @@ -417,34 +428,52 @@ void moveto_location_effects(dungeon_feature_type old_feat,

if (you.ground_level())
{
if (player_likes_lava(false))

if (feat_is_lava(new_grid) && !feat_is_lava(old_feat))
{
if (feat_is_lava(new_grid) && !feat_is_lava(old_feat))
{
if (!stepped)
noisy(4, you.pos(), "Gloop!");
if (!stepped)
noisy(4, you.pos(), "Gloop!");

mprf("You %s lava.",
(stepped) ? "slowly immerse yourself in the" : "fall into the");
mprf("You %s lava.",
(stepped) ? "slowly immerse yourself in the" : "fall into the");

// Extra time if you stepped in.
if (stepped)
you.time_taken *= 2;
// Extra time if you stepped in.
if (stepped)
you.time_taken *= 2;
#if TAG_MAJOR_VERSION == 34
if (player_likes_lava(false))
{
// This gets called here because otherwise you wouldn't heat
// until your second turn in lava.
if (temperature() < TEMP_FIRE)
mpr("The lava instantly superheats you.");
you.temperature = TEMP_MAX;
#endif
}

else if (!feat_is_lava(new_grid) && feat_is_lava(old_feat))
{
mpr("You slowly pull yourself out of the lava.");
you.time_taken *= 2;
else
{
int lava_damage = div_rand_round(you.hp_max, 10) + random2(10);
mprf("The lava roasts you! (%d)", lava_damage);
ouch(lava_damage, KILLED_BY_LAVA);
}
#endif
}

else if (!feat_is_lava(new_grid) && feat_is_lava(old_feat))
{
mpr("You slowly pull yourself out of the lava.");
you.time_taken *= 2;
}

else if (feat_is_lava(new_grid) && feat_is_lava(old_feat))
{
if (stepped)
{
you.time_taken *= 2;
int lava_damage = div_rand_round(you.hp_max, 10) + random2(10);
mprf("The lava roasts you! (%d)", lava_damage);
ouch(lava_damage, KILLED_BY_LAVA);
}
}

if (feat_is_water(new_grid))
{
Expand Down Expand Up @@ -560,17 +589,7 @@ void move_player_to_grid(const coord_def& p, bool stepped)
bool is_feat_dangerous(dungeon_feature_type grid, bool permanently,
bool ignore_flight)
{
if (!ignore_flight
&& (you.permanent_flight() || you.airborne() && !permanently))
{
return false;
}
else if (grid == DNGN_LAVA && !player_likes_lava(permanently))
{
return true;
}
else
return false;
return false;
}

bool is_map_persistent()
Expand Down
7 changes: 7 additions & 0 deletions crawl-ref/source/spl-cast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,13 @@ static bool _can_cast()
mpr("You cannot cast spells while swimming in deep water!");
return false;
}

if (grd(you.pos()) == DNGN_LAVA
&& !player_likes_lava() && !you.airborne())
{
mpr("You cannot cast spells while swimming in lava!");
return false;
}

if (you.duration[DUR_NO_CAST])
{
Expand Down
8 changes: 0 additions & 8 deletions crawl-ref/source/terrain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1564,14 +1564,6 @@ void fall_into_a_pool(dungeon_feature_type terrain)
// included in default force_more_message

clear_messages();
if (terrain == DNGN_LAVA)
{
if (you.species == SP_MUMMY)
mpr("You burn to ash...");
else
mpr("The lava burns you to a cinder!");
ouch(INSTANT_DEATH, KILLED_BY_LAVA);
}
}

typedef map<string, dungeon_feature_type> feat_desc_map;
Expand Down

0 comments on commit 3822202

Please sign in to comment.