//::////////////////////////////////////////////////////
//:: NW_O2_CONINCLUDE.nss
//:: Copyright (c) 2001 Bioware Corp.
//::////////////////////////////////////////////////
/*
  This include file handles the random treasure
  distribution for treasure from containers

 [ ] Documented
*/
//:://////////////////////////////////////////////
//:: Created By:  Brent, Andrew
//:: Created On:  November - May
//::///////////////////////////////////////////////
// :: MODS
// April 23 2002: Removed animal parts. They were silly.
// May 6 2002: Added Undead to the EXCLUSION treasure list (they drop nothing now)
//  - redistributed treasure (to lessen amount of armor and increase 'class specific treasure'
//  - Rangers with heavy armor prof. will be treated as Fighters else as Barbarians
//  - Gave wizards, druids and monk their own function
// MAY 29 2002: Removed the heal potion from treasure
//              Moved nymph cloak +4 to treasure bracket 6
//              Added Monk Enhancement items to random treasure

// * ---------
// * CONSTANTS
// * ---------


// * tweaking constants

    // * SIX LEVEL RANGES
    const int RANGE_1_MIN = 0;
    const int RANGE_1_MAX = 5;
    const int RANGE_2_MIN = 6;
    const int RANGE_2_MAX = 8;

    const int RANGE_3_MIN = 9;
    const int RANGE_3_MAX = 10;

    const int RANGE_4_MIN = 11;
    const int RANGE_4_MAX = 13;

    const int RANGE_5_MIN = 14;
    const int RANGE_5_MAX = 16;

    const int RANGE_6_MIN = 17;
    const int RANGE_6_MAX = 100;

    // * NUMBER OF ITEMS APPEARING
    const int NUMBER_LOW_ONE   = 100; const int NUMBER_MED_ONE    = 60; const int NUMBER_HIGH_ONE   = 40;  const int NUMBER_BOSS_ONE = 100;
    const int NUMBER_LOW_TWO   = 0;   const int NUMBER_MED_TWO    = 30; const int NUMBER_HIGH_TWO   = 40;  const int NUMBER_BOSS_TWO = 0;
    const int NUMBER_LOW_THREE = 0;   const int NUMBER_MED_THREE  = 10; const int NUMBER_HIGH_THREE = 20;  const int NUMBER_BOSS_THREE = 0;

    const int NUMBER_BOOK_ONE = 75;
    const int NUMBER_BOOK_TWO = 20;
    const int NUMBER_BOOK_THREE = 5;

    // * AMOUNT OF GOLD BY VALUE
    const float LOW_MOD_GOLD = 0.5;   const float MEDIUM_MOD_GOLD = 1.0; const float HIGH_MOD_GOLD = 3.0;
    // * FREQUENCY OF ITEM TYPE APPEARING BY TREASURE TYPE
    const int LOW_PROB_BOOK    = 1;  const int MEDIUM_PROB_BOOK =   1;  const int HIGH_PROB_BOOK =1;
    const int LOW_PROB_ANIMAL  = 0;  const int MEDIUM_PROB_ANIMAL = 0;  const int HIGH_PROB_ANIMAL = 0;
    const int LOW_PROB_JUNK    = 2;  const int MEDIUM_PROB_JUNK =    1;  const int HIGH_PROB_JUNK = 1;
    const int LOW_PROB_GOLD = 43;    const int MEDIUM_PROB_GOLD =   38; const int HIGH_PROB_GOLD = 15;
    const int LOW_PROB_GEM  = 9;     const int MEDIUM_PROB_GEM =    15; const int HIGH_PROB_GEM = 15;
    const int LOW_PROB_JEWEL = 4;    const int MEDIUM_PROB_JEWEL =  6; const int HIGH_PROB_JEWEL = 15;
    const int LOW_PROB_ARCANE = 3;   const int MEDIUM_PROB_ARCANE = 3; const int HIGH_PROB_ARCANE = 3;
    const int LOW_PROB_DIVINE = 3;   const int MEDIUM_PROB_DIVINE = 3;  const int HIGH_PROB_DIVINE = 3;
    const int LOW_PROB_AMMO = 10;    const int MEDIUM_PROB_AMMO =   5;  const int HIGH_PROB_AMMO  =   3;
    const int LOW_PROB_KIT = 5;      const int MEDIUM_PROB_KIT =    5;  const int HIGH_PROB_KIT   =   5;
    const int LOW_PROB_POTION =17;   const int MEDIUM_PROB_POTION = 20; const int HIGH_PROB_POTION=   9;
    const int LOW_PROB_TABLE2 = 3;   const int MEDIUM_PROB_TABLE2 = 3; const int HIGH_PROB_TABLE2=   30;


// * readability constants

const int    TREASURE_LOW = 1;
const int    TREASURE_MEDIUM = 2;
const int    TREASURE_HIGH = 3;
const int    TREASURE_BOSS = 4;
const int    TREASURE_BOOK = 5;


// * JUMP_LEVEL is used in a Specific item function
// * in the case where a generic item is called for within that function
// * it will create a generic item by adding JUMP_LEVEL to the character's
// * hit die for the purposes of the treasure evaluation.
// * May 2002: Lowered JUMP_LEVEL from 3 to 2

const int JUMP_LEVEL = 2;


//* Declarations
    void CreateGenericExotic(object oTarget, object oAdventurer, int nModifier = 0);
    void CreateGenericMonkWeapon(object oTarget, object oAdventurer, int nModifier = 0);
    void CreateSpecificMonkWeapon(object oTarget, object oAdventurer, int nModifier = 0);
    void CreateGenericDruidWeapon(object oTarget, object oAdventurer, int nModifier = 0);
    void CreateSpecificDruidWeapon(object oTarget, object oAdventurer, int nModifier = 0);
    void CreateGenericWizardWeapon(object oTarget, object oAdventurer, int nModifier = 0);
    void CreateSpecificWizardWeapon(object oTarget, object oAdventurer, int nModifier = 0);
    int nDetermineClassToUse(object oCharacter);
	
	// * Returns the object that either last opened the container or destroyed it
	object GetLastOpener();

 // Removes every item from the chest
void RemoveItems(object oChest);

// *
// * IMPLEMENTATION
// *

// * Comment the speakstring in to debug treasure generation
void dbSpeak(string s)
{
//   SpeakString(s);
}
void RemoveItems(object oChest)

{
object oItem;
object oStrip;

oItem=GetFirstItemInInventory(oChest);

while (GetIsObjectValid(oItem))

 {
 oStrip=oItem;
 DestroyObject(oStrip);
 oItem=GetNextItemInInventory(oChest);
 }
}

//* made this function to help with debugging
void dbCreateItemOnObject(string sItemTemplate, object oTarget = OBJECT_SELF, int nStackSize = 1)
{
/*
    if (sItemTemplate == "")
    {
        PrintString("blank item passed into dbCreateItemOnObject. Please report as bug to Brent.");
    }
    dbSpeak(sItemTemplate);
*/

    //sItemTemplate = GetStringLowerCase

    if (nStackSize == 1)
    {
        // * checks to see if this is a throwing item and if it is
        // * it creates more

        string sRoot = GetSubString(sItemTemplate, 0, 6);
        //dbSpeak("ROOT: " + sRoot);
        if (GetStringLowerCase(sRoot) == "nw_wth")
        {
            nStackSize = Random(30) + 1;
        }
    }
    object oItem = CreateItemOnObject(sItemTemplate, oTarget, nStackSize);
/*
    if (GetIsObjectValid(oItem) == FALSE && sItemTemplate != "NW_IT_GOLD001")
    {

        // * check to see if item is there in a stack, if not give warning
        if (GetIsObjectValid(GetItemPossessedBy(oTarget, GetStringUpperCase(sItemTemplate))) == FALSE &&
            GetIsObjectValid(GetItemPossessedBy(oTarget, GetStringLowerCase(sItemTemplate))) == FALSE)
        {
            PrintString("**DESIGN***");
            PrintString("******" + sItemTemplate + " is an invalid item template. Please report as bug to Brent.");
            PrintString("*******");
        }
    }
*/
}


// *
// * GET FUNCTIONS
// *

// * Returns the object that either last opened the container or destroyed it
object GetLastOpener()
{
    if (GetIsObjectValid(GetLastOpenedBy()) == TRUE)
    {
        //dbSpeak("LastOpener: GetLastOpenedBy " + GetTag(GetLastOpenedBy()));
        return GetLastOpenedBy();
    }
    else
    if (GetIsObjectValid(GetLastKiller()) == TRUE)
    {
        //dbSpeak("LastOpener: GetLastAttacker");
        return GetLastKiller();
    }
    //dbSpeak("LastOpener: The Object is Invalid you weenie!");
    return OBJECT_INVALID;
}

//::///////////////////////////////////////////////
//:: GetRange
//:: Copyright (c) 2002 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Returns true if nHD matches the correct
    level range for the indicated nCategory.
    (i.e., First to Fourth level characters
    are considered Range1)
*/
//:://////////////////////////////////////////////
//:: Created By:  Brent
//:: Created On:
//:://////////////////////////////////////////////
int GetRange(int nCategory, int nHD)
{
    int nMin = 0; int nMax = 0;
    switch (nCategory)
    {
        case 6: nMin = RANGE_6_MIN; nMax = RANGE_6_MAX; break;
        case 5: nMin = RANGE_5_MIN; nMax = RANGE_5_MAX; break;
        case 4: nMin = RANGE_4_MIN; nMax = RANGE_4_MAX; break;
        case 3: nMin = RANGE_3_MIN; nMax = RANGE_3_MAX; break;
        case 2: nMin = RANGE_2_MIN; nMax = RANGE_2_MAX; break;
        case 1: nMin = RANGE_1_MIN; nMax = RANGE_1_MAX; break;
    }

   //dbSpeak("nMin = " + IntToString(nMin));
   //dbSpeak("nMax = " + IntToString(nMax));
   //dbSpeak("GetRange.nHD = " + IntToString(nHD));
   if (nHD >= nMin && nHD <= nMax)
   {
    return TRUE;
   }

  return FALSE;

}

//::///////////////////////////////////////////////
//:: GetNumberOfItems
//:: Copyright (c) 2002 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Returns the number of items to create.
*/
//:://////////////////////////////////////////////
//:: Created By:  Brent
//:: Created On:
//:://////////////////////////////////////////////
int GetNumberOfItems(int nTreasureType)
{
    int nItems = 0;
    int nRandom = 0;

    int nProbThreeItems = 0;
    int nProbTwoItems = 0;
    int nProbOneItems = 0;

    if (nTreasureType == TREASURE_LOW)
    {
     nProbThreeItems = NUMBER_LOW_THREE;
     nProbTwoItems = NUMBER_LOW_TWO;
     nProbOneItems = NUMBER_LOW_ONE;
    }
    else
    if (nTreasureType == TREASURE_MEDIUM)
    {
     nProbThreeItems = NUMBER_MED_THREE;
     nProbTwoItems = NUMBER_MED_TWO;
     nProbOneItems = NUMBER_MED_ONE;
    }
    else
    if (nTreasureType == TREASURE_HIGH)
    {
     nProbThreeItems = NUMBER_HIGH_THREE;
     nProbTwoItems = NUMBER_HIGH_TWO;
     nProbOneItems = NUMBER_HIGH_ONE;
    }
    else
    if (nTreasureType == TREASURE_BOSS)
    {
     nProbThreeItems = NUMBER_BOSS_THREE;
     nProbTwoItems = NUMBER_BOSS_TWO;
     nProbOneItems = NUMBER_BOSS_ONE;
    }
    else
    if (nTreasureType == TREASURE_BOOK)
    {
     nProbThreeItems = NUMBER_BOOK_THREE;
     nProbTwoItems = NUMBER_BOOK_TWO;
     nProbOneItems = NUMBER_BOOK_ONE;
    }


    nRandom = d100();
    if (nRandom <= nProbThreeItems)
    {
        nItems = 3;
    }
    else
    if (nRandom <= nProbTwoItems + nProbThreeItems)
    {
        nItems = 2;
    }
    else
    {
        nItems = 1;
    }


    int nSpotskill=GetSkillRank(SKILL_SEARCH, GetLastOpener());
    if (nSpotskill>0)
    {
      if (GetIsSkillSuccessful(GetLastOpener(), SKILL_SEARCH,21))
      {
      nItems=nItems+1;
      }
    }
    
    // * May 13 2002: Cap number of items, in case of logic error
    if (nItems > 3)
    {
        nItems = 3;
    }

    return nItems;
}


