summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-11-13 01:43:33 -0800
committerMatthew Cline <zelgadis@sourceforge.net>2009-11-13 01:44:02 -0800
commitfd7d5006068e22916ca6aed8bad49baac476e445 (patch)
tree47e9a02d59c73edf7a15827caebc5a33ff30216c
parentf436e7d24f238b1a0c08e17ece91b441b437bdc5 (diff)
downloadcrawl-ref-fd7d5006068e22916ca6aed8bad49baac476e445.tar.gz
crawl-ref-fd7d5006068e22916ca6aed8bad49baac476e445.zip
Move most Royal Jelly code to dat/lair.des
-rw-r--r--crawl-ref/source/dat/lair.des82
-rw-r--r--crawl-ref/source/misc.cc16
-rw-r--r--crawl-ref/source/mon-stuff.cc134
-rw-r--r--crawl-ref/source/mon-stuff.h2
-rw-r--r--crawl-ref/source/religion.cc10
5 files changed, 98 insertions, 146 deletions
diff --git a/crawl-ref/source/dat/lair.des b/crawl-ref/source/dat/lair.des
index 0797f57e2e..3640e02d51 100644
--- a/crawl-ref/source/dat/lair.des
+++ b/crawl-ref/source/dat/lair.des
@@ -731,6 +731,88 @@ KMASK: | = no_monster_gen
KFEAT: Z = altar_jiyva
SHUFFLE: ([{
LFLAGS: no_tele_control
+
+{{
+-- Attach function to the royal jelly itself. This will follow it wherever
+-- it goes, even through polymorphs, and set dgn.persist.royal_jelly_dead
+-- when it dies through means other than being banished.
+local function monster_die(monster, killer_type, killer_index, silent, wizard)
+ if killer_type == "reset" then
+ if monster.you_can_see then
+ crawl.mpr("You feel a great sense of loss.")
+ else
+ crawl.mpr("You feel a great sense of loss, and a brush of " ..
+ "the abyss.")
+ end
+ else
+ dgn.persist.fix_slime_vaults = true
+ end
+end
+}}
+MARKER: 1 = lua: MonPropsMarker:new {monster_dies_lua_key = monster_die}
+
+{{
+local function fixup_slime_vaults(data, triggerable, triggerer, marker, ev)
+ if not dgn.persist.fix_slime_vaults then
+ return
+ end
+
+ -- Restore teleport control.
+ dgn.change_level_flags("!no_tele_control")
+
+ local to_feat
+ if you.god() == "Jiyva" then
+ to_feat = "floor"
+ else
+ to_feat = "clear_rock_wall"
+ end
+
+ local seen = dgn.seen_replace_feat("stone_wall", to_feat)
+ seen = dgn.seen_replace_feat("clear_stone_wall", to_feat) or seen
+
+ if you.god() == "Jiyva" then
+ if you.silenced() then
+ crawl.mpr("An unexplained breeze blows through the dungeon.", "god")
+ else
+ crawl.mpr("You hear the sound of toppling stones.", "god")
+ end
+ else
+ if seen then
+ crawl.mpr("Suddenly, all colour oozes out of the stone walls.",
+ "monster_enchant")
+ else
+ crawl.mpr("You feel a strange vibration for a moment.",
+ "monster_enchant")
+ end
+ end
+
+ -- We're done.
+ dgn.persist.slime_fixup_done = true
+
+ triggerable:remove(marker)
+end
+
+local fixup_marker = TriggerableFunction:new(
+ {
+ func=fixup_slime_vaults,
+ repeated=true
+ }
+)
+
+fixup_marker:add_triggerer(DgnTriggerer:new {
+ type="monster_dies",
+ target="any"
+})
+
+fixup_marker:add_triggerer(DgnTriggerer:new {
+ type="entered_level"
+})
+
+}}
+# Doesn't matter where thisw marker goes, so we might as well chose
+# the altar.
+: lua_marker("Z", fixup_marker)
+
{{
dgn.set_feature_desc_short("stone wall", "rune carved stone wall")
dgn.set_feature_desc_long("stone wall",
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index 944cf6aa98..4833122691 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -42,7 +42,6 @@
#include "directn.h"
#include "dgnevent.h"
#include "directn.h"
-#include "dungeon.h"
#include "fprop.h"
#include "fight.h"
#include "files.h"
@@ -2586,21 +2585,6 @@ void down_stairs( int old_level, dungeon_feature_type force_stair,
new_level();
- static int times_entered = 0;
-
- if (level_id::current() == level_id(BRANCH_SLIME_PITS, 6))
- {
- if (times_entered == 0)
- {
- if (you.religion == GOD_JIYVA)
- slime_vault_change(false);
- else if (jiyva_is_dead())
- slime_vault_change(true);
- }
-
- times_entered++;
- }
-
// Clear list of beholding monsters.
you.clear_beholders();
diff --git a/crawl-ref/source/mon-stuff.cc b/crawl-ref/source/mon-stuff.cc
index 4d5dc0bbc3..bdd286c9c3 100644
--- a/crawl-ref/source/mon-stuff.cc
+++ b/crawl-ref/source/mon-stuff.cc
@@ -824,56 +824,16 @@ static bool _monster_avoided_death(monsters *monster, killer_type killer, int i)
return (false);
}
-static bool _slime_vault_in_los()
+static void _jiyva_died()
{
- bool in_los = false;
-
- for (int x = 0; x < GXM && !in_los; ++x)
- {
- for (int y = 0; y < GYM; ++y)
- {
- if ((grd[x][y] == DNGN_STONE_WALL
- || grd[x][y] == DNGN_CLEAR_STONE_WALL)
- && observe_cell(coord_def(x, y)))
- {
- in_los = true;
- break;
- }
- }
- }
-
- return (in_los);
-}
-
-static bool _slime_vault_to_glass(bool silent)
-{
- unset_level_flags(LFLAG_NO_TELE_CONTROL, silent);
-
- bool in_los = false;
-
- if (!silent)
- in_los = _slime_vault_in_los();
-
- replace_area_wrapper(DNGN_STONE_WALL, DNGN_CLEAR_ROCK_WALL);
- // In case it was already vitrified, but then it's less noticeable.
- replace_area_wrapper(DNGN_CLEAR_STONE_WALL, DNGN_CLEAR_ROCK_WALL);
-
- if (!silent)
- {
- if (in_los)
- {
- mpr("Suddenly, all colour oozes out of the stone walls.",
- MSGCH_MONSTER_ENCHANT);
- }
- else
- {
- mpr("You feel a strange vibration for a moment.",
- MSGCH_MONSTER_ENCHANT);
- }
- }
+ if (you.religion == GOD_JIYVA)
+ return;
remove_all_jiyva_altars();
+ if (!player_in_branch(BRANCH_SLIME_PITS))
+ return;
+
if (silenced(you.pos()))
{
god_speaks(GOD_JIYVA, "With an infernal shudder, the power ruling "
@@ -884,71 +844,6 @@ static bool _slime_vault_to_glass(bool silent)
god_speaks(GOD_JIYVA, "With infernal noise, the power ruling this "
"place vanishes!");
}
-
- return (true);
-}
-
-static bool _slime_vault_to_glass_offlevel()
-{
- return _slime_vault_to_glass(true);
-}
-
-static bool _slime_vault_to_glass_onlevel()
-{
- return _slime_vault_to_glass(false);
-}
-
-static bool _slime_vault_to_floor(bool silent)
-{
- unset_level_flags(LFLAG_NO_TELE_CONTROL, silent);
-
- bool in_los = false;
-
- if (!silent)
- in_los = _slime_vault_in_los();
-
- replace_area_wrapper(DNGN_STONE_WALL, DNGN_FLOOR);
- // In case it was already vitrified, but then it's less noticeable.
- replace_area_wrapper(DNGN_CLEAR_STONE_WALL, DNGN_FLOOR);
-
- if (silenced(you.pos()))
- mpr("An unexplained breeze blows through the dungeon.", MSGCH_GOD);
- else
- mpr("You hear the sound of toppling stones.", MSGCH_GOD);
-
- return (true);
-}
-
-static bool _slime_vault_to_floor_offlevel()
-{
- return _slime_vault_to_floor(true);
-}
-
-static bool _slime_vault_to_floor_onlevel()
-{
- return _slime_vault_to_floor(false);
-}
-
-void slime_vault_change(bool glass)
-{
- const level_id target(BRANCH_SLIME_PITS, 6);
- if (is_existing_level(target))
- {
- if (glass)
- {
- apply_to_level(target,
- target == level_id::current() ?
- _slime_vault_to_glass_onlevel :
- _slime_vault_to_glass_offlevel);
- }
- else
- {
- apply_to_level(target,
- target == level_id::current() ?
- _slime_vault_to_floor_onlevel :
- _slime_vault_to_floor_offlevel);
- }
- }
}
static void _fire_monster_death_event(monsters *monster,
@@ -970,33 +865,18 @@ static void _fire_monster_death_event(monsters *monster,
// Banished monsters aren't technically dead, so no death event
// for them.
if (killer == KILL_RESET)
- {
- // Give player a hint that banishing the Royal Jelly means the
- // Slime:6 vaults stay locked.
- if (type == MONS_ROYAL_JELLY)
- {
- if (you.can_see(monster))
- mpr("You feel a great sense of loss.");
- else
- mpr("You feel a great sense of loss, and the brush of the "
- "Abyss.");
- }
return;
- }
dungeon_events.fire_event(
dgn_event(DET_MONSTER_DIED, monster->pos(), 0,
monster_index(monster), killer));
- // Don't unlock the Slime:6 vaults if the "death" was actually the
- // Royal Jelly polymorphing into something else; the player still
- // has to kill whatever it polymorphed into.
if (type == MONS_ROYAL_JELLY && !polymorph)
{
you.royal_jelly_dead = true;
if (jiyva_is_dead())
- slime_vault_change(true);
+ _jiyva_died();
}
}
diff --git a/crawl-ref/source/mon-stuff.h b/crawl-ref/source/mon-stuff.h
index 4f1bb73a78..525cb666e0 100644
--- a/crawl-ref/source/mon-stuff.h
+++ b/crawl-ref/source/mon-stuff.h
@@ -87,8 +87,6 @@ bool explode_corpse(item_def& corpse, const coord_def& where);
int place_monster_corpse(const monsters *monster, bool silent,
bool force = false);
-void slime_vault_change(bool glass);
-
void slimify_monster(monsters *monster, bool hostile = false);
bool mon_can_be_slimified(monsters *monster);
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 76a4c5af79..f29e38152e 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -32,6 +32,7 @@
#include "decks.h"
#include "delay.h"
#include "describe.h"
+#include "dgnevent.h"
#include "effects.h"
#include "enum.h"
#include "fprop.h"
@@ -5047,7 +5048,14 @@ void god_pitch(god_type which_god)
if (you.religion == GOD_JIYVA)
{
if (you.worshipped[GOD_JIYVA] == 1)
- slime_vault_change(false);
+ {
+ dlua.callfn("dgn_set_persistent_var", "sb",
+ "fix_slime_vaults", true);
+ // If we're on Slime:6, pretend we just entered the level
+ // in order to bring down the vault walls.
+ if (level_id::current() == level_id(BRANCH_SLIME_PITS, 6))
+ dungeon_events.fire_event(DET_ENTERED_LEVEL);
+ }
if (!_has_jelly())
{