
quest subquest_36 begin
	state start begin
		when login or levelup with pc.level >= 47 and pc.level <= 49 begin
			set_state(information)
		end
	end

	state information begin
		when letter begin
			local v=find_npc_by_vnum(20005)
			if 0==v then
			else
				target.vid("__TARGET__", v, gameforge.subquest_36._10_targetVid)
			end
		end


        when __TARGET__.target.click or 20005.chat.gameforge.subquest_36._20_npcChat begin
			target.delete("__TARGET__")
			say_title(gameforge.subquest_01._140_sayTitle)
			say(gameforge.subquest_36._30_say)
			wait()
			say_title(gameforge.subquest_01._140_sayTitle)
			say(gameforge.subquest_36._40_say)
			local s= select(gameforge.subquest_36._50_select, gameforge.subquest_36._60_select)
			if 2==s then
				say(gameforge.subquest_26._210_say)
				local a= select(gameforge.locale.guild.yes, gameforge.locale.guild.no)
				if 2==a then
					say_title(gameforge.subquest_01._140_sayTitle)
					say(gameforge.subquest_36._70_say)
					return
				end
				say_title(gameforge.subquest_01._140_sayTitle)
				say(gameforge.subquest_36._80_say)
				set_state(__GIVEUP__)
				return
			end
			say_title(gameforge.subquest_01._140_sayTitle)
			say(gameforge.subquest_36._90_say)
			set_state(for_horse)
		end
	end


state for_horse begin
	when letter begin
	    send_letter(gameforge.subquest_36._20_npcChat)
		if 	pc.count_item(50054)>=10 then
			local v=find_npc_by_vnum(20349)
			if 0==v then
			else
				target.vid("__TARGET__", v, gameforge.pony_buy._250_makequestbutton)
			end
		end

	end
	when button or info begin
		if 	pc.count_item(50054)>=10 then
	    		say_title(gameforge.subquest_36._100_sayTitle)
			say(gameforge.subquest_36._110_say)
			return
		end

		say_title(gameforge.subquest_36._120_sayTitle)
		say(gameforge.subquest_36._130_say)
	end



	when 20349.chat.gameforge.subquest_36._140_npcChat with pc.count_item(50054) ==0 or pc.count_item(50054) < 10 begin
		say_title(gameforge.horse_exchange_ticket._20_sayTitle)
		say(gameforge.subquest_36._150_say)
	    local s= select(gameforge.subquest_36._190_select, gameforge.subquest_31._180_select)
	    if 1==s then
			say_pc_name()
			say(gameforge.subquest_36._160_say)
			return

	    else
			say_pc_name()
			say(gameforge.subquest_36._170_say)
			wait()
			say_title(gameforge.horse_exchange_ticket._20_sayTitle)
			say(gameforge.subquest_36._180_say)

			local s= select(gameforge.subquest_36._190_select, gameforge.subquest_31._180_select)
			if 1==s then
				say_pc_name()
				say(gameforge.subquest_36._200_say)
				return

			elseif 2==s then
				say_pc_name()
				say(gameforge.subquest_36._210_say)
				set_state(__GIVEUP__)
			end
	    end
	end



	when __TARGET__.target.click or	20349.chat.gameforge.subquest_36._220_npcChat with pc.count_item(50054)>=10 begin
		target.delete("__TARGET__")
		say_title(gameforge.horse_levelup._240_sayTitle)
		say(gameforge.subquest_36._230_say)
		say_reward(gameforge.subquest_36._240_sayReward)
		pc.give_exp2(1800000)

		pc.remove_item(50054,10)
		set_state(OLD_MAN_DONE)
	end
  end

  state OLD_MAN_DONE begin
	when letter begin
			send_letter(gameforge.subquest_36._250_sendLetter)
			local v=find_npc_by_vnum(20005)
			if 0==v then
			else
				target.vid("__TARGET__", v, gameforge.subquest_36._10_targetVid)
			end

		end
	when button or info begin
		say_title(gameforge.subquest_36._260_sayTitle)
		say(gameforge.subquest_36._270_say)
	end
	when __TARGET__.target.click or	20005.chat.gameforge.subquest_36._280_npcChat begin
		target.delete("__TARGET__")
		say_title(gameforge.subquest_36._10_targetVid)
		say(gameforge.subquest_36._290_say)
		say_reward(gameforge.subquest_36._300_sayReward)

		local s=number(1,3)
		if 1>=s then
			pc.give_item2(50320)
		elseif 2>=s then
			pc.give_item2(50320)
		elseif 3>=s then
			pc.give_item2(50320)
		end

		set_state(__COMPLETE__)
		clear_letter()

	end
end
    state __COMPLETE__ begin
		when enter begin
			q.done()
		end
	end
	state __GIVEUP__ begin
    end
end

