summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-24 05:05:29 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-24 05:05:29 +0000
commit87b16bb06d3f693ec3f6d727a50bdadf4df5c138 (patch)
treead3445cac5278e9fa8c422f09d88639935159894 /crawl-ref/source
parent7facfd7958a3f544d702f12310b4d5f40563641b (diff)
downloadcrawl-ref-87b16bb06d3f693ec3f6d727a50bdadf4df5c138.tar.gz
crawl-ref-87b16bb06d3f693ec3f6d727a50bdadf4df5c138.zip
For items that originate in a portal vault, store the string describing
their origin place in "portal_vault_origin" in the item's prop hash table, so that (for example) an item bought in a bazaar will display its origin as "in a bazaar" after exiting the bazaar, instead of "in a Portal Vault". The string can be made different than the default with the "dstorigin" property of the entrance portal marker, or via the lua function dgn.set_level_type_origin(). Ziggurat items now say "on level X of a ziggurat", and sewer items "in the sewers", with other portal vaults using the default. Breaks savefile compatibilty. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7577 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/dat/clua/ziggurat.lua4
-rw-r--r--crawl-ref/source/dat/sewer.des4
-rw-r--r--crawl-ref/source/externs.h5
-rw-r--r--crawl-ref/source/items.cc20
-rw-r--r--crawl-ref/source/luadgn.cc20
-rw-r--r--crawl-ref/source/misc.cc40
-rw-r--r--crawl-ref/source/tags.cc6
7 files changed, 96 insertions, 3 deletions
diff --git a/crawl-ref/source/dat/clua/ziggurat.lua b/crawl-ref/source/dat/clua/ziggurat.lua
index 29aa01d6fc..9f313bf65d 100644
--- a/crawl-ref/source/dat/clua/ziggurat.lua
+++ b/crawl-ref/source/dat/clua/ziggurat.lua
@@ -45,6 +45,7 @@ end
function zig_depth_increment()
zig().depth = zig().depth + 1
zig().level = { }
+ dgn.set_level_type_origin("on level " .. zig().depth .. " of a ziggurat")
end
-- Returns the current depth in the ziggurat.
@@ -58,6 +59,7 @@ function ziggurat_portal(e)
return one_way_stair {
desc = "gateway to a ziggurat",
dst = "ziggurat",
+ dstorigin = "on level 1 of a ziggurat",
floor = "stone_arch",
onclimb = ziggurat_initializer
}
@@ -373,4 +375,4 @@ end
function ziggurat_choose_builder()
return util.random_from(ziggurat_builders)
-end \ No newline at end of file
+end
diff --git a/crawl-ref/source/dat/sewer.des b/crawl-ref/source/dat/sewer.des
index b6def7e5a3..82a5c0f4ae 100644
--- a/crawl-ref/source/dat/sewer.des
+++ b/crawl-ref/source/dat/sewer.des
@@ -16,7 +16,9 @@
{{
function sewer_portal(e)
e.marker([[O = lua:one_way_stair { desc = "A glowing drain",
- dst = "sewer", floor = "stone_arch" }]])
+ dst = "sewer",
+ dstorigin = "in the sewers",
+ floor = "stone_arch" }]])
e.kfeat("O = enter_portal_vault")
e.colour("O = lightgreen")
end
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 6419609046..6c75be735d 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -741,6 +741,11 @@ public:
// if not explicitly set by the entry portal.
std::string level_type_name;
+ // Item origin string for items from portal vaults, so that dumps
+ // can have origins like "You found it in on level 2 of a ziggurat".
+ // Will be set relative to level_type_name if not explicitly set.
+ std::string level_type_origin;
+
// .des file tag for portal vault
std::string level_type_tag;
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index fc10c34971..8d5b6a9d4a 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -68,6 +68,8 @@
#include "view.h"
#include "xom.h"
+#define PORTAL_VAULT_ORIGIN_KEY "portal_vault_origin"
+
static bool _invisible_to_player( const item_def& item );
static void _autoinscribe_item( item_def& item );
static void _autoinscribe_floor_items();
@@ -874,6 +876,14 @@ void origin_set_startequip(item_def &item)
}
}
+void _origin_set_portal_vault(item_def &item)
+{
+ if (you.level_type != LEVEL_PORTAL_VAULT)
+ return;
+
+ item.props[PORTAL_VAULT_ORIGIN_KEY] = you.level_type_origin;
+}
+
void origin_set_monster(item_def &item, const monsters *monster)
{
if (!origin_known(item))
@@ -881,6 +891,7 @@ void origin_set_monster(item_def &item, const monsters *monster)
if (!item.orig_monnum)
item.orig_monnum = monster->type + 1;
item.orig_place = get_packed_place();
+ _origin_set_portal_vault(item);
}
}
@@ -888,6 +899,7 @@ void origin_purchased(item_def &item)
{
// We don't need to check origin_known if it's a shop purchase
item.orig_place = get_packed_place();
+ _origin_set_portal_vault(item);
// Hackiness
item.orig_monnum = -1;
}
@@ -896,6 +908,7 @@ void origin_acquired(item_def &item, int agent)
{
// We don't need to check origin_known if it's a divine gift
item.orig_place = get_packed_place();
+ _origin_set_portal_vault(item);
// Hackiness
item.orig_monnum = -2 - agent;
}
@@ -990,6 +1003,7 @@ static void _origin_freeze(item_def &item, const coord_def& where)
origin_set_monstercorpse(item, where);
item.orig_place = get_packed_place();
+ _origin_set_portal_vault(item);
_check_note_item(item);
#ifdef DGL_MILESTONES
@@ -1010,6 +1024,12 @@ std::string origin_monster_name(const item_def &item)
static std::string _origin_place_desc(const item_def &item)
{
+ if (place_type(item.orig_place) == LEVEL_PORTAL_VAULT
+ && item.props.exists(PORTAL_VAULT_ORIGIN_KEY))
+ {
+ return item.props[PORTAL_VAULT_ORIGIN_KEY].get_string();
+ }
+
return prep_branch_level_name(item.orig_place);
}
diff --git a/crawl-ref/source/luadgn.cc b/crawl-ref/source/luadgn.cc
index 7a0d1bddfc..483164951d 100644
--- a/crawl-ref/source/luadgn.cc
+++ b/crawl-ref/source/luadgn.cc
@@ -2203,6 +2203,25 @@ LUAFN(dgn_level_id)
return (1);
}
+LUAFN(dgn_set_level_type_origin)
+{
+ if (you.level_type != LEVEL_PORTAL_VAULT)
+ {
+ luaL_error(ls, "Can only set level type origin on portal vaults");
+ return(0);
+ }
+
+ if (!lua_isstring(ls, 1))
+ {
+ luaL_argerror(ls, 1, "Expected string for level type origin");
+ return(0);
+ }
+
+ you.level_type_origin = luaL_checkstring(ls, 1);
+
+ return(0);
+}
+
static inline bool _lua_boolean(lua_State *ls, int ndx, bool defval)
{
return lua_isnone(ls, ndx)? defval : lua_toboolean(ls, ndx);
@@ -2371,6 +2390,7 @@ static const struct luaL_reg dgn_lib[] =
{ "br_parent_branch", dgn_br_parent_branch },
{ "level_id", dgn_level_id },
+ { "set_level_type_origin", dgn_set_level_type_origin },
{ "map_by_tag", dgn_map_by_tag },
{ "map_in_depth", dgn_map_in_depth },
{ "map_by_place", dgn_map_by_place },
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index c5cbf044fc..a5f5cc577b 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -1359,9 +1359,18 @@ static void leaving_level_now()
std::string newname =
env.markers.property_at(you.pos(), MAT_ANY, "dstname");
+ std::string neworigin =
+ env.markers.property_at(you.pos(), MAT_ANY, "dstorigin");
+
+ you.level_type_origin = "";
+
dungeon_events.fire_position_event(DET_PLAYER_CLIMBS, you.pos());
dungeon_events.fire_event(DET_LEAVING_LEVEL);
+ // Lua scripts explicitly set level_type_origin, so use that.
+ if (!you.level_type_origin.empty())
+ neworigin = you.level_type_origin;
+
// Don't clobber level_type_name for stairs in portal vaults.
if (you.level_type_name.empty() || !newname.empty()
|| you.level_type != LEVEL_PORTAL_VAULT)
@@ -1377,6 +1386,37 @@ static void leaving_level_now()
if (!you.level_type_tag.empty() && you.level_type_name.empty())
you.level_type_name = you.level_type_tag;
+
+ if (!neworigin.empty())
+ you.level_type_origin = neworigin;
+ else if (!you.level_type_name.empty())
+ {
+ std::string lname = lowercase_string(you.level_type_name);
+ std::string article, prep;
+
+ if (starts_with(lname, "level "))
+ prep = "on ";
+ else
+ prep = "in ";
+
+ if (starts_with(lname, "a ") || starts_with(lname, "an ")
+ || starts_with(lname, "the ") || starts_with(lname, "level "))
+ {
+ ; // Doesn't need an article
+ }
+ else
+ {
+ char letter = you.level_type_name[0];
+ if (isupper(letter))
+ article = "the ";
+ else if (is_vowel(letter))
+ article = "an ";
+ else
+ article = "a ";
+ }
+
+ you.level_type_origin = prep + article + you.level_type_name;
+ }
}
static void set_entry_cause(entry_cause_type default_cause,
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index a03e3f1d98..34f510109b 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -852,6 +852,7 @@ static void tag_construct_you(writer &th)
marshallLong(th, you.sage_bonus_degree);
marshallByte(th, you.level_type);
marshallString(th, you.level_type_name);
+ marshallString(th, you.level_type_origin);
marshallString(th, you.level_type_tag);
marshallByte(th, you.entry_cause);
marshallByte(th, you.entry_cause_god);
@@ -1249,7 +1250,10 @@ static void tag_read_you(reader &th, char minorVersion)
you.level_type_name = unmarshallString(th);
if (minorVersion >= TAG_MINOR_LUADGN)
- you.level_type_tag = unmarshallString(th);
+ {
+ you.level_type_origin = unmarshallString(th);
+ you.level_type_tag = unmarshallString(th);
+ }
you.entry_cause = static_cast<entry_cause_type>( unmarshallByte(th) );
you.entry_cause_god = static_cast<god_type>( unmarshallByte(th) );