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

NPCs that can not breath under water will not be generated under water

git-svn-id: http://svn.net-core.org/repos/t-engine4@2707 51575b47-30f0-44d4-a5cc-537603b46e54
parent 01fa43f2
No related branches found
No related tags found
No related merge requests found
......@@ -63,6 +63,8 @@ _M._no_save_fields.can_see_cache = true
-- Use distance maps
_M.__do_distance_map = true
_M.__is_actor = true
function _M:init(t, no_default)
-- Define some basic combat stats
self.combat_def = 0
......
......@@ -60,6 +60,15 @@ function _M:block_move(x, y, e, act, couldpass)
end
end
-- Huge hack, if we are an actor without position this means we are not yet put on the map
-- If so make sure we can only go where we can breathe
if e.__is_actor and not e.x and not e:attr("no_breath") then
local air_level, air_condition = self:check("air_level"), self:check("air_condition")
if air_level and (not air_condition or not e.can_breath[air_condition] or e.can_breath[air_condition] <= 0) then
return true
end
end
return self.does_block_move
end
......
......@@ -43,6 +43,26 @@ starty = 20
-- addSpot section
addSpot({29, 13}, "npc", "arena")
addSpot({21, 11}, "npc", "elemental")
addSpot({16, 16}, "npc", "elemental")
addSpot({12, 25}, "npc", "elemental")
addSpot({16, 32}, "npc", "elemental")
addSpot({23, 24}, "npc", "elemental")
addSpot({28, 32}, "npc", "elemental")
addSpot({26, 38}, "npc", "elemental")
addSpot({37, 30}, "npc", "elemental")
addSpot({32, 29}, "npc", "elemental")
addSpot({33, 37}, "npc", "elemental")
addSpot({33, 24}, "npc", "elemental")
addSpot({34, 15}, "npc", "elemental")
addSpot({37, 20}, "npc", "elemental")
addSpot({24, 18}, "npc", "elemental")
addSpot({28, 20}, "npc", "elemental")
addSpot({25, 13}, "npc", "elemental")
addSpot({22, 30}, "npc", "elemental")
addSpot({18, 36}, "npc", "elemental")
addSpot({12, 31}, "npc", "elemental")
addSpot({12, 31}, "npc", "elemental")
-- addZone section
......
......@@ -56,21 +56,14 @@ on_grant = function(self, who)
self.max_count = 0
for i = 1, 12 do
local m = game.zone:makeEntity(game.level, "actor", {special_rarity="derth_rarity"}, nil, true)
if m then
local x, y = rng.range(10, game.level.map.w - 11), rng.range(10, game.level.map.h - 11)
local tries = 0
while not m:canMove(x, y) and tries < 100 do
x, y = rng.range(10, game.level.map.w - 11), rng.range(10, game.level.map.h - 11)
tries = tries + 1
end
if tries < 100 then
m.quest = true
m.on_die = function(self)
game.player:resolveSource():hasQuest("lightning-overload"):kill_one()
end
game.zone:addEntity(game.level, m, "actor", x, y)
self.max_count = self.max_count + 1
local spot = game.level:pickSpot{type="npc", subtype="elemental"}
if m and spot then
m.quest = true
m.on_die = function(self)
game.player:resolveSource():hasQuest("lightning-overload"):kill_one()
end
game.zone:addEntity(game.level, m, "actor", spot.x, spot.y)
self.max_count = self.max_count + 1
end
end
self.kill_count = 0
......
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