201 lines
7.6 KiB
Plaintext
201 lines
7.6 KiB
Plaintext
#include "nw_i0_plot"
|
|
|
|
void main()
|
|
{
|
|
// Step 1 ) get Lecturn Infromation
|
|
object oLecturn = GetNearestObjectByTag("ASG_LECTURN",OBJECT_SELF);
|
|
if (GetIsObjectValid(oLecturn))
|
|
{
|
|
// Look for alchemy book
|
|
object oItem = GetFirstItemInInventory(oLecturn);
|
|
object oPC = GetPCSpeaker();
|
|
int iPass = FALSE;
|
|
|
|
if (GetIsObjectValid(oItem))
|
|
{
|
|
string sTag = GetTag(oItem);
|
|
string sTagLeft6 = GetStringLeft(sTag,6);
|
|
int iLen = GetStringLength(sTag)-9;
|
|
string sMatTag = GetStringRight(sTag,iLen);
|
|
string sBase = "ASG_MAT_";
|
|
string sMatChest = sBase+sMatTag;
|
|
object oMatChest;
|
|
object oCCHest;
|
|
object oItem;
|
|
if (sTagLeft6=="ASG_MT")
|
|
{
|
|
iPass = TRUE;
|
|
}
|
|
else
|
|
{
|
|
SetCustomToken(1970000,"No Valid Alchemy Book found in Lecturn.");
|
|
return;
|
|
}
|
|
// Step 3) Found Legal Alchemy Book, Check Material Chest
|
|
if (iPass==TRUE)
|
|
{
|
|
oMatChest = GetObjectByTag(sMatChest);
|
|
if (GetIsObjectValid(oMatChest)) iPass = TRUE;
|
|
else
|
|
{
|
|
SetCustomToken(1970000,"ERROR: No Valid Material Chest found - Report to Mod Builder. Looking for TAG :["+sMatChest+"]");
|
|
return;
|
|
}
|
|
}
|
|
// Step 4) Found Legal Material Chest, no check verse Componant Chest
|
|
if (iPass==TRUE)
|
|
{
|
|
object oCChest = GetNearestObjectByTag("ASG_CCHEST",OBJECT_SELF);
|
|
if (GetIsObjectValid(oCChest)==FALSE)
|
|
{
|
|
SetCustomToken(1970000,"ERROR: No Valid Componant Chest found - Report to Builder.");
|
|
return;
|
|
}
|
|
object oCTStone = GetItemPossessedBy(oMatChest,"ASG_CatalystStone");
|
|
object oHWater = GetItemPossessedBy(oMatChest,"hc_holywater");
|
|
if (GetIsObjectValid(oCTStone))
|
|
{
|
|
int iSor = GetLevelByClass(CLASS_TYPE_SORCERER,oPC);
|
|
int iWiz = GetLevelByClass(CLASS_TYPE_WIZARD,oPC);
|
|
if (iSor < 1 && iWiz <1)
|
|
{
|
|
SetCustomToken(1970000,"This alchemy proccess requires a Wizard or Sorcerer.");
|
|
return;
|
|
}
|
|
}
|
|
else if (GetIsObjectValid(oHWater))
|
|
{
|
|
int iClr = GetLevelByClass(CLASS_TYPE_CLERIC,oPC);
|
|
int iDrd = GetLevelByClass(CLASS_TYPE_DRUID,oPC);
|
|
if (iClr < 1 && iDrd <1)
|
|
{
|
|
SetCustomToken(1970000,"This alchemy proccess requires a Cleric or Druid.");
|
|
return;
|
|
}
|
|
}
|
|
// Create List of Items inside of Material Chest;
|
|
int iIndex = 0;
|
|
string sIndexTag;
|
|
int iMaxIndex;
|
|
int iTemp;
|
|
string sTemp;
|
|
oItem = GetFirstItemInInventory(oMatChest);
|
|
while(GetIsObjectValid(oItem))
|
|
{
|
|
sTag = GetTag(oItem);
|
|
iTemp = GetLocalInt(OBJECT_SELF,sTag);
|
|
if (iTemp==0)
|
|
{
|
|
// Update iIndex
|
|
iIndex++;
|
|
if (iIndex<100)
|
|
{
|
|
sTemp = "0";
|
|
}
|
|
if (iIndex<10)
|
|
{
|
|
sTemp = "00";
|
|
}
|
|
SetLocalString(OBJECT_SELF,"INDEX_"+sTemp+IntToString(iIndex),sTag);
|
|
SetLocalInt(OBJECT_SELF,sTag,1);
|
|
SendMessageToPC(oPC,"DEBUG: Creating Index "+IntToString(iIndex));
|
|
}
|
|
else
|
|
{
|
|
SetLocalInt(OBJECT_SELF,sTag,iTemp+1);
|
|
}
|
|
|
|
oItem = GetNextItemInInventory(oMatChest);
|
|
}
|
|
// Items found, now compair agains items inside the Componant Chest.
|
|
// Compair & Destroy Local Varibles.
|
|
iPass = FALSE;
|
|
if (iIndex>0)
|
|
{
|
|
iMaxIndex = iIndex;
|
|
int iNum,iReq,iArray;
|
|
for (iIndex=1;iIndex<=iMaxIndex;iIndex++)
|
|
{
|
|
sBase = "INDEX_";
|
|
if (iIndex<100)
|
|
{
|
|
sTemp = "0";
|
|
}
|
|
if (iIndex<10)
|
|
{
|
|
sTemp = "00";
|
|
}
|
|
sBase+=sTemp+IntToString(iIndex);
|
|
sTemp = GetLocalString(OBJECT_SELF,sBase);
|
|
DeleteLocalString(OBJECT_SELF,sBase);
|
|
iTemp = GetLocalInt(OBJECT_SELF,sTemp);
|
|
DeleteLocalInt(OBJECT_SELF,sTemp);
|
|
// Compair Chests info
|
|
iReq = iTemp;
|
|
iNum = GetNumItems(oCChest,sTemp);
|
|
if (iNum >= iReq)
|
|
{
|
|
iPass = TRUE;
|
|
oItem = GetFirstItemInInventory(oCChest);
|
|
while (GetIsObjectValid(oItem))
|
|
{
|
|
DestroyObject(oItem);
|
|
oItem = GetNextItemInInventory(oCChest);
|
|
}
|
|
}
|
|
}
|
|
// Not Enough Materials in Chest
|
|
if (iPass == FALSE)
|
|
{
|
|
SetCustomToken(1970000,"You lack enough materials to make this magic powder.");
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SetCustomToken(1970000,"ERROR: No Materials found in Material Chest Report to Builder. Material Chest Tag ["+GetTag(oMatChest)+"]");
|
|
return;
|
|
}
|
|
}
|
|
// Last Step
|
|
if (iPass==TRUE)
|
|
{
|
|
|
|
string sGrade;
|
|
string sBluePrint = "";
|
|
oItem = GetFirstItemInInventory(oLecturn);
|
|
sTag = GetStringLeft(GetTag(oItem),8);
|
|
sGrade = GetStringRight(sTag,1);
|
|
if (sGrade == "A")
|
|
{
|
|
sBluePrint = "asg_magicpowdera";
|
|
SetCustomToken(1970000,"One bag of Grade A Magic Powder worth 10,000gp");
|
|
}
|
|
else if (sGrade == "B")
|
|
{
|
|
sBluePrint = "asg_magicpowderb";
|
|
SetCustomToken(1970000,"One bag of Grade B Magic Powder worth 1,000gp");
|
|
}
|
|
else if (sGrade == "C")
|
|
{
|
|
sBluePrint = "asg_magicpowderc";
|
|
SetCustomToken(1970000,"One bag of Grade C Magic Powder worth 100gp");
|
|
}
|
|
else
|
|
{
|
|
SetCustomToken(1970000,"ERROR: Could not identify Magic Powder Type. Report to Mod Builder.");
|
|
return;
|
|
}
|
|
oItem = CreateItemOnObject(sBluePrint,oPC,1);
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SetCustomToken(1970000,"ERROR: No Lecturn Found.");
|
|
}
|
|
|
|
}
|