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

plop

git-svn-id: http://svn.net-core.org/repos/t-engine4@1687 51575b47-30f0-44d4-a5cc-537603b46e54
parent 05b63d8c
No related branches found
No related tags found
No related merge requests found
......@@ -100,3 +100,64 @@ function _M:worldDirectorAI()
local ok, err = pcall(script)
if not ok and err then error(err) end
end
function _M:spawnWorldAmbush(enc)
local gen = { class = "engine.generator.map.Forest",
edge_entrances = {4,6},
sqrt_percent = 50,
zoom = 10,
floor = "GRASS",
wall = "TREE",
down = "DOWN",
up = "UP_WILDERNESS",
}
local g = game.level.map(game.player.x, game.player.y, engine.Map.TERRAIN)
if not g.can_encounter then return false end
if g.can_encounter == "desert" then gen.floor = "SAND" gen.wall = "PALMTREE" end
local zone = engine.Zone.new("ambush", {
name = "Ambush!",
level_range = {game.player.level, game.player.level},
level_scheme = "player",
max_level = 1,
actor_adjust_level = function(zone, level, e) return zone.base_level + e:getRankLevelAdjust() + level.level-1 + rng.range(-1,2) end,
width = enc.width or 20, height = enc.height or 20,
all_lited = true,
ambiant_music = "last",
generator = {
map = gen,
actor = { class = "engine.generator.actor.Random", nb_npc = enc.nb or {1,1}, filters=enc.filters },
},
npc_list = mod.class.NPC:loadList("/data/general/npcs/all.lua", nil, nil, function(e) e.make_escort=nil end),
grid_list = mod.class.Grid:loadList{"/data/general/grids/basic.lua", "/data/general/grids/forest.lua", "/data/general/grids/sand.lua"},
object_list = mod.class.Object:loadList("/data/general/objects/objects.lua"),
trap_list = {},
post_process = function(level)
-- Find a good starting location, on the opposite side of the exit
local sx, sy = level.map.w-1, rng.range(0, level.map.h-1)
level.spots[#level.spots+1] = {
check_connectivity = "entrance",
x = sx,
y = sy,
}
level.default_down = level.default_up
level.default_up = {x=sx, y=sy}
end,
})
game.player:runStop()
game.player.energy.value = game.energy_to_act
game.paused = true
game:changeLevel(1, zone)
engine.ui.Dialog:simplePopup("Ambush!", "You have been ambushed!")
end
function _M:handleWorldEncounter(target)
local enc = target.on_encounter
if type(enc) == "function" then return enc() end
if type(enc) == "table" then
if enc.type == "ambush" then target:die() self:spawnWorldAmbush(enc)
end
end
end
......@@ -121,8 +121,10 @@ function _M:onLeaveLevel(zone, level)
end
-- Wilderness encounter
function _M:onWorldEncounter(self)
print("PLAYER ENCOUNTER")
function _M:onWorldEncounter(target)
if target.on_encounter then
game.state:handleWorldEncounter(target)
end
end
function _M:move(x, y, force)
......
......@@ -53,6 +53,10 @@ function _M:bumpInto(target)
end
end
function _M:takeHit()
return nil
end
function _M:encounterAttack(target)
if target.player then target:onWorldEncounter(self) return end
......
......@@ -52,6 +52,7 @@ newEntity{
rarity = 4,
unit_power = 1,
ai = "world_hostile", ai_state = {chase_distance=3},
on_encounter = {type="ambush", width=10, height=10, nb={1,1}, filters={{type="animal", subtype="bear"}}},
}
newEntity{
......@@ -63,57 +64,5 @@ newEntity{
rarity = 4,
unit_power = 1,
ai = "world_hostile", ai_state = {chase_distance=3},
on_encounter = function()
local gen = { class = "engine.generator.map.Forest",
edge_entrances = {4,6},
sqrt_percent = 50,
zoom = 10,
floor = "GRASS",
wall = "TREE",
up = "UP",
down = "DOWN",
up = "UP_WILDERNESS_FAR_EAST",
}
local g = game.level.map(who.x, who.y, engine.Map.TERRAIN)
if not g.can_encounter then return false end
if g.can_encounter == "desert" then gen.floor = "SAND" gen.wall = "PALMTREE" end
local zone = engine.Zone.new("ambush", {
name = "Ambush!",
level_range = {20, 50},
level_scheme = "player",
max_level = 1,
actor_adjust_level = function(zone, level, e) return zone.base_level + e:getRankLevelAdjust() + level.level-1 + rng.range(-1,2) end,
width = 20, height = 20,
all_lited = true,
ambiant_music = "last",
generator = {
map = gen,
actor = { class = "engine.generator.actor.Random",nb_npc = {5, 7}, },
trap = { class = "engine.generator.trap.Random", nb_trap = {0, 0}, },
},
npc_list = mod.class.NPC:loadList("/data/general/npcs/orc.lua", nil, nil, function(e) e.make_escort=nil end),
grid_list = mod.class.Grid:loadList{"/data/general/grids/basic.lua", "/data/general/grids/forest.lua", "/data/general/grids/sand.lua"},
object_list = mod.class.Object:loadList("/data/general/objects/objects.lua"),
trap_list = {},
post_process = function(level)
-- Find a good starting location, on the opposite side of the exit
local sx, sy = level.map.w-1, rng.range(0, level.map.h-1)
level.spots[#level.spots+1] = {
check_connectivity = "entrance",
x = sx,
y = sy,
}
level.default_down = level.default_up
level.default_up = {x=sx, y=sy}
end,
})
game.player:runStop()
game.player.energy.value = game.energy_to_act
game.paused = true
game:changeLevel(1, zone)
engine.ui.Dialog:simplePopup("Ambush!", "You have been ambushed by a patrol of orcs!")
end,
on_encounter = {type="ambush", width=10, height=10, nb={3,5}, filters={{type="animal", subtype="canine"}}},
}
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