#include "inc_isdm"
void main()
{
    object PC = GetEnteringObject();
    SetPlotFlag(PC, FALSE);
    SetImmortal(PC, FALSE);
    ExecuteScript("fixitems", PC);
    if (GetItemPossessedBy(PC, "EmoteWand") == OBJECT_INVALID) CreateItemOnObject("emotewand", PC);
    if (GetItemPossessedBy(PC, "whostone") == OBJECT_INVALID) CreateItemOnObject("whostone", PC);
    if (GetItemPossessedBy(PC, "NW_IT_RECALL") == OBJECT_INVALID) CreateItemOnObject("recall", PC);
    int toys = GetCampaignInt(GetModuleName(), "toys", PC);
    SetLocalInt(PC, "toys", toys);

    int dm = isdm(PC);
    int s, tcnt = GetLocalInt(GetModule(), "tcnt");
    string ref;
    object item;
    for(s=0; s<tcnt; s++) {
        ref = GetLocalString(GetModule(), "tref"+IntToString(s));
        item = GetItemPossessedBy(PC, "toy_"+ref);
        if (((1<<s) & toys) != 0 || dm != 0) {
            if (item == OBJECT_INVALID) item = CreateItemOnObject(ref, PC);
        }
        if (item != OBJECT_INVALID) SetLocalInt(item, "id", s);
    }
    DelayCommand(15.0, AddJournalQuestEntry("welcome", 1, PC, FALSE));
}