#include "adv_include" #include "dcy_include" #include "rwt_include" #include "qst_include" // Name of the table that stores information about items PCs have found in search sites const string SRCH_TABLE_MYSQL = "search_items"; // This represents the max number of "Item#" columns in the SRCH_TABLE_MYSQL table // If you need more item slots, add more columns in the table and then increase this constant const int SRCH_MAX_NUMBER_OF_ITEMS = 50; // Number of seconds before searching can take place again at a particular search site // Default: 7200 (2 Hours ) const int SRCH_TIMELOCK = 7200; // Name of the array of integers which stores the time lock period for players for all search sites const string SRCH_ARRAY_TIMELOCK = "SRCH_TIMELOCK"; // Name of the variable which stores a search site's unique ID number const string SRCH_CHEST_ID = "SEARCH_ID"; // Name of the variable which stores a search site's DC const string SRCH_CHEST_DC = "DC"; // Name of the variable which stores a search site's time lock period (in seconds) const string SRCH_CHEST_TIMELOCK = "SRCH_TIME_LOCK"; // Name of the variable which stores a search site's base number of searches const string SRCH_CHEST_NUMBER_SEARCHES = "NUMBER_SEARCHES"; // Name of the variable which stores a search site's loot table const string SRCH_CHEST_LOOT_TABLE = "LOOT_TABLE"; // Name of the variable which determines the tier of items to spawn in an area. // This variable is set on the area as opposed to the search site const string SRCH_AREA_TIER = "SRCH_TIER"; // Tag and ResRef of the copy placeable object const string SRCH_COPY_RESREF = "srch_plc_copy"; // An extra search is granted to PCs every time they reach this number. // Example: A player with 10 search skill can search 2 extra times (a total of 3 searched) // Example: A player with 8 search skill can search 1 extra time (a total of 2 searches) // Example: A player with 2 search skill can search 0 extra times (a total of 1 search) // DEFAULT: 5 (Every 5 skill levels a player receives one bonus search) const int SRCH_EXTRA_SEARCH_SKILL_LEVEL = 5; ////////////////// // ITEM RESREFS // ////////////////// // Constants for commonly used resrefs (gold, materials, etc) const string ITEM_GOLD = "nw_it_gold001"; // Gold const string ITEM_RADIO = "reo_radio"; // Radio const string ITEM_LOCKPICK = "lockpick"; // Lockpick const string ITEM_BLUE_HERB = "blue_herb"; // Blue Herb const string ITEM_GREEN_HERB = "green_herb"; // Green Herb const string ITEM_RED_HERB = "red_herb"; // Red Herb const string ITEM_FIRST_AID_SPRAY = "first_aid_spray"; // First Aid Spray const string ITEM_GUNPOWDER_A = "gunpowder_a"; // Gun Powder A const string ITEM_GUNPOWDER_B = "gunpowder_b"; // Gun Powder B const string ITEM_RELOADING_TOOL = "reloading_tool"; // Reloading Tool const string ITEM_INCENDIARY_MIX = "incendiary_mix"; // Incendiary Mix const string ITEM_REPAIR_KIT_ALPHA = "repair_kit_alpha"; // Repair Kit Alpha const string ITEM_REPAIR_KIT_BETA = "repair_kit_beta"; // Repair Kit Beta const string ITEM_REPAIR_KIT_GAMMA = "repair_kit_gamma"; // Repair Kit Gamma const string ITEM_RUBBER_MATERIAL = "rubber_material"; // Rubber Material const string ITEM_SCRAP_IRON = "scrap_iron"; // Scrap Iron const string ITEM_SCRAP_BRONZE = "scrap_bronze"; // Scrap Bronze const string ITEM_SCRAP_LEAD = "scrap_lead"; // Scrap Lead const string ITEM_SCRAP_BRASS = "scrap_brass"; // Scrap Brass const string ITEM_SCRAP_ZINC = "scrap_zinc"; // Scrap Zinc const string ITEM_GASOLINE = "gasoline"; // Gasoline const string ITEM_PLASTIC_FIBER = "plastic_fiber"; // Plastic Fiber const string ITEM_GLASS_SHARD = "glass_shard"; // Glass Shard const string ITEM_FABRIC_SCRAP = "fabric_scrap"; // Fabric Scrap const string ITEM_HANDGUN_AMMO = "ammo_box_1"; // Handgun Ammo const string ITEM_RIFLE_AMMO = "ammo_box_2"; // Rifle Ammo const string ITEM_SHOTGUN_SHELLS = "ammo_box_3"; // Shotgun Shells const string ITEM_SMG_AMMO = "ammo_box_4"; // SMG Ammo const string ITEM_MAGNUM_AMMO = "ammo_box_5"; // Magnum Ammo ///////////////////// // GET/SET METHODS // ///////////////////// // Returns the unique ID number for a search site int SRCH_GetChestSearchID(object oChest); // Returns the base DC value for PC searches int SRCH_GetChestSearchDC(object oChest); // Returns the amount of time between searches. This value is in the form of seconds // If no object is specified the default time listed in SRCH_TIMELOCK will be used. int SRCH_GetChestTimelock(object oChest = OBJECT_INVALID); // Returns the base number of times a PC searches for items int SRCH_GetChestNumberSearches(object oChest); int SRCH_GetChestSearchID(object oChest) { return GetLocalInt(oChest, SRCH_CHEST_ID); } int SRCH_GetChestSearchDC(object oChest) { return GetLocalInt(oChest, SRCH_CHEST_DC); } int SRCH_GetChestTimelock(object oChest = OBJECT_INVALID) { if(oChest != OBJECT_INVALID) { int iSeconds = GetLocalInt(oChest, SRCH_CHEST_TIMELOCK); if(iSeconds > 0) return GetLocalInt(oChest, SRCH_CHEST_TIMELOCK); } return SRCH_TIMELOCK; } int SRCH_GetChestNumberSearches(object oChest) { return GetLocalInt(oChest, SRCH_CHEST_NUMBER_SEARCHES); } int SRCH_GetChestLootTable(object oChest) { return GetLocalInt(oChest, SRCH_CHEST_LOOT_TABLE); } ////////////////////// // DATABASE HELPERS // ////////////////////// // This is a helper function which will update the SRCH_TABLE_MYSQL table with all items // inside of oChest, based on oPC's unique ID number void SRCH_UpdateDatabase(object oPC, object oChest); void SRCH_UpdateDatabase(object oPC, object oChest) { object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE); string sSearchID = IntToString(SRCH_GetChestSearchID(oChest)); string sPCID = IntToString(GetLocalInt(oDatabase, PC_ID_NUMBER)); string sName = SQLEncodeSpecialChars(GetName(oPC)); string sAccountName = SQLEncodeSpecialChars(GetPCPlayerName(oPC)); string sCDKey = SQLEncodeSpecialChars(GetPCPublicCDKey(oPC, TRUE)); string sSQL = "DELETE FROM " + SRCH_TABLE_MYSQL + " WHERE SearchID=" + sSearchID + " AND PCID=" + sPCID; SQLExecDirect(sSQL); // Row doesn't exist now, so insert a new row and then we'll fill it with item information sSQL = "INSERT INTO " + SRCH_TABLE_MYSQL + " (SearchID,PCID,Name,Account,CDKey) VALUES" + "('" + sSearchID + "','" + sPCID + "','" + sName + "','" + sAccountName + "','" + sCDKey + "')"; SQLExecDirect(sSQL); // At this point, we know the row exists. Let's cycle through the chest's inventory // and add any items inside to the database object oInventory = GetFirstItemInInventory(oChest); int bFoundItems = FALSE; int iItemCount; while(GetIsObjectValid(oInventory)) { // Quest items don't get stored in the database. All other items do. if(GetLocalInt(oInventory, "QST_QUEST_ITEM") == FALSE) { bFoundItems = TRUE; iItemCount++; sSQL = "UPDATE " + SRCH_TABLE_MYSQL + " SET Item" + IntToString(iItemCount) + "=%s WHERE SearchID=" + sSearchID + " AND PCID=" + sPCID; SetLocalString(GetModule(), "NWNX!ODBC!SETSCORCOSQL", sSQL); StoreCampaignObject ("NWNX", "-", oInventory); } oInventory = GetNextItemInInventory(oChest); } // We didn't find any items in the inventory so let's just remove the row. No sense having dead data if(bFoundItems == FALSE) { sSQL = "DELETE FROM " + SRCH_TABLE_MYSQL + " WHERE SearchID=" + sSearchID + " AND PCID=" + sPCID; SQLExecDirect(sSQL); } } ///////////// // METHODS // ///////////// // Call this on the OnOpen event of your COPY search sites. // Will check to see if the time lock period has passed. // If it has passed, all data in MySQL will be deleted and the search process will fire. // If it hasn't passed, all items stored in MySQL will be created on the search site void SRCH_OnChestOpened(); // Call this on the OnDisturbed event of your COPY search sites. // When an item is added by a player, the item is returned // When an item is removed by a player, the database gets updated to reflect the changes in inventory void SRCH_OnChestDisturbed(); // Call this on the OnClosed event of your COPY search sites. // Will delete all items from the chest and unlock it so another PC may use it. void SRCH_OnChestClosed(); // Call this on the OnUsed event of your ORIGINAL search sites. // Will spawn a COPY search site and force the player to open it. The copy is then set to not usable. // This fixes an issue in NWN where chests will sometimes get stuck open, not allowing other players to use them until the server resets. void SRCH_OnChestUsed(); // Internal function - do not call on its own. // Will use oPC's skill rank to determine which items are created on a particular search site. void SRCH_RunSearchCycle(object oPC, object oChest, int iDC); void SRCH_OnChestUsed() { object oPC = GetLastUsedBy(); if(!GetIsPC(oPC) || GetIsDM(oPC)) return; object oChest = OBJECT_SELF; location lLocation = GetLocation(oChest); vector vPosition = GetPosition(oPC); object oCopy = CreateObject(OBJECT_TYPE_PLACEABLE, SRCH_COPY_RESREF, lLocation); string sSiteName = GetName(oChest); // Copy the search site name over SetName(oCopy, sSiteName); // Make the copy face the PC SetFacingPoint(vPosition); // Copy the local variables from the original search site to the copy search site // Linux if(ADV_USING_LINUX) { CopyVariables(oChest, oCopy); } // Windows - TO-DO else { } // Force PC to use the copy, initiating the rest of the system AssignCommand(oPC, ActionInteractObject(oCopy)); } void SRCH_OnChestOpened() { object oPC = GetLastOpenedBy(); if(!GetIsPC(oPC) || GetIsDM(oPC)) return; object oChest = OBJECT_SELF; object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE); string sResref = GetResRef(oChest); int iChestID = SRCH_GetChestSearchID(oChest); int iSkill = GetSkillRank(SKILL_SEARCH, oPC); int iChestTimelock = SRCH_GetChestTimelock(oChest); int iSearches = SRCH_GetChestNumberSearches(oChest) + (iSkill / SRCH_EXTRA_SEARCH_SKILL_LEVEL); int iPCTimelock = GetLocalArrayInt(oDatabase, SRCH_ARRAY_TIMELOCK, iChestID); int iUnixTime = RWT_GetUnixTimestamp(); //SetLocked(oChest, TRUE); // Make the copy search sites lose their usable flag when opened. // This prevents other players from accessing it in the short time between spawning and opening the copy if(sResref == SRCH_COPY_RESREF) { SetUseableFlag(oChest, FALSE); } // Quest items are ALWAYS spawned if PC is on the correct quest. QST_DoSearchSpawnItems(oPC); // Timelock has passed. Update database item and delete all previous items from database // Then update the database with these new items. if(iUnixTime >= iPCTimelock) { iUnixTime = iUnixTime + iChestTimelock; SetLocalArrayInt(oDatabase, SRCH_ARRAY_TIMELOCK, iChestID, iUnixTime); int iLoop; int iDC = SRCH_GetChestSearchDC(oChest); for(iLoop = 1; iLoop <= iSearches; iLoop++) { SRCH_RunSearchCycle(oPC, oChest, iDC); iDC = iDC + SRCH_EXTRA_SEARCH_SKILL_LEVEL; } SRCH_UpdateDatabase(oPC, oChest); } // Timelock hasn't passed. Create all the items stored in the database for this particular PC and search site else { int iLoop; string sPCID = IntToString(GetLocalInt(oDatabase, PC_ID_NUMBER)); string sSearchID = IntToString(iChestID); for(iLoop = 1; iLoop <= SRCH_MAX_NUMBER_OF_ITEMS; iLoop++) { string sSQL = "SELECT Item" + IntToString(iLoop) + " FROM " + SRCH_TABLE_MYSQL + " WHERE SearchID=" + sSearchID + " AND PCID=" + sPCID +";"; SetLocalString(GetModule(), "NWNX!ODBC!SETSCORCOSQL", sSQL); object oItem = RetrieveCampaignObject ("NWNX", "-", GetLocation(oChest), oChest); // No need to keep checking the table - there are no more items being stored at the moment if(!GetIsObjectValid(oItem)){break;} // Prevent duplication of items in containers if(GetHasInventory(oItem)) { object oCycle = GetFirstItemInInventory(oItem); while(GetIsObjectValid(oCycle)) { DestroyObject(oCycle); oCycle = GetNextItemInInventory(oItem); } } } } } void SRCH_OnChestDisturbed() { object oPC = GetLastDisturbed(); if(!GetIsPC(oPC)) return; object oChest = OBJECT_SELF; object oItem = GetInventoryDisturbItem(); int iType = GetInventoryDisturbType(); if(iType == INVENTORY_DISTURB_TYPE_ADDED) { CopyItem(oItem, oPC, TRUE); DestroyObject(oItem); return; } else if(iType == INVENTORY_DISTURB_TYPE_REMOVED) { SRCH_UpdateDatabase(oPC, oChest); string sName = GetName(oItem); if(sName == "") sName = "money"; AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0, 1.5)); ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectCutsceneImmobilize(), oPC, 1.5); SendPlayerAOEMessage(oPC, 20.0, "FILTER_SEARCH_ITEMS_FOUND", GetName(oPC) + " found " + sName + ".", TRUE); } } void SRCH_OnChestClosed() { object oChest = OBJECT_SELF; object oInventory = GetFirstItemInInventory(oChest); string sResref = GetResRef(oChest); while(GetIsObjectValid(oInventory)) { DestroyObject(oInventory); oInventory = GetNextItemInInventory(oChest); } //SetLocked(oChest, FALSE); // Legacy check - make sure any search sites that weren't properly updated aren't destroyed if(sResref == SRCH_COPY_RESREF) { // Remove the copy DestroyObject(oChest); } } void SRCH_RunSearchCycle(object oPC, object oChest, int iDC) { object oArea = GetArea(oChest); int iLootTable = SRCH_GetChestLootTable(oChest); string sResref; int iAmount = 1; int iSkill = GetSkillRank(SKILL_SEARCH, oPC, FALSE); // Determines which main group to spawn items from. Defaults to 1 if below 1. int iTier = GetLocalInt(oArea, SRCH_AREA_TIER); if(iTier <= 0) iTier = 1; // Safety check to ensure skill bonus doesn't go out of range if(iSkill > 10) iSkill = 10; else if(iSkill < 0) iSkill = 0; int iRoll = d20(1); // PC must pass the DC check in order to find anything if(iRoll + iSkill >= iDC) { FloatingTextStringOnCreature(ColorTokenSkillCheck() + "Search: *success*: (" + IntToString(iRoll) + " + " + IntToString(iSkill) + " = " + IntToString(iRoll + iSkill) + " vs. DC: " + IntToString(iDC) + ")", oPC, FALSE); switch(iTier) { // TIER 1 GROUP case 1: //case 2: // Temporary { // TIER 1 SUB-GROUPS switch(iLootTable) { // Handgun Ammo, Gold case 1: { iRoll = d20(1); if(iRoll <= 18) { sResref = ITEM_HANDGUN_AMMO; iAmount = d10(1) + 5; } else { sResref = ITEM_GOLD; iAmount = d10(1) + 5; } break; } // Scrap Iron, Rubber Material case 2: { iRoll = d2(1); switch(iRoll) { case 1: sResref = ITEM_RUBBER_MATERIAL; break; case 2: sResref = ITEM_SCRAP_IRON; break; } break; } // Scrap Iron, Rubber Material, Gun Powder A, Handgun Ammo, Shotgun Shells case 3: { iRoll = d20(1); if(iRoll <= 5) { sResref = ITEM_RUBBER_MATERIAL; } else if(iRoll <= 10) { sResref = ITEM_SCRAP_IRON; } else if(iRoll <= 12) { sResref = ITEM_GUNPOWDER_A; } else if(iRoll <= 17) { sResref = ITEM_HANDGUN_AMMO; iAmount = Random(5) + 1; } else if(iRoll <= 20) { sResref = ITEM_SHOTGUN_SHELLS; iAmount = d4(1) + 3; } break; } // Gold, Gun Powder A, Repair Kit Alpha case 4: { iRoll = d3(1); switch(iRoll) { case 1: sResref = ITEM_GOLD; iAmount = d20(1) + 5; break; case 2: sResref = ITEM_GUNPOWDER_A; break; case 3: sResref = ITEM_REPAIR_KIT_ALPHA; break; } break; } // Gold case 5: { sResref = ITEM_GOLD; iAmount = d10(3); break; } // Gun Powder A, Gun Powder B, Green Herb, Repair Kit Alpha case 6: { iRoll = d10(1); if(iRoll <= 3) { sResref = ITEM_GUNPOWDER_A; } else if(iRoll <= 6) { sResref = ITEM_GUNPOWDER_B; } else if(iRoll <= 8) { sResref = ITEM_GREEN_HERB; } else if(iRoll <= 10) { sResref = ITEM_REPAIR_KIT_ALPHA; } break; } // Gold, Handgun Ammo case 7: { iRoll = d3(1); if(iRoll <= 2) { sResref = ITEM_HANDGUN_AMMO; iAmount = d10(1); } else if(iRoll <= 3) { sResref = ITEM_GOLD; iAmount = d10(1); } break; } // RARE ITEMS: Radio, Lockpick, Gun Powder A, Gun Powder B, Repair Kit Alpha, First Aid Spray case 8: { iRoll = Random(6) + 1; switch(iRoll) { case 1: sResref = ITEM_RADIO; break; case 2: sResref = ITEM_LOCKPICK; break; case 3: sResref = ITEM_GUNPOWDER_A; break; case 4: sResref = ITEM_GUNPOWDER_B; break; case 5: sResref = ITEM_REPAIR_KIT_ALPHA; break; case 6: sResref = ITEM_FIRST_AID_SPRAY; break; } break; } // Green Herb, Red Herb, Blue Herb, Rubber Material, Scrap Iron, Gun Powder B case 9: { iRoll = Random(6) + 1; switch(iRoll) { case 1: sResref = ITEM_GREEN_HERB; break; case 2: sResref = ITEM_RED_HERB; break; case 3: sResref = ITEM_BLUE_HERB; break; case 4: sResref = ITEM_RUBBER_MATERIAL; break; case 5: sResref = ITEM_SCRAP_IRON; break; case 6: sResref = ITEM_GUNPOWDER_B; break; } break; } // Rifle Ammo, Shotgun Shells, Gold case 10: { iRoll = d3(1); switch(iRoll) { case 1: sResref = ITEM_RIFLE_AMMO; iAmount = d4(1) + 3; break; case 2: sResref = ITEM_SHOTGUN_SHELLS; iAmount = d4(1) + 2; break; case 3: sResref = ITEM_GOLD; iAmount = d4(1) + 5; break; } break; } // Gold case 11: { sResref = ITEM_GOLD; iAmount = d4(1) + 5; break; } } break; } // TIER 2 GROUP case 2: { // TIER 2 SUB-GROUPS switch(iLootTable) { // Handgun Ammo, Gold, Green Herbs case 1: { iRoll = d20(1); if(iRoll <= 6) { sResref = ITEM_HANDGUN_AMMO; iAmount = d12(1) + 8; } else if(iRoll <= 14) { sResref = ITEM_GOLD; iAmount = d20(1) + 7; } else { sResref = ITEM_GREEN_HERB; break; } break; } // Scrap Iron, Rubber Material, Rifle Ammo case 2: { iRoll = d3(1); switch(iRoll) { case 1: sResref = ITEM_RUBBER_MATERIAL; break; case 2: sResref = ITEM_SCRAP_IRON; break; case 3: sResref = ITEM_RIFLE_AMMO; iAmount = d4(1) + 1; break; } break; } // Scrap Iron, Rubber Material, Gun Powder A, Gun Powder B, Handgun Ammo, Shotgun Shells case 3: { iRoll = d20(1); if(iRoll <= 5) { sResref = ITEM_RUBBER_MATERIAL; } else if(iRoll <= 6) { sResref = ITEM_SCRAP_IRON; } else if(iRoll <= 10) { sResref = ITEM_GUNPOWDER_A; } else if(iRoll <= 14) { sResref = ITEM_GUNPOWDER_A; } else if(iRoll <= 17) { sResref = ITEM_HANDGUN_AMMO; iAmount = Random(9) + 4; } else if(iRoll <= 20) { sResref = ITEM_SHOTGUN_SHELLS; iAmount = d6(1) + 5; } break; } // Gold,Gun Powder A, Gun Powder B, Repair Kit Alpha case 4: { iRoll = d4(1); switch(iRoll) { case 1: sResref = ITEM_GOLD; iAmount = d10(3) + 7; break; case 2: sResref = ITEM_GUNPOWDER_A; break; case 3: sResref = ITEM_GUNPOWDER_B; break; case 4: sResref = ITEM_REPAIR_KIT_ALPHA; break; } break; } // Gold case 5: { sResref = ITEM_GOLD; iAmount = d10(4) + 5; break; } // Gun Powder A, Gun Powder B, Blue Herb, Red Herb, Green Herb, Repair Kit Alpha case 6: { iRoll = d20(1); if(iRoll <= 3) { sResref = ITEM_GUNPOWDER_A; } else if(iRoll <= 6) { sResref = ITEM_GUNPOWDER_B; } else if(iRoll <= 9) { sResref = ITEM_GREEN_HERB; } else if(iRoll <= 12) { sResref = ITEM_BLUE_HERB; } else if(iRoll <= 16) { sResref = ITEM_RED_HERB; } else if(iRoll <= 20) { sResref = ITEM_REPAIR_KIT_ALPHA; } break; } // Gold, Handgun Ammo, Shotgun Ammo, SMG Ammo case 7: { iRoll = d3(1); if(iRoll <= 2) { sResref = ITEM_HANDGUN_AMMO; iAmount = d10(2) + 2; } if(iRoll <= 2) { sResref = ITEM_SHOTGUN_SHELLS; iAmount = d4(1) + 1; } if(iRoll <= 2) { sResref = ITEM_SMG_AMMO; iAmount = d10(2) + 5; } else if(iRoll <= 3) { sResref = ITEM_GOLD; iAmount = d10(3) + 5; } break; } // RARE ITEMS: Radio, Lockpick, Gun Powder A, Gun Powder B, Repair Kit Alpha, First Aid Spray, Repair Kit Beta case 8: { iRoll = Random(7) + 1; switch(iRoll) { case 1: sResref = ITEM_RADIO; break; case 2: sResref = ITEM_LOCKPICK; break; case 3: sResref = ITEM_GUNPOWDER_A; break; case 4: sResref = ITEM_GUNPOWDER_B; break; case 5: sResref = ITEM_REPAIR_KIT_ALPHA; break; case 6: sResref = ITEM_FIRST_AID_SPRAY; break; case 7: sResref = ITEM_REPAIR_KIT_BETA; break; } break; } // Green Herb, Red Herb, Blue Herb, Rubber Material, Scrap Iron, Gun Powder A, Gun Powder B case 9: { iRoll = Random(7) + 1; switch(iRoll) { case 1: sResref = ITEM_GREEN_HERB; break; case 2: sResref = ITEM_RED_HERB; break; case 3: sResref = ITEM_BLUE_HERB; break; case 4: sResref = ITEM_RUBBER_MATERIAL; break; case 5: sResref = ITEM_SCRAP_IRON; break; case 6: sResref = ITEM_GUNPOWDER_A; break; case 7: sResref = ITEM_GUNPOWDER_B; break; } break; } // Rifle Ammo, Shotgun Shells, Gold case 10: { iRoll = d3(1); switch(iRoll) { case 1: sResref = ITEM_RIFLE_AMMO; iAmount = d4(2) + 5; break; case 2: sResref = ITEM_SHOTGUN_SHELLS; iAmount = d4(2) + 5; break; case 3: sResref = ITEM_GOLD; iAmount = d4(2) + 10; break; } break; } // Gold case 11: { sResref = ITEM_GOLD; iAmount = d4(2) + 10; break; } } break; } } } // Failed the search check - inform player else { FloatingTextStringOnCreature(ColorTokenSkillCheck() + "Search: *failure*: (" + IntToString(iRoll) + " + " + IntToString(iSkill) + " = " + IntToString(iRoll + iSkill) + " vs. DC: " + IntToString(iDC) + ")", oPC, FALSE); return; } // As long as we found something to create, create it. if(sResref != "" && iAmount > 0) { object oFoundItem = CreateItemOnObject(sResref, oChest, iAmount); // Give the found item a random durability between 1% and 70%. Note that the list of // items this affects is found in the "SetDurability" function in the include file "dcy_include" DCY_SetItemDurability(oFoundItem, Random(70) + 1); } } // Error checking //void main(){}