local NEED_ACTIVEPOINT = 10
local g_szMission = "循环任务"
local g_nParam = {}
local g_nIndex = 0
local g_idMission = 0
local g_idScript = 0
local g_dwNextTime = 0
FirstObjects(1)
local g_NpcInfo = {
	[0] = {szNpcName="郑无名", fX=99, fY=54},
	[1] = {szNpcName="杜子庞", fX=45, fY=73},
	[2] = {szNpcName="制药操作台", fX=48, fY=98},
	[3] = {szNpcName="苟写", fX=73, fY=93},
	[4] = {szNpcName="余满仓", fX=165, fY=141},
}

g_Yuansu_Skill = {
	[1] = "金",
	[2] = "木",
	[3] = "水",
	[4] = "火",
	[5] = "土",
	[6] = "融合",
}

g_Zhiyao_Skill = { 
	[1] = "添加主要药材",
	[2] = "添加次要药材",
	[3] = "添加辅助药材",
	[4] = "研磨药材",
}

g_Caiji_Info = {
	[1] = {szNpc="果树", fX=65, fY=143, szItem = "果子"},
	[2] = {szNpc="鱼篓", fX=161, fY=142, szItem = "鲜鱼"},
	[3] = {szNpc="粮垛", fX=119, fY=94, szItem = "粮袋"},
}

g_Buyu_Skill = {
	[1] = "捕鱼一",
	[2] = "捕鱼二",
	[3] = "捕鱼三",
	[4] = "捕鱼四",
	[5] = "捕鱼五",
	[6] = "捕鱼六"	
}

local g_nBYIndex = 0

function 前往帮会驻地()
	if 是否在驻地() ~= 1 then
		打印信息("前往帮会城市")
		召唤坐骑(1)
		跨图寻路(237,236,"洛阳")
		对话npc("范纯仁")
		对话选项("进入本帮城市")
		while 是否在驻地() ~= 1 do 延迟(2000) end
	end
end

function 离开帮会地图()
	if 是否在驻地() == 1 then
		召唤坐骑(1)
		地图寻路(98,157)
		延迟(1000)
		点击确定()
		while 是否在驻地() == 1 do 延迟(2000) end
	end
end

function 交任务()
	前往帮会驻地()
	地图寻路(g_NpcInfo[0].fX, g_NpcInfo[0].fY)
	对话npc(g_NpcInfo[0].szNpcName)
	对话选项(g_szMission)
	任务继续()
	完成任务()
end
function 循环任务()
	local 任务进度 = 取任务进度(g_szMission)
	if 任务进度 == -1 then
		if GetRoleActive() >= NEED_ACTIVEPOINT then
			前往帮会驻地()
			召唤坐骑(1)
			地图寻路(g_NpcInfo[0].fX, g_NpcInfo[0].fY)
			对话npc(g_NpcInfo[0].szNpcName)
			对话选项(g_szMission)
			接受任务()
			延迟(1000)
			return 循环任务()
		else
			打印信息("人物活跃度不足,无法接取任务,离开帮会地图")
			离开帮会地图()
			跨图寻路(237,236,"洛阳")
			return
		end
	end

	if 任务进度 == 1 then
		交任务()
		if 取对话栏内容() == "#{DJBHGZ_110511_75}" then 打印信息("帮会循环任务已经全部完成，任务无法交付，脚本结束") Retx = 1 return end
		return 循环任务()
	end

	if 任务进度 == 0 then
		local 类型 = 取任务参数(g_szMission,2)
		if 类型 == 600067 then
			local Buff = 取任务参数(g_szMission,8)
			if Buff == 1 then
				while 取任务参数(g_szMission,0) ~= 1 do 
					local x,y,Id = 搜索目标("跳跃的鱼",1)
					--打印信息("x = "..x.."y = "..y.."Id = "..Id)
					if Id ~= -1 then
						local index = 0

						if x == 169 and y == 135 then --1
							index = 1 
						elseif x == 170 and y == 137 then --2
							index = 2
						elseif x == 169 and y == 139 then --3
							index = 3
						elseif x == 170 and y == 141 then --4
							index = 4
						elseif x == 169 and y == 143 then --5
							index = 5
						elseif x == 168 and y == 144 then --6
							index = 6
						end
						if index > 0 and index < 7 and g_nBYIndex ~= index then
							使用技能(g_Buyu_Skill[index], -1)
							g_nBYIndex = index
							--打印信息("使用技能"..g_Buyu_Skill[index])
						end
					end
					local Buff = 取任务参数(g_szMission,8)
					if Buff == 0 then return 循环任务() end
					延迟(1000)
				end
				return 循环任务()
			else
				if 取距离(g_NpcInfo[4].fX, g_NpcInfo[4].fY) >= 20 then 召唤坐骑(1) end
				地图寻路(g_NpcInfo[4].fX, g_NpcInfo[4].fY)
				召唤坐骑(0)
				对话npc(g_NpcInfo[4].szNpcName)
				对话选项("#{BHXH_DDS_110526_06}")
				return 循环任务()
			end
		end
	end


end

循环任务()
