HoS_PRC8/_mod/_module/nss/oc_gentreasure.nss
Jaysyn904 04165202c0 Initial upload
Initial upload
2024-11-25 19:36:07 -05:00

46 lines
1.5 KiB
Plaintext

//////////////////////////////////////////////////////////////////////////////
// Generate treasure on close
//////////////////////////////////////////////////////////////////////////////
// tag = delay seconds_quantity_resref
//////////////////////////////////////////////////////////////////////////////
string fnParse(string sSource)
{ // return parsed
string sRet="";
string sName=sSource;
while(GetStringLength(sName)>0&&GetStringLeft(sName,1)!="_")
{ // build return string
sRet=sRet+GetStringLeft(sName,1);
sName=GetStringRight(sName,GetStringLength(sName)-1);
} // build return string
return sRet;
} // fnParse()
string fnRemoveParsed(string sSource,string sParsed)
{
string sRet=GetStringRight(sSource,GetStringLength(sSource)-GetStringLength(sParsed));
if (GetStringLeft(sRet,1)=="_") sRet=GetStringRight(sRet,GetStringLength(sRet)-1);
return sRet;
} // fnRemoveParsed()
void fnCreateTreasure(object oContainer,string sResRef,int nQuantity)
{ // create treasure in container
object oItem=CreateItemOnObject(sResRef,oContainer,nQuantity);
} // fnCreateTreasure()
void main()
{
string sName=GetName(OBJECT_SELF);
string sRes="";
int nDelay=0;
int nQuantity=1;
string sParsed=fnParse(sName);
sName=fnRemoveParsed(sName,sParsed);
nDelay=StringToInt(sParsed);
sParsed=fnParse(sName);
sRes=fnRemoveParsed(sName,sParsed);
nQuantity=StringToInt(sParsed);
if (nDelay<1) nDelay=1;
if (nQuantity<1) nQuantity=1;
DelayCommand(IntToFloat(nDelay),fnCreateTreasure(OBJECT_SELF,sRes,nQuantity));
}