RoT2_PRC8/_module/nss/asg_enchan_01t.nss
Jaysyn904 499aba4eb3 Initial upload
Initial upload
2023-09-25 18:13:22 -04:00

113 lines
4.1 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Name(ASG_RULE) Setup Magic Items
//:: FileName
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Used for assembiling magic items Vol 1.
*/
//:://////////////////////////////////////////////
//:: Created By: Donny Wilbanks
//:: Created On: 02/17/03
//:://////////////////////////////////////////////
// asg_REQ1(object oPC,int vREQ, int vNUM);
#include "nw_i0_plot"
#include "asg_include_mics"
string sPower = GetLocalString(OBJECT_SELF,"ASG_BUILDITEM_ARCDIVALL");
int iClass = GetLocalInt(OBJECT_SELF,"ASG_BUILDITEM_REQUIREDCLASS");
int iRclass = GetLocalInt(OBJECT_SELF,"ASG_BUILDITEM_CREATORSLEVEL");
int iLevelR = GetLocalInt(OBJECT_SELF,"ASG_BUILDITEM_LEVELREQUIRED");
int iGPCost = GetLocalInt(OBJECT_SELF,"ASG_BUILDITEM_MATERIALCOST");
int iXPCost = GetLocalInt(OBJECT_SELF,"ASG_BUILDITEM_XPLOSS");
string sBluePrint = GetLocalString(OBJECT_SELF,"ASG_BUILDITEM_BLUEPRINT");
int StartingConditional()
{
int iResult = FALSE;
int iBBonus = 0;
int iBaseType;
object oPC = GetPCSpeaker();
object oCChest = GetNearestObjectByTag("ASG_CCHEST",OBJECT_SELF);
if (GetIsObjectValid(oCChest))
{
string sGradeC = "MagicPowder";
string sGradeB = "MagicPowderGradeB";
string sGradeA = "MagicPowderGradeA";
string sTag;
int iGPTotal = 0;
object oItem = GetFirstItemInInventory(oCChest);
while (GetIsObjectValid(oItem))
{
sTag = GetTag(oItem);
if (sTag==sGradeC || sTag==sGradeB || sTag==sGradeA)
{
iGPTotal = iGPTotal + GetGoldPieceValue(oItem);
SetLocalInt(oItem,"ASG_SETTODESTROY",TRUE);
}
oItem = GetNextItemInInventory(oCChest);
}
// SendMessageToPC(oPC,"DEBUG: Cost = "+IntToString(iGPCost)+", Materials Supplied = "+IntToString(iGPTotal));
if (iGPTotal >= iGPCost) iResult = TRUE;
if (iResult==TRUE)
{
string sChestTag = "ASG_TTEMPSTORAGECHEST";
object oChest = GetObjectByTag(sChestTag);
string sBaseType;
int iGP2 = 0;
if (GetIsObjectValid(oChest))
{
object oItem = GetLocalObject(OBJECT_SELF,"ASG_BUILDITEM_ITEM");
if (GetIsObjectValid(oItem))
{
iBaseType = GetBaseItemType(oItem);
iGP2 = GetGold(oItem);
SetLocalString(OBJECT_SELF,"ASG_BUILDITEM_BLUEPRINT",GetResRef(oItem));
}
else
{
iResult = FALSE;
SendMessageToPC(oPC,"(!) Construction Error, Item is not avaible to be built in module.");
}
if (iResult == TRUE)
{
object oItem2 = GetFirstItemInInventory(oCChest);
int iMlevel = 0;
iResult = FALSE;
while(GetIsObjectValid(oItem2) && iResult!=TRUE)
{
if (GetBaseItemType(oItem2)==iBaseType && GetPlotFlag(oItem2)!=TRUE)
{
iResult = TRUE;
iMlevel = FindItemLevel(oItem);
SetLocalInt(oItem2,"ASG_SETTODESTROY",TRUE);
}
oItem2 = GetNextItemInInventory(oCChest);
}
}
}
}
if (iResult==TRUE)
{
int nHD = GetHitDice(oPC);
int nXP = GetXP(oPC);
// * You can not lose a level with this respawning
int nMin = ((nHD * (nHD - 1)) / 2) * 1000;
int nNewXP = nXP - iXPCost;
if (nNewXP < nMin)
{
iResult = FALSE;
SendMessageToPC(oPC,"(!)Warning: You need to gain more experince before building this item, you would lose a level if you did build it.");
PlaySound("as_cv_glasbreak2");
}
else
{
SetXP(oPC, nNewXP);
}
}
}
return iResult;
}