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

plop

git-svn-id: http://svn.net-core.org/repos/t-engine4@1744 51575b47-30f0-44d4-a5cc-537603b46e54
parent 4b5f1dd4
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
......@@ -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
No preview for this file type
......@@ -401,6 +401,30 @@
<property name="type" value="&quot;farportal-end&quot;"/>
</properties>
</object>
<object name="Sunwall patrol" x="5188" y="1028" width="26" height="24">
<properties>
<property name="subtype" value="&quot;sunwall&quot;"/>
<property name="type" value="&quot;patrol&quot;"/>
</properties>
</object>
<object name="Sunwall patrol" x="5250" y="1348" width="26" height="24">
<properties>
<property name="subtype" value="&quot;sunwall&quot;"/>
<property name="type" value="&quot;patrol&quot;"/>
</properties>
</object>
<object name="Sunwall patrol" x="5218" y="582" width="26" height="24">
<properties>
<property name="subtype" value="&quot;sunwall&quot;"/>
<property name="type" value="&quot;patrol&quot;"/>
</properties>
</object>
<object name="Sunwall patrol" x="4836" y="964" width="26" height="24">
<properties>
<property name="subtype" value="&quot;sunwall&quot;"/>
<property name="type" value="&quot;patrol&quot;"/>
</properties>
</object>
</objectgroup>
<objectgroup name="addZone" width="170" height="100" visible="0">
<object name="Maj'Eyal" x="34" y="40" width="2488" height="1456">
......
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