Skip to content
Snippets Groups Projects
Commit ec5940b4 authored by dg's avatar dg
Browse files

plop

git-svn-id: http://svn.net-core.org/repos/t-engine4@1747 51575b47-30f0-44d4-a5cc-537603b46e54
parent 8ba49012
No related branches found
No related tags found
No related merge requests found
......@@ -86,6 +86,10 @@ function _M:calc(sx, sy, tx, ty, use_has_seen, heuristic)
local cache = self.map._fovcache.path_caches[self.actor:getPathString()]
local checkPos
if cache then
if not (self.map:isBound(tx, ty) and ((use_has_seen and not self.map.has_seens(tx, ty)) or not cache:get(tx, ty))) then
print("Astar fail: destination unreachable")
return nil
end
checkPos = function(node, nx, ny)
local nnode = self:toSingle(nx, ny)
if not closed[nnode] and self.map:isBound(nx, ny) and ((use_has_seen and not self.map.has_seens(nx, ny)) or not cache:get(nx, ny)) then
......@@ -104,6 +108,10 @@ function _M:calc(sx, sy, tx, ty, use_has_seen, heuristic)
end
end
else
if not (self.map:isBound(tx, ty) and ((use_has_seen and not self.map.has_seens(tx, ty)) or not self.map:checkEntity(tx, ty, Map.TERRAIN, "block_move", self.actor, nil, true))) then
print("Astar fail: destination unreachable")
return nil
end
checkPos = function(node, nx, ny)
local nnode = self:toSingle(nx, ny)
if not closed[nnode] and self.map:isBound(nx, ny) and ((use_has_seen and not self.map.has_seens(nx, ny)) or not self.map:checkEntity(nx, ny, Map.TERRAIN, "block_move", self.actor, nil, true)) then
......
......@@ -63,13 +63,13 @@ newAI("move_world_patrol", function(self)
self.ai_state.route = game.level:pickSpot{type="patrol", subtype=self.ai_state.route_kind}
local a = Astar.new(game.level.map, self)
self.ai_state.route_path = a:calc(self.x, self.y, self.ai_state.route.x, self.ai_state.route.y)
-- print(self.name, "Selecting route!", self.ai_state.route_path, "from", self.x, self.y, "to", self.ai_state.route.x, self.ai_state.route.y)
print(self.name, "Selecting route!", self.ai_state.route_path, "from", self.x, self.y, "to", self.ai_state.route.x, self.ai_state.route.y)
else
local path = self.ai_state.route_path
-- print("Using route", self.ai_state.route_path)
print("Using route", self.ai_state.route_path)
if not path or not path[1] or (path[1] and math.floor(core.fov.distance(self.x, self.y, path[1].x, path[1].y)) > 1) then
self.ai_state.route_path = nil self.ai_state.route = nil
-- print("Nulling!", path, path and path[1], path and path[1] and math.floor(core.fov.distance(self.x, self.y, path[1].x, path[1].y)))
print("Nulling!", path, path and path[1], path and path[1] and math.floor(core.fov.distance(self.x, self.y, path[1].x, path[1].y)))
return true
else
local ret = self:move(path[1].x, path[1].y)
......
......@@ -23,13 +23,12 @@ require "engine.Entity"
module(..., package.seeall, class.inherit(engine.Entity))
function _M:init(t, no_default)
assert(t.coords, "no encounter coords")
assert(t.level_range, "no encounter level_range")
assert(t.on_encounter, "no encounter on_encounter")
engine.Entity.init(self, t, no_default)
self:parseCoords()
if self.coords then self:parseCoords() end
end
function _M:parseCoords()
......@@ -59,9 +58,13 @@ end
function _M:checkFilter(filter)
if self.special_filter and not self.special_filter(self) then return false end
if filter.mapx and filter.mapy then
if filter.mapx and filter.mapy and self.on_map then
if not self.on_map[filter.mapx.."x"..filter.mapy] then return false end
end
if filter.mapx and filter.mapy and self.on_world_encounter then
local we = game.level.map.attrs(filter.mapx, filter.mapy, "world-encounter")
if not we or not we[self.on_world_encounter] then return false end
end
return true
end
......
......@@ -21,20 +21,8 @@ newEntity{
name = "Novice mage",
type = "harmless", subtype = "special", unique = true,
level_range = {1, 10},
rarity = 3,
coords = {{ x=10, y=18, likelymap={
[[ 11111111 ]],
[[ 1111111111111 ]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[ 1111111111111 ]],
[[ 111111111 ]],
}}},
rarity = 1,
on_world_encounter = "angolwen",
-- Spawn the novice mage near the player
on_encounter = function(self, who)
local x, y = self:findSpot(who)
......@@ -130,7 +118,6 @@ newEntity{
type = "harmless", subtype = "special", unique = true,
level_range = {30, 40},
rarity = 8,
coords = {{ x=0, y=0, w=100, h=100}},
on_encounter = function(self, who)
local x, y = self:findSpot(who)
if not x then return end
......@@ -154,27 +141,7 @@ newEntity{
type = "harmless", subtype = "special", unique = true,
level_range = {5, 15},
rarity = 8,
coords = {{ x=61, y=15, likelymap={
[[ 11111111 ]],
[[ 1111111111111 ]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[111111111111111]],
[[ 1111111111111 ]],
[[ 111111111 ]],
}}},
on_world_encounter = "lumberjack-cursed",
on_encounter = function(self, who)
local Chat = require "engine.Chat"
local chat = Chat.new("lumberjack-quest", {name="Half-dead lumberjack"}, who)
......@@ -188,7 +155,6 @@ newEntity{
type = "harmless", subtype = "special", unique = true,
level_range = {15, 25},
rarity = 7,
coords = {{ x=0, y=0, w=100, h=100}},
special_filter = function(self)
local p = game.player
if p.level < 15 then return false end
......
......@@ -148,6 +148,8 @@ addZone({7, 54, 75, 86}, "zonename", "Tar'Eyal")
addZone({11, 51, 21, 54}, "zonename", "Tar'Eyal")
addZone({64, 52, 66, 53}, "zonename", "Tar'Eyal")
addZone({11, 87, 16, 94}, "zonename", "Tar'Eyal")
addZone({54, 23, 65, 37}, "world-encounter", "lumberjack-cursed")
addZone({3, 15, 19, 33}, "world-encounter", "angolwen")
-- ASCII map section
return {
......
......@@ -75,7 +75,7 @@ if zone == "Maj'Eyal" then
-- Spawn some hostiles
if wda.cur_hostiles < 4 and rng.percent(5) then
local e = game.zone:makeEntity(game.level, "maj_eyal_encounters_npcs", {type="hostile", subtype="maj eyal"}, nil, true)
local e = game.zone:makeEntity(game.level, "maj_eyal_encounters_npcs", {type="hostile"}, nil, true)
if e then
local spot = game.level:pickSpot{type="hostile", subtype="maj-eyal"}
if spot and not game.level.map(spot.x, spot.y, Map.ACTOR) and not game.level.map.seens(spot.x, spot.y) then
......@@ -142,7 +142,7 @@ elseif zone == "Far East" then
-- Spawn some hostiles
if wda.cur_hostiles < 4 and rng.percent(5) then
local e = game.zone:makeEntity(game.level, "fareast_encounters_npcs", {type="hostile", subtype="fareast"}, nil, true)
local e = game.zone:makeEntity(game.level, "fareast_encounters_npcs", {type="hostile"}, nil, true)
if e then
local spot = game.level:pickSpot{type="hostile", subtype="fareast"}
if spot and not game.level.map(spot.x, spot.y, Map.ACTOR) and not game.level.map.seens(spot.x, spot.y) then
......
......@@ -24,12 +24,12 @@ return {
level_range = {1, 1},
max_level = 1,
width = 170, height = 100,
all_remembered = true,
all_lited = true,
-- all_remembered = true,
-- all_lited = true,
persistant = "memory",
ambiant_music = "Remembrance.ogg",
wilderness = true,
-- wilderness_see_radius = 4,
wilderness_see_radius = 4,
generator = {
map = {
class = "engine.generator.map.Static",
......@@ -42,6 +42,11 @@ return {
for x = z.x1, z.x2 do for y = z.y1, z.y2 do
game.level.map.attrs(x, y, "zonename", z.subtype)
end end
elseif z.type == "world-encounter" then
for x = z.x1, z.x2 do for y = z.y1, z.y2 do
if not game.level.map.attrs(x, y, "world-encounter") then game.level.map.attrs(x, y, "world-encounter", {}) end
game.level.map.attrs(x, y, "world-encounter")[z.subtype] = true
end end
end
end
......
......@@ -518,4 +518,18 @@
</properties>
</object>
</objectgroup>
<objectgroup name="addZone" width="170" height="100">
<object name="Lumjberjack quest" x="1759" y="741" width="348" height="469">
<properties>
<property name="subtype" value="&quot;lumberjack-cursed&quot;"/>
<property name="type" value="&quot;world-encounter&quot;"/>
</properties>
</object>
<object name="Angolwen quest" x="123" y="485" width="510" height="597">
<properties>
<property name="subtype" value="&quot;angolwen&quot;"/>
<property name="type" value="&quot;world-encounter&quot;"/>
</properties>
</object>
</objectgroup>
</map>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment