//::///////////////////////////////////////////////
//:: FileName: inc_levelset
//:: Created By: Styzygy
//::
//:: Sets PC to a specified level,
//:: gives PC gold amount per DMG v3.5, pg 43
//:: and wipes inventory so PC is ready for "legal" equipping
//:://////////////////////////////////////////////

int GetIsDMFI(object oItem)
{
    string sItemTag = GetTag(oItem);
    if (
       (sItemTag == "dmfi_pc_dicebag") || (sItemTag == "dmfi_pc_emote") ||
       (sItemTag == "dmfi_pc_follow") || (sItemTag == "dmfi_playerbook") ||
       (sItemTag == "hlslang_1") || (sItemTag == "hlslang_2") ||
       (sItemTag == "hlslang_3") || (sItemTag == "hlslang_4") ||
       (sItemTag == "hlslang_5") || (sItemTag == "hlslang_6") ||
       (sItemTag == "hlslang_7") || (sItemTag == "hlslang_8") ||
       (sItemTag == "hlslang_9") || (sItemTag == "hlslang_10") ||
       (sItemTag == "hlslang_11") || (sItemTag == "hlslang_12") ||
       (sItemTag == "hlslang_13")
       )  return TRUE;
       else return FALSE;
}

void stripInventory(object oTarget)
{
    //for testing
    //AssignCommand(oTarget, SpeakString("stripInventory fired"));

    //valid only for creatures
    //if ( GetObjectType(oTarget) != OBJECT_TYPE_CREATURE) return;

    // set the variables
    int i;
    object oItem = GetFirstItemInInventory(oTarget);

    // destroy unequipped items in inventory
    while ( GetIsObjectValid(oItem) )
        {
        if (!GetIsDMFI(oItem)) DestroyObject(oItem);
        oItem = GetNextItemInInventory(oTarget);
        }
    // destroy equipped items in slots
    for ( i = 0; i < NUM_INVENTORY_SLOTS; i++ )
        {
        oItem = GetItemInSlot(i, oTarget);
        if ( GetIsObjectValid(oItem) )
            DestroyObject(oItem);
        }
}

