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

@ -476,9 +476,9 @@ namespace Server.Items
public override void Deserialize( GenericReader reader )
{
if ( CheckType( "PitcherWater" ) || CheckType( "GlassPitcher" ) )
base.Deserialize( reader, false );
base.InternalDeserialize( reader, false );
else
base.Deserialize( reader, true );
base.InternalDeserialize( reader, true );
int version = reader.ReadInt();
@ -1141,10 +1141,10 @@ namespace Server.Items
public override void Deserialize( GenericReader reader )
{
Deserialize( reader, true );
InternalDeserialize( reader, true );
}
public void Deserialize( GenericReader reader, bool read )
protected void InternalDeserialize( GenericReader reader, bool read )
{
base.Deserialize( reader );

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

View file

@ -52,16 +52,38 @@ namespace Server.Items
}
}
private static object[,] m_Table = new object[,]
{
{ typeof( BrownBear ), 0x1E60, 1041093, 1041107 },
{ typeof( GreatHart ), 0x1E61, 1041095, 1041109 },
{ typeof( BigFish ), 0x1E62, 1041096, 1041110 },
{ typeof( Gorilla ), 0x1E63, 1041091, 1041105 },
{ typeof( Orc ), 0x1E64, 1041090, 1041104 },
{ typeof( PolarBear ), 0x1E65, 1041094, 1041108 },
{ typeof( Troll ), 0x1E66, 1041092, 1041106 }
};
private static TrophyInfo[] m_Table = new TrophyInfo[]
{
new TrophyInfo( typeof( BrownBear ), 0x1E60, 1041093, 1041107 ),
new TrophyInfo( typeof( GreatHart ), 0x1E61, 1041095, 1041109 ),
new TrophyInfo( typeof( BigFish ), 0x1E62, 1041096, 1041110 ),
new TrophyInfo( typeof( Gorilla ), 0x1E63, 1041091, 1041105 ),
new TrophyInfo( typeof( Orc ), 0x1E64, 1041090, 1041104 ),
new TrophyInfo( typeof( PolarBear ), 0x1E65, 1041094, 1041108 ),
new TrophyInfo( typeof( Troll ), 0x1E66, 1041092, 1041106 )
};
public class TrophyInfo
{
public TrophyInfo( Type type, int id, int deedNum, int addonNum )
{
m_CreatureType = type;
m_NorthID = id;
m_DeedNumber = deedNum;
m_AddonNumber = addonNum;
}
private Type m_CreatureType;
private int m_NorthID;
private int m_DeedNumber;
private int m_AddonNumber;
public Type CreatureType { get { return m_CreatureType; } }
public int NorthID { get { return m_NorthID; } }
public int DeedNumber { get { return m_DeedNumber; } }
public int AddonNumber { get { return m_AddonNumber; } }
}
private class CorpseTarget : Target
{
@ -100,43 +122,49 @@ namespace Server.Items
if ( obj is Corpse )
obj = ((Corpse)obj).Owner;
for ( int i = 0; obj != null && i < m_Table.GetLength( 0 ); ++i )
{
if ( m_Table[i, 0] == obj.GetType() )
{
Container pack = from.Backpack;
if ( obj != null )
{
for ( int i = 0; i < m_Table.Length; i++ )
{
if ( m_Table[i].CreatureType == obj.GetType() )
{
Container pack = from.Backpack;
if ( pack != null && pack.ConsumeTotal( typeof( Board ), 10 ) )
{
from.SendLocalizedMessage( 1042278 ); // You review the corpse and find it worthy of a trophy.
from.SendLocalizedMessage( 1042602 ); // You use your kit up making the trophy.
if ( pack != null && pack.ConsumeTotal( typeof( Board ), 10 ) )
{
from.SendLocalizedMessage( 1042278 ); // You review the corpse and find it worthy of a trophy.
from.SendLocalizedMessage( 1042602 ); // You use your kit up making the trophy.
Mobile hunter = null;
int weight = 0;
Mobile hunter = null;
int weight = 0;
if ( targeted is BigFish )
{
hunter = ((BigFish)targeted).Fisher;
weight = (int) ((BigFish)targeted).Weight;
}
if ( targeted is BigFish )
{
BigFish fish = targeted as BigFish;
from.AddToBackpack( new TrophyDeed( (int)m_Table[i, 1] + 7, (int)m_Table[i, 1], (int)m_Table[i, 2], (int)m_Table[i, 3], hunter, weight ) );
hunter = fish.Fisher;
weight = (int)fish.Weight;
if ( targeted is Corpse )
((Corpse)targeted).VisitedByTaxidermist = true;
else if ( targeted is BigFish )
((BigFish)targeted).Consume();
fish.Consume();
}
m_Kit.Delete();
return;
}
else
{
from.SendLocalizedMessage( 1042598 ); // You do not have enough boards.
return;
}
}
}
from.AddToBackpack( new TrophyDeed( m_Table[i], hunter, weight ) );
if ( targeted is Corpse )
((Corpse)targeted).VisitedByTaxidermist = true;
m_Kit.Delete();
return;
}
else
{
from.SendLocalizedMessage( 1042598 ); // You do not have enough boards.
return;
}
}
}
}
from.SendLocalizedMessage( 1042599 ); // That does not look like something you want hanging on a wall.
}
@ -144,6 +172,8 @@ namespace Server.Items
}
}
public class TrophyAddon : Item, IAddon
{
public override bool ForceShowProperties { get { return ObjectPropertyList.Enabled; } }
@ -353,6 +383,11 @@ namespace Server.Items
m_AnimalWeight = animalWeight;
}
public TrophyDeed( TaxidermyKit.TrophyInfo info, Mobile hunter, int animalWeight )
: this( info.NorthID + 7, info.NorthID, info.DeedNumber, info.AddonNumber )
{
}
public TrophyDeed( Serial serial ) : base( serial )
{
}

View file

@ -191,7 +191,7 @@ namespace Server.Items
{
Item gems = null;
switch ( Utility.Random( 17 ) )
switch ( Utility.Random( 15 ) )
{
case 0: gems = new Amber(); break;
case 1: gems = new Amethyst(); break;
@ -208,10 +208,8 @@ namespace Server.Items
case 10: gems = new DarkSapphire(); break;
case 11: gems = new Turquoise(); break;
case 12: gems = new EcruCitrine(); break;
case 13: gems = new WhitePearl(); break;
case 14: gems = new FireRuby(); break;
case 15: gems = new BlueDiamond(); break;
case 16: gems = new BrilliantAmber(); break;
case 13: gems = new FireRuby(); break;
case 14: gems = new BlueDiamond(); break;
}
int amount = Math.Min( 5, m_Gems );