-- Chuseok Events
quest harvest_festival begin
    state start begin
        function kill_action()
            local kill_count = pc.getqf("mob_kill2_count") + 1
            local random_rice = harvest_festival.get_random_rice(2)
            pc.setqf("mob_kill2_count", kill_count)

            if kill_count < 0 then
                return
            end	-- end of if
        
            q.set_counter("remaining_2403", 60 - kill_count);

            if kill_count >= 60 or kill_count < 0 then
                notice_multiline(string.format(gameforge.harvest_festival._560_notice, random_rice), notice)
                -- Getting the rice cake
                local cake_count = pc.getqf("cake_count") + random_rice
                pc.setqf("cake_count", cake_count)

                pc.setqf("harvest_festival_mob_complete", 1)
                clear_letter()
                set_state(information)

            end -- end of if
        
        end
        
        
        function get_random_rice(type)
            if (type == 1) then
                if (pc.get_level() >= 90) then
                    random_rice = number(3, 6)
                elseif (pc.get_level() >= 70) then
                    random_rice = number(2, 5)
                elseif (pc.get_level() >= 50) then
                    random_rice = number(2, 4)
                elseif (pc.get_level() >= 30) then
                    random_rice = number(1, 3)
                elseif (pc.get_level() >= 10) then
                    random_rice = number(1, 2)
                else
                    random_rice = number(1, 2)
                end -- end of if
            elseif (type == 2) then
                if (pc.get_level() >= 90) then
                    random_rice = number(4, 8)
                elseif (pc.get_level() >= 70) then
                    random_rice = number(3, 7)
                elseif (pc.get_level() >= 50) then
                    random_rice = number(3, 6)
                elseif (pc.get_level() >= 30) then
                    random_rice = number(2, 5)
                elseif (pc.get_level() >= 10) then
                    random_rice = number(2, 4)
                else
                    random_rice = number(2, 3)
                end -- end of if
            end
            
            return random_rice
            
        end

        when login with pc.get_level() > 0 begin
            set_state(information)
            pc.setqf("harvest_festival_count", 0)
            pc.setqf("harvest_festival_mob_complete", 0)
            pc.setqf("cake_count", 0)
            pc.setqf("rice_count", 0)
      end -- end of when
  end -- end of state

    
    -- Event Start
    state information begin	
        when letter with game.get_event_flag("harvest_festival")>0  begin
            local v= find_npc_by_vnum(20086)
            if 0==v then
            else
                target.vid("__TARGET__", v, gameforge.harvest_festival._010_targetVid)
            end
        end


        -- Glutinous rice in exchange for a gift
        when 20087.chat.gameforge.harvest_festival._025_npcChat with game.get_event_flag("harvest_festival")>0 begin
            local rice_count = pc.getqf("rice_count")

            say_title(gameforge.harvest_festival._020_sayTitle)
            say(string.format(gameforge.harvest_festival._030_say, rice_count))
            local reward_set = select(gameforge.harvest_festival._040_select, gameforge.harvest_festival._050_select)

            if reward_set == 2 then
                say_title(gameforge.harvest_festival._020_sayTitle)
                say(gameforge.harvest_festival._060_say)
                return
            end -- end of if	
        
            say_title(gameforge.harvest_festival._020_sayTitle)
            say(gameforge.harvest_festival._070_say)

            -- local harvest_item_set = select("15x Glut",  "15x Gl","35x Perle","35x Gluttrank","35x Gltes","Maybe later")
            local harvest_item_set = select(gameforge.harvest_festival._090_select,
                                            gameforge.harvest_festival._100_select,
                                            gameforge.harvest_festival._110_select,
                                            gameforge.harvest_festival._120_select,
                                            gameforge.harvest_festival._130_select,
                                            gameforge.harvest_festival._140_select,
                                            gameforge.harvest_festival._150_select,
                                            gameforge.harvest_festival._160_select,
                                            gameforge.harvest_festival._170_select)
            if harvest_item_set == 9 then
                return
            end -- end of if

            local harvest_item_name = ""
            local harvest_rice_count = 0
            
            
            if harvest_item_set == 1 then
                harvest_item_name = gameforge.harvest_festival._090_select
                harvest_rice_count = 30 
            elseif harvest_item_set == 2 then
                harvest_item_name = gameforge.harvest_festival._100_select
                harvest_rice_count = 45 
            elseif harvest_item_set == 3 then
                harvest_item_name = gameforge.harvest_festival._110_select
                harvest_rice_count = 50
            elseif harvest_item_set == 4 then
                harvest_item_name = gameforge.harvest_festival._120_select
                harvest_rice_count = 55
            elseif harvest_item_set == 5 then
                harvest_item_name = gameforge.harvest_festival._130_select
                harvest_rice_count = 60 
           elseif harvest_item_set == 6 then
                harvest_item_name = gameforge.harvest_festival._140_select
                harvest_rice_count = 70 
            elseif harvest_item_set == 7 then
                harvest_item_name = gameforge.harvest_festival._150_select
                harvest_rice_count = 75
            elseif harvest_item_set == 8 then
                harvest_item_name = gameforge.harvest_festival._160_select
                harvest_rice_count = 80
            end -- end of if	

            -- Check glutinous rice amount
            if rice_count < harvest_rice_count then
                say_title(gameforge.harvest_festival._020_sayTitle)
                say(gameforge.harvest_festival._180_say)
                return
            end -- end of if	

            say_title(gameforge.harvest_festival._020_sayTitle)
            say(gameforge.harvest_festival._190_say)
            say("")
            say(string.format(gameforge.harvest_festival._200_say,harvest_rice_count, harvest_item_name))
            say(gameforge.harvest_festival._210_say)

            local item_get_set = select(gameforge.harvest_festival._220_select, gameforge.harvest_festival._170_select)

            if item_get_set == 2 then
                return
            end -- end of if

            -- System to hand out the items
            if harvest_item_set == 1 then
                pc.setqf("rice_count", rice_count - harvest_rice_count)	
                pc.give_item2("50109", 1)
            elseif harvest_item_set == 2 then
                pc.setqf("rice_count", rice_count - harvest_rice_count)	
                pc.give_item2("50110", 1)
            elseif harvest_item_set == 3 then
                pc.setqf("rice_count", rice_count - harvest_rice_count)	
                pc.give_item2("72728", 1)
            elseif harvest_item_set == 4 then
                pc.setqf("rice_count", rice_count - harvest_rice_count)	
                pc.give_item2("50111", 1)
            elseif harvest_item_set == 5 then
                pc.setqf("rice_count", rice_count - harvest_rice_count)	
                pc.give_item2("50112", 1)
            elseif harvest_item_set == 6 then
                pc.setqf("rice_count", rice_count - harvest_rice_count)	
                pc.give_item2("72724", 1)
            elseif harvest_item_set == 7 then
                pc.setqf("rice_count", rice_count - harvest_rice_count)	
                pc.give_item2("50114", 1)
            elseif harvest_item_set == 8 then
                pc.setqf("rice_count", rice_count - harvest_rice_count)	
                pc.give_item2("50115", 1)
            end -- end of if

            say_reward(string.format(gameforge.harvest_festival._230_say,harvest_item_name))
            say(gameforge.harvest_festival._240_say)
            
        end -- end of when
        
        when 20086.chat."Harvest Event Commands" with pc.get_gm_level() == 5 begin

            if game.get_event_flag("harvest_festival") == 0 then
             
                say("Current Status: ThanksGiving Event Results")
                say("")

                local s = select("Start Event", "Cancel")
                if 1==s then

                    game.set_event_flag("harvest_festival", 1) 
                return
            end
            else

                say("Current Status: The event is currently active")
                say("")
                local s = select("Stop the Event", "Cancel")
                if 1==s then

                    game.set_event_flag("harvest_festival", 0) 
                return
                end
            end
        end

        when 20086.chat.gameforge.harvest_festival._250_npcChat with game.get_event_flag("harvest_festival")>0 begin
            target.delete("__TARGET__")
            local quest_count = pc.getqf("harvest_festival_count")
            local quest_complete = pc.getqf("harvest_festival_mob_complete")

            -- When you finished all the quests
            if quest_count >= 10 then
                say_title(gameforge.harvest_festival._260_sayTitle)
                say(gameforge.harvest_festival._270_say)

                return
            end -- end of if

            -- If you came back for this dish
            if quest_complete == 1 then
                pc.setqf("harvest_festival_count", quest_count + 1)
                pc.setqf("harvest_festival_mob_complete", 0)
                pc.setqf("mob_kill1_count", 0)
                pc.setqf("mob_kill2_count", 0)
                
                local quest_count = pc.getqf("harvest_festival_count")
                
                say_title(gameforge.harvest_festival._260_sayTitle)
                say(gameforge.harvest_festival._280_say)
                wait()

                -- Getting the Glutinous Rice
                local rice_count = pc.getqf("rice_count")
                local cake_count = pc.getqf("cake_count")
                pc.setqf("rice_count", rice_count + cake_count)
                pc.setqf("cake_count", 0)
                
                say_title(gameforge.harvest_festival._260_sayTitle)
                say(string.format(gameforge.harvest_festival._290_say, cake_count))
								wait()
                say_title(gameforge.harvest_festival._260_sayTitle)
                say(gameforge.harvest_festival._300_say)
                wait()

                if quest_count >= 10 then
                    char_log(0, "EVENT_RECORD", "harvest_festival clear")
                    say_title(gameforge.harvest_festival._260_sayTitle)
                    say(gameforge.harvest_festival._310_say)

                    return
                else
                    say_title(gameforge.harvest_festival._260_sayTitle)
                    say(gameforge.harvest_festival._320_say)
                end -- end of if

                local replay_set = select(gameforge.harvest_festival._330_select, gameforge.harvest_festival._340_select)

                if replay_set == 2 then
                    return
                end	-- end of if

                local current_count = quest_count + 1

                say_title(gameforge.harvest_festival._260_sayTitle)
                say(gameforge.harvest_festival._350_say)
                say(string.format(gameforge.harvest_festival._360_say, current_count))
                
                set_state(mob_kill1)

                return
            end -- end of if

            -- If you stop and do the quest again
            if quest_count > 0 then
                say_title(gameforge.harvest_festival._260_sayTitle)
                say(gameforge.harvest_festival._360_say)

                local replay_set = select(gameforge.harvest_festival._380_select,gameforge.harvest_festival._390_select)

                if replay_set == 2 then
                    return
                end	-- end of if

                local current_count = quest_count + 1
                say_title(gameforge.harvest_festival._260_sayTitle)
                say(string.format(gameforge.harvest_festival._400_say, current_count))
                set_state(mob_kill1)

                return
            end -- end of if

            -- here we must put the different mobnames
            if pc.get_level() >= 81 then
                pc.setqf("mob1_info", 6)
                mob1_name = gameforge.harvest_festival._410_say
            elseif pc.get_level() >= 61 then	
                pc.setqf("mob1_info", 5)
                mob1_name = gameforge.harvest_festival._420_say
            elseif pc.get_level() >= 41 then	
                pc.setqf("mob1_info", 4)
                mob1_name = gameforge.harvest_festival._430_say
            elseif pc.get_level() >= 21 then	
                pc.setqf("mob1_info", 3)
                mob1_name = gameforge.harvest_festival._440_say
            elseif pc.get_level() >= 11 then	
                pc.setqf("mob1_info", 2)
                mob1_name = gameforge.harvest_festival._450_say
            elseif pc.get_level() <= 10 then	
                pc.setqf("mob1_info", 1)
                mob1_name = gameforge.harvest_festival._460_say
            end -- end of if
            
					
					-- When you start for the 1st time
            say_title(gameforge.harvest_festival._260_sayTitle)
            say(gameforge.harvest_festival._470_say)
            say(string.format(gameforge.harvest_festival._480_say, mob1_name))

            local main_set = select(gameforge.harvest_festival._490_select,gameforge.harvest_festival._500_select)
            if main_set == 2 then
                say_title(gameforge.harvest_festival._260_sayTitle)
                say(gameforge.harvest_festival._510_select)
                return
            end -- end of if

            local current_count = quest_count + 1

            say_title(gameforge.harvest_festival._260_sayTitle)
            say(string.format(gameforge.harvest_festival._400_say, current_count))
            set_state(mob_kill1)

        end -- end of when
    end -- end of state

    
    state mob_kill1 begin
        when letter begin
            send_letter(gameforge.harvest_festival._520_sendLetter)
        end -- end of when

        when info or button begin
            local mob1_info = pc.getqf("mob1_info")
            if mob1_info == 6 then
                mob1_name = gameforge.harvest_festival._410_say
            elseif mob1_info == 5 then	
                mob1_name = gameforge.harvest_festival._420_say
            elseif mob1_info == 4 then	
                mob1_name = gameforge.harvest_festival._430_say
            elseif mob1_info == 3 then	
                mob1_name = gameforge.harvest_festival._440_say
            elseif mob1_info == 2 then	
                mob1_name = gameforge.harvest_festival._450_say
            elseif mob1_info == 1 then	
                mob1_name = gameforge.harvest_festival._460_say
            end -- end of if
        
            say(gameforge.harvest_festival._520_sendLetter)
            say(string.format(gameforge.harvest_festival._530_say, mob1_info))

            local gogo_set = select(gameforge.harvest_festival._540_select,gameforge.harvest_festival._550_select)

            if gogo_set == 2 then
                clear_letter()
                set_state(information)
            end -- end of if

        end -- end of when

        when 20086.chat.gameforge.harvest_festival._570_npcChat with game.get_event_flag("harvest_festival")>0 begin
            local kill_count = pc.getqf("mob_kill1_count")
            if kill_count < 30 then
                say_title(gameforge.harvest_festival._260_sayTitle)
                say(gameforge.harvest_festival._580_say)
            else
                say_title(gameforge.harvest_festival._260_sayTitle)
                say(gameforge.harvest_festival._590_say)
                local mob2_name = ""
                if pc.get_level() >= 91 then
                    pc.setqf("mob2_info", 8)
                    mob2_name = gameforge.harvest_festival._600_say
                elseif pc.get_level() >= 81 then
                    pc.setqf("mob2_info", 7)
                    mob2_name = gameforge.harvest_festival._610_say
                elseif pc.get_level() >= 71 then
                    pc.setqf("mob2_info", 6)
                    mob2_name = gameforge.harvest_festival._620_say
                elseif pc.get_level() >= 61 then	
                    pc.setqf("mob2_info", 5)
                    mob2_name = gameforge.harvest_festival._630_say
                elseif pc.get_level() >= 51 then	
                    pc.setqf("mob2_info", 4)
                    mob2_name = gameforge.harvest_festival._640_say
                elseif pc.get_level() >= 41 then	
                    pc.setqf("mob2_info", 3)
                    mob2_name = gameforge.harvest_festival._650_say
                elseif pc.get_level() >= 31 then	
                    pc.setqf("mob2_info", 2)
                    mob2_name = gameforge.harvest_festival._660_say
                elseif pc.get_level() >= 20 then	
                    pc.setqf("mob2_info", 1)
                    mob2_name = gameforge.harvest_festival._670_say
                end -- end of if
                
                say(string.format(gameforge.harvest_festival._680_say, mob2_name))
                local sub_set = select(gameforge.harvest_festival._690_select,gameforge.harvest_festival._700_select)
                
                if sub_set == 2	then
                    say_title(gameforge.harvest_festival._260_sayTitle)
                    say(gameforge.harvest_festival._710_say)
                    set_state(information)
                    return
                end
                say_title(gameforge.harvest_festival._260_sayTitle)
                say(string.format(gameforge.harvest_festival._715_say, mob2_name))
                set_state(mob_kill2)
            end
        end	-- end of when
        
        when 20087.click with game.get_event_flag("harvest_festival")>0 begin
            say_title(gameforge.harvest_festival._020_sayTitle)
            say(gameforge.harvest_festival._550_select)
        end	-- end of when
        
        when 1137.kill with pc.getf("harvest_festival","mob1_info") == 6 begin
            local kill_count = pc.getqf("mob_kill1_count") + 1
            local random_rice = harvest_festival.get_random_rice(1)
            pc.setqf("mob_kill1_count", kill_count)

            if kill_count < 0 then
                return
            end	-- end of if
            
            q.set_counter("remaining_1137", 30 - kill_count)

            if kill_count >= 30 or kill_count < 0 then
                notice_multiline(string.format(gameforge.harvest_festival._560_notice, random_rice), notice)
                -- How many dishes are needed
                pc.setqf("cake_count", random_rice)
                clear_letter()

            end
        end
        
        when 2202.kill with pc.getf("harvest_festival","mob1_info") == 5 begin
            local kill_count = pc.getqf("mob_kill1_count") + 1
            local random_rice = harvest_festival.get_random_rice(1)
            pc.setqf("mob_kill1_count", kill_count)

            if kill_count < 0 then
                return
            end	-- end of if
            
            q.set_counter("remaining_2202", 30 - kill_count)

            if kill_count >= 30 or kill_count < 0 then
                notice_multiline(string.format(gameforge.harvest_festival._560_notice, random_rice), notice)
                -- How many dishes are needed
                pc.setqf("cake_count", random_rice)
                clear_letter()
            end
        
        end
        
        when 701.kill with pc.getf("harvest_festival","mob1_info") == 4 begin
            local kill_count = pc.getqf("mob_kill1_count") + 1
            local random_rice = harvest_festival.get_random_rice(1)
            pc.setqf("mob_kill1_count", kill_count)

            if kill_count < 0 then
                return
            end	-- end of if
            
            q.set_counter("remaining_701", 30 - kill_count)

            if kill_count >= 30 or kill_count < 0 then
                notice_multiline(string.format(gameforge.harvest_festival._560_notice, random_rice), notice)
                -- How many dishes are needed
                pc.setqf("cake_count", random_rice)
                clear_letter()

            end
        
        end
        
        when 501.kill with pc.getf("harvest_festival","mob1_info") == 3 begin
            local kill_count = pc.getqf("mob_kill1_count") + 1
            local random_rice = harvest_festival.get_random_rice(1)
            pc.setqf("mob_kill1_count", kill_count)

            if kill_count < 0 then
                return
            end	-- end of if
            
            q.set_counter("remaining_501", 30 - kill_count)

            if kill_count >= 30 or kill_count < 0 then
                notice_multiline(string.format(gameforge.harvest_festival._560_notice, random_rice), notice)
                -- How many dishes are needed
                pc.setqf("cake_count", random_rice)
                clear_letter()

            end
        end
        
        when 301.kill with pc.getf("harvest_festival","mob1_info") == 2 begin
            local kill_count = pc.getqf("mob_kill1_count") + 1
            local random_rice = harvest_festival.get_random_rice(1)
            pc.setqf("mob_kill1_count", kill_count)

            if kill_count < 0 then
                return
            end	-- end of if
            
            q.set_counter("remaining_301", 30 - kill_count)

            if kill_count >= 30 or kill_count < 0 then
                notice_multiline(string.format(gameforge.harvest_festival._560_notice, random_rice), notice)
                -- How many dishes are needed
                pc.setqf("cake_count", random_rice)
                clear_letter()
            end		
        end -- end of when
        
        when 105.kill with pc.getf("harvest_festival","mob1_info") == 1 begin
            local kill_count = pc.getqf("mob_kill1_count") + 1
            local random_rice = harvest_festival.get_random_rice(1)
            pc.setqf("mob_kill1_count", kill_count)

            if kill_count < 0 then
                return
            end	-- end of if
            
            q.set_counter("remaining_105", 30 - kill_count)

            if kill_count >= 30 or kill_count < 0 then
                notice_multiline(string.format(gameforge.harvest_festival._560_notice, random_rice), notice)
                -- How many dishes are needed
                pc.setqf("cake_count", random_rice)
                clear_letter()
            end		
        end -- end of when

        
    end -- end of state


    state mob_kill2 begin

        when letter begin
            send_letter(gameforge.harvest_festival._520_sendLetter)
        end -- end of when
      
       when info or button begin
            local mob2_info = pc.getqf("mob2_info")
            if mob2_info == 8 then
                mob2_name = gameforge.harvest_festival._600_say
            elseif mob2_info == 7 then
                mob2_name = gameforge.harvest_festival._610_say
            elseif mob2_info == 6 then
                mob2_name = gameforge.harvest_festival._620_say
            elseif mob2_info == 5 then
                mob2_name = gameforge.harvest_festival._630_say
            elseif mob2_info == 4 then
                mob2_name = gameforge.harvest_festival._640_say
            elseif mob2_info == 3 then
                mob2_name = gameforge.harvest_festival._650_say
            elseif mob2_info == 2 then
                mob2_name = gameforge.harvest_festival._660_say
            elseif mob2_info == 1 then
                mob2_name = gameforge.harvest_festival._670_say
            end -- end of if

            say_title(gameforge.harvest_festival._520_sendLetter)
            say(string.format(gameforge.harvest_festival._720_say,mob2_name))

            if party.is_party() then
                say(gameforge.harvest_festival._730_say)
            else
                say(gameforge.harvest_festival._740_say)
            end -- end of if

            local gogo_set = select(gameforge.harvest_festival._380_select,gameforge.harvest_festival._540_select)

            if gogo_set == 2 then
                clear_letter()
                set_state(information)
            end -- end of if

        end -- end of when
     
     
        when 20086.chat.gameforge.harvest_festival._750_npcChat with game.get_event_flag("harvest_festival")>0 begin

            local quest_count = pc.getqf("harvest_festival_count")
            local quest_complete = pc.getqf("harvest_festival_mob_complete")

            -- When you have finished all the quests
            if quest_count >= 10 then
                say_title(gameforge.harvest_festival._260_sayTitle)
                say(gameforge.harvest_festival._760_say)
                set_state(information)
                return
            end -- end of if

            -- If you come back for the dish
            if quest_complete == 1 then
                pc.setqf("harvest_festival_count", quest_count + 1)
                pc.setqf("harvest_festival_mob_complete", 0)
                pc.setqf("mob_kill1_count", 0)
                pc.setqf("mob_kill2_count", 0)
                
                local quest_count = pc.getqf("harvest_festival_count")
                
                say_title(gameforge.harvest_festival._260_sayTitle)
                say(gameforge.harvest_festival._770_say)
                wait()

                -- Getting Glutinous Rice
                local rice_count = pc.getqf("rice_count")
                local cake_count = pc.getqf("cake_count")
                pc.setqf("rice_count", rice_count + cake_count)
                pc.setqf("cake_count", 0)
                
                say_title(gameforge.harvest_festival._260_sayTitle)
                say(gameforge.harvest_festival._780_say)
                wait()
                
                if quest_count >= 10 then
                    char_log(0, "EVENT_RECORD", "harvest_festival clear")
                    say_title(gameforge.harvest_festival._260_sayTitle)
                    say(gameforge.harvest_festival._790_say)
                    set_state(information)
                    return
                else
                    say_title(gameforge.harvest_festival._260_sayTitle)
                    say(gameforge.harvest_festival._795_say)
                end -- end of if

                local replay_set = select(gameforge.harvest_festival._380_select,gameforge.harvest_festival._390_select)

                if replay_set == 2 then
                    set_state(information)
                    return
                end	-- end of if

                local current_count = quest_count + 1

                say_title(gameforge.harvest_festival._260_sayTitle)
                say(string.format(gameforge.harvest_festival._400_say,current_count))
                set_state(mob_kill1)
                return
            end -- end of if
        end -- end of when
        
        when 20087.click with game.get_event_flag("harvest_festival")>0 begin
            say(gameforge.harvest_festival._020_sayTitle)
            say(gameforge.harvest_festival._800_say)
        end -- end of when

        when 113.kill with pc.getf("harvest_festival","mob2_info") == 1 and party.is_party() begin
            local kill_count = pc.getqf("mob_kill2_count") + 1
            local random_rice = harvest_festival.get_random_rice(2)
            pc.setqf("mob_kill2_count", kill_count)

            if kill_count < 0 then
                return
            end	-- end of if
        
            q.set_counter("remaining_113", 60 - kill_count);

            if kill_count >= 60 or kill_count < 0 then

                notice_multiline(string.format(gameforge.harvest_festival._560_notice, random_rice), notice)
                -- Getting the rice cake
                local cake_count = pc.getqf("cake_count") + random_rice
                pc.setqf("cake_count", cake_count)

                pc.setqf("harvest_festival_mob_complete", 1)
                clear_letter()
                set_state(information)

            end -- end of if
        end -- end of when	

        when 502.kill with pc.getf("harvest_festival","mob2_info") == 2  and party.is_party() begin
            local kill_count = pc.getqf("mob_kill2_count") + 1
            local random_rice = harvest_festival.get_random_rice(2) 
            pc.setqf("mob_kill2_count", kill_count)

            if kill_count < 0 then
                return
            end	-- end of if
        
            q.set_counter("remaining_502", 60 - kill_count);

            if kill_count >= 60 or kill_count < 0 then
                notice_multiline(string.format(gameforge.harvest_festival._560_notice, random_rice), notice)
                -- Getting the rice cake
                local cake_count = pc.getqf("cake_count") + random_rice
                pc.setqf("cake_count", cake_count)
                pc.setqf("harvest_festival_mob_complete", 1)
                clear_letter()
                set_state(information)

            end -- end of if
        end -- end of when	

        when 703.kill with pc.getf("harvest_festival","mob2_info") == 3 and party.is_party()  begin
            local kill_count = pc.getqf("mob_kill2_count") + 1
            local random_rice = harvest_festival.get_random_rice(2) 
            pc.setqf("mob_kill2_count", kill_count)

            if kill_count < 0 then
                return
            end	-- end of if
        
            q.set_counter("remaining_703", 60 - kill_count);

            if kill_count >= 60 or kill_count < 0 then
                notice_multiline(string.format(gameforge.harvest_festival._560_notice, random_rice), notice)
                -- Getting the rice cake
                local cake_count = pc.getqf("cake_count") + random_rice
                pc.setqf("cake_count", cake_count)
                pc.setqf("harvest_festival_mob_complete", 1)
                clear_letter()
                set_state(information)

            end -- end of if
        end -- end of when	

        when 707.kill with pc.getf("harvest_festival","mob2_info") == 4 and party.is_party()  begin
            local kill_count = pc.getqf("mob_kill2_count") + 1
            local random_rice = harvest_festival.get_random_rice(2) 
            pc.setqf("mob_kill2_count", kill_count)

            if kill_count < 0 then
                return
            end	-- end of if
        
            q.set_counter("remaining_707", 60 - kill_count);

            if kill_count >= 60 or kill_count < 0 then
                notice_multiline(string.format(gameforge.harvest_festival._560_notice, random_rice), notice)
                -- Getting the rice cake
                local cake_count = pc.getqf("cake_count") + random_rice
                pc.setqf("cake_count", cake_count)
                pc.setqf("harvest_festival_mob_complete", 1)
                clear_letter()
                set_state(information)

            end -- end of if
        end -- end of when	
            
        when 1305.kill with pc.getf("harvest_festival","mob2_info") == 5 and party.is_party()  begin
            local kill_count = pc.getqf("mob_kill2_count") + 1
            local random_rice = harvest_festival.get_random_rice(2)
            pc.setqf("mob_kill2_count", kill_count)

            if kill_count < 0 then
                return
            end	-- end of if
        
            q.set_counter("remaining_1305", 60 - kill_count);

            if kill_count >= 60 or kill_count < 0 then


                notice_multiline(string.format(gameforge.harvest_festival._560_notice, random_rice), notice)
                -- Getting the rice cake
                local cake_count = pc.getqf("cake_count") + random_rice
                pc.setqf("cake_count", cake_count)

                pc.setqf("harvest_festival_mob_complete", 1)
                clear_letter()
                set_state(information)

            end -- end of if
        end -- end of when	
        
        when 2205.kill with pc.getf("harvest_festival","mob2_info") == 6  and party.is_party() begin
            local kill_count = pc.getqf("mob_kill2_count") + 1
            local random_rice = harvest_festival.get_random_rice(2) 
            pc.setqf("mob_kill2_count", kill_count)

            if kill_count < 0 then
                return
            end	-- end of if
        
            q.set_counter("remaining_2205", 60 - kill_count);

            if kill_count >= 60 or kill_count < 0 then


                notice_multiline(string.format(gameforge.harvest_festival._560_notice, random_rice), notice)
                -- Getting the rice cake
                local cake_count = pc.getqf("cake_count") + random_rice
                pc.setqf("cake_count", cake_count)

                pc.setqf("harvest_festival_mob_complete", 1)
                clear_letter()
                set_state(information)

            end -- end of if
        end -- end of when	
        
   when 2401.kill with pc.getf("harvest_festival","mob2_info") == 7  and party.is_party() begin
            local kill_count = pc.getqf("mob_kill2_count") + 1
            local random_rice = harvest_festival.get_random_rice(2)
            pc.setqf("mob_kill2_count", kill_count)

            if kill_count < 0 then
                return
            end	-- end of if
        
            q.set_counter("remaining_2401", 60 - kill_count);

            if kill_count >= 60 or kill_count < 0 then


                notice_multiline(string.format(gameforge.harvest_festival._560_notice, random_rice), notice)
                -- Getting the rice cake
                local cake_count = pc.getqf("cake_count") + random_rice
                pc.setqf("cake_count", cake_count)

                pc.setqf("harvest_festival_mob_complete", 1)
                clear_letter()
                set_state(information)

            end -- end of if
        end -- end of when	

        when 2403.kill with pc.getf("harvest_festival","mob2_info") == 8  and party.is_party() begin
            harvest_festival.kill_action(2403,2)
            local kill_count = pc.getqf("mob_kill2_count") + 1
            local random_rice = harvest_festival.get_random_rice(2)
            pc.setqf("mob_kill2_count", kill_count)

            if kill_count < 0 then
                return
            end	-- end of if
        
            q.set_counter("remaining_2403", 60 - kill_count);

            if kill_count >= 60 or kill_count < 0 then
                notice_multiline(string.format(gameforge.harvest_festival._560_notice, random_rice), notice)
                -- Getting the rice cake
                local cake_count = pc.getqf("cake_count") + random_rice
                pc.setqf("cake_count", cake_count)

                pc.setqf("harvest_festival_mob_complete", 1)
                clear_letter()
                set_state(information)

            end -- end of if
        end -- end of when	
    end -- end of state	
end -- end of quest

