quest upgrade_refine_scroll begin
    state start begin
	when 20016.chat.gameforge.upgrade_refine_scroll._10_npcChat begin
		say_title(gameforge.blacksmith._20_sayTitle)
		say(gameforge.upgrade_refine_scroll._20_say)
		wait()

	    if pc.count_item(70035)==0 then
			say_title(gameforge.blacksmith._20_sayTitle)
			say(gameforge.upgrade_refine_scroll._30_say)
			say_item(gameforge.upgrade_refine_scroll._40_sayItem, 70035, "")
			wait()
	    end

	    if pc.count_item(25040)==0 then
			say_title(gameforge.blacksmith._20_sayTitle)
			say(gameforge.upgrade_refine_scroll._50_say)
			say_item(gameforge.upgrade_refine_scroll._60_sayItem, 25040, "")
			wait()
	    end

	    say_title(gameforge.blacksmith._20_sayTitle)
	    say(gameforge.upgrade_refine_scroll._70_say)
	    local s= select(gameforge.locale.guild.yes, gameforge.locale.guild.no)
	    if 1==s then
		if pc.get_gold() < 200000 then
		    say_title(gameforge.blacksmith._40_sayTitle)
		    say_reward(gameforge.horse_summon._80_say)
		elseif pc.count_item(70035)>0 and pc.count_item(25040)>0 then
		    pc.remove_item(70035)
		    pc.remove_item(25040)
		    pc.changegold(-200000)
		    pc.give_item2(71021)
		    say_title(gameforge.blacksmith._20_sayTitle)
		    say(gameforge.upgrade_refine_scroll._80_say)
		    say_item(gameforge.upgrade_refine_scroll._90_sayItem, 71021, "")
		else
		    say_title(gameforge.blacksmith._20_sayTitle)
		    say(gameforge.upgrade_refine_scroll._100_say)
		    
		end
	    end
	end
	when 20016.chat.gameforge.upgrade_refine_scroll._110_npcChat begin
	    say_title(gameforge.blacksmith._20_sayTitle)
	    say(gameforge.upgrade_refine_scroll._120_say)
	    wait()

	    if pc.count_item(71026)==0 then
			say_title(gameforge.blacksmith._20_sayTitle)
			say(gameforge.upgrade_refine_scroll._130_say)
			say_item(gameforge.upgrade_refine_scroll._140_sayItem, 71026, "")
			wait()
	    end

	    if pc.count_item(25040)==0 then
			say_title(gameforge.blacksmith._20_sayTitle)
			say(gameforge.upgrade_refine_scroll._150_say)
			say_item(gameforge.upgrade_refine_scroll._60_sayItem, 25040,"")
			wait()
	    end
		
	    say_title(gameforge.blacksmith._20_sayTitle)
	    say(gameforge.upgrade_refine_scroll._160_say)
	    local s= select(gameforge.locale.guild.yes, gameforge.locale.guild.no)
	    if 1==s then
		if pc.count_item(71026)>0 and pc.count_item(25040)>0 then
		    pc.remove_item(71026)
		    pc.remove_item(25040)
		    pc.give_item2(71032)
		    say_title(gameforge.subquest_30._110_targetVid)
		    say(gameforge.upgrade_refine_scroll._170_say)
		    say_item(gameforge.upgrade_refine_scroll._110_npcChat, 71032, "")
		else
		    say_title(gameforge.blacksmith._20_sayTitle)
		    say(gameforge.upgrade_refine_scroll._180_say)
		end
	    end
	end

	when 20016.chat.gameforge.upgrade_refine_scroll._190_npcChat begin
		say_title(gameforge.blacksmith._20_sayTitle)
		say(gameforge.upgrade_refine_scroll._200_say)
		wait()

		if pc.count_item(71025) == 0 then
			say_title(gameforge.blacksmith._20_sayTitle)
			say(gameforge.upgrade_refine_scroll._210_say)
			say_item(gameforge.upgrade_refine_scroll._220_sayItem, 71025, "")
						wait()
		end

		if pc.count_item(25040) == 0 then
			say_title(gameforge.blacksmith._20_sayTitle)
			say(gameforge.upgrade_refine_scroll._230_say)
			say_item(gameforge.upgrade_refine_scroll._60_sayItem, 25040, "")
						wait()
		end


		say_title(gameforge.blacksmith._20_sayTitle)
		say(gameforge.upgrade_refine_scroll._240_say)

		local s =  select(gameforge.locale.guild.yes, gameforge.locale.guild.no)
		if 1 == s then
			if pc.count_item(71025) > 0 and pc.count_item(25040) > 0 then
				pc.remove_item(71025)
				pc.remove_item(25040)
				pc.give_item2(70039)
				say_title(gameforge.blacksmith._20_sayTitle)
				say(gameforge.upgrade_refine_scroll._250_say)
				say_item(gameforge.upgrade_refine_scroll._260_sayItem, 70039, "")
			else
				say_title(gameforge.blacksmith._20_sayTitle)
				say(gameforge.upgrade_refine_scroll._270_say)
			end
		end
	end

    end
end