void setLevel(int iLevel, object oPC)
{
    //testing
    //AssignCommand(oPC, SpeakString("setLevel fired"));

    //strip inventory
    if (GetLocalInt(GetModule(), "iStripInventory") == 1)
        stripInventory(oPC);

    int iGoldToTake = GetGold(oPC);
    TakeGoldFromCreature(iGoldToTake, oPC, TRUE);

    if (iLevel==1)
    {
        SetXP(oPC, 0);
        GiveGoldToCreature(oPC, 300);
    }

    else if (iLevel==2)
    {
        SetXP(oPC, 1000);
        GiveGoldToCreature(oPC, 900);
    }

    else if (iLevel==3)
    {
        SetXP(oPC, 3000);
        GiveGoldToCreature(oPC, 2700);
    }

    else if (iLevel==4)
    {
        SetXP(oPC, 6000);
        GiveGoldToCreature(oPC, 5400);
    }

    else if (iLevel==5)
    {
        SetXP(oPC, 10000);
        GiveGoldToCreature(oPC, 9000);
    }

    else if (iLevel==6)
    {
        SetXP(oPC, 15000);
        GiveGoldToCreature(oPC, 13000);
    }

    else if (iLevel==7)
    {
        SetXP(oPC, 21000);
        GiveGoldToCreature(oPC, 19000);
    }

    else if (iLevel==8)
    {
        SetXP(oPC, 28000);
        GiveGoldToCreature(oPC, 27000);
    }

    else if (iLevel==9)
    {
        SetXP(oPC, 36000);
        GiveGoldToCreature(oPC, 36000);
    }

    else if (iLevel==10)
    {
        SetXP(oPC, 45000);
        GiveGoldToCreature(oPC, 49000);
    }

    else if (iLevel==11)
    {
        SetXP(oPC, 55000);
        GiveGoldToCreature(oPC, 66000);
    }

    else if (iLevel==12)
    {
        SetXP(oPC, 66000);
        GiveGoldToCreature(oPC, 88000);
    }

    else if (iLevel==13)
    {
        SetXP(oPC, 78000);
        GiveGoldToCreature(oPC, 110000);
    }

    else if (iLevel==14)
    {
        SetXP(oPC, 91000);
        GiveGoldToCreature(oPC, 150000);
    }

    else if (iLevel==15)
    {
        SetXP(oPC, 105000);
        GiveGoldToCreature(oPC, 200000);
    }

    else if (iLevel==16)
    {
        SetXP(oPC, 120000);
        GiveGoldToCreature(oPC, 260000);
    }

    else if (iLevel==17)
    {
        SetXP(oPC, 136000);
        GiveGoldToCreature(oPC, 340000);
    }

    else if (iLevel==18)
    {
        SetXP(oPC, 153000);
        GiveGoldToCreature(oPC, 440000);
    }

    else if (iLevel==19)
    {
        SetXP(oPC, 171000);
        GiveGoldToCreature(oPC, 580000);
    }

    else if (iLevel==20)
    {
        SetXP(oPC, 190000);
        GiveGoldToCreature(oPC, 760000);
    }

    else if (iLevel==21)
    {
        SetXP(oPC, 210000);
        GiveGoldToCreature(oPC, 940000);
    }

    else if (iLevel==22)
    {
        SetXP(oPC, 231000);
        GiveGoldToCreature(oPC, 1120000);
    }

    else if (iLevel==23)
    {
        SetXP(oPC, 253000);
        GiveGoldToCreature(oPC, 1300000);
    }

    else if (iLevel==24)
    {
        SetXP(oPC, 276000);
        GiveGoldToCreature(oPC, 1480000);
    }

    else if (iLevel==25)
    {
        SetXP(oPC, 300000);
        GiveGoldToCreature(oPC, 1660000);
    }

    else if (iLevel==26)
    {
        SetXP(oPC, 325000);
        GiveGoldToCreature(oPC, 1840000);
    }

    else if (iLevel==27)
    {
        SetXP(oPC, 351000);
        GiveGoldToCreature(oPC, 2020000);
    }

    else if (iLevel==28)
    {
        SetXP(oPC, 378000);
        GiveGoldToCreature(oPC, 2200000);
    }

    else if (iLevel==29)
    {
        SetXP(oPC, 406000);
        GiveGoldToCreature(oPC, 2380000);
    }

    else if (iLevel==30)
    {
        SetXP(oPC, 435000);
        GiveGoldToCreature(oPC, 2560000);
    }

    else if (iLevel==31)
    {
        SetXP(oPC, 465000);
        GiveGoldToCreature(oPC, 2740000);
    }

    else if (iLevel==32)
    {
        SetXP(oPC, 496000);
        GiveGoldToCreature(oPC, 2920000);
    }

    else if (iLevel==33)
    {
        SetXP(oPC, 528000);
        GiveGoldToCreature(oPC, 3100000);
    }

    else if (iLevel==34)
    {
        SetXP(oPC, 561000);
        GiveGoldToCreature(oPC, 3280000);
    }

    else if (iLevel==35)
    {
        SetXP(oPC, 595000);
        GiveGoldToCreature(oPC, 3460000);
    }

    else if (iLevel==36)
    {
        SetXP(oPC, 630000);
        GiveGoldToCreature(oPC, 3640000);
    }

    else if (iLevel==37)
    {
        SetXP(oPC, 666000);
        GiveGoldToCreature(oPC, 3820000);
    }

    else if (iLevel==38)
    {
        SetXP(oPC, 703000);
        GiveGoldToCreature(oPC, 4000000);
    }

    else if (iLevel==39)
    {
        SetXP(oPC, 741000);
        GiveGoldToCreature(oPC, 4180000);
    }

    else if (iLevel==40)
    {
        SetXP(oPC, 780000);
        GiveGoldToCreature(oPC, 4360000);
    }

    else
        FloatingTextStringOnCreature("Level set failed.", oPC);

}