// *
// * TREASURE GENERATION FUNCTIONS
// *
    // *
    // * Non-Scaling Treasure
    // *
    void CreateBook(object oTarget)
    {
        string sRes;
        // Palmer - make our own books drop as loot
        // once I can find a way to stop it happening in
        // IWD areas
        if (1)
        {
        int nBook1 = Random(31) + 1;
         sRes = "NW_IT_BOOK01";

        if (nBook1 < 10)
        {
            sRes = "NW_IT_BOOK00" + IntToString(nBook1);
        }
        else
        {
            sRes = "NW_IT_BOOK0" + IntToString(nBook1);
        }
        //dbSpeak("Create book");
        dbCreateItemOnObject(sRes, oTarget);
    }
        else
        {
        int nResult=Random(12)+1;

        switch (nResult)
        {
            case 1: sRes = "jw_wildm_book"; break;
            case 2: sRes = "jw_book1"; break;
            case 3: sRes = "jw_book8"; break;
            case 4: sRes = "jw_dwarf_book1"; break;
            case 5: sRes = "jw_dwarf_book4"; break;
            case 6: sRes = "jw_book14"; break;
            case 7: sRes = "jw_book6"; break;
             case 8: sRes = "jw_book3"; break;
              case 9: sRes = "jw_book12"; break;
             case 10: sRes = "jw_book15"; break;
           case 11: sRes = "jw_book7"; break;
           case 12: sRes = "jw_dwarf_book5"; break;
        }
        }


        dbCreateItemOnObject(sRes, oTarget);
    }

    void CreateAnimalPart(object oTarget)
    {

        string sRes = "";
        int nResult = Random(3) + 1;
        switch (nResult)
        {
            case 1: sRes = "NW_IT_MSMLMISC20"; break;
            case 2: sRes = "NW_IT_MMIDMISC05"; break;
            case 3: sRes = "NW_IT_MMIDMISC06"; break;
        }
        //dbSpeak("animal");
        dbCreateItemOnObject(sRes, oTarget);
    }

    void CreateJunk(object oTarget)
    {
        string sRes = "NW_IT_TORCH001";
        int NUM_ITEMS = 6;
        int nResult = Random(NUM_ITEMS) + 1;
        int nKit = 0;
        switch (nResult)
        {
            case 1: sRes = "NW_IT_MPOTION021"; break; //ale
            case 2: sRes = "NW_IT_MPOTION021"; break;   // ale
            case 3: sRes = "NW_IT_MPOTION023"; break; // wine
            case 4: sRes = "NW_IT_MPOTION021"; break; // ale
            case 5: sRes = "NW_IT_MPOTION022"; break; // spirits
            case 6: sRes = "NW_IT_TORCH001"; break; //torch
        }
        //dbSpeak("CreateJunk");
        dbCreateItemOnObject(sRes, oTarget);
    }
    // *
    // * Scaling Treasure
    // *
    void CreateGold(object oTarget, object oAdventurer, int nTreasureType, int nModifier = 0)
    {
        int nHD = GetHitDice(oAdventurer) + nModifier;

        if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }




        int nAmount = 0;

        if (GetRange(1, nHD))
        {
            nAmount = d10();
        }
        else if (GetRange(2, nHD))
        {
            nAmount = d20();
        }
        else if (GetRange(3, nHD))
        {
            nAmount = d20(2);
        }
        else if (GetRange(4, nHD))
        {
            nAmount = d20(5);
        }
        else if (GetRange(5, nHD))
        {
            nAmount = d20(8);
        }
        else if (GetRange(6, nHD))
        {
            nAmount = d20(10);
        }
        float nMod = 0.0;
        if (nTreasureType == TREASURE_LOW) nMod = LOW_MOD_GOLD;
        else if (nTreasureType == TREASURE_MEDIUM) nMod = MEDIUM_MOD_GOLD;
        else if (nTreasureType == TREASURE_HIGH) nMod = HIGH_MOD_GOLD;

        // * always at least 1gp is created
        nAmount = FloatToInt(nAmount * nMod);
        if (nAmount <= 0)
        {
            nAmount = 1;
        }
        //dbSpeak("gold");
        dbCreateItemOnObject("NW_IT_GOLD001", oTarget, nAmount);
    }
    void CreateGem(object oTarget, object oAdventurer, int nTreasureType, int nModifier = 0)
    {
        int nHD = GetHitDice(oAdventurer) + nModifier;

         if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }

        string sGem = "nw_it_gem001";          // *** Greenstone ***
        if (GetRange(1, nHD))
        {
            int nRandom = Random(10) + 1;
            switch (nRandom)
            {
                case 1: sGem = "nw_it_gem001";  break;          // *** Greenstone ***
                case 2: sGem = "nw_it_gem007";  break;          // *** Malachite ***
                case 3: sGem = "nw_it_gem002";  break;          // *** Fire Agate ***
                case 4: case 5: sGem = "nw_it_gem004"; break;          // *** Phenalope ***
                case 6: case 7: sGem = "nw_it_gem014"; break;          // *** Aventurine ***
                case 8: sGem = "nw_it_gem003";         break;          // *** Amethyst ***
                case 9: sGem = "nw_it_gem015";         break;          // *** Fluorspar ***
                case 10: sGem = "nk_garnetlrguc";         break;          // *** Uncut Large Garnet ***
            }
        }
        else if (GetRange(2, nHD))               // 30 GP Avg; 150 gp Max
        {
            int nRandom = Random(13) + 1;
            switch (nRandom)
            {
                case 1: sGem = "nw_it_gem001";         break;          // *** Greenstone ***
                case 2: sGem = "nw_it_gem007";         break;          // *** Malachite ***
                case 3: sGem = "nw_it_gem002";         break;          // *** Fire Agate ***
                case 4: sGem = "nw_it_gem004";         break;          // *** Phenalope ***
                case 5: case 6: sGem = "nw_it_gem014";  break;          // *** Aventurine ***
                case 7: case 8: sGem = "nw_it_gem003";  break;          // *** Amethyst ***
                case 9: case 10: sGem = "nw_it_gem015"; break;          // *** Fluorspar ***
                case 11: sGem = "nw_it_gem011";         break;          // *** Garnet ***
                case 12: sGem = "nw_it_gem013";         break;          // *** Alexandrite ***
                case 13: sGem = "nk_garnetlrguc";         break;          // *** Uncut Large Garnet ***

            }

        }
        else if (GetRange(3, nHD))  // 75GP Avg; 500 gp max
        {
            int nRandom = Random(11) + 1;
            switch (nRandom)
            {
                case 1: case 2: case 3: case 4: case 5: sGem = "nw_it_gem013";         break;          // *** Alexandrite ***
                case 6: case 7: case 8: case 9: case 10: sGem = "nw_it_gem010";         break;          // *** Topaz ***
                case 11: sGem = "nk_garnetlrguc";         break;          // *** Uncut Large Garnet ***

            }

        }
        else if (GetRange(4, nHD))  // 150 gp avg; 1000 gp max
        {
            int nRandom = Random(11) + 1;
            switch (nRandom)
            {
                case 1: case 2: case 3: sGem = "nw_it_gem013";  break;          // *** Alexandrite ***
                case 4: case 5: case 6: sGem = "nw_it_gem010";    break;          // *** Topaz ***
                case 7: case 8: case 9: sGem = "nw_it_gem008";           break;          // *** Sapphire ***
                case 10: sGem = "nk_garnetlrguc";         break;          // *** Uncut Large Garnet ***
                case 11: sGem = "nk_rhodoliteuc";         break;          // *** Uncut Rhodolite ***

            }
        }
        else if (GetRange(5, nHD))  // 300 gp avg; any
        {
            int nRandom = Random(11) + 1;
            switch (nRandom)
            {
                case 1: case 2: case 3: sGem = "nw_it_gem013";  break;          // *** Alexandrite ***
                case 4: case 5: case 6: sGem = "nw_it_gem010";    break;          // *** Topaz ***
                case 7: case 8: case 9: sGem = "nw_it_gem008";           break;          // *** Sapphire ***
                case 10: sGem = "nk_garnetlrguc";         break;          // *** Uncut Large Garnet ***
                case 11: sGem = "nk_rhodoliteuc";         break;          // *** Uncut Rhodolite ***

            }
        }
        else if (GetRange(6, nHD))// * Anything higher than level 15    500 gp avg; any
        {
            int nRandom = Random(10) + 1;
            switch (nRandom)
            {
                case 1: sGem = "nw_it_gem013";  break;          // *** Alexandrite ***
                case 2: sGem = "nw_it_gem010";    break;          // *** Topaz ***
                case 3: case 4: sGem = "nw_it_gem008";           break;          // *** Sapphire ***
                case 5: sGem = "nw_it_gem009";           break;          // *** Fire Opal ***
                case 6: sGem = "nw_it_gem009";           break;          // *** Fire Opal ***
                case 7: sGem = "nw_it_gem006";           break;          // *** Ruby ***
                case 8: sGem = "nw_it_gem010";           break;          // *** Topaz ***
                case 9: sGem = "nk_garnetlrguc";         break;          // *** Uncut Large Garnet ***
                case 10: sGem = "nk_rhodoliteuc";         break;          // *** Uncut Rhodolite ***

            }
        }
       if (sGem=="nk_garnetlrguc")
       {
         if(d20()>2)
          {
          sGem="nw_it_gem007";
          }
       }
       if (sGem=="nk_rhodoliteuc")
       {
         if(d20()>2)
          {
          sGem="nw_it_gem013";
          }
       }

      dbCreateItemOnObject(sGem, oTarget, 1);
    }
    void CreateJewel(object oTarget, object oAdventurer, int nTreasureType, int nModifier = 0)
    {
        int nHD = GetHitDice(oAdventurer) + nModifier;

         if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }



        string sJewel = "";

        if (GetRange(1, nHD))        // 15 gp avg; 75 gp max
        {
          int nRandom = d2();
          switch (nRandom)
          {
            case 1: sJewel = "nw_it_mring021";   break;          // *** Emerald ***
            case 2: sJewel = "nw_it_mneck020";   break;          // *** Emerald ***
          }
        }
        else if (GetRange(2, nHD))   // 30 GP Avg; 150 gp Max
        {
          int nRandom = d6();
          switch (nRandom)
          {
            case 1: sJewel = "nw_it_mring021";            break;          // *** Emerald ***
            case 2: case 3: sJewel = "nw_it_mneck020";    break;          // *** Emerald ***
            case 4: sJewel = "nw_it_mring022";            break;          // *** Emerald ***
            case 5: case 6: sJewel = "nw_it_mneck023";            break;          }          // *** Emerald ***
        }
        else if (GetRange(3, nHD))  // 75GP Avg; 500 gp max
        {
          int nRandom = d6();
          switch (nRandom)
          {
            case 1: sJewel = "nw_it_mring021";           break;          // *** Emerald ***
            case 2: case 3: sJewel = "nw_it_mneck020";   break;          // *** Emerald ***
            case 4: case 5: sJewel = "nw_it_mring022";   break;          // *** Emerald ***
            case 6: sJewel = "nw_it_mneck021";           break;          // *** Emerald ***
          }
        }
        else if (GetRange(4, nHD))  // 150 gp avg; 1000 gp max
        {
          int nRandom = d6();
          switch (nRandom)
          {
            case 1: sJewel = "nw_it_mring021";            break;          // *** Emerald ***
            case 2: sJewel = "nw_it_mring022";            break;          // *** Emerald ***
            case 3: case 4: case 5: sJewel = "nw_it_mneck021";    break;          // *** Emerald ***
            case 6: sJewel = "nw_it_mring023";            break;          // *** Emerald ***
          }
        }
        else if (GetRange(5, nHD))  // 300 gp avg; any
        {
          int nRandom = d8();
          switch (nRandom)
          {
            case 1: sJewel = "nw_it_mring022";           break;          // *** Emerald ***
            case 2: case 3: sJewel = "nw_it_mneck021";   break;          // *** Emerald ***
            case 4: case 5: case 6: sJewel = "nw_it_mring023"; break;          // *** Emerald ***
            case 7: case 8: sJewel = "nw_it_mneck022";               break;          // *** Emerald ***
          }
        }
        else if (GetRange(6, nHD))
        {
          int nRandom = d6();
          switch (nRandom)
          {
            case 1: sJewel = "nw_it_mring022";              break;          // *** Emerald ***
            case 2: sJewel = "nw_it_mneck021";              break;          // *** Emerald ***
            case 3: case 4: sJewel = "nw_it_mring023";      break;          // *** Emerald ***
            case 5: case 6: sJewel = "nw_it_mneck022";      break;          // *** Emerald ***
          }
        }
      //dbSpeak("Create Jewel");

      dbCreateItemOnObject(sJewel, oTarget, 1);

    }
    // * returns the valid upper limit for any arcane spell scroll
    int TrimLevel(int nScroll, int nLevel)
    {   int nMax = 5;
        switch (nLevel)
        {
            case 0: nMax = 4; break;
            case 1: nMax = 13; break;
            case 2: nMax = 21; break;
            case 3: nMax = 15; break;
            case 4: nMax = 17; break;
            case 5: nMax = 13; break;
            case 6: nMax = 14; break;
            case 7: nMax = 8; break;
            case 8: nMax = 9; break;
            case 9: nMax = 12; break;
        }
        if (nScroll > nMax) nScroll = nMax;
        return nScroll;

    }
    // * nModifier is to 'raise' the level of the oAdventurer
    void CreateArcaneScroll(object oTarget, object oAdventurer, int nModifier = 0)
    {
        int nMaxSpells = 21;
        int nHD = GetHitDice(oAdventurer) + nModifier;

         if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }



        int nScroll = 1;
        int nLevel = 1;

        if (GetRange(1, nHD))           // l 1-2
        {
          nLevel = d2();
          nScroll =  Random(nMaxSpells) + 1;
        }
        else if (GetRange(2, nHD))      // l 1-4
        {
          nLevel = d4();
          nScroll =  Random(nMaxSpells) + 1;
        }
        else if (GetRange(3, nHD))    // l 2-6
        {
          nLevel = d6();
          if (nLevel < 2) nLevel = 2;

          nScroll =  Random(nMaxSpells) + 1;
        }
        else if (GetRange(4, nHD))   // l 3-8
        {
          nLevel = d8();
          if (nLevel < 3) nLevel = 3;

          nScroll =  Random(nMaxSpells) + 1;
        }
        else if (GetRange(5, nHD))   // l 4-9
        {
          nLevel = d8() + 1;
          if (nLevel < 4) nLevel = 4;

          nScroll =  Random(nMaxSpells) + 1;
        }
        else if (GetRange(6, nHD))   // 5 -9
        {
          nLevel = d8() + 1;
          if (nLevel < 5) nLevel = 5;

          nScroll =  Random(nMaxSpells) + 1;
        }

        // * Trims the level of the scroll to match the max # of scrolls in each level range
        nScroll = TrimLevel(nScroll, nLevel);

        string sRes = "nw_it_sparscr216";          // *** Knock ***

        if (nScroll < 10)
        {
            sRes = "NW_IT_SPARSCR" + IntToString(nLevel) + "0" + IntToString(nScroll);
        }
        else
        {
            sRes = "NW_IT_SPARSCR" + IntToString(nLevel) + IntToString(nScroll);
        }
          dbCreateItemOnObject(sRes, oTarget, 1);
        }

    void CreateDivineScroll(object oTarget, object oAdventurer, int nModifier=0)
    {
        int nHD = GetHitDice(oAdventurer) + nModifier;

         if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }

        string sScroll = "";
        if (GetRange(1, nHD))
        {
            int nRandom = d4();
            switch (nRandom)
            {
                case 1: sScroll = "nw_it_spdvscr201"; break;          // *** Lesser Restoration ***
                case 2: sScroll = "nw_it_spdvscr202"; break;          // *** Charm Person or Animal ***
                case 3: sScroll = "nw_it_spdvscr203"; break;          // *** Silence ***
                case 4: sScroll = "nw_it_spdvscr204"; break;          // *** Sound Burst ***
            }
        }
        else if (GetRange(2, nHD))
        {
            int nRandom = d8();
            switch (nRandom)
            {
                case 1: sScroll = "nw_it_spdvscr201"; break;          // *** Lesser Restoration ***
                case 2: sScroll = "nw_it_spdvscr202";break;          // *** Charm Person or Animal ***
                case 3: sScroll = "nw_it_spdvscr203"; break;          // *** Silence ***
                case 4: sScroll = "nw_it_spdvscr204"; break;          // *** Sound Burst ***
                case 5: sScroll = "nw_it_spdvscr301"; break;          // *** Remove Blindness / Deafness ***
                case 6: sScroll = "nw_it_spdvscr302"; break;          // *** Remove Disease ***
                case 7: sScroll = "nw_it_spdvscr401"; break;          // *** Restoration ***
                case 8: sScroll = "nw_it_spdvscr402"; break;          // *** Neutralize Poison ***
            }

        }
        else if (GetRange(3, nHD))
        {
            int nRandom = Random(9) + 1;
            switch (nRandom)
            {
                case 1: sScroll = "nw_it_spdvscr201"; break;          // *** Lesser Restoration ***
                case 2: sScroll = "nw_it_spdvscr202"; break;          // *** Charm Person or Animal ***
                case 3: sScroll = "nw_it_spdvscr203"; break;          // *** Silence ***
                case 4: sScroll = "nw_it_spdvscr204"; break;          // *** Sound Burst ***
                case 5: sScroll = "nw_it_spdvscr301"; break;          // *** Remove Blindness / Deafness ***
                case 6: sScroll = "nw_it_spdvscr302"; break;          // *** Remove Disease ***
                case 7: sScroll = "nw_it_spdvscr401"; break;          // *** Restoration ***
                case 8: sScroll = "nw_it_spdvscr402"; break;          // *** Neutralize Poison ***
                case 9: sScroll = "nw_it_spdvscr204"; break;          // *** Raise Dead ***
            }

        }
        else
        {
            int nRandom = Random(7) + 1;
            switch (nRandom)
            {
                case 1: sScroll = "nw_it_spdvscr301"; break;          // *** Remove Blindness / Deafness ***
                case 2: sScroll = "nw_it_spdvscr302";  break;          // *** Remove Disease ***
                case 3: sScroll = "nw_it_spdvscr401"; break;          // *** Restoration ***
                case 4: sScroll = "nw_it_spdvscr402"; break;          // *** Neutralize Poison ***
                case 5: sScroll = "nw_it_spdvscr501"; break;          // *** Raise Dead ***
                case 6: sScroll = "nw_it_spdvscr701"; break;          // *** Greater Restoration ***
                case 7: sScroll = "nw_it_spdvscr401";  break;          // *** Resurrection ***
            }
        }


        dbCreateItemOnObject(sScroll, oTarget, 1);

    }
    void CreateAmmo(object oTarget, object oAdventurer, int nModifier=0)
    {
        int nHD = GetHitDice(oAdventurer) + nModifier;

         if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }
       int nAmount;
       string sAmmo = "";


        if (GetRange(1, nHD))           // * 200 gp max
        {
            nAmount=1;
            int nRandom = d3();
            switch (nRandom)
            {
                case 1: sAmmo = "nw_wamar001";  break;          // *** Arrow ***
                case 2: sAmmo = "nw_wambo001";  break;          // *** Bolt ***
                case 3: sAmmo = "nw_wambu001";  break;          // *** Bullet ***
            }
          }
        else if (GetRange(2, nHD))       // * 800 gp max
        {
            nAmount=2;
            int nRandom = d6();
            switch (nRandom)
            {
                case 1: sAmmo = "nw_wamar001";  break;          // *** Arrow ***
                case 2: sAmmo = "nw_wambo001";  break;          // *** Bolt ***
                case 3: sAmmo = "nw_wambu001";  break;          // *** Bullet ***
                case 4: sAmmo = "nw_wammar001"; break;
                case 5: sAmmo = "nw_wammbo001"; break;
                case 6: sAmmo = "nw_wammbo002"; break;
            }
        }
        else if (GetRange(3, nHD))    // *  - 2500 gp
        {
            nAmount=3;
            int nRandom = d20();
            switch (nRandom)
            {
                case 1: sAmmo = "nw_wamar001";  break;          // *** Arrow ***
                case 2: sAmmo = "nw_wambo001";  break;          // *** Bolt ***
                case 3: sAmmo = "nw_wambu001";  break;          // *** Bullet ***
                case 4: sAmmo = "nw_wammar001";  break;
                case 5: sAmmo = "nw_wammbo001";  break;
                case 6: sAmmo = "nw_wammbo002";   break;
                case 7: sAmmo = "nw_wammbo003";  break;
                case 8: sAmmo = "nw_wammbu002";  break;
                case 9: sAmmo = "nw_wammar002";  break;
                case 10: sAmmo = "nw_wammar001"; break;
                case 11: sAmmo = "nw_wammar003"; break;
                case 12: sAmmo = "nw_wammar004"; break;
                case 13: sAmmo = "nw_wammar005"; break;
                case 14: sAmmo = "nw_wammar006"; break;
                case 15: sAmmo = "nw_wammbo004";  break;
                case 16: sAmmo = "nw_wammbo005"; break;
                case 17: sAmmo = "nw_wammbu004"; break;
                case 18: sAmmo = "nw_wammbu005"; break;
                case 19: sAmmo = "nw_wammbu006"; break;
                case 20: sAmmo = "nw_wammbu007"; break;
            }
        }
        else
        {
            int nRandom = d20();
            switch (nRandom)
            {
                case 1: sAmmo = "nw_wamar001";  break;          // *** Arrow ***
                case 2: sAmmo = "nw_wambo001";  break;          // *** Bolt ***
                case 3: sAmmo = "nw_wambu001";  break;          // *** Bullet ***
                case 4: sAmmo = "nw_wammar001";     break;
                case 5: sAmmo = "nw_wammbo001";      break;
                case 6: sAmmo = "nw_wammbo002";     break;
                case 7: sAmmo = "nw_wammbo003";     break;
                case 8: sAmmo = "nw_wammbu002";     break;
                case 9: sAmmo = "nw_wammar002";     break;
                case 10: sAmmo = "nw_wammar001";    break;
                case 11: sAmmo = "nw_wammar003";    break;
                case 12: sAmmo = "nw_wammar004";     break;
                case 13: sAmmo = "nw_wammar005";    break;
                case 14: sAmmo = "nw_wammar006";    break;
                case 15: sAmmo = "nw_wammbo004";    break;
                case 16: sAmmo = "nw_wammbo005";    break;
                case 17: sAmmo = "nw_wammbu004";    break;
                case 18: sAmmo = "nw_wammbu005";    break;
                case 19: sAmmo = "nw_wammbu006";    break;
                case 20: sAmmo = "nw_wammbu007";    break;
            }
        }
        //dbSpeak("ammo");
        dbCreateItemOnObject(sAmmo, oTarget, (Random(30) + 1)*(nAmount)); // create up to 30 of the specified ammo type

    }

    void CreateTrapKit(object oTarget, object oAdventurer, int nModifier = 0)
    {
      int nHD = GetHitDice(oAdventurer) + nModifier;
 if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }


      string sKit = "";
        if (GetRange(1, nHD))      // 200
        {
            int nRandom = d3();
            switch (nRandom)
            {
                case 1: sKit = "nw_it_trap001";    break;          // *** Minor Spike Trap Kit ***
                case 2: sKit = "nw_it_trap029";    break;          // *** Minor Frost Trap Kit ***
                case 3: sKit = "nw_it_trap033";    break;          // *** Minor Acid Splash Trap Kit ***
            }
        }
        else if (GetRange(2, nHD))  // 800
        {
            int nRandom = d12();
            switch (nRandom)
            {
                case 1: sKit = "nw_it_trap001";    break;          // *** Minor Spike Trap Kit ***
                case 2: sKit = "nw_it_trap029";    break;          // *** Minor Frost Trap Kit ***
                case 3: sKit = "nw_it_trap033";    break;          // *** Minor Acid Splash Trap Kit ***
                case 4: sKit = "nw_it_trap002";    break;          // *** Average Spike Trap Kit ***
                case 5: sKit = "nw_it_trap030";    break;          // *** Average Frost Trap Kit ***
                case 6: sKit = "nw_it_trap037";    break;          // *** Minor Sonic Trap Kit ***
                case 7: sKit = "nw_it_trap034";   break;          // *** Average Acid Splash Trap Kit ***
                case 8: sKit = "nw_it_trap005";   break;          // *** Minor Holy Trap Kit ***
                case 9: sKit = "nw_it_trap038";   break;          // *** Average Sonic Trap Kit ***
                case 10: sKit = "nw_it_trap041";   break;          // *** Minor Negative Trap Kit ***
                case 11: sKit = "nw_it_trap003";    break;          // *** Strong Spike Trap Kit ***
                case 12: sKit = "nw_it_trap031";   break;          // *** Strong Frost Trap Kit ***
            }

        }
        else if (GetRange(3, nHD))   // 200 - 2500
        {
            int nRandom = Random(17) + 1;
            switch (nRandom)
            {
                case 1: sKit = "nw_it_trap002";  break;          // *** Average Spike Trap Kit ***
                case 2: sKit = "nw_it_trap030";  break;          // *** Average Frost Trap Kit ***
                case 3: sKit = "nw_it_trap037";  break;          // *** Minor Sonic Trap Kit ***
                case 4: sKit = "nw_it_trap034";   break;          // *** Average Acid Splash Trap Kit ***
                case 5: sKit = "nw_it_trap005";  break;          // *** Minor Holy Trap Kit ***
                case 6: sKit = "nw_it_trap038";   break;          // *** Average Sonic Trap Kit ***
                case 7: sKit = "nw_it_trap041";   break;          // *** Minor Negative Trap Kit ***
                case 8: sKit = "nw_it_trap003";   break;          // *** Strong Spike Trap Kit ***
                case 9: sKit = "nw_it_trap031";   break;          // *** Strong Frost Trap Kit ***
                case 10: sKit = "nw_it_trap035";   break;          // *** Strong Acid Splash Trap Kit ***
                case 11: sKit = "nw_it_trap006";   break;          // *** Average Holy Trap Kit ***
                case 12: sKit = "nw_it_trap042";   break;          // *** Average Negative Trap Kit ***
                case 13: sKit = "nw_it_trap004";   break;          // *** Deadly Spike Trap Kit ***
                case 14: sKit = "nw_it_trap032";   break;          // *** Deadly Frost Trap Kit ***
                case 15: sKit = "nw_it_trap039";    break;          // *** Strong Sonic Trap Kit ***
                case 16: sKit = "nw_it_trap009";   break;          // *** Minor Tangle Trap Kit ***
                case 17: sKit = "nw_it_trap036";   break;          // *** Deadly Acid Splash Trap Kit ***
            }

       }
        else if (GetRange(4, nHD))  // 800 - 10000
        {
            int nRandom = Random(19) + 1;
            switch (nRandom)
            {
                case 1: sKit = "nw_it_trap035";  break;          // *** Strong Acid Splash Trap Kit ***
                case 2: sKit = "nw_it_trap006";  break;          // *** Average Holy Trap Kit ***
                case 3: sKit = "nw_it_trap042";  break;          // *** Average Negative Trap Kit ***
                case 4: sKit = "nw_it_trap004";   break;          // *** Deadly Spike Trap Kit ***
                case 5: sKit = "nw_it_trap032";   break;          // *** Deadly Frost Trap Kit ***
                case 6: sKit = "nw_it_trap039";   break;          // *** Strong Sonic Trap Kit ***
                case 7: sKit = "nw_it_trap009";   break;          // *** Minor Tangle Trap Kit ***
                case 8: sKit = "nw_it_trap036";   break;          // *** Deadly Acid Splash Trap Kit ***
                case 9: sKit = "nw_it_trap013";   break;          // *** Minor Blob of Acid Trap Kit ***
                case 10: sKit = "nw_it_trap040";  break;          // *** Deadly Sonic Trap Kit ***
                case 11: sKit = "nw_it_trap007";  break;          // *** Strong Holy Trap Kit ***
                case 12: sKit = "nw_it_trap043";  break;          // *** Strong Negative Trap Kit ***
                case 13: sKit = "nw_it_trap010";  break;          // *** Average Tangle Trap Kit ***
                case 14: sKit = "nw_it_trap017";  break;          // *** Minor Fire Trap Kit ***
                case 15: sKit = "nw_it_trap021"; break;          // *** Minor Electrical Trap Kit ***
                case 16: sKit = "nw_it_trap014"; break;          // *** Average Blob of Acid Trap Kit ***
                case 17: sKit = "nw_it_trap025"; break;          // *** Minor Gas Trap Kit ***
                case 18: sKit = "nw_it_trap008";  break;          // *** Deadly Holy Trap Kit ***
                case 19: sKit = "nw_it_trap044";  break;          // *** Deadly Negative Trap Kit ***
            }

        }
        else if (GetRange(5, nHD))  // 2000 -16500
        {
            int nRandom = Random(18) + 1;
            switch (nRandom)
            {
                case 1: sKit = "nw_it_trap039";   break;          // *** Strong Sonic Trap Kit ***
                case 2: sKit = "nw_it_trap009";   break;          // *** Minor Tangle Trap Kit ***
                case 3: sKit = "nw_it_trap036";   break;          // *** Deadly Acid Splash Trap Kit ***
                case 4: sKit = "nw_it_trap013";   break;          // *** Minor Blob of Acid Trap Kit ***
                case 5: sKit = "nw_it_trap040";   break;          // *** Deadly Sonic Trap Kit ***
                case 6: sKit = "nw_it_trap007";   break;          // *** Strong Holy Trap Kit ***
                case 7: sKit = "nw_it_trap043";   break;          // *** Strong Negative Trap Kit ***
                case 8: sKit = "nw_it_trap010";  break;          // *** Average Tangle Trap Kit ***
                case 9: sKit = "nw_it_trap017";  break;          // *** Minor Fire Trap Kit ***
                case 10: sKit = "nw_it_trap021";  break;          // *** Minor Electrical Trap Kit ***
                case 11: sKit = "nw_it_trap014";  break;          // *** Average Blob of Acid Trap Kit ***
                case 12: sKit = "nw_it_trap025";  break;          // *** Minor Gas Trap Kit ***
                case 13: sKit = "nw_it_trap008";  break;          // *** Deadly Holy Trap Kit ***
                case 14: sKit = "nw_it_trap044";  break;          // *** Deadly Negative Trap Kit ***
                case 15: sKit = "nw_it_trap018";  break;          // *** Average Fire Trap Kit ***
                case 16: sKit = "nw_it_trap011";  break;          // *** Strong Tangle Trap Kit ***
                case 17: sKit = "nw_it_trap022";  break;          // *** Average Electrical Trap Kit ***
                case 18: sKit = "nw_it_trap026";  break;          // *** Average Gas Trap Kit ***
            }

        }
        else if (GetRange(6, nHD))   // 2000 - ?
        {
            int nRandom = Random(27) + 1;
            switch (nRandom)
            {
                case 1: sKit = "nw_it_trap039";  break;          // *** Strong Sonic Trap Kit ***
                case 2: sKit = "nw_it_trap009";  break;          // *** Minor Tangle Trap Kit ***
                case 3: sKit = "nw_it_trap036";  break;          // *** Deadly Acid Splash Trap Kit ***
                case 4: sKit = "nw_it_trap013";  break;          // *** Minor Blob of Acid Trap Kit ***
                case 5: sKit = "nw_it_trap040";  break;          // *** Deadly Sonic Trap Kit ***
                case 6: sKit = "nw_it_trap007";  break;          // *** Strong Holy Trap Kit ***
                case 7: sKit = "nw_it_trap043";  break;          // *** Strong Negative Trap Kit ***
                case 8: sKit = "nw_it_trap010"; break;          // *** Average Tangle Trap Kit ***
                case 9: sKit = "nw_it_trap017"; break;          // *** Minor Fire Trap Kit ***
                case 10: sKit = "nw_it_trap021"; break;          // *** Minor Electrical Trap Kit ***
                case 11: sKit = "nw_it_trap014"; break;          // *** Average Blob of Acid Trap Kit ***
                case 12: sKit = "nw_it_trap025"; break;          // *** Minor Gas Trap Kit ***
                case 13: sKit = "nw_it_trap008"; break;          // *** Deadly Holy Trap Kit ***
                case 14: sKit = "nw_it_trap044"; break;          // *** Deadly Negative Trap Kit ***
                case 15: sKit = "nw_it_trap018"; break;          // *** Average Fire Trap Kit ***
                case 16: sKit = "nw_it_trap011"; break;          // *** Strong Tangle Trap Kit ***
                case 17: sKit = "nw_it_trap022"; break;          // *** Average Electrical Trap Kit ***
                case 18: sKit = "nw_it_trap026"; break;          // *** Average Gas Trap Kit ***
                case 19: sKit = "nw_it_trap015"; break;          // *** Strong Blob of Acid Trap Kit ***
                case 20: sKit = "nw_it_trap012"; break;          // *** Deadly Tangle Trap Kit ***
                case 21: sKit = "nw_it_trap019"; break;          // *** Strong Fire Trap Kit ***
                case 22: sKit = "nw_it_trap023"; break;          // *** Strong Electrical Trap Kit ***
                case 23: sKit = "nw_it_trap016"; break;          // *** Deadly Blob of Acid Trap Kit ***
                case 24: sKit = "nw_it_trap027"; break;          // *** Strong Gas Trap Kit ***
                case 25: sKit = "nw_it_trap020"; break;          // *** Deadly Fire Trap Kit ***
                case 26: sKit = "nw_it_trap024"; break;          // *** Deadly Electrical Trap Kit ***
                case 27: sKit = "nw_it_trap028"; break;          // *** Deadly Gas Trap Kit ***
             }

        }
        //dbSpeak("Create Trapkit");
        dbCreateItemOnObject(sKit, oTarget, 1);

    }
    void CreateHealingKit(object oTarget, object oAdventurer, int nModifier = 0)
    {
        int nHD = GetHitDice(oAdventurer) + nModifier;

         if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }


        string sKit = "";
        if (GetRange(1, nHD))      // 200
        {
            int nRandom = Random(1) + 1;
            switch (nRandom)
            {
                case 1: sKit = "nw_it_medkit001";  break;          // *** Healer's Kit ***
            }
        }
        else if (GetRange(2, nHD))  // 800
        {
            int nRandom = Random(2) + 1;
            switch (nRandom)
            {
                case 1: sKit = "nw_it_medkit001";  break;          // *** Healer's Kit ***
                case 2: sKit = "nw_it_medkit002";  break;          // *** Healer's Kit ***
            }

        }
        else if (GetRange(3, nHD))   // 200 - 2500
        {
            int nRandom = Random(2) + 1;
            switch (nRandom)
            {
                case 1: sKit = "nw_it_medkit002"; break;          // *** Healer's Kit ***
                case 2: sKit = "nw_it_medkit003";  break;          // *** Healer's Kit ***
            }

       }
        else if (GetRange(4, nHD))  // 800 - 10000
        {
            int nRandom = Random(2) + 1;
            switch (nRandom)
            {
                case 1: sKit = "nw_it_medkit003";break;          // *** Healer's Kit ***
                case 2: sKit = "nw_it_medkit004"; break;          // *** Healer's Kit ***
            }

        }
        else if (GetRange(5, nHD))  // 2000 -16500
        {
            int nRandom = Random(2) + 1;
            switch (nRandom)
            {
                case 1: sKit = "nw_it_medkit003"; break;          // *** Healer's Kit ***
                case 2: sKit = "nw_it_medkit004";break;          // *** Healer's Kit ***
            }

        }
        else if (GetRange(6, nHD))   // 2000 - ?
        {
            int nRandom = Random(2) + 1;
            switch (nRandom)
            {
                case 1: sKit = "nw_it_medkit003"; break;          // *** Healer's Kit ***
                case 2: sKit = "nw_it_medkit004";break;          // *** Healer's Kit ***
             }

        }
        //dbSpeak("Create Healing Kit");

        dbCreateItemOnObject(sKit, oTarget, 1);

    }
    void CreateLockPick(object oTarget, object oAdventurer, int nModifier = 0)
    {
        int nHD = GetHitDice(oAdventurer) + nModifier;

          if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }


        string sKit = "";
        if (GetRange(1, nHD))      // 200
        {
            int nRandom = d8();
            switch (nRandom)
            {
                case 1: sKit = "nw_it_picks001";   break;          // *** Thieves' Tools +1 ***
                case 2: sKit = "nw_it_picks002";   break;          // *** Thieves' Tools +3 ***
                case 3: sKit = "nw_it_picks001";   break;          // *** Thieves' Tools +1 ***
                case 4: sKit = "nw_it_picks001";   break;          // *** Thieves' Tools +1 ***
                case 5: sKit = "nw_it_picks001";   break;          // *** Thieves' Tools +1 ***
                case 6: sKit = "nw_it_picks001";   break;          // *** Thieves' Tools +1 ***
                case 7: sKit = "nw_it_picks001";   break;          // *** Thieves' Tools +1 ***
                case 8: sKit = "nw_it_picks001";   break;          // *** Thieves' Tools +1 ***
            }
        }
        else if (GetRange(2, nHD))  // 800
        {
            int nRandom = d6();
            switch (nRandom)
            {
                case 1: sKit = "nw_it_picks001";   break;          // *** Thieves' Tools +1 ***
                case 2: sKit = "nw_it_picks002";    break;          // *** Thieves' Tools +3 ***
                case 3: sKit = "nw_it_picks003";   break;          // *** Thieves' Tools +6 ***
                case 4: sKit = "nw_it_picks002";    break;          // *** Thieves' Tools +3 ***
                case 5: sKit = "nw_it_picks002";    break;          // *** Thieves' Tools +3 ***
                case 6: sKit = "nw_it_picks002";    break;          // *** Thieves' Tools +3 ***
            }

        }
        else if (GetRange(3, nHD))   // 200 - 2500
        {
            int nRandom = Random(2) + 1;
            switch (nRandom)
            {
                case 1: sKit = "nw_it_picks003";  break;          // *** Thieves' Tools +6 ***
                case 2: sKit = "nw_it_picks004";  break;          // *** Thieves' Tools +10 ***
            }

       }
        else if (GetRange(4, nHD))  // 800 - 10000
        {
            int nRandom = Random(1) + 1;
            switch (nRandom)
            {
                case 1: sKit = "nw_it_picks004";  break;          // *** Thieves' Tools +10 ***
            }

        }
        else if (GetRange(5, nHD))  // 2000 -16500
        {
            int nRandom = Random(1) + 1;
            switch (nRandom)
            {
                case 1: sKit = "nw_it_picks004"; break;          // *** Thieves' Tools +10 ***
            }

        }
        else if (GetRange(6, nHD))   // 2000 - ?
        {
            int nRandom = Random(1) + 1;
            switch (nRandom)
            {
                case 1: sKit = "nw_it_picks004"; break;          // *** Thieves' Tools +10 ***
             }

        }
       //dbSpeak("Create Lockpick");

        dbCreateItemOnObject(sKit, oTarget, 1);

    }
    void CreateKit(object oTarget, object oAdventurer, int nModifier = 0)
    {
        // * April 23 2002: Major restructuring of this function
        // * to allow me to

        switch (Random(8) + 1)
        {
            case 1: CreateTrapKit(oTarget, oAdventurer, nModifier); break;
            case 2: case 3: case 4: case 5: case 6: case 7: case 8: CreateHealingKit(oTarget, oAdventurer, nModifier); break;
//EDITED    case 6: case 7: case 8: CreateLockPick(oTarget, oAdventurer, nModifier); break;
        }
    }

    void CreatePotion(object oTarget, object oAdventurer, int nModifier = 0)
    {
        string sPotion = "";
        int nHD = GetHitDice(oAdventurer) + nModifier;

         if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }


        if (GetRange(1, nHD))
        {
            int nRandom = Random(16)+1;
            switch (nRandom)
            {
                case 1: case 2: case 3: case 4: sPotion = "nw_it_mpotion001"; break;          // *** Potion of Cure Light Wounds ***
                case 5: case 6: case 7: case 8: case 9: case 10: sPotion = "nw_it_mpotion020";  break;          // *** Potion of Cure Light Wounds ***

                case 11: case 12: case 13: sPotion = "nw_it_mpotion002";  break;          // *** Potion of Cure Serious Wounds ***
                case 14: sPotion = "nw_it_mpotion009";  break;          // *** Potion of Bless ***
                case 15: sPotion = "nw_it_mpotion005";  break;          // *** Potion of Barkskin ***
                case 16: sPotion = "X2_IT_MPOTION001";  break;           // potion of ironguts
            }

        }
        else if (GetRange(2, nHD))
        {
           int nRandom = Random(30) + 1;
            switch (nRandom)
            {
                case 1: case 2: case 3: sPotion = "nw_it_mpotion001"; break;          // *** Potion of Cure Light Wounds ***
                case 4: case 5: case 6: case 7: case 8: sPotion = "nw_it_mpotion020";  break;          // *** Potion of Cure Light Wounds ***
                case 9: case 10: case 11: case 12: sPotion = "nw_it_mpotion002";  break;          // *** Potion of Cure Serious Wounds ***
                case 13: case 14: sPotion = "nw_it_mpotion003";  break;          // *** Potion of Cure Critical Wounds ***
                case 15: sPotion = "nw_it_mpotion009";  break;          // *** Potion of Bless ***
                case 16: sPotion = "nw_it_mpotion005";  break;          // *** Potion of Barkskin ***
                case 17: sPotion = "nw_it_mpotion007";  break;          // *** Potion of Clarity ***
                case 18: sPotion = "nw_it_mpotion008";  break;          // *** Potion of Invisibility ***
                case 19: sPotion = "nw_it_mpotion010";  break;          // *** Potion of Eagle's Splendor ***
                case 20: sPotion = "nw_it_mpotion011";  break;          // *** Potion of Lesser Restoration ***
                case 21: sPotion = "nw_it_mpotion013";  break;          // *** Potion of Endurance ***
                case 22: sPotion = "nw_it_mpotion014";  break;          // *** Potion of Cat's Grace ***
                case 23: sPotion = "nw_it_mpotion015";  break;          // *** Potion of Bull's Strength ***
                case 24: sPotion = "nw_it_mpotion016";  break;          // *** Potion of Aid ***
                case 25: sPotion = "nw_it_mpotion017";  break;          // *** Potion of Fox's Cunning ***
                case 26: sPotion = "nw_it_mpotion018";  break;          // *** Potion of Owl's Wisdom ***
                case 27: sPotion = "nw_it_mpotion019";  break;          // *** Potion of Lore ***
                case 28: sPotion = "nw_it_mpotion004";  break;          // *** Potion of Speed ***
                case 29: sPotion = "nw_it_mpotion006";  break;          // *** Potion of Antidote ***
                case 30: sPotion = "X2_IT_MPOTION001";  break;          // potion of ironguts
           }
        }
        else if (GetRange(3, nHD))
        {
           int nRandom = Random(31) + 1;
            switch (nRandom)
            {
                case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:
                case 9: case 10: case 11: case 12:
                case 13: case 14: sPotion = "nw_it_mpotion003";  break;          // *** Potion of Cure Critical Wounds ***
                case 15: sPotion = "nw_it_mpotion009";  break;          // *** Potion of Bless ***
                case 16: sPotion = "nw_it_mpotion005";  break;          // *** Potion of Barkskin ***
                case 17: sPotion = "nw_it_mpotion007";  break;          // *** Potion of Clarity ***
                case 18: sPotion = "nw_it_mpotion008";  break;          // *** Potion of Invisibility ***
                case 19: sPotion = "nw_it_mpotion010";  break;          // *** Potion of Eagle's Splendor ***
                case 20: sPotion = "nw_it_mpotion011";  break;          // *** Potion of Lesser Restoration ***
                case 21: sPotion = "nw_it_mpotion013";  break;          // *** Potion of Endurance ***
                case 22: sPotion = "nw_it_mpotion014";  break;          // *** Potion of Cat's Grace ***
                case 23: sPotion = "nw_it_mpotion015";  break;          // *** Potion of Bull's Strength ***
                case 24: sPotion = "nw_it_mpotion016";  break;          // *** Potion of Aid ***
                case 25: sPotion = "nw_it_mpotion017";  break;          // *** Potion of Fox's Cunning ***
                case 26: sPotion = "nw_it_mpotion018";  break;          // *** Potion of Owl's Wisdom ***
                case 27: sPotion = "nw_it_mpotion019";  break;          // *** Potion of Lore ***
                case 28: sPotion = "nw_it_mpotion004";  break;          // *** Potion of Speed ***
                case 29: sPotion = "nw_it_mpotion006";  break;          // *** Potion of Antidote ***
               case 30: sPotion = "X2_IT_MPOTION001";  break;          // potion of ironguts
               case 31: sPotion = "X2_IT_MPOTION002";  break;           // death armour

           }
        }
        else if (GetRange(4, nHD))
        {
           int nRandom = Random(31) + 1;
            switch (nRandom)
            {
                case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:
                case 9: case 10: case 11: case 12: sPotion = "nw_it_mpotion003"; break;          // *** Potion of Cure Critical Wounds ***
                case 13: case 14: sPotion = "nw_it_mpotion003";  break;          // *** Potion of Cure Critical Wounds ***
                case 15: sPotion = "nw_it_mpotion009";  break;          // *** Potion of Bless ***
                case 16: sPotion = "nw_it_mpotion005";  break;          // *** Potion of Barkskin ***
                case 17: sPotion = "nw_it_mpotion007";  break;          // *** Potion of Clarity ***
                case 18: sPotion = "nw_it_mpotion008";  break;          // *** Potion of Invisibility ***
                case 19: sPotion = "nw_it_mpotion010";  break;          // *** Potion of Eagle's Splendor ***
                case 20: sPotion = "nw_it_mpotion011";  break;          // *** Potion of Lesser Restoration ***
                case 21: sPotion = "nw_it_mpotion013";  break;          // *** Potion of Endurance ***
                case 22: sPotion = "nw_it_mpotion014";  break;          // *** Potion of Cat's Grace ***
                case 23: sPotion = "nw_it_mpotion015";  break;          // *** Potion of Bull's Strength ***
                case 24: sPotion = "nw_it_mpotion016";  break;          // *** Potion of Aid ***
                case 25: sPotion = "nw_it_mpotion017";  break;          // *** Potion of Fox's Cunning ***
                case 26: sPotion = "nw_it_mpotion018";  break;          // *** Potion of Owl's Wisdom ***
                case 27: sPotion = "nw_it_mpotion019";  break;          // *** Potion of Lore ***
                case 28: sPotion = "nw_it_mpotion004";  break;          // *** Potion of Speed ***
                case 29: sPotion = "nw_it_mpotion006";  break;          // *** Potion of Antidote ***
                case 30: sPotion = "X2_IT_MPOTION001";  break;          // potion of ironguts
                 case 31: sPotion = "X2_IT_MPOTION002";  break;           // death armour
           }
        }
        else  // keep 5 and 6 the same
        {
           int nRandom = Random(32) + 1;
            switch (nRandom)
            {
                case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:
                case 9: sPotion = "nw_it_mpotion003" ;          // *** Potion of Cure Critical Wounds ***
                case 10: case 11: case 12: case 13: case 14: sPotion = "nw_it_mpotion003";  break;          // *** Potion of Cure Critical Wounds ***
                case 15: sPotion = "nw_it_mpotion009";  break;          // *** Potion of Bless ***
                case 16: sPotion = "nw_it_mpotion005";  break;          // *** Potion of Barkskin ***
                case 17: sPotion = "nw_it_mpotion007";  break;          // *** Potion of Clarity ***
                case 18: sPotion = "nw_it_mpotion008";  break;          // *** Potion of Invisibility ***
                case 19: sPotion = "nw_it_mpotion010";  break;          // *** Potion of Eagle's Splendor ***
                case 20: sPotion = "nw_it_mpotion011";  break;          // *** Potion of Lesser Restoration ***
                case 21: sPotion = "nw_it_mpotion013";  break;          // *** Potion of Endurance ***
                case 22: sPotion = "nw_it_mpotion014";  break;          // *** Potion of Cat's Grace ***
                case 23: sPotion = "nw_it_mpotion015";  break;          // *** Potion of Bull's Strength ***
                case 24: sPotion = "nw_it_mpotion016";  break;          // *** Potion of Aid ***
                case 25: sPotion = "nw_it_mpotion017";  break;          // *** Potion of Fox's Cunning ***
                case 26: sPotion = "nw_it_mpotion018";  break;          // *** Potion of Owl's Wisdom ***
                case 27: sPotion = "nw_it_mpotion019";  break;          // *** Potion of Lore ***
                case 28: sPotion = "nw_it_mpotion004";  break;          // *** Potion of Speed ***
                case 29: sPotion = "nw_it_mpotion006";  break;          // *** Potion of Antidote ***
                case 30: sPotion = "nw_it_mpotion004";  break;          // *** Potion of Stoneskin ***
                case 31: sPotion = "X2_IT_MPOTION001";  break;          // potion of ironguts
                 case 32: sPotion = "X2_IT_MPOTION002";  break;           // death armour
            }
        }
        //dbSpeak("Create Potion");
        dbCreateItemOnObject(sPotion, oTarget, 1);
    }
    //::///////////////////////////////////////////////
    //:: CreateTable2GenericItem
    //:: Copyright (c) 2002 Bioware Corp.
    //:://////////////////////////////////////////////
    /*
        Creates an item based upon the class of
        oAdventurer
    */
    //:://////////////////////////////////////////////
    //:: Created By:  Brent
    //:: Created On:
    //:://////////////////////////////////////////////
    // * CHANGED BY PALMER
    // * Creates the custom made items instead
        void CreateGenericMiscItem(object oTarget, object oAdventurer, int nModifier=0)
        {
            int nHD = GetHitDice(oAdventurer) + nModifier;
            string sItem = "";
            if (GetRange(1, nHD))    // * 200
            {
                int nRandom = Random(9) + 1;
                switch (nRandom)
                {
                 case 1: sItem = "nw_it_mglove004"; break;
                 case 2: sItem = "nw_it_mglove004"; break;
                 case 3: sItem = "nw_it_mglove005"; break;
                 case 4: sItem = "nw_it_mglove006"; break;
                 case 5: sItem = "nw_it_mglove007"; break;
                 case 6: sItem = "nw_it_mglove008"; break;
                 case 7: sItem = "nw_it_mglove009"; break;
                 case 8: sItem = "nw_mcloth006"; break;
                 case 9: sItem = "nw_it_mglove012"; break;
                }
            }
            else if (GetRange(2, nHD))   // * 800
            {
                int nRandom = Random(25) + 1;
                switch (nRandom)
                {
                 case 1: sItem = "nw_mcloth006"; break;
                 case 2: sItem = "nw_it_mring009"; break;
                 case 3: sItem = "nw_it_mring009"; break;
                 case 4: sItem = "nw_it_mring010"; break;
                 case 5: sItem = "nw_it_mring011"; break;
                 case 6: sItem = "nw_it_mboots010"; break;
                 case 7: sItem = "nw_it_mneck024"; break;
                 case 8: sItem = "nw_mcloth007"; break;
                 case 9: sItem = "nw_it_mring024"; break;
                 case 10: sItem = "nw_it_mring012"; break;
                 case 11: sItem = "nw_mcloth008"; break;
                 case 12: sItem = "nw_it_mglove010"; break;
                 case 13: sItem = "nw_it_mglove011"; break;
                 case 14: sItem = "nw_it_mglove013"; break;
                 case 15: sItem = "nw_it_mglove014"; break;
                 case 16: sItem = "nw_it_mglove015"; break;
                 case 17: sItem = "nw_maarcl097"; break;
                 case 18: sItem = "nw_maarcl097"; break;
                 case 19: sItem = "nw_maarcl099"; break;
                 case 20: sItem = "nw_it_mneck032"; break;
                 case 21: sItem = "nw_mcloth010"; break;
                 case 22: sItem = "nw_it_mbracer002"; break;
                 case 23: sItem = "nw_it_mneck001"; break;
                 case 24: sItem = "nw_maarcl055"; break;
                 case 25: sItem = "nw_mcloth009"; break;
                }

            }
            else if (GetRange(3, nHD))   // * 200 - 2500
            {
                int nRandom = Random(44) + 1;
                switch (nRandom)
                {
                 case 1: sItem = "nw_it_mring009"; break;
                 case 2: sItem = "nw_it_mring009"; break;
                 case 3: sItem = "nw_it_mring010"; break;
                 case 4: sItem = "nw_it_mring011"; break;
                 case 5: sItem = "nw_it_mboots010"; break;
                 case 6: sItem = "nw_it_mneck024"; break;
                 case 7: sItem = "nw_mcloth007"; break;
                 case 8: sItem = "nw_it_mring024"; break;
                 case 9: sItem = "nw_it_mring012"; break;
                 case 10: sItem = "nw_mcloth008"; break;
                 case 11: sItem = "nw_it_mglove010"; break;
                 case 12: sItem = "nw_it_mglove011"; break;
                 case 13: sItem = "nw_it_mglove013"; break;
                 case 14: sItem = "nw_it_mglove014"; break;
                 case 15: sItem = "nw_it_mglove015"; break;
                 case 16: sItem = "nw_it_contain003"; break;
                 case 17: sItem = "nw_maarcl097"; break;
                 case 18: sItem = "nw_maarcl099"; break;
                 case 19: sItem = "nw_it_mneck032"; break;
                 case 20: sItem = "nw_mcloth010"; break;
                 case 21: sItem = "nw_it_mbracer002"; break;
                 case 22: sItem = "nw_it_mneck001"; break;
                 case 23: sItem = "nw_maarcl055"; break;
                 case 24: sItem = "nw_mcloth009"; break;
                 case 25: sItem = "nw_it_mring001"; break;
                 case 26: sItem = "nw_it_mboots001"; break;
                 case 27: sItem = "nw_it_mbracer001"; break;
                 case 28: sItem = "nw_it_mneck007"; break;
                 case 29: sItem = "nw_maarcl096"; break;
                 case 30: sItem = "nw_it_mglove003"; break;
                 case 31: sItem = "nw_it_contain004"; break;
                 case 32: sItem = "nw_it_mneck031"; break;
                 case 33: sItem = "nw_it_mring006"; break;
                 case 34: sItem = "nw_it_mneck006"; break;
                 case 35: sItem = "nw_it_mneck029"; break;
                 case 36: sItem = "nw_it_mring013"; break;
                 case 37: sItem = "nw_it_mboots011"; break;
                 case 38: sItem = "nw_it_mneck025"; break;
                 case 39: sItem = "nw_it_mbelt009"; break;
                 case 40: sItem = "nw_it_mbelt010"; break;
                 case 41: sItem = "nw_it_mbelt011"; break;
                 case 42: sItem = "nw_it_mring025"; break;
                 case 43: sItem = "nw_it_mring025"; break;
                 case 44: sItem = "nw_maarcl031"; break;

                }

            }
            else if (GetRange(4, nHD))   // * 800 - 10000
            {
                int nRandom = Random(48) + 1;
                switch (nRandom)
                {
                 case 1: sItem = "nw_it_mring001"; break;
                 case 2: sItem = "nw_it_mboots001"; break;
                 case 3: sItem = "nw_it_mbracer001"; break;
                 case 4: sItem = "nw_it_mneck007"; break;
                 case 5: sItem = "nw_maarcl096"; break;
                 case 6: sItem = "nw_it_mglove003"; break;
                 case 7: sItem = "nw_it_mneck031"; break;
                 case 8: sItem = "nw_it_mneck031"; break;
                 case 9: sItem = "nw_it_mring006"; break;
                 case 10: sItem = "nw_it_mneck006"; break;
                 case 11: sItem = "nw_it_mneck029"; break;
                 case 12: sItem = "nw_it_mring013"; break;
                 case 13: sItem = "nw_it_mboots011"; break;
                 case 14: sItem = "nw_it_mneck025"; break;
                 case 15: sItem = "nw_it_mbelt009"; break;
                 case 16: sItem = "nw_it_mbelt010"; break;
                 case 17: sItem = "nw_it_mbelt011"; break;
                 case 18: sItem = "nw_it_mring025"; break;
                 case 19: sItem = "nw_it_mring025"; break;
                 case 20: sItem = "nw_it_mbracer007"; break;
                 case 21: sItem = "nw_it_mbracer007"; break;
                 case 22: sItem = "nw_it_mneck012"; break;
                 case 23: sItem = "nw_maarcl088"; break;
                 case 24: sItem = "nw_it_mboots012"; break;
                 case 25: sItem = "nw_it_mneck026"; break;
                 case 26: sItem = "nw_it_mboots006"; break;
                 case 27: sItem = "nw_it_mbracer003"; break;
                 case 28: sItem = "nw_it_mneck008"; break;
                 case 29: sItem = "nw_it_mring008"; break;
                 case 30: sItem = "nw_maarcl056"; break;
                 case 31: sItem = "nw_maarcl092"; break;
                 case 32: sItem = "nw_it_mring014"; break;
                 case 33: sItem = "nw_it_mneck016"; break;
                 case 34: sItem = "nw_it_mboots013"; break;
                 case 35: sItem = "nw_it_mneck027"; break;
                 case 36: sItem = "nw_it_mbracer008"; break;
                 case 37: sItem = "nw_it_mneck013"; break;
                 case 38: sItem = "nw_maarcl089"; break;
                 case 39: sItem = "nw_it_mbelt012"; break;
                 case 40: sItem = "nw_it_mbelt013"; break;
                 case 41: sItem = "nw_it_mbelt014"; break;
                 case 42: sItem = "nw_it_mring027"; break;
                 case 43: sItem = "nw_it_mboots007"; break;
                 case 44: sItem = "nw_it_mbracer004"; break;
                 case 45: sItem = "nw_it_mneck009"; break;
                 case 46: sItem = "nw_it_mring018"; break;
                 case 47: sItem = "nw_maarcl093"; break;
                 case 48: sItem = "nw_it_mboots002"; break;

                }
            }
            else if (GetRange(5, nHD))   // * 2500 - 16500
            {
                int nRandom = Random(42) + 1;
                switch (nRandom)
                {
                 case 1: sItem = "nw_it_mbracer007"; break;
                 case 2: sItem = "nw_it_mbracer007"; break;
                 case 3: sItem = "nw_it_mneck012"; break;
                 case 4: sItem = "nw_maarcl088"; break;
                 case 5: sItem = "nw_it_mboots012"; break;
                 case 6: sItem = "nw_it_mneck026"; break;
                 case 7: sItem = "nw_it_mboots006"; break;
                 case 8: sItem = "nw_it_mbracer003"; break;
                 case 9: sItem = "nw_it_mneck008"; break;
                 case 10: sItem = "nw_it_mring008"; break;
                 case 11: sItem = "nw_maarcl056"; break;
                 case 12: sItem = "nw_maarcl092"; break;
                 case 13: sItem = "nw_it_mring014"; break;
                 case 14: sItem = "nw_it_mneck016"; break;
                 case 15: sItem = "nw_it_mboots013"; break;
                 case 16: sItem = "nw_it_mneck027"; break;
                 case 17: sItem = "nw_it_mbracer008"; break;
                 case 18: sItem = "nw_it_mneck013"; break;
                 case 19: sItem = "nw_maarcl089"; break;
                 case 20: sItem = "nw_it_mbelt012"; break;
                 case 21: sItem = "nw_it_mbelt013"; break;
                 case 22: sItem = "nw_it_mbelt014"; break;
                 case 23: sItem = "nw_it_mring027"; break;
                 case 24: sItem = "nw_it_mboots007"; break;
                 case 25: sItem = "nw_it_mbracer004"; break;
                 case 26: sItem = "nw_it_mneck009"; break;
                 case 27: sItem = "nw_it_mring018"; break;
                 case 28: sItem = "nw_maarcl093"; break;
                 case 29: sItem = "nw_it_mboots002"; break;
                 case 30: sItem = "nw_it_mboots014"; break;
                 case 31: sItem = "nw_it_mneck028"; break;
                 case 32: sItem = "nw_it_mring015"; break;
                 case 33: sItem = "nw_it_mbracer009"; break;
                 case 34: sItem = "nw_it_mneck014"; break;
                 case 35: sItem = "nw_maarcl090"; break;
                 case 36: sItem = "nw_it_mring028"; break;
                 case 37: sItem = "nw_it_mneck017"; break;
                 case 38: sItem = "nw_it_mboots008"; break;
                 case 39: sItem = "nw_it_mbracer005"; break;
                 case 40: sItem = "nw_it_mneck010"; break;
                 case 41: sItem = "nw_it_mmidmisc02"; break;
                 case 42: sItem = "nw_it_mring019"; break;
                }
            }
            else if (GetRange(6, nHD))   // * 8000 - 25000
            {
                int nRandom = Random(30) + 1;
                switch (nRandom)
                {
                 case 1: sItem = "nw_it_mring027"; break;
                 case 2: sItem = "nw_it_mboots007"; break;
                 case 3: sItem = "nw_it_mbracer004"; break;
                 case 4: sItem = "nw_it_mneck009"; break;
                 case 5: sItem = "nw_it_mring018"; break;
                 case 6: sItem = "nw_maarcl093"; break;
                 case 7: sItem = "nw_it_mboots002"; break;
                 case 8: sItem = "nw_it_mboots014"; break;
                 case 9: sItem = "nw_it_mneck028"; break;
                 case 10: sItem = "nw_it_mring015"; break;
                 case 11: sItem = "nw_it_mbracer009"; break;
                 case 12: sItem = "nw_it_mneck014"; break;
                 case 13: sItem = "nw_maarcl090"; break;
                 case 14: sItem = "nw_it_mring028"; break;
                 case 15: sItem = "nw_it_mneck017"; break;
                 case 16: sItem = "nw_it_mboots008"; break;
                 case 17: sItem = "nw_it_mbracer005"; break;
                 case 18: sItem = "nw_it_mneck010"; break;
                 case 19: sItem = "nw_it_mmidmisc02"; break;
                 case 20: sItem = "nw_maarcl094"; break;
                 case 21: sItem = "nw_it_mring019"; break;
                 case 22: sItem = "nw_it_mring016"; break;
                 case 23: sItem = "nw_it_mbracer010"; break;
                 case 24: sItem = "nw_it_mneck015"; break;
                 case 25: sItem = "nw_maarcl091"; break;
                 case 26: sItem = "nw_it_mboots009"; break;
                 case 27: sItem = "nw_it_mbracer006"; break;
                 case 28: sItem = "nw_it_mneck011"; break;
                 case 29: sItem = "nw_maarcl095"; break;
                 case 30: sItem = "nw_it_mneck018"; break;
                }
             }
             //dbSpeak("Create Misc");

             dbCreateItemOnObject(sItem, oTarget, 1);
         }

         // * this function just returns an item that is more appropriate
         // * for this class. Only wizards, sorcerers, clerics, monks, rogues and bards get this
		void CreateGenericClassItem(object oTarget, object oAdventurer, int nSpecific =0)
		{

			string sItem = "";
			int nHD = GetHitDice(oAdventurer) ;

			if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
			{
				if (GetWillSavingThrow(OBJECT_SELF)<nHD)
				{
					nHD=GetWillSavingThrow(OBJECT_SELF);
				}
			}

            if (GetRange(1, nHD))    // * 200
            {
                  int nRandom = Random(20) + 1;
                  switch (nRandom)
				{
					case 1: sItem = "x1_wmgrenade001"; break;          // *** grenade weapon 1 ***
						case 2: sItem = "x1_wmgrenade002"; break;          // *** grenade weapon 2 ***
                        case 3: sItem = "x1_wmgrenade003"; break;          // *** grenade weapon 3 ***
                        case 4: sItem = "x1_wmgrenade004"; break;          // *** grenade weapon 4 ***
                        case 5: sItem = "x1_wmgrenade005"; break;          // *** grenade weapon 5 ***
                        case 6: sItem = "x1_wmgrenade006"; break;          // *** grenade weapon 6 ***
                        case 7: sItem = "x1_wmgrenade007"; break;          // *** grenade weapon 7 ***
                       case 8: sItem = "ah_blind_dust"; break;          // *** Blind dust ***
                       case 9: sItem = "jw_med_bag"; break;          // *** Medicine bag ***
                       case 10: sItem = "jw_garrote1"; break;          // *** Garotte 1 ***
                       case 11: sItem = "NW_IT_MSMLMISC11"; break;          // *** Quartz crystal for trap making ***
                       case 12: sItem = "X1_IT_MSMLMISC01"; break;          // *** Coldstone for trap making 1 ***
                       case 13: sItem = "jw_blank_scroll"; break;          // *** Blank Scroll ***
                       case 14: sItem = "jw_empty_potion"; break;          // *** Empty potion bottle ***
                       case 15: sItem = "x2_it_cfm_wand"; break;          // *** Bone wand ***
                       case 16: sItem = "x2_it_acidbomb"; break;          // *** Acidbomb ***
                       case 17: sItem = "x2_it_firebomb"; break;          // *** Firebomb ***
                       case 18: sItem = "jw_poison007"; break;          // *** Weak poison ***
                       case 19: sItem = "jw_poison009"; break;          // *** Weak poison ***
                       case 20: sItem = "jw_poison008"; break;          // *** Weak poison ***
                   }

            }
            else if (GetRange(2, nHD))   // * 800
            {
                  int nRandom = Random(28) + 1;
                  switch (nRandom)
                  {
                        case 1: sItem = "x1_wmgrenade001"; break;          // *** grenade weapon 1 ***
                        case 2: sItem = "x1_wmgrenade002"; break;          // *** grenade weapon 2 ***
                        case 3: sItem = "x1_wmgrenade003"; break;          // *** grenade weapon 3 ***
                        case 4: sItem = "x1_wmgrenade004"; break;          // *** grenade weapon 4 ***
                        case 5: sItem = "x1_wmgrenade005"; break;          // *** grenade weapon 5 ***
                        case 6: sItem = "x1_wmgrenade006"; break;          // *** grenade weapon 6 ***
                        case 7: sItem = "x1_wmgrenade007"; break;          // *** grenade weapon 7 ***
                       case 8: sItem = "ah_blind_dust"; break;          // *** Blind dust ***
                       case 9: sItem = "jw_elis_instr"; break;          // *** Lute of Elistrea ***
                       case 10: sItem = "jw_med_bag"; break;          // *** Medicine bag ***
                       case 11: sItem = "jw_garrote2"; break;          // *** Garotte 2 ***
                       case 12: sItem = "jw_empty_potion"; break;          // *** Herb used to make Harper potions ***
                       case 13: sItem = "jw_empty_potion"; break;          // *** Herb used to make Harper potions ***
                       case 14: sItem = "jw_empty_potion"; break;          // *** Herb used to make Harper potions ***
                       case 15: sItem = "jw_empty_potion"; break;          // *** Herb used to make Harper potions ***
                       case 16: sItem = "jw_empty_potion"; break;          // *** Herb used to make Harper potions ***
                       case 17: sItem = "jw_empty_potion"; break;          // *** Herb used to make Harper potions ***
                       case 18: sItem = "jw_empty_potion"; break;          // *** Herb used to make Harper potions ***
                       case 19: sItem = "NW_IT_MSMLMISC11"; break;          // *** Quartz crystal for trap making ***
                       case 20: sItem = "X1_IT_MSMLMISC01"; break;          // *** Coldstone for trap making 1 ***
                       case 21: sItem = "jw_blank_scroll"; break;          // *** Blank Scroll ***
                       case 22: sItem = "jw_empty_potion"; break;          // *** Empty potion bottle ***
                       case 23: sItem = "x2_it_cfm_wand"; break;          // *** Bone wand ***
                       case 24: sItem = "x2_it_acidbomb"; break;          // *** Acidbomb ***
                       case 25: sItem = "x2_it_firebomb"; break;          // *** Firebomb ***
                       case 26: sItem = "jw_poison007"; break;          // *** Weak poison ***
                       case 27: sItem = "jw_poison009"; break;          // *** Weak poison ***
                       case 28: sItem = "jw_poison008"; break;          // *** Weak poison ***
                   }

            }
            else if (GetRange(3, nHD))   // * 200 - 2500
            {
                  int nRandom = Random(35) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "x1_wmgrenade001"; break;          // *** grenade weapon 1 ***
                        case 2: sItem = "x1_wmgrenade002"; break;          // *** grenade weapon 2 ***
                        case 3: sItem = "x1_wmgrenade003"; break;          // *** grenade weapon 3 ***
                        case 4: sItem = "x1_wmgrenade004"; break;          // *** grenade weapon 4 ***
                        case 5: sItem = "x1_wmgrenade005"; break;          // *** grenade weapon 5 ***
                        case 6: sItem = "x1_wmgrenade006"; break;          // *** grenade weapon 6 ***
                        case 7: sItem = "x1_wmgrenade007"; break;          // *** grenade weapon 7 ***
                       case 8: sItem = "ah_blind_dust"; break;          // *** Blind dust ***
                       case 9: sItem = "jw_elis_instr"; break;          // *** Lute of Elistrea ***
                       case 10: sItem = "jw_med_bag"; break;          // *** Medicine bag ***
                       case 11: sItem = "jw_garrote3"; break;          // *** Garotte 3 ***
                       case 12: sItem = "jw_empty_potion"; break;          // *** Herb used to make Harper potions ***
                       case 13: sItem = "jw_empty_potion"; break;          // *** Herb used to make Harper potions ***
                       case 14: sItem = "jw_empty_potion"; break;          // *** Herb used to make Harper potions ***
                       case 15: sItem = "jw_empty_potion"; break;          // *** Herb used to make Harper potions ***
                       case 16: sItem = "jw_empty_potion"; break;          // *** Herb used to make Harper potions ***
                       case 17: sItem = "jw_empty_potion"; break;          // *** Herb used to make Harper potions ***
                       case 18: sItem = "jw_empty_potion"; break;          // *** Herb used to make Harper potions ***
                        case 19: sItem = "NW_IT_MSMLMISC11"; break;          // *** Quartz crystal for trap making ***
                       case 20: sItem = "X1_IT_MSMLMISC01"; break;          // *** Coldstone for trap making 1 ***
                       case 21: sItem = "jw_blank_scroll"; break;          // *** Blank Scroll ***
                       case 22: sItem = "jw_empty_potion"; break;          // *** Empty potion bottle ***
                       case 23: sItem = "x2_it_cfm_wand"; break;          // *** Bone wand **
                       case 24: sItem = "x2_it_acidbomb"; break;          // *** Acidbomb ***
                       case 25: sItem = "x2_it_firebomb"; break;          // *** Firebomb ***
                       case 26: sItem = "jw_poison020"; break;          // *** Average poison ***
                       case 27: sItem = "jw_poison021"; break;          // *** Average poison ***
                       case 28: sItem = "jw_poison019"; break;          // *** Average poison ***
                       case 29: sItem = "jw_ioun_554"; break;         // dusty rose ioun stone
                       case 30: sItem = "jw_ioun_555"; break;         // Pale blue ioun stone
                       case 31: sItem = "jw_ioun_556"; break;         // Scarlet blue ioun stone
                       case 32: sItem = "jw_ioun_557"; break;         // blue ioun stone
                       case 33: sItem = "jw_ioun_558"; break;         // deepred ioun stone
                       case 34: sItem = "jw_ioun_559"; break;         // pink ioun stone
                       case 35: sItem = "jw_ioun_560"; break;         // pink green



                   }


            }
            else if (GetRange(4, nHD))   // * 800 - 10000
            {
                  int nRandom = Random(36) + 1;
                  switch (nRandom)
                  {
                     case 1: sItem = "x1_wmgrenade001"; break;          // *** grenade weapon 1 ***
                        case 2: sItem = "x1_wmgrenade002"; break;          // *** grenade weapon 2 ***
                        case 3: sItem = "x1_wmgrenade003"; break;          // *** grenade weapon 3 ***
                        case 4: sItem = "x1_wmgrenade004"; break;          // *** grenade weapon 4 ***
                        case 5: sItem = "x1_wmgrenade005"; break;          // *** grenade weapon 5 ***
                        case 6: sItem = "x1_wmgrenade006"; break;          // *** grenade weapon 6 ***
                        case 7: sItem = "x1_wmgrenade007"; break;          // *** grenade weapon 7 ***
                       case 8: sItem = "ah_blind_dust"; break;          // *** Blind dust ***
                       case 9: sItem = "jw_elis_instr"; break;          // *** Lute of Elistrea ***
                       case 10: sItem = "jw_med_bag"; break;          // *** Medicine bag ***
                       case 11: sItem = "jw_garrote4"; break;          // *** Garotte 4 ***
                       case 12: sItem = "jw_ioun_554"; break;          // *** Herb used to make Harper potions ***
                       case 13: sItem = "jw_ioun_555"; break;          // *** Herb used to make Harper potions ***
                       case 14: sItem = "jw_ioun_556"; break;          // *** Herb used to make Harper potions ***
                       case 15: sItem = "jw_ioun_557"; break;          // *** Herb used to make Harper potions ***
                       case 16: sItem = "jw_ioun_558"; break;          // *** Herb used to make Harper potions ***
                       case 17: sItem = "jw_ioun_559"; break;          // *** Herb used to make Harper potions ***
                       case 18: sItem = "jw_ioun_560"; break;          // *** Herb used to make Harper potions ***
                        case 19: sItem = "NW_IT_MSMLMISC11"; break;          // *** Quartz crystal for trap making ***
                       case 20: sItem = "X1_IT_MSMLMISC01"; break;          // *** Coldstone for trap making 1 ***
                       case 21: sItem = "jw_blank_scroll"; break;          // *** Blank Scroll ***
                        case 22: sItem = "jw_empty_potion"; break;          // *** Empty potion bottle ***
                       case 23: sItem = "x2_it_cfm_wand"; break;          // *** Bone wand **
                       case 24: sItem = "x2_it_acidbomb"; break;          // *** Acidbomb ***
                       case 25: sItem = "x2_it_firebomb"; break;          // *** Firebomb ***
                       case 26: sItem = "jw_branch_giv"; break;          // *** Branch of giving ***
                       case 27: sItem = "jw_poison020"; break;          // *** Average poison ***
                       case 28: sItem = "jw_poison021"; break;          // *** Average poison ***
                       case 29: sItem = "jw_poison019"; break;          // *** Average poison ***
                        case 30: sItem = "jw_ioun_554"; break;         // dusty rose ioun stone
                       case 31: sItem = "jw_ioun_555"; break;         // Pale blue ioun stone
                       case 32: sItem = "jw_ioun_556"; break;         // Scarlet blue ioun stone
                       case 33: sItem = "jw_ioun_557"; break;         // blue ioun stone
                       case 34: sItem = "jw_ioun_558"; break;         // deepred ioun stone
                       case 35: sItem = "jw_ioun_559"; break;         // pink ioun stone
                       case 36: sItem = "jw_ioun_560"; break;         // pink green

                   }
            }
            else  // * 2500 - 16500
            {
                  int nRandom = Random(36) + 1;
                  switch (nRandom)
                  {
                      case 1: sItem = "x1_wmgrenade001"; break;          // *** grenade weapon 1 ***
                        case 2: sItem = "x1_wmgrenade002"; break;          // *** grenade weapon 2 ***
                        case 3: sItem = "x1_wmgrenade003"; break;          // *** grenade weapon 3 ***
                        case 4: sItem = "x1_wmgrenade004"; break;          // *** grenade weapon 4 ***
                        case 5: sItem = "x1_wmgrenade005"; break;          // *** grenade weapon 5 ***
                        case 6: sItem = "x1_wmgrenade006"; break;          // *** grenade weapon 6 ***
                        case 7: sItem = "x1_wmgrenade007"; break;          // *** grenade weapon 7 ***
                       case 8: sItem = "ah_blind_dust"; break;          // *** Blind dust ***
                       case 9: sItem = "jw_elis_instr"; break;          // *** Lute of Elistrea ***
                       case 10: sItem = "jw_med_bag"; break;          // *** Medicine bag ***
                       case 11: sItem = "jw_garrote4"; break;          // *** Garotte 4 ***
                       case 12: sItem = "jw_ioun_554"; break;          // *** Herb used to make Harper potions ***
                       case 13: sItem = "jw_ioun_555"; break;          // *** Herb used to make Harper potions ***
                       case 14: sItem = "jw_ioun_556"; break;          // *** Herb used to make Harper potions ***
                       case 15: sItem = "jw_ioun_557"; break;          // *** Herb used to make Harper potions ***
                       case 16: sItem = "jw_ioun_558"; break;          // *** Herb used to make Harper potions ***
                       case 17: sItem = "jw_ioun_559"; break;          // *** Herb used to make Harper potions ***
                       case 18: sItem = "jw_ioun_560"; break;          // *** Herb used to make Harper potions ***
                        case 19: sItem = "NW_IT_MSMLMISC11"; break;          // *** Quartz crystal for trap making ***
                       case 20: sItem = "X1_IT_MSMLMISC01"; break;          // *** Coldstone for trap making 1 ***
                       case 21: sItem = "jw_blank_scroll"; break;          // *** Blank Scroll ***
                        case 22: sItem = "jw_empty_potion"; break;          // *** Empty potion bottle ***
                       case 23: sItem = "x2_it_cfm_wand"; break;          // *** Bone wand **
                         case 24: sItem = "x2_it_acidbomb"; break;          // *** Acidbomb ***
                       case 25: sItem = "x2_it_firebomb"; break;          // *** Firebomb ***
                       case 26: sItem = "jw_branch_giv"; break;          // *** Branch of giving ***
                       case 27: sItem = "jw_poison031"; break;          // *** V strong poison ***
                       case 28: sItem = "jw_poison032"; break;          // *** V strong poison ***
                       case 29: sItem = "jw_poison033"; break;          // *** V strong poison ***
                       case 30: sItem = "jw_ioun_554"; break;         // dusty rose ioun stone
                       case 31: sItem = "jw_ioun_555"; break;         // Pale blue ioun stone
                       case 32: sItem = "jw_ioun_556"; break;         // Scarlet blue ioun stone
                       case 33: sItem = "jw_ioun_557"; break;         // blue ioun stone
                       case 34: sItem = "jw_ioun_558"; break;         // deepred ioun stone
                       case 35: sItem = "jw_ioun_559"; break;         // pink ioun stone
                       case 36: sItem = "jw_ioun_560"; break;         // pink green

                   }
            }

           dbCreateItemOnObject(sItem, oTarget, 1);
        }

        void CreateGenericRodStaffWand(object oTarget, object oAdventurer, int nModifier = 0)
        {
            string sItem = "";
            int nHD = GetHitDice(oAdventurer) + nModifier;

            if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }

             //**************************************
             //CHANGED THIS TO CLOTHES
             //**************************************
                int nRandom = Random(77) + 1;
                switch (nRandom)
                {
                    case 1: sItem = "blackoutfit"; break;
                    case 2: sItem = "blueoutfit"; break;
                    case 3: sItem = "commonersoutfit";  break;
                    case 4: sItem = "jw_farm_rags";  break;
                    case 5: sItem = "knickerbockersou";  break;
                    case 6: sItem = "redoutfit";  break;
                    case 7: sItem = "shirtless";  break;
                    case 8: sItem = "wizardsoutfit";  break;
                    case 9: sItem = "wizardsoutfit001";  break;
                    case 10: sItem = "wizardsoutfit002";  break;
                    case 11: sItem = "wizardsoutfit003";  break;
                    case 12: sItem = "redvestoutfit";  break;
                    case 13: sItem = "hotpants";  break;
                    case 14: sItem = "bardsoutfit";  break;
                    case 15: sItem = "jw_clothing1";  break;
                    case 16: sItem = "jw_clothing2";  break;
                    case 17: sItem = "jw_clothing3";  break;
                    case 18: sItem = "jw_clothing4";  break;
                    case 19: sItem = "jw_clothing5";  break;
                    case 20: sItem = "jw_clothing6";  break;
                    case 21: sItem = "jw_clothing7";  break;
                    case 22: sItem = "jw_clothing8";  break;
                    case 23: sItem = "jw_clothing9";  break;
                    case 24: sItem = "jw_clothing10";  break;
                    case 25: sItem = "jw_clothing11";  break;
                    case 26: sItem = "jw_clothing12";  break;
                    case 27: sItem = "jw_clothing13";  break;
                    case 28: sItem = "jw_clothing14";  break;
                    case 29: sItem = "clothinga";  break;
                    case 30: sItem = "clothingb";  break;
                    case 31: sItem = "clothingc";  break;
                    case 32: sItem = "tasseldalerob001";  break;
                    case 33: sItem = "tasseldalerob002";  break;
                    case 34: sItem = "woodsmanoutfit";  break;
                    case 35: sItem = "nk_outfitbr";  break;
                    case 36: sItem = "nk_outfitbw";  break;
                    case 37: sItem = "nk_outfitblksp";  break;
                     case 38: sItem = "ashabenfordro001";  break;
                    case 39: sItem = "ashabenfordro002";  break;
                    case 40: sItem = "ashabenfordrobe";  break;
                    case 41: sItem = "bristarrobe";  break;
                    case 42: sItem = "bristarrobe001";  break;
                    case 43: sItem = "bristarrobe002";  break;
                    case 44: sItem = "tasseldalerobe";  break;
                    case 45: sItem = "shadowdalerobe";  break;
                    case 46: sItem = "shadowdalerob001";  break;
                    case 47: sItem = "shadowdalerob002";  break;
                    case 48: sItem = "shadowdalerob003";  break;
                    case 49: sItem = "shadowdalerob004";  break;
                     case 50: sItem = "alberanrobe";  break;
                     case 51: sItem = "alberanrobe001";  break;
                     case 52: sItem = "courdenrobe001";  break;
                     case 53: sItem = "darbenrobe001";  break;
                     case 54: sItem = "mardenshirero001";  break;
                     case 55: sItem = "mardenshirerobe";  break;
                     case 56: sItem = "morgotoutfit";  break;
                     case 57: sItem = "morgotoutfit001";  break;
                     case 58: sItem = "roaneoutfit";  break;
                     case 59: sItem = "shadowdalerob005";  break;
                     case 60: sItem = "shadowdalerob007";  break;
                      case 61: sItem = "ta_robe001";  break;
                     case 62: sItem = "ta_robe002";  break;
                     case 63: sItem = "ta_robe005";  break;
                     case 64: sItem = "ta_robe009";  break;
                     case 65: sItem = "ta_robe012";  break;
                     case 66: sItem = "ta_robe013";  break;
                     case 67: sItem = "shadowdalenob004";  break;
                     case 68: sItem = "shadowdalenob005";  break;
                     case 69: sItem = "shadowdalenob007";  break;
                     case 70: sItem = "shadowdalerob009";  break;
                      case 71: sItem = "scardalecloth";  break;
                     case 72: sItem = "scardalecloth001";  break;
                     case 73: sItem = "scardalecloth003";  break;
                     case 74: sItem = "theskrobe";  break;
                     case 75: sItem = "theskrobe003";  break;
                     case 76: sItem = "wizardsoutfit004";  break;
                     case 77: sItem = "jw_whore_costume";  break;

                }


          dbCreateItemOnObject(sItem, oTarget, 1);
        }

		void CreateGenericMonkWeapon(object oTarget, object oAdventurer, int nModifier = 0)
        {
            string sItem = "";
            int nHD = GetHitDice(oAdventurer) + nModifier;

            if (GetRange(1, nHD))    // * 200
            {
                  int nRandom = Random(10) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wthsh001"; break;
                       case 2: sItem = "nw_wblcl001"; break;
                       case 3: sItem = "nw_wdbqs001"; break;
                       case 4: sItem = "nw_wbwsl001"; break;
                       case 5: sItem = "nw_wswdg001"; break;
                       case 6: sItem = "nw_wspka001"; break;
                       case 7: sItem = "nw_wbwxh001"; break;
                       case 8: sItem = "nw_waxhn001"; break;
                       case 9: sItem = "nw_wbwxl001"; break;
                       case 10: sItem = "nw_wthmsh002"; break;
                   }

            }
            else if (GetRange(2, nHD))   // * 800
            {
                  int nRandom = Random(14) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wthsh001"; break;
                       case 2: sItem = "nw_wblcl001"; break;
                       case 3: sItem = "nw_wdbqs001"; break;
                       case 4: sItem = "nw_wbwsl001"; break;
                       case 5: sItem = "nw_wswdg001"; break;
                       case 6: sItem = "nw_wspka001"; break;
                       case 7: sItem = "nw_wbwxh001"; break;
                       case 8: sItem = "nw_waxhn001"; break;
                       case 9: sItem = "nw_wbwxl001"; break;
                       case 10: sItem = "nw_wthmsh002"; break;
                       case 11: sItem = "nw_wbwmsl001"; break;
                       case 12: sItem = "nw_wbwmxh002"; break;
                       case 13: sItem = "nw_wthmsh008"; break;
                       case 14: sItem = "nw_wbwmxl002"; break;
                   }

            }
            else if (GetRange(3, nHD))   // * 200 - 2500
            {
                  int nRandom = Random(13) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wbwmsl001"; break;
                       case 2: sItem = "nw_wbwmxh002"; break;
                       case 3: sItem = "nw_wthmsh008"; break;
                       case 4: sItem = "nw_wbwmxl002"; break;
                       case 5: sItem = "nw_wthmsh009"; break;
                       case 6: sItem = "nw_wblmcl002"; break;
                       case 7: sItem = "nw_wdbmqs002"; break;
                       case 8: sItem = "nw_wswmdg002"; break;
                       case 9: sItem = "nw_wspmka002"; break;
                       case 10: sItem = "nw_waxmhn002"; break;
                       case 11: sItem = "nw_wbwmsl009"; break;
                       case 12: sItem = "nw_wbwmxh008"; break;
                       case 13: sItem = "nw_wbwmxl008"; break;
                   }


            }
            else if (GetRange(4, nHD))   // * 800 - 10000
            {
                  int nRandom = Random(17) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wthmsh009"; break;
                       case 2: sItem = "nw_wblmcl002"; break;
                       case 3: sItem = "nw_wdbmqs002"; break;
                       case 4: sItem = "nw_wswmdg002"; break;
                       case 5: sItem = "nw_wspmka002"; break;
                       case 6: sItem = "nw_waxmhn002"; break;
                       case 7: sItem = "nw_wbwmsl009"; break;
                       case 8: sItem = "nw_wbwmxh008"; break;
                       case 9: sItem = "nw_wbwmxl008"; break;
                       case 10: sItem = "nw_wbwmsl010"; break;
                       case 11: sItem = "nw_wbwmxh009"; break;
                       case 12: sItem = "nw_wbwmxl009"; break;
                       case 13: sItem = "nw_wblmcl010"; break;
                       case 14: sItem = "nw_wdbmqs008"; break;
                       case 15: sItem = "nw_wswmdg008"; break;
                       case 16: sItem = "nw_wspmka008"; break;
                       case 17: sItem = "nw_waxmhn010"; break;
                   }
            }
            else  // * 2500 - 16500
            {
                  int nRandom = Random(13) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wbwmsl010"; break;
                       case 2: sItem = "nw_wbwmxh009"; break;
                       case 3: sItem = "nw_wbwmxl009"; break;
                       case 4: sItem = "nw_wblmcl010"; break;
                       case 5: sItem = "nw_wdbmqs008"; break;
                       case 6: sItem = "nw_wswmdg008"; break;
                       case 7: sItem = "nw_wspmka008"; break;
                       case 8: sItem = "nw_waxmhn010"; break;
                       case 9: sItem = "nw_wblmcl011"; break;
                       case 10: sItem = "nw_wdbmqs009"; break;
                       case 11: sItem = "nw_wswmdg009"; break;
                       case 12: sItem = "nw_wspmka009"; break;
                       case 13: sItem = "nw_waxmhn011"; break;
                   }
            }
          //dbSpeak("Generic Monk Weapon");

           dbCreateItemOnObject(sItem, oTarget, 1);
        }
        
		void CreateSpecificMonkWeapon(object oTarget, object oAdventurer, int nModifier = 0)
        {

            string sItem = "";
            int nHD = GetHitDice(oAdventurer) + nModifier;

            if (GetRange(1, nHD))    // * 800
            {
                  int nRandom = Random(3) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wthmsh003"; break;
                       case 2: sItem = "nw_wthmsh006"; break;
                       case 3: CreateGenericMonkWeapon(oTarget, oAdventurer, JUMP_LEVEL); return; break;
                  }

            }
            else if (GetRange(2, nHD))   // * 2500
            {
                  int nRandom = Random(8) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wthmsh003"; break;
                       case 2: sItem = "nw_wthmsh006"; break;
                       case 3: sItem = "nw_wthmsh004"; break;
                       case 4: sItem = "nw_wthmsh007"; break;
                       case 5: sItem = "NW_IT_MGLOVE016"; break;
                       case 6: sItem = "NW_IT_MGLOVE021"; break;
                       case 7: sItem = "NW_IT_MGLOVE026"; break;
                       case 8: CreateGenericMonkWeapon(oTarget, oAdventurer, JUMP_LEVEL); return; break;
                   }

            }
            else if (GetRange(3, nHD))   // * 800 - 10000
            {
                  int nRandom = Random(21) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wthmsh006"; break;
                       case 2: sItem = "nw_wthmsh004"; break;
                       case 3: sItem = "nw_wthmsh007"; break;
                       case 4: sItem = "nw_wbwmsl005"; break;
                       case 5: sItem = "nw_wbwmxh005"; break;
                       case 6: sItem = "nw_wspmka004"; break;
                       case 7: sItem = "nw_wbwmxl005"; break;
                       case 8: sItem = "nw_wspmka007"; break;
                       case 9: sItem = "nw_wswmdg006"; break;
                       case 10: sItem = "nw_wspmka005"; break;
                       case 11: sItem = "NW_IT_MGLOVE016"; break;
                       case 12: sItem = "NW_IT_MGLOVE021"; break;
                       case 13: sItem = "NW_IT_MGLOVE026"; break;

                       case 14: sItem = "NW_IT_MGLOVE017"; break;
                       case 15: sItem = "NW_IT_MGLOVE022"; break;
                       case 16: sItem = "NW_IT_MGLOVE027"; break;

                       case 17: sItem = "NW_IT_MGLOVE018"; break;
                       case 18: sItem = "NW_IT_MGLOVE023"; break;
                       case 19: sItem = "NW_IT_MGLOVE028"; break;

                       case 20: sItem = "NW_IT_MGLOVE029"; break;
                       case 21: sItem = "NW_IT_MGLOVE030"; break;


                   }

            }
            else if (GetRange(4, nHD))   // * 2500 -16500
            {
                  int nRandom = Random(22) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wbwmsl005"; break;
                       case 2: sItem = "nw_wbwmxh005"; break;
                       case 3: sItem = "nw_wspmka004"; break;
                       case 4: sItem = "nw_wbwmxl005"; break;
                       case 5: sItem = "nw_wspmka007"; break;
                       case 6: sItem = "nw_wswmdg006"; break;
                       case 7: sItem = "nw_wspmka005"; break;
                       case 8: sItem = "nw_wblmcl004"; break;
                       case 9: sItem = "nw_wblmcl003"; break;
                       case 10: sItem = "nw_wbwmsl003"; break;
                       case 11: sItem = "nw_wbwmxh003"; break;
                       case 12: sItem = "nw_waxmhn004"; break;
                       case 13: sItem = "nw_wbwmxl003"; break;

                       case 14: sItem = "NW_IT_MGLOVE017"; break;
                       case 15: sItem = "NW_IT_MGLOVE022"; break;

                       case 16: sItem = "NW_IT_MGLOVE018"; break;
                       case 17: sItem = "NW_IT_MGLOVE023"; break;
                       case 18: sItem = "NW_IT_MGLOVE028"; break;

                       case 19: sItem = "NW_IT_MGLOVE029"; break;
                       case 20: sItem = "NW_IT_MGLOVE030"; break;

                       case 21: sItem = "NW_IT_MGLOVE019"; break;
                       case 22: sItem = "NW_IT_MGLOVE024"; break;


                   }

            }
            else  // * 16000 +
            {
                  int nRandom = Random(24) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wbwmxl003"; break;
                       case 2: sItem = "nw_wspmka006"; break;
                       case 3: sItem = "nw_wbwmxl004"; break;
                       case 4: sItem = "nw_wspmka003"; break;
                       case 5: sItem = "nw_wbwmxl007"; break;
                       case 6: sItem = "nw_waxmhn003"; break;
                       case 7: sItem = "nw_wblmcl005"; break;
                       case 8: sItem = "nw_wswmdg004"; break;
                       case 9: sItem = "nw_wbwmsl007"; break;
                       case 10: sItem = "nw_wbwmxh004"; break;
                       case 11: sItem = "nw_waxmhn005"; break;
                       case 12: sItem = "nw_wbwmxh007"; break;
                       case 13: sItem = "nw_wswmdg003"; break;
                       case 14: sItem = "nw_wswmdg007"; break;
                       case 15: sItem = "nw_wbwmsl006"; break;
                       case 16: sItem = "nw_wbwmsl008"; break;
                       case 17: sItem = "nw_wblmcl006"; break;
                       case 18: sItem = "nw_wbwmsl004"; break;
                       case 19: sItem = "nw_waxmhn006"; break;
                       case 20: sItem = "nw_wbwmxh006"; break;
                       case 21: sItem = "nw_wswmdg005"; break;
                       case 22: sItem = "nw_wbwmxl006"; break;

                       case 23: sItem = "NW_IT_MGLOVE020"; break;
                       case 24: sItem = "NW_IT_MGLOVE025"; break;

                   }

            }
           //dbSpeak("Specific Monk Weapon");

           dbCreateItemOnObject(sItem, oTarget, 1);

        }

        void CreateGenericDruidWeapon(object oTarget, object oAdventurer, int nModifier = 0)
        {
            string sItem = "";
            int nHD = GetHitDice(oAdventurer) + nModifier;

            if (GetRange(1, nHD))    // * 200
            {
                  int nRandom = Random(8) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wthdt001"; break;
                       case 2: sItem = "nw_wblcl001"; break;
                       case 3: sItem = "nw_wdbqs001"; break;
                       case 4: sItem = "nw_wplss001"; break;
                       case 5: sItem = "nw_wswdg001"; break;
                       case 6: sItem = "nw_wspsc001"; break;
                       case 7: sItem = "nw_wswsc001"; break;
                       case 8: sItem = "nw_wthmdt002"; break;
                   }
            }
            else if (GetRange(2, nHD))   // * 800
            {
                  int nRandom = Random(11) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wthdt001"; break;
                       case 2: sItem = "nw_wblcl001"; break;
                       case 3: sItem = "nw_wdbqs001"; break;
                       case 4: sItem = "nw_wplss001"; break;
                       case 5: sItem = "nw_wswdg001"; break;
                       case 6: sItem = "nw_wspsc001"; break;
                       case 7: sItem = "nw_wswsc001"; break;
                       case 8: sItem = "nw_wthmdt002"; break;
                       case 9: sItem = "nw_wthmdt005"; break;
                       case 10: sItem = "nw_wbwmsl001"; break;
                       case 11: sItem = "nw_wthmdt008"; break;
                   }

            }
            else if (GetRange(3, nHD))   // * 200 - 2500
            {
                  int nRandom = Random(13) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wthmdt005"; break;
                       case 2: sItem = "nw_wbwmsl001"; break;
                       case 3: sItem = "nw_wthmdt008"; break;
                       case 4: sItem = "nw_wthmdt009"; break;
                       case 5: sItem = "nw_wthmdt006"; break;
                       case 6: sItem = "nw_wblmcl002"; break;
                       case 7: sItem = "nw_wdbmqs002"; break;
                       case 8: sItem = "nw_wplmss002"; break;
                       case 9: sItem = "nw_wswmdg002"; break;
                       case 10: sItem = "nw_wspmsc002"; break;
                       case 11: sItem = "nw_wswmsc002"; break;
                       case 12: sItem = "nw_wthmdt003"; break;
                       case 13: sItem = "nw_wbwmsl009"; break;
                   }

            }
            else if (GetRange(4, nHD))   // * 800 - 10000
            {
                  int nRandom = Random(19) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wthmdt009"; break;
                       case 2: sItem = "nw_wthmdt006"; break;
                       case 3: sItem = "nw_wblmcl002"; break;
                       case 4: sItem = "nw_wdbmqs002"; break;
                       case 5: sItem = "nw_wplmss002"; break;
                       case 6: sItem = "nw_wswmdg002"; break;
                       case 7: sItem = "nw_wspmsc002"; break;
                       case 8: sItem = "nw_wswmsc002"; break;
                       case 9: sItem = "nw_wthmdt003"; break;
                       case 10: sItem = "nw_wbwmsl009"; break;
                       case 11: sItem = "nw_wthmdt007"; break;
                       case 12: sItem = "nw_wthmdt004"; break;
                       case 13: sItem = "nw_wbwmsl010"; break;
                       case 14: sItem = "nw_wblmcl010"; break;
                       case 15: sItem = "nw_wdbmqs008"; break;
                       case 16: sItem = "nw_wplmss010"; break;
                       case 17: sItem = "nw_wswmdg008"; break;
                       case 18: sItem = "nw_wspmsc010"; break;
                       case 19: sItem = "nw_wswmsc010"; break;
                   }

            }
            else  // * 2500 - 16500
            {
                  int nRandom = Random(15) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wthmdt007"; break;
                       case 2: sItem = "nw_wthmdt004"; break;
                       case 3: sItem = "nw_wbwmsl010"; break;
                       case 4: sItem = "nw_wblmcl010"; break;
                       case 5: sItem = "nw_wdbmqs008"; break;
                       case 6: sItem = "nw_wplmss010"; break;
                       case 7: sItem = "nw_wswmdg008"; break;
                       case 8: sItem = "nw_wspmsc010"; break;
                       case 9: sItem = "nw_wswmsc010"; break;
                       case 10: sItem = "nw_wblmcl011"; break;
                       case 11: sItem = "nw_wdbmqs009"; break;
                       case 12: sItem = "nw_wplmss011"; break;
                       case 13: sItem = "nw_wswmdg009"; break;
                       case 14: sItem = "nw_wspmsc011"; break;
                       case 15: sItem = "nw_wswmsc011"; break;
                   }

            }
          //dbSpeak("Generic Druid weapon");

           dbCreateItemOnObject(sItem, oTarget, 1);


        }
        
		void CreateSpecificDruidWeapon(object oTarget, object oAdventurer, int nModifier = 0)
        {

            string sItem = "";
            int nHD = GetHitDice(oAdventurer) + nModifier;

            if (GetRange(1, nHD))    // * 800
            {
                CreateGenericDruidWeapon(oTarget, oAdventurer, JUMP_LEVEL); return;

            }
            else if (GetRange(2, nHD))   // * 2500
            {
                CreateGenericDruidWeapon(oTarget, oAdventurer, JUMP_LEVEL); return;
            }
            else if (GetRange(3, nHD))   // * 800 - 10000
            {
                  int nRandom = Random(5) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wdbmqs005"; break;
                       case 2: sItem = "nw_wdbmqs006"; break;
                       case 3: sItem = "nw_wbwmsl005"; break;
                       case 4: sItem = "nw_wswmdg006"; break;
                       case 5: CreateGenericDruidWeapon(oTarget, oAdventurer, JUMP_LEVEL); return; break;
                   }

            }
            else if (GetRange(4, nHD))   // * 2500 -16500
            {
                  int nRandom = Random(10) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wdbmqs005"; break;
                       case 2: sItem = "nw_wdbmqs006"; break;
                       case 3: sItem = "nw_wbwmsl005"; break;
                       case 4: sItem = "nw_wswmdg006"; break;
                       case 5: sItem = "nw_wblmcl004"; break;
                       case 6: sItem = "nw_wdbmqs004"; break;
                       case 7: sItem = "nw_wblmcl003"; break;
                       case 8: sItem = "nw_wbwmsl003"; break;
                       case 9: sItem = "nw_wswmsc004"; break;
                       case 10: sItem = "nw_wplmss005"; break;
                   }

            }
            else  // * 16000 +
            {
                  int nRandom = Random(18) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wdbmqs003"; break;
                       case 2: sItem = "nw_wblmcl005"; break;
                       case 3: sItem = "nw_wplmss007"; break;
                       case 4: sItem = "nw_wswmdg004"; break;
                       case 5: sItem = "nw_wbwmsl007"; break;
                       case 6: sItem = "nw_wplmss006"; break;
                       case 7: sItem = "nw_wswmsc006"; break;
                       case 8: sItem = "nw_wswmdg003"; break;
                       case 9: sItem = "nw_wswmdg007"; break;
                       case 10: sItem = "nw_wswmsc007"; break;
                       case 11: sItem = "nw_wbwmsl006"; break;
                       case 12: sItem = "nw_wbwmsl008"; break;
                       case 13: sItem = "nw_wdbmqs007"; break;
                       case 14: sItem = "nw_wblmcl006"; break;
                       case 15: sItem = "nw_wbwmsl004"; break;
                       case 16: sItem = "nw_wswmsc005"; break;
                       case 17: sItem = "nw_wplmss004"; break;
                       case 18: sItem = "nw_wswmdg005"; break;
                   }

            }
          //dbSpeak("specific druid weapon");

           dbCreateItemOnObject(sItem, oTarget, 1);

        }

        void CreateGenericWizardWeapon(object oTarget, object oAdventurer, int nModifier = 0)
        {
            string sItem = "";
            int nHD = GetHitDice(oAdventurer) + nModifier;

            if (GetRange(1, nHD))    // * 200
            {
                  int nRandom = Random(5) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wblcl001"; break;
                       case 2: sItem = "nw_wdbqs001"; break;
                       case 3: sItem = "nw_wswdg001"; break;
                       case 4: sItem = "nw_wbwxh001"; break;
                       case 5: sItem = "nw_wbwxl001"; break;
                   }

            }
            else if (GetRange(2, nHD))   // * 800
            {
                  int nRandom = Random(6) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wblcl001"; break;
                       case 2: sItem = "nw_wdbqs001"; break;
                       case 3: sItem = "nw_wswdg001"; break;
                       case 4: sItem = "nw_wbwxh001"; break;
                       case 5: sItem = "nw_wbwxl001"; break;
                       case 6: sItem = "nw_wbwmxl002"; break;
                   }

            }
            else if (GetRange(3, nHD))   // * 200 - 2500
            {
                  int nRandom = Random(6) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wbwmxl002"; break;
                       case 2: sItem = "nw_wblmcl002"; break;
                       case 3: sItem = "nw_wdbmqs002"; break;
                       case 4: sItem = "nw_wswmdg002"; break;
                       case 5: sItem = "nw_wbwmxh008"; break;
                       case 6: sItem = "nw_wbwmxl008"; break;
                   }

            }
            else if (GetRange(4, nHD))   // * 800 - 10000
            {
                  int nRandom = Random(10) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wblmcl002"; break;
                       case 2: sItem = "nw_wdbmqs002"; break;
                       case 3: sItem = "nw_wswmdg002"; break;
                       case 4: sItem = "nw_wbwmxh008"; break;
                       case 5: sItem = "nw_wbwmxl008"; break;
                       case 6: sItem = "nw_wbwmxh009"; break;
                       case 7: sItem = "nw_wbwmxl009"; break;
                       case 8: sItem = "nw_wblmcl010"; break;
                       case 9: sItem = "nw_wdbmqs008"; break;
                       case 10: sItem = "nw_wswmdg008"; break;
                   }

            }
            else  // * 2500 - 16500
            {
                  int nRandom = Random(8) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wbwmxh009"; break;
                       case 2: sItem = "nw_wbwmxl009"; break;
                       case 3: sItem = "nw_wblmcl010"; break;
                       case 4: sItem = "nw_wdbmqs008"; break;
                       case 5: sItem = "nw_wswmdg008"; break;
                       case 6: sItem = "nw_wblmcl011"; break;
                       case 7: sItem = "nw_wdbmqs009"; break;
                       case 8: sItem = "nw_wswmdg009"; break;
                   }

            }
          //dbSpeak("Generic Wizard or Sorcerer Weapon");

           dbCreateItemOnObject(sItem, oTarget, 1);

        }
        
		void CreateSpecificWizardWeapon(object oTarget, object oAdventurer, int nModifier = 0)
        {

            string sItem = "";
            int nHD = GetHitDice(oAdventurer) + nModifier;

            if (GetRange(1, nHD))    // * 800
            {
                CreateGenericWizardWeapon(oTarget, oAdventurer, JUMP_LEVEL); return;
            }
            else if (GetRange(2, nHD))   // * 2500
            {
                CreateGenericWizardWeapon(oTarget, oAdventurer, JUMP_LEVEL); return;
            }
            else if (GetRange(3, nHD))   // * 800 - 10000
            {
                  int nRandom = Random(5) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wdbmqs005"; break;
                       case 2: sItem = "nw_wdbmqs006"; break;
                       case 3: sItem = "nw_wbwmxh005"; break;
                       case 4: sItem = "nw_wbwmxl005"; break;
                       case 5: sItem = "nw_wswmdg006"; break;
                   }

            }
            else if (GetRange(4, nHD))   // * 2500 -16500
            {
                  int nRandom = Random(10) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wdbmqs005"; break;
                       case 2: sItem = "nw_wdbmqs006"; break;
                       case 3: sItem = "nw_wbwmxh005"; break;
                       case 4: sItem = "nw_wbwmxl005"; break;
                       case 5: sItem = "nw_wswmdg006"; break;
                       case 6: sItem = "nw_wblmcl004"; break;
                       case 7: sItem = "nw_wdbmqs004"; break;
                       case 8: sItem = "nw_wblmcl003"; break;
                       case 9: sItem = "nw_wbwmxh003"; break;
                       case 10: sItem = "nw_wbwmxl003"; break;
                   }

            }
            else  // * 16000 +
            {
                  int nRandom = Random(15) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wbwmxl003"; break;
                       case 2: sItem = "nw_wdbmqs003"; break;
                       case 3: sItem = "nw_wbwmxl004"; break;
                       case 4: sItem = "nw_wbwmxl007"; break;
                       case 5: sItem = "nw_wblmcl005"; break;
                       case 6: sItem = "nw_wswmdg004"; break;
                       case 7: sItem = "nw_wbwmxh004"; break;
                       case 8: sItem = "nw_wbwmxh007"; break;
                       case 9: sItem = "nw_wswmdg003"; break;
                       case 10: sItem = "nw_wswmdg007"; break;
                       case 11: sItem = "nw_wdbmqs007"; break;
                       case 12: sItem = "nw_wblmcl006"; break;
                       case 13: sItem = "nw_wbwmxh006"; break;
                       case 14: sItem = "nw_wswmdg005"; break;
                       case 15: sItem = "nw_wbwmxl006"; break;
                   }

            }
          //dbSpeak("Specific Wizard or Sorcerer Weapon");

           dbCreateItemOnObject(sItem, oTarget, 1);

        }

        void CreateGenericSimple(object oTarget, object oAdventurer, int nModifier = 0)
        {
           string sItem = "";
           int nHD = GetHitDice(oAdventurer) + nModifier;

  if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }

            if (GetRange(1, nHD))    // * 200
            {
                int nRandom = Random(11) + 1;
                switch (nRandom)
                {
                    case 1: sItem = "nw_wthdt001"; break;          // *** Dart ***
                    case 2: sItem = "nw_wblcl001"; break;          // *** Club ***
                    case 3: sItem = "nw_wbwsl001"; break;          // *** Sling ***
                    case 4: sItem = "nw_wplss001"; break;          // *** Shortspear ***
                    case 5: sItem = "nw_wdbqs001"; break;          // *** Quarterstaff ***
                    case 6: sItem = "nw_wswdg001"; break;          // *** Dagger ***
                    case 7: sItem = "nw_wblml001"; break;          // *** Mace ***
                    case 8: sItem = "nw_wbwxh001"; break;          // *** Heavy Crossbow ***
                    case 9: sItem = "nw_wspsc001"; break;          // *** Sickle ***
                    case 10: sItem = "nw_wblms001"; break;          // *** Morningstar ***
                    case 11: sItem = "nw_wbwxl001"; break;          // *** Light Crossbow ***
                }

            }
            else if (GetRange(2, nHD))   // * 800
            {
                int nRandom = Random(11) + 1;
                switch (nRandom)
                {
                    case 1: sItem = "nw_wthdt001"; break;          // *** Dart ***
                    case 2: sItem = "nw_wblcl001"; break;          // *** Club ***
                    case 3: sItem = "nw_wbwsl001"; break;          // *** Sling ***
                    case 4: sItem = "nw_wplss001"; break;          // *** Shortspear ***
                    case 5: sItem = "nw_wdbqs001"; break;          // *** Quarterstaff ***
                    case 6: sItem = "nw_wswdg001"; break;          // *** Dagger ***
                    case 7: sItem = "nw_wblml001"; break;          // *** Mace ***
                    case 8: sItem = "nw_wbwxh001"; break;          // *** Heavy Crossbow ***
                    case 9: sItem = "nw_wspsc001"; break;          // *** Sickle ***
                    case 10: sItem = "nw_wblms001"; break;          // *** Morningstar ***
                    case 11: sItem = "nw_wbwxl001"; break;          // *** Light Crossbow ***
                }
            }
            else if (GetRange(3, nHD))   // * 200 - 2500
            {
                int nRandom = Random(11) + 1;
                switch (nRandom)
                {
                    case 1: sItem = "nw_wthdt001"; break;          // *** Dart ***
                    case 2: sItem = "nw_wblcl001"; break;          // *** Club ***
                    case 3: sItem = "nw_wbwsl001"; break;          // *** Sling ***
                    case 4: sItem = "nw_wplss001"; break;          // *** Shortspear ***
                    case 5: sItem = "nw_wdbqs001"; break;          // *** Quarterstaff ***
                    case 6: sItem = "nw_wswdg001"; break;          // *** Dagger ***
                    case 7: sItem = "nw_wblml001"; break;          // *** Mace ***
                    case 8: sItem = "nw_wbwxh001"; break;          // *** Heavy Crossbow ***
                    case 9: sItem = "nw_wspsc001"; break;          // *** Sickle ***
                    case 10: sItem = "nw_wblms001"; break;          // *** Morningstar ***
                    case 11: sItem = "nw_wbwxl001"; break;          // *** Light Crossbow ***
                }
            }
            else if (GetRange(4, nHD))   // * 800 - 10000
            {
                int nRandom = Random(11) + 1;
                switch (nRandom)
                {
                    case 1: sItem = "nw_wthdt001"; break;          // *** Dart ***
                    case 2: sItem = "nw_wblcl001"; break;          // *** Club ***
                    case 3: sItem = "nw_wbwsl001"; break;          // *** Sling ***
                    case 4: sItem = "nw_wplss001"; break;          // *** Shortspear ***
                    case 5: sItem = "nw_wdbqs001"; break;          // *** Quarterstaff ***
                    case 6: sItem = "nw_wswdg001"; break;          // *** Dagger ***
                    case 7: sItem = "nw_wblml001"; break;          // *** Mace ***
                    case 8: sItem = "nw_wbwxh001"; break;          // *** Heavy Crossbow ***
                    case 9: sItem = "nw_wspsc001"; break;          // *** Sickle ***
                    case 10: sItem = "nw_wblms001"; break;          // *** Morningstar ***
                    case 11: sItem = "nw_wbwxl001"; break;          // *** Light Crossbow ***
                }

            }
            else if (GetRange(5, nHD))   // * 2500 - 16500
            {
                int nRandom = Random(11) + 1;
                switch (nRandom)
                {
                    case 1: sItem = "nw_wthdt001"; break;          // *** Dart ***
                    case 2: sItem = "nw_wblcl001"; break;          // *** Club ***
                    case 3: sItem = "nw_wbwsl001"; break;          // *** Sling ***
                    case 4: sItem = "nw_wplss001"; break;          // *** Shortspear ***
                    case 5: sItem = "nw_wdbqs001"; break;          // *** Quarterstaff ***
                    case 6: sItem = "nw_wswdg001"; break;          // *** Dagger ***
                    case 7: sItem = "nw_wblml001"; break;          // *** Mace ***
                    case 8: sItem = "nw_wbwxh001"; break;          // *** Heavy Crossbow ***
                    case 9: sItem = "nw_wspsc001"; break;          // *** Sickle ***
                    case 10: sItem = "nw_wblms001"; break;          // *** Morningstar ***
                    case 11: sItem = "nw_wbwxl001"; break;          // *** Light Crossbow ***
                }
            }
            else if (GetRange(6, nHD))   // * 8000 - 25000
            {
                int nRandom = Random(11) + 1;
                switch (nRandom)
                {
                    case 1: sItem = "nw_wthdt001"; break;          // *** Dart ***
                    case 2: sItem = "nw_wblcl001"; break;          // *** Club ***
                    case 3: sItem = "nw_wbwsl001"; break;          // *** Sling ***
                    case 4: sItem = "nw_wplss001"; break;          // *** Shortspear ***
                    case 5: sItem = "nw_wdbqs001"; break;          // *** Quarterstaff ***
                    case 6: sItem = "nw_wswdg001"; break;          // *** Dagger ***
                    case 7: sItem = "nw_wblml001"; break;          // *** Mace ***
                    case 8: sItem = "nw_wbwxh001"; break;          // *** Heavy Crossbow ***
                    case 9: sItem = "nw_wspsc001"; break;          // *** Sickle ***
                    case 10: sItem = "nw_wblms001"; break;          // *** Morningstar ***
                    case 11: sItem = "nw_wbwxl001"; break;          // *** Light Crossbow ***
                }
            }


            dbCreateItemOnObject(sItem, oTarget, 1);
        }
        
		void CreateGenericMartial(object oTarget, object oAdventurer, int nModifier = 0)
        {
           string sItem = "";

            int nHD = GetHitDice(oAdventurer) +nModifier;

  if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }

            if (GetRange(1, nHD))    // * 200
            {
                int nRandom = Random(17) + 1;
                switch (nRandom)
                {
                    case 1: sItem = "nw_wthax001"; break;          // *** Throwing Axe ***
                    case 2: sItem = "nw_wblhl001"; break;          // *** Light Hammer ***
                    case 3: sItem = "nw_waxhn001"; break;          // *** Handaxe ***
                    case 4: sItem = "nw_wblfl001"; break;          // *** Light Flail ***
                    case 5: sItem = "nw_waxbt001"; break;          // *** Battleaxe ***
                    case 6: sItem = "nw_wplhb001"; break;          // *** Halberd ***
                    case 7: sItem = "nw_wswss001"; break;          // *** Shortsword ***
                    case 8: sItem = "nw_wblhw001"; break;          // *** Warhammer ***
                    case 9: sItem = "nw_wblfh001"; break;          // *** Heavy Flail ***
                    case 10: sItem = "nw_wswls001"; break;          // *** Longsword ***
                    case 11: sItem = "nw_wswsc001"; break;          // *** Scimitar ***
                    case 12: sItem = "nw_waxgr001"; break;          // *** Greataxe ***
                    case 13: sItem = "nw_wswrp001"; break;          // *** Rapier ***
                    case 14: sItem = "nw_wbwsh001"; break;          // *** Shortbow ***
                    case 15: sItem = "nw_wswbs001"; break;          // *** Bastard Sword ***
                    case 16: sItem = "nw_wswgs001"; break;          // *** Greatsword ***
                    case 17: sItem = "nw_wbwln001"; break;          // *** Longbow ***
                }

            }
            else if (GetRange(2, nHD))   // * 800
            {
                 int nRandom = Random(17) + 1;
                switch (nRandom)
                {
                    case 1: sItem = "nw_wthax001"; break;          // *** Throwing Axe ***
                    case 2: sItem = "nw_wblhl001"; break;          // *** Light Hammer ***
                    case 3: sItem = "nw_waxhn001"; break;          // *** Handaxe ***
                    case 4: sItem = "nw_wblfl001"; break;          // *** Light Flail ***
                    case 5: sItem = "nw_waxbt001"; break;          // *** Battleaxe ***
                    case 6: sItem = "nw_wplhb001"; break;          // *** Halberd ***
                    case 7: sItem = "nw_wswss001"; break;          // *** Shortsword ***
                    case 8: sItem = "nw_wblhw001"; break;          // *** Warhammer ***
                    case 9: sItem = "nw_wblfh001"; break;          // *** Heavy Flail ***
                    case 10: sItem = "nw_wswls001"; break;          // *** Longsword ***
                    case 11: sItem = "nw_wswsc001"; break;          // *** Scimitar ***
                    case 12: sItem = "nw_waxgr001"; break;          // *** Greataxe ***
                    case 13: sItem = "nw_wswrp001"; break;          // *** Rapier ***
                    case 14: sItem = "nw_wbwsh001"; break;          // *** Shortbow ***
                    case 15: sItem = "nw_wswbs001"; break;          // *** Bastard Sword ***
                    case 16: sItem = "nw_wswgs001"; break;          // *** Greatsword ***
                    case 17: sItem = "nw_wbwln001"; break;          // *** Longbow ***
                }


            }
            else if (GetRange(3, nHD))   // * 200 - 2500
            {
                 int nRandom = Random(17) + 1;
                switch (nRandom)
                {
                    case 1: sItem = "nw_wthax001"; break;          // *** Throwing Axe ***
                    case 2: sItem = "nw_wblhl001"; break;          // *** Light Hammer ***
                    case 3: sItem = "nw_waxhn001"; break;          // *** Handaxe ***
                    case 4: sItem = "nw_wblfl001"; break;          // *** Light Flail ***
                    case 5: sItem = "nw_waxbt001"; break;          // *** Battleaxe ***
                    case 6: sItem = "nw_wplhb001"; break;          // *** Halberd ***
                    case 7: sItem = "nw_wswss001"; break;          // *** Shortsword ***
                    case 8: sItem = "nw_wblhw001"; break;          // *** Warhammer ***
                    case 9: sItem = "nw_wblfh001"; break;          // *** Heavy Flail ***
                    case 10: sItem = "nw_wswls001"; break;          // *** Longsword ***
                    case 11: sItem = "nw_wswsc001"; break;          // *** Scimitar ***
                    case 12: sItem = "nw_waxgr001"; break;          // *** Greataxe ***
                    case 13: sItem = "nw_wswrp001"; break;          // *** Rapier ***
                    case 14: sItem = "nw_wbwsh001"; break;          // *** Shortbow ***
                    case 15: sItem = "nw_wswbs001"; break;          // *** Bastard Sword ***
                    case 16: sItem = "nw_wswgs001"; break;          // *** Greatsword ***
                    case 17: sItem = "nw_wbwln001"; break;          // *** Longbow ***
                }


            }
            else if (GetRange(4, nHD))   // * 800 - 10000
            {
                 int nRandom = Random(17) + 1;
                switch (nRandom)
                {
                    case 1: sItem = "nw_wthax001"; break;          // *** Throwing Axe ***
                    case 2: sItem = "nw_wblhl001"; break;          // *** Light Hammer ***
                    case 3: sItem = "nw_waxhn001"; break;          // *** Handaxe ***
                    case 4: sItem = "nw_wblfl001"; break;          // *** Light Flail ***
                    case 5: sItem = "nw_waxbt001"; break;          // *** Battleaxe ***
                    case 6: sItem = "nw_wplhb001"; break;          // *** Halberd ***
                    case 7: sItem = "nw_wswss001"; break;          // *** Shortsword ***
                    case 8: sItem = "nw_wblhw001"; break;          // *** Warhammer ***
                    case 9: sItem = "nw_wblfh001"; break;          // *** Heavy Flail ***
                    case 10: sItem = "nw_wswls001"; break;          // *** Longsword ***
                    case 11: sItem = "nw_wswsc001"; break;          // *** Scimitar ***
                    case 12: sItem = "nw_waxgr001"; break;          // *** Greataxe ***
                    case 13: sItem = "nw_wswrp001"; break;          // *** Rapier ***
                    case 14: sItem = "nw_wbwsh001"; break;          // *** Shortbow ***
                    case 15: sItem = "nw_wswbs001"; break;          // *** Bastard Sword ***
                    case 16: sItem = "nw_wswgs001"; break;          // *** Greatsword ***
                    case 17: sItem = "nw_wbwln001"; break;          // *** Longbow ***
                }


            }
            else if (GetRange(5, nHD))   // * 2500 - 16500
            {
                   int nRandom = Random(17) + 1;
                switch (nRandom)
                {
                    case 1: sItem = "nw_wthax001"; break;          // *** Throwing Axe ***
                    case 2: sItem = "nw_wblhl001"; break;          // *** Light Hammer ***
                    case 3: sItem = "nw_waxhn001"; break;          // *** Handaxe ***
                    case 4: sItem = "nw_wblfl001"; break;          // *** Light Flail ***
                    case 5: sItem = "nw_waxbt001"; break;          // *** Battleaxe ***
                    case 6: sItem = "nw_wplhb001"; break;          // *** Halberd ***
                    case 7: sItem = "nw_wswss001"; break;          // *** Shortsword ***
                    case 8: sItem = "nw_wblhw001"; break;          // *** Warhammer ***
                    case 9: sItem = "nw_wblfh001"; break;          // *** Heavy Flail ***
                    case 10: sItem = "nw_wswls001"; break;          // *** Longsword ***
                    case 11: sItem = "nw_wswsc001"; break;          // *** Scimitar ***
                    case 12: sItem = "nw_waxgr001"; break;          // *** Greataxe ***
                    case 13: sItem = "nw_wswrp001"; break;          // *** Rapier ***
                    case 14: sItem = "nw_wbwsh001"; break;          // *** Shortbow ***
                    case 15: sItem = "nw_wswbs001"; break;          // *** Bastard Sword ***
                    case 16: sItem = "nw_wswgs001"; break;          // *** Greatsword ***
                    case 17: sItem = "nw_wbwln001"; break;          // *** Longbow ***
                }


            }
            else if (GetRange(6, nHD))   // * 8000 - 25000
            {
                   int nRandom = Random(17) + 1;
                switch (nRandom)
                {
                    case 1: sItem = "nw_wthax001"; break;          // *** Throwing Axe ***
                    case 2: sItem = "nw_wblhl001"; break;          // *** Light Hammer ***
                    case 3: sItem = "nw_waxhn001"; break;          // *** Handaxe ***
                    case 4: sItem = "nw_wblfl001"; break;          // *** Light Flail ***
                    case 5: sItem = "nw_waxbt001"; break;          // *** Battleaxe ***
                    case 6: sItem = "nw_wplhb001"; break;          // *** Halberd ***
                    case 7: sItem = "nw_wswss001"; break;          // *** Shortsword ***
                    case 8: sItem = "nw_wblhw001"; break;          // *** Warhammer ***
                    case 9: sItem = "nw_wblfh001"; break;          // *** Heavy Flail ***
                    case 10: sItem = "nw_wswls001"; break;          // *** Longsword ***
                    case 11: sItem = "nw_wswsc001"; break;          // *** Scimitar ***
                    case 12: sItem = "nw_waxgr001"; break;          // *** Greataxe ***
                    case 13: sItem = "nw_wswrp001"; break;          // *** Rapier ***
                    case 14: sItem = "nw_wbwsh001"; break;          // *** Shortbow ***
                    case 15: sItem = "nw_wswbs001"; break;          // *** Bastard Sword ***
                    case 16: sItem = "nw_wswgs001"; break;          // *** Greatsword ***
                    case 17: sItem = "nw_wbwln001"; break;          // *** Longbow ***
                }


            }



           dbCreateItemOnObject(sItem, oTarget, 1);
        }
        
		void CreateGenericExotic(object oTarget, object oAdventurer, int nModifier = 0)
        {
            string sItem = "";

            int nHD = GetHitDice(oAdventurer) + nModifier;

  if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }

            if (GetRange(1, nHD))    // * 200
            {
                  int nRandom = Random(8) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wthsh001"; break;          // *** Shuriken ***
                       case 2: sItem = "nw_wspka001"; break;          // *** Kama ***
                       case 3: sItem = "nw_wspku001"; break;          // *** Kukri ***
                       case 4: sItem = "nw_wplsc001"; break;          // *** Scythe ***
                       case 5: sItem = "nw_wdbax001"; break;          // *** Double Axe ***
                       case 6: sItem = "nw_wdbma001"; break;          // *** Dire Mace ***
                       case 7: sItem = "nw_wswka001"; break;          // *** Katana ***
                       case 8: sItem = "nw_wdbsw001"; break;          // *** Two-Bladed Sword ***
                   }

            }
            else if (GetRange(2, nHD))   // * 800
            {
                  int nRandom = Random(8) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wthsh001"; break;          // *** Shuriken ***
                       case 2: sItem = "nw_wspka001"; break;          // *** Kama ***
                       case 3: sItem = "nw_wspku001"; break;          // *** Kukri ***
                       case 4: sItem = "nw_wplsc001"; break;          // *** Scythe ***
                       case 5: sItem = "nw_wdbax001"; break;          // *** Double Axe ***
                       case 6: sItem = "nw_wdbma001"; break;          // *** Dire Mace ***
                       case 7: sItem = "nw_wswka001"; break;          // *** Katana ***
                       case 8: sItem = "nw_wdbsw001"; break;          // *** Two-Bladed Sword ***
                   }
            }
            else if (GetRange(3, nHD))   // * 200 - 2500
            {
                  int nRandom = Random(8) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wthsh001"; break;          // *** Shuriken ***
                       case 2: sItem = "nw_wspka001"; break;          // *** Kama ***
                       case 3: sItem = "nw_wspku001"; break;          // *** Kukri ***
                       case 4: sItem = "nw_wplsc001"; break;          // *** Scythe ***
                       case 5: sItem = "nw_wdbax001"; break;          // *** Double Axe ***
                       case 6: sItem = "nw_wdbma001"; break;          // *** Dire Mace ***
                       case 7: sItem = "nw_wswka001"; break;          // *** Katana ***
                       case 8: sItem = "nw_wdbsw001"; break;          // *** Two-Bladed Sword ***
                   }

            }
            else if (GetRange(4, nHD))   // * 800 - 10000
            {
                 int nRandom = Random(8) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wthsh001"; break;          // *** Shuriken ***
                       case 2: sItem = "nw_wspka001"; break;          // *** Kama ***
                       case 3: sItem = "nw_wspku001"; break;          // *** Kukri ***
                       case 4: sItem = "nw_wplsc001"; break;          // *** Scythe ***
                       case 5: sItem = "nw_wdbax001"; break;          // *** Double Axe ***
                       case 6: sItem = "nw_wdbma001"; break;          // *** Dire Mace ***
                       case 7: sItem = "nw_wswka001"; break;          // *** Katana ***
                       case 8: sItem = "nw_wdbsw001"; break;          // *** Two-Bladed Sword ***
                   }
            }
            else if (GetRange(5, nHD))   // * 2500 - 16500
            {
                  int nRandom = Random(8) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wthsh001"; break;          // *** Shuriken ***
                       case 2: sItem = "nw_wspka001"; break;          // *** Kama ***
                       case 3: sItem = "nw_wspku001"; break;          // *** Kukri ***
                       case 4: sItem = "nw_wplsc001"; break;          // *** Scythe ***
                       case 5: sItem = "nw_wdbax001"; break;          // *** Double Axe ***
                       case 6: sItem = "nw_wdbma001"; break;          // *** Dire Mace ***
                       case 7: sItem = "nw_wswka001"; break;          // *** Katana ***
                       case 8: sItem = "nw_wdbsw001"; break;          // *** Two-Bladed Sword ***
                   }

            }
            else if (GetRange(6, nHD))   // * 8000 - 25000
            {
                  int nRandom = Random(8) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_wthsh001"; break;          // *** Shuriken ***
                       case 2: sItem = "nw_wspka001"; break;          // *** Kama ***
                       case 3: sItem = "nw_wspku001"; break;          // *** Kukri ***
                       case 4: sItem = "nw_wplsc001"; break;          // *** Scythe ***
                       case 5: sItem = "nw_wdbax001"; break;          // *** Double Axe ***
                       case 6: sItem = "nw_wdbma001"; break;          // *** Dire Mace ***
                       case 7: sItem = "nw_wswka001"; break;          // *** Katana ***
                       case 8: sItem = "nw_wdbsw001"; break;          // *** Two-Bladed Sword ***
                   }

            }


           dbCreateItemOnObject(sItem, oTarget, 1);
        }
        
		void CreateGenericLightArmor(object oTarget, object oAdventurer, int nModifier = 0)
        {
            string sItem = "";

            int nHD = GetHitDice(oAdventurer) + nModifier;

  if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }

            if (GetRange(1, nHD))    // * 200
            {
                  int nRandom = Random(5) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "commonpaddedarmo"; break;          // *** Padded Armor ***
                       case 2: sItem = "nw_ashsw001"; break;          // *** Small Shield ***
                       case 3: sItem = "commonleatherarm"; break;          // *** Leather Armor ***
                       case 4: sItem = "commonstuddedlea"; break;          // *** Studded Leather Armor ***
                       case 5: sItem = "commonhidearmor"; break;          // *** Hide Armort ***
                    /*   case 6: sItem = "jw_darkleth"; break;              // Armour of the Shadows
                       case 7: sItem = "ph_paddedarch"; break;              // Archendale Armour
                       case 8: sItem = "jw_eartharm_com"; break;              // Earth mother armour
                       case 9: sItem = "jw_newlighto"; break;              // Bulette oxe armourBul
                       case 10: sItem = "jw_bluelight_o"; break;              // Hap armour
                       case 11: sItem = "jw_corma_o"; break;              // Cormanthor Armour
                    */


                  }

            }
            else if (GetRange(2, nHD))   // * 800
            {
                  int nRandom = Random(5) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "commonpaddedarmo"; break;          // *** Padded Armor ***
                       case 2: sItem = "nw_ashsw001"; break;          // *** Small Shield ***
                       case 3: sItem = "commonleatherarm"; break;          // *** Leather Armor ***
                       case 4: sItem = "commonstuddedlea"; break;          // *** Studded Leather Armor ***
                       case 5: sItem = "commonhidearmor"; break;          // *** Hide Armort ***
                       case 6: sItem = "jw_darkleth"; break;              // Armour of the Shadows
                       case 7: sItem = "ph_paddedarch"; break;              // Archendale Armour
                       case 8: sItem = "jw_eartharm_com"; break;              // Earth mother armour
                       case 9: sItem = "jw_newlighto"; break;              // Bulette oxe armour
                       case 10: sItem = "jw_bluelight_o"; break;              // Hap armour
                       case 11: sItem = "jw_corma_o"; break;              // Cormanthor Armour
                   }

            }
            else if (GetRange(3, nHD))   // * 200 - 2500
            {
                  int nRandom = Random(5) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "commonpaddedarmo"; break;          // *** Padded Armor ***
                       case 2: sItem = "nw_ashsw001"; break;          // *** Small Shield ***
                       case 3: sItem = "commonleatherarm"; break;          // *** Leather Armor ***
                       case 4: sItem = "commonstuddedlea"; break;          // *** Studded Leather Armor ***
                       case 5: sItem = "commonhidearmor"; break;          // *** Hide Armort ***
                      case 6: sItem = "jw_darkleth"; break;              // Armour of the Shadows
                      case 7: sItem = "ph_paddedarch"; break;              // Archendale Armour
                       case 8: sItem = "jw_eartharm_com"; break;              // Earth mother armour
                       case 9: sItem = "jw_newlighto"; break;              // Bulette oxe armour
                      case 10: sItem = "jw_bluelight_o"; break;              // Hap armour
                       case 11: sItem = "jw_corma_o"; break;              // Cormanthor Armour
                  }

            }
            else if (GetRange(4, nHD))   // * 800 - 10000
            {
                  int nRandom = Random(5) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "commonpaddedarmo"; break;          // *** Padded Armor ***
                       case 2: sItem = "nw_ashsw001"; break;          // *** Small Shield ***
                       case 3: sItem = "commonleatherarm"; break;          // *** Leather Armor ***
                       case 4: sItem = "commonstuddedlea"; break;          // *** Studded Leather Armor ***
                       case 5: sItem = "commonhidearmor"; break;          // *** Hide Armort ***
                       case 6: sItem = "jw_darkleth"; break;              // Armour of the Shadows
                       case 7: sItem = "ph_paddedarch"; break;              // Archendale Armour
                        case 8: sItem = "jw_eartharm_com"; break;              // Earth mother armour
                       case 9: sItem = "jw_newlighto"; break;              // Bulette oxe armour
                      case 10: sItem = "jw_bluelight_o"; break;              // Hap armour
                       case 11: sItem = "jw_corma_o"; break;              // Cormanthor Armour
                   }

            }
            else if (GetRange(5, nHD))   // * 2500 - 16500
            {
                  int nRandom = Random(5) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "commonpaddedarmo"; break;          // *** Padded Armor ***
                       case 2: sItem = "nw_ashsw001"; break;          // *** Small Shield ***
                       case 3: sItem = "commonleatherarm"; break;          // *** Leather Armor ***
                       case 4: sItem = "commonstuddedlea"; break;          // *** Studded Leather Armor ***
                       case 5: sItem = "commonhidearmor"; break;          // *** Hide Armort ***
                       case 6: sItem = "jw_darkleth"; break;              // Armour of the Shadows
                       case 7: sItem = "ph_paddedarch"; break;              // Archendale Armour
                        case 8: sItem = "jw_eartharm_com"; break;              // Earth mother armour
                       case 9: sItem = "jw_newlighto"; break;              // Bulette oxe armour
                       case 10: sItem = "jw_bluelight_o"; break;              // Hap armour
                        case 11: sItem = "jw_corma_o"; break;              // Cormanthor Armour
                  }

            }
            else if (GetRange(6, nHD))   // * 8000 - 25000
            {
                  int nRandom = Random(5) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "commonpaddedarmo"; break;          // *** Padded Armor ***
                       case 2: sItem = "nw_ashsw001"; break;          // *** Small Shield ***
                       case 3: sItem = "commonleatherarm"; break;          // *** Leather Armor ***
                       case 4: sItem = "commonstuddedlea"; break;          // *** Studded Leather Armor ***
                       case 5: sItem = "commonhidearmor"; break;          // *** Hide Armort ***
                       case 6: sItem = "jw_darkleth"; break;              // Armour of the Shadows
                       case 7: sItem = "ph_paddedarch"; break;              // Archendale Armour
                       case 8: sItem = "jw_eartharm_com"; break;              // Earth mother armour
                       case 9: sItem = "jw_newlighto"; break;              // Bulette oxe armour
                       case 10: sItem = "jw_bluelight_o"; break;              // Hap armour
                       case 11: sItem = "jw_corma_o"; break;              // Cormanthor Armour
                  }

            }


           dbCreateItemOnObject(sItem, oTarget, 1);
        }
        
		void CreateGenericMediumArmor(object oTarget, object oAdventurer, int nModifier = 0)
        {
            int nHD = GetHitDice(oAdventurer) + nModifier;

          if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }


            string sItem = "";
            if (GetRange(1, nHD))    // * 200
            {
                 int nRandom = Random(11) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "commonhelmet"; break;
                       case 2: sItem = "commonhelmet001"; break;
                       case 3: sItem = "commonhelmet002"; break;
                       case 4: sItem = "commonhelmet003"; break;
                       case 5: sItem = "commonhelmet004"; break;
                       case 6: sItem = "commonhelmet005"; break;
                       case 7: sItem = "commonhelmet006"; break;
                       case 8: sItem = "commonhelmet007"; break;
                       case 9: sItem = "commonchainshirt"; break;
                       case 10: sItem = "commonscalemail"; break;
                       case 11: sItem = "nw_ashlw001"; break;          // *** Large Shield ***
                   }
            }
            else if (GetRange(2, nHD))   // * 800
            {
                  int nRandom = Random(11) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "commonhelmet"; break;
                       case 2: sItem = "commonhelmet001"; break;
                       case 3: sItem = "commonhelmet002"; break;
                       case 4: sItem = "commonhelmet003"; break;
                       case 5: sItem = "commonhelmet004"; break;
                       case 6: sItem = "commonhelmet005"; break;
                       case 7: sItem = "commonhelmet006"; break;
                       case 8: sItem = "commonhelmet007"; break;
                       case 9: sItem = "commonchainshirt"; break;
                       case 10: sItem = "commonscalemail"; break;
                       case 11: sItem = "nw_ashlw001"; break;// *** Large Shield ***
                       case 12: sItem = "jw_arch_arm"; break;  // ladies armour
                       case 13: sItem = "jw_green_arm"; break;  // green armour
                       case 14: sItem = "jw_newy_armo"; break;  // Armour of Amn

                   }

            }
            else if (GetRange(3, nHD))   // * 200 - 2500
            {
                  int nRandom = Random(11) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "commonhelmet"; break;
                       case 2: sItem = "commonhelmet001"; break;
                       case 3: sItem = "commonhelmet002"; break;
                       case 4: sItem = "commonhelmet003"; break;
                       case 5: sItem = "commonhelmet004"; break;
                       case 6: sItem = "commonhelmet005"; break;
                       case 7: sItem = "commonhelmet006"; break;
                       case 8: sItem = "commonhelmet007"; break;
                       case 9: sItem = "commonchainshirt"; break;
                       case 10: sItem = "commonscalemail"; break;
                       case 11: sItem = "nw_ashto001"; break;          // *** Large Shield ***
                       case 12: sItem = "jw_arch_arm"; break;  // ladies armour
                       case 13: sItem = "jw_green_arm"; break;  // green armour
                       case 14: sItem = "jw_newy_armo"; break;  // Armour of Amn
                   }

            }
            else if (GetRange(4, nHD))   // * 800 - 10000
            {
                  int nRandom = Random(11) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "commonhelmet"; break;
                       case 2: sItem = "commonhelmet001"; break;
                       case 3: sItem = "commonhelmet002"; break;
                       case 4: sItem = "commonhelmet003"; break;
                       case 5: sItem = "commonhelmet004"; break;
                       case 6: sItem = "commonhelmet005"; break;
                       case 7: sItem = "commonhelmet006"; break;
                       case 8: sItem = "commonhelmet007"; break;
                       case 9: sItem = "commonchainshirt"; break;
                       case 10: sItem = "commonscalemail"; break;
                       case 11: sItem = "nw_ashlw001"; break;          // *** Large Shield ***
                       case 12: sItem = "jw_arch_arm"; break;  // ladies armour
                       case 13: sItem = "jw_green_arm"; break;  // green armour
                       case 14: sItem = "jw_newy_armo"; break;  // Armour of Amn
                   }

            }
            else if (GetRange(5, nHD))   // * 2500 - 16500
            {
                  int nRandom = Random(11) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "commonhelmet"; break;
                       case 2: sItem = "commonhelmet001"; break;
                       case 3: sItem = "commonhelmet002"; break;
                       case 4: sItem = "commonhelmet003"; break;
                       case 5: sItem = "commonhelmet004"; break;
                       case 6: sItem = "commonhelmet005"; break;
                       case 7: sItem = "commonhelmet006"; break;
                       case 8: sItem = "commonhelmet007"; break;
                       case 9: sItem = "commonchainshirt"; break;
                       case 10: sItem = "commonscalemail"; break;
                       case 11: sItem = "nw_ashlw001"; break;          // *** Large Shield ***
                       case 12: sItem = "jw_arch_arm"; break;  // ladies armour
                       case 13: sItem = "jw_green_arm"; break;  // green armour
                       case 14: sItem = "jw_newy_armo"; break;  // Armour of Amn
                   }

            }
            else if (GetRange(6, nHD))   // * 8000 - 25000
            {
                  int nRandom = Random(11) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "commonhelmet"; break;
                       case 2: sItem = "commonhelmet001"; break;
                       case 3: sItem = "commonhelmet002"; break;
                       case 4: sItem = "commonhelmet003"; break;
                       case 5: sItem = "commonhelmet004"; break;
                       case 6: sItem = "commonhelmet005"; break;
                       case 7: sItem = "commonhelmet006"; break;
                       case 8: sItem = "commonhelmet007"; break;
                       case 9: sItem = "commonchainshirt"; break;
                       case 10: sItem = "commonscalemail"; break;
                       case 11: sItem = "nw_ashlw001"; break;          // *** Large Shield ***
                       case 12: sItem = "jw_arch_arm"; break;  // ladies armour
                       case 13: sItem = "jw_green_arm"; break;  // green armour
                       case 14: sItem = "jw_newy_armo"; break;  // Armour of Amn
                   }

            }


           dbCreateItemOnObject(sItem, oTarget, 1);
        }
        
		void CreateGenericHeavyArmor(object oTarget, object oAdventurer, int nModifier = 0)
        {
            string sItem = "";
            int nHD = GetHitDice(oAdventurer) + nModifier;

  if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }

            if (GetRange(1, nHD))    // * 200
            {
                  int nRandom = Random(5) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "commonleatherarm"; break;          // *** Splint Mail ***
                       case 2: sItem = "commonleatherarm"; break;          // *** Splint Mail ***
                       case 3: sItem = "commonleatherarm"; break;          // *** Banded Mail ****
                       case 4: sItem = "commonleatherarm"; break;          // *** Splint ***
                       case 5: sItem = "commonbandedmail"; break;          // *** Banded ***
                   }

            }
            else if (GetRange(2, nHD))   // * 800
            {
                  int nRandom = Random(6) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_ashto001"; break;          // *** Tower Shield ***
                       case 2: sItem = "commonleatherarm"; break;          // *** Splint Mail ***
                       case 3: sItem = "commonleatherarm"; break;          // *** Banded Mail ****
                       case 4: sItem = "commonleatherarm"; break;          // *** Splint  ***
                       case 5: sItem = "commonbandedmail"; break;          // *** Banded ***
                       case 6: sItem = "commonhalfplate"; break;          // *** Half Plate ***
                      case 7: sItem = "jw_rusty_com"; break;              // Harrowdale armour
                   }

            }
            else if (GetRange(3, nHD))   // * 200 - 2500
            {
                  int nRandom = Random(14) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_ashto001"; break;          // *** Tower Shield ***
                       case 2: sItem = "commonleatherarm"; break;          // *** Splint Mail ***
                       case 3: sItem = "commonbandedmail"; break;          // *** Banded Mail ****
                       case 4: sItem = "commonhalfplate"; break;          // *** Half Plate ***
                       case 5: sItem = "commonleatherarm"; break;          // *** Banded Plate ***
                       case 6: case 7: case 8: sItem = "commonhalfplate"; break;          // *** Half Plate ***
                       case 9:  sItem = "commonfullplate"; break;          // *** Full Plate ***
                      case 10: case 11: case 12: sItem = "jw_rusty_com"; break;              // Harrowdale armour
                      case 13: sItem = "jw_thiriun_armou"; break;         // Thiriun Armour
                      case 14: sItem = "by_dwarvenwar004"; break;         // Byron's Dwarf armour
                   }

            }
            else if (GetRange(4, nHD))   // * 800 - 10000
            {
                  int nRandom = Random(14) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_ashto001"; break;          // *** Tower Shield ***
                       case 2: sItem = "commonsplintmail"; break;          // *** Splint Mail ***
                       case 3: sItem = "commonbandedmail"; break;          // *** Banded Mail ****
                       case 4: sItem = "commonbandedmail"; break;          // *** Half Plate ***
                       case 5: sItem = "commonleatherarm"; break;          // *** Full Plate ***
                       case 6: case 7: case 8: sItem = "commonhalfplate"; break;          // *** Half Plate ***
                       case 9:  sItem = "commonfullplate"; break;          // *** Full Plate ***
                      case 10: case 11: case 12: sItem = "jw_rusty_com"; break;              // Harrowdale armour
                      case 13: sItem = "jw_thiriun_armou"; break;         // Thiriun Armour
                      case 14: sItem = "by_dwarvenwar004"; break;         // Byron's Dwarf armour
                  }

            }
            else if (GetRange(5, nHD))   // * 2500 - 16500
            {
                  int nRandom = Random(14) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_ashto001"; break;          // *** Tower Shield ***
                       case 2: sItem = "commonsplintmail"; break;          // *** Splint Mail ***
                       case 3: sItem = "commonbandedmail"; break;          // *** Banded Mail ****
                       case 4: sItem = "commonbandedmail"; break;          // *** Half Plate ***
                       case 5: sItem = "commonleatherarm"; break;          // *** Full Plate ***
                       case 6: case 7: case 8: sItem = "commonhalfplate"; break;          // *** Half Plate ***
                       case 9:  sItem = "commonfullplate"; break;          // *** Full Plate ***
                      case 10: case 11: case 12: sItem = "jw_rusty_com"; break;              // Harrowdale armour
                      case 13: sItem = "jw_thiriun_armou"; break;         // Thiriun Armour
                      case 14: sItem = "by_dwarvenwar004"; break;         // Byron's Dwarf armour
                  }


            }
            else if (GetRange(6, nHD))   // * 8000 - 25000
            {
                  int nRandom = Random(14) + 1;
                  switch (nRandom)
                  {
                       case 1: sItem = "nw_ashto001"; break;          // *** Tower Shield ***
                       case 2: sItem = "commonsplintmail"; break;          // *** Splint Mail ***
                       case 3: sItem = "commonbandedmail"; break;          // *** Banded Mail ****
                       case 4: sItem = "commonbandedmail"; break;          // *** Half Plate ***
                       case 5: sItem = "commonleatherarm"; break;          // *** Full Plate ***
                       case 6: case 7: case 8: sItem = "commonhalfplate"; break;          // *** Half Plate ***
                       case 9:  sItem = "commonfullplate"; break;          // *** Full Plate ***
                      case 10: case 11: case 12: sItem = "jw_rusty_com"; break;              // Harrowdale armour
                      case 13: sItem = "jw_thiriun_armou"; break;         // Thiriun Armour
                     case 14: sItem = "by_dwarvenwar004"; break;         // Byron's Dwarf armour
                   }

            }


           dbCreateItemOnObject(sItem, oTarget, 1);
        }
        // *
        // * SPECIC TREASURE ITEMS (re: Named Items)
        // *

        void CreateSpecificRodStaffWand(object oTarget, object oAdventurer)
        {
            string sItem = "";
            int nHD = GetHitDice(oAdventurer);


 if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }

            CreateGenericRodStaffWand(oTarget, oAdventurer, JUMP_LEVEL);
            return;
            dbCreateItemOnObject(sItem, oTarget, 1);
        }


        void CreateSpecificSimple(object oTarget, object oAdventurer)
        {
           string sItem = "";
            int nHD = GetHitDice(oAdventurer);
  if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }


            CreateGenericSimple(oTarget, oAdventurer, JUMP_LEVEL);
            return;
            dbCreateItemOnObject(sItem, oTarget, 1);
        }
        void CreateSpecificMartial(object oTarget, object oAdventurer)
        {
            string sItem = "";
            int nHD = GetHitDice(oAdventurer);


  if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }

            CreateGenericMartial(oTarget, oAdventurer, JUMP_LEVEL);
            return;
            dbCreateItemOnObject(sItem, oTarget, 1);
        }
        void CreateSpecificExotic(object oTarget, object oAdventurer)
        {
            string sItem = "";
            int nHD = GetHitDice(oAdventurer);

  if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }
            CreateGenericExotic(oTarget, oAdventurer, JUMP_LEVEL);
            return;
            dbCreateItemOnObject(sItem, oTarget, 1);
        }
        void CreateSpecificLightArmor(object oTarget, object oAdventurer)
        {
            string sItem = "";
            int nHD = GetHitDice(oAdventurer);

  if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }


            CreateGenericLightArmor(oTarget, oAdventurer, JUMP_LEVEL);
            return;
            dbCreateItemOnObject(sItem, oTarget, 1);
        }
        void CreateSpecificMediumArmor(object oTarget, object oAdventurer)
        {
            string sItem = "";
            int nHD = GetHitDice(oAdventurer);


  if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }

            CreateGenericMediumArmor(oTarget, oAdventurer, JUMP_LEVEL);
            return;
            dbCreateItemOnObject(sItem, oTarget, 1);
        }
        void CreateSpecificHeavyArmor(object oTarget, object oAdventurer)
        {
            string sItem = "";
            int nHD = GetHitDice(oAdventurer);


  if (GetObjectType(OBJECT_SELF)==OBJECT_TYPE_PLACEABLE)
        {
           if (GetWillSavingThrow(OBJECT_SELF)<nHD)
           {
            nHD=GetWillSavingThrow(OBJECT_SELF);
            }
        }
            CreateGenericHeavyArmor(oTarget, oAdventurer, JUMP_LEVEL);
            return;
            dbCreateItemOnObject(sItem, oTarget, 1);

        }
        // * if nSpecific is = 1 then spawn in 'named' items at the higher levels
    void CreateTable2Item(object oTarget, object oAdventurer, int nSpecific=0)
    {

        // PALMER generic class now generates our custom toys


        string sItem = "";
        int nProbMisc = 0;
        int nProbClass = 40;
        int nProbRodStaffWand = 1;
        int nProbSimple = 7;
        int nProbMartial = 7;
        int nProbExotic = 7;
        int nProbLight = 14;
        int nProbMedium = 14;
        int nProbHeavy = 10;





        //* Create Items based on Probabilities
        int nRandom = d100();
        if (nRandom <= nProbMisc)
        {
            // this should never happen

        }
        else
        if (nRandom <= nProbMisc + nProbClass)
        {   // * no need for a seperate specific function here
            CreateGenericClassItem(oTarget, oAdventurer);
        }
        else
        if (nRandom <= nProbMisc + nProbClass + nProbRodStaffWand)
        {
            if (nSpecific == 0) CreateGenericRodStaffWand(oTarget, oAdventurer);
            else CreateSpecificRodStaffWand(oTarget, oAdventurer);
        }
        else
        if (nRandom <= nProbMisc + nProbClass + nProbRodStaffWand + nProbSimple)
        {
            if (nSpecific == 0) CreateGenericSimple(oTarget, oAdventurer);
            else CreateSpecificSimple(oTarget, oAdventurer);
        }
        else
        if (nRandom <= nProbMisc + nProbClass + nProbRodStaffWand + nProbSimple + nProbMartial)
        {

             if (nSpecific == 0) CreateGenericMartial(oTarget, oAdventurer);
             else CreateSpecificMartial(oTarget, oAdventurer);
        }
        else
        if (nRandom <= nProbMisc + nProbClass + nProbRodStaffWand + nProbSimple + nProbMartial + nProbExotic)
        {
            if (nSpecific == 0) CreateGenericExotic(oTarget, oAdventurer);
            else CreateSpecificExotic(oTarget, oAdventurer);
        }
        else
        if (nRandom <= nProbMisc + nProbClass + nProbRodStaffWand + nProbSimple + nProbMartial + nProbExotic + nProbLight)
        {
            if (nSpecific == 0) CreateGenericLightArmor(oTarget, oAdventurer);
            else CreateSpecificLightArmor(oTarget, oAdventurer);
        }
        else
        if (nRandom <= nProbMisc + nProbClass + nProbRodStaffWand + nProbSimple + nProbMartial + nProbExotic + nProbLight + nProbMedium)
        {
            if (nSpecific == 0) CreateGenericMediumArmor(oTarget, oAdventurer);
            else CreateSpecificMediumArmor(oTarget, oAdventurer);
        }
        else
        if (nRandom <= nProbMisc + nProbClass + nProbRodStaffWand + nProbSimple + nProbMartial + nProbExotic + nProbLight + nProbMedium + nProbHeavy)
        {
            if (nSpecific == 0) CreateGenericHeavyArmor(oTarget, oAdventurer);
            else CreateSpecificHeavyArmor(oTarget, oAdventurer);
        }

    }

