Initial Upload
Initial Upload
This commit is contained in:
215
_module/nss/asg_alcdsk_mat01.nss
Normal file
215
_module/nss/asg_alcdsk_mat01.nss
Normal file
@@ -0,0 +1,215 @@
|
||||
#include "nw_i0_plot"
|
||||
#include "prc_inc_racial"
|
||||
|
||||
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 iArcane = GetLevelByClass(CLASS_TYPE_SORCERER,oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_WIZARD,oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_BEGUILER,oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_DRAGONFIRE_ADEPT,oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_DREAD_NECROMANCER,oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_SHADOWCASTER,oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_WARLOCK,oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_WARMAGE,oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_SUBLIME_CHORD,oPC);
|
||||
if (iArcane < 1)
|
||||
{
|
||||
SetCustomToken(1970000,"This alchemy proccess requires an arcane spellcaster.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (GetIsObjectValid(oHWater))
|
||||
{
|
||||
int iDivine = GetLevelByClass(CLASS_TYPE_ARCHIVIST,oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_BLIGHTER,oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_CLERIC,oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_DRUID,oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_FAVOURED_SOUL,oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_OCULAR,oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_SHAMAN,oPC)
|
||||
+ GetLevelByClass(CLASS_TYPE_UR_PRIEST,oPC);
|
||||
|
||||
if (iDivine < 1)
|
||||
{
|
||||
SetCustomToken(1970000,"This alchemy proccess requires a divine spellcaster.");
|
||||
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.");
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user