738 lines
22 KiB
Plaintext
738 lines
22 KiB
Plaintext
//Script Name: inv_system_ou
|
||
//////////////////////////////////////////
|
||
//Created By: Genisys (Guile)
|
||
//Created On: 8/01/08
|
||
//Update On: 8/14/08 (Fixed error)
|
||
/////////////////////////////////////////
|
||
/*
|
||
This script is must be in the Onused event
|
||
of a specific placeable object in the
|
||
Inventory Room. NOTE: The user MUST
|
||
be in that room, or the system may error
|
||
due to lagg! (This is paramount!)
|
||
You should always playtest this system
|
||
THOROUGHLY before you utilize it on
|
||
your server, YOU HAVE BEEN WARNED!
|
||
*/
|
||
////////////////////////////////////////
|
||
//Seriously, this system rocks!
|
||
////////////////////////////////////////
|
||
//PROTOTYPES DECLARED
|
||
int GetNum(object oTarget);
|
||
void CheckBox(object oTarget);
|
||
void Seperate(object oTarget);
|
||
void Disperse(object oTarget);
|
||
void ReturnUndroppables(object oTarget);
|
||
void SortBoxes();
|
||
void ClearBag(object oTarget);
|
||
void SortContainer(object oTarget);
|
||
void SortBox(object oTarget);
|
||
void GiveAll(object oTarget);
|
||
void ClearAll();
|
||
//////////////////////////////////////////////////////////
|
||
|
||
//Main Script
|
||
void main()
|
||
{
|
||
|
||
//Declare All Major Variables
|
||
object oPC = GetLastUsedBy();
|
||
object oNPC = GetObjectByTag("ihold4u");
|
||
object oSelf = OBJECT_SELF;
|
||
object oItem;
|
||
|
||
//If anyone is using this system..
|
||
if(GetLocalInt(GetModule(), "ORGANIZING")==1)
|
||
{
|
||
FloatingTextStringOnCreature("This system is busy, try again later", oPC, FALSE);
|
||
//Stop the script here!
|
||
return;
|
||
}
|
||
//Since it's not in use..
|
||
else
|
||
{
|
||
|
||
//If this system is in use, tell them to try later.. (A Second Check)
|
||
if(GetLocalInt(oSelf, "INUSENOW")==1)
|
||
{
|
||
FloatingTextStringOnCreature("System in use, try again later.", oPC, FALSE);
|
||
//Stop here!
|
||
return;
|
||
}
|
||
//Otherwise allow them to use it and set that it's in use
|
||
else
|
||
{
|
||
SetLocalInt(oSelf, "INUSENOW", 1);
|
||
}
|
||
|
||
|
||
//Otherwise set that it is in use
|
||
SetLocalInt(GetModule(), "ORGANIZING", 1);
|
||
|
||
//This is an important fix for Module Events OnAcquire / OnUnAcquire
|
||
//A lot of items are beinging taken / given, so it would fire
|
||
//these Module Event Scripts repeatedly, which is REAL bad!
|
||
SetLocalInt(oPC, "ORGANIZING", 1);
|
||
|
||
//The holding box! (not an NPC)
|
||
object oNPC = GetObjectByTag("ihold4u");
|
||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
////////////////////////////MAIN FUNCTIONS///////////////////////////////////
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
float fTime = 0.2;
|
||
|
||
//Let's clear all actions on boxes FIRST!
|
||
ClearAll();
|
||
|
||
//Put all Non-Container Items in the proper boxes
|
||
//Then destroy the containers in the PC's inventory
|
||
oItem = GetFirstItemInInventory(oPC);
|
||
while(GetIsObjectValid(oItem))
|
||
{
|
||
|
||
if(!GetHasInventory(oItem))
|
||
{
|
||
//Put the item in the proper box if it's not a bag (container)
|
||
Disperse(oItem);
|
||
}
|
||
//Otherwise take the items out of the bag and put it on the NPC (box1)
|
||
else
|
||
{
|
||
ClearBag(oItem);
|
||
//This MUST have a big delay!
|
||
DelayCommand(12.0, DestroyObject(oItem, 0.0f));
|
||
}
|
||
|
||
oItem = GetNextItemInInventory(oPC);
|
||
//While Loop End
|
||
}
|
||
|
||
//Next, Sort the items in the box (NPC)
|
||
DelayCommand(10.2, Seperate(oNPC));
|
||
|
||
//Allow the Control to be used again afte some time..
|
||
DelayCommand(33.3, SetLocalInt(oSelf, "INUSENOW", 0));
|
||
|
||
//Allow the system to be useable again after some time..
|
||
DelayCommand(33.5, SetLocalInt(GetModule(), "ORGANIZING", 0));
|
||
|
||
//Take the variable off of the player so the events fire on them again.
|
||
DelayCommand(33.7, SetLocalInt(oPC, "ORGANIZING", 0));
|
||
|
||
//Let's Make sure that all boxes are cleared of all action ques.
|
||
DelayCommand(33.9, ClearAll());
|
||
|
||
DelayCommand(34.0, FloatingTextStringOnCreature(
|
||
"Organizing Complete.", oPC, TRUE));
|
||
|
||
//Else Statement End
|
||
}
|
||
|
||
//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))
|
||
{
|
||
//Add +1 for every item..
|
||
nNum = nNum +1;
|
||
|
||
oItem = GetNextItemInInventory(oTarget);
|
||
}
|
||
|
||
if(nNum>=1)
|
||
{
|
||
return TRUE;
|
||
}
|
||
else
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
//END PROTOTYPE
|
||
}
|
||
|
||
////////////////////////////////////////////////////////////////////////
|
||
//PROTOTYPE DEFINED
|
||
|
||
void CheckBox(object oTarget)
|
||
{
|
||
|
||
object oBox = oTarget;
|
||
|
||
//We only continue if the box has items!
|
||
if(GetNum(oBox)>=TRUE && GetNum(oBox)!=FALSE)
|
||
{
|
||
DelayCommand(0.1, SortBox(oTarget));
|
||
}
|
||
|
||
//PROTOTYPE END
|
||
}
|
||
|
||
////////////////////////////////////////////////////////////////////////
|
||
//PROTOTYPE DEFINED
|
||
void Seperate(object oTarget)
|
||
{
|
||
|
||
//We are going to take items in bags with this function.
|
||
|
||
//NOTE: oTarget = The bag which we identified in Clear Bags
|
||
|
||
//Declare major variables
|
||
object oBox; object oBox1; object oBox2; object oBox3; object oBox4;
|
||
object oBox5; object oBox6;object oBox7; object oItem;
|
||
|
||
//Now lets deal with the items in the bags
|
||
oItem = GetFirstItemInInventory(oTarget);
|
||
while(GetIsObjectValid(oItem))
|
||
{
|
||
|
||
//If in fact the item in Undroppable, then give it to the ibox..
|
||
if(GetItemCursedFlag(oItem))
|
||
{
|
||
oBox1 = GetObjectByTag("plotbox");
|
||
AssignCommand(oBox1, ActionTakeItem(oItem, oTarget));
|
||
}
|
||
|
||
//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)
|
||
{
|
||
oBox2 = GetObjectByTag("potbox");
|
||
AssignCommand(oBox2, ActionTakeItem(oItem, oTarget));
|
||
}
|
||
|
||
//Put all weapons in the weapon box..
|
||
else 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)
|
||
{
|
||
oBox3 = GetObjectByTag("wepbox");
|
||
AssignCommand(oBox3, ActionTakeItem(oItem, oTarget));
|
||
}
|
||
|
||
|
||
//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)
|
||
{
|
||
oBox4 = GetObjectByTag("armbox");
|
||
AssignCommand(oBox4, ActionTakeItem(oItem, oTarget));
|
||
}
|
||
|
||
//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)
|
||
{
|
||
oBox5 = GetObjectByTag("obox");
|
||
AssignCommand(oBox5, ActionTakeItem(oItem, oTarget));
|
||
}
|
||
|
||
//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)
|
||
{
|
||
oBox6 = GetObjectByTag("ammobox");
|
||
AssignCommand(oBox6, ActionTakeItem(oItem, oTarget));
|
||
}
|
||
|
||
//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)
|
||
{
|
||
oBox7 = GetObjectByTag("rswbox");
|
||
AssignCommand(oBox7, ActionTakeItem(oItem, oTarget));
|
||
}
|
||
|
||
//Otherwise put the item in the ibox!
|
||
else
|
||
{
|
||
oBox = GetObjectByTag("ibox");
|
||
AssignCommand(oBox, ActionTakeItem(oItem, oTarget));
|
||
}
|
||
|
||
//Continue the loop
|
||
oItem = GetNextItemInInventory(oTarget);
|
||
|
||
//While loop end
|
||
}
|
||
|
||
//Return all Undroppable items to the PC (the iBag organizes these)
|
||
DelayCommand(4.0, ReturnUndroppables(GetObjectByTag("plotbox")));
|
||
//Now sort all the boxes holding the sorted items..
|
||
DelayCommand(5.0, SortBoxes());
|
||
//PROTOTYPE END
|
||
}
|
||
|
||
////////////////////////////////////////////////////////////////////////
|
||
//PROTOTYPE DEFINED
|
||
void Disperse(object oTarget)
|
||
{
|
||
|
||
//This function will take the rest of the items on the PC..
|
||
|
||
//NOTE: oTarget = an Item
|
||
|
||
//Declare major variables
|
||
object oPC = GetLastUsedBy();
|
||
object oBox; object oBox1; object oBox2; object oBox3; object oBox4;
|
||
object oBox5; object oBox6;object oBox7;
|
||
|
||
object oItem = oTarget;
|
||
|
||
//We don't want to take bags (just in case!)
|
||
if(!GetHasInventory(oItem))
|
||
{
|
||
//If in fact the item in Undroppable, give it to the iBox
|
||
if(GetItemCursedFlag(oItem))
|
||
{
|
||
oBox1 = GetObjectByTag("plotbox");
|
||
AssignCommand(oBox1, 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))
|
||
{
|
||
oBox2 = GetObjectByTag("potbox");
|
||
AssignCommand(oBox2, ActionTakeItem(oItem, oPC));
|
||
}
|
||
|
||
//Put all weapons in the weapon box..
|
||
else 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))
|
||
{
|
||
oBox3 = GetObjectByTag("wepbox");
|
||
AssignCommand(oBox3, 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))
|
||
{
|
||
oBox4 = GetObjectByTag("armbox");
|
||
AssignCommand(oBox4, 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))
|
||
{
|
||
oBox5 = GetObjectByTag("obox");
|
||
AssignCommand(oBox5, 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))
|
||
{
|
||
oBox6 = GetObjectByTag("ammobox");
|
||
AssignCommand(oBox6, 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))
|
||
{
|
||
oBox7= GetObjectByTag("rswbox");
|
||
AssignCommand(oBox7, ActionTakeItem(oItem, oPC));
|
||
}
|
||
|
||
//Otherwise put the item in the ibox!
|
||
else
|
||
{
|
||
oBox = GetObjectByTag("ibox");
|
||
AssignCommand(oBox, ActionTakeItem(oItem, oPC));
|
||
}
|
||
|
||
//If statement end
|
||
}
|
||
|
||
//PROTOTYPE END
|
||
}
|
||
|
||
///////////////////////////////////////////////////////
|
||
void ReturnUndroppables(object oTarget)
|
||
{
|
||
|
||
//NOTE: oTarget = the plotBox;
|
||
|
||
object oPC = GetLastUsedBy();
|
||
|
||
object oItem;
|
||
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 SortBoxes()
|
||
{
|
||
object oBox = GetObjectByTag("ibox");
|
||
object oBox1 = GetObjectByTag("plotbox");
|
||
object oBox2 = GetObjectByTag("potbox");
|
||
object oBox3 = GetObjectByTag("wepbox");
|
||
object oBox4 = GetObjectByTag("armbox");
|
||
object oBox5 = GetObjectByTag("obox");
|
||
object oBox6 = GetObjectByTag("ammobox");
|
||
object oBox7= GetObjectByTag("rswbox");
|
||
object oBox8= GetObjectByTag("ihold4u");
|
||
|
||
//Sort the Boxes now holding the sorted items
|
||
DelayCommand(1.1, SortBox(oBox1));
|
||
//Return any left over items (safeguard!)
|
||
DelayCommand(6.1, GiveAll(oBox1));
|
||
//etc..
|
||
DelayCommand(2.2, SortBox(oBox2));
|
||
DelayCommand(7.2, GiveAll(oBox2));
|
||
DelayCommand(3.3, SortBox(oBox3));
|
||
DelayCommand(8.3, GiveAll(oBox3));
|
||
DelayCommand(4.4, SortBox(oBox4));
|
||
DelayCommand(9.4, GiveAll(oBox4));
|
||
DelayCommand(5.5, SortBox(oBox5));
|
||
DelayCommand(10.5, GiveAll(oBox5));
|
||
DelayCommand(6.6, SortBox(oBox6));
|
||
DelayCommand(11.6, GiveAll(oBox6));
|
||
DelayCommand(7.7, SortBox(oBox7));
|
||
DelayCommand(12.7, GiveAll(oBox7));
|
||
DelayCommand(8.8, SortBox(oBox));
|
||
DelayCommand(13.8, GiveAll(oBox));
|
||
DelayCommand(13.9, GiveAll(oBox8));
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////
|
||
//PROTOTYPE DEFINED
|
||
|
||
void ClearBag(object oTarget)
|
||
{
|
||
|
||
//NOTE: oTarget = oPC
|
||
//AssignCommand(oTarget, ClearAllActions());
|
||
|
||
object oNPC = GetObjectByTag("ihold4u");
|
||
object oItem;
|
||
|
||
//First, take all items from inside of bags first!
|
||
oItem = GetFirstItemInInventory(oTarget);
|
||
while(GetIsObjectValid(oItem))
|
||
{
|
||
AssignCommand(oNPC, ActionTakeItem(oItem, oTarget));
|
||
|
||
oItem = GetNextItemInInventory(oTarget);
|
||
}
|
||
|
||
//PROTOTYPE END
|
||
}
|
||
|
||
/////////////////////////////////////////////////
|
||
//PROTOTYPE DEFINED
|
||
void SortContainer(object oTarget)
|
||
{
|
||
|
||
//NOTE: oTarget = The Box assigned to be sorted
|
||
|
||
//Declare Major Variables
|
||
object oPC = GetLastUsedBy();
|
||
object oNPC = GetObjectByTag("ihold4u");
|
||
string sTag = GetTag(oTarget);
|
||
object oBox = GetObjectByTag(sTag);
|
||
object oBag = GetItemPossessedBy(oNPC, sTag);
|
||
object oMine;
|
||
string sName;
|
||
|
||
//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);
|
||
}
|
||
|
||
//Make the bags unsellable and undroppable!!
|
||
SetItemCursedFlag(oBag, TRUE);
|
||
SetPlotFlag(oBag, TRUE);
|
||
|
||
//Determine what to name the Bags based on the box's tagname
|
||
|
||
if(GetTag(oTarget) == "ibox")
|
||
{
|
||
sName = "<cr<63> >Other Items";
|
||
}
|
||
if(GetTag(oTarget) == "plotbox")
|
||
{
|
||
sName = "<c<><63> >Plot Items";
|
||
}
|
||
if(GetTag(oTarget) == "potbox")
|
||
{
|
||
sName = "<c <20><>>Potions & Scrolls";
|
||
}
|
||
if(GetTag(oTarget) == "wepbox")
|
||
{
|
||
sName = "<c<> >Weapons";
|
||
}
|
||
if(GetTag(oTarget) == "armbox")
|
||
{
|
||
sName = "<c=w<>>Armor & Clothing";
|
||
}
|
||
if(GetTag(oTarget) == "obox")
|
||
{
|
||
sName = "<c<><63>~>Miscellaneous Items";
|
||
}
|
||
if(GetTag(oTarget) == "ammobox")
|
||
{
|
||
sName = "<c<><63> >Ammunition";
|
||
}
|
||
if(GetTag(oTarget) == "rswbox")
|
||
{
|
||
sName = "<c<><63> >Rods/Staves/Wands";
|
||
}
|
||
|
||
//Give the bag a the proper name with color :)
|
||
DelayCommand(0.2,SetName(oBag, sName));
|
||
|
||
//Give the PC the bag now that it has items in it!
|
||
DelayCommand(0.5, AssignCommand(oNPC, ActionGiveItem(oBag, oPC)));
|
||
|
||
DelayCommand(0.6, CheckBox(oTarget));
|
||
|
||
//PROTOTYPE END
|
||
}
|
||
|
||
//////////////////////////////////////////////////
|
||
//PROTOTYPE DEFINED
|
||
void SortBox(object oTarget)
|
||
{
|
||
|
||
//NOTE: oTarget = The Box Assigned to be sorted.
|
||
|
||
//Declare Major Variables
|
||
object oPC = GetLastUsedBy();
|
||
object oNPC = GetObjectByTag("ihold4u");
|
||
object oBox = GetObjectByTag(GetTag(oTarget));
|
||
object oItem;
|
||
|
||
//We only continue if the box has items!
|
||
if((GetNum(oBox)==TRUE && GetNum(oBox)!=FALSE))
|
||
{
|
||
//Give the NPC a Bag to store items in!
|
||
//Give the bag the tagname of the box!
|
||
CreateItemOnObject("NW_IT_CONTAIN006", oNPC, 1, GetTag(oTarget));
|
||
|
||
//Start putting items in the bag on the NPC
|
||
DelayCommand(0.1, SortContainer(oTarget));
|
||
}
|
||
|
||
//PROTOTYPES End
|
||
}
|
||
|
||
///////////////////////////////////////////////////////
|
||
void GiveAll(object oTarget)
|
||
{
|
||
|
||
object oItem;
|
||
object oPC = GetLastUsedBy();
|
||
|
||
oItem = GetFirstItemInInventory(oTarget);
|
||
while(GetIsObjectValid(oItem))
|
||
{
|
||
//Give everything to the PC..
|
||
AssignCommand(oTarget, ActionGiveItem(oItem, oPC));
|
||
|
||
oItem = GetNextItemInInventory(oTarget);
|
||
}
|
||
|
||
//PROTOTYPE END
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//PROTOTYPE DEFINED
|
||
void ClearAll()
|
||
{
|
||
|
||
//Forgot to remove all action ques from the boxes!
|
||
//Otherwise the system would not work 2 times!
|
||
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");
|
||
|
||
AssignCommand(oBox, ClearAllActions());
|
||
AssignCommand(oBox1, ClearAllActions());
|
||
AssignCommand(oBox2, ClearAllActions());
|
||
AssignCommand(oBox3, ClearAllActions());
|
||
AssignCommand(oBox4, ClearAllActions());
|
||
AssignCommand(oBox5, ClearAllActions());
|
||
AssignCommand(oBox6, ClearAllActions());
|
||
AssignCommand(oBox7, ClearAllActions());
|
||
AssignCommand(oBox8, ClearAllActions());
|
||
|
||
//PROTOTYPE END
|
||
}
|
||
|
||
//////////WELCOME TO THE 700 CLUB WITH GENISYS YOUR HOST :p ///////////////
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//THE END, WOOOOOOOSHHH!!!////////////////////FINAL EDITION//////////////
|