From cdd41772973c2ef40b15a7234302ed1b7d305405 Mon Sep 17 00:00:00 2001
From: DarkGod <darkgod@net-core.org>
Date: Thu, 23 Jan 2014 23:14:36 +0100
Subject: [PATCH] Change zone and Grant quest debug commands now handle
 correctly zones and quest provided by addons Shoot can be added a cooldown
 with talent_cd_reduction

---
 game/modules/tome/class/Actor.lua             |  1 +
 game/modules/tome/class/interface/Archery.lua |  7 +++++++
 .../modules/tome/data/chats/eidolon-plane.lua |  8 ++++----
 .../tome/data/talents/techniques/archery.lua  |  1 +
 .../modules/tome/dialogs/debug/ChangeZone.lua |  6 +++---
 .../modules/tome/dialogs/debug/GrantQuest.lua | 19 +++++++++++++++----
 6 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index cf99068299..82a28a4b00 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -4573,6 +4573,7 @@ function _M:startTalentCooldown(t)
 	t = self:getTalentFromId(t)
 	if not t.cooldown then return end
 	self.talents_cd[t.id] = self:getTalentCooldown(t)
+	if self.talents_cd[t.id] <= 0 then self.talents_cd[t.id] = nil end
 	self.changed = true
 end
 
diff --git a/game/modules/tome/class/interface/Archery.lua b/game/modules/tome/class/interface/Archery.lua
index c15745745f..7b217813d7 100644
--- a/game/modules/tome/class/interface/Archery.lua
+++ b/game/modules/tome/class/interface/Archery.lua
@@ -32,14 +32,18 @@ module(..., package.seeall, class.make)
 function _M:archeryAcquireTargets(tg, params)
 	params = params or {}
 	local weapon, ammo, offweapon = self:hasArcheryWeapon()
+	-- Awesome, we can shoot from our offhand!
+	if self.can_offshoot and not weapon and offweapon then weapon, offweapon = offweapon, nil end
 	if not weapon then
 		game.logPlayer(self, "You must wield a bow or a sling (%s)!", ammo)
+		print("== no weapon")
 		return nil
 	end
 	local infinite = ammo.infinite or self:attr("infinite_ammo") or params.infinite
 
 	if not ammo or (ammo.combat.shots_left <= 0 and not infinite) then
 		game.logPlayer(self, "You do not have enough ammo left!")
+		print("== no ammo")
 		return nil
 	end
 
@@ -51,6 +55,7 @@ function _M:archeryAcquireTargets(tg, params)
 		local val = self['get'..weapon.use_resource.kind:capitalize()](self)
 		if val < weapon.use_resource.value then
 			game.logPlayer(self, "You do not have enough %s left!", weapon.use_resource.kind)
+			print("== no ressource")
 			return nil
 		end
 	end
@@ -590,6 +595,8 @@ end
 
 function _M:hasDualArcheryWeapon(type)
 	local w, a, o = self:hasArcheryWeapon(type)
+	if self.can_solo_dual_archery and w and not o then w, o = w, w end
+	if self.can_solo_dual_archery and not w and o then w, o = o, o end
 	if w and a and o then return w, a, o end
 	return nil
 end
