abstract
| - This random treasure script works rather similarly to the Shadows of Undrentide (SoU) treasure system (see the script x0_i0_treasure). The basic idea is that the builder places treasure in player-inaccessible source chests, and the player-accessible chests randomly select items from the inaccessible ones. Specifically, one or two items will be selected from a generic chest that serves the entire module, and another item likely (2/3 of the time) will be selected from an area-specific chest.
- Items from RNDTRE01 may randomly grant one of the following: Items from RNDTRE02 may randomly grant one of the following: Items from RNDTRE03 may randomly grant one of the following: Items from RNDTRE04 may randomly grant one of the following: Items from RNDTRE05 may randomly grant one of the following: Items from RNDTRE06 may randomly grant one of the following:
- put this script on On Open and OnDestroyed. //sChest = string SourceChest tag //oChest = Object Destination Chest // grab random object from source Chest // and create a copy of it in Destination chest // the source chests are in the Dungeon Master's Palace // and have unique names void MakeTreasure(string sChest,object oChest){ int nCountItems; int nRandomItem; object oSource; object oItem; string sResRefItem; oSource = GetObjectByTag(sChest); if(!GetIsObjectValid(oSource))return; //count item logic oItem=GetFirstItemInInventory(oSource); nCountItems = 0; while(GetIsObjectValid(oItem)){ nCountItems++; oItem=GetNextItemInInventory(oSource); } //now get random item nRandomItem=Random(nCountItems)+1; oItem=GetFirstItemInInventory(oSource); while(nRandomItem>1){ nRandomItem--; oItem=GetNextItemInInventory(oSource); } sResRefItem = GetResRef(oItem); CreateItemOnObject(sResRefItem,oChest); } void main() { object oThisChest = OBJECT_SELF; location lThisChest = GetLocation(oThisChest); float fDelay = 10.0; // delay in seconds int nFlag= 0; string sSourceChest; // Source of Treasure nFlag = GetLocalInt(oThisChest, "Used"); sSourceChest = GetLocalString(GetArea(oThisChest),"SourceChest"); if(nFlag > 0) return; // timer in progress //2 pieces of junk, 1 good item //obviously chests with these tags apear in the //Dungeon Masters Palace and have the appropriate //items in them MakeTreasure("cgchestjunk",oThisChest); if(d2() > 1 ) MakeTreasure("cgchestjunk",oThisChest); if(d3() > 1 ) MakeTreasure(sSourceChest,oThisChest); //MakeTreasure("cgchest3",oThisChest); SetLocalInt(oThisChest,"Used",1); // this chest has been // used already, don't do it again }
|