//::///////////////////////////////////////////////
//:: GenerateTreasure
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
   Generate Treasure
   NOTE: When used by NPCs, the treasure is scaled
   to how powerful the NPC is.

   If used by containers, it is scaled by how
   powerful the PC is.

   PARAMETERS
   oLastOpener = The creature that opened the container
   oCreateOn = The place to put the treasure. If this is
    invalid then the treasure is placed on oLastOpener


*/
//:://////////////////////////////////////////////
//:: Created By:  Andrew
//:: Created On:
//:://////////////////////////////////////////////
void GenerateTreasure(int nTreasureType, object oLastOpener, object oCreateOn)
{



    // * abort treasure if no one opened the container
    if (GetIsObjectValid(oLastOpener) == FALSE)
    {
        return;
    }

    // * if no valid create on object, then create on oLastOpener
    if (oCreateOn == OBJECT_INVALID)
    {
        oCreateOn = oLastOpener;
    }

    // * if an Animal then generate 100% animal treasure

    // not done yet
    // * VARIABLES
   int nProbBook =   0;
   int nProbAnimal = 0;
   int nProbJunk =   0;
   int nProbGold = 0;
   int nProbGem = 0;
   int nProbJewel = 0;
   int nProbArcane = 0;
   int nProbDivine = 0;
   int nProbAmmo = 0;
   int nProbKit = 0;
   int nProbPotion = 0;
   int nProbTable2 = 0;

   int nSpecific = 0;
   int i = 0;
   int nNumberItems = GetNumberOfItems(nTreasureType);

   // * Set Treasure Type Values
   if (nTreasureType == TREASURE_LOW)
   {
    nProbBook   = LOW_PROB_BOOK;
    nProbAnimal = LOW_PROB_ANIMAL;
    nProbJunk   = LOW_PROB_JUNK;
    nProbGold   = LOW_PROB_GOLD;
    nProbGem    = LOW_PROB_GEM;
    nProbJewel  = LOW_PROB_JEWEL;
    nProbArcane = LOW_PROB_ARCANE;
    nProbDivine  = LOW_PROB_DIVINE;
    nProbAmmo = LOW_PROB_AMMO ;
    nProbKit = LOW_PROB_KIT;
    nProbPotion = LOW_PROB_POTION;
    nProbTable2 = LOW_PROB_TABLE2;
   }
   else if (nTreasureType == TREASURE_MEDIUM)
   {
    nProbBook   = MEDIUM_PROB_BOOK;
    nProbAnimal = MEDIUM_PROB_ANIMAL;
    nProbJunk   = MEDIUM_PROB_JUNK;
    nProbGold   = MEDIUM_PROB_GOLD;
    nProbGem    = MEDIUM_PROB_GEM;
    nProbJewel  = MEDIUM_PROB_JEWEL;
    nProbArcane = MEDIUM_PROB_ARCANE;
    nProbDivine  = MEDIUM_PROB_DIVINE;
    nProbAmmo = MEDIUM_PROB_AMMO ;
    nProbKit = MEDIUM_PROB_KIT;
    nProbPotion = MEDIUM_PROB_POTION;
    nProbTable2 = MEDIUM_PROB_TABLE2;
   }
   else if (nTreasureType == TREASURE_HIGH)
   {
    nProbBook   = HIGH_PROB_BOOK;
    nProbAnimal = HIGH_PROB_ANIMAL;
    nProbJunk   = HIGH_PROB_JUNK;
    nProbGold   = HIGH_PROB_GOLD;
    nProbGem    = HIGH_PROB_GEM;
    nProbJewel  = HIGH_PROB_JEWEL;
    nProbArcane = HIGH_PROB_ARCANE;
    nProbDivine  = HIGH_PROB_DIVINE;
    nProbAmmo = HIGH_PROB_AMMO ;
    nProbKit = HIGH_PROB_KIT;
    nProbPotion = HIGH_PROB_POTION;
    nProbTable2 = HIGH_PROB_TABLE2;
   }
   else if (nTreasureType == TREASURE_BOSS)
   {
    nProbTable2 = 100;
    nSpecific = 1;
   }
   else if (nTreasureType == TREASURE_BOOK)
   {
    nProbBook = 0;
    nProbArcane = 60;
    nProbDivine = 40;
   }



int nAmount=1;



   for (i = nAmount; i <= nNumberItems; i++)
   {
     int nRandom = d100();
     if (nRandom <= nProbBook)
        CreateBook(oCreateOn);                                // * Book
     else if (nRandom <= nProbBook + nProbAnimal)
        CreateBook(oCreateOn);                          // * THis should never occur
     else if (nRandom <= nProbBook + nProbAnimal + nProbJunk)
        CreateJunk(oCreateOn);                                // * Junk
     else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold)
        CreateGold(oCreateOn, oLastOpener, nTreasureType);    // * Gold
     else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold + nProbGem)
        CreateGem(oCreateOn, oLastOpener, nTreasureType);     // * Gem
     else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold + nProbGem + nProbJewel)
        CreateJewel(oCreateOn, oLastOpener, nTreasureType);   // * Jewel
     else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold + nProbGem + nProbJewel + nProbArcane)
        CreateArcaneScroll(oCreateOn, oLastOpener);   // * Arcane Scroll
     else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold + nProbGem + nProbJewel + nProbArcane + nProbDivine)
        CreateDivineScroll(oCreateOn, oLastOpener);   // * Divine Scroll
     else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold + nProbGem + nProbJewel + nProbArcane + nProbDivine + nProbAmmo)
        CreateAmmo(oCreateOn, oLastOpener);   // * Ammo
     else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold + nProbGem + nProbJewel + nProbArcane + nProbDivine + nProbAmmo + nProbKit)
        CreateKit(oCreateOn, oLastOpener);   // * Healing, Trap, or Thief kit
     else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold + nProbGem + nProbJewel + nProbArcane + nProbDivine + nProbAmmo + nProbKit + nProbPotion)
        CreatePotion(oCreateOn, oLastOpener);   // * Potion
     else if (nRandom <= nProbBook + nProbAnimal + nProbJunk + nProbGold + nProbGem + nProbJewel + nProbArcane + nProbDivine + nProbAmmo + nProbKit + nProbPotion + nProbTable2)
     {
        CreateTable2Item(oCreateOn, oLastOpener);   // * Weapons, Armor, Misc - Class based
     }





   }
}
void GenerateLowTreasure(object oLastOpener, object oCreateOn=OBJECT_INVALID)
{
 GenerateTreasure(TREASURE_LOW, oLastOpener, oCreateOn);
}
void GenerateMediumTreasure(object oLastOpener, object oCreateOn=OBJECT_INVALID)
{
 GenerateTreasure(TREASURE_MEDIUM, oLastOpener, oCreateOn);
}
void GenerateHighTreasure(object oLastOpener, object oCreateOn=OBJECT_INVALID)
{
 GenerateTreasure(TREASURE_HIGH, oLastOpener, oCreateOn);
}
void GenerateBossTreasure(object oLastOpener, object oCreateOn=OBJECT_INVALID)
{
 GenerateTreasure(TREASURE_BOSS, oLastOpener, oCreateOn);
}
void GenerateBookTreasure(object oLastOpener, object oCreateOn=OBJECT_INVALID)
{
 GenerateTreasure(TREASURE_BOOK, oLastOpener, oCreateOn);
}
//::///////////////////////////////////////////////
//:: GenerateNPCTreasure
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
   Preferrably called from OnSpawn scripts.
   Use the random treasure functions to generate
   appropriate treasure for the creature to drop.
