#include "inc_isdm"
#include "av_persist"
void main()
{
    object oPC = GetEnteringObject();
    ExecuteScript("_visit_counter_e", OBJECT_SELF);
//    DelayCommand (4.0,ExecuteScript("av_onenter", OBJECT_SELF));
    LodPlayer(oPC);
    if(GetIsDM(oPC))
        return;//dont mess with DMs
    if(GetXP(oPC)== 1)
    {
    GiveXPToCreature(oPC,3000);
    GiveGoldToCreature(oPC, 10000);
    }
//    object PC = GetEnteringObject();
//    ExecuteScript("fixitems", PC);
    if (GetItemPossessedBy(oPC, "EmoteWand") == OBJECT_INVALID) CreateItemOnObject("emotewand", oPC);
    if (GetItemPossessedBy(oPC, "whostone") == OBJECT_INVALID) CreateItemOnObject("whostone", oPC);
    if (GetItemPossessedBy(oPC, "NW_IT_RECALL") == OBJECT_INVALID) CreateItemOnObject("recall", oPC);
    int toys = GetCampaignInt(GetModuleName(), "toys", oPC);
    SetLocalInt(oPC, "toys", toys);

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