Automatically generates loot for all creatures in the game based on their calculated level. I attempted to get it as close as I could to the same level of levels generated through the manual system. The system works with Champions still as well.
The system provides for a more randomized experience to the game while rewarding for attempting harder creatures. With this system there can be different loot generation between creatures themselves. Some greater dragons can vary greatly in their strength and skills. This system will provide different loot between different levels of greater dragons providing an even more rewarding experience.
Right now there is not a configuration but I may plan for one in the future.
There are a few small basecreature edits required in order to not
Feel free to use, edit, modify however you wish.
BaseCreature.cs
Right above "public virtual bool CheckGold(Mobile from, Item dropped)".
Righ above "public virtual void GenerateLoot() {}".
Finally in OnBeforeDeath() I found this function
and I replaced GenerateLoot(false); with my new function GenerateDynamicLoot();
Here is my complete OnBeforeDeath just incase anyone has a hard time finding it in future versions.
The system provides for a more randomized experience to the game while rewarding for attempting harder creatures. With this system there can be different loot generation between creatures themselves. Some greater dragons can vary greatly in their strength and skills. This system will provide different loot between different levels of greater dragons providing an even more rewarding experience.
Right now there is not a configuration but I may plan for one in the future.
There are a few small basecreature edits required in order to not
Feel free to use, edit, modify however you wish.
BaseCreature.cs
Right above "public virtual bool CheckGold(Mobile from, Item dropped)".
Code:
#region DynamicLoot Edit #1
/// <summary>
/// Gets the monsters currentLevel
/// </summary>
private int m_Level = -1;
[CommandProperty(AccessLevel.GameMaster)]
public int Level {
get {
if (m_Level == -1)
{
m_Level = GetCurrentLevel;
}
return m_Level;
}
}
private int GetCurrentLevel {
get {
var hpLevel = Math.Max(1, HitsMax / 50);
var statsLevel = Math.Max(1, (RawStr + RawDex + RawInt) / 20.0);
return hpLevel + (int)statsLevel;
}
}
#endregion
Righ above "public virtual void GenerateLoot() {}".
Code:
#region DynamicLoot Edit #2
public virtual void GenerateDynamicLoot() {
if (Summoned) {
return;
}
Container backpack = Backpack;
if (backpack == null) {
backpack = new Backpack {Movable = false};
AddItem(backpack);
}
DynamicLoot.Generate(this, backpack, m_Spawning, m_KillersLuck);
}
#endregion
Finally in OnBeforeDeath() I found this function
Code:
if (!Summoned && !NoKillAwards && !m_HasGeneratedLoot && !m_NoLootOnDeath)
{
m_HasGeneratedLoot = true;
GenerateLoot(false);
}
and I replaced GenerateLoot(false); with my new function GenerateDynamicLoot();
Code:
if (!Summoned && !NoKillAwards && !m_HasGeneratedLoot && !m_NoLootOnDeath)
{
m_HasGeneratedLoot = true;
GenerateDynamicLoot();
}
Here is my complete OnBeforeDeath just incase anyone has a hard time finding it in future versions.
Code:
public override bool OnBeforeDeath()
{
int treasureLevel = TreasureMapLevel;
GetLootingRights();
if (treasureLevel == 1 && Map == Map.Trammel && TreasureMap.IsInHavenIsland(this))
{
Mobile killer = LastKiller;
if (killer is BaseCreature)
{
killer = ((BaseCreature)killer).GetMaster();
}
if (killer is PlayerMobile && ((PlayerMobile)killer).Young)
{
treasureLevel = 0;
}
}
if (!Summoned && !NoKillAwards && !IsBonded && !NoLootOnDeath)
{
if (treasureLevel >= 0)
{
if (m_Paragon && XmlParagon.GetChestChance(this) > Utility.RandomDouble())
{
XmlParagon.AddChest(this, treasureLevel);
}
else if (TreasureMapChance >= Utility.RandomDouble())
{
Map map = Map;
if (map == Map.Trammel && Siege.SiegeShard)
map = Map.Felucca;
PackItem(new TreasureMap(treasureLevel, map));
}
}
if (m_Paragon && Paragon.ChocolateIngredientChance > Utility.RandomDouble())
{
switch (Utility.Random(4))
{
case 0:
PackItem(new CocoaButter());
break;
case 1:
PackItem(new CocoaLiquor());
break;
case 2:
PackItem(new SackOfSugar());
break;
case 3:
PackItem(new Vanilla());
break;
}
}
}
if (!Summoned && !NoKillAwards && !m_HasGeneratedLoot && !m_NoLootOnDeath)
{
m_HasGeneratedLoot = true;
GenerateDynamicLoot();
}
if (!NoKillAwards && Region.IsPartOf("Doom"))
{
int bones = TheSummoningQuest.GetDaemonBonesFor(this);
if (bones > 0)
{
PackItem(new DaemonBone(bones));
}
}
if (IsAnimatedDead)
{
Effects.SendLocationEffect(Location, Map, 0x3728, 13, 1, 0x461, 4);
}
InhumanSpeech speechType = SpeechType;
if (speechType != null)
{
speechType.OnDeath(this);
}
if (m_ReceivedHonorContext != null)
{
m_ReceivedHonorContext.OnTargetKilled();
}
return base.OnBeforeDeath();
}