*/
//:://////////////////////////////////////////////
//:: Created By: Brent
//:: Created On: January 2002
//:://////////////////////////////////////////////

void GenerateNPCTreasure(int nTreasureValue=1, object oTreasureGetter=OBJECT_SELF, object oKiller=OBJECT_SELF)
{

SendMessageToAllDMs("I am "+GetName(OBJECT_SELF)+" and I am using the wrong on spawn script");

}

// *
// * Theft Prevention
// *

//::///////////////////////////////////////////////
//:: ShoutDisturbed
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*

*/
//:://////////////////////////////////////////////
//:: Created By:
//:: Created On:
//:://////////////////////////////////////////////

// * Container shouts if disturbed
void ShoutDisturbed()
{
    if (GetIsDead(OBJECT_SELF) == TRUE)
    {
            object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_LARGE, GetLocation(OBJECT_SELF), TRUE, OBJECT_TYPE_CREATURE);
        //Cycle through the targets within the spell shape until an invalid object is captured.
        while (GetIsObjectValid(oTarget))
        {
           if (GetFactionEqual(oTarget, OBJECT_SELF) == TRUE)
           {
               // * Make anyone who is a member of my faction hostile if I am violated
           object oAttacker = GetLastAttacker();
           SetIsTemporaryEnemy(oAttacker,oTarget);
           AssignCommand(oTarget, ActionAttack(oAttacker));
           }
           oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_LARGE, GetLocation(OBJECT_SELF), TRUE, OBJECT_TYPE_CREATURE);
        }
    }
    else (GetIsOpen(OBJECT_SELF) == TRUE);
    {
            object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_LARGE, GetLocation(OBJECT_SELF), TRUE, OBJECT_TYPE_CREATURE);
        //Cycle through the targets within the spell shape until an invalid object is captured.
        while (GetIsObjectValid(oTarget))
        {
           if (GetFactionEqual(oTarget, OBJECT_SELF) == TRUE)
           {
               // * Make anyone who is a member of my faction hostile if I am violated
           object oAttacker = GetLastOpener();
           SetIsTemporaryEnemy(oAttacker,oTarget);
           AssignCommand(oTarget, ActionAttack(oAttacker));

           }
           oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_LARGE, GetLocation(OBJECT_SELF), TRUE, OBJECT_TYPE_CREATURE);
        }
    }
}


