From 3b48c5b5d836174d86f59fc9b4fe1522ac54df3e Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Mon, 28 Jun 2010 21:37:18 +0000
Subject: [PATCH] ix

git-svn-id: http://svn.net-core.org/repos/t-engine4@860 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engine/PlayerProfile.lua                 |  2 +
 game/engine/interface/ActorQuest.lua          |  4 +-
 game/engine/utils.lua                         |  8 +++
 game/modules/tome/data/quests/escort-duty.lua | 53 +++++++++++++++++++
 4 files changed, 65 insertions(+), 2 deletions(-)
 create mode 100644 game/modules/tome/data/quests/escort-duty.lua

diff --git a/game/engine/PlayerProfile.lua b/game/engine/PlayerProfile.lua
index 035d97130f..1c63009887 100644
--- a/game/engine/PlayerProfile.lua
+++ b/game/engine/PlayerProfile.lua
@@ -104,6 +104,7 @@ function _M:loadGenericProfile()
 			local field = file:gsub(".profile$", "")
 			self.generic[field] = self.generic[field] or {}
 			self:loadData(f, self.generic[field])
+			if not self.generic[field].__uuid then self.generic[field].__uuid = util.uuid() end
 		end
 	end
 
@@ -124,6 +125,7 @@ function _M:loadModuleProfile(short_name)
 			local field = file:gsub(".profile$", "")
 			self.modules[short_name][field] = self.modules[short_name][field] or {}
 			self:loadData(f, self.modules[short_name][field])
+			if not self.modules[short_name][field].__uuid then self.modules[short_name][field].__uuid = util.uuid() end
 		end
 	end
 
diff --git a/game/engine/interface/ActorQuest.lua b/game/engine/interface/ActorQuest.lua
index 26618bb62a..f85acf92c2 100644
--- a/game/engine/interface/ActorQuest.lua
+++ b/game/engine/interface/ActorQuest.lua
@@ -25,11 +25,11 @@ module(..., package.seeall, class.make)
 _M.quest_class = "engine.Quest"
 
 --- Grants a quest to an actor from the given quest definition
-function _M:grantQuest(quest)
+function _M:grantQuest(quest, args)
 	if type(quest) == "string" then
 		local f, err = loadfile("/data/quests/"..quest..".lua")
 		if not f and err then error(err) end
-		local ret = {}
+		local ret = args or {}
 		setfenv(f, setmetatable(ret, {__index=_G}))
 		f()
 		ret.id = ret.id or quest
diff --git a/game/engine/utils.lua b/game/engine/utils.lua
index 8e5766fa40..20bf1cf5eb 100644
--- a/game/engine/utils.lua
+++ b/game/engine/utils.lua
@@ -533,3 +533,11 @@ function util.show_backtrace()
 		level = level + 1
 	end
 end
+
+function util.uuid()
+	local x = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}
+	local y = {'8', '9', 'a', 'b'}
+	local tpl = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
+	local uuid = tpl:gsub("[xy]", function(c) if c=='y' then return rng.table(y) else return rng.table(x) end end)
+	return uuid
+end
diff --git a/game/modules/tome/data/quests/escort-duty.lua b/game/modules/tome/data/quests/escort-duty.lua
new file mode 100644
index 0000000000..c3f71dad70
--- /dev/null
+++ b/game/modules/tome/data/quests/escort-duty.lua
@@ -0,0 +1,53 @@
+-- ToME - Tales of Middle-Earth
+-- Copyright (C) 2009, 2010 Nicolas Casalini
+--
+-- This program is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation, either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
+--
+-- Nicolas Casalini "DarkGod"
+-- darkgod@te4.org
+
+-- Random escort
+id = "escort-duty-"..game.zone.short_name.."-"..game.level.level
+
+kind = {}
+
+name = ""
+desc = function(self, who)
+	local desc = {}
+	desc[#desc+1] = "Escort"
+	return table.concat(desc, "\n")
+end
+
+on_grant = function(self, who)
+	self.on_grant = nil
+	local types = {
+		{ name="warrior",
+			types = {
+				["technique/combat-training"] = 0.7,
+				["technique/combat-techniques-active"] = 0.7,
+				["technique/combat-techniques-passive"] = 0.7,
+			},
+			talents =
+			{
+				[who.T_RUSH] = 1,
+			},
+			stats =
+			{
+				[who.STAT_STR] = 2,
+				[who.STAT_DEX] = 1,
+				[who.STAT_CON] = 2,
+			}
+		},
+	}
+end
-- 
GitLab