260 lines
6.0 KiB
Plaintext
260 lines
6.0 KiB
Plaintext
#include "rd_treasure"
|
|
#include "nw_o2_coninclude"
|
|
|
|
void GenerateWeapon(object oChest, object oPC);
|
|
void GenerateArmor(object oChest, object oPC);
|
|
|
|
void main()
|
|
{
|
|
object oPC = GetLastOpener();
|
|
|
|
if (!GetIsObjectValid(GetObjectByTag("LairSpawn")) && GetLocalInt(OBJECT_SELF,"EN4DoOnce") == 0)
|
|
{
|
|
SetLocalInt(OBJECT_SELF,"EN4DoOnce",1);
|
|
if (GetLocalInt(OBJECT_SELF,"Weapon") == 1)
|
|
{
|
|
object oPartyMember = GetFirstFactionMember(oPC, TRUE);
|
|
while (GetIsObjectValid(oPartyMember) == TRUE)
|
|
{
|
|
GenerateWeapon(OBJECT_SELF,oPartyMember);
|
|
oPartyMember = GetNextFactionMember(oPC, TRUE);
|
|
}
|
|
} else {
|
|
object oPartyMember = GetFirstFactionMember(oPC, TRUE);
|
|
while (GetIsObjectValid(oPartyMember) == TRUE)
|
|
{
|
|
GenerateArmor(OBJECT_SELF,oPartyMember);
|
|
oPartyMember = GetNextFactionMember(oPC, TRUE);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
void GenerateWeapon(object oChest, object oPC)
|
|
{
|
|
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;
|
|
|
|
GetWeaponType(oPC);
|
|
sTag = "en3_" + GetWeaponTag(oPC);
|
|
iBuild = 1;
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
void GenerateArmor(object oChest, object oPC)
|
|
{
|
|
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 = 2;
|
|
iArmor = ENGetArmorType(oPC);
|
|
sTag = GetArmorTag(iArmor);
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|