diff options
-rw-r--r-- | crawl-ref/source/dat/bazaar.des | 2 | ||||
-rw-r--r-- | crawl-ref/source/dat/clua/lm_tmsg.lua | 60 | ||||
-rw-r--r-- | crawl-ref/source/dat/clua/util.lua | 10 | ||||
-rw-r--r-- | crawl-ref/source/dat/lab.des | 2 | ||||
-rw-r--r-- | crawl-ref/source/hiscores.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/ouch.h | 1 |
6 files changed, 62 insertions, 15 deletions
diff --git a/crawl-ref/source/dat/bazaar.des b/crawl-ref/source/dat/bazaar.des index a2a5ca73b5..e063de01f6 100644 --- a/crawl-ref/source/dat/bazaar.des +++ b/crawl-ref/source/dat/bazaar.des @@ -19,7 +19,7 @@ function bazaar_portal() .. "they move on!" }, finalmsg = "You hear the last, dying notes of the bell.", verb = 'tolling', - noisemaker = 'a massive bell' + noisemaker = 'bell' } local blow = 200 + 30*(40 - you.absdepth()) + crawl.random2(200) local bhigh = blow + crawl.random2(blow) + 100 diff --git a/crawl-ref/source/dat/clua/lm_tmsg.lua b/crawl-ref/source/dat/clua/lm_tmsg.lua index 564ced9a6b..42e0246cfa 100644 --- a/crawl-ref/source/dat/clua/lm_tmsg.lua +++ b/crawl-ref/source/dat/clua/lm_tmsg.lua @@ -36,10 +36,25 @@ end function TimedMessaging:init(tmarker, cm, verbose) self.entity = tmarker.props.entity or tmarker.props.desc - if not self.ranges and not self.visible then - self.ranges = { { 5000, 'stately ' }, { 4000, '' }, - { 2500, 'brisk ' }, { 1500, 'urgent ' }, - { 0, 'frantic ' } } + if not self.ranges and not self.visible and not self.messages then + self.ranges = { + { 5000, 'stately ' }, { 4000, '' }, + { 2500, 'brisk ' }, { 1500, 'urgent ' }, + { 0, 'frantic ' } + } + end + + if not self.range_adjectives then + local function sqr(x) + return x * x + end + + self.range_adjectives = { + { sqr(30), '$F, a long way away' }, + { sqr(15), 'distant' }, + { sqr(7), '$F nearby' }, + { 0, '$F' } + } end self.check = self.check or tmarker.dur - 500 @@ -95,22 +110,49 @@ function TimedMessaging:proc_ranges(ranges, dur, fn) end end +function TimedMessaging:player_distance2(cm) + local cx, cy = cm:pos() + local x, y = you.pos() + local dx, dy = cx - x, cy - y + return dx * dx + dy * dy +end + +function TimedMessaging:choose_range_adjective(distance) + for _, dadj in ipairs(self.range_adjectives) do + if distance >= dadj[1] then + return dadj[2] + end + end +end + +function TimedMessaging:range_adjective(cm, thing) + local adj = self:choose_range_adjective(self:player_distance2(cm)) + if string.find(adj, '$F') then + return util.expand_entity(self.noisemaker, adj) + else + return crawl.article_a(#adj == 0 and self.noisemaker + or adj .. ' ' .. self.noisemaker) + end +end + function TimedMessaging:say_message(cm, dur) if dur <= 0 then - self:emit_message(cm, self.finalmsg) + self:emit_message(nil, self.finalmsg) return end + local noisemaker = self:range_adjective(cm, self.noisemaker) + self:proc_ranges(self.ranges, dur, function (chk) - self:emit_message(cm, + self:emit_message(nil, "You hear the " .. chk[2] .. self.verb - .. " of " .. self.noisemaker .. ".") + .. " of " .. noisemaker .. ".") end) self:proc_ranges(self.messages, dur, function (chk) - self:emit_message(cm, chk[2]) + self:emit_message(nil, chk[2]) end) end @@ -122,7 +164,7 @@ function TimedMessaging:event(luamark, cmarker, event) end if self:perceptible(cmarker) then - self:say_message(nil, luamark.dur) + self:say_message(cmarker, luamark.dur) end end end diff --git a/crawl-ref/source/dat/clua/util.lua b/crawl-ref/source/dat/clua/util.lua index f0c16dc537..9e4fcc6f34 100644 --- a/crawl-ref/source/dat/clua/util.lua +++ b/crawl-ref/source/dat/clua/util.lua @@ -214,9 +214,13 @@ function util.random_weighted_from(weightfn, list) end function util.expand_entity(entity, msg) - return string.gsub(msg, "$F%{(%w+)%}", - function (desc) - return crawl.grammar(entity, desc) + local msg_a = string.gsub(msg, "$F%{(%w+)%}", + function (desc) + return crawl.grammar(entity, desc) + end) + return string.gsub(msg_a, "$F", + function () + return crawl.grammar(entity, 'a') end) end diff --git a/crawl-ref/source/dat/lab.des b/crawl-ref/source/dat/lab.des index c6e08d78d5..f3b80ccd3e 100644 --- a/crawl-ref/source/dat/lab.des +++ b/crawl-ref/source/dat/lab.des @@ -24,7 +24,7 @@ DEPTH: 12-27 .. "the gate is sealed!" }, finalmsg = "You hear the last, dying ticks of the clock.", verb = 'ticking', - noisemaker = 'an ancient clock' + noisemaker = 'clock' } }} MARKER: O = lua: timed_marker { \ diff --git a/crawl-ref/source/hiscores.cc b/crawl-ref/source/hiscores.cc index 9f3576d51e..dab6d8a920 100644 --- a/crawl-ref/source/hiscores.cc +++ b/crawl-ref/source/hiscores.cc @@ -427,7 +427,7 @@ static const char *kill_method_names[] = "wild_magic", "xom", "statue", "rotting", "targeting", "spore", "tso_smiting", "petrification", "unknown", "something", "falling_down_stairs", "acid", "curare", "melting", "bleeding", - "beogh_smiting", "divine_wrath" + "beogh_smiting", "divine_wrath", "bounce", "reflect" }; const char *kill_method_name(kill_method_type kmt) diff --git a/crawl-ref/source/ouch.h b/crawl-ref/source/ouch.h index a1addae560..a61101902d 100644 --- a/crawl-ref/source/ouch.h +++ b/crawl-ref/source/ouch.h @@ -15,6 +15,7 @@ #include "enum.h" +// Keep in sync with names in hiscores.cc. enum kill_method_type { KILLED_BY_MONSTER, // 0 |