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

Trollmire now has a road, for easier navigation

git-svn-id: http://svn.net-core.org/repos/t-engine4@4167 51575b47-30f0-44d4-a5cc-537603b46e54
parent 13eff6bd
No related branches found
No related tags found
No related merge requests found
Showing
with 270 additions and 23 deletions
......@@ -36,6 +36,7 @@ function _M:init(zone, map, level, spots)
self.nb_npc = data.nb_npc or {10, 20}
self.area = data.area or {x1=0, x2=self.map.w-1, y1=0, y2=self.map.h-1}
self.guardian = data.guardian
self.guardian_spot = data.guardian_spot
self.guardian_no_connectivity = data.guardian_no_connectivity
self.guardian_level = data.guardian_level
self.post_generation = data.post_generation
......@@ -56,13 +57,27 @@ function _M:generateGuardian(guardian)
local m = self.zone:makeEntityByName(self.level, "actor", guardian)
local ok = false
if m then
local x, y = rng.range(self.area.x1, self.area.x2), rng.range(self.area.y1, self.area.y2)
local tries = 0
while (not m:canMove(x, y) or self.map.room_map[x][y].special) and tries < 100 do
local x, y = nil, nil
if self.guardian_spot then
local spot = self.level:pickSpot(self.guardian_spot)
if spot then
x, y = spot.x, spot.y
print("Selecting guardian spot", x, y)
end
end
if not x or not y then
x, y = rng.range(self.area.x1, self.area.x2), rng.range(self.area.y1, self.area.y2)
tries = tries + 1
local tries = 0
while (not m:canMove(x, y) or self.map.room_map[x][y].special) and tries < 100 do
x, y = rng.range(self.area.x1, self.area.x2), rng.range(self.area.y1, self.area.y2)
tries = tries + 1
end
if tries >= 100 then x, y = nil, nil end
end
if tries < 100 then
if x and y then
self.spots[#self.spots+1] = {x=x, y=y, guardian=true, check_connectivity=(not self.guardian_no_connectivity) and "entrance" or nil}
self.zone:addEntity(self.level, m, "actor", x, y)
print("Guardian allocated: ", self.guardian, m.uid, m.name)
......
......@@ -21,6 +21,8 @@ require "engine.class"
local Map = require "engine.Map"
require "engine.Generator"
local RoomsLoader = require "engine.generator.map.RoomsLoader"
local Astar = require"engine.Astar"
local DirectPath = require"engine.DirectPath"
module(..., package.seeall, class.inherit(engine.Generator, RoomsLoader))
function _M:init(zone, map, level, data)
......@@ -37,6 +39,11 @@ function _M:init(zone, map, level, data)
self.octave = data.octave or 4
self.nb_spots = data.nb_spots or 10
self.do_ponds = data.do_ponds
self.add_road = data.add_road or false
self.end_road = data.end_road or false
self.end_road_room = data.end_road_room
if self.do_ponds then
self.do_ponds.zoom = self.do_ponds.zoom or 5
self.do_ponds.octave = self.do_ponds.octave or 5
......@@ -118,6 +125,7 @@ function _M:addPond(x, y, spots)
for j = 1, self.do_ponds.size.h do
if pmap[i][j] then
self.map(i-1+x, j-1+y, Map.TERRAIN, self:resolve(pmap[i][j], self.grid_list, true))
self.map.room_map[i-1+x][j-1+y].special = "pond"
end
end
end
......@@ -155,12 +163,15 @@ function _M:generate(lev, old_lev)
end
local spots = {}
local waypoints = {}
self.spots = spots
-- Add some spots
for i = 1, self.nb_spots do
local s = rng.tableRemove(possible_spots)
if s then self.spots[#self.spots+1] = s end
if s then
self.spots[#self.spots+1] = s
end
end
if self.do_ponds then
......@@ -169,8 +180,50 @@ function _M:generate(lev, old_lev)
end
end
local nb_room = util.getval(self.data.nb_rooms or 0)
local rooms = {}
local end_room
local axis
local direction
local ending
-- get the axis and direction
if self.data.edge_entrances[1] == 2 or self.data.edge_entrances[1] == 8 then axis = "y"
else axis = "x"
end
if self.data.edge_entrances[1] == 2 or self.data.edge_entrances[1] == 4 then direction = 1
else direction = -1
end
-- Add the "requested" end room first (must be at least 66% into the level)
print("End Room:",self.end_road_room)
if self.end_road and self.end_road_room then
print("Trying to load",self.end_road_room)
local rroom, end_room_load
end_room_load = self:loadRoom(self.end_road_room)
local r = self:roomAlloc(end_room_load, #rooms+1, lev, old_lev, function(room, x, y)
local far_enough = false
if axis == "x" and direction == 1 then
far_enough = x >= self.map.w*0.66
elseif axis == "x" and direction == -1 then
far_enough = x <= self.map.w*0.33
elseif axis == "y" and direction == 1 then
far_enough = y >= self.map.h*0.66
elseif axis == "y" and direction == -1 then
far_enough = y <= self.map.h*0.33
end
return far_enough
end)
if r then
rooms[#rooms+1] = r
end_room = r
print("Successfully loaded the end room")
end
end
while nb_room > 0 do
local rroom
while true do
......@@ -194,9 +247,167 @@ function _M:generate(lev, old_lev)
ux, uy, dx, dy, spots = self:makeStairsInside(lev, old_lev, spots)
end
-- Create a road between the stairs via "waypoints" on the map
-- The rule is that no waypoint may further away (in terms of the directional axis) than the previous point
if self.add_road then
if self.end_road then
ending = true
else
ending = false
end
-- Add the up stairs as waypoint 1
if #waypoints > 0 then
table.insert(waypoints,1,{x=ux,y=uy})
else
waypoints[#waypoints+1] = {x=ux,y=uy}
end
-- Get 30 random locations
local possible_waypoints = {}
for i = 1, 30 do
local x = rng.range(0,self.map.w-1)
local y = rng.range(0,self.map.h-1)
possible_waypoints[i] = {x=x,y=y}
--print("Possible waypoint",i,x,y)
end
-- sort all the spots in order of upstairs to downstairs
local start, finish
if self.data.edge_entrances[1] == 2 then
start = 0
finish = self.map.h
table.sort(possible_waypoints,function(a, b) return b.y > a.y end)
elseif self.data.edge_entrances[1] == 4 then
start = 0
finish = self.map.w
table.sort(possible_waypoints,function(a, b) return b.x > a.x end)
elseif self.data.edge_entrances[1] == 6 then
start = self.map.w
finish = 0
table.sort(possible_waypoints,function(a, b) return b.x < a.x end)
elseif self.data.edge_entrances[1] == 8 then
start = self.map.h
finish = 0
table.sort(possible_waypoints,function(a, b) return b.y < a.y end)
end
-- for i = 1, #possible_waypoints do
-- spot = possible_waypoints[i]
-- print("Possible waypoint",i,spot.x,spot.y)
-- end
print("Axis : ", axis, " from ", start," to ", finish)
if ending and end_room then
if axis == "x" then finish = end_room.x
else finish = end_room.y
end
end
for i = 1, #possible_waypoints do
local s = possible_waypoints[i]
print ("Possible waypoint",i,s.x,s.y)
reason = self:checkValid(s,waypoints[#waypoints],axis,start,finish)
if not self.map.room_map[s.x][s.y].special and reason == true then
waypoints[#waypoints+1] = {x=s.x,y=s.y}
print("Waypoint",i,s.x,s.y,"accepted")
else
print("Waypoint",i,s.x,s.y,"rejected: ",reason)
end
end
-- if the downstairs exist, and the road's not ending here, add the downstairs
if dx and not ending then
waypoints[#waypoints+1] = {x=dx,y=dy}
end
if ending and self.end_road_room then
waypoints[#waypoints+1] = {x=end_room.x,y=end_room.y}
end
--print("Amount of waypoints in road are: ", #waypoints)
local i = 2
while i <= #waypoints do
print("tunnel waypoint ",i-1," from ", waypoints[i-1].x, waypoints[i-1].y, " to ", waypoints[i].x,waypoints[i].y)
self:makeRoad(waypoints[i-1].x,waypoints[i-1].y,waypoints[i].x,waypoints[i].y,id,"road")
i = i + 1
end
end
return ux, uy, dx, dy, spots
end
function _M:makeRoad(x1,y1,x2,y2,id,terrain)
local a = Astar.new(self.map, game:getPlayer())
local recheck = false
path = a:calc(x1, y1, x2, y2, true, nil,
function(x, y)
if game.level.map:checkEntity(x, y, Map.TERRAIN, "air_level") then
return false
else
return true
end
end,
true)
--No Astar path ? just be dumb and try direct line
if not path then
local d = DirectPath.new(game.level.map, game:getPlayer())
path = d:calc(x1, y1, x2, y2, false)
print("A* couldn't find road to ",x2,y2,"from",x1,x2)
end
-- convert path to tunnel
for i, pathnode in ipairs(path) do
if not self.map.room_map[pathnode.x][pathnode.y].special then
self.map(pathnode.x, pathnode.y, Map.TERRAIN, self:resolve(terrain))
end
end
end
function _M:checkValid(spot, lastspot, axis, start, finish)
-- Get the axis
local mindistance = 2
--math.floor((start+finish)*0.07)
local progress, measure, invert_measure,invert_progress, measure = 0,0,0,0
if axis == "x" then
progress = lastspot.x
measure = spot.x
invert_measure = spot.y
invert_progress = lastspot.y
else
progress = lastspot.y
measure = spot.y
invert_measure = spot.x
invert_progress = lastspot.x
end
-- Get the direction
if finish < start then
progess = progress * -1
measure = measure * -1
finish = finish * -1
mindistance = mindistance * -1
end
-- every next one must be at least X squares closer to the end, and not closer than 2*X to the end,
-- and on the other axis may not be further than 20% of the distance of the map away
if not (measure > progress+mindistance) then
return "not enough progress from previous waypoint"
end
if not (measure < finish-mindistance*2) then
return "measure too close to finish"
end
if not (math.abs(invert_progress - invert_measure) < math.abs(start-finish)*0.2) then
return "on non-progress axis, the measure was more than 20% different from previous"
end
return
measure > progress+mindistance and
measure < finish-mindistance*2 and
math.abs(invert_progress - invert_measure) < math.abs(start-finish)*0.2
end
--- Create the stairs inside the level
function _M:makeStairsInside(lev, old_lev, spots)
-- Put down stairs
......@@ -264,3 +475,4 @@ function _M:makeStairsSides(lev, old_lev, sides, spots)
return ux, uy, dx, dy, spots
end
......@@ -181,7 +181,7 @@ function _M:roomPlace(room, id, x, y)
end
--- Make up a room
function _M:roomAlloc(room, id, lev, old_lev)
function _M:roomAlloc(room, id, lev, old_lev, add_check)
room = self:roomGen(room, id, lev, old_lev)
if not room then return end
......@@ -198,7 +198,7 @@ function _M:roomAlloc(room, id, lev, old_lev)
if not ok then break end
end
if ok then
if ok and (not add_check or add_check(room, x, y)) then
local res = self:roomPlace(room, id, x, y)
if res then return res end
end
......
......@@ -36,8 +36,16 @@ newBirthDescriptor{
},
},
copy = {
-- All mages are of angolwen faction
faction = "sunwall",
class_start_check = function(self)
if self.descriptor.world == "Maj'Eyal" and (self.descriptor.race == "Human" or self.descriptor.race == "Elf") then
self.celestial_race_start_quest = self.starting_quest
self.default_wilderness = {"zone-pop", "ruined-gates-of-morning"}
self.starting_zone = "town-gates-of-morning"
self.starting_quest = "start-sunwall"
self.starting_intro = "sunwall"
self.faction = "sunwall"
end
end,
},
}
......@@ -79,9 +87,9 @@ newBirthDescriptor{
copy = {
max_life = 110,
resolvers.equip{ id=true,
{type="weapon", subtype="mace", name="iron mace", autoreq=true, ego_chance=-1000},
{type="armor", subtype="shield", name="iron shield", autoreq=true, ego_chance=-1000},
{type="armor", subtype="heavy", name="iron mail armour", autoreq=true, ego_chance=-1000},
{type="weapon", subtype="mace", name="iron mace", ingore_material_restriction=true, autoreq=true, ego_chance=-1000},
{type="armor", subtype="shield", name="iron shield", ingore_material_restriction=true, autoreq=true, ego_chance=-1000},
{type="armor", subtype="heavy", name="iron mail armour", ingore_material_restriction=true, autoreq=true, ego_chance=-1000},
},
},
copy_add = {
......@@ -127,8 +135,8 @@ newBirthDescriptor{
copy = {
max_life = 90,
resolvers.equip{ id=true,
{type="weapon", subtype="staff", name="elm staff", autoreq=true, ego_chance=-1000},
{type="armor", subtype="cloth", name="linen robe", autoreq=true, ego_chance=-1000}
{type="weapon", subtype="staff", name="elm staff", ingore_material_restriction=true, autoreq=true, ego_chance=-1000},
{type="armor", subtype="cloth", name="linen robe", ingore_material_restriction=true, autoreq=true, ego_chance=-1000}
},
},
}
......@@ -155,12 +155,11 @@ newBirthDescriptor{
self.starting_zone = "town-angolwen"
self.starting_quest = "start-archmage"
self.starting_intro = "archmage"
self.faction = "angolwen"
self:learnTalent(self.T_TELEPORT_ANGOLWEN, true)
end
end,
-- All mages are of angolwen faction
faction = "angolwen",
max_life = 90,
resolvers.equip{ id=true,
{type="weapon", subtype="staff", name="elm staff", autoreq=true, ego_chance=-1000},
......
......@@ -17,6 +17,16 @@
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
if not game.state:isAdvanced() then
newChat{ id="welcome",
text = [[Good day to you.]],
answers = {
{"Good day to you too."},
}
}
return "welcome"
end
if not game.player:hasQuest("spydric-infestation") then
newChat{ id="welcome",
text = [[I have heard you are a great hero of the west. Could you help me, please?]],
......
......@@ -18,11 +18,11 @@
-- darkgod@te4.org
newChat{ id="welcome",
text = [[Thank you for your help. What may I do for you?]],
text = [[What may I do for you?]],
answers = {
{"Tell me more about the Gates of Morning.", jump="explain-gates"},
{"Tell me more about the Gates of Morning.", jump="explain-gates", cond=function(npc, player) return player.faction ~= "sunwall" end},
{"Before I came here, I happened upon members of the Sunwall in Maj'Eyal. Do you know of this?.", jump="sunwall_west", cond=function(npc, player) return game.state.found_sunwall_west and not npc.been_asked_sunwall_west end, action=function(npc, player) npc.been_asked_sunwall_west = true end},
{"I need help in my hunt for clues about the staff.", jump="clues", cond=function(npc, player) return not player:hasQuest("orc-pride") end},
{"I need help in my hunt for clues about the staff.", jump="clues", cond=function(npc, player) return game.state:isAdvanced() and not player:hasQuest("orc-pride") end},
{"I have destroyed the leaders of all the Orc Prides.", jump="prides-dead", cond=function(npc, player) return player:isQuestStatus("orc-pride", engine.Quest.COMPLETED) end},
{"I am back from the Charred Scar, where the orcs took the staff.", jump="charred-scar", cond=function(npc, player) return player:hasQuest("charred-scar") and player:hasQuest("charred-scar"):isCompleted() end},
{"Sorry, I have to go!"},
......
......@@ -43,7 +43,7 @@ newChat{ id="welcome",
text = [[#LIGHT_GREEN#*A slot in the door opens and a pair of wild eyes peers out.*#WHITE#
What do you want, @playerdescriptor.race@?]],
answers = {
{"Paladin Aeryn told me that you could help me. I need to get to Maj'Eyal.", jump="help", cond=function(npc, player) return not player:hasQuest("west-portal") end},
{"Paladin Aeryn told me that you could help me. I need to get to Maj'Eyal.", jump="help", cond=function(npc, player) return game.state:isAdvanced() and not player:hasQuest("west-portal") end},
{"I found the Blood-Runed Athame, but there was no Resonating Diamond.", jump="athame", cond=function(npc, player) return player:hasQuest("west-portal") and player:hasQuest("west-portal"):isCompleted("athame") and not player:hasQuest("west-portal"):isCompleted("gem") end},
{"I have a Resonating Diamond.", jump="complete", cond=function(npc, player) return player:hasQuest("west-portal") and player:hasQuest("west-portal"):isCompleted("gem") end},
{"Sorry, I have to go!"},
......
......@@ -123,7 +123,6 @@ newEntity{
name = "deep water", image = "terrain/water_floor.png",
display = '~', color=colors.AQUAMARINE, back_color=colors.DARK_BLUE,
always_remember = true,
air_level = -5, air_condition="water",
}
-----------------------------------------
......@@ -133,6 +132,7 @@ newEntity{
newEntity{ base="WATER_BASE",
define_as = "DEEP_WATER",
image="terrain/water_grass_5_1.png",
air_level = -5, air_condition="water",
}
-----------------------------------------
......@@ -142,6 +142,7 @@ newEntity{ base="WATER_BASE",
newEntity{ base="WATER_BASE",
define_as = "DEEP_OCEAN_WATER",
image = "terrain/ocean_water_grass_5_1.png",
air_level = -5, air_condition="water",
}
-----------------------------------------
......
game/modules/tome/data/gfx/shockbolt/terrain/misc_bog1.png

1.22 KiB

game/modules/tome/data/gfx/shockbolt/terrain/misc_bog2.png

1.68 KiB

game/modules/tome/data/gfx/shockbolt/terrain/misc_bog3.png

4.76 KiB

game/modules/tome/data/gfx/shockbolt/terrain/misc_bog4.png

2.93 KiB

game/modules/tome/data/gfx/shockbolt/terrain/misc_bog5.png

5.49 KiB

game/modules/tome/data/gfx/shockbolt/terrain/misc_bog6.png

2.44 KiB

game/modules/tome/data/gfx/shockbolt/terrain/misc_bog7.png

4.85 KiB

game/modules/tome/data/gfx/shockbolt/terrain/naga_portal.png

14.6 KiB

game/modules/tome/data/gfx/talents/thick_skin.png

3.95 KiB

......@@ -77,6 +77,8 @@ addSpot({42, 26}, "npc", "aeryn-main")
addSpot({43, 21}, "pop-quest", "farportal")
addSpot({43, 20}, "pop-quest", "farportal-npc")
addSpot({42, 21}, "pop-quest", "farportal-player")
addSpot({40, 30}, "pop-birth", "sunwall")
addSpot({42, 30}, "pop-birth", "slazish-fens")
-- addZone section
......
......@@ -27,7 +27,7 @@ for i = 1, 44 do list[#list+1] = i end
-- defineTile section
defineTile("*", function() local v = rng.tableRemove(list) if not v then v = "" end return "GRAVE"..v end)
defineTile("<", "GRASS_UP4")
defineTile("<", "GRASS_UP_WILDERNESS")
defineTile("_", "ROAD")
defineTile(">", "MAUSOLEUM")
defineTile(".", "GRASS")
......
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