//::///////////////////////////////////////////////
//:: Determine Class to Use
//:: Copyright (c) 2002 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Determines which of a NPCs three classes to
    use in the random treasure system
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: April 4, 2002
//:://////////////////////////////////////////////

int nDetermineClassToUse(object oCharacter)
{
    int nClass;
    int nTotal = GetHitDice(oCharacter);

    if (nTotal < 1)
    {
        nTotal = 1;
    }
    float fTotal = IntToFloat(nTotal);

    int nClass1 =  GetClassByPosition(1, oCharacter);
    int nState1 = FloatToInt((IntToFloat(GetLevelByClass(nClass1, oCharacter)) / fTotal) * 100);


    PrintString("GENERIC SCRIPT DEBUG STRING ********** " +  GetTag(oCharacter) + "Class 1 " + IntToString(nState1));

    int nClass2 = GetClassByPosition(2, oCharacter);
    int nState2 = FloatToInt((IntToFloat(GetLevelByClass(nClass2, oCharacter)) / fTotal) * 100) + nState1;
    PrintString("GENERIC SCRIPT DEBUG STRING ********** " + GetTag(oCharacter) + "Class 2 " + IntToString(nState2));

    int nClass3 = GetClassByPosition(3, oCharacter);
    int nState3 = FloatToInt((IntToFloat(GetLevelByClass(nClass3, oCharacter)) / fTotal) * 100) + nState2;
    PrintString("GENERIC SCRIPT DEBUG STRING ********** " + GetTag(oCharacter) + "Class 3 " + IntToString(nState3));

    int nUseClass = d100();
    PrintString("GENERIC SCRIPT DEBUG STRING ********** " + "D100 Roll " +IntToString(nUseClass));



    if(nUseClass <= nState1)
    {
        nClass = nClass1;
    }
    else if(nUseClass > nState1 && nUseClass <= nState2)
    {
        nClass = nClass2;
    }
    else
    {
        nClass = nClass3;
    }

    return nClass;
}

//::void main (){}