massive branch sync

This commit is contained in:
mark 2010-04-25 06:09:43 +00:00
parent 489bbabe93
commit b3e8ec0a08
192 changed files with 1249 additions and 1124 deletions

View file

@ -90,17 +90,160 @@ namespace Server.Items
if ( !Core.SE )
return false;
return ( DateTime.Now > m_TimeOfDeath + InstancedCorpseTime );
return ( DateTime.Now < (m_TimeOfDeath + InstancedCorpseTime) );
}
}
public override bool IsDecoContainer
private Dictionary<Item, InstancedItemInfo> m_InstancedItems;
private class InstancedItemInfo
{
private Mobile m_Mobile;
private Item m_Item;
private bool m_Perpetual; //Needed for Rummaged stuff. CONTRARY to the Patchlog, cause a later FoF contradicts it. Verify on OSI.
public bool Perpetual { get { return m_Perpetual; } set { m_Perpetual = value; } }
public InstancedItemInfo( Item i, Mobile m )
{
m_Item = i;
m_Mobile = m;
}
public bool IsOwner( Mobile m )
{
if ( m_Item.LootType == LootType.Cursed ) //Cursed Items are part of everyone's instanced corpse... (?)
return true;
if ( m == null )
return false; //sanity
if ( m_Mobile == m )
return true;
Party myParty = Party.Get( m_Mobile );
return (myParty != null && myParty == Party.Get( m ));
}
}
public override bool IsChildVisibleTo( Mobile m, Item child )
{
if ( !m.Player || m.AccessLevel > AccessLevel.Player ) //Staff and creatures not subject to instancing.
return true;
if ( m_InstancedItems != null )
{
InstancedItemInfo info;
if ( m_InstancedItems.TryGetValue( child, out info ) && (InstancedCorpse || info.Perpetual) )
{
return info.IsOwner( m ); //IsOwner checks Party stuff.
}
}
return true;
}
private void AssignInstancedLoot()
{
if ( m_Aggressors.Count == 0 || this.Items.Count == 0 )
return;
if ( m_InstancedItems == null )
m_InstancedItems = new Dictionary<Item, InstancedItemInfo>();
List<Item> m_Stackables = new List<Item>();
List<Item> m_Unstackables = new List<Item>();
for ( int i = 0; i < this.Items.Count; i++ )
{
Item item = this.Items[i];
if ( item.LootType != LootType.Cursed ) //Don't have curesd items take up someone's item spot.. (?)
{
if ( item.Stackable )
m_Stackables.Add( item );
else
m_Unstackables.Add( item );
}
}
List<Mobile> attackers = new List<Mobile>( m_Aggressors );
for ( int i = 1; i < attackers.Count -1; i++ ) //randomize
{
int rand = Utility.Random( i + 1 );
Mobile temp = attackers[rand];
attackers[rand] = attackers[i];
attackers[i] = temp;
}
//stackables first, for the remaining stackables, have those be randomly added after
for ( int i = 0; i < m_Stackables.Count; i++ )
{
Item item = m_Stackables[i];
if ( item.Amount >= attackers.Count )
{
int amountPerAttacker = (item.Amount / attackers.Count);
int remainder = (item.Amount % attackers.Count);
for ( int j = 0; j < ((remainder == 0) ? attackers.Count -1 : attackers.Count); j++ )
{
Item splitItem = Mobile.LiftItemDupe( item, item.Amount - amountPerAttacker ); //LiftItemDupe automagically adds it as a child item to the corpse
m_InstancedItems.Add( splitItem, new InstancedItemInfo( splitItem, attackers[j] ) );
//What happens to the remaining portion? TEMP FOR NOW UNTIL OSI VERIFICATION: Treat as Single Item.
}
if ( remainder == 0 )
{
m_InstancedItems.Add( item, new InstancedItemInfo( item, attackers[attackers.Count - 1] ) );
//Add in the original item (which has an equal amount as the others) to the instance for the last attacker, cause it wasn't added above.
}
else
{
m_Unstackables.Add( item );
}
}
else
{
//What happens in this case? TEMP FOR NOW UNTIL OSI VERIFICATION: Treat as Single Item.
m_Unstackables.Add( item );
}
}
for ( int i = 0; i < m_Unstackables.Count; i++ )
{
Mobile m = attackers[i % attackers.Count];
Item item = m_Unstackables[i];
m_InstancedItems.Add( item, new InstancedItemInfo( item, m ) );
}
}
public void AddCarvedItem( Item carved, Mobile carver )
{
this.DropItem( carved );
if ( this.InstancedCorpse )
{
if ( m_InstancedItems == null )
m_InstancedItems = new Dictionary<Item, InstancedItemInfo>();
m_InstancedItems.Add( carved, new InstancedItemInfo( carved, carver ) );
}
}
public override bool IsDecoContainer
{
get{ return false; }
}
private Dictionary<Mobile, List<Item>> m_InstancedItems;
[CommandProperty( AccessLevel.GameMaster )]
public DateTime TimeOfDeath
{
@ -310,6 +453,9 @@ namespace Server.Items
if ( owner.Player && Core.AOS )
c.SetRestoreInfo( item, item.Location );
}
if ( !owner.Player )
c.AssignInstancedLoot();
}
else
{
@ -371,7 +517,9 @@ namespace Server.Items
m_EquipItems = equipItems;
m_Aggressors = new List<Mobile>( owner.Aggressors.Count + owner.Aggressed.Count );
bool addToAggressors = !( owner is BaseCreature );
//bool addToAggressors = !( owner is BaseCreature );
bool isBaseCreature = (owner is BaseCreature);
TimeSpan lastTime = TimeSpan.MaxValue;
@ -385,7 +533,7 @@ namespace Server.Items
lastTime = (DateTime.Now - info.LastCombatTime);
}
if ( addToAggressors && !info.CriminalAggression )
if ( !isBaseCreature && !info.CriminalAggression )
m_Aggressors.Add( info.Attacker );
}
@ -399,11 +547,11 @@ namespace Server.Items
lastTime = (DateTime.Now - info.LastCombatTime);
}
if ( addToAggressors )
if ( !isBaseCreature )
m_Aggressors.Add( info.Defender );
}
if ( !addToAggressors )
if ( isBaseCreature )
{
BaseCreature bc = (BaseCreature)owner;
@ -426,12 +574,6 @@ namespace Server.Items
DevourCorpse();
}
private void AssignInstancedLoot()
{
if ( m_InstancedItems == null )
m_InstancedItems = new Dictionary<Mobile, List<Item>>();
}
public Corpse( Serial serial ) : base( serial )
{
}
@ -713,6 +855,9 @@ namespace Server.Items
if ( !m_Looters.Contains( from ) )
m_Looters.Add( from );
if ( m_InstancedItems != null && m_InstancedItems.ContainsKey( item ) )
m_InstancedItems.Remove( item );
}
public override void OnItemLifted( Mobile from, Item item )
@ -727,6 +872,9 @@ namespace Server.Items
if ( !m_Looters.Contains( from ) )
m_Looters.Add( from );
if ( m_InstancedItems != null && m_InstancedItems.ContainsKey( item ) )
m_InstancedItems.Remove( item );
}
private class OpenCorpseEntry : ContextMenuEntry