rendered paste bodyusing System;
using System.Reflection;
using DOL.Database;
using log4net;
using DOL.GS;
using DOL.Events;
using DOL.GS.PacketHandler;
namespace DOL.GS
{
public class RoG : LootGeneratorBase
{
//Minimum level mob to drop an item.
private static int MIN_LEVEL = 0;
//%chance for an item to drop.
private static int DROP_CHANCE = 100;
//Toggle scaling of drop % by the relative level of mob to attacker. If the mob is lower level, chance reduced. If mob is higher, chance increased.
//Modifier is the rate at which the chance changes by level difference. Mod = 5 means that the drop% changes by 5% per level difference.
private static bool CHANCE_SCALE = false;
private static int CHANCE_MODIFIER = 1;
//Toggle Quality scaling of drops, killing higher level monsters increases the MIN_QUAL of the items by QUALITY_MODIFIER per level difference.
private static bool QUALITY_SCALE = false;
private static int QUALITY_MODIFIER = 1;
//Minimum Quality of items
private static int MIN_QUAL = 85;
//Maximum Quality of items
private static int MAX_QUAL = 100;
//Adjust the ratio of Armor dropped to other (jewelry+cloaks) items.
//The % of armor drops is related by: % = (ARMOR_RATIO - 6)/ARMOR_RATIO; So a ratio of 10 would give 50% armor, and 100 gives 95%.
private static int ARMOR_RATIO = 30; //80%
//Maximum number of item drops from a single mob
private static int MAX_DROPS = 5;
//Realm specific drops.
private static bool REALM_SPECIFIC = false;
/*
armor[0][][] = cloth;
armor[1][][] = leather;
armor[2][][] = studded;
armor[3][][] = chain;
armor[4][][] = scale;
armor[5][][] = plate;
armor[][0][] = head;
armor[][1][] = hands;
armor[][2][] = arms;
armor[][3][] = torso;
armor[][4][] = legs;
armor[][5][] = boots;
armor[][][x] = Model IDs;
cloak[x] = Model IDs;
misc[0] = necklace;
misc[1] = jewel;
misc[2] = belt;
misc[3] = ring;
misc[4] = bracer;
*/
//MODEL IDS
private static ushort[][][] armor = new ushort[6][][];
private static ushort[] cloak;
private static ushort[] jewel = { 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 620, 621 };
private static ushort[] necklace = { 101, 623, 624, 1887 };
private static ushort[] belt = { 597, 1601, 1884 };
private static ushort[] ring = { 103, 1888, 1891, 2520, 2521, 2522, 2523, 2524, 2525, 2526 };
private static ushort[] bracer = { 598, 1885, 619, 622 };
//private static String[] slots = {"head", "hands", "arms", "torso", "legs", "boots", "cloak"};
private static byte[] slots = { 0x15, 0x16, 0x1C, 0x19, 0x1B, 0x17, 0x1A };
/*
obj_armor contains Object_Type values for armor.
obj_armor[0][] = albion;
obj_armor[1][] = hibernia;
obj_armor[2][] = midgard;
armor_type = { head, hands, arms, torso, legs, boots };
*/
private static byte[][] obj_armor;
private static byte[] item_types = { 0x15, 0x16, 0x1C, 0x19, 0x1B, 0x17 };
private static byte[][] stat_value = new byte[][]{new byte[]{1, 1}, new byte[]{4, 3}, new byte[]{7, 5}, new byte[]{10, 7}, new byte[]{13, 9}, new byte[]{16, 11}, new byte[]{19, 13}, new byte[]{22, 15}, new byte[]{25, 17}, new byte[]{28, 19}};
private static byte[][] resist_value = new byte[][]{new byte[]{1, 1}, new byte[]{2, 2}, new byte[]{3, 4}, new byte[]{5, 8}, new byte[]{7, 12}, new byte[]{9, 16}, new byte[]{11, 20}, new byte[]{13, 24}, new byte[]{15, 28}, new byte[]{17, 32}};
private static byte[][] hits_value = new byte[][]{new byte[]{4, 1}, new byte[]{12, 3}, new byte[]{20, 5}, new byte[]{28, 7}, new byte[]{36, 9}, new byte[]{44, 11}, new byte[]{52, 13}, new byte[]{60, 15}, new byte[]{68, 17}, new byte[]{76, 19}};
private static byte[][] power_value = new byte[][]{new byte[]{1, 1}, new byte[]{2, 2}, new byte[]{3, 4}, new byte[]{5, 8}, new byte[]{7, 12}, new byte[]{9, 16}, new byte[]{11, 20}, new byte[]{13, 24}, new byte[]{15, 28}, new byte[]{17, 32}};
private static byte[][] focus_value = new byte[][]{new byte[]{5, 1}, new byte[]{10, 1}, new byte[]{15, 1}, new byte[]{20, 1}, new byte[]{25, 1}, new byte[]{30, 1}, new byte[]{35, 1}, new byte[]{40, 1}, new byte[]{45, 1}, new byte[]{50, 1}};
private static byte[][] skill_value = new byte[][]{new byte[]{1, 1}, new byte[]{2, 5}, new byte[]{3, 10}, new byte[]{4, 15}, new byte[]{5, 20}, new byte[]{6, 25}, new byte[]{7, 30}, new byte[]{8, 35}};
[ScriptLoadedEvent]
public static void OnScriptCompiled(DOLEvent e, object sender, EventArgs args)
{
DataObject[] temp;
int[] ot = { 32, 33, 34, 35, 38, 36 };
int x;
for (int a = 0; a<6; a++)
{
armor[a] = new ushort[6][];
for (int b = 0; b<6; b++)
{
x = 0;
temp = GameServer.Database.SelectObjects(typeof(ItemTemplate), "Object_Type = " + ot[a] + " AND Item_Type = " + slots[b]);
armor[a][b] = new ushort[temp.Length];
foreach(DataObject item in temp)
{
armor[a][b][x++] = (ushort)(item as ItemTemplate).Model;
}
}
}
x = 0;
temp = GameServer.Database.SelectObjects(typeof(ItemTemplate), "Item_Type = " + slots[6]);
cloak = new ushort[temp.Length];
foreach(DataObject item in temp)
{
cloak[x++] = (ushort)(item as ItemTemplate).Model;
}
obj_armor = new byte[3][];
obj_armor[0] = new byte[] { 32, 33, 34, 35, 36 };
obj_armor[1] = new byte[] { 32, 33, 34, 35 };
obj_armor[2] = new byte[] { 32, 33, 37, 38 };
}
// Defines a logger for this class.
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// Map holding the corresponding lootTemplateName for each Moblevel group
// groups are rounded down to 1-5, 5-10, 10-15, 15-20, 20-25, etc...
// 1:n Mapping between Moblevel and LootTemplate
protected static ItemTemplate[][] m_itemTemplates=null;
// Constrcut a new templategenerate and load it's values from database.
public RoG()
{
}
public override LootList GenerateLoot(GameMob mob, GameObject killer)
{
LootList loot = new LootList();
if(mob.Level >= MIN_LEVEL)
{
int NewChance = DROP_CHANCE;
if(CHANCE_SCALE)
{
NewChance += (mob.Level - killer.Level) * CHANCE_MODIFIER;
if(NewChance > 100) NewChance = 100;
if(NewChance < 0) NewChance = 0;
}
if (Util.Chance(NewChance))
{
for(int i = 0; i < MAX_DROPS; i++)
if(Util.Chance(NewChance))
loot.AddFixed(GetItem(mob, killer));
}
}
return loot;
}
public virtual ItemTemplate GetItem(GameMob mob, GameObject killer)
{
ItemTemplate temp = new ItemTemplate();
/*These properties apply to all items unless otherwise specified*/
temp.Condition = 50000;
temp.Durability = 50000;
temp.MaxCondition = 50000;
temp.MaxDurability = 50000;
int qual;
if(QUALITY_SCALE)
{
qual = Util.Random(MIN_QUAL + (killer.Level - mob.Level), MAX_QUAL);
if(qual < MIN_QUAL) qual = MIN_QUAL;
}
else
qual = Util.Random(MIN_QUAL, MAX_QUAL);
temp.Quality = qual;
temp.MaxQuality = qual;
temp.Level = killer.Level;
temp.Bonus = Util.Random((int)(killer.Level * 0.7));
temp.IsPickable = true;
temp.IsDropable = true;
temp.Weight = Util.Random(5, 30);
temp.SPD_ABS = 0;
temp.DPS_AF = 0;
int RandRealm;
if(REALM_SPECIFIC)
{
RandRealm = killer.Realm;
temp.Realm = RandRealm--;
}
else
{
RandRealm = Util.Random(2);
temp.Realm = RandRealm;
}
switch(Util.Random(ARMOR_RATIO))
{
case 0: //Cloak
{
temp.Object_Type = 41;
temp.Item_Type = 0x1A;
temp.Model = cloak[Util.Random(cloak.Length - 1)];
temp.Name = "cloak";
break;
}
case 1: //Necklace
{
temp.Object_Type = 41;
temp.Item_Type = 0x1D;
temp.Model = necklace[Util.Random(necklace.Length - 1)];
temp.Name = "necklace";
break;
}
case 2: //Jewel
{
temp.Object_Type = 41;
temp.Item_Type = 0x18;
temp.Model = jewel[Util.Random(jewel.Length - 1)];
temp.Name = "jewel";
break;
}
case 3: //Ring
{
temp.Object_Type = 41;
temp.Item_Type = 0x23;
temp.Model = ring[Util.Random(ring.Length - 1)];
temp.Name = "ring";
break;
}
case 4: //Bracer
{
temp.Object_Type = 41;
temp.Item_Type = 0x21;
temp.Model = bracer[Util.Random(bracer.Length - 1)];
break;
}
case 5: //Belt
{
temp.Object_Type = 41;
temp.Item_Type = 0x20;
temp.Model = belt[Util.Random(belt.Length - 1)];
temp.Name = "belt";
break;
}
default:
{
byte armorMaterial = (byte)Util.Random(obj_armor[RandRealm].Length - 1);
temp.Object_Type = obj_armor[RandRealm][armorMaterial];
byte armorSlot = (byte)Util.Random(item_types.Length - 1);
temp.Item_Type = item_types[armorSlot];
temp.Model = armor[armorMaterial][armorSlot][Util.Random(armor[armorMaterial][armorSlot].Length - 1)];
switch(armorMaterial)
{
case 0: temp.SPD_ABS = 0; temp.Name = "cloth"; break;
case 1: temp.SPD_ABS = 10; temp.Name = "leather"; break;
case 2: temp.SPD_ABS = 19; temp.Name = "studded"; break;
case 3: temp.SPD_ABS = 27; temp.Name = "chain"; break;
case 4: temp.SPD_ABS = 27; temp.Name = "scale";break;
case 5: temp.SPD_ABS = 34; temp.Name = "plate";break;
}
switch(armorSlot)
{
case 0: temp.Name += " helm"; break;
case 1: temp.Name += " gloves"; break;
case 2: temp.Name += " arms"; break;
case 3: temp.Name += " hauberk"; break;
case 4: temp.Name += " leggings"; break;
case 5: temp.Name += " boots"; break;
}
temp.DPS_AF = killer.Level + 1;
if(armorMaterial != 0) temp.DPS_AF *= 2;
break;
}
}
GetMods(temp);
switch(temp.Bonus1Type)
{
case 1: temp.Name += " of Strength"; break;
case 2: temp.Name += " of Dexterity"; break;
case 3: temp.Name += " of Constitution"; break;
case 4: temp.Name += " of Quickness"; break;
case 5: temp.Name += " of Intelligence"; break;
case 6: temp.Name += " of Piety"; break;
case 7: temp.Name += " of Empathy"; break;
case 8: temp.Name += " of Charisma"; break;
case 9: temp.Name += " of Power"; break;
case 10: temp.Name += " of Health"; break;
case 11: temp.Name += " of Body Resistance"; break;
case 12: temp.Name += " of Cold Resistance"; break;
case 13: temp.Name += " of Crush Resistance"; break;
case 14: temp.Name += " of Energy Resistance"; break;
case 15: temp.Name += " of Heat Resistance"; break;
case 16: temp.Name += " of Matter Resistance"; break;
case 17: temp.Name += " of Slash Resistance"; break;
case 18: temp.Name += " of Spirit Resistance"; break;
case 19: temp.Name += " of Thrust Resistance"; break;
default: break;
}
temp.Gold = (short) (killer.Level / 10);
temp.Silver = (byte) Util.Random(killer.Level * 2);
temp.Copper = (byte) Util.Random(100);
return temp;
}
void GetMods(ItemTemplate t)
{
int bank = t.Level * ((t.Quality / 100)^10);
for(int modcount = 0; modcount < 6 && bank > 0; modcount++)
{
int mod = Util.Random(18) + 1;
int value = 0;
int cost = 0;
if(mod < 9)
{
do
{
value = Util.Random(stat_value.Length - 1);
cost = modcount > 0 ? stat_value[value][1] / 2 : stat_value[value][1];
value = stat_value[value][0];
}while(bank - cost < 0);
}
else if(mod > 10)
{
do
{
value = Util.Random(resist_value.Length - 1);
cost = modcount > 0 ? resist_value[value][1] / 2 : resist_value[value][1];
value = resist_value[value][0];
}while(bank - cost < 0);
}
else if(mod == 9)
{
do
{
value = Util.Random(power_value.Length - 1);
cost = modcount > 0 ? power_value[value][1] / 2 : power_value[value][1];
value = power_value[value][0];
}while(bank - cost < 0);
}
else if(mod == 10)
{
do
{
value = Util.Random(hits_value.Length - 1);
cost = modcount > 0 ? hits_value[value][1] / 2 : hits_value[value][1];
value = hits_value[value][0];
}while(bank - cost < 0);
}
switch(modcount)
{
case 0: t.Bonus1Type = mod; t.Bonus1 = value; break;
case 1: t.Bonus2Type = mod; t.Bonus2 = value; break;
case 2: t.Bonus3Type = mod; t.Bonus3 = value; break;
case 3: t.Bonus4Type = mod; t.Bonus4 = value; break;
case 4: t.Bonus5Type = mod; t.Bonus5 = value; break;
case 5: t.ExtraBonusType = mod; t.ExtraBonus = value; break;
}
bank -= cost;
}
}
}
}