///////////////////////////////////////////////////////////////////////// // components_h - handle spell components, and other material components // By Deva Bryson Winblood. 04/28/2005 ///////////////////////////////////////////////////////////////////////// ////////////////////// // PROTOTYPES ////////////////////// // FILE: components_h FUNCTION: GetHasComponents() // This function will return TRUE if oPC possesses nQuantity // of items with the tag specified by sTag. int GetHasComponents(object oPC,string sTag,int nQuantity); // FILE: components_h FUNCTION: ConsumeComponents() // This function will consume nQuantity of sTag components // carried by oPC. void ConsumeComponents(object oPC,string sTag,int nQuantity); ////////////////////// // FUNCTIONS ////////////////////// int GetHasComponents(object oPC,string sTag,int nQuantity) { int bRet=FALSE; object oItem=GetItemPossessedBy(oPC,sTag); int nCount=0; if (oItem!=OBJECT_INVALID) { // count out items oItem=GetFirstItemInInventory(oPC); while(oItem!=OBJECT_INVALID&&bRet==FALSE) { // check inventory if (GetTag(oItem)==sTag) { // found one nCount++; if (nCount>=nQuantity) bRet=TRUE; } // found one oItem=GetNextItemInInventory(oPC); } // check inventory } // count out items return bRet; } // GetHasComponents() void ConsumeComponents(object oPC,string sTag,int nQuantity) { int nCount=0; object oItem=GetFirstItemInInventory(oPC); int nN; int nDif; while(oItem!=OBJECT_INVALID&&nCountnQuantity) { // more than enough nDif=nQuantity-nCount; nN=nN-nDif; SetItemStackSize(oItem,nN); nCount=nQuantity+1; } // more than enough else { // a portion nCount=nCount+nN; DelayCommand(1.0,DestroyObject(oItem)); } // a portion } // found oItem=GetNextItemInInventory(oPC); } // check inventory } // ConsumeComponents() //void main(){}