diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-12-25 08:14:55 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-12-25 08:14:55 +0000 |
commit | 299e58e1cac6a28bde782516f08532f6fe08aec9 (patch) | |
tree | 5a1c0c5a44c2e6c2bc511d45d656ab9b87ff0a75 | |
parent | ef9621cf23810e12b8d3f77ba8de3538d4f02fc0 (diff) | |
download | crawl-ref-299e58e1cac6a28bde782516f08532f6fe08aec9.tar.gz crawl-ref-299e58e1cac6a28bde782516f08532f6fe08aec9.zip |
Let e.set_random_mon_list() work, as well as dgn.set_random_mon_list()
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7969 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/dungeon.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/luadgn.cc | 52 | ||||
-rw-r--r-- | crawl-ref/source/mapdef.cc | 7 | ||||
-rw-r--r-- | crawl-ref/source/mapdef.h | 2 |
4 files changed, 57 insertions, 10 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index f831d7254d..c8b3e49452 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -787,6 +787,12 @@ void dgn_register_place(const vault_placement &place, bool register_vault) set_level_flags(place.map.level_flags.flags_set, true); unset_level_flags(place.map.level_flags.flags_unset, true); + if (place.map.random_mons.size() > 0) + { + ASSERT(you.level_type == LEVEL_PORTAL_VAULT); + set_vault_mon_list(place.map.random_mons); + } + if (place.map.floor_colour != BLACK) env.floor_colour = place.map.floor_colour; diff --git a/crawl-ref/source/luadgn.cc b/crawl-ref/source/luadgn.cc index e1a4685b6b..88c0be8bef 100644 --- a/crawl-ref/source/luadgn.cc +++ b/crawl-ref/source/luadgn.cc @@ -613,14 +613,48 @@ static int dgn_set_random_mon_list(lua_State *ls) return (0); } - mons_list mlist = _lua_get_mlist(ls, 1); + const int nargs = lua_gettop(ls); + + map_def *map = NULL; + if (nargs > 2) + { + luaL_error(ls, "Too many arguments."); + return (0); + } + else if (nargs == 0) + { + luaL_error(ls, "Too few arguments."); + return (0); + } + else if (nargs == 2) + { + map_def **_map( + clua_get_userdata<map_def*>(ls, MAP_METATABLE, 1)); + map = *_map; + } + + if (map) + { + if (map->orient != MAP_ENCOMPASS || map->place.is_valid() + || !map->depths.empty()) + { + luaL_error(ls, "Can only be used in portal vaults."); + return (0); + } + } + + int list_pos = (map != NULL) ? 2 : 1; + mons_list mlist = _lua_get_mlist(ls, list_pos); if (mlist.size() == 0) + { + luaL_argerror(ls, list_pos, "Mon list is empty."); return (0); + } if (mlist.size() > 1) { - luaL_argerror(ls, 1, "Mon list must contain only one slot."); + luaL_argerror(ls, list_pos, "Mon list must contain only one slot."); return (0); } @@ -628,7 +662,7 @@ static int dgn_set_random_mon_list(lua_State *ls) if (num_mons == 0) { - luaL_argerror(ls, 1, "Mon list is empty."); + luaL_argerror(ls, list_pos, "Mon list is empty."); return (0); } @@ -655,7 +689,7 @@ static int dgn_set_random_mon_list(lua_State *ls) std::string err; err = make_stringf("mon #%d: Can't use Lab or Portal as a " "monster place.", i + 1); - luaL_argerror(ls, 1, err.c_str()); + luaL_argerror(ls, list_pos, err.c_str()); return(0); } name = mon.place.describe(); @@ -667,7 +701,7 @@ static int dgn_set_random_mon_list(lua_State *ls) std::string err; err = make_stringf("mon #%d: can't use random monster in " "list specifying random monsters", i + 1); - luaL_argerror(ls, 1, err.c_str()); + luaL_argerror(ls, list_pos, err.c_str()); return(0); } if (mon.mid == -1) @@ -700,11 +734,15 @@ static int dgn_set_random_mon_list(lua_State *ls) if (mons.size() == 0 && num_lords > 0) { - luaL_argerror(ls, 1, "Mon list contains only pandemonium lords."); + luaL_argerror(ls, list_pos, + "Mon list contains only pandemonium lords."); return (0); } - set_vault_mon_list(mons); + if (map) + map->random_mons = mons; + else + set_vault_mon_list(mons); return (0); } diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc index 446583ef5c..af02c2b429 100644 --- a/crawl-ref/source/mapdef.cc +++ b/crawl-ref/source/mapdef.cc @@ -1201,9 +1201,9 @@ dlua_set_map::~dlua_set_map() map_def::map_def() : name(), tags(), place(), depths(), orient(), chance(), weight(), weight_depth_mult(), weight_depth_div(), welcome_messages(), map(), - mons(), items(), keyspecs(), prelude("dlprelude"), main("dlmain"), - validate("dlvalidate"), veto("dlveto"), rock_colour(BLACK), - floor_colour(BLACK), rock_tile(0), floor_tile(0), + mons(), items(), random_mons(), keyspecs(), prelude("dlprelude"), + main("dlmain"), validate("dlvalidate"), veto("dlveto"), + rock_colour(BLACK), floor_colour(BLACK), rock_tile(0), floor_tile(0), index_only(false), cache_offset(0L) { init(); @@ -1227,6 +1227,7 @@ void map_def::init() void map_def::reinit() { items.clear(); + random_mons.clear(); keyspecs.clear(); level_flags.clear(); branch_flags.clear(); diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h index 68d62b5851..2d43e59519 100644 --- a/crawl-ref/source/mapdef.h +++ b/crawl-ref/source/mapdef.h @@ -640,6 +640,8 @@ public: mons_list mons; item_list items; + std::vector<mons_spec> random_mons; + map_flags level_flags, branch_flags; keyed_specs keyspecs; |