Revision 3745

Date:
2019-10-26 23:24:58
Author:
dsb
Revision Log:
Implement "Map of <town>" parchments.
Files:

Legend:

 
Added
 
Removed
 
Modified
  • tome2/trunk/class/GameState.lua

     
    134 134 self.zone_recall_depth[zone_id] = math.max(game.level.level, depth)
    135 135 end
    136 136
    137 function _M:getZoneInfo(zone_id)
    138 if self.zone_info[zone_id] then return self.zone_info[zone_id] end
    139 -- Mimics engine.Zone:getBaseName()
    140 local base, name = '/data', zone_id
    141 local _, _, addon, rname = zone_id:find("^([^+]+)%+(.+)$")
    142 if addon and rname then
    143 base = '/data-'..addon
    144 name = rname
    145 end
    146 local f, err = loadfile(base..'/zones/'..name..'/zone.lua')
    147 if f then
    148 setfenv(f, setmetatable({}, {__index=_G}))
    149 local ok, z = pcall(f)
    150 if ok then
    151 self.zone_info[zone_id] = {
    152 name = z.name,
    153 level_range = table.clone(z.level_range),
    154 }
    155 end
    156 end
    157 return self.zone_info[zone_id]
    158 end
    159
    137 160 function _M:getZoneLevelRange(zone_id)
    138 161 local range = self.zone_info[zone_id] and self.zone_info[zone_id].level_range or {1,1}
    139 162 return range[1], range[2]
  • tome2/trunk/data/general/objects/bases.lua

     
    153 153 encumber = 0.5,
    154 154 stacking = true,
    155 155 category = 'magic',
    156 use_simple = {
    157 titles = { 'Read', 'read' },
    158 use = function(self, who, inven, floor, item)
    159 if self.use_simple.town_map then
    160 game:onLevelLoad('worldmap-1', obj_util.parchment_map_town, self.use_simple.town_map)
    161 local z_inf = game.state:getZoneInfo(self.use_simple.town_map.zone)
    162 if z_inf then
    163 game.logPlayer(self, [[Based on this map, you now know where the town of %s is.]], z_inf.name)
    164 else
    165 game.logPlayer(self, [[You're not sure what town this map is showing, but you're pretty sure you can get there now.]])
    166 end
    167 elseif self.use_simple.lore then
    168 game.log('[Sorry, not implemented (lore "%s")]', self.use_simple.lore)
    169 else
    170 game.log('[Sorry, not implemented (%s)]', self:getName{no_count=true})
    171 end
    172 end,
    173 name = function(self)
    174 local desc = 'do something unspecified'
    175 if self.use.simple.town_map then
    176 desc = 'reveal the location of a town and its surrounding geography on the world map'
    177 elseif self.use_simple_lore then
    178 desc = 'learn the lore on the parchment'
    179 end
    180 return desc .. obj_util.consume_desc_suffix(self, 'parchment')
    181 end,
    182 },
    183 cant_use_if = { blind=true, confused=true, unlit=true },
    156 184 }
    157 185
    158 186 newEntity {
  • tome2/trunk/data/general/objects/parchments.lua

     
    44 44 extra = 100,
    45 45 cost = 100,
    46 46 allocation = { { level=3, rarity=3 } },
    47 -- BEGIN VERBATIM
    48 use_simple = {
    49 town_map = { zone='town-bree', radius=6 },
    50 },
    51 -- END VERBATIM
    47 52 }
    48 53
    49 54 newEntity {
     
    59 64 extra = 100,
    60 65 cost = 50000,
    61 66 allocation = { { level=70, rarity=3 } },
    67 -- BEGIN VERBATIM
    68 use_simple = {
    69 town_map = { zone='town-gondolin', radius=3 },
    70 },
    71 -- END VERBATIM
    62 72 }
    63 73
    64 74 newEntity {
     
    74 84 extra = 100,
    75 85 cost = 1000,
    76 86 allocation = { { level=6, rarity=3 } },
    87 -- BEGIN VERBATIM
    88 use_simple = {
    89 town_map = { zone='town-lothlorien', radius=4 },
    90 },
    91 -- END VERBATIM
    77 92 }
    78 93
    79 94 newEntity {
     
    89 104 extra = 100,
    90 105 cost = 10000,
    91 106 allocation = { { level=36, rarity=3 } },
    107 -- BEGIN VERBATIM
    108 use_simple = {
    109 town_map = { zone='town-minas-anor', radius=3 },
    110 },
    111 -- END VERBATIM
    92 112 }
    93 113
    94 114 newEntity {
  • tome2/trunk/obj-util.lua

     
    186 186 return any
    187 187 end
    188 188
    189 -- Utility method for parchments, to mark the area around a specified zone
    190 -- as remembered.
    191 function obj_util.parchment_map_town(zone, level, data)
    192 local function block_cb(_, x, y) return not level.map:isBound(x, y) end
    193 local function apply cb(_, x, y) level.map.remembers(x, y, true) end
    194 local txy = game.state:getWorldMapZoneCoords(data.zone)
    195 if not txy then return end
    196 core.fov.calc_circle(txy.x, txy.y, level.map.w, level.map.h, data.radius, block_cb, apply_cb, nil)
    197 end
    198
    199 -- Utility method for the use description of consumable objects.
    189 200 function obj_util.consume_desc_suffix(o, simple_name)
    190 201 local repl_name = nil
    191 202 if o.alchemy_replace_on_use and game.player:getSkillLevel('ALCHEMY') > 0 then