From fb79a7fe552ceb199fac5ee2b63b185ed30746e5 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Mon, 13 Jul 2009 18:20:54 +0000 Subject: Add milestones for progress in ziggurats (##crawl, dpeg). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10210 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/dat/clua/util.lua | 9 +++++++++ crawl-ref/source/dat/clua/ziggurat.lua | 11 +++++++++++ crawl-ref/source/hiscores.cc | 2 ++ crawl-ref/source/luadgn.cc | 11 +++++++++++ 4 files changed, 33 insertions(+) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/dat/clua/util.lua b/crawl-ref/source/dat/clua/util.lua index fa78b189aa..4894f1fc67 100644 --- a/crawl-ref/source/dat/clua/util.lua +++ b/crawl-ref/source/dat/clua/util.lua @@ -190,6 +190,15 @@ function util.exists(list, pred) return false end +function util.contains(haystack, needle) + for _, value in ipairs(haystack) do + if value == needle then + return true + end + end + return false +end + function util.random_from(list) return list[ crawl.random2(#list) + 1 ] end diff --git a/crawl-ref/source/dat/clua/ziggurat.lua b/crawl-ref/source/dat/clua/ziggurat.lua index 0792043c49..aefb68383c 100644 --- a/crawl-ref/source/dat/clua/ziggurat.lua +++ b/crawl-ref/source/dat/clua/ziggurat.lua @@ -132,7 +132,18 @@ function ziggurat_awaken_all(mons) mons.beh = beh_wander end +function ziggurat_milestone() + local depth = zig().depth + if util.contains({ 1, 9, 15, 21, 24, 27 }, depth) then + crawl.mark_milestone(depth < 27 and "br.enter" or "br.end", + (depth == 1 and "entered a Ziggurat" or + ("reached level " .. depth .. " of a Ziggurat")) + .. ".") + end +end + function ziggurat_build_level(e) + ziggurat_milestone() if zig().depth == 1 then e.welcome("You land on top of a ziggurat so tall you cannot make out the ground.") end diff --git a/crawl-ref/source/hiscores.cc b/crawl-ref/source/hiscores.cc index 9c6a2805e9..d503d51660 100644 --- a/crawl-ref/source/hiscores.cc +++ b/crawl-ref/source/hiscores.cc @@ -2078,6 +2078,8 @@ std::string xlog_fields::xlog_line() const #ifdef DGL_MILESTONES void mark_milestone(const std::string &type, const std::string &milestone) { + if (crawl_state.arena) + return; const std::string milestone_file = Options.save_dir + "milestones.txt"; if (FILE *fp = lk_open("a", milestone_file)) { diff --git a/crawl-ref/source/luadgn.cc b/crawl-ref/source/luadgn.cc index 012b58788c..ebc9c082a7 100644 --- a/crawl-ref/source/luadgn.cc +++ b/crawl-ref/source/luadgn.cc @@ -22,6 +22,7 @@ REVISION("$Rev$"); #include "directn.h" #include "dungeon.h" #include "files.h" +#include "hiscores.h" #include "initfile.h" #include "items.h" #include "luadgn.h" @@ -3091,6 +3092,15 @@ LUAFN(_crawl_args) return dlua_stringtable(ls, SysEnv.cmd_args); } +LUAFN(_crawl_milestone) +{ +#ifdef DGL_MILESTONES + mark_milestone(luaL_checkstring(ls, 1), + luaL_checkstring(ls, 2)); +#endif + return (0); +} + #ifdef UNIX LUAFN(_crawl_millis) { @@ -3109,6 +3119,7 @@ LUAFN(_crawl_millis) static const struct luaL_reg crawl_lib[] = { { "args", _crawl_args }, + { "mark_milestone", _crawl_milestone }, #ifdef UNIX { "millis", _crawl_millis }, #endif -- cgit v1.2.3-54-g00ecf