diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index f6121322391ba9cf24d7d4fcd677e1c3fcf11370..1bc8c1d0e0540b187920b2b0dfdf7d4733bfd9c6 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -163,24 +163,7 @@ function _M:move(x, y, force) if game.zone.wilderness then -- Cheat with time game.turn = game.turn + 1000 - self.wild_x, self.wild_y = self.x, self.y - local g = game.level.map(self.x, self.y, Map.TERRAIN) - - if g and g.can_encounter and game.level.data.encounters then - local type = game.level.data.encounters.chance(self) - if type then - game.level.level = self.level - game.level:setEntitiesList("encounters_rng", game.zone:computeRarities("encounters_rng", game.level:getEntitiesList("encounters"), game.level, nil)) - local e = game.zone:makeEntity(game.level, "encounters_rng", {type=type, mapx=self.x, mapy=self.y, nb_tries=10}) - if e then - if e:check("on_encounter", self) then - e:added() - end - end - end - end - game.state:worldDirectorAI() end diff --git a/game/modules/tome/data/maps/wilderness/eyal.lua b/game/modules/tome/data/maps/wilderness/eyal.lua index 1cb382fde6ad3b517405b492c24dc6c3d1533e5b..c0ab21cfe3bbd1a0753b0b2923be63d1d740a97d 100644 --- a/game/modules/tome/data/maps/wilderness/eyal.lua +++ b/game/modules/tome/data/maps/wilderness/eyal.lua @@ -74,20 +74,11 @@ else end -- Load encounters for this map -prepareEntitiesList("encounters", "mod.class.Encounter", "/data/general/encounters/maj-eyal.lua") -prepareEntitiesList("encounters_fareast", "mod.class.Encounter", "/data/general/encounters/fareast.lua") -prepareEntitiesList("encounters_npcs", "mod.class.WorldNPC", "/data/general/encounters/maj-eyal-npcs.lua") +prepareEntitiesList("maj_eyal_encounters", "mod.class.Encounter", "/data/general/encounters/maj-eyal.lua") +prepareEntitiesList("maj_eyal_encounters_npcs", "mod.class.WorldNPC", "/data/general/encounters/maj-eyal-npcs.lua") +prepareEntitiesList("fareast_encounters", "mod.class.Encounter", "/data/general/encounters/fareast.lua") addData{ - wda = { script="maj-eyal", }, - encounters = { - chance=function(who) - local harmless_chance = 1 + who:getLck(7) - local hostile_chance = 2 - if rng.percent(hostile_chance) then return "hostile" - elseif rng.percent(harmless_chance) then return "harmless" - end - end - }, + wda = { script="maj-eyal", zones={} }, } -- addSpot section diff --git a/game/modules/tome/data/wda/maj-eyal.lua b/game/modules/tome/data/wda/maj-eyal.lua index cae717a1558f6d2368077a004306723066e7377b..c4620ed00b61412efbd13ab75124d862d6a19e6a 100644 --- a/game/modules/tome/data/wda/maj-eyal.lua +++ b/game/modules/tome/data/wda/maj-eyal.lua @@ -17,35 +17,108 @@ -- Nicolas Casalini "DarkGod" -- darkgod@te4.org --- Maj'Eyal worldmap directory AI - -wda.cur_patrols = wda.cur_patrols or 0 -wda.cur_hostiles = wda.cur_hostiles or 0 - --- Spawn some patrols -if wda.cur_patrols < 3 then - local e = game.zone:makeEntity(game.level, "encounters_npcs", {type="patrol"}, nil, true) - if e then - local spot = game.level:pickSpot{type="patrol", "allied-kingdoms"} - if spot and not game.level.map(spot.x, spot.y, engine.Map.ACTOR) and not game.level.map.seens(spot.x, spot.y) then - print("Spawned allied kingdom patrol", spot.x, spot.y, e.name) - game.zone:addEntity(game.level, e, "actor", spot.x, spot.y) - wda.cur_patrols = wda.cur_patrols + 1 - e.on_die = function() game.level.data.wda.cur_patrols = game.level.data.wda.cur_patrols - 1 end - end +-- Eyal worldmap directory AI + +-- Select the zone +local Map = require "engine.Map" +local zone = game.zone.display_name() +if not wda.zones[zone] then wda.zones[zone] = {} end +wda = wda.zones[zone] + +game.level.level = game.player.level + +local encounter_chance = function(who) + local harmless_chance = 1 + who:getLck(7) + local hostile_chance = 2 + if rng.percent(hostile_chance) then return "hostile" + elseif rng.percent(harmless_chance) then return "harmless" end end --- Spawn some hostiles -if wda.cur_hostiles < 4 and rng.percent(5) then - local e = game.zone:makeEntity(game.level, "encounters_npcs", {type="hostile"}, nil, true) - if e then - local spot = game.level:pickSpot{type="hostile", "random"} - if spot and not game.level.map(spot.x, spot.y, engine.Map.ACTOR) and not game.level.map.seens(spot.x, spot.y) then - print("Spawned hostile", spot.x, spot.y, e.name) - game.zone:addEntity(game.level, e, "actor", spot.x, spot.y) - wda.cur_hostiles = wda.cur_hostiles + 1 - e.on_die = function() game.level.data.wda.cur_hostiles = game.level.data.wda.cur_hostiles - 1 end +--------------------------------------------------------------------- +-- Maj'Eyal +--------------------------------------------------------------------- +if zone == "Maj'Eyal" then + wda.cur_patrols = wda.cur_patrols or 0 + wda.cur_hostiles = wda.cur_hostiles or 0 + + -- Spawn random encounters + local g = game.level.map(game.player.x, game.player.y, Map.TERRAIN) + if g and g.can_encounter then + local type = encounter_chance(game.player) + if type then + game.level:setEntitiesList("maj_eyal_encounters_rng", game.zone:computeRarities("maj_eyal_encounters_rng", game.level:getEntitiesList("maj_eyal_encounters"), game.level, nil)) + local e = game.zone:makeEntity(game.level, "maj_eyal_encounters_rng", {type=type, mapx=game.player.x, mapy=game.player.y, nb_tries=10}) + if e then + if e:check("on_encounter", game.player) then + e:added() + end + end + end + end + + -- Spawn some patrols + if wda.cur_patrols < 3 then + local e = game.zone:makeEntity(game.level, "maj_eyal_encounters_npcs", {type="patrol"}, nil, true) + if e then + local spot = game.level:pickSpot{type="patrol", "allied-kingdoms"} + if spot and not game.level.map(spot.x, spot.y, Map.ACTOR) and not game.level.map.seens(spot.x, spot.y) then + print("Spawned allied kingdom patrol", spot.x, spot.y, e.name) + game.zone:addEntity(game.level, e, "actor", spot.x, spot.y) + wda.cur_patrols = wda.cur_patrols + 1 + e.world_zone = zone + e.on_die = function(self) game.level.data.wda.zones[self.world_zone].cur_patrols = game.level.data.wda.zones[self.world_zone].cur_patrols - 1 end + end + end + end + + -- 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"}, nil, true) + if e then + local spot = game.level:pickSpot{type="hostile", "random"} + if spot and not game.level.map(spot.x, spot.y, Map.ACTOR) and not game.level.map.seens(spot.x, spot.y) then + print("Spawned hostile", spot.x, spot.y, e.name) + game.zone:addEntity(game.level, e, "actor", spot.x, spot.y) + wda.cur_hostiles = wda.cur_hostiles + 1 + e.world_zone = zone + e.on_die = function(self) game.level.data.wda.zones[self.world_zone].cur_hostiles = game.level.data.wda.zones[self.world_zone].cur_hostiles - 1 end + end + end + end + +--------------------------------------------------------------------- +-- Var'Eyal (Far East) +--------------------------------------------------------------------- +elseif zone == "Far East" then + wda.cur_patrols = wda.cur_patrols or 0 + wda.cur_hostiles = wda.cur_hostiles or 0 + + -- Spawn some patrols + if wda.cur_patrols < 3 then + local e = game.zone:makeEntity(game.level, "encounters_npcs", {type="patrol"}, nil, true) + if e then + local spot = game.level:pickSpot{type="patrol", "sunwall"} + if spot and not game.level.map(spot.x, spot.y, Map.ACTOR) and not game.level.map.seens(spot.x, spot.y) then + print("Spawned sunwall patrol", spot.x, spot.y, e.name) + game.zone:addEntity(game.level, e, "actor", spot.x, spot.y) + wda.cur_patrols = wda.cur_patrols + 1 + e.on_die = function() game.level.data.wda.cur_patrols = game.level.data.wda.cur_patrols - 1 end + end + end + end + + -- Spawn some hostiles + if wda.cur_hostiles < 4 and rng.percent(5) then + local e = game.zone:makeEntity(game.level, "encounters_npcs", {type="hostile"}, nil, true) + if e then + local spot = game.level:pickSpot{type="hostile", "random"} + if spot and not game.level.map(spot.x, spot.y, Map.ACTOR) and not game.level.map.seens(spot.x, spot.y) then + print("Spawned hostile", spot.x, spot.y, e.name) + game.zone:addEntity(game.level, e, "actor", spot.x, spot.y) + wda.cur_hostiles = wda.cur_hostiles + 1 + e.on_die = function() game.level.data.wda.cur_hostiles = game.level.data.wda.cur_hostiles - 1 end + end end end end diff --git a/ideas/setting.ods b/ideas/setting.ods index 9c048f87c449c25a3a32ce0568f280e0b82804e7..49f0d1a480d4a726963d7d072c7d7094d52f06af 100644 Binary files a/ideas/setting.ods and b/ideas/setting.ods differ diff --git a/tiled-maps/eyal.tmx b/tiled-maps/eyal.tmx index 7a05f222e277f6d0b5646b645b34fec6605db658..28f7535ea889058c53397cddf04f5e334d8a59c0 100644 --- a/tiled-maps/eyal.tmx +++ b/tiled-maps/eyal.tmx @@ -401,6 +401,30 @@ <property name="type" value=""farportal-end""/> </properties> </object> + <object name="Sunwall patrol" x="5188" y="1028" width="26" height="24"> + <properties> + <property name="subtype" value=""sunwall""/> + <property name="type" value=""patrol""/> + </properties> + </object> + <object name="Sunwall patrol" x="5250" y="1348" width="26" height="24"> + <properties> + <property name="subtype" value=""sunwall""/> + <property name="type" value=""patrol""/> + </properties> + </object> + <object name="Sunwall patrol" x="5218" y="582" width="26" height="24"> + <properties> + <property name="subtype" value=""sunwall""/> + <property name="type" value=""patrol""/> + </properties> + </object> + <object name="Sunwall patrol" x="4836" y="964" width="26" height="24"> + <properties> + <property name="subtype" value=""sunwall""/> + <property name="type" value=""patrol""/> + </properties> + </object> </objectgroup> <objectgroup name="addZone" width="170" height="100" visible="0"> <object name="Maj'Eyal" x="34" y="40" width="2488" height="1456">