///////////////////////////////////////////////////////// //Redundant Variable object oPC; //PROTOTYPES DECLARED int GetNum(object oTarget); void Seperate(object oTarget); void Disperse(object oTarget); void TakeAll(object oTarget); void ReturnUndroppables(object oTarget); void SortContainer(object oTarget); void SortBox(object oTarget); void GiveAll(object oTarget); //NO INCLUDES required (It's all required to be in this script!) ////////////////////////////////////////////////////////// //Main Script void main() { //Declare All Major Variables oPC = GetLastUsedBy(); object oItem; //The holding tank! object oNPC = GetObjectByTag("ihold4u"); object oBox; oBox = GetObjectByTag("ibox"); object oBox1; oBox1 = GetObjectByTag("plotbox"); object oBox2; oBox2 = GetObjectByTag("potbox"); object oBox3; oBox3 = GetObjectByTag("wepbox"); object oBox4; oBox4 = GetObjectByTag("armbox"); object oBox5; oBox5 = GetObjectByTag("obox"); object oBox6; oBox6 = GetObjectByTag("ammobox"); object oBox7; oBox7= GetObjectByTag("rswbox"); object oBox8; oBox8= GetObjectByTag("ihold4u"); //First, take all items from inside of bags first! oItem = GetFirstItemInInventory(oPC); while(GetIsObjectValid(oItem)) { if(GetHasInventory(oItem)) { //Have the proper container take the item. DelayCommand(1.0, Seperate(oItem)); } //continue the loop.. oItem = GetNextItemInInventory(oPC); } //After Bags have been emptied, take the rest of the items and //destroy all remaining bags.. DelayCommand(10.5, TakeAll(oPC)); //Now put the items into the proper sorting box.. DelayCommand(18.0, ReturnUndroppables(oBox)); //Sort the Boxes now holding the copied items DelayCommand(20.1, SortBox(oBox1)); DelayCommand(21.2, SortBox(oBox2)); DelayCommand(22.3, SortBox(oBox3)); DelayCommand(23.4, SortBox(oBox4)); DelayCommand(24.5, SortBox(oBox5)); DelayCommand(25.6, SortBox(oBox6)); DelayCommand(26.7, SortBox(oBox7)); DelayCommand(27.8, SortBox(oBox)); //Return ALL Items in ALL Boxes (Safe Guard!) DelayCommand(28.1, GiveAll(oBox1)); DelayCommand(28.2, GiveAll(oBox2)); DelayCommand(28.3, GiveAll(oBox3)); DelayCommand(28.4, GiveAll(oBox4)); DelayCommand(28.5, GiveAll(oBox5)); DelayCommand(28.6, GiveAll(oBox6)); DelayCommand(28.7, GiveAll(oBox7)); DelayCommand(28.8, GiveAll(oBox8)); DelayCommand(28.9, GiveAll(oBox)); DelayCommand(30.0, FloatingTextStringOnCreature( "Organizing Complete.", oPC, FALSE)); //Main Script End } ///////////////////////////////////////////////////// //DEFINE ALL PROTOTYPES////////////////////////////// ///////////////////////////////////////////////////// //////////////////////////////////////////////////////// //PROTOTYPE DEFINED // Return the number of items oTarget possesses in thier inventory int GetNum(object oTarget) { int nNum = 0; object oItem = GetFirstItemInInventory(oTarget); while (GetIsObjectValid(oItem) == TRUE) { nNum = nNum +1; oItem = GetNextItemInInventory(oTarget); } return nNum; //END PROTOTYPE } //////////////////////////////////////////////////////////////////////// //PROTOTYPE DEFINED void Seperate(object oTarget) { object oPC = oTarget; object oBox; oBox = GetObjectByTag("ibox"); object oBox1; oBox1 = GetObjectByTag("plotbox"); object oBox2; oBox2 = GetObjectByTag("potbox"); object oBox3; oBox3 = GetObjectByTag("wepbox"); object oBox4; oBox4 = GetObjectByTag("armbox"); object oBox5; oBox5 = GetObjectByTag("obox"); object oBox6; oBox6 = GetObjectByTag("ammobox"); object oBox7; oBox7= GetObjectByTag("rswbox"); object oItem; //Now lets deal with the items in the box now.. oItem = GetFirstItemInInventory(oTarget); while(GetIsObjectValid(oItem)) { //If in fact the item in Undroppable, then give it back to the PC if(GetItemCursedFlag(oItem)) { DelayCommand(0.2, AssignCommand(oBox, ActionTakeItem(oItem, oPC))); } //Otherwise assign the item to the proper box! else { //Put all weapons in the weapon box.. if(GetBaseItemType(oItem)== BASE_ITEM_BASTARDSWORD || GetBaseItemType(oItem)== BASE_ITEM_BATTLEAXE || GetBaseItemType(oItem)== BASE_ITEM_CLUB || GetBaseItemType(oItem)== BASE_ITEM_DAGGER || GetBaseItemType(oItem)== BASE_ITEM_DIREMACE || GetBaseItemType(oItem)== BASE_ITEM_DOUBLEAXE || GetBaseItemType(oItem)== BASE_ITEM_DWARVENWARAXE || GetBaseItemType(oItem)== BASE_ITEM_GREATAXE || GetBaseItemType(oItem)== BASE_ITEM_GREATSWORD || GetBaseItemType(oItem)== BASE_ITEM_HALBERD || GetBaseItemType(oItem)== BASE_ITEM_HANDAXE || GetBaseItemType(oItem)== BASE_ITEM_HEAVYFLAIL || GetBaseItemType(oItem)== BASE_ITEM_KAMA || GetBaseItemType(oItem)== BASE_ITEM_KATANA || GetBaseItemType(oItem)== BASE_ITEM_KUKRI || GetBaseItemType(oItem)== BASE_ITEM_LIGHTFLAIL || GetBaseItemType(oItem)== BASE_ITEM_LIGHTHAMMER || GetBaseItemType(oItem)== BASE_ITEM_LIGHTMACE || GetBaseItemType(oItem)== BASE_ITEM_LONGSWORD || GetBaseItemType(oItem)== BASE_ITEM_MORNINGSTAR || GetBaseItemType(oItem)== BASE_ITEM_QUARTERSTAFF || GetBaseItemType(oItem)== BASE_ITEM_RAPIER || GetBaseItemType(oItem)== BASE_ITEM_SCIMITAR || GetBaseItemType(oItem)== BASE_ITEM_SCYTHE || GetBaseItemType(oItem)== BASE_ITEM_SHORTSPEAR || GetBaseItemType(oItem)== BASE_ITEM_SHORTSWORD || GetBaseItemType(oItem)== BASE_ITEM_SICKLE || GetBaseItemType(oItem)== BASE_ITEM_TRIDENT || GetBaseItemType(oItem)== BASE_ITEM_TWOBLADEDSWORD || GetBaseItemType(oItem)== BASE_ITEM_WARHAMMER || GetBaseItemType(oItem)== BASE_ITEM_WHIP || GetBaseItemType(oItem)== BASE_ITEM_HEAVYCROSSBOW || GetBaseItemType(oItem)== BASE_ITEM_LIGHTCROSSBOW || GetBaseItemType(oItem)== BASE_ITEM_LONGBOW || GetBaseItemType(oItem)== BASE_ITEM_SHORTBOW || GetBaseItemType(oItem)== BASE_ITEM_SLING) { DelayCommand(0.2, AssignCommand(oBox3, ActionTakeItem(oItem, oPC))); } //Put all ammunitions in the ammobox else if(GetBaseItemType(oItem)== BASE_ITEM_ARROW || GetBaseItemType(oItem)== BASE_ITEM_BOLT || GetBaseItemType(oItem)== BASE_ITEM_BULLET || GetBaseItemType(oItem)== BASE_ITEM_DART || GetBaseItemType(oItem)== BASE_ITEM_SHURIKEN || GetBaseItemType(oItem)== BASE_ITEM_THROWINGAXE) { DelayCommand(0.2, AssignCommand(oBox6, ActionTakeItem(oItem, oPC))); } //Serpate ALL Potions, Scrolls, & Healer's Kits into the potbox else if(GetBaseItemType(oItem)==BASE_ITEM_POTIONS || GetBaseItemType(oItem)==BASE_ITEM_ENCHANTED_POTION || GetBaseItemType(oItem)==BASE_ITEM_ENCHANTED_SCROLL || GetBaseItemType(oItem)==BASE_ITEM_HEALERSKIT || GetBaseItemType(oItem)==BASE_ITEM_SPELLSCROLL) { DelayCommand(0.2, AssignCommand(oBox2, ActionTakeItem(oItem, oPC))); } //Seperate the Armor & Worn Items into the armbox else if(GetBaseItemType(oItem)==BASE_ITEM_AMULET || GetBaseItemType(oItem)==BASE_ITEM_ARMOR || GetBaseItemType(oItem)==BASE_ITEM_BELT || GetBaseItemType(oItem)==BASE_ITEM_BOOTS || GetBaseItemType(oItem)==BASE_ITEM_BRACER || GetBaseItemType(oItem)==BASE_ITEM_CLOAK || GetBaseItemType(oItem)==BASE_ITEM_GLOVES || GetBaseItemType(oItem)==BASE_ITEM_HELMET || GetBaseItemType(oItem)==BASE_ITEM_LARGESHIELD || GetBaseItemType(oItem)==BASE_ITEM_RING || GetBaseItemType(oItem)==BASE_ITEM_SMALLSHIELD || GetBaseItemType(oItem)==BASE_ITEM_TOWERSHIELD) { DelayCommand(0.2, AssignCommand(oBox4, ActionTakeItem(oItem, oPC))); } //Now let's seperate plot items next before we do the other seperations else if(GetPlotFlag(oItem)==TRUE) { DelayCommand(0.2, AssignCommand(oBox1, ActionTakeItem(oItem, oPC))); } //Seperate all Rods / Staves / Wands into the srwbox else if(GetBaseItemType(oItem)==BASE_ITEM_MAGICROD || GetBaseItemType(oItem)==BASE_ITEM_MAGICSTAFF || GetBaseItemType(oItem)==BASE_ITEM_MAGICWAND) { DelayCommand(0.2, AssignCommand(oBox7, ActionTakeItem(oItem, oPC))); } //now let's seperate all the miscellaneous items //Grenades, Trapkits, and Thieving Tools into the oBox else if(GetBaseItemType(oItem)==BASE_ITEM_MISCSMALL || GetBaseItemType(oItem)==BASE_ITEM_MISCMEDIUM || GetBaseItemType(oItem)==BASE_ITEM_MISCLARGE || GetBaseItemType(oItem)==BASE_ITEM_MISCTHIN || GetBaseItemType(oItem)==BASE_ITEM_MISCWIDE || GetBaseItemType(oItem)==BASE_ITEM_MISCTALL || GetBaseItemType(oItem)==BASE_ITEM_GRENADE || GetBaseItemType(oItem)==BASE_ITEM_THIEVESTOOLS || GetBaseItemType(oItem)==BASE_ITEM_TRAPKIT) { DelayCommand(0.2, AssignCommand(oBox5, ActionTakeItem(oItem, oPC))); } //Otherwise put the item in the ibox! else { DelayCommand(0.2, AssignCommand(oBox, ActionTakeItem(oItem, oPC))); } //Else statement end.. } //Continue the loop oItem = GetNextItemInInventory(oTarget); } //PROTOTYPE END } //////////////////////////////////////////////////////////////////////// //PROTOTYPE DEFINED void Disperse(object oTarget) { oPC = GetLastUsedBy(); object oBox; oBox = GetObjectByTag("ibox"); object oBox1; oBox1 = GetObjectByTag("plotbox"); object oBox2; oBox2 = GetObjectByTag("potbox"); object oBox3; oBox3 = GetObjectByTag("wepbox"); object oBox4; oBox4 = GetObjectByTag("armbox"); object oBox5; oBox5 = GetObjectByTag("obox"); object oBox6; oBox6 = GetObjectByTag("ammobox"); object oBox7; oBox7= GetObjectByTag("rswbox"); object oItem = oTarget; //If in fact the item in Undroppable, then give it back to the PC if(GetItemCursedFlag(oItem)==TRUE) { DelayCommand(0.2, AssignCommand(oBox, ActionTakeItem(oItem, oPC))); } //Otherwise assign the item to the proper box! else { //Put all weapons in the weapon box.. if(GetBaseItemType(oItem)== BASE_ITEM_BASTARDSWORD || GetBaseItemType(oItem)== BASE_ITEM_BATTLEAXE || GetBaseItemType(oItem)== BASE_ITEM_CLUB || GetBaseItemType(oItem)== BASE_ITEM_DAGGER || GetBaseItemType(oItem)== BASE_ITEM_DIREMACE || GetBaseItemType(oItem)== BASE_ITEM_DOUBLEAXE || GetBaseItemType(oItem)== BASE_ITEM_DWARVENWARAXE || GetBaseItemType(oItem)== BASE_ITEM_GREATAXE || GetBaseItemType(oItem)== BASE_ITEM_GREATSWORD || GetBaseItemType(oItem)== BASE_ITEM_HALBERD || GetBaseItemType(oItem)== BASE_ITEM_HANDAXE || GetBaseItemType(oItem)== BASE_ITEM_HEAVYFLAIL || GetBaseItemType(oItem)== BASE_ITEM_KAMA || GetBaseItemType(oItem)== BASE_ITEM_KATANA || GetBaseItemType(oItem)== BASE_ITEM_KUKRI || GetBaseItemType(oItem)== BASE_ITEM_LIGHTFLAIL || GetBaseItemType(oItem)== BASE_ITEM_LIGHTHAMMER || GetBaseItemType(oItem)== BASE_ITEM_LIGHTMACE || GetBaseItemType(oItem)== BASE_ITEM_LONGSWORD || GetBaseItemType(oItem)== BASE_ITEM_MORNINGSTAR || GetBaseItemType(oItem)== BASE_ITEM_QUARTERSTAFF || GetBaseItemType(oItem)== BASE_ITEM_RAPIER || GetBaseItemType(oItem)== BASE_ITEM_SCIMITAR || GetBaseItemType(oItem)== BASE_ITEM_SCYTHE || GetBaseItemType(oItem)== BASE_ITEM_SHORTSPEAR || GetBaseItemType(oItem)== BASE_ITEM_SHORTSWORD || GetBaseItemType(oItem)== BASE_ITEM_SICKLE || GetBaseItemType(oItem)== BASE_ITEM_TRIDENT || GetBaseItemType(oItem)== BASE_ITEM_TWOBLADEDSWORD || GetBaseItemType(oItem)== BASE_ITEM_WARHAMMER || GetBaseItemType(oItem)== BASE_ITEM_WHIP || GetBaseItemType(oItem)== BASE_ITEM_HEAVYCROSSBOW || GetBaseItemType(oItem)== BASE_ITEM_LIGHTCROSSBOW || GetBaseItemType(oItem)== BASE_ITEM_LONGBOW || GetBaseItemType(oItem)== BASE_ITEM_SHORTBOW || GetBaseItemType(oItem)== BASE_ITEM_SLING) { DelayCommand(0.2, AssignCommand(oBox3, ActionTakeItem(oItem, oPC))); } //Put all ammunitions in the ammobox else if(GetBaseItemType(oItem)== BASE_ITEM_ARROW || GetBaseItemType(oItem)== BASE_ITEM_BOLT || GetBaseItemType(oItem)== BASE_ITEM_BULLET || GetBaseItemType(oItem)== BASE_ITEM_DART || GetBaseItemType(oItem)== BASE_ITEM_SHURIKEN || GetBaseItemType(oItem)== BASE_ITEM_THROWINGAXE) { DelayCommand(0.2, AssignCommand(oBox6, ActionTakeItem(oItem, oPC))); } //Serpate ALL Potions, Scrolls, & Healer's Kits into the potbox else if(GetBaseItemType(oItem)==BASE_ITEM_POTIONS || GetBaseItemType(oItem)==BASE_ITEM_ENCHANTED_POTION || GetBaseItemType(oItem)==BASE_ITEM_ENCHANTED_SCROLL || GetBaseItemType(oItem)==BASE_ITEM_HEALERSKIT || GetBaseItemType(oItem)==BASE_ITEM_SPELLSCROLL) { DelayCommand(0.2, AssignCommand(oBox2, ActionTakeItem(oItem, oPC))); } //Seperate the Armor & Worn Items into the armbox else if(GetBaseItemType(oItem)==BASE_ITEM_AMULET || GetBaseItemType(oItem)==BASE_ITEM_ARMOR || GetBaseItemType(oItem)==BASE_ITEM_BELT || GetBaseItemType(oItem)==BASE_ITEM_BOOTS || GetBaseItemType(oItem)==BASE_ITEM_BRACER || GetBaseItemType(oItem)==BASE_ITEM_CLOAK || GetBaseItemType(oItem)==BASE_ITEM_GLOVES || GetBaseItemType(oItem)==BASE_ITEM_HELMET || GetBaseItemType(oItem)==BASE_ITEM_LARGESHIELD || GetBaseItemType(oItem)==BASE_ITEM_RING || GetBaseItemType(oItem)==BASE_ITEM_SMALLSHIELD || GetBaseItemType(oItem)==BASE_ITEM_TOWERSHIELD) { DelayCommand(0.2, AssignCommand(oBox4, ActionTakeItem(oItem, oPC))); } //Now let's seperate plot items next before we do the other seperations else if(GetPlotFlag(oItem)==TRUE) { DelayCommand(0.2, AssignCommand(oBox1, ActionTakeItem(oItem, oPC))); } //Seperate all Rods / Staves / Wands into the srwbox else if(GetBaseItemType(oItem)==BASE_ITEM_MAGICROD || GetBaseItemType(oItem)==BASE_ITEM_MAGICSTAFF || GetBaseItemType(oItem)==BASE_ITEM_MAGICWAND) { DelayCommand(0.2, AssignCommand(oBox7, ActionTakeItem(oItem, oPC))); } //now let's seperate all the miscellaneous items //Grenades, Trapkits, and Thieving Tools into the oBox else if(GetBaseItemType(oItem)==BASE_ITEM_MISCSMALL || GetBaseItemType(oItem)==BASE_ITEM_MISCMEDIUM || GetBaseItemType(oItem)==BASE_ITEM_MISCLARGE || GetBaseItemType(oItem)==BASE_ITEM_MISCTHIN || GetBaseItemType(oItem)==BASE_ITEM_MISCWIDE || GetBaseItemType(oItem)==BASE_ITEM_MISCTALL || GetBaseItemType(oItem)==BASE_ITEM_GRENADE || GetBaseItemType(oItem)==BASE_ITEM_THIEVESTOOLS || GetBaseItemType(oItem)==BASE_ITEM_TRAPKIT) { DelayCommand(0.2, AssignCommand(oBox5, ActionTakeItem(oItem, oPC))); } //Otherwise put the item in the ibox! else { DelayCommand(0.2, AssignCommand(oBox, ActionTakeItem(oItem, oPC))); } //Else statement end } //PROTOTYPE END } ////////////////////////////////////////////////////////////// void TakeAll(object oTarget) { object oBox = GetObjectByTag("ihold4u"); object oItem; //Copy all Non-Bags in the PC's inventory into the box //Then destroy the originals and then the bags. oItem = GetFirstItemInInventory(oTarget); while(GetIsObjectValid(oItem)) { //If it's not a container.. if(!GetHasInventory(oItem)) { //Have the proper container take it! Disperse(oItem); } //if It's a Container, then remove it's contents! if(GetHasInventory(oItem)) { DelayCommand(7.0, DestroyObject(oItem, 0.0f)); } //continue the loop.. oItem = GetNextItemInInventory(oTarget); } //END PROTOTYPE } /////////////////////////////////////////////////////// void ReturnUndroppables(object oTarget) { object oItem; oPC = GetLastUsedBy(); oItem = GetFirstItemInInventory(oTarget); while(GetIsObjectValid(oItem)) { //return all containers to the PC! if(GetItemCursedFlag(oItem)) { //Give everything to the PC.. AssignCommand(oTarget, ActionGiveItem(oItem, oPC)); } oItem = GetNextItemInInventory(oTarget); } //PROTOTYPE END } ///////////////////////////////////////////////// //PROTOTYPE DEFINED void SortContainer(object oTarget) { //Declare Major Variables object oPC = GetLastUsedBy(); object oNPC = GetObjectByTag("ihold4u"); object oBox = GetObjectByTag(GetTag(oTarget)); object oMine; object oBag = GetItemPossessedBy(oNPC, GetTag(oTarget)); //Determine what script fired this function! if(GetLocalInt(oNPC, "iFired")==1) { oPC = GetItemActivator(); } else { oPC = GetLastUsedBy(); } //First Put all the items that will fit into the bag //on the NPC into the bag.. oMine = GetFirstItemInInventory(oTarget); while(GetIsObjectValid(oMine)==TRUE) { AssignCommand(oTarget, ActionGiveItem(oMine, oBag)); oMine = GetNextItemInInventory(oTarget); } if(GetLocalInt(GetModule(), "BAGCONTROL")==1) { //Make the bags unsellable and undroppable!! SetItemCursedFlag(oBag, TRUE); SetPlotFlag(oBag, TRUE); } string sName; if(GetTag(oTarget) == "ibox") { sName = "Other Items"; } if(GetTag(oTarget) == "plotbox") { sName = "Plot Items"; } if(GetTag(oTarget) == "potbox") { sName = "Potions & Scrolls"; } if(GetTag(oTarget) == "wepbox") { sName = "Weapons"; } if(GetTag(oTarget) == "armbox") { sName = "Armor & Clothing"; } if(GetTag(oTarget) == "obox") { sName = "Miscellaneous Items"; } if(GetTag(oTarget) == "ammobox") { sName = "Ammunition"; } if(GetTag(oTarget) == "rswbox") { sName = "Rods/Staves/Wands"; } //Give the bag a the proper name with color :) DelayCommand(0.1,SetName(oBag, sName)); //Give the PC the bag now that it has items in it! DelayCommand(0.4, AssignCommand(oNPC, ActionGiveItem(oBag, oPC))); //PROTOTYPE END } ////////////////////////////////////////////////// //PROTOTYPE DEFINED void SortBox(object oTarget) { //Declare Major Variables object oPC = GetLastUsedBy(); object oBox = GetObjectByTag(GetTag(oTarget)); object oItem; object oNPC = GetObjectByTag("ihold4u"); //We only continue if the box has items! if(GetNum(oBox)>0) { //Give the NPC a Bag to store items in! //Give the bag the tagname of the box! CreateItemOnObject("NW_IT_CONTAIN006", oNPC, 1, GetTag(oBox)); //Start putting items in the bag on the NPC DelayCommand(0.1, SortContainer(oTarget)); //Continue to sort the box till nothing is left! DelayCommand(0.5, SortBox(oTarget)); } //NOTE: If the box has 0 items, no need to continue! //PROTOTYPES End } /////////////////////////////////////////////////////// void GiveAll(object oTarget) { object oItem; oPC = GetLastUsedBy(); oItem = GetFirstItemInInventory(oTarget); while(GetIsObjectValid(oItem)) { //Give everything to the PC.. AssignCommand(oTarget, ActionGiveItem(oItem, oPC)); oItem = GetNextItemInInventory(oTarget); } //PROTOTYPE END }