/*-------------------------------------------------------- Script Name: gen_treasure ---------------------------------------------------------- Created By: Genisys(Guile) Created On: 4/19/09 ---------------------------------------------------------- This is my default Treasure Include Script To utilize simply place: #include "gen_treasure" at the top of your script, and then use the following function after the PC is defined, like it's shown below.. object oPC = GetLastUsedBy(); (for OnUsed Event of an object w/ inventory!) object oPC = GetLastOpenedBy(); (for OnOpen of a chest/bag w/ ineventory!) object oPC = GetLastKiller(); (for OnDeath of a creature) GenerateTreasure(oPC); <--- This Function goes after oPC! Please note that this script is level dependent! You will need to create 4 chest in your module and give them the following tagnames (in lower case letters!) gen_treas_low (put low items in this chest) gen_treas_med (put med level items in this chest) gen_treas_high (put high level items in this chest) gen_treas_rare (put your best items in this chest) Depending upon which level the PC is they will get items from the chest appropriate to their level... ----------------------------------------------------------*/ //Set this to the # of item you wish to spawn EVERY time! const int NUMBER_OF_ITEMS = 1; //use 1 - 10 only ! //Make sure all chest have at least 10 items in them! ////////////////////////////////////////////////////////////////////////// ////////////////DON'T TOUCH ANYTHING BELOW THIS LINE!//////////////////// //////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// //PROTOTYPE DEFINED int GetInvCount(object oBox) { int i = 0; object oGem = GetFirstItemInInventory(oBox); while(GetIsObjectValid(oGem)) { i+=1; oGem = GetNextItemInInventory(oBox); } return i; //PROTOTYPE END } void GetTreasureItem(object oBox, int nCount) { int i = 0; object oItem; oItem = GetFirstItemInInventory(oBox); while(GetIsObjectValid(oItem)) { //tell us which item we are looking at! i +=1; //If it's the item we are looking for, then copy it into the object! if(i==nCount) CopyItem(oItem, OBJECT_SELF, TRUE); oItem = GetNextItemInInventory(oBox); } } ///////////////////////////////////////////////////////////// //PROTOTYPE DEFINED void GenerateTreasure(object oPC) { //Prevent script errors! if(oPC == OBJECT_INVALID) {return;} //Prevent Cheating while looting! if(GetHasSpellEffect(SPELL_INVISIBILITY, oPC) || GetHasSpellEffect(SPELL_INVISIBILITY_SPHERE, oPC) || GetHasSpellEffect(SPELL_ETHEREALNESS, oPC) || GetHasSpellEffect(SPELL_SANCTUARY, oPC) || GetHasSpellEffect(SPELL_IMPROVED_INVISIBILITY, oPC)) { string sMsg = "You cannot loot treasure while invisible!"; effect eEffect; //Scare the daylights out of the cheater! eEffect = EffectVisualEffect(VFX_FNF_IMPLOSION, FALSE); ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC, 0.0f); //Warn them about cheating! FloatingTextStringOnCreature(sMsg, oPC, TRUE); SendMessageToAllDMs(GetName(oPC) + " ***Has been looting while invisible!***"); return; } //Declare All Major Variables.. //Prevent handing out Great treasure to low level players! int nLvl = GetHitDice(oPC); //Determine which box to look in... object oBox; object oItem; //Define which box to look in... if(nLvl <=10) { oBox = GetObjectByTag("gen_treas_low"); } else if(nLvl>=11 && nLvl <=20) { oBox = GetObjectByTag("gen_treas_med"); } else if(nLvl>=21 && nLvl <=30) { oBox = GetObjectByTag("gen_treas_high"); } else if(nLvl>=31) { oBox = GetObjectByTag("gen_treas_rare"); } else //Default! { oBox = GetObjectByTag("gen_treas_low"); } //The object we are putting the treasure in! object oMe = OBJECT_SELF; //Count up the # of items in that chest... int a = GetInvCount(oBox); int b = a + 1; //Add 1 to a (this is paramount!) int c = Random(b); //the item we are randomly choosing from the box //Generate X items into the object we are running the script on... int i; for(i=0; i