[RunUO 2.0 Final] Instanced loot system
Here is my instanced loot system:
i.e. if two people kill one monster they are treated as if they killed two monsters and got seperate loots.Fame is not seperated.The nice thing is the loot is calculated for each one according to their own luck. I think some of the shard owners want this type of looting system.
You have to replace
/scripts/items/misc/corpses/corpse.cs
/scripts/engines/ai/creature/basecreature.cs
I used non-professional techniques, but I guess it's ok since it is my first script release =)
BEWARE: Carving has changed a little bit, now if you cut a sheep's corpse the wool is dropped on the ground
After you add these scripts previous corpses will be useless. I mean don't add while the server is busier than usual.
And make sure that you test a little bit! I am pretty sure there will be bugs but we can solve if you point them out ^^
I'll write the modified parts tomorrow if there are people out there who don't want to replace but edit
CORPSE.CS
find ( around line 17)
make it
find (around line 400)
note: if you edited it before, 10 can be any value.
make it
find( around line 450)
make it
find( around line 860)
make it
find(around line 1000)
make it
Thats all for corpse.cs
BaseCreature.cs
find ( around line 168)
make it
find ( around line 1260)
make it
find( around line 1356)
make it
find(around line 1440)
make it
find(around line 3537)
make it
find(around line 1575)
make it
I guess thats all ^^
Here is my instanced loot system:
i.e. if two people kill one monster they are treated as if they killed two monsters and got seperate loots.Fame is not seperated.The nice thing is the loot is calculated for each one according to their own luck. I think some of the shard owners want this type of looting system.
You have to replace
/scripts/items/misc/corpses/corpse.cs
/scripts/engines/ai/creature/basecreature.cs
I used non-professional techniques, but I guess it's ok since it is my first script release =)
BEWARE: Carving has changed a little bit, now if you cut a sheep's corpse the wool is dropped on the ground
After you add these scripts previous corpses will be useless. I mean don't add while the server is busier than usual.
And make sure that you test a little bit! I am pretty sure there will be bugs but we can solve if you point them out ^^
I'll write the modified parts tomorrow if there are people out there who don't want to replace but edit
CORPSE.CS
find ( around line 17)
Code:
public class Corpse : Container, ICarvable
{
make it
Code:
private List<Mobile> m_Looted = new List<Mobile>();
private List<Backpack> m_Packs = new List<Backpack>();
public bool isParagon;
public Type ownerType;
find (around line 400)
note: if you edited it before, 10 can be any value.
Code:
writer.Write((int)10);
make it
Code:
if (ownerType != null)
{
writer.Write((int)11);
writer.Write((string)ownerType.FullName);
writer.Write((bool)isParagon);
writer.Write((int)m_Looted.Count);
foreach (PlayerMobile PM in m_Looted)
{
writer.Write(PM);
}
writer.Write((int)m_Packs.Count);
foreach (Backpack BP in m_Packs)
{
writer.Write(BP);
}
}
else
writer.Write((int)10);
find( around line 450)
Code:
switch ( version )
{
make it
Code:
switch ( version )
{
//modify
case 11:
{
ownerType = ScriptCompiler.FindTypeByFullName(reader.ReadString());
isParagon = reader.ReadBool();
int subcount = reader.ReadInt();
for (int i = 0; i < subcount; i++)
{
PlayerMobile pm = (PlayerMobile)reader.ReadMobile();
m_Looted.Add(pm);
}
subcount = reader.ReadInt();
for (int i = 0; i < subcount; i++)
{
Backpack bp = reader.ReadItem() as Backpack;
m_Packs.Add(bp);
}
goto case 10;
}
find( around line 860)
Code:
player.SendLocalizedMessage( 1050023 ); // You find a golden skull, but your backpack is too full to carry it.
}
}
}
}
#endregion
make it
Code:
player.SendLocalizedMessage( 1050023 ); // You find a golden skull, but your backpack is too full to carry it.
}
}
}
}
#endregion
//modify
if ((!selfLoot) && !(this.Owner is PlayerMobile))
{
int x = hasLooted(from);
if (x >= 0)
{
Point3D cantayeri = new Point3D(from.Location.X, from.Location.Y, from.Location.Z-50);
m_Packs[x].MoveToWorld(cantayeri, from.Map);
m_Packs[x].Open(from);
}
else
{
if (ownerType != null)
{
BaseCreature creature = Activator.CreateInstance(ownerType) as BaseCreature;
Backpack backpack;
backpack = new Backpack();
while (creature.Backpack.Items.Count > 0)
backpack.AddItem(creature.Backpack.Items[0]);
creature.BodyValue = 0;
Point3D canavaryeri = new Point3D(0, 0, -30);
creature.MoveToWorld(canavaryeri, from.Map);
if (isParagon)
creature.IsParagon = true;
else
creature.IsParagon = false;
creature.instancedCreature = true;
creature.luck = from.Luck;
creature.Kill();
creature.OnBeforeDeath();
creature.Corpse.Visible = false;
int count = creature.Corpse.Items.Count;
while (creature.Corpse.Items.Count > 0)
backpack.AddItem(creature.Corpse.Items[0]);
Point3D cantayeri = new Point3D(from.Location.X, from.Location.Y, from.Location.Z - 50);
backpack.MoveToWorld(cantayeri, from.Map);
backpack.Open(from);
m_Looted.Add(from);
m_Packs.Add(backpack);
}
}
if (from != m_Owner)
from.RevealingAction();
return;
}
find(around line 1000)
Code:
public override void OnDoubleClick( Mobile from )
{
Open(from, Core.AOS);
}
make it
Code:
public override void OnDoubleClick( Mobile from )
{
Open(from, Core.AOS);
}
public int hasLooted(Mobile who)
{
for (int i = 0; i < m_Looted.Count; i++)
{
if (m_Looted[i] != null && m_Looted[i] == who)
return i;
}
return -1;
}
Thats all for corpse.cs
BaseCreature.cs
find ( around line 168)
Code:
public class BaseCreature : Mobile, IHonorTarget
{
Code:
public class BaseCreature : Mobile, IHonorTarget
{
public bool instancedCreature;
public int luck;
find ( around line 1260)
Code:
public virtual void OnCarve( Mobile from, Corpse corpse )
{
Code:
public virtual void OnCarve( Mobile from, Corpse corpse )
{
while(corpse.Items.Count > 0)
corpse.Items[0].Delete();
find( around line 1356)
Code:
from.SendMessage( "You cut away some scales, but they remain on the corpse." );
}
make it
Code:
from.SendMessage( "You cut away some scales, but they remain on the corpse." );
}
while (corpse.Items.Count > 0)
corpse.Items[0].MoveToWorld(corpse.Location, corpse.Map);
find(around line 1440)
Code:
base.Serialize( writer );
Code:
base.Serialize( writer );
if (instancedCreature != null)
{
writer.Write((int)17); // version
writer.Write((bool)instancedCreature);
writer.Write((int)luck);
}
else
writer.Write((int)16);
find(around line 3537)
Code:
if ( !spawning )
m_KillersLuck = LootPack.GetLuckChanceForKiller( this );
Code:
if ( !spawning )
m_KillersLuck = LootPack.GetLuckChanceForKiller( this );
if (instancedCreature)
m_KillersLuck = luck;
find(around line 1575)
Code:
int version = reader.ReadInt();
make it
Code:
int version = reader.ReadInt();
if (version == 17)
{
instancedCreature = reader.ReadBool();
luck = reader.ReadInt();
}
I guess thats all ^^