From 7b3d0d2c5ae727bad3e09d2c4184c28d0c367da0 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Sun, 31 Oct 2010 14:01:33 +0000
Subject: [PATCH] farportals are connected using pickSpot

git-svn-id: http://svn.net-core.org/repos/t-engine4@1733 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/ai/worldnpcs.lua            |  2 +-
 game/modules/tome/class/Player.lua            | 11 ++++--
 .../tome/data/maps/wilderness/maj-eyal.lua    |  4 +++
 game/modules/tome/data/quests/east-portal.lua |  2 +-
 game/modules/tome/data/quests/west-portal.lua |  2 +-
 .../tome/data/zones/charred-scar/grids.lua    |  2 +-
 .../tome/data/zones/high-peak/grids.lua       |  4 +--
 game/modules/tome/data/zones/reknor/grids.lua |  2 +-
 tiled-maps/maj-eyal.tmx                       | 34 ++++++++++++++++---
 9 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/game/modules/tome/ai/worldnpcs.lua b/game/modules/tome/ai/worldnpcs.lua
index 5748d30ec7..18eceebad8 100644
--- a/game/modules/tome/ai/worldnpcs.lua
+++ b/game/modules/tome/ai/worldnpcs.lua
@@ -102,7 +102,7 @@ newAI("move_world_hostile", function(self)
 		local g = rng.table(gs)
 		self.ai_state.wander_x, self.ai_state.wander_y = g[1], g[2]
 		tx, ty = self.ai_state.wander_x, self.ai_state.wander_y
-		print("Hostile selected random wander", tx, ty)
+--		print("Hostile selected random wander", tx, ty)
 	end
 
 	if tx and ty then
diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua
index 378ee724d9..f612132239 100644
--- a/game/modules/tome/class/Player.lua
+++ b/game/modules/tome/class/Player.lua
@@ -747,9 +747,14 @@ function _M:useOrbPortal(portal)
 		if x and y then self:move(x, y, true) end
 	else
 		if portal.change_wilderness then
-			self.current_wilderness = portal.change_wilderness.name
-			self.wild_x = portal.change_wilderness.x or 0
-			self.wild_y = portal.change_wilderness.y or 0
+			if portal.change_wilderness.spot then
+				local spot = game.memory_levels[portal.change_zone.."-"..portal.change_level]:pickSpot(portal.change_wilderness.spot)
+				self.wild_x = spot and spot.x or 0
+				self.wild_y = spot and spot.y or 0
+			else
+				self.wild_x = portal.change_wilderness.x or 0
+				self.wild_y = portal.change_wilderness.y or 0
+			end
 		end
 		game:changeLevel(portal.change_level, portal.change_zone)
 	end
diff --git a/game/modules/tome/data/maps/wilderness/maj-eyal.lua b/game/modules/tome/data/maps/wilderness/maj-eyal.lua
index fde65a0050..336a77125d 100644
--- a/game/modules/tome/data/maps/wilderness/maj-eyal.lua
+++ b/game/modules/tome/data/maps/wilderness/maj-eyal.lua
@@ -132,6 +132,10 @@ addSpot({50, 9}, "zone-pop", "antimagic")
 addSpot({10, 18}, "zone-pop", "angolwen")
 addSpot({12, 18}, "zone-pop", "angolwen-portal")
 addSpot({152, 13}, "zone-pop", "high-peak")
+addSpot({153, 19}, "farportal-end", "fareast")
+addSpot({162, 31}, "farportal-end", "gates-of-morning")
+addSpot({57, 33}, "farportal-end", "last-hope")
+addSpot({66, 16}, "farportal-end", "iron-throne")
 
 -- addZone section
 addZone({0, 0, 73, 40}, "zonename", "Maj'Eyal")
diff --git a/game/modules/tome/data/quests/east-portal.lua b/game/modules/tome/data/quests/east-portal.lua
index 5c6b47bc05..e78f560975 100644
--- a/game/modules/tome/data/quests/east-portal.lua
+++ b/game/modules/tome/data/quests/east-portal.lua
@@ -81,7 +81,7 @@ This one seems to go near the Gates of Morning in the Far East.]],
 			change_level = 1,
 			change_zone = "wilderness",
 			change_wilderness = {
-				x = 65, y = 35,
+				spot = {type="farportal-end", subtype="gates-of-morning"},
 			},
 			message = "#VIOLET#You enter the swirling portal and in the blink of an eye you set foot in sight of the Gates of Morning, with no trace of the portal...",
 			on_use = function(self, who)