diff --git a/game/modules/tome/data/chats/eidolon-plane.lua b/game/modules/tome/data/chats/eidolon-plane.lua
index 9c6d120ef3..09c9434cdd 100644
--- a/game/modules/tome/data/chats/eidolon-plane.lua
+++ b/game/modules/tome/data/chats/eidolon-plane.lua
@@ -27,15 +27,15 @@ As for your probable many questions, they will stay unanswered. I may help, but
 	answers = {
 		{"Thank you. I will rest for a while."},
 		{"Thank you. I am ready to go back!", 
-			cond=function() return game.level.source_level end,
+			cond=function() return game.level.source_level and not game.level.source_level.no_return_from_eidolon end,
 			action=function() game.level.data.eidolon_exit(false) end
 		},
 		{"Thank you, but I fear I will not survive anyway, can you send me back somewhere else please?",
-			cond=function() return game.level.source_level and (not game.level.source_level.data or not game.level.source_level.data.no_worldport) end,
+			cond=function() return game.level.source_level and not game.level.source_level.no_return_from_eidolon and (not game.level.source_level.data or not game.level.source_level.data.no_worldport) end,
 			action=function() game.level.data.eidolon_exit(true) end
 		},
 		{"Thank you, I am ready to go back!",
-			cond=function() return not game.level.source_level end,
+			cond=function() return not game.level.source_level or game.level.source_level.no_return_from_eidolon end,
 			jump="jump_error",
 		},
 		{"Thank you, but I am weary of this life, I wish no more, please let me go.", jump="die"},
@@ -43,7 +43,7 @@ As for your probable many questions, they will stay unanswered. I may help, but
 }
 
 newChat{ id="jump_error",
-	text = [[It seems the threads of time have been disrupted...
+	text = [[It seems the threads of time and space have been disrupted...
 I will try to send you to safety.]],
 	answers = {
 		{"Thanks.", action=function(npc, player) game:changeLevel(1, "wilderness") end},
diff --git a/game/modules/tome/data/talents/techniques/archery.lua b/game/modules/tome/data/talents/techniques/archery.lua
index d7c81109bf..b8bed8a249 100644
--- a/game/modules/tome/data/talents/techniques/archery.lua
+++ b/game/modules/tome/data/talents/techniques/archery.lua
@@ -25,6 +25,7 @@ newTalent{
 	hide = true,
 	innate = true,
 	points = 1,
+	cooldown = 0,
 	range = archery_range,
 	message = "@Source@ shoots!",
 	requires_target = true,
diff --git a/game/modules/tome/dialogs/debug/ChangeZone.lua b/game/modules/tome/dialogs/debug/ChangeZone.lua
index a14da30bfa..d4b178c334 100644
--- a/game/modules/tome/dialogs/debug/ChangeZone.lua
+++ b/game/modules/tome/dialogs/debug/ChangeZone.lua
@@ -64,14 +64,14 @@ end
 function _M:generateList()
 	local list = {}
 
-	local function parse(base, add)
+	local function parse(base, add, add_simple)
 		for i, dir in ipairs(fs.list(base.."/zones/")) do
 			local f = loadfile(base.."/zones/"..dir.."/zone.lua")
 			if f then
 				setfenv(f, setmetatable({}, {__index=_G}))
 				local ok, z = pcall(f)
 				if ok then
-					list[#list+1] = {name=z.name, zone=add..dir, min=1, max=z.max_level}
+					list[#list+1] = {name=z.name..(add_simple and " ["..add_simple.."]" or ""), zone=add..dir, min=1, max=z.max_level}
 				end
 			end
 		end
@@ -81,7 +81,7 @@ function _M:generateList()
 	for i, dir in ipairs(fs.list("/")) do
 		local _, _, addon = dir:find("^data%-(.+)$")
 		if addon then
-			parse("/"..dir, addon.."+")
+			parse("/"..dir, addon.."+", addon)
 		end
 	end
 
diff --git a/game/modules/tome/dialogs/debug/GrantQuest.lua b/game/modules/tome/dialogs/debug/GrantQuest.lua
index f2ea1f1eb2..acc85b25a9 100644
--- a/game/modules/tome/dialogs/debug/GrantQuest.lua
+++ b/game/modules/tome/dialogs/debug/GrantQuest.lua
@@ -69,12 +69,23 @@ end
 function _M:generateList()
 	local list = {}
 
-	for i, file in ipairs(fs.list("/data/quests/")) do
-		if file:find(".lua$") then
-			local n = file:gsub(".lua$", "")
-			list[#list+1] = {name=n, quest=n, hasit=game.player:hasQuest(n)}
+	local function parse(base, add, add_simple)
+		for i, file in ipairs(fs.list(base.."/quests/")) do
+			if file:find(".lua$") then
+				local n = file:gsub(".lua$", "")
+				list[#list+1] = {name=n..(add_simple and " ["..add_simple.."]" or ""), quest=add..n, hasit=game.player:hasQuest(n)}
+			end
 		end
 	end
+
+	parse("/data", "")
+	for i, dir in ipairs(fs.list("/")) do
+		local _, _, addon = dir:find("^data%-(.+)$")
+		if addon then
+			parse("/"..dir, addon.."+", addon)
+		end
+	end
+
 	table.sort(list, function(a,b) return a.name < b.name end)
 
 	local chars = {}
-- 
GitLab