def onTalk(self, npc, player):
    htmltext = "<html><body>You are either not carrying out your quest or don't meet the criteria.</body></html>"
    st = player.getQuestState(qn)
    if (not st):
        return htmltext
    npcId = npc.getNpcId()
    id = st.getState()
    if (id == COMPLETED):
        st.setState(CREATED)
        id = CREATED
    progress = st.getInt('progress')
    if (npcId == PM_COOPER):
        if (id == CREATED):
            return check_level(st)
        elif ((id == STARTING) and (progress == 0)):
            return 'Starting.htm'
        else:
            return 'Started.htm'
    elif (npcId == SG_CRONOS):
        if (id == STARTING):
            if (progress == 0):
                return '420_cronos_1.htm'
            elif (progress in [1, 2, 8, 9]):
                return check_stone(st, progress)
            elif (progress in [3, 4, 10, 11]):
                return '420_cronos_9.htm'
            elif (progress in [5, 6, 12, 13]):
                return '420_cronos_11.htm'
            elif (progress == 7):
                return '420_cronos_10.htm'
    elif (npcId == MC_MARIA):
        if (id == STARTING):
            if (((progress in [1, 8]) and (st.getQuestItemsCount(FSN_LIST) == 1)) or ((progress in [2, 9]) and (st.getQuestItemsCount(FSN_LIST_DLX) == 1))):
                return check_elements(st, progress)
            elif (progress in [3, 4, 5, 6, 7, 10, 11]):
                return '420_maria_6.htm'
    elif (npcId == GD_BYRON):
        if (id == STARTING):
            if (((progress in [1, 8]) and (st.getQuestItemsCount(FSN_LIST) == 1)) or ((progress in [2, 9]) and (st.getQuestItemsCount(FSN_LIST_DLX) == 1))):
                return '420_byron_10.htm'
            elif (progress == 7):
                return '420_byron_9.htm'
            elif (((progress == 3) and (st.getQuestItemsCount(FRY_STN) == 1)) or ((progress == 4) and (st.getQuestItemsCount(FRY_STN_DLX) == 1))):
                return '420_byron_1.htm'
            elif ((progress == 10) and (st.getQuestItemsCount(FRY_STN) == 1)):
                st.set('progress', '12')
                return '420_byron_5.htm'
            elif ((progress == 11) and (st.getQuestItemsCount(FRY_STN_DLX) == 1)):
                st.set('progress', '13')
                return '420_byron_6.htm'
            elif (progress in [5, 12]):
                return '420_byron_7.htm'
            elif (progress in [6, 13]):
                return '420_byron_8.htm'
    elif (npcId == FR_MYMYU):
        if (id == STARTING):
            if ((progress in [5, 12]) and (st.getQuestItemsCount(FRY_STN) == 1)):
                return '420_mymyu_1.htm'
            elif ((progress in [6, 13]) and (st.getQuestItemsCount(FRY_STN_DLX) == 1)):
                return '420_mymyu_3.htm'
        elif (id == STARTED):
            if ((progress < 14) and (st.getQuestItemsCount(JUICE) == 1)):
                return '420_mymyu_7.htm'
            elif (progress > 13):
                return check_eggs(st, 'mymyu', progress)
    elif (npcId == DK_EXARION):
        if (id == STARTED):
            if ((progress in [5, 6, 12, 13]) and (st.getQuestItemsCount(JUICE) == 1)):
                st.takeItems(JUICE, 1)
                return '420_exarion_1.htm'
            elif ((progress > 13) and (st.getQuestItemsCount(SCALE_1) == 1)):
                return check_eggs(st, 'exarion', progress)
            elif ((progress in [19, 20]) and (st.getQuestItemsCount(EX_EGG) == 1)):
                return '420_exarion_5.htm'
    elif (npcId == DK_ZWOV):
        if (id == STARTED):
            if ((progress in [5, 6, 12, 13]) and (st.getQuestItemsCount(JUICE) == 1)):
                st.takeItems(JUICE, 1)
                return '420_zwov_1.htm'
            elif ((progress > 13) and (st.getQuestItemsCount(SCALE_2) == 1)):
                return check_eggs(st, 'zwov', progress)
            elif ((progress in [19, 20]) and (st.getQuestItemsCount(ZW_EGG) == 1)):
                return '420_zwov_5.htm'
    elif (npcId == DK_KALIBRAN):
        if (id == STARTED):
            if ((progress in [5, 6, 12, 13]) and (st.getQuestItemsCount(JUICE) == 1)):
                st.takeItems(JUICE, 1)
                return '420_kalibran_1.htm'
            elif ((progress > 13) and (st.getQuestItemsCount(SCALE_3) == 1)):
                return check_eggs(st, 'kalibran', progress)
            elif ((progress in [19, 20]) and (st.getQuestItemsCount(KA_EGG) == 1)):
                return '420_kalibran_6.htm'
    elif (npcId == WM_SUZET):
        if (id == STARTED):
            if ((progress in [5, 6, 12, 13]) and (st.getQuestItemsCount(JUICE) == 1)):
                st.takeItems(JUICE, 1)
                return '420_suzet_1.htm'
            elif ((progress > 13) and (st.getQuestItemsCount(SCALE_4) == 1)):
                return check_eggs(st, 'suzet', progress)
            elif ((progress in [19, 20]) and (st.getQuestItemsCount(SU_EGG) == 1)):
                return '420_suzet_6.htm'
    elif (npcId == WM_SHAMHAI):
        if (id == STARTED):
            if ((progress in [5, 6, 12, 13]) and (st.getQuestItemsCount(JUICE) == 1)):
                st.takeItems(JUICE, 1)
                return '420_shamhai_1.htm'
            elif ((progress > 13) and (st.getQuestItemsCount(SCALE_5) == 1)):
                return check_eggs(st, 'shamhai', progress)
            elif ((progress in [19, 20]) and (st.getQuestItemsCount(SH_EGG) == 1)):
                return '420_shamhai_5.htm'
    return '<html><body>I have nothing to say to you</body></html>'
