MMD_PRC8/_module/nss/rnd_magicitem.nss
Jaysyn904 adeff59f82 Initial commit
Initial commit.
2024-08-02 23:18:00 -04:00

76 lines
3.1 KiB
Plaintext

//Random Dynamic Magic Items by Ed Marshall
void main()
{
object oOpener = GetLastOpenedBy();
int iHitdice = GetHitDice(oOpener);
int iItemEnch = d20(1) + Random(iHitdice);//enchant level of item
int iItemType = d10(1);//type of item (int part of resref)
int iItemKind = d20(1);//kind of item
string sKind ="kind";//kind of item(string part of resref)
string sItem = IntToString(iItemType);
int iEnchNum = d4(1);
int iDone = GetLocalInt(OBJECT_SELF,"chestdone");
switch (iItemKind)
{
case 1: SetLocalString(OBJECT_SELF,sKind,"arrw"); break;
case 2: SetLocalString(OBJECT_SELF,sKind,"rwep"); break;
case 3: SetLocalString(OBJECT_SELF,sKind,"exot"); break;
case 4: SetLocalString(OBJECT_SELF,sKind,"larm"); break;
case 5: SetLocalString(OBJECT_SELF,sKind,"marm"); break;
case 6: SetLocalString(OBJECT_SELF,sKind,"harm"); break;
case 7: SetLocalString(OBJECT_SELF,sKind,"shld"); break;
case 8: SetLocalString(OBJECT_SELF,sKind,"ring"); break;
case 9: SetLocalString(OBJECT_SELF,sKind,"amlt"); break;
case 10: SetLocalString(OBJECT_SELF,sKind,"wand"); break;
case 11: SetLocalString(OBJECT_SELF,sKind,"gaun"); break;
case 12: SetLocalString(OBJECT_SELF,sKind,"helm"); break;
case 13: SetLocalString(OBJECT_SELF,sKind,"stff"); break;
case 14: SetLocalString(OBJECT_SELF,sKind,"clok"); break;
case 15: SetLocalString(OBJECT_SELF,sKind,"boot"); break;
case 16: SetLocalString(OBJECT_SELF,sKind,"belt"); break;
case 17: SetLocalString(OBJECT_SELF,sKind,"swrd"); break;
case 18: SetLocalString(OBJECT_SELF,sKind,"long"); break;
case 19: SetLocalString(OBJECT_SELF,sKind,"blnt"); break;
case 20: SetLocalString(OBJECT_SELF,sKind,"robe"); break;
}
SetLocalString(OBJECT_SELF,"type",sItem);
string sMakeThis = GetLocalString(OBJECT_SELF,"kind")+ GetLocalString(OBJECT_SELF,"type");
//SendMessageToPC(oOpener,"resref is " + sMakeThis);//debug
if ( iDone != 1 )
{
if (iItemKind==1)
{
object oItem = CreateItemOnObject(sMakeThis,OBJECT_SELF,Random(50)+1); //creates a random stack of stackables
SetLocalInt(oItem,"lvl",iItemEnch);
SetLocalInt(oItem,"times",iEnchNum);
ExecuteScript("rnd_arrow",oItem);
DelayCommand(0.3, ExecuteScript("ss_treasure",OBJECT_SELF));
SetLocalInt(OBJECT_SELF,"chestdone",1);
return;
}
else if (iItemKind!=1)
{
object oItem = CreateItemOnObject(sMakeThis,OBJECT_SELF);//creates single item
string sScript = "rnd_" + GetLocalString(OBJECT_SELF,"kind");
SetLocalInt(oItem,"lvl",iItemEnch);
SetLocalInt(oItem,"times",iEnchNum);
ExecuteScript(sScript,oItem);
DelayCommand(0.3, ExecuteScript("ss_treasure",OBJECT_SELF));
SetLocalInt(OBJECT_SELF,"chestdone",1);
return;
}
}
}