public static int NewScroll(CLRScriptBase script, int maxValue)
{
#region Early Return if No Scrolls Fit the Criteria
if (maxValue < 12)
{
return 0;
}
#endregion
#region Generate up to Level 9 Scrolls
if (maxValue >= 3825)
{
int roll = Generation.rand.Next(512);
if((roll & 256) == 0)
{
script.CreateItemOnObject(Level0Scrolls[Generation.rand.Next(Level0Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 12;
}
else if((roll & 128) == 0)
{
script.CreateItemOnObject(Level1Scrolls[Generation.rand.Next(Level1Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 25;
}
else if ((roll & 64) == 0)
{
script.CreateItemOnObject(Level2Scrolls[Generation.rand.Next(Level2Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 150;
}
else if ((roll & 32) == 0)
{
script.CreateItemOnObject(Level3Scrolls[Generation.rand.Next(Level3Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 375;
}
else if ((roll & 16) == 0)
{
script.CreateItemOnObject(Level4Scrolls[Generation.rand.Next(Level4Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 700;
}
else if ((roll & 8) == 0)
{
script.CreateItemOnObject(Level5Scrolls[Generation.rand.Next(Level5Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 1125;
}
else if ((roll & 4) == 0)
{
script.CreateItemOnObject(Level6Scrolls[Generation.rand.Next(Level6Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 1650;
}
else if ((roll & 2) == 0)
{
script.CreateItemOnObject(Level7Scrolls[Generation.rand.Next(Level7Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 2275;
}
else if ((roll & 1) == 0)
{
script.CreateItemOnObject(Level8Scrolls[Generation.rand.Next(Level8Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 3000;
}
else
{
script.CreateItemOnObject(Level9Scrolls[Generation.rand.Next(Level9Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 3825;
}
}
#endregion
#region Generate up to Level 8 Scrolls
else if (maxValue > 3000)
{
int roll = Generation.rand.Next(256);
if ((roll & 128) == 0)
{
script.CreateItemOnObject(Level0Scrolls[Generation.rand.Next(Level0Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 12;
}
else if ((roll & 64) == 0)
{
script.CreateItemOnObject(Level1Scrolls[Generation.rand.Next(Level1Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 25;
}
else if ((roll & 32) == 0)
{
script.CreateItemOnObject(Level2Scrolls[Generation.rand.Next(Level2Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 150;
}
else if ((roll & 16) == 0)
{
script.CreateItemOnObject(Level3Scrolls[Generation.rand.Next(Level3Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 375;
}
else if ((roll & 8) == 0)
{
script.CreateItemOnObject(Level4Scrolls[Generation.rand.Next(Level4Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 700;
}
else if ((roll & 4) == 0)
{
script.CreateItemOnObject(Level5Scrolls[Generation.rand.Next(Level5Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 1125;
}
else if ((roll & 2) == 0)
{
script.CreateItemOnObject(Level6Scrolls[Generation.rand.Next(Level6Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 1650;
}
else if ((roll & 1) == 0)
{
script.CreateItemOnObject(Level7Scrolls[Generation.rand.Next(Level7Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 2275;
}
else
{
script.CreateItemOnObject(Level8Scrolls[Generation.rand.Next(Level8Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 3000;
}
}
#endregion
#region Generate up to Level 7 Scrolls
else if (maxValue > 2275)
{
int roll = Generation.rand.Next(128);
if ((roll & 64) == 0)
{
script.CreateItemOnObject(Level0Scrolls[Generation.rand.Next(Level0Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 12;
}
else if ((roll & 32) == 0)
{
script.CreateItemOnObject(Level1Scrolls[Generation.rand.Next(Level1Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 25;
}
else if ((roll & 16) == 0)
{
script.CreateItemOnObject(Level2Scrolls[Generation.rand.Next(Level2Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 150;
}
else if ((roll & 8) == 0)
{
script.CreateItemOnObject(Level3Scrolls[Generation.rand.Next(Level3Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 375;
}
else if ((roll & 4) == 0)
{
script.CreateItemOnObject(Level4Scrolls[Generation.rand.Next(Level4Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 700;
}
else if ((roll & 2) == 0)
{
script.CreateItemOnObject(Level5Scrolls[Generation.rand.Next(Level5Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 1125;
}
else if ((roll & 1) == 0)
{
script.CreateItemOnObject(Level6Scrolls[Generation.rand.Next(Level6Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 1650;
}
else
{
script.CreateItemOnObject(Level7Scrolls[Generation.rand.Next(Level7Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 2275;
}
}
#endregion
#region Generate up to Level 6 Scrolls
else if (maxValue > 1650)
{
int roll = Generation.rand.Next(64);
if ((roll & 32) == 0)
{
script.CreateItemOnObject(Level0Scrolls[Generation.rand.Next(Level0Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 12;
}
else if ((roll & 16) == 0)
{
script.CreateItemOnObject(Level1Scrolls[Generation.rand.Next(Level1Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 25;
}
else if ((roll & 8) == 0)
{
script.CreateItemOnObject(Level2Scrolls[Generation.rand.Next(Level2Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 150;
}
else if ((roll & 4) == 0)
{
script.CreateItemOnObject(Level3Scrolls[Generation.rand.Next(Level3Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 375;
}
else if ((roll & 2) == 0)
{
script.CreateItemOnObject(Level4Scrolls[Generation.rand.Next(Level4Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 700;
}
else if ((roll & 1) == 0)
{
script.CreateItemOnObject(Level5Scrolls[Generation.rand.Next(Level5Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 1125;
}
else
{
script.CreateItemOnObject(Level6Scrolls[Generation.rand.Next(Level6Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 1650;
}
}
#endregion
#region Generate up to Level 5 Scrolls
else if (maxValue > 1125)
{
int roll = Generation.rand.Next(32);
if ((roll & 16) == 0)
{
script.CreateItemOnObject(Level0Scrolls[Generation.rand.Next(Level0Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 12;
}
else if ((roll & 8) == 0)
{
script.CreateItemOnObject(Level1Scrolls[Generation.rand.Next(Level1Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 25;
}
else if ((roll & 4) == 0)
{
script.CreateItemOnObject(Level2Scrolls[Generation.rand.Next(Level2Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 150;
}
else if ((roll & 2) == 0)
{
script.CreateItemOnObject(Level3Scrolls[Generation.rand.Next(Level3Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 375;
}
else if ((roll & 1) == 0)
{
script.CreateItemOnObject(Level4Scrolls[Generation.rand.Next(Level4Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 700;
}
else
{
script.CreateItemOnObject(Level5Scrolls[Generation.rand.Next(Level5Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 1125;
}
}
#endregion
#region Generate up to Level 4 Scrolls
else if (maxValue > 700)
{
int roll = Generation.rand.Next(16);
if ((roll & 8) == 0)
{
script.CreateItemOnObject(Level0Scrolls[Generation.rand.Next(Level0Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 12;
}
else if ((roll & 4) == 0)
{
script.CreateItemOnObject(Level1Scrolls[Generation.rand.Next(Level1Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 25;
}
else if ((roll & 2) == 0)
{
script.CreateItemOnObject(Level2Scrolls[Generation.rand.Next(Level2Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 150;
}
else if ((roll & 1) == 0)
{
script.CreateItemOnObject(Level3Scrolls[Generation.rand.Next(Level3Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 375;
}
else
{
script.CreateItemOnObject(Level4Scrolls[Generation.rand.Next(Level4Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 700;
}
}
#endregion
#region Generate up to Level 3 Scrolls
else if (maxValue > 375)
{
int roll = Generation.rand.Next(8);
if ((roll & 4) == 0)
{
script.CreateItemOnObject(Level0Scrolls[Generation.rand.Next(Level0Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 12;
}
else if ((roll & 2) == 0)
{
script.CreateItemOnObject(Level1Scrolls[Generation.rand.Next(Level1Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 25;
}
else if ((roll & 1) == 0)
{
script.CreateItemOnObject(Level2Scrolls[Generation.rand.Next(Level2Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 150;
}
else
{
script.CreateItemOnObject(Level3Scrolls[Generation.rand.Next(Level3Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 375;
}
}
#endregion
#region Generate up to Level 2 Scrolls
else if (maxValue > 150)
{
int roll = Generation.rand.Next(4);
if ((roll & 2) == 0)
{
script.CreateItemOnObject(Level0Scrolls[Generation.rand.Next(Level0Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 12;
}
else if ((roll & 1) == 0)
{
script.CreateItemOnObject(Level1Scrolls[Generation.rand.Next(Level1Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 25;
}
else
{
script.CreateItemOnObject(Level2Scrolls[Generation.rand.Next(Level2Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 150;
}
}
#endregion
#region Generate up to Level 1 Spells
else if (maxValue > 25)
{
int roll = Generation.rand.Next(2);
if ((roll & 1) == 0)
{
script.CreateItemOnObject(Level0Scrolls[Generation.rand.Next(Level0Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 12;
}
else
{
script.CreateItemOnObject(Level1Scrolls[Generation.rand.Next(Level1Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 25;
}
}
#endregion
#region Only Generate Level 0 Spells
else
{
script.CreateItemOnObject(Level0Scrolls[Generation.rand.Next(Level0Scrolls.Count)], script.OBJECT_SELF, 1, "", FALSE);
return 12;
}
#endregion
}