Initial Commit
Initial Commit [v1.32PRC8]
This commit is contained in:
150
_module/nss/rd_magicitemchst.nss
Normal file
150
_module/nss/rd_magicitemchst.nss
Normal file
@@ -0,0 +1,150 @@
|
||||
#include "x2_inc_treasure"
|
||||
#include "nw_o2_coninclude"
|
||||
#include "x2_inc_compon"
|
||||
#include "rd_treasure"
|
||||
|
||||
void GenerateMagicItem(object oChest);
|
||||
|
||||
void main()
|
||||
{
|
||||
int iRandom;
|
||||
|
||||
if (GetLocalInt(OBJECT_SELF,"NW_DO_ONCE") != 0)
|
||||
return;
|
||||
|
||||
object oLastOpener = GetLastOpener();
|
||||
|
||||
GenerateMagicItem(OBJECT_SELF);
|
||||
if (Random(10) == 0)
|
||||
GenerateMagicItem(OBJECT_SELF);
|
||||
|
||||
SetLocalInt(OBJECT_SELF,"NW_DO_ONCE",1);
|
||||
|
||||
ShoutDisturbed();
|
||||
}
|
||||
|
||||
|
||||
void GenerateMagicItem(object oChest)
|
||||
{
|
||||
int iArmor;
|
||||
int iRandom;
|
||||
int iRandom2;
|
||||
int iShield;
|
||||
int iEnchant;
|
||||
int iLevel;
|
||||
int iEnchantments;
|
||||
int iIndex;
|
||||
int iPosition;
|
||||
int iBuild;
|
||||
string sTag;
|
||||
itemproperty iProperty;
|
||||
object oItem;
|
||||
object oPC;
|
||||
|
||||
oPC = GetRandomTreasurePC();
|
||||
iBuild = 0;
|
||||
iRandom = Random(3)+1;
|
||||
|
||||
switch (iRandom)
|
||||
{
|
||||
case 1: GetWeaponType(oPC);
|
||||
sTag = "en3_" + GetWeaponTag(oPC);
|
||||
iBuild = 1;
|
||||
break;
|
||||
case 2: iBuild = 2;
|
||||
iArmor = ENGetArmorType(oPC);
|
||||
sTag = GetArmorTag(iArmor);
|
||||
break;
|
||||
case 3: GetMiscMagic(oChest);
|
||||
break;
|
||||
}
|
||||
|
||||
iLevel = GetLevelByPosition(1,oPC) +
|
||||
GetLevelByPosition(2,oPC) +
|
||||
GetLevelByPosition(3,oPC);
|
||||
|
||||
if (iBuild>0)
|
||||
{
|
||||
|
||||
iRandom = Random(100)+1 + iLevel/3;
|
||||
|
||||
if (iRandom <=60)
|
||||
iEnchant = 1;
|
||||
else if (iRandom <=80)
|
||||
iEnchant= 2;
|
||||
else if (iRandom <=90)
|
||||
iEnchant = 3;
|
||||
else if (iRandom <=95)
|
||||
iEnchant = 4;
|
||||
else if (iRandom <=99)
|
||||
iEnchant = 5;
|
||||
else
|
||||
iEnchant = Random(5) + 6;
|
||||
|
||||
if (iLevel > 20)
|
||||
if (Random(100) < (iLevel-20))
|
||||
iEnchant = iEnchant + Random(10)+1;
|
||||
|
||||
if (iBuild == 1)
|
||||
{
|
||||
sTag = sTag + "2";
|
||||
oItem=CreateItemOnObject(sTag,oChest,1);
|
||||
if (IPGetIsRangedWeapon(oItem))
|
||||
{
|
||||
iProperty=ItemPropertyAttackBonus(iEnchant);
|
||||
IPSafeAddItemProperty(oItem,iProperty);
|
||||
iProperty=ItemPropertyMaxRangeStrengthMod(iEnchant);
|
||||
}
|
||||
else
|
||||
{
|
||||
iProperty=ItemPropertyEnhancementBonus(iEnchant);
|
||||
}
|
||||
}
|
||||
|
||||
if (iBuild == 2)
|
||||
{
|
||||
sTag = sTag + IntToString(Random(3)+2);
|
||||
oItem=CreateItemOnObject(sTag,oChest,1);
|
||||
iProperty=ItemPropertyACBonus(iEnchant);
|
||||
}
|
||||
|
||||
|
||||
IPSafeAddItemProperty(oItem,iProperty);
|
||||
|
||||
iEnchantments = GetNumEnchantments(iLevel);
|
||||
|
||||
iIndex=0;
|
||||
|
||||
while (iIndex < iEnchantments)
|
||||
{
|
||||
iIndex++;
|
||||
if (iBuild==1)
|
||||
if (GetTag(oItem) == "en3_monkgloves1" || sTag == "en3_monkgloves2")
|
||||
iProperty = MonkWeaponProperty(iEnchant);
|
||||
else if (IPGetIsRangedWeapon(oItem))
|
||||
iProperty = RangedWeaponProperty(iEnchant);
|
||||
else
|
||||
iProperty = WeaponProperty(iEnchant);
|
||||
else
|
||||
iProperty = ArmorProperty(iEnchant);
|
||||
IPSafeAddItemProperty(oItem,iProperty);
|
||||
}
|
||||
}
|
||||
|
||||
if (IPGetIsRangedWeapon(oItem))
|
||||
{
|
||||
if (sTag == "en3_hxbow2" || sTag == "en3_lxbow2")
|
||||
{
|
||||
GetAmmo(oChest,"en3_bolt1",iEnchant);
|
||||
}
|
||||
|
||||
if (sTag == "en3_longbow2" || sTag == "en3_sbow2")
|
||||
{
|
||||
GetAmmo(oChest,"en3_arrow1",iEnchant);
|
||||
}
|
||||
if (sTag == "en3_sling2")
|
||||
{
|
||||
GetAmmo(oChest,"en3_bullet1",iEnchant);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user