/*
Thanks for help from PASSWORD PROTECTED DOOR by mod_urn@yahoo.com
*/

#include "nw_i0_generic"

void main()
{
    int iListen = GetListenPatternNumber();
    string sNewName;

    if(iListen == 777) // listen pattern set in s_listener
    {
        sNewName = GetMatchedSubstring(0);

        if (GetLocalInt(OBJECT_SELF, "iListenFlag") == TRUE)
        {
            //SpeakString("Echo = " + sNewName);
            object oAnvil = GetNearestObjectByTag("pAnvilOfWonder");
            object oItem = GetFirstItemInInventory(oAnvil);
            string sOldName = GetName(oItem);
            SetName(oItem, sNewName);
            SpeakString(sOldName + " is renamed to " + sNewName);
        }
    }

    else if (iListen == -1)
    {
        // Not a match -- start an ordinary conversation
        if (GetCommandable(OBJECT_SELF))
        {
            ClearActions(CLEAR_NW_C2_DEFAULT4_29);
            BeginConversation();
        }
     }

}

