This commit is contained in:
eos 2011-12-01 05:42:10 +00:00
parent 4e15a2aa4c
commit 4708ec4301
18 changed files with 889 additions and 800 deletions

View file

@ -152,7 +152,7 @@ namespace Server.Items
AddonComponent.ApplyLightTo( this ); AddonComponent.ApplyLightTo( this );
} }
public void DropItemsToGround() public virtual void DropItemsToGround()
{ {
for ( int i = Items.Count - 1; i >= 0; i-- ) for ( int i = Items.Count - 1; i >= 0; i-- )
Items[ i ].MoveToWorld( Location ); Items[ i ].MoveToWorld( Location );

View file

@ -5,6 +5,7 @@ using Server;
using Server.Items; using Server.Items;
using Server.Mobiles; using Server.Mobiles;
using Server.Multis; using Server.Multis;
using Server.Network;
using Server.Gumps; using Server.Gumps;
using Server.ContextMenus; using Server.ContextMenus;
@ -12,6 +13,8 @@ namespace Server.Items
{ {
public class Aquarium : BaseAddonContainer public class Aquarium : BaseAddonContainer
{ {
public static readonly TimeSpan EvaluationInterval = TimeSpan.FromDays( 1 );
// items info // items info
private int m_LiveCreatures; private int m_LiveCreatures;
@ -48,7 +51,7 @@ namespace Server.Items
{ {
get get
{ {
int state = m_Food.State == (int) FoodState.Overfed ? 1 : (int) FoodState.Full - m_Food.State; int state = ( m_Food.State == (int) FoodState.Overfed ) ? 1 : (int) FoodState.Full - m_Food.State;
state += (int) WaterState.Strong - m_Water.State; state += (int) WaterState.Strong - m_Water.State;
@ -61,7 +64,7 @@ namespace Server.Items
[CommandProperty( AccessLevel.GameMaster )] [CommandProperty( AccessLevel.GameMaster )]
public bool IsFull public bool IsFull
{ {
get{ return Items.Count >= MaxItems; } get{ return ( Items.Count >= MaxItems ); }
} }
// vacation info // vacation info
@ -82,18 +85,20 @@ namespace Server.Items
public AquariumState Food public AquariumState Food
{ {
get{ return m_Food; } get{ return m_Food; }
set{ m_Food = value; InvalidateProperties(); }
} }
[CommandProperty( AccessLevel.GameMaster )] [CommandProperty( AccessLevel.GameMaster )]
public AquariumState Water public AquariumState Water
{ {
get{ return m_Water; } get{ return m_Water; }
set{ m_Water = value; InvalidateProperties(); }
} }
[CommandProperty( AccessLevel.GameMaster )] [CommandProperty( AccessLevel.GameMaster )]
public bool OptimalState public bool OptimalState
{ {
get{ return m_Food.State == (int) FoodState.Full && m_Water.State == (int) WaterState.Strong; } get{ return ( m_Food.State == (int) FoodState.Full && m_Water.State == (int) WaterState.Strong ); }
} }
// events // events
@ -120,15 +125,19 @@ namespace Server.Items
{ {
get get
{ {
if ( ItemID == 0x3060 ) if ( ItemID == 0x3062 )
return new AquariumEastDeed(); return new AquariumEastDeed();
else else
return new AquariumNorthDeed(); return new AquariumNorthDeed();
} }
} }
public override double DefaultWeight{ get{ return 10.0; } }
public Aquarium( int itemID ) : base( itemID ) public Aquarium( int itemID ) : base( itemID )
{ {
Movable = false;
if ( itemID == 0x3060 ) if ( itemID == 0x3060 )
AddComponent( new AddonContainerComponent( 0x3061 ), -1, 0, 0 ); AddComponent( new AddonContainerComponent( 0x3061 ), -1, 0, 0 );
@ -136,7 +145,6 @@ namespace Server.Items
AddComponent( new AddonContainerComponent( 0x3063 ), 0, -1, 0 ); AddComponent( new AddonContainerComponent( 0x3063 ), 0, -1, 0 );
MaxItems = 30; MaxItems = 30;
Weight = 10.0;
m_Food = new AquariumState(); m_Food = new AquariumState();
m_Water = new AquariumState(); m_Water = new AquariumState();
@ -144,32 +152,52 @@ namespace Server.Items
m_Food.State = (int) FoodState.Full; m_Food.State = (int) FoodState.Full;
m_Water.State = (int) WaterState.Strong; m_Water.State = (int) WaterState.Strong;
m_Food.Maintain = Utility.RandomMinMax( 1, 2 );; m_Food.Maintain = Utility.RandomMinMax( 1, 2 );
m_Food.Improve = m_Food.Maintain + Utility.RandomMinMax( 1, 2 ); m_Food.Improve = m_Food.Maintain + Utility.RandomMinMax( 1, 2 );
m_Water.Maintain = Utility.RandomMinMax( 1, 3 );; m_Water.Maintain = Utility.RandomMinMax( 1, 3 );
m_Events = new List<int>(); m_Events = new List<int>();
m_Timer = Timer.DelayCall( TimeSpan.FromHours( 24 ), TimeSpan.FromHours( 24 ), new TimerCallback( Evaluate ) ); m_Timer = Timer.DelayCall( EvaluationInterval, EvaluationInterval, new TimerCallback( Evaluate ) );
} }
public Aquarium( Serial serial ) : base( serial ) public Aquarium( Serial serial ) : base( serial )
{ {
} }
public override void OnDelete()
{
if ( m_Timer != null )
{
m_Timer.Stop();
m_Timer = null;
}
}
public override void OnDoubleClick( Mobile from ) public override void OnDoubleClick( Mobile from )
{ {
ExamineAquarium( from ); ExamineAquarium( from );
} }
public override bool OnDragDrop( Mobile from, Item dropped ) public virtual bool HasAccess( Mobile from )
{ {
bool truefalse = true; if ( from == null || from.Deleted )
return false;
else if ( from.AccessLevel >= AccessLevel.GameMaster )
return true;
BaseHouse house = BaseHouse.FindHouseAt( this ); BaseHouse house = BaseHouse.FindHouseAt( this );
if ( house == null || !house.IsCoOwner( from ) ) if ( house != null && house.IsCoOwner( from ) )
return true;
return false;
}
public override bool OnDragDrop( Mobile from, Item dropped )
{
if ( !HasAccess( from ) )
{ {
from.SendLocalizedMessage( 1073821 ); // You do not have access to that item for use with the aquarium. from.SendLocalizedMessage( 1073821 ); // You do not have access to that item for use with the aquarium.
return false; return false;
@ -181,20 +209,18 @@ namespace Server.Items
return false; return false;
} }
bool takeItem = true;
if ( dropped is FishBowl ) if ( dropped is FishBowl )
{ {
FishBowl bowl = (FishBowl) dropped; FishBowl bowl = (FishBowl) dropped;
if( !bowl.Empty ) if ( bowl.Empty || !AddFish( from, bowl.Fish ) )
{ return false;
if( AddFish( from, bowl.Fish ) )
{
bowl.InvalidateProperties();
InvalidateProperties();
}
}
return false;
bowl.InvalidateProperties();
takeItem = false;
} }
else if ( dropped is BaseFish ) else if ( dropped is BaseFish )
{ {
@ -205,21 +231,20 @@ namespace Server.Items
} }
else if ( dropped is VacationWafer ) else if ( dropped is VacationWafer )
{ {
m_VacationLeft += 7; m_VacationLeft = VacationWafer.VacationDays;
((Item) dropped).Delete(); dropped.Delete();
from.SendLocalizedMessage( 1074428, "" + m_VacationLeft ); // The aquarium will be in vacation mode for ~1_DAYS~ days from.SendLocalizedMessage( 1074428, m_VacationLeft.ToString() ); // The aquarium will be in vacation mode for ~1_DAYS~ days
} }
else if ( dropped is AquariumFood ) else if ( dropped is AquariumFood )
{ {
m_Food.Added += 1; m_Food.Added += 1;
((Item) dropped).Delete(); dropped.Delete();
from.SendLocalizedMessage( 1074259, "" + 1 ); // ~1_NUM~ unit(s) of food have been added to the aquarium. from.SendLocalizedMessage( 1074259, "1" ); // ~1_NUM~ unit(s) of food have been added to the aquarium.
} }
else if ( dropped is BaseBeverage ) else if ( dropped is BaseBeverage )
{ {
BaseBeverage beverage = (BaseBeverage) dropped; BaseBeverage beverage = (BaseBeverage) dropped;
if ( beverage.IsEmpty || !beverage.Pourable || beverage.Content != BeverageType.Water ) if ( beverage.IsEmpty || !beverage.Pourable || beverage.Content != BeverageType.Water )
@ -232,26 +257,34 @@ namespace Server.Items
beverage.Quantity -= 1; beverage.Quantity -= 1;
from.PlaySound( 0x4E ); from.PlaySound( 0x4E );
from.SendLocalizedMessage( 1074260, "" + 1 ); // ~1_NUM~ unit(s) of water have been added to the aquarium. from.SendLocalizedMessage( 1074260, "1" ); // ~1_NUM~ unit(s) of water have been added to the aquarium.
truefalse = false;
takeItem = false;
} }
else if ( !AddDecoration( from, dropped ) ) else if ( !AddDecoration( from, dropped ) )
truefalse = false; {
takeItem = false;
}
from.CloseGump( typeof( AquariumGump ) ); from.CloseGump( typeof( AquariumGump ) );
InvalidateProperties(); InvalidateProperties();
return truefalse; if ( takeItem )
from.PlaySound( 0x42 );
return takeItem;
} }
public override void OnChop( Mobile from ) public override void DropItemsToGround()
{ {
for ( int i = 0; i < Items.Count; i ++ ) Point3D loc = GetWorldLocation();
for ( int i = Items.Count - 1; i >= 0; i-- )
{ {
Item item = Items[ i ]; Item item = Items[ i ];
item.MoveToWorld( Location, Map ); item.MoveToWorld( loc, Map );
if ( item is BaseFish ) if ( item is BaseFish )
{ {
@ -261,8 +294,6 @@ namespace Server.Items
fish.StartTimer(); fish.StartTimer();
} }
} }
base.OnChop( from );
} }
public override void GetProperties( ObjectPropertyList list ) public override void GetProperties( ObjectPropertyList list )
@ -270,26 +301,28 @@ namespace Server.Items
base.GetProperties( list ); base.GetProperties( list );
if ( m_VacationLeft > 0 ) if ( m_VacationLeft > 0 )
list.Add( 1074430, "{0}", m_VacationLeft ); // Vacation days left: ~1_DAYS list.Add( 1074430, m_VacationLeft.ToString() ); // Vacation days left: ~1_DAYS
if ( m_Events.Count > 0 ) if ( m_Events.Count > 0 )
list.Add( 1074426, "{0}", m_Events.Count ); // ~1_NUM~ event(s) to view! list.Add( 1074426, m_Events.Count.ToString() ); // ~1_NUM~ event(s) to view!
if ( m_RewardAvailable ) if ( m_RewardAvailable )
list.Add( 1074362 ); // A reward is available! list.Add( 1074362 ); // A reward is available!
list.Add( 1074247, "{0}\t{1}", m_LiveCreatures, MaxLiveCreatures ); // Live Creatures: ~1_NUM~ / ~2_MAX~ list.Add( 1074247, "{0}\t{1}", m_LiveCreatures, MaxLiveCreatures ); // Live Creatures: ~1_NUM~ / ~2_MAX~
if ( DeadCreatures > 0 ) int dead = DeadCreatures;
list.Add( 1074248, "{0}", DeadCreatures ); // Dead Creatures: ~1_NUM~
int decorations = Items.Count - m_LiveCreatures - DeadCreatures; if ( dead > 0 )
list.Add( 1074248, dead.ToString() ); // Dead Creatures: ~1_NUM~
int decorations = Items.Count - m_LiveCreatures - dead;
if ( decorations > 0 ) if ( decorations > 0 )
list.Add( 1074249, "{0}", Items.Count - m_LiveCreatures - DeadCreatures ); // Decorations: ~1_NUM~ list.Add( 1074249, decorations.ToString() ); // Decorations: ~1_NUM~
list.Add( 1074250, "#" + FoodNumber() ); // Food state: ~1_STATE~ list.Add( 1074250, "#{0}", FoodNumber() ); // Food state: ~1_STATE~
list.Add( 1074251, "#" + WaterNumber() ); // Water state: ~1_STATE~ list.Add( 1074251, "#{0}", WaterNumber() ); // Water state: ~1_STATE~
if ( m_Food.State == (int) FoodState.Dead ) if ( m_Food.State == (int) FoodState.Dead )
list.Add( 1074577, "{0}\t{1}", m_Food.Added, m_Food.Improve ); // Food Added: ~1_CUR~ Needed: ~2_NEED~ list.Add( 1074577, "{0}\t{1}", m_Food.Added, m_Food.Improve ); // Food Added: ~1_CUR~ Needed: ~2_NEED~
@ -304,8 +337,6 @@ namespace Server.Items
list.Add( 1074578, "{0}\t{1}", m_Water.Added, m_Water.Maintain ); // Water Added: ~1_CUR~ Needed: ~2_NEED~ list.Add( 1074578, "{0}\t{1}", m_Water.Added, m_Water.Maintain ); // Water Added: ~1_CUR~ Needed: ~2_NEED~
else else
list.Add( 1074254, "{0}\t{1}\t{2}", m_Water.Added, m_Water.Maintain, m_Water.Improve ); // Water Added: ~1_CUR~ Maintain: ~2_NEED~ Improve: ~3_GROW~ list.Add( 1074254, "{0}\t{1}\t{2}", m_Water.Added, m_Water.Maintain, m_Water.Improve ); // Water Added: ~1_CUR~ Maintain: ~2_NEED~ Improve: ~3_GROW~
//list.Add( 1073841, "{0}\t{1}\t{2}", Items.Count, MaxItems, TotalWeight ); // Contents: ~1_COUNT~/~2_MAXCOUNT~ items, ~3_WEIGHT~ stones
} }
public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list ) public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
@ -316,17 +347,20 @@ namespace Server.Items
{ {
list.Add( new ExamineEntry( this ) ); list.Add( new ExamineEntry( this ) );
if ( m_RewardAvailable ) if ( HasAccess( from ) )
list.Add( new CollectRewardEntry( this ) ); {
if ( m_RewardAvailable )
list.Add( new CollectRewardEntry( this ) );
if ( m_Events.Count > 0 ) if ( m_Events.Count > 0 )
list.Add( new ViewEventEntry( this ) ); list.Add( new ViewEventEntry( this ) );
if ( m_VacationLeft > 0 ) if ( m_VacationLeft > 0 )
list.Add( new CancelVacationMode( this ) ); list.Add( new CancelVacationMode( this ) );
}
} }
if ( (int) from.AccessLevel > (int) AccessLevel.Counselor ) if ( from.AccessLevel >= AccessLevel.GameMaster )
{ {
list.Add( new GMAddFood( this ) ); list.Add( new GMAddFood( this ) );
list.Add( new GMAddWater( this ) ); list.Add( new GMAddWater( this ) );
@ -340,13 +374,13 @@ namespace Server.Items
{ {
base.Serialize( writer ); base.Serialize( writer );
writer.Write( 1 ); // Version writer.Write( 2 ); // Version
// version 1 // version 1
if ( m_Timer != null ) if ( m_Timer != null )
writer.Write( m_Timer.Next ); writer.Write( m_Timer.Next );
else else
writer.Write( DateTime.Now + TimeSpan.FromHours( 24 ) ); writer.Write( DateTime.Now + EvaluationInterval );
// version 0 // version 0
writer.Write( (int) m_LiveCreatures ); writer.Write( (int) m_LiveCreatures );
@ -371,16 +405,20 @@ namespace Server.Items
switch ( version ) switch ( version )
{ {
case 2:
case 1: case 1:
{
DateTime next = reader.ReadDateTime(); DateTime next = reader.ReadDateTime();
if ( next < DateTime.Now ) if ( next < DateTime.Now )
next = DateTime.Now; next = DateTime.Now;
m_Timer = Timer.DelayCall( next - DateTime.Now, TimeSpan.FromHours( 24 ), new TimerCallback( Evaluate ) ); m_Timer = Timer.DelayCall( next - DateTime.Now, EvaluationInterval, new TimerCallback( Evaluate ) );
goto case 0; goto case 0;
}
case 0: case 0:
{
m_LiveCreatures = reader.ReadInt(); m_LiveCreatures = reader.ReadInt();
m_VacationLeft = reader.ReadInt(); m_VacationLeft = reader.ReadInt();
@ -400,6 +438,13 @@ namespace Server.Items
m_RewardAvailable = reader.ReadBool(); m_RewardAvailable = reader.ReadBool();
break; break;
}
}
if ( version < 2 )
{
Weight = DefaultWeight;
Movable = false;
} }
} }
@ -506,29 +551,41 @@ namespace Server.Items
switch ( Utility.Random( 6 ) ) switch ( Utility.Random( 6 ) )
{ {
case 0: case 0:
{
message = 1074371; // Brine shrimp have hatched overnight in the tank. message = 1074371; // Brine shrimp have hatched overnight in the tank.
fish = new BrineShrimp(); fish = new BrineShrimp();
break; break;
}
case 1: case 1:
{
message = 1074365; // A new creature has hatched overnight in the tank. message = 1074365; // A new creature has hatched overnight in the tank.
fish = new Coral(); fish = new Coral();
break; break;
}
case 2: case 2:
{
message = 1074365; // A new creature has hatched overnight in the tank. message = 1074365; // A new creature has hatched overnight in the tank.
fish = new FullMoonFish(); fish = new FullMoonFish();
break; break;
}
case 3: case 3:
{
message = 1074373; // A sea horse has hatched overnight in the tank. message = 1074373; // A sea horse has hatched overnight in the tank.
fish = new SeaHorseFish(); fish = new SeaHorseFish();
break; break;
}
case 4: case 4:
{
message = 1074365; // A new creature has hatched overnight in the tank. message = 1074365; // A new creature has hatched overnight in the tank.
fish = new StrippedFlakeFish(); fish = new StrippedFlakeFish();
break; break;
}
case 5: case 5:
{
message = 1074365; // A new creature has hatched overnight in the tank. message = 1074365; // A new creature has hatched overnight in the tank.
fish = new StrippedSosarianSwill(); fish = new StrippedSosarianSwill();
break; break;
}
} }
if ( Utility.RandomDouble() < 0.05 ) if ( Utility.RandomDouble() < 0.05 )
@ -536,7 +593,10 @@ namespace Server.Items
else if ( Utility.RandomDouble() < 0.5 ) else if ( Utility.RandomDouble() < 0.5 )
fish.Hue = Utility.RandomMinMax( 0x100, 0x3E5 ); fish.Hue = Utility.RandomMinMax( 0x100, 0x3E5 );
m_Events.Add( message ); if ( AddFish( fish ) )
m_Events.Add( message );
else
fish.Delete();
} }
} }
@ -547,10 +607,13 @@ namespace Server.Items
KillFish( 1 ); KillFish( 1 );
} }
else else
{
KillFish( m_LiveCreatures - MaxLiveCreatures ); KillFish( m_LiveCreatures - MaxLiveCreatures );
}
} }
m_EvaluateDay = !m_EvaluateDay; m_EvaluateDay = !m_EvaluateDay;
InvalidateProperties();
} }
public virtual void GiveReward( Mobile to ) public virtual void GiveReward( Mobile to )
@ -558,31 +621,37 @@ namespace Server.Items
if ( !m_RewardAvailable ) if ( !m_RewardAvailable )
return; return;
double max = ( m_LiveCreatures / (double) 30 ) * m_Decorations.Length + 1; int max = (int) ( ( (double) m_LiveCreatures / 30 ) * m_Decorations.Length );
int random = (int) Math.Log( Utility.RandomMinMax( 1, (int) Math.Pow( Math.E, max ) ) ); int random = ( max <= 0 ) ? 0 : Utility.Random( max );
if ( random < 0 ) if ( random >= m_Decorations.Length )
random = 0;
if ( random > m_Decorations.Length - 1 )
random = m_Decorations.Length - 1; random = m_Decorations.Length - 1;
Type reward = m_Decorations[ random ];
Item item; Item item;
try{ item = Activator.CreateInstance( reward ) as Item; } try
catch{ return; } {
item = Activator.CreateInstance( m_Decorations[ random ] ) as Item;
}
catch
{
return;
}
if ( item == null )
return;
if ( !to.PlaceInBackpack( item ) ) if ( !to.PlaceInBackpack( item ) )
to.SendLocalizedMessage( 1074361 ); // The reward could not be given. Make sure you have room in your pack.
else
{ {
to.SendLocalizedMessage( 1074360, "#" + item.LabelNumber ); // You receive a reward: ~1_REWARD~ item.Delete();
to.PlaySound( 0x5A3 ); to.SendLocalizedMessage( 1074361 ); // The reward could not be given. Make sure you have room in your pack.
return;
} }
to.SendLocalizedMessage( 1074360, String.Format( "#{0}", item.LabelNumber ) ); // You receive a reward: ~1_REWARD~
to.PlaySound( 0x5A3 );
m_RewardAvailable = false; m_RewardAvailable = false;
InvalidateProperties(); InvalidateProperties();
@ -591,9 +660,9 @@ namespace Server.Items
public virtual void UpdateFoodState() public virtual void UpdateFoodState()
{ {
if ( m_Food.Added < m_Food.Maintain ) if ( m_Food.Added < m_Food.Maintain )
m_Food.State = m_Food.State <= 0 ? 0 : m_Food.State - 1; m_Food.State = ( m_Food.State <= 0 ) ? 0 : m_Food.State - 1;
else if ( m_Food.Added >= m_Food.Improve ) else if ( m_Food.Added >= m_Food.Improve )
m_Food.State = m_Food.State >= (int) FoodState.Overfed ? (int) FoodState.Overfed : m_Food.State + 1; m_Food.State = ( m_Food.State >= (int) FoodState.Overfed ) ? (int) FoodState.Overfed : m_Food.State + 1;
m_Food.Maintain = Utility.Random( (int) FoodState.Overfed + 1 - m_Food.State, 2 ); m_Food.Maintain = Utility.Random( (int) FoodState.Overfed + 1 - m_Food.State, 2 );
@ -608,9 +677,9 @@ namespace Server.Items
public virtual void UpdateWaterState() public virtual void UpdateWaterState()
{ {
if ( m_Water.Added < m_Water.Maintain ) if ( m_Water.Added < m_Water.Maintain )
m_Water.State = m_Water.State <= 0 ? 0 : m_Water.State - 1; m_Water.State = ( m_Water.State <= 0 ) ? 0 : m_Water.State - 1;
else if ( m_Water.Added >= m_Water.Improve ) else if ( m_Water.Added >= m_Water.Improve )
m_Water.State = m_Water.State >= (int) WaterState.Strong ? (int) WaterState.Strong : m_Water.State + 1; m_Water.State = ( m_Water.State >= (int) WaterState.Strong ) ? (int) WaterState.Strong : m_Water.State + 1;
m_Water.Maintain = Utility.Random( (int) WaterState.Strong + 2 - m_Water.State, 2 ); m_Water.Maintain = Utility.Random( (int) WaterState.Strong + 2 - m_Water.State, 2 );
@ -649,7 +718,9 @@ namespace Server.Items
return false; return false;
} }
else else
{
from.SendLocalizedMessage( 1074512 ); // You put the gasping creature into your pack. from.SendLocalizedMessage( 1074512 ); // You put the gasping creature into your pack.
}
} }
if ( !fish.Dead ) if ( !fish.Dead )
@ -663,7 +734,9 @@ namespace Server.Items
return false; return false;
} }
else else
{
from.SendLocalizedMessage( 1074513 ); // You put the item into your pack. from.SendLocalizedMessage( 1074513 ); // You put the item into your pack.
}
} }
InvalidateProperties(); InvalidateProperties();
@ -672,32 +745,33 @@ namespace Server.Items
public virtual void ExamineAquarium( Mobile from ) public virtual void ExamineAquarium( Mobile from )
{ {
if ( !from.InRange( this, 2 ) ) if ( !from.InRange( GetWorldLocation(), 2 ) )
{ {
from.Say( 1019045 ); // I can't reach that. from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
return; return;
} }
BaseHouse house = BaseHouse.FindHouseAt( this );
from.CloseGump( typeof( AquariumGump ) ); from.CloseGump( typeof( AquariumGump ) );
from.SendGump( new AquariumGump( this, HasAccess( from ) ) );
if ( house != null && house.IsCoOwner( from ) )
from.SendGump( new AquariumGump( this, true ) );
else
from.SendGump( new AquariumGump( this, false ) );
from.PlaySound( 0x5A4 ); from.PlaySound( 0x5A4 );
} }
public virtual bool AddFish( BaseFish fish )
{
return AddFish( null, fish );
}
public virtual bool AddFish( Mobile from, BaseFish fish ) public virtual bool AddFish( Mobile from, BaseFish fish )
{ {
if ( fish == null ) if ( fish == null )
return false; return false;
if ( ( m_LiveCreatures == MaxLiveCreatures && !IsFull ) || fish.Dead ) if ( IsFull || m_LiveCreatures == MaxLiveCreatures || fish.Dead )
{ {
from.SendLocalizedMessage( 1073633 ); // The aquarium can not hold the creature. if ( from != null )
from.SendLocalizedMessage( 1073633 ); // The aquarium can not hold the creature.
return false; return false;
} }
@ -706,12 +780,18 @@ namespace Server.Items
m_LiveCreatures += 1; m_LiveCreatures += 1;
from.SendLocalizedMessage( 1073632, "#" + fish.LabelNumber ); // You add the following creature to your aquarium: ~1_FISH~ if ( from != null )
from.SendLocalizedMessage( 1073632, String.Format( "#{0}", fish.LabelNumber ) ); // You add the following creature to your aquarium: ~1_FISH~
InvalidateProperties(); InvalidateProperties();
return true; return true;
} }
public virtual bool AddDecoration( Item item )
{
return AddDecoration( null, item );
}
public virtual bool AddDecoration( Mobile from, Item item ) public virtual bool AddDecoration( Mobile from, Item item )
{ {
if ( item == null ) if ( item == null )
@ -719,22 +799,24 @@ namespace Server.Items
if ( IsFull ) if ( IsFull )
{ {
from.SendLocalizedMessage( 1073636 ); // The decoration will not fit in the aquarium. if ( from != null )
from.SendLocalizedMessage( 1073636 ); // The decoration will not fit in the aquarium.
return false; return false;
} }
if ( !Accepts( item ) ) if ( !Accepts( item ) )
{ {
from.SendLocalizedMessage( 1073822 ); // The aquarium can not hold that item. if ( from != null )
from.SendLocalizedMessage( 1073822 ); // The aquarium can not hold that item.
return false; return false;
} }
AddItem( item ); AddItem( item );
if ( item.LabelNumber != 0 ) if ( from != null )
from.SendLocalizedMessage( 1073635, "#" + item.LabelNumber ); // You add the following decoration to your aquarium: ~1_NAME~ from.SendLocalizedMessage( 1073635, ( item.LabelNumber != 0 ) ? String.Format( "#{0}", item.LabelNumber ) : item.Name ); // You add the following decoration to your aquarium: ~1_NAME~
else
from.SendLocalizedMessage( 1073635, item.Name ); // You add the following decoration to your aquarium: ~1_NAME~
InvalidateProperties(); InvalidateProperties();
return true; return true;
@ -744,7 +826,7 @@ namespace Server.Items
#region Static members #region Static members
public static FishBowl GetEmptyBowl( Mobile from ) public static FishBowl GetEmptyBowl( Mobile from )
{ {
if ( from.Backpack == null ) if ( from == null || from.Backpack == null )
return null; return null;
Item[] items = from.Backpack.FindItemsByType( typeof( FishBowl ) ); Item[] items = from.Backpack.FindItemsByType( typeof( FishBowl ) );
@ -769,7 +851,7 @@ namespace Server.Items
typeof( WaterloggedBoots ), typeof( WaterloggedBoots ),
typeof( CaptainBlackheartsFishingPole ), typeof( CaptainBlackheartsFishingPole ),
typeof( CraftysFishingHat ), typeof( CraftysFishingHat ),
typeof( AquariumFishingNet ), typeof( AquariumFishNet ),
typeof( AquariumMessage ), typeof( AquariumMessage ),
typeof( IslandStatue ), typeof( IslandStatue ),
typeof( Shell ), typeof( Shell ),
@ -808,7 +890,7 @@ namespace Server.Items
{ {
private Aquarium m_Aquarium; private Aquarium m_Aquarium;
public ExamineEntry( Aquarium aquarium ) : base( 6235, 2 ) public ExamineEntry( Aquarium aquarium ) : base( 6235, 2 ) // Examine Aquarium
{ {
m_Aquarium = aquarium; m_Aquarium = aquarium;
} }
@ -826,18 +908,17 @@ namespace Server.Items
{ {
private Aquarium m_Aquarium; private Aquarium m_Aquarium;
public CollectRewardEntry( Aquarium aquarium ) : base( 6237, 2 ) public CollectRewardEntry( Aquarium aquarium ) : base( 6237, 2 ) // Collect Reward
{ {
m_Aquarium = aquarium; m_Aquarium = aquarium;
} }
public override void OnClick() public override void OnClick()
{ {
if ( m_Aquarium.Deleted ) if ( m_Aquarium.Deleted || !m_Aquarium.HasAccess( Owner.From ) )
return; return;
m_Aquarium.GiveReward( Owner.From ); m_Aquarium.GiveReward( Owner.From );
m_Aquarium.InvalidateProperties();
} }
} }
@ -845,14 +926,14 @@ namespace Server.Items
{ {
private Aquarium m_Aquarium; private Aquarium m_Aquarium;
public ViewEventEntry( Aquarium aquarium ) : base( 6239, 2 ) public ViewEventEntry( Aquarium aquarium ) : base( 6239, 2 ) // View events
{ {
m_Aquarium = aquarium; m_Aquarium = aquarium;
} }
public override void OnClick() public override void OnClick()
{ {
if ( m_Aquarium.Deleted ) if ( m_Aquarium.Deleted || !m_Aquarium.HasAccess( Owner.From ) || m_Aquarium.Events.Count == 0 )
return; return;
Owner.From.SendLocalizedMessage( m_Aquarium.Events[ 0 ] ); Owner.From.SendLocalizedMessage( m_Aquarium.Events[ 0 ] );
@ -869,14 +950,14 @@ namespace Server.Items
{ {
private Aquarium m_Aquarium; private Aquarium m_Aquarium;
public CancelVacationMode( Aquarium aquarium ) : base( 6240, 2 ) public CancelVacationMode( Aquarium aquarium ) : base( 6240, 2 ) // Cancel vacation mode
{ {
m_Aquarium = aquarium; m_Aquarium = aquarium;
} }
public override void OnClick() public override void OnClick()
{ {
if ( m_Aquarium.Deleted ) if ( m_Aquarium.Deleted || !m_Aquarium.HasAccess( Owner.From ) )
return; return;
Owner.From.SendLocalizedMessage( 1074429 ); // Vacation mode has been cancelled. Owner.From.SendLocalizedMessage( 1074429 ); // Vacation mode has been cancelled.
@ -890,7 +971,7 @@ namespace Server.Items
{ {
private Aquarium m_Aquarium; private Aquarium m_Aquarium;
public GMAddFood( Aquarium aquarium ) : base( 6231, -1 ) public GMAddFood( Aquarium aquarium ) : base( 6231, -1 ) // GM Add Food
{ {
m_Aquarium = aquarium; m_Aquarium = aquarium;
} }
@ -909,7 +990,7 @@ namespace Server.Items
{ {
private Aquarium m_Aquarium; private Aquarium m_Aquarium;
public GMAddWater( Aquarium aquarium ) : base( 6232, -1 ) public GMAddWater( Aquarium aquarium ) : base( 6232, -1 ) // GM Add Water
{ {
m_Aquarium = aquarium; m_Aquarium = aquarium;
} }
@ -928,7 +1009,7 @@ namespace Server.Items
{ {
private Aquarium m_Aquarium; private Aquarium m_Aquarium;
public GMForceEvaluate( Aquarium aquarium ) : base( 6233, -1 ) public GMForceEvaluate( Aquarium aquarium ) : base( 6233, -1 ) // GM Force Evaluate
{ {
m_Aquarium = aquarium; m_Aquarium = aquarium;
} }
@ -939,7 +1020,6 @@ namespace Server.Items
return; return;
m_Aquarium.Evaluate(); m_Aquarium.Evaluate();
m_Aquarium.InvalidateProperties();
} }
} }
@ -947,7 +1027,7 @@ namespace Server.Items
{ {
private Aquarium m_Aquarium; private Aquarium m_Aquarium;
public GMOpen( Aquarium aquarium ) : base( 6234, -1 ) public GMOpen( Aquarium aquarium ) : base( 6234, -1 ) // GM Open Container
{ {
m_Aquarium = aquarium; m_Aquarium = aquarium;
} }
@ -965,7 +1045,7 @@ namespace Server.Items
{ {
private Aquarium m_Aquarium; private Aquarium m_Aquarium;
public GMFill( Aquarium aquarium ) : base( 6236, -1 ) public GMFill( Aquarium aquarium ) : base( 6236, -1 ) // GM Fill Food and Water
{ {
m_Aquarium = aquarium; m_Aquarium = aquarium;
} }
@ -985,7 +1065,7 @@ namespace Server.Items
public class AquariumEastDeed : BaseAddonContainerDeed public class AquariumEastDeed : BaseAddonContainerDeed
{ {
public override BaseAddonContainer Addon{ get{ return new Aquarium( 0x3060 ); } } public override BaseAddonContainer Addon{ get{ return new Aquarium( 0x3062 ); } }
public override int LabelNumber{ get{ return 1074501; } } // Large Aquarium (east) public override int LabelNumber{ get{ return 1074501; } } // Large Aquarium (east)
[Constructable] [Constructable]
@ -1014,7 +1094,7 @@ namespace Server.Items
public class AquariumNorthDeed : BaseAddonContainerDeed public class AquariumNorthDeed : BaseAddonContainerDeed
{ {
public override BaseAddonContainer Addon{ get{ return new Aquarium( 0x3062 ); } } public override BaseAddonContainer Addon{ get{ return new Aquarium( 0x3060 ); } }
public override int LabelNumber{ get{ return 1074497; } } // Large Aquarium (north) public override int LabelNumber{ get{ return 1074497; } } // Large Aquarium (north)
[Constructable] [Constructable]

View file

@ -6,27 +6,161 @@ using Server.Targeting;
namespace Server.Items namespace Server.Items
{ {
public class AquariumFishNet : SpecialFishingNet
{
public override int LabelNumber{ get{ return 1074463; } } // An aquarium fishing net
[Constructable]
public AquariumFishNet()
{
ItemID = 0xDC8;
if ( Hue == 0x8A0 )
Hue = 0x240;
}
protected override void AddNetProperties( ObjectPropertyList list )
{
}
// TODO
//public override bool RequireDeepWater { get { return false; } }
protected override void FinishEffect( Point3D p, Map map, Mobile from )
{
if ( Utility.RandomDouble() < 0.02 )
{
from.SendLocalizedMessage( 1074487 ); // The creatures are too quick for you!
}
else
{
BaseFish fish = GiveFish( from );
FishBowl bowl = Aquarium.GetEmptyBowl( from );
if ( bowl != null )
{
fish.StopTimer();
bowl.AddItem( fish );
from.SendLocalizedMessage( 1074489 ); // A live creature jumps into the fish bowl in your pack!
Delete();
return;
}
else
{
if ( from.PlaceInBackpack( fish ) )
{
from.PlaySound( 0x5A2 );
from.SendLocalizedMessage( 1074490 ); // A live creature flops around in your pack before running out of air.
fish.Kill();
Delete();
return;
}
else
{
fish.Delete();
from.SendLocalizedMessage( 1074488 ); // You could not hold the creature.
}
}
}
InUse = false;
Movable = true;
if ( !from.PlaceInBackpack( this ) )
{
if ( from.Map == null || from.Map == Map.Internal )
Delete();
else
MoveToWorld( from.Location, from.Map );
}
}
private BaseFish GiveFish( Mobile from )
{
double skill = from.Skills.Fishing.Value;
if ( ( skill / 100.0 ) >= Utility.RandomDouble() )
{
int max = (int) skill / 5;
if ( max > 20 )
max = 20;
switch ( Utility.Random( max ) )
{
case 0: return new MinocBlueFish();
case 1: return new Shrimp();
case 2: return new FandancerFish();
case 3: return new GoldenBroadtail();
case 4: return new RedDartFish();
case 5: return new AlbinoCourtesanFish();
case 6: return new MakotoCourtesanFish();
case 7: return new NujelmHoneyFish();
case 8: return new Jellyfish();
case 9: return new SpeckledCrab();
case 10: return new LongClawCrab();
case 11: return new AlbinoFrog();
case 12: return new KillerFrog();
case 13: return new VesperReefTiger();
case 14: return new PurpleFrog();
case 15: return new BritainCrownFish();
case 16: return new YellowFinBluebelly();
case 17: return new SpottedBuccaneer();
case 18: return new SpinedScratcherFish();
default: return new SmallMouthSuckerFin();
}
}
return new MinocBlueFish();
}
public AquariumFishNet( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
// Legacy code
public class AquariumFishingNet : Item public class AquariumFishingNet : Item
{ {
public override int LabelNumber{ get{ return 1074463; } } // An aquarium fishing net public override int LabelNumber{ get{ return 1074463; } } // An aquarium fishing net
private static int[] m_Hues = { 0x09B, 0x0CD, 0x0D3, 0x14D, 0x1DD, 0x1E9, 0x1F4, 0x373, 0x451, 0x47F, 0x489, 0x492, 0x4B5, 0x8AA }; public AquariumFishingNet()
private static int[] m_WaterTiles = { 0x00A8, 0x00AB, 0x0136, 0x0137 };
private Mobile m_Player;
[Constructable]
public AquariumFishingNet() : base( 0xDC8 )
{ {
Weight = 1.0;
Hue = ( 0.01 > Utility.RandomDouble() ) ? Utility.RandomList( m_Hues ) : 0x240;
} }
public AquariumFishingNet( Serial serial ) : base( serial ) public AquariumFishingNet( Serial serial ) : base( serial )
{ {
} }
private Item CreateReplacement()
{
Item result = new AquariumFishNet();
result.Hue = Hue;
result.LootType = LootType;
result.Movable = Movable;
result.Name = Name;
result.QuestItem = QuestItem;
result.Visible = Visible;
return result;
}
public override void OnDoubleClick( Mobile from ) public override void OnDoubleClick( Mobile from )
{ {
if ( !IsChildOf( from.Backpack ) ) if ( !IsChildOf( from.Backpack ) )
@ -35,197 +169,18 @@ namespace Server.Items
return; return;
} }
from.SendLocalizedMessage( 1010484 ); // Where do you wish to use the net? Item replacement = CreateReplacement();
from.BeginTarget( -1, true, TargetFlags.None, new TargetCallback( OnTarget ) );
}
public void OnTarget( Mobile from, object obj ) if ( !from.PlaceInBackpack( replacement ) )
{
m_Player = from;
if ( Deleted )
return;
IPoint3D p3D = obj as IPoint3D;
if ( p3D == null )
return;
Map map = from.Map;
if ( map == null || map == Map.Internal )
return;
int x = p3D.X, y = p3D.Y;
if ( !from.InRange( p3D, 6 ) )
{ {
from.SendLocalizedMessage( 500976 ); // You need to be closer to the water to fish! replacement.Delete();
} from.SendLocalizedMessage( 500720 ); // You don't have enough room in your backpack!
else if ( FullValidation( map, x, y ) )
{
Point3D p = new Point3D( x, y, map.GetAverageZ( x, y ) );
Movable = false;
MoveToWorld( p, map );
from.Animate( 12, 5, 1, true, false, 0 );
Timer.DelayCall( TimeSpan.FromSeconds( 1.5 ), TimeSpan.FromSeconds( 1.0 ), 20, new TimerStateCallback( DoEffect ), new object[]{ p, 0 } );
from.SendLocalizedMessage( 1010487 ); // You plunge the net into the sea...
} }
else else
{ {
from.SendLocalizedMessage( 1010485 ); // You can only use this net in deep water!
}
}
public static bool FullValidation( Map map, int x, int y )
{
bool valid = ValidateDeepWater( map, x, y );
for ( int j = 1, offset = 5; valid && j <= 5; ++j, offset += 5 )
{
if ( !ValidateDeepWater( map, x + offset, y + offset ) )
valid = false;
else if ( !ValidateDeepWater( map, x + offset, y - offset ) )
valid = false;
else if ( !ValidateDeepWater( map, x - offset, y + offset ) )
valid = false;
else if ( !ValidateDeepWater( map, x - offset, y - offset ) )
valid = false;
}
return valid;
}
private static bool ValidateDeepWater( Map map, int x, int y )
{
int tileID = map.Tiles.GetLandTile( x, y ).ID;
bool water = false;
for ( int i = 0; !water && i < m_WaterTiles.Length; i += 2 )
water = ( tileID >= m_WaterTiles[i] && tileID <= m_WaterTiles[i + 1] );
return water;
}
private void DoEffect( object state )
{
if ( Deleted )
return;
object[] states = (object[])state;
Point3D p = (Point3D)states[0];
int index = (int)states[1];
states[1] = ++index;
if ( index == 1 )
{
Effects.SendLocationEffect( p, Map, 0x352D, 16, 4 );
Effects.PlaySound( p, Map, 0x364 );
}
else if ( index <= 10 || index == 20 )
{
for ( int i = 0; i < 3; ++i )
{
int x, y;
switch ( Utility.Random( 8 ) )
{
default:
case 0: x = -1; y = -1; break;
case 1: x = -1; y = 0; break;
case 2: x = -1; y = +1; break;
case 3: x = 0; y = -1; break;
case 4: x = 0; y = +1; break;
case 5: x = +1; y = -1; break;
case 6: x = +1; y = 0; break;
case 7: x = +1; y = +1; break;
}
Effects.SendLocationEffect( new Point3D( p.X + x, p.Y + y, p.Z ), Map, 0x352D, 16, 4 );
}
Effects.PlaySound( p, Map, 0x364 );
if ( index == 20 )
FinishEffect( p );
else
this.Z -= 1;
}
}
private void FinishEffect( Point3D p )
{
BaseFish fish = GiveFish( m_Player.Skills.Fishing.Base / 100 );
if ( fish != null )
{
Item[] items = m_Player.Backpack.FindItemsByType( typeof( FishBowl ) );
foreach ( FishBowl bowl in items )
{
if ( !bowl.Deleted && bowl.Empty )
{
fish.StopTimer();
bowl.AddItem( fish );
bowl.InvalidateProperties();
m_Player.SendLocalizedMessage( 1074489 ); // A live creature jumps into the fish bowl in your pack!
Delete();
return;
}
}
if ( !m_Player.PlaceInBackpack( fish ) )
{
m_Player.SendLocalizedMessage( 500720 ); // You don't have enough room in your backpack!
fish.MoveToWorld( m_Player.Location, m_Player.Map );
}
else
m_Player.SendLocalizedMessage( 1074490 ); // A live creature flops around in your pack before running out of air.
fish.Kill();
Delete(); Delete();
from.Use( replacement );
} }
else
{
Movable = true;
if ( !m_Player.PlaceInBackpack( this ) )
MoveToWorld( m_Player.Location, m_Player.Map );
m_Player.SendLocalizedMessage( 1074487 ); // The creatures are too quick for you!
}
}
public BaseFish GiveFish( double skill )
{
if ( 0.004 * skill > Utility.RandomDouble() ) return new Shrimp();
if ( 0.008 * skill > Utility.RandomDouble() ) return new SmallMouthSuckerFin();
if ( 0.008 * skill > Utility.RandomDouble() ) return new SpinedScratcherFish();
if ( 0.022 * skill > Utility.RandomDouble() ) return new SpottedBuccaneer();
if ( 0.022 * skill > Utility.RandomDouble() ) return new YellowFinBluebelly();
if ( 0.030 * skill > Utility.RandomDouble() ) return new BritainCrownFish();
if ( 0.030 * skill > Utility.RandomDouble() ) return new PurpleFrog();
if ( 0.032 * skill > Utility.RandomDouble() ) return new VesperReefTiger();
if ( 0.038 * skill > Utility.RandomDouble() ) return new KillerFrog();
if ( 0.040 * skill > Utility.RandomDouble() ) return new AlbinoFrog();
if ( 0.046 * skill > Utility.RandomDouble() ) return new LongClawCrab();
if ( 0.052 * skill > Utility.RandomDouble() ) return new SpeckledCrab();
if ( 0.058 * skill > Utility.RandomDouble() ) return new Jellyfish();
if ( 0.062 * skill > Utility.RandomDouble() ) return new NujelmHoneyFish();
if ( 0.064 * skill > Utility.RandomDouble() ) return new MakotoCourtesanFish();
if ( 0.076 * skill > Utility.RandomDouble() ) return new AlbinoCourtesanFish();
if ( 0.082 * skill > Utility.RandomDouble() ) return new RedDartFish();
if ( 0.088 * skill > Utility.RandomDouble() ) return new MinocBlueFish();
if ( 0.090 * skill > Utility.RandomDouble() ) return new GoldenBroadtail();
if ( 0.148 * skill > Utility.RandomDouble() ) return new FandancerFish();
return null;
} }
public override void Serialize( GenericWriter writer ) public override void Serialize( GenericWriter writer )

View file

@ -2,18 +2,17 @@ using System;
using System.Collections; using System.Collections;
using Server.Gumps; using Server.Gumps;
using Server.Items; using Server.Items;
using Server.Network;
namespace Server.Items namespace Server.Items
{ {
public class AquariumGump : Gump public class AquariumGump : Gump
{ {
private Aquarium m_Aquarium; private Aquarium m_Aquarium;
private bool m_Edit;
public AquariumGump( Aquarium aquarium, bool edit ) : base( 100, 100 ) public AquariumGump( Aquarium aquarium, bool edit ) : base( 100, 100 )
{ {
m_Aquarium = aquarium; m_Aquarium = aquarium;
m_Edit = edit;
Closable = true; Closable = true;
Disposable = true; Disposable = true;
@ -28,10 +27,10 @@ namespace Server.Items
return; return;
for ( int i = 1; i <= m_Aquarium.Items.Count; i ++ ) for ( int i = 1; i <= m_Aquarium.Items.Count; i ++ )
DisplayPage( i ); DisplayPage( i, edit );
} }
public virtual void DisplayPage( int page ) public virtual void DisplayPage( int page, bool edit )
{ {
AddPage( page ); AddPage( page );
@ -43,35 +42,18 @@ namespace Server.Items
// item details // item details
if ( item is BaseFish ) if ( item is BaseFish )
{ AddHtmlLocalized( 20, 239, 315, 20, ( (BaseFish) item ).GetDescription(), 0xFFFFFF, false, false );
BaseFish fish = (BaseFish) item;
if ( !fish.Dead && fish.ItemID > 0x3B0F )
AddHtmlLocalized( 20, 239, 315, 20, 1074422, 0xFFFFFF, false, false ); // A very unusual live aquarium creature
else if ( !fish.Dead && fish.Hue > 0 )
AddHtmlLocalized( 20, 239, 315, 20, 1074423, 0xFFFFFF, false, false ); // A live aquarium creature of unusual color
else if ( !fish.Dead )
AddHtmlLocalized( 20, 239, 315, 20, 1073622, 0xFFFFFF, false, false ); // A live aquarium creature
else if ( fish.Dead && fish.ItemID > 0x3B0F )
AddHtmlLocalized( 20, 239, 315, 20, 1074424, 0xFFFFFF, false, false ); // A very unusual dead aquarium creature
else if ( fish.Dead && fish.Hue > 0 )
AddHtmlLocalized( 20, 239, 315, 20, 1074425, 0xFFFFFF, false, false ); // A dead aquarium creature of unusual color
else if ( fish.Dead )
AddHtmlLocalized( 20, 239, 315, 20, 1073623, 0xFFFFFF, false, false ); // A dead aquarium creature
}
else else
{
AddHtmlLocalized( 20, 239, 315, 20, 1073634, 0xFFFFFF, false, false ); // An aquarium decoration AddHtmlLocalized( 20, 239, 315, 20, 1073634, 0xFFFFFF, false, false ); // An aquarium decoration
}
// item image // item image
AddItem( 150, 80, item.ItemID, item.Hue ); AddItem( 150, 80, item.ItemID, item.Hue );
// item number / all items // item number / all items
AddHtml( 20, 195, 250, 20, String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", 0xFFFFFF, page + "/" + ( m_Aquarium.Items.Count ) ), false, false ); AddHtml( 20, 195, 250, 20, String.Format( "<BASEFONT COLOR=#FFFFFF>{0}/{1}</BASEFONT>", page, m_Aquarium.Items.Count ), false, false );
// remove item // remove item
if ( m_Edit ) if ( edit )
{ {
AddBackground( 230, 195, 100, 26, 0x13BE ); AddBackground( 230, 195, 100, 26, 0x13BE );
AddButton( 235, 200, 0x845, 0x846, page, GumpButtonType.Reply, 0 ); AddButton( 235, 200, 0x845, 0x846, page, GumpButtonType.Reply, 0 );
@ -93,16 +75,18 @@ namespace Server.Items
} }
} }
public override void OnResponse( Server.Network.NetState sender, RelayInfo info ) public override void OnResponse( NetState sender, RelayInfo info )
{ {
if ( m_Aquarium == null || m_Aquarium.Deleted ) if ( m_Aquarium == null || m_Aquarium.Deleted )
return; return;
if ( info.ButtonID > 0 && info.ButtonID <= m_Aquarium.Items.Count && m_Edit ) bool edit = m_Aquarium.HasAccess( sender.Mobile );
if ( info.ButtonID > 0 && info.ButtonID <= m_Aquarium.Items.Count && edit )
m_Aquarium.RemoveItem( sender.Mobile, info.ButtonID - 1 ); m_Aquarium.RemoveItem( sender.Mobile, info.ButtonID - 1 );
if ( info.ButtonID > 0 ) if ( info.ButtonID > 0 )
sender.Mobile.SendGump( new AquariumGump( m_Aquarium, m_Edit ) ); sender.Mobile.SendGump( new AquariumGump( m_Aquarium, edit ) );
} }
} }
} }

View file

@ -9,7 +9,7 @@ namespace Server.Items
Dying, Dying,
Unhealthy, Unhealthy,
Healthy, Healthy,
Strong, Strong
} }
public enum FoodState public enum FoodState
@ -18,7 +18,7 @@ namespace Server.Items
Starving, Starving,
Hungry, Hungry,
Full, Full,
Overfed, Overfed
} }
[PropertyObject] [PropertyObject]
@ -33,7 +33,16 @@ namespace Server.Items
public int State public int State
{ {
get{ return m_State; } get{ return m_State; }
set{ m_State = value; } set
{
m_State = value;
if ( m_State < 0 )
m_State = 0;
if ( m_State > 4 )
m_State = 4;
}
} }
[CommandProperty( AccessLevel.GameMaster )] [CommandProperty( AccessLevel.GameMaster )]

View file

@ -6,12 +6,14 @@ namespace Server.Items
{ {
public class BaseFish : Item public class BaseFish : Item
{ {
private static readonly TimeSpan DeathDelay = TimeSpan.FromMinutes( 5 );
private Timer m_Timer; private Timer m_Timer;
[CommandProperty( AccessLevel.GameMaster )] [CommandProperty( AccessLevel.GameMaster )]
public bool Dead public bool Dead
{ {
get{ return ItemID == 0x3B0C; } get{ return ( ItemID == 0x3B0C ); }
} }
[Constructable] [Constructable]
@ -29,7 +31,9 @@ namespace Server.Items
if ( m_Timer != null ) if ( m_Timer != null )
m_Timer.Stop(); m_Timer.Stop();
m_Timer = Timer.DelayCall( TimeSpan.FromMinutes( 5 ), new TimerCallback( Kill ) ); m_Timer = Timer.DelayCall( DeathDelay, new TimerCallback( Kill ) );
InvalidateProperties();
} }
public virtual void StopTimer() public virtual void StopTimer()
@ -38,6 +42,13 @@ namespace Server.Items
m_Timer.Stop(); m_Timer.Stop();
m_Timer = null; m_Timer = null;
InvalidateProperties();
}
public override void OnDelete()
{
StopTimer();
} }
public virtual void Kill() public virtual void Kill()
@ -48,37 +59,22 @@ namespace Server.Items
InvalidateProperties(); InvalidateProperties();
} }
public override bool DropToItem( Mobile from, Item target, Point3D p ) public int GetDescription()
{ {
if ( target is FishBowl || target is Aquarium ) // TODO: This will never return "very unusual dead aquarium creature" due to the way it is killed
{ if ( ItemID > 0x3B0F )
if ( base.DropToItem( from, target, p ) ) return Dead ? 1074424 : 1074422; // A very unusual [dead/live] aquarium creature
{ else if ( Hue != 0 )
StopTimer(); return Dead ? 1074425 : 1074423; // A [dead/live] aquarium creature of unusual color
return true; return Dead ? 1073623 : 1073622; // A [dead/live] aquarium creature
}
}
return base.DropToItem( from, target, p );
} }
public override void GetProperties( ObjectPropertyList list ) public override void GetProperties( ObjectPropertyList list )
{ {
base.GetProperties( list ); base.GetProperties( list );
if ( !Dead && ItemID > 0x3B0F ) list.Add( GetDescription() );
list.Add( 1074422 ); // A very unusual live aquarium creature
else if ( !Dead && Hue > 0 )
list.Add( 1074423 ); // A live aquarium creature of unusual color
else if ( !Dead )
list.Add( 1073622 ); // A live aquarium creature
else if ( Dead && ItemID > 0x3B0F )
list.Add( 1074424 ); // A very unusual dead aquarium creature
else if ( Dead && Hue > 0 )
list.Add( 1074425 ); // A dead aquarium creature of unusual color
else if ( Dead )
list.Add( 1073623 ); // A dead aquarium creature
if ( !Dead && m_Timer != null ) if ( !Dead && m_Timer != null )
list.Add( 1074507 ); // Gasping for air list.Add( 1074507 ); // Gasping for air

View file

@ -6,15 +6,17 @@ using Server.ContextMenus;
namespace Server.Items namespace Server.Items
{ {
public class FishBowl : Container public class FishBowl : BaseContainer
{ {
public override int LabelNumber{ get{ return 1074499; } } // A fish bowl public override int LabelNumber{ get{ return 1074499; } } // A fish bowl
[CommandProperty( AccessLevel.GameMaster )]
public bool Empty public bool Empty
{ {
get{ return Items.Count == 0; } get{ return ( Items.Count == 0 ); }
} }
[CommandProperty( AccessLevel.GameMaster )]
public BaseFish Fish public BaseFish Fish
{ {
get get
@ -29,12 +31,13 @@ namespace Server.Items
} }
} }
public override double DefaultWeight { get { return 2.0; } }
[Constructable] [Constructable]
public FishBowl() : base( 0x241C ) public FishBowl() : base( 0x241C )
{ {
Hue = 0x47E; Hue = 0x47E;
MaxItems = 1; MaxItems = 1;
Weight = 1;
} }
public FishBowl( Serial serial ) : base( serial ) public FishBowl( Serial serial ) : base( serial )
@ -47,36 +50,47 @@ namespace Server.Items
public override bool OnDragDrop( Mobile from, Item dropped ) public override bool OnDragDrop( Mobile from, Item dropped )
{ {
if ( dropped is BaseFish && Empty ) if ( !IsAccessibleTo( from ) )
{ {
((BaseFish) dropped).StopTimer(); from.SendLocalizedMessage( 502436 ); // That is not accessible.
InvalidateProperties(); return false;
return base.OnDragDrop( from, dropped );
} }
else
if ( !( dropped is BaseFish ) )
{ {
from.SendLocalizedMessage( 1074836 ); // The container can not hold that type of object. from.SendLocalizedMessage( 1074836 ); // The container can not hold that type of object.
return false; return false;
} }
if ( base.OnDragDrop( from, dropped ) )
{
((BaseFish) dropped).StopTimer();
InvalidateProperties();
return true;
}
return false;
} }
public override void GetProperties( ObjectPropertyList list ) public override void AddNameProperties( ObjectPropertyList list )
{ {
list.Add( 1074499 ); // A fish bowl base.AddNameProperties( list );
list.Add( 1072788, Weight.ToString() ); // Weight: ~1_WEIGHT~ stone
if ( !Empty ) if ( !Empty )
list.Add( 1074494, "#" + Fish.LabelNumber ); // Contains: ~1_CREATURE~ {
BaseFish fish = Fish;
list.Add( 1073841, "{0}\t{1}\t{2}", Items.Count, MaxItems, GetTotal( TotalType.Weight ) ); // Contents: ~1_COUNT~/~2_MAXCOUNT~ items, ~3_WEIGHT~ stones if ( fish != null )
list.Add( 1074494, "#{0}", fish.LabelNumber ); // Contains: ~1_CREATURE~
}
} }
public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list ) public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
{ {
base.GetContextMenuEntries( from, list ); base.GetContextMenuEntries( from, list );
if ( !Empty ) if ( !Empty && IsAccessibleTo( from ) )
list.Add( new RemoveCreature( this ) ); list.Add( new RemoveCreature( this ) );
} }
@ -84,7 +98,7 @@ namespace Server.Items
{ {
base.Serialize( writer ); base.Serialize( writer );
writer.Write( (int) 0 ); // version writer.Write( (int) 1 ); // version
} }
public override void Deserialize( GenericReader reader ) public override void Deserialize( GenericReader reader )
@ -92,28 +106,37 @@ namespace Server.Items
base.Deserialize( reader ); base.Deserialize( reader );
int version = reader.ReadInt(); int version = reader.ReadInt();
if ( version == 0 )
Weight = DefaultWeight;
} }
private class RemoveCreature : ContextMenuEntry private class RemoveCreature : ContextMenuEntry
{ {
private FishBowl m_Bowl; private FishBowl m_Bowl;
public RemoveCreature( FishBowl bowl ) : base( 6242, 0 ) // Remove creature public RemoveCreature( FishBowl bowl ) : base( 6242, 3 ) // Remove creature
{ {
m_Bowl = bowl; m_Bowl = bowl;
} }
public override void OnClick() public override void OnClick()
{ {
if ( m_Bowl == null || m_Bowl.Deleted ) if ( m_Bowl == null || m_Bowl.Deleted || !m_Bowl.IsAccessibleTo( Owner.From ) )
return; return;
BaseFish fish = m_Bowl.Fish; BaseFish fish = m_Bowl.Fish;
if ( fish != null ) if ( fish != null )
{ {
if ( !Owner.From.PlaceInBackpack( fish ) ) if ( fish.IsLockedDown )
{
Owner.From.SendLocalizedMessage( 1010449 ); // You may not use this object while it is locked down.
}
else if ( !Owner.From.PlaceInBackpack( fish ) )
{
Owner.From.SendLocalizedMessage( 1074496 ); // There is no room in your pack for the creature. Owner.From.SendLocalizedMessage( 1074496 ); // There is no room in your pack for the creature.
}
else else
{ {
Owner.From.SendLocalizedMessage( 1074495 ); // The creature has been removed from the fish bowl. Owner.From.SendLocalizedMessage( 1074495 ); // The creature has been removed from the fish bowl.

View file

@ -17,9 +17,9 @@ namespace Server.Items
{ {
} }
public override void GetProperties( ObjectPropertyList list ) public override void AddNameProperties( ObjectPropertyList list )
{ {
base.GetProperties( list ); base.AddNameProperties( list );
list.Add( 1073634 ); // An aquarium decoration list.Add( 1073634 ); // An aquarium decoration
} }

View file

@ -17,9 +17,9 @@ namespace Server.Items
{ {
} }
public override void GetProperties( ObjectPropertyList list ) public override void AddNameProperties( ObjectPropertyList list )
{ {
base.GetProperties( list ); base.AddNameProperties( list );
list.Add( 1073634 ); // An aquarium decoration list.Add( 1073634 ); // An aquarium decoration
} }

View file

@ -8,6 +8,15 @@ namespace Server.Items
{ {
public override int LabelNumber{ get{ return 1074572; } } // Crafty's Fishing Hat public override int LabelNumber{ get{ return 1074572; } } // Crafty's Fishing Hat
public override int BasePhysicalResistance{ get{ return 0; } }
public override int BaseFireResistance{ get{ return 5; } }
public override int BaseColdResistance{ get{ return 9; } }
public override int BasePoisonResistance{ get{ return 5; } }
public override int BaseEnergyResistance{ get{ return 5; } }
public override int InitMinHits{ get{ return 20; } }
public override int InitMaxHits{ get{ return 30; } }
[Constructable] [Constructable]
public CraftysFishingHat() : base( 0x1713 ) public CraftysFishingHat() : base( 0x1713 )
{ {
@ -17,9 +26,9 @@ namespace Server.Items
{ {
} }
public override void GetProperties( ObjectPropertyList list ) public override void AddNameProperties( ObjectPropertyList list )
{ {
base.GetProperties( list ); base.AddNameProperties( list );
list.Add( 1073634 ); // An aquarium decoration list.Add( 1073634 ); // An aquarium decoration
} }

View file

@ -6,20 +6,20 @@ namespace Server.Items
public class FishBones : Item public class FishBones : Item
{ {
public override int LabelNumber{ get{ return 1074601; } } // Fish bones public override int LabelNumber{ get{ return 1074601; } } // Fish bones
public override double DefaultWeight{ get{ return 1.0; } }
[Constructable] [Constructable]
public FishBones() : base( 0x3B0C ) public FishBones() : base( 0x3B0C )
{ {
Weight = 1;
} }
public FishBones( Serial serial ) : base( serial ) public FishBones( Serial serial ) : base( serial )
{ {
} }
public override void GetProperties( ObjectPropertyList list ) public override void AddNameProperties( ObjectPropertyList list )
{ {
base.GetProperties( list ); base.AddNameProperties( list );
list.Add( 1073634 ); // An aquarium decoration list.Add( 1073634 ); // An aquarium decoration
} }

View file

@ -7,20 +7,20 @@ namespace Server.Items
public class IslandStatue : Item public class IslandStatue : Item
{ {
public override int LabelNumber{ get{ return 1074600; } } // An island statue public override int LabelNumber{ get{ return 1074600; } } // An island statue
public override double DefaultWeight{ get{ return 1.0; } }
[Constructable] [Constructable]
public IslandStatue() : base( 0x3B0F ) public IslandStatue() : base( 0x3B0F )
{ {
Weight = 1;
} }
public IslandStatue( Serial serial ) : base( serial ) public IslandStatue( Serial serial ) : base( serial )
{ {
} }
public override void GetProperties( ObjectPropertyList list ) public override void AddNameProperties( ObjectPropertyList list )
{ {
base.GetProperties( list ); base.AddNameProperties( list );
list.Add( 1073634 ); // An aquarium decoration list.Add( 1073634 ); // An aquarium decoration
} }

View file

@ -7,20 +7,20 @@ namespace Server.Items
public class Shell : Item public class Shell : Item
{ {
public override int LabelNumber{ get{ return 1074598; } } // A shell public override int LabelNumber{ get{ return 1074598; } } // A shell
public override double DefaultWeight{ get{ return 1.0; } }
[Constructable] [Constructable]
public Shell() : base( Utility.RandomList( 0x3B12, 0x3B13 ) ) public Shell() : base( Utility.RandomList( 0x3B12, 0x3B13 ) )
{ {
Weight = 1;
} }
public Shell( Serial serial ) : base( serial ) public Shell( Serial serial ) : base( serial )
{ {
} }
public override void GetProperties( ObjectPropertyList list ) public override void AddNameProperties( ObjectPropertyList list )
{ {
base.GetProperties( list ); base.AddNameProperties( list );
list.Add( 1073634 ); // An aquarium decoration list.Add( 1073634 ); // An aquarium decoration
} }

View file

@ -8,20 +8,20 @@ namespace Server.Items
public class ToyBoat : Item public class ToyBoat : Item
{ {
public override int LabelNumber{ get{ return 1074363; } } // A toy boat public override int LabelNumber{ get{ return 1074363; } } // A toy boat
public override double DefaultWeight{ get{ return 1.0; } }
[Constructable] [Constructable]
public ToyBoat() : base( 0x14F3 ) public ToyBoat() : base( 0x14F4 )
{ {
Weight = 1;
} }
public ToyBoat( Serial serial ) : base( serial ) public ToyBoat( Serial serial ) : base( serial )
{ {
} }
public override void GetProperties( ObjectPropertyList list ) public override void AddNameProperties( ObjectPropertyList list )
{ {
base.GetProperties( list ); base.AddNameProperties( list );
list.Add( 1073634 ); // An aquarium decoration list.Add( 1073634 ); // An aquarium decoration
} }

View file

@ -28,9 +28,9 @@ namespace Server.Items
{ {
} }
public override void GetProperties( ObjectPropertyList list ) public override void AddNameProperties( ObjectPropertyList list )
{ {
base.GetProperties( list ); base.AddNameProperties( list );
list.Add( 1073634 ); // An aquarium decoration list.Add( 1073634 ); // An aquarium decoration
} }

View file

@ -6,23 +6,31 @@ namespace Server.Items
{ {
public class VacationWafer : Item public class VacationWafer : Item
{ {
public const int VacationDays = 7;
public override int LabelNumber{ get{ return 1074431; } } // An aquarium flake sphere public override int LabelNumber{ get{ return 1074431; } } // An aquarium flake sphere
[Constructable] [Constructable]
public VacationWafer() : base( 0x971 ) public VacationWafer() : base( 0x973 )
{ {
} }
public VacationWafer( Serial serial ) : base( serial ) public VacationWafer( Serial serial ) : base( serial )
{ {
}
public override void AddNameProperties( ObjectPropertyList list )
{
base.AddNameProperties( list );
list.Add( 1074432, VacationDays.ToString() ); // Vacation days: ~1_DAYS~
} }
public override void Serialize( GenericWriter writer ) public override void Serialize( GenericWriter writer )
{ {
base.Serialize( writer ); base.Serialize( writer );
writer.Write( (int) 0 ); // version writer.Write( (int) 1 ); // version
} }
public override void Deserialize( GenericReader reader ) public override void Deserialize( GenericReader reader )
@ -30,6 +38,9 @@ namespace Server.Items
base.Deserialize( reader ); base.Deserialize( reader );
int version = reader.ReadInt(); int version = reader.ReadInt();
if ( version < 1 && ItemID == 0x971 )
ItemID = 0x973;
} }
} }
} }

View file

@ -11,6 +11,13 @@ namespace Server.Items
private bool m_InUse; private bool m_InUse;
[CommandProperty( AccessLevel.GameMaster )]
public bool InUse
{
get{ return m_InUse; }
set{ m_InUse = value; }
}
[Constructable] [Constructable]
public SpecialFishingNet() : base( 0x0DCA ) public SpecialFishingNet() : base( 0x0DCA )
{ {
@ -48,6 +55,11 @@ namespace Server.Items
{ {
base.GetProperties( list ); base.GetProperties( list );
AddNetProperties( list );
}
protected virtual void AddNetProperties( ObjectPropertyList list )
{
// as if the name wasn't enough.. // as if the name wasn't enough..
list.Add( 1017410 ); // Special Fishing Net list.Add( 1017410 ); // Special Fishing Net
} }
@ -100,6 +112,9 @@ namespace Server.Items
} }
} }
// TODO
//public virtual bool RequireDeepWater{ get{ return true; } }
public void OnTarget( Mobile from, object obj ) public void OnTarget( Mobile from, object obj )
{ {
if ( Deleted || m_InUse ) if ( Deleted || m_InUse )
@ -125,8 +140,11 @@ namespace Server.Items
{ {
Point3D p = new Point3D( x, y, map.GetAverageZ( x, y ) ); Point3D p = new Point3D( x, y, map.GetAverageZ( x, y ) );
for ( int i = 1; i < Amount; ++i ) // these were stackable before, doh if ( GetType() == typeof( SpecialFishingNet ) )
from.AddToBackpack( new SpecialFishingNet() ); {
for ( int i = 1; i < Amount; ++i ) // these were stackable before, doh
from.AddToBackpack( new SpecialFishingNet() );
}
m_InUse = true; m_InUse = true;
Movable = false; Movable = false;
@ -308,6 +326,10 @@ namespace Server.Items
Hue = 0x481; Hue = 0x481;
} }
protected override void AddNetProperties( ObjectPropertyList list )
{
}
protected override int GetSpawnCount() protected override int GetSpawnCount()
{ {
return base.GetSpawnCount() + 4; return base.GetSpawnCount() + 4;

View file

@ -30,7 +30,7 @@ namespace Server.Mobiles
Add( new GenericBuyInfo( typeof( FishingPole ), 15, 20, 0xDC0, 0 ) ); Add( new GenericBuyInfo( typeof( FishingPole ), 15, 20, 0xDC0, 0 ) );
#region Mondain's Legacy #region Mondain's Legacy
Add( new GenericBuyInfo( typeof( AquariumFishingNet ), 250, 20, 0xDC8, 0x240 ) ); Add( new GenericBuyInfo( typeof( AquariumFishNet ), 250, 20, 0xDC8, 0x240 ) );
Add( new GenericBuyInfo( typeof( AquariumFood ), 62, 20, 0xEFC, 0 ) ); Add( new GenericBuyInfo( typeof( AquariumFood ), 62, 20, 0xEFC, 0 ) );
Add( new GenericBuyInfo( typeof( FishBowl ), 6312, 20, 0x241C, 0x482 ) ); Add( new GenericBuyInfo( typeof( FishBowl ), 6312, 20, 0x241C, 0x482 ) );
Add( new GenericBuyInfo( typeof( VacationWafer ), 67, 20, 0x971, 0 ) ); Add( new GenericBuyInfo( typeof( VacationWafer ), 67, 20, 0x971, 0 ) );