diff --git a/game/modules/tome/data/quests/west-portal.lua b/game/modules/tome/data/quests/west-portal.lua
index 63d20b5793..459702840f 100644
--- a/game/modules/tome/data/quests/west-portal.lua
+++ b/game/modules/tome/data/quests/west-portal.lua
@@ -90,7 +90,7 @@ This one seems to go near the town of Last Hope in Maj'Eyal.]],
 			change_level = 1,
 			change_zone = "wilderness",
 			change_wilderness = {
-				x = 60, y = 54,
+				spot = {type="farportal-end", subtype="last-hope"},
 			},
 			message = "#VIOLET#You enter the swirling portal and in the blink of an eye you set foot on the outskirts of Last Hope, with no trace of the portal...",
 			on_use = function(self, who)
diff --git a/game/modules/tome/data/zones/charred-scar/grids.lua b/game/modules/tome/data/zones/charred-scar/grids.lua
index 50228145c9..a896efd4e8 100644
--- a/game/modules/tome/data/zones/charred-scar/grids.lua
+++ b/game/modules/tome/data/zones/charred-scar/grids.lua
@@ -57,7 +57,7 @@ newEntity{
 		change_level = 1,
 		change_zone = "wilderness",
 		change_wilderness = {
-			x = 9, y = 5,
+			spot = {type="farportal-end", subtype="fareast"},
 		},
 		message = "#VIOLET#You enter the swirling portal and in the blink of an eye you are back to the far east.",
 	},
diff --git a/game/modules/tome/data/zones/high-peak/grids.lua b/game/modules/tome/data/zones/high-peak/grids.lua
index 7f8b5b14ee..78fd083297 100644
--- a/game/modules/tome/data/zones/high-peak/grids.lua
+++ b/game/modules/tome/data/zones/high-peak/grids.lua
@@ -33,7 +33,7 @@ This one seems to go to the Far East.]],
 		change_level = 1,
 		change_zone = "wilderness",
 		change_wilderness = {
-			x = 9, y = 5,
+			spot = {type="farportal-end", subtype="fareast"},
 		},
 		message = "#VIOLET#You enter the swirling portal and in the blink of an eye you set foot on the Far East, with no trace of the portal...",
 		on_use = function(self, who)
@@ -55,7 +55,7 @@ This one seems to go to the Misty Mountains in the West.]],
 		change_level = 1,
 		change_zone = "wilderness",
 		change_wilderness = {
-			x = 62, y = 7,
+			spot = {type="farportal-end", subtype="iron-throne"},
 		},
 		message = "#VIOLET#You enter the swirling portal and in the blink of an eye you set foot on the slopes of the Misty Mountains, with no trace of the portal...",
 		on_use = function(self, who)
diff --git a/game/modules/tome/data/zones/reknor/grids.lua b/game/modules/tome/data/zones/reknor/grids.lua
index 845e9dffc0..5e77103b97 100644
--- a/game/modules/tome/data/zones/reknor/grids.lua
+++ b/game/modules/tome/data/zones/reknor/grids.lua
@@ -33,7 +33,7 @@ This one seems to go to the Far East, a continent of which only rumours are know
 		change_level = 1,
 		change_zone = "wilderness",
 		change_wilderness = {
-			x = 9, y = 5,
+			spot = {type="farportal-end", subtype="fareast"},
 		},
 		message = "#VIOLET#You enter the swirling portal and in the blink of an eye you set foot on an unfamiliar land, with no trace of the portal...",
 		on_use = function(self, who)
diff --git a/tiled-maps/maj-eyal.tmx b/tiled-maps/maj-eyal.tmx
index 5e2b6cb934..8325388c82 100644
--- a/tiled-maps/maj-eyal.tmx
+++ b/tiled-maps/maj-eyal.tmx
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<map version="1.0" orientation="orthogonal" width="170" height="70" tilewidth="32" tileheight="32">
+<map version="1.0" orientation="orthogonal" width="170" height="100" tilewidth="32" tileheight="32">
  <tileset firstgid="1" name="dg_grounds32" tilewidth="32" tileheight="32">
   <image source="gfx/dg_grounds32.gif" width="288" height="640"/>
   <tile id="9">
@@ -203,12 +203,12 @@
    </properties>
   </tile>
  </tileset>
- <layer name="Terrain" width="170" height="70">
+ <layer name="Terrain" width="170" height="100">
   <data encoding="base64" compression="gzip">
-   H4sIAAAAAAAAA+3cS27cRhAG4F4L0EJAcgEdQoNcQIC0DJCNDPgAvoSBnCEH4AHiZZ7Ow/DJEgJsqFyud1ezZ4a9+GF5RDab1d80OSQ170op7wx5A/KDkjfO5ffIy//5PpjnmeHRfEbtnYvTF5Co02l1fHoYbQ3enrbNF2Pq8tNpbm62RNezrO912tujFmjO6hM7jVgdbeEcg51x8azT4pQKbr+3T+wU54TyllgG92M63cdpJK1OuXa1ZTOMclax0ep0zd+FNuq1OtrECG+jjFL9kJxCq5b2NM8Wg5Q5yapkFIfq55GdWo1kOsVjUfPExOLUuk1quzi/F94cNrq29+/2L+XQEslpxOpoU5fgVLJAjQVlkrKLnX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thi/FZ+6CZeA5VHqMV5dvfcfacyxax6+ZsUCHrwrvEi8n9XwpPl7hvl57D2dZp3WcPFIfnDQ6z+gauRQfpyNZtjvb6RJo9Tviveix33Ksxj484nUs8IVDWy5F735ZDv9exVWxvsUplWgLW82oURiP+dXDZitSq/j8zLu/06ivU25O1PhcyoK/6+M9l0qcSszN9NmKxKfHPuYo8drf94J/g2r2/r6V6H7W5IVj3xwpo/t8zi2cU+Fc7d2OS3l+T+xS9uc0jwf6ke73LU69509JG2AupW91tL6ebV3WSaf2sfK0GtmGtdYZcbpGX+01XB/3zGrGbeYYaLdprfesNq75mT5ytGMkuZcVWb90euxw9iTX+usyM+ulvecw45qwtI1e1jPyfp0554zWp2WXOt728ppO9+WUWm9tp9AqZ1R63U1jNeqzfMZIDbb62mMMRuZPi9MPYF1c5oxndNOpv1OJoZmfEY0Z6ExjFFu1zN1p9TyxzJ9UWg7x9wRmPXOTXo8dz/HmjFJWo52m1e3HModSz79QTvH/2XZtLBvtNK1uO9IxfAVCPavVcwqNtpx6Xw9Ir8eLxqjWKX5WWuo0co6NHo+MzWq1yT2j3TOn8Rnh9Yb+zmw3nFPu+WzO6mhyDs30rHL7+7rMbK/pNNNzqkk1bfUXZTW63zPjRql7pdw91OruFbO85lmWNHruzNynWpNzaWYPTtdIdL9n0mk6PV6ivaTTzFatbuFzEt3nme06nV0PTZnRfZ7ZntE16xndn5k58TK4lp10es54zpNr2kmn58psp2vWO7ovM3PjeewX5TS6DzPrZI/70T3UMTNnzPfkNHO+pNHMHpJOM3tIGs3sIek0s4ek08wekk4ze0k6zWQymUwmk8lkMplMZvv5D6J5qHagCQEA
   </data>
  </layer>
- <objectgroup name="addSpot" width="170" height="70">
+ <objectgroup name="addSpot" width="170" height="100">
   <object name="Allied kingdoms patrol" x="1122" y="1060" width="26" height="24">
    <properties>
     <property name="subtype" value="&quot;allied-kingdoms&quot;"/>
@@ -371,8 +371,32 @@
     <property name="type" value="&quot;zone-pop&quot;"/>
    </properties>
   </object>
+  <object name="Far East portal arrival" x="4899" y="614" width="24" height="20">
+   <properties>
+    <property name="subtype" value="&quot;fareast&quot;"/>
+    <property name="type" value="&quot;farportal-end&quot;"/>
+   </properties>
+  </object>
+  <object name="Gates of morning portal arrival" x="5187" y="999" width="24" height="20">
+   <properties>
+    <property name="subtype" value="&quot;gates-of-morning&quot;"/>
+    <property name="type" value="&quot;farportal-end&quot;"/>
+   </properties>
+  </object>
+  <object name="Last Hope portal arrival" x="1827" y="1061" width="24" height="20">
+   <properties>
+    <property name="subtype" value="&quot;last-hope&quot;"/>
+    <property name="type" value="&quot;farportal-end&quot;"/>
+   </properties>
+  </object>
+  <object name="Iron Throne portal arrival" x="2115" y="519" width="24" height="20">
+   <properties>
+    <property name="subtype" value="&quot;iron-throne&quot;"/>
+    <property name="type" value="&quot;farportal-end&quot;"/>
+   </properties>
+  </object>
  </objectgroup>
- <objectgroup name="addZone" width="170" height="70" visible="0">
+ <objectgroup name="addZone" width="170" height="100" visible="0">
   <object name="Maj'Eyal" x="14" y="10" width="2348" height="1290">
    <properties>
     <property name="subtype" value="&quot;Maj'Eyal&quot;"/>
-- 
GitLab