def onTalk(self, npc, player):
    htmltext = "<html><body>You are either not carrying out your quest or don't meet the criteria.</body></html>"
    st = player.getQuestState(qn)
    if (not st):
        return htmltext
    npcId = npc.getNpcId()
    id = st.getState()
    if (id == COMPLETED):
        st.setState(CREATED)
        id = CREATED
    progress = st.getInt('progress')
    if (npcId == PM_COOPER):
        if (id == CREATED):
            return check_level(st)
        elif ((id == STARTING) and (progress == 0)):
            return 'Starting.htm'
        else:
            return 'Started.htm'
    elif (npcId == SG_CRONOS):
        if (id == STARTING):
            if (progress == 0):
                return '420_cronos_1.htm'
            elif (progress in [1, 2, 8, 9]):
                return check_stone(st, progress)
            elif (progress in [3, 4, 10, 11]):
                return '420_cronos_9.htm'
            elif (progress in [5, 6, 12, 13]):
                return '420_cronos_11.htm'
            elif (progress == 7):
                return '420_cronos_10.htm'
    elif (npcId == MC_MARIA):
        if (id == STARTING):
            if (((progress in [1, 8]) and (st.getQuestItemsCount(FSN_LIST) == 1)) or ((progress in [2, 9]) and (st.getQuestItemsCount(FSN_LIST_DLX) == 1))):
                return check_elements(st, progress)
            elif (progress in [3, 4, 5, 6, 7, 10, 11]):
                return '420_maria_6.htm'
    elif (npcId == GD_BYRON):
        if (id == STARTING):
            if (((progress in [1, 8]) and (st.getQuestItemsCount(FSN_LIST) == 1)) or ((progress in [2, 9]) and (st.getQuestItemsCount(FSN_LIST_DLX) == 1))):
                return '420_byron_10.htm'
            elif (progress == 7):
                return '420_byron_9.htm'
            elif (((progress == 3) and (st.getQuestItemsCount(FRY_STN) == 1)) or ((progress == 4) and (st.getQuestItemsCount(FRY_STN_DLX) == 1))):
                return '420_byron_1.htm'
            elif ((progress == 10) and (st.getQuestItemsCount(FRY_STN) == 1)):
                st.set('progress', '12')
                return '420_byron_5.htm'
            elif ((progress == 11) and (st.getQuestItemsCount(FRY_STN_DLX) == 1)):
                st.set('progress', '13')
                return '420_byron_6.htm'
            elif (progress in [5, 12]):
                return '420_byron_7.htm'
            elif (progress in [6, 13]):
                return '420_byron_8.htm'
    elif (npcId == FR_MYMYU):
        if (id == STARTING):
            if ((progress in [5, 12]) and (st.getQuestItemsCount(FRY_STN) == 1)):
                return '420_mymyu_1.htm'
            elif ((progress in [6, 13]) and (st.getQuestItemsCount(FRY_STN_DLX) == 1)):
                return '420_mymyu_3.htm'
        elif (id == STARTED):
            if ((progress < 14) and (st.getQuestItemsCount(JUICE) == 1)):
                return '420_mymyu_7.htm'
            elif (progress > 13):
                return check_eggs(st, 'mymyu', progress)
    elif (npcId == DK_EXARION):
        if (id == STARTED):
            if ((progress in [5, 6, 12, 13]) and (st.getQuestItemsCount(JUICE) == 1)):
                st.takeItems(JUICE, 1)
                return '420_exarion_1.htm'
            elif ((progress > 13) and (st.getQuestItemsCount(SCALE_1) == 1)):
                return check_eggs(st, 'exarion', progress)
            elif ((progress in [19, 20]) and (st.getQuestItemsCount(EX_EGG) == 1)):
                return '420_exarion_5.htm'
    elif (npcId == DK_ZWOV):
        if (id == STARTED):
            if ((progress in [5, 6, 12, 13]) and (st.getQuestItemsCount(JUICE) == 1)):
                st.takeItems(JUICE, 1)
                return '420_zwov_1.htm'
            elif ((progress > 13) and (st.getQuestItemsCount(SCALE_2) == 1)):
                return check_eggs(st, 'zwov', progress)
            elif ((progress in [19, 20]) and (st.getQuestItemsCount(ZW_EGG) == 1)):
                return '420_zwov_5.htm'
    elif (npcId == DK_KALIBRAN):
        if (id == STARTED):
            if ((progress in [5, 6, 12, 13]) and (st.getQuestItemsCount(JUICE) == 1)):
                st.takeItems(JUICE, 1)
                return '420_kalibran_1.htm'
            elif ((progress > 13) and (st.getQuestItemsCount(SCALE_3) == 1)):
                return check_eggs(st, 'kalibran', progress)
            elif ((progress in [19, 20]) and (st.getQuestItemsCount(KA_EGG) == 1)):
                return '420_kalibran_6.htm'
    elif (npcId == WM_SUZET):
        if (id == STARTED):
            if ((progress in [5, 6, 12, 13]) and (st.getQuestItemsCount(JUICE) == 1)):
                st.takeItems(JUICE, 1)
                return '420_suzet_1.htm'
            elif ((progress > 13) and (st.getQuestItemsCount(SCALE_4) == 1)):
                return check_eggs(st, 'suzet', progress)
            elif ((progress in [19, 20]) and (st.getQuestItemsCount(SU_EGG) == 1)):
                return '420_suzet_6.htm'
    elif (npcId == WM_SHAMHAI):
        if (id == STARTED):
            if ((progress in [5, 6, 12, 13]) and (st.getQuestItemsCount(JUICE) == 1)):
                st.takeItems(JUICE, 1)
                return '420_shamhai_1.htm'
            elif ((progress > 13) and (st.getQuestItemsCount(SCALE_5) == 1)):
                return check_eggs(st, 'shamhai', progress)
            elif ((progress in [19, 20]) and (st.getQuestItemsCount(SH_EGG) == 1)):
                return '420_shamhai_5.htm'
    return '<html><body>I have nothing to say to you</body></html>'