Fixes code according to modern code style. Fixes a few expression bugs.

This commit is contained in:
Kamron Batman 2018-09-15 09:58:51 -07:00
parent 89eea25e5f
commit 970fd563b2
3324 changed files with 441118 additions and 433755 deletions

View file

@ -3,119 +3,119 @@ using Server.Network;
namespace Server.Engines.Plants
{
public class EmptyTheBowlGump : Gump
{
private PlantItem m_Plant;
public class EmptyTheBowlGump : Gump
{
private PlantItem m_Plant;
public EmptyTheBowlGump( PlantItem plant ) : base( 20, 20 )
{
m_Plant = plant;
public EmptyTheBowlGump(PlantItem plant) : base(20, 20)
{
m_Plant = plant;
DrawBackground();
DrawBackground();
AddLabel( 90, 70, 0x44, "Empty the bowl?" );
AddLabel(90, 70, 0x44, "Empty the bowl?");
DrawPicture();
DrawPicture();
AddButton( 98, 150, 0x47E, 0x480, 1, GumpButtonType.Reply, 0 ); // Cancel
AddButton(98, 150, 0x47E, 0x480, 1, GumpButtonType.Reply, 0); // Cancel
AddButton( 138, 151, 0xD2, 0xD2, 2, GumpButtonType.Reply, 0 ); // Help
AddLabel( 143, 151, 0x835, "?" );
AddButton(138, 151, 0xD2, 0xD2, 2, GumpButtonType.Reply, 0); // Help
AddLabel(143, 151, 0x835, "?");
AddButton( 168, 150, 0x481, 0x483, 3, GumpButtonType.Reply, 0 ); // Ok
}
AddButton(168, 150, 0x481, 0x483, 3, GumpButtonType.Reply, 0); // Ok
}
private void DrawBackground()
{
AddBackground( 50, 50, 200, 150, 0xE10 );
private void DrawBackground()
{
AddBackground(50, 50, 200, 150, 0xE10);
AddItem( 45, 45, 0xCEF );
AddItem( 45, 118, 0xCF0 );
AddItem(45, 45, 0xCEF);
AddItem(45, 118, 0xCF0);
AddItem( 211, 45, 0xCEB );
AddItem( 211, 118, 0xCEC );
}
AddItem(211, 45, 0xCEB);
AddItem(211, 118, 0xCEC);
}
private void DrawPicture()
{
AddItem( 90, 100, 0x1602 );
AddImage( 140, 102, 0x15E1 );
AddItem( 160, 100, 0x15FD );
private void DrawPicture()
{
AddItem(90, 100, 0x1602);
AddImage(140, 102, 0x15E1);
AddItem(160, 100, 0x15FD);
if ( m_Plant.PlantStatus != PlantStatus.BowlOfDirt && m_Plant.PlantStatus < PlantStatus.Plant )
AddItem( 156, 130, 0xDCF ); // Seed
}
if (m_Plant.PlantStatus != PlantStatus.BowlOfDirt && m_Plant.PlantStatus < PlantStatus.Plant)
AddItem(156, 130, 0xDCF); // Seed
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
public override void OnResponse(NetState sender, RelayInfo info)
{
Mobile from = sender.Mobile;
if ( info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant )
return;
if ( info.ButtonID == 3 && !from.InRange( m_Plant.GetWorldLocation(), 3 ) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3E9, 500446 ); // That is too far away.
return;
}
if (info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant)
return;
if ( !m_Plant.IsUsableBy( from ) )
{
m_Plant.LabelTo( from, 1061856 ); // You must have the item in your backpack or locked down in order to use it.
return;
}
if (info.ButtonID == 3 && !from.InRange(m_Plant.GetWorldLocation(), 3))
{
from.LocalOverheadMessage(MessageType.Regular, 0x3E9, 500446); // That is too far away.
return;
}
switch ( info.ButtonID )
{
case 1: // Cancel
{
from.SendGump( new MainPlantGump( m_Plant ) );
if (!m_Plant.IsUsableBy(from))
{
m_Plant.LabelTo(from, 1061856); // You must have the item in your backpack or locked down in order to use it.
return;
}
break;
}
case 2: // Help
{
from.Send( new DisplayHelpTopic( 71, true ) ); // EMPTYING THE BOWL
switch (info.ButtonID)
{
case 1: // Cancel
{
from.SendGump(new MainPlantGump(m_Plant));
from.SendGump( new EmptyTheBowlGump( m_Plant ) );
break;
}
case 2: // Help
{
from.Send(new DisplayHelpTopic(71, true)); // EMPTYING THE BOWL
break;
}
case 3: // Ok
{
PlantBowl bowl = new PlantBowl();
from.SendGump(new EmptyTheBowlGump(m_Plant));
if ( !from.PlaceInBackpack( bowl ) )
{
bowl.Delete();
break;
}
case 3: // Ok
{
PlantBowl bowl = new PlantBowl();
m_Plant.LabelTo( from, 1053047 ); // You cannot empty a bowl with a full pack!
from.SendGump( new MainPlantGump( m_Plant ) );
if (!from.PlaceInBackpack(bowl))
{
bowl.Delete();
break;
}
m_Plant.LabelTo(from, 1053047); // You cannot empty a bowl with a full pack!
from.SendGump(new MainPlantGump(m_Plant));
if ( m_Plant.PlantStatus != PlantStatus.BowlOfDirt && m_Plant.PlantStatus < PlantStatus.Plant )
{
Seed seed = new Seed( m_Plant.PlantType, m_Plant.PlantHue, m_Plant.ShowType );
break;
}
if ( !from.PlaceInBackpack( seed ) )
{
bowl.Delete();
seed.Delete();
if (m_Plant.PlantStatus != PlantStatus.BowlOfDirt && m_Plant.PlantStatus < PlantStatus.Plant)
{
Seed seed = new Seed(m_Plant.PlantType, m_Plant.PlantHue, m_Plant.ShowType);
m_Plant.LabelTo( from, 1053047 ); // You cannot empty a bowl with a full pack!
from.SendGump( new MainPlantGump( m_Plant ) );
if (!from.PlaceInBackpack(seed))
{
bowl.Delete();
seed.Delete();
break;
}
}
m_Plant.LabelTo(from, 1053047); // You cannot empty a bowl with a full pack!
from.SendGump(new MainPlantGump(m_Plant));
m_Plant.Delete();
break;
}
}
break;
}
}
}
}
m_Plant.Delete();
break;
}
}
}
}
}

View file

@ -1,417 +1,436 @@
using System;
using Server.Items;
using Server.Gumps;
using Server.Items;
using Server.Network;
namespace Server.Engines.Plants
{
public class MainPlantGump : Gump
{
private PlantItem m_Plant;
public MainPlantGump( PlantItem plant ) : base( 20, 20 )
{
m_Plant = plant;
DrawBackground();
DrawPlant();
AddButton( 71, 67, 0xD4, 0xD4, 1, GumpButtonType.Reply, 0 ); // Reproduction menu
AddItem( 59, 68, 0xD08 );
PlantSystem system = plant.PlantSystem;
AddButton( 71, 91, 0xD4, 0xD4, 2, GumpButtonType.Reply, 0 ); // Infestation
AddItem( 8, 96, 0x372 );
AddPlus( 95, 92, system.Infestation );
AddButton( 71, 115, 0xD4, 0xD4, 3, GumpButtonType.Reply, 0 ); // Fungus
AddItem( 58, 115, 0xD16 );
AddPlus( 95, 116, system.Fungus );
AddButton( 71, 139, 0xD4, 0xD4, 4, GumpButtonType.Reply, 0 ); // Poison
AddItem( 59, 143, 0x1AE4 );
AddPlus( 95, 140, system.Poison );
AddButton( 71, 163, 0xD4, 0xD4, 5, GumpButtonType.Reply, 0 ); // Disease
AddItem( 55, 167, 0x1727 );
AddPlus( 95, 164, system.Disease );
AddButton( 209, 67, 0xD2, 0xD2, 6, GumpButtonType.Reply, 0 ); // Water
AddItem( 193, 67, 0x1F9D );
AddPlusMinus( 196, 67, system.Water );
AddButton( 209, 91, 0xD4, 0xD4, 7, GumpButtonType.Reply, 0 ); // Poison potion
AddItem( 201, 91, 0xF0A );
AddLevel( 196, 91, system.PoisonPotion );
AddButton( 209, 115, 0xD4, 0xD4, 8, GumpButtonType.Reply, 0 ); // Cure potion
AddItem( 201, 115, 0xF07 );
AddLevel( 196, 115, system.CurePotion );
AddButton( 209, 139, 0xD4, 0xD4, 9, GumpButtonType.Reply, 0 ); // Heal potion
AddItem( 201, 139, 0xF0C );
AddLevel( 196, 139, system.HealPotion );
AddButton( 209, 163, 0xD4, 0xD4, 10, GumpButtonType.Reply, 0 ); // Strength potion
AddItem( 201, 163, 0xF09 );
AddLevel( 196, 163, system.StrengthPotion );
AddImage( 48, 47, 0xD2 );
AddLevel( 54, 47, (int)m_Plant.PlantStatus );
AddImage( 232, 47, 0xD2 );
AddGrowthIndicator( 239, 47 );
AddButton( 48, 183, 0xD2, 0xD2, 11, GumpButtonType.Reply, 0 ); // Help
AddLabel( 54, 183, 0x835, "?" );
AddButton( 232, 183, 0xD4, 0xD4, 12, GumpButtonType.Reply, 0 ); // Empty the bowl
AddItem( 219, 180, 0x15FD );
}
private void DrawBackground()
{
AddBackground( 50, 50, 200, 150, 0xE10 );
AddItem( 45, 45, 0xCEF );
AddItem( 45, 118, 0xCF0 );
AddItem( 211, 45, 0xCEB );
AddItem( 211, 118, 0xCEC );
}
private void DrawPlant()
{
PlantStatus status = m_Plant.PlantStatus;
if ( status < PlantStatus.FullGrownPlant )
{
AddImage( 110, 85, 0x589 );
AddItem( 122, 94, 0x914 );
AddItem( 135, 94, 0x914 );
AddItem( 120, 112, 0x914 );
AddItem( 135, 112, 0x914 );
if ( status >= PlantStatus.Stage2 )
{
AddItem( 127, 112, 0xC62 );
}
if ( status == PlantStatus.Stage3 || status == PlantStatus.Stage4 )
{
AddItem( 129, 85, 0xC7E );
}
if ( status >= PlantStatus.Stage4 )
{
AddItem( 121, 117, 0xC62 );
AddItem( 133, 117, 0xC62 );
}
if ( status >= PlantStatus.Stage5 )
{
AddItem( 110, 100, 0xC62 );
AddItem( 140, 100, 0xC62 );
AddItem( 110, 130, 0xC62 );
AddItem( 140, 130, 0xC62 );
}
if ( status >= PlantStatus.Stage6 )
{
AddItem( 105, 115, 0xC62 );
AddItem( 145, 115, 0xC62 );
AddItem( 125, 90, 0xC62 );
AddItem( 125, 135, 0xC62 );
}
}
else
{
PlantTypeInfo typeInfo = PlantTypeInfo.GetInfo( m_Plant.PlantType );
PlantHueInfo hueInfo = PlantHueInfo.GetInfo( m_Plant.PlantHue );
// The large images for these trees trigger a client crash, so use a smaller, generic tree.
if ( m_Plant.PlantType == PlantType.CypressTwisted || m_Plant.PlantType == PlantType.CypressStraight )
AddItem( 130 + typeInfo.OffsetX, 96 + typeInfo.OffsetY, 0x0CCA, hueInfo.Hue );
else
AddItem( 130 + typeInfo.OffsetX, 96 + typeInfo.OffsetY, typeInfo.ItemID, hueInfo.Hue );
}
if ( status != PlantStatus.BowlOfDirt )
{
int message = m_Plant.PlantSystem.GetLocalizedHealth();
switch ( m_Plant.PlantSystem.Health )
{
case PlantHealth.Dying:
{
AddItem( 92, 167, 0x1B9D );
AddItem( 161, 167, 0x1B9D );
AddHtmlLocalized( 136, 167, 42, 20, message, 0x00FC00, false, false );
break;
}
case PlantHealth.Wilted:
{
AddItem( 91, 164, 0x18E6 );
AddItem( 161, 164, 0x18E6 );
AddHtmlLocalized( 132, 167, 42, 20, message, 0x00C207, false, false );
break;
}
case PlantHealth.Healthy:
{
AddItem( 96, 168, 0xC61 );
AddItem( 162, 168, 0xC61 );
AddHtmlLocalized( 129, 167, 42, 20, message, 0x008200, false, false );
break;
}
case PlantHealth.Vibrant:
{
AddItem( 93, 162, 0x1A99 );
AddItem( 162, 162, 0x1A99 );
AddHtmlLocalized( 129, 167, 42, 20, message, 0x0083E0, false, false );
break;
}
}
}
}
private void AddPlus( int x, int y, int value )
{
switch ( value )
{
case 1: AddLabel( x, y, 0x35, "+" ); break;
case 2: AddLabel( x, y, 0x21, "+" ); break;
}
}
private void AddPlusMinus( int x, int y, int value )
{
switch ( value )
{
case 0: AddLabel( x, y, 0x21, "-" ); break;
case 1: AddLabel( x, y, 0x35, "-" ); break;
case 3: AddLabel( x, y, 0x35, "+" ); break;
case 4: AddLabel( x, y, 0x21, "+" ); break;
}
}
private void AddLevel( int x, int y, int value )
{
AddLabel( x, y, 0x835, value.ToString() );
}
private void AddGrowthIndicator( int x, int y )
{
if ( !m_Plant.IsGrowable )
return;
switch ( m_Plant.PlantSystem.GrowthIndicator )
{
case PlantGrowthIndicator.InvalidLocation : AddLabel( x, y, 0x21, "!" ); break;
case PlantGrowthIndicator.NotHealthy : AddLabel( x, y, 0x21, "-" ); break;
case PlantGrowthIndicator.Delay : AddLabel( x, y, 0x35, "-" ); break;
case PlantGrowthIndicator.Grown : AddLabel( x, y, 0x3, "+" ); break;
case PlantGrowthIndicator.DoubleGrown : AddLabel( x, y, 0x3F, "+" ); break;
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
if ( info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant )
return;
if ( ( ( info.ButtonID >= 6 && info.ButtonID <= 10 ) || info.ButtonID == 12 ) && !from.InRange( m_Plant.GetWorldLocation(), 3 ) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3E9, 500446 ); // That is too far away.
return;
}
if ( !m_Plant.IsUsableBy( from ) )
{
m_Plant.LabelTo( from, 1061856 ); // You must have the item in your backpack or locked down in order to use it.
return;
}
switch ( info.ButtonID )
{
case 1: // Reproduction menu
{
if ( m_Plant.PlantStatus > PlantStatus.BowlOfDirt )
{
from.SendGump( new ReproductionGump( m_Plant ) );
}
else
{
from.SendLocalizedMessage( 1061885 ); // You need to plant a seed in the bowl first.
from.SendGump( new MainPlantGump( m_Plant ) );
}
break;
}
case 2: // Infestation
{
from.Send( new DisplayHelpTopic( 54, true ) ); // INFESTATION LEVEL
from.SendGump( new MainPlantGump( m_Plant ) );
break;
}
case 3: // Fungus
{
from.Send( new DisplayHelpTopic( 56, true ) ); // FUNGUS LEVEL
from.SendGump( new MainPlantGump( m_Plant ) );
break;
}
case 4: // Poison
{
from.Send( new DisplayHelpTopic( 58, true ) ); // POISON LEVEL
from.SendGump( new MainPlantGump( m_Plant ) );
break;
}
case 5: // Disease
{
from.Send( new DisplayHelpTopic( 60, true ) ); // DISEASE LEVEL
from.SendGump( new MainPlantGump( m_Plant ) );
break;
}
case 6: // Water
{
Item[] item = from.Backpack.FindItemsByType( typeof( BaseBeverage ) );
bool foundUsableWater = false;
if ( item != null && item.Length > 0 )
{
for ( int i = 0; i < item.Length; ++i )
{
BaseBeverage beverage = (BaseBeverage)item[i];
if ( !beverage.IsEmpty && beverage.Pourable && beverage.Content == BeverageType.Water )
{
foundUsableWater = true;
m_Plant.Pour( from, beverage );
break;
}
}
}
if ( !foundUsableWater )
{
from.Target = new PlantPourTarget( m_Plant );
from.SendLocalizedMessage( 1060808, "#" + m_Plant.GetLocalizedPlantStatus().ToString() ); // Target the container you wish to use to water the ~1_val~.
}
from.SendGump( new MainPlantGump( m_Plant ) );
break;
}
case 7: // Poison potion
{
AddPotion( from, PotionEffect.PoisonGreater, PotionEffect.PoisonDeadly );
break;
}
case 8: // Cure potion
{
AddPotion( from, PotionEffect.CureGreater );
break;
}
case 9: // Heal potion
{
AddPotion( from, PotionEffect.HealGreater );
break;
}
case 10: // Strength potion
{
AddPotion( from, PotionEffect.StrengthGreater );
break;
}
case 11: // Help
{
from.Send( new DisplayHelpTopic( 48, true ) ); // PLANT GROWING
from.SendGump( new MainPlantGump( m_Plant ) );
break;
}
case 12: // Empty the bowl
{
from.SendGump( new EmptyTheBowlGump( m_Plant ) );
break;
}
}
}
private void AddPotion( Mobile from, params PotionEffect[] effects )
{
Item item = GetPotion( from, effects );
if ( item != null )
{
m_Plant.Pour( from, item );
}
else
{
int message;
if ( m_Plant.ApplyPotion( effects[0], true, out message ) )
{
from.SendLocalizedMessage( 1061884 ); // You don't have any strong potions of that type in your pack.
from.Target = new PlantPourTarget( m_Plant );
from.SendLocalizedMessage( 1060808, "#" + m_Plant.GetLocalizedPlantStatus().ToString() ); // Target the container you wish to use to water the ~1_val~.
return;
}
m_Plant.LabelTo( from, message );
}
from.SendGump( new MainPlantGump( m_Plant ) );
}
public static Item GetPotion( Mobile from, PotionEffect[] effects )
{
if ( from.Backpack == null )
return null;
Item[] items = from.Backpack.FindItemsByType( new[] { typeof( BasePotion ), typeof( PotionKeg ) } );
foreach ( Item item in items )
{
if ( item is BasePotion potion )
{
if ( Array.IndexOf( effects, potion.PotionEffect ) >= 0 )
return potion;
}
else
{
PotionKeg keg = (PotionKeg)item;
if ( keg.Held > 0 && Array.IndexOf( effects, keg.Type ) >= 0 )
return keg;
}
}
return null;
}
}
}
public class MainPlantGump : Gump
{
private PlantItem m_Plant;
public MainPlantGump(PlantItem plant) : base(20, 20)
{
m_Plant = plant;
DrawBackground();
DrawPlant();
AddButton(71, 67, 0xD4, 0xD4, 1, GumpButtonType.Reply, 0); // Reproduction menu
AddItem(59, 68, 0xD08);
PlantSystem system = plant.PlantSystem;
AddButton(71, 91, 0xD4, 0xD4, 2, GumpButtonType.Reply, 0); // Infestation
AddItem(8, 96, 0x372);
AddPlus(95, 92, system.Infestation);
AddButton(71, 115, 0xD4, 0xD4, 3, GumpButtonType.Reply, 0); // Fungus
AddItem(58, 115, 0xD16);
AddPlus(95, 116, system.Fungus);
AddButton(71, 139, 0xD4, 0xD4, 4, GumpButtonType.Reply, 0); // Poison
AddItem(59, 143, 0x1AE4);
AddPlus(95, 140, system.Poison);
AddButton(71, 163, 0xD4, 0xD4, 5, GumpButtonType.Reply, 0); // Disease
AddItem(55, 167, 0x1727);
AddPlus(95, 164, system.Disease);
AddButton(209, 67, 0xD2, 0xD2, 6, GumpButtonType.Reply, 0); // Water
AddItem(193, 67, 0x1F9D);
AddPlusMinus(196, 67, system.Water);
AddButton(209, 91, 0xD4, 0xD4, 7, GumpButtonType.Reply, 0); // Poison potion
AddItem(201, 91, 0xF0A);
AddLevel(196, 91, system.PoisonPotion);
AddButton(209, 115, 0xD4, 0xD4, 8, GumpButtonType.Reply, 0); // Cure potion
AddItem(201, 115, 0xF07);
AddLevel(196, 115, system.CurePotion);
AddButton(209, 139, 0xD4, 0xD4, 9, GumpButtonType.Reply, 0); // Heal potion
AddItem(201, 139, 0xF0C);
AddLevel(196, 139, system.HealPotion);
AddButton(209, 163, 0xD4, 0xD4, 10, GumpButtonType.Reply, 0); // Strength potion
AddItem(201, 163, 0xF09);
AddLevel(196, 163, system.StrengthPotion);
AddImage(48, 47, 0xD2);
AddLevel(54, 47, (int)m_Plant.PlantStatus);
AddImage(232, 47, 0xD2);
AddGrowthIndicator(239, 47);
AddButton(48, 183, 0xD2, 0xD2, 11, GumpButtonType.Reply, 0); // Help
AddLabel(54, 183, 0x835, "?");
AddButton(232, 183, 0xD4, 0xD4, 12, GumpButtonType.Reply, 0); // Empty the bowl
AddItem(219, 180, 0x15FD);
}
private void DrawBackground()
{
AddBackground(50, 50, 200, 150, 0xE10);
AddItem(45, 45, 0xCEF);
AddItem(45, 118, 0xCF0);
AddItem(211, 45, 0xCEB);
AddItem(211, 118, 0xCEC);
}
private void DrawPlant()
{
PlantStatus status = m_Plant.PlantStatus;
if (status < PlantStatus.FullGrownPlant)
{
AddImage(110, 85, 0x589);
AddItem(122, 94, 0x914);
AddItem(135, 94, 0x914);
AddItem(120, 112, 0x914);
AddItem(135, 112, 0x914);
if (status >= PlantStatus.Stage2) AddItem(127, 112, 0xC62);
if (status == PlantStatus.Stage3 || status == PlantStatus.Stage4) AddItem(129, 85, 0xC7E);
if (status >= PlantStatus.Stage4)
{
AddItem(121, 117, 0xC62);
AddItem(133, 117, 0xC62);
}
if (status >= PlantStatus.Stage5)
{
AddItem(110, 100, 0xC62);
AddItem(140, 100, 0xC62);
AddItem(110, 130, 0xC62);
AddItem(140, 130, 0xC62);
}
if (status >= PlantStatus.Stage6)
{
AddItem(105, 115, 0xC62);
AddItem(145, 115, 0xC62);
AddItem(125, 90, 0xC62);
AddItem(125, 135, 0xC62);
}
}
else
{
PlantTypeInfo typeInfo = PlantTypeInfo.GetInfo(m_Plant.PlantType);
PlantHueInfo hueInfo = PlantHueInfo.GetInfo(m_Plant.PlantHue);
// The large images for these trees trigger a client crash, so use a smaller, generic tree.
if (m_Plant.PlantType == PlantType.CypressTwisted || m_Plant.PlantType == PlantType.CypressStraight)
AddItem(130 + typeInfo.OffsetX, 96 + typeInfo.OffsetY, 0x0CCA, hueInfo.Hue);
else
AddItem(130 + typeInfo.OffsetX, 96 + typeInfo.OffsetY, typeInfo.ItemID, hueInfo.Hue);
}
if (status != PlantStatus.BowlOfDirt)
{
int message = m_Plant.PlantSystem.GetLocalizedHealth();
switch (m_Plant.PlantSystem.Health)
{
case PlantHealth.Dying:
{
AddItem(92, 167, 0x1B9D);
AddItem(161, 167, 0x1B9D);
AddHtmlLocalized(136, 167, 42, 20, message, 0x00FC00, false, false);
break;
}
case PlantHealth.Wilted:
{
AddItem(91, 164, 0x18E6);
AddItem(161, 164, 0x18E6);
AddHtmlLocalized(132, 167, 42, 20, message, 0x00C207, false, false);
break;
}
case PlantHealth.Healthy:
{
AddItem(96, 168, 0xC61);
AddItem(162, 168, 0xC61);
AddHtmlLocalized(129, 167, 42, 20, message, 0x008200, false, false);
break;
}
case PlantHealth.Vibrant:
{
AddItem(93, 162, 0x1A99);
AddItem(162, 162, 0x1A99);
AddHtmlLocalized(129, 167, 42, 20, message, 0x0083E0, false, false);
break;
}
}
}
}
private void AddPlus(int x, int y, int value)
{
switch (value)
{
case 1:
AddLabel(x, y, 0x35, "+");
break;
case 2:
AddLabel(x, y, 0x21, "+");
break;
}
}
private void AddPlusMinus(int x, int y, int value)
{
switch (value)
{
case 0:
AddLabel(x, y, 0x21, "-");
break;
case 1:
AddLabel(x, y, 0x35, "-");
break;
case 3:
AddLabel(x, y, 0x35, "+");
break;
case 4:
AddLabel(x, y, 0x21, "+");
break;
}
}
private void AddLevel(int x, int y, int value)
{
AddLabel(x, y, 0x835, value.ToString());
}
private void AddGrowthIndicator(int x, int y)
{
if (!m_Plant.IsGrowable)
return;
switch (m_Plant.PlantSystem.GrowthIndicator)
{
case PlantGrowthIndicator.InvalidLocation:
AddLabel(x, y, 0x21, "!");
break;
case PlantGrowthIndicator.NotHealthy:
AddLabel(x, y, 0x21, "-");
break;
case PlantGrowthIndicator.Delay:
AddLabel(x, y, 0x35, "-");
break;
case PlantGrowthIndicator.Grown:
AddLabel(x, y, 0x3, "+");
break;
case PlantGrowthIndicator.DoubleGrown:
AddLabel(x, y, 0x3F, "+");
break;
}
}
public override void OnResponse(NetState sender, RelayInfo info)
{
Mobile from = sender.Mobile;
if (info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant)
return;
if ((info.ButtonID >= 6 && info.ButtonID <= 10 || info.ButtonID == 12) &&
!from.InRange(m_Plant.GetWorldLocation(), 3))
{
from.LocalOverheadMessage(MessageType.Regular, 0x3E9, 500446); // That is too far away.
return;
}
if (!m_Plant.IsUsableBy(from))
{
m_Plant.LabelTo(from, 1061856); // You must have the item in your backpack or locked down in order to use it.
return;
}
switch (info.ButtonID)
{
case 1: // Reproduction menu
{
if (m_Plant.PlantStatus > PlantStatus.BowlOfDirt)
{
from.SendGump(new ReproductionGump(m_Plant));
}
else
{
from.SendLocalizedMessage(1061885); // You need to plant a seed in the bowl first.
from.SendGump(new MainPlantGump(m_Plant));
}
break;
}
case 2: // Infestation
{
from.Send(new DisplayHelpTopic(54, true)); // INFESTATION LEVEL
from.SendGump(new MainPlantGump(m_Plant));
break;
}
case 3: // Fungus
{
from.Send(new DisplayHelpTopic(56, true)); // FUNGUS LEVEL
from.SendGump(new MainPlantGump(m_Plant));
break;
}
case 4: // Poison
{
from.Send(new DisplayHelpTopic(58, true)); // POISON LEVEL
from.SendGump(new MainPlantGump(m_Plant));
break;
}
case 5: // Disease
{
from.Send(new DisplayHelpTopic(60, true)); // DISEASE LEVEL
from.SendGump(new MainPlantGump(m_Plant));
break;
}
case 6: // Water
{
Item[] item = from.Backpack.FindItemsByType(typeof(BaseBeverage));
bool foundUsableWater = false;
if (item != null && item.Length > 0)
for (int i = 0; i < item.Length; ++i)
{
BaseBeverage beverage = (BaseBeverage)item[i];
if (!beverage.IsEmpty && beverage.Pourable && beverage.Content == BeverageType.Water)
{
foundUsableWater = true;
m_Plant.Pour(from, beverage);
break;
}
}
if (!foundUsableWater)
{
from.Target = new PlantPourTarget(m_Plant);
from.SendLocalizedMessage(1060808,
"#" + m_Plant
.GetLocalizedPlantStatus()); // Target the container you wish to use to water the ~1_val~.
}
from.SendGump(new MainPlantGump(m_Plant));
break;
}
case 7: // Poison potion
{
AddPotion(from, PotionEffect.PoisonGreater, PotionEffect.PoisonDeadly);
break;
}
case 8: // Cure potion
{
AddPotion(from, PotionEffect.CureGreater);
break;
}
case 9: // Heal potion
{
AddPotion(from, PotionEffect.HealGreater);
break;
}
case 10: // Strength potion
{
AddPotion(from, PotionEffect.StrengthGreater);
break;
}
case 11: // Help
{
from.Send(new DisplayHelpTopic(48, true)); // PLANT GROWING
from.SendGump(new MainPlantGump(m_Plant));
break;
}
case 12: // Empty the bowl
{
from.SendGump(new EmptyTheBowlGump(m_Plant));
break;
}
}
}
private void AddPotion(Mobile from, params PotionEffect[] effects)
{
Item item = GetPotion(from, effects);
if (item != null)
{
m_Plant.Pour(from, item);
}
else
{
int message;
if (m_Plant.ApplyPotion(effects[0], true, out message))
{
from.SendLocalizedMessage(1061884); // You don't have any strong potions of that type in your pack.
from.Target = new PlantPourTarget(m_Plant);
from.SendLocalizedMessage(1060808,
"#" + m_Plant
.GetLocalizedPlantStatus()); // Target the container you wish to use to water the ~1_val~.
return;
}
m_Plant.LabelTo(from, message);
}
from.SendGump(new MainPlantGump(m_Plant));
}
public static Item GetPotion(Mobile from, PotionEffect[] effects)
{
if (from.Backpack == null)
return null;
Item[] items = from.Backpack.FindItemsByType(new[] { typeof(BasePotion), typeof(PotionKeg) });
foreach (Item item in items)
if (item is BasePotion potion)
{
if (Array.IndexOf(effects, potion.PotionEffect) >= 0)
return potion;
}
else
{
PotionKeg keg = (PotionKeg)item;
if (keg.Held > 0 && Array.IndexOf(effects, keg.Type) >= 0)
return keg;
}
return null;
}
}
}

View file

@ -1,36 +1,36 @@
namespace Server.Items
{
public class FertileDirt : Item
{
[Constructible]
public FertileDirt() : this( 1 )
{
}
public class FertileDirt : Item
{
[Constructible]
public FertileDirt() : this(1)
{
}
[Constructible]
public FertileDirt( int amount ) : base( 0xF81 )
{
Stackable = true;
Weight = 1.0;
Amount = amount;
}
[Constructible]
public FertileDirt(int amount) : base(0xF81)
{
Stackable = true;
Weight = 1.0;
Amount = amount;
}
public FertileDirt( Serial serial ) : base( serial )
{
}
public FertileDirt(Serial serial) : base(serial)
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write( (int) 0 ); // version
}
writer.Write(0); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
int version = reader.ReadInt();
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -4,139 +4,137 @@ using Server.Network;
namespace Server.Items
{
public class OrangePetals : Item
{
public override int LabelNumber => 1053122; // orange petals
public class OrangePetals : Item
{
private static Hashtable m_Table = new Hashtable();
public override double DefaultWeight => 0.1;
[Constructible]
public OrangePetals() : this(1)
{
}
[Constructible]
public OrangePetals() : this( 1 )
{
}
[Constructible]
public OrangePetals(int amount) : base(0x1021)
{
Stackable = true;
Hue = 0x2B;
Amount = amount;
}
[Constructible]
public OrangePetals( int amount ) : base( 0x1021 )
{
Stackable = true;
Hue = 0x2B;
Amount = amount;
}
public OrangePetals(Serial serial) : base(serial)
{
}
public OrangePetals( Serial serial ) : base( serial )
{
}
public override int LabelNumber => 1053122; // orange petals
public override bool CheckItemUse( Mobile from, Item item )
{
if ( item != this )
return base.CheckItemUse( from, item );
public override double DefaultWeight => 0.1;
if ( from != RootParent )
{
from.SendLocalizedMessage( 1042038 ); // You must have the object in your backpack to use it.
return false;
}
public override bool CheckItemUse(Mobile from, Item item)
{
if (item != this)
return base.CheckItemUse(from, item);
return base.CheckItemUse( from, item );
}
if (from != RootParent)
{
from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it.
return false;
}
public override void OnDoubleClick( Mobile from )
{
OrangePetalsContext context = GetContext( from );
return base.CheckItemUse(from, item);
}
if ( context != null )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061904 );
return;
}
public override void OnDoubleClick(Mobile from)
{
OrangePetalsContext context = GetContext(from);
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061905 );
from.PlaySound( 0x3B );
if (context != null)
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1061904);
return;
}
Timer timer = new OrangePetalsTimer( from );
timer.Start();
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1061905);
from.PlaySound(0x3B);
AddContext( from, new OrangePetalsContext( timer ) );
Timer timer = new OrangePetalsTimer(from);
timer.Start();
Consume();
}
AddContext(from, new OrangePetalsContext(timer));
private static Hashtable m_Table = new Hashtable();
Consume();
}
private static void AddContext( Mobile m, OrangePetalsContext context )
{
m_Table[m] = context;
}
private static void AddContext(Mobile m, OrangePetalsContext context)
{
m_Table[m] = context;
}
public static void RemoveContext( Mobile m )
{
OrangePetalsContext context = GetContext( m );
public static void RemoveContext(Mobile m)
{
OrangePetalsContext context = GetContext(m);
if ( context != null )
RemoveContext( m, context );
}
if (context != null)
RemoveContext(m, context);
}
private static void RemoveContext( Mobile m, OrangePetalsContext context )
{
m_Table.Remove( m );
private static void RemoveContext(Mobile m, OrangePetalsContext context)
{
m_Table.Remove(m);
context.Timer.Stop();
}
context.Timer.Stop();
}
private static OrangePetalsContext GetContext( Mobile m )
{
return ( m_Table[m] as OrangePetalsContext );
}
private static OrangePetalsContext GetContext(Mobile m)
{
return m_Table[m] as OrangePetalsContext;
}
public static bool UnderEffect( Mobile m )
{
return ( GetContext( m ) != null );
}
public static bool UnderEffect(Mobile m)
{
return GetContext(m) != null;
}
private class OrangePetalsTimer : Timer
{
private Mobile m_Mobile;
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
public OrangePetalsTimer( Mobile from ) : base ( TimeSpan.FromMinutes( 5.0 ) )
{
m_Mobile = from;
}
writer.Write(0); // version
}
protected override void OnTick()
{
if ( !m_Mobile.Deleted )
{
m_Mobile.LocalOverheadMessage( MessageType.Regular, 0x3F, true,
"* You feel the effects of your poison resistance wearing off *" );
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
RemoveContext( m_Mobile );
}
}
int version = reader.ReadInt();
}
private class OrangePetalsContext
{
public Timer Timer { get; }
private class OrangePetalsTimer : Timer
{
private Mobile m_Mobile;
public OrangePetalsContext( Timer timer )
{
Timer = timer;
}
}
public OrangePetalsTimer(Mobile from) : base(TimeSpan.FromMinutes(5.0))
{
m_Mobile = from;
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
protected override void OnTick()
{
if (!m_Mobile.Deleted)
m_Mobile.LocalOverheadMessage(MessageType.Regular, 0x3F, true,
"* You feel the effects of your poison resistance wearing off *");
writer.Write( (int) 0 ); // version
}
RemoveContext(m_Mobile);
}
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
private class OrangePetalsContext
{
public OrangePetalsContext(Timer timer)
{
Timer = timer;
}
int version = reader.ReadInt();
}
}
}
public Timer Timer{ get; }
}
}
}

View file

@ -2,100 +2,100 @@ using Server.Targeting;
namespace Server.Items
{
public class RedLeaves : Item
{
public override int LabelNumber => 1053123; // red leaves
public class RedLeaves : Item
{
[Constructible]
public RedLeaves() : this(1)
{
}
public override double DefaultWeight => 0.1;
[Constructible]
public RedLeaves(int amount) : base(0x1E85)
{
Stackable = true;
Hue = 0x21;
Amount = amount;
}
[Constructible]
public RedLeaves() : this( 1 )
{
}
public RedLeaves(Serial serial) : base(serial)
{
}
[Constructible]
public RedLeaves( int amount ) : base( 0x1E85 )
{
Stackable = true;
Hue = 0x21;
Amount = amount;
}
public override int LabelNumber => 1053123; // red leaves
public RedLeaves( Serial serial ) : base( serial )
{
}
public override double DefaultWeight => 0.1;
public override void OnDoubleClick( Mobile from )
{
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042664 ); // You must have the object in your backpack to use it.
return;
}
public override void OnDoubleClick(Mobile from)
{
if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042664); // You must have the object in your backpack to use it.
return;
}
from.Target = new InternalTarget( this );
from.SendLocalizedMessage( 1061907 ); // Choose a book you wish to seal with the wax from the red leaf.
}
from.Target = new InternalTarget(this);
from.SendLocalizedMessage(1061907); // Choose a book you wish to seal with the wax from the red leaf.
}
private class InternalTarget : Target
{
private RedLeaves m_RedLeaves;
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
public InternalTarget( RedLeaves redLeaves ) : base( 3, false, TargetFlags.None )
{
m_RedLeaves = redLeaves;
}
writer.Write(0); // version
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( m_RedLeaves.Deleted )
return;
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
if ( !m_RedLeaves.IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042664 ); // You must have the object in your backpack to use it.
return;
}
int version = reader.ReadInt();
}
if ( !(targeted is Item item) || !item.IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042664 ); // You must have the object in your backpack to use it.
}
else if ( !(item is BaseBook) )
{
item.LabelTo( from, 1061911 ); // You can only use red leaves to seal the ink into book pages!
}
else
{
BaseBook book = (BaseBook)item;
private class InternalTarget : Target
{
private RedLeaves m_RedLeaves;
if ( !book.Writable )
{
book.LabelTo( from, 1061909 ); // The ink in this book has already been sealed.
}
else
{
m_RedLeaves.Consume();
book.Writable = false;
public InternalTarget(RedLeaves redLeaves) : base(3, false, TargetFlags.None)
{
m_RedLeaves = redLeaves;
}
book.LabelTo( from, 1061910 ); // You seal the ink to the page using wax from the red leaf.
}
}
}
}
protected override void OnTarget(Mobile from, object targeted)
{
if (m_RedLeaves.Deleted)
return;
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
if (!m_RedLeaves.IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042664); // You must have the object in your backpack to use it.
return;
}
writer.Write( (int) 0 ); // version
}
if (!(targeted is Item item) || !item.IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042664); // You must have the object in your backpack to use it.
}
else if (!(item is BaseBook))
{
item.LabelTo(from, 1061911); // You can only use red leaves to seal the ink into book pages!
}
else
{
BaseBook book = (BaseBook)item;
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
if (!book.Writable)
{
book.LabelTo(from, 1061909); // The ink in this book has already been sealed.
}
else
{
m_RedLeaves.Consume();
book.Writable = false;
int version = reader.ReadInt();
}
}
}
book.LabelTo(from, 1061910); // You seal the ink to the page using wax from the red leaf.
}
}
}
}
}
}

View file

@ -1,71 +1,71 @@
namespace Server.Mobiles
{
public class GiantIceWorm : BaseCreature
{
public override string CorpseName => "a giant ice worm corpse";
public override bool SubdueBeforeTame => true;
public override string DefaultName => "a giant ice worm";
public class GiantIceWorm : BaseCreature
{
[Constructible]
public GiantIceWorm() : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
{
Body = 89;
BaseSoundID = 0xDC;
[Constructible]
public GiantIceWorm() : base( AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4 )
{
Body = 89;
BaseSoundID = 0xDC;
SetStr(216, 245);
SetDex(76, 100);
SetInt(66, 85);
SetStr( 216, 245 );
SetDex( 76, 100 );
SetInt( 66, 85 );
SetHits(130, 147);
SetHits( 130, 147 );
SetDamage(7, 17);
SetDamage( 7, 17 );
SetDamageType(ResistanceType.Physical, 10);
SetDamageType(ResistanceType.Cold, 90);
SetDamageType( ResistanceType.Physical, 10 );
SetDamageType( ResistanceType.Cold, 90 );
SetResistance(ResistanceType.Physical, 30, 35);
SetResistance(ResistanceType.Fire, 0);
SetResistance(ResistanceType.Cold, 80, 90);
SetResistance(ResistanceType.Poison, 15, 25);
SetResistance(ResistanceType.Energy, 10, 20);
SetResistance( ResistanceType.Physical, 30, 35 );
SetResistance( ResistanceType.Fire, 0 );
SetResistance( ResistanceType.Cold, 80, 90 );
SetResistance( ResistanceType.Poison, 15, 25 );
SetResistance( ResistanceType.Energy, 10, 20 );
SetSkill(SkillName.Poisoning, 75.1, 95.0);
SetSkill(SkillName.MagicResist, 45.1, 60.0);
SetSkill(SkillName.Tactics, 75.1, 80.0);
SetSkill(SkillName.Wrestling, 60.1, 80.0);
SetSkill( SkillName.Poisoning, 75.1, 95.0 );
SetSkill( SkillName.MagicResist, 45.1, 60.0 );
SetSkill( SkillName.Tactics, 75.1, 80.0 );
SetSkill( SkillName.Wrestling, 60.1, 80.0 );
Fame = 4500;
Karma = -4500;
Fame = 4500;
Karma = -4500;
VirtualArmor = 40;
VirtualArmor = 40;
Tamable = true;
ControlSlots = 1;
MinTameSkill = 71.1;
}
Tamable = true;
ControlSlots = 1;
MinTameSkill = 71.1;
}
public GiantIceWorm(Serial serial) : base(serial)
{
}
public override Poison PoisonImmune => Poison.Greater;
public override string CorpseName => "a giant ice worm corpse";
public override bool SubdueBeforeTame => true;
public override string DefaultName => "a giant ice worm";
public override Poison HitPoison => Poison.Greater;
public override Poison PoisonImmune => Poison.Greater;
public override FoodType FavoriteFood => FoodType.Meat;
public override Poison HitPoison => Poison.Greater;
public GiantIceWorm( Serial serial ) : base ( serial )
{
}
public override FoodType FavoriteFood => FoodType.Meat;
public override void Serialize(GenericWriter writer)
{
base.Serialize( writer );
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write( (int) 0 );
}
writer.Write(0);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize( reader );
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
}
int version = reader.ReadInt();
}
}
}

View file

@ -1,15 +1,15 @@
namespace Server.Network
{
public class DisplayHelpTopic : Packet
{
public DisplayHelpTopic( int topicID, bool display ) : base( 0xBF )
{
EnsureCapacity( 11 );
public class DisplayHelpTopic : Packet
{
public DisplayHelpTopic(int topicID, bool display) : base(0xBF)
{
EnsureCapacity(11);
m_Stream.Write( (short) 0x17 );
m_Stream.Write( (byte) 1 );
m_Stream.Write( (int) topicID );
m_Stream.Write( (bool) display );
}
}
m_Stream.Write((short)0x17);
m_Stream.Write((byte)1);
m_Stream.Write(topicID);
m_Stream.Write(display);
}
}
}

View file

@ -1,188 +1,194 @@
using Server.Items;
using Server.Targeting;
using Server.Network;
using Server.Targeting;
namespace Server.Engines.Plants
{
public class PlantBowl : Item
{
public override int LabelNumber => 1060834; // a plant bowl
public class PlantBowl : Item
{
private static int[] m_DirtPatchTiles =
{
0x9, 0x15,
0x71, 0x7C,
0x82, 0xA7,
0xDC, 0xE3,
0xE8, 0xEB,
0x141, 0x144,
0x14C, 0x15C,
0x169, 0x174,
0x1DC, 0x1EF,
0x272, 0x275,
0x27E, 0x281,
0x2D0, 0x2D7,
0x2E5, 0x2FF,
0x303, 0x31F,
0x32C, 0x32F,
0x33D, 0x340,
0x345, 0x34C,
0x355, 0x358,
0x367, 0x36E,
0x377, 0x37A,
0x38D, 0x390,
0x395, 0x39C,
0x3A5, 0x3A8,
0x3F6, 0x405,
0x547, 0x54E,
0x553, 0x556,
0x597, 0x59E,
0x623, 0x63A,
0x6F3, 0x6FA,
0x777, 0x791,
0x79A, 0x7A9,
0x7AE, 0x7B1,
0x98C, 0x99F,
0x9AC, 0x9BF,
0x5B27, 0x5B3E,
0x71F4, 0x71FB,
0x72C9, 0x72CA
};
[Constructible]
public PlantBowl() : base( 0x15FD )
{
Weight = 1.0;
}
[Constructible]
public PlantBowl() : base(0x15FD)
{
Weight = 1.0;
}
public PlantBowl( Serial serial ) : base( serial )
{
}
public PlantBowl(Serial serial) : base(serial)
{
}
public override void OnDoubleClick( Mobile from )
{
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042664 ); // You must have the object in your backpack to use it.
return;
}
public override int LabelNumber => 1060834; // a plant bowl
from.Target = new InternalTarget( this );
from.SendLocalizedMessage( 1061897 ); // Choose a patch of dirt to scoop up.
}
public override void OnDoubleClick(Mobile from)
{
if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042664); // You must have the object in your backpack to use it.
return;
}
private class InternalTarget : Target
{
private PlantBowl m_PlantBowl;
from.Target = new InternalTarget(this);
from.SendLocalizedMessage(1061897); // Choose a patch of dirt to scoop up.
}
public InternalTarget( PlantBowl plantBowl ) : base( 3, true, TargetFlags.None )
{
m_PlantBowl = plantBowl;
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
protected override void OnTarget( Mobile from, object targeted )
{
if ( m_PlantBowl.Deleted )
return;
writer.Write(0); // version
}
if ( !m_PlantBowl.IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042664 ); // You must have the object in your backpack to use it.
return;
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
if ( targeted is FertileDirt dirt )
{
int _dirtNeeded = Core.ML ? 20 : 40;
int version = reader.ReadInt();
}
if ( !dirt.IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042664 ); // You must have the object in your backpack to use it.
}
else if ( dirt.Amount < _dirtNeeded )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061896 ); // You need more dirt to fill a plant bowl!
}
else
{
PlantItem fullBowl = new PlantItem( true );
public static bool IsDirtPatch(object obj)
{
int tileID;
if ( from.PlaceInBackpack( fullBowl ) )
{
dirt.Consume( _dirtNeeded );
m_PlantBowl.Delete();
if (obj is Static staticObj && !staticObj.Movable)
tileID = (staticObj.ItemID & 0x3FFF) | 0x4000;
else if (obj is StaticTarget staticTarget)
tileID = (staticTarget.ItemID & 0x3FFF) | 0x4000;
else if (obj is LandTarget landTarget)
tileID = landTarget.TileID;
else
return false;
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061895 ); // You fill the bowl with fresh dirt.
}
else
{
fullBowl.Delete();
bool contains = false;
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061894 ); // There is no room in your backpack for a bowl full of dirt!
}
}
}
else if ( IsDirtPatch( targeted ) )
{
PlantItem fullBowl = new PlantItem( false );
for (int i = 0; !contains && i < m_DirtPatchTiles.Length; i += 2)
contains = tileID >= m_DirtPatchTiles[i] && tileID <= m_DirtPatchTiles[i + 1];
if ( from.PlaceInBackpack( fullBowl ) )
{
m_PlantBowl.Delete();
return contains;
}
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061895 ); // You fill the bowl with fresh dirt.
}
else
{
fullBowl.Delete();
private class InternalTarget : Target
{
private PlantBowl m_PlantBowl;
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061894 ); // There is no room in your backpack for a bowl full of dirt!
}
}
else
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061893 ); // You'll want to gather fresh dirt in order to raise a healthy plant!
}
}
public InternalTarget(PlantBowl plantBowl) : base(3, true, TargetFlags.None)
{
m_PlantBowl = plantBowl;
}
protected override void OnTargetOutOfRange( Mobile from, object targeted )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 502825 ); // That location is too far away
}
}
protected override void OnTarget(Mobile from, object targeted)
{
if (m_PlantBowl.Deleted)
return;
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
if (!m_PlantBowl.IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042664); // You must have the object in your backpack to use it.
return;
}
writer.Write( (int) 0 ); // version
}
if (targeted is FertileDirt dirt)
{
int _dirtNeeded = Core.ML ? 20 : 40;
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
if (!dirt.IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042664); // You must have the object in your backpack to use it.
}
else if (dirt.Amount < _dirtNeeded)
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2,
1061896); // You need more dirt to fill a plant bowl!
}
else
{
PlantItem fullBowl = new PlantItem(true);
int version = reader.ReadInt();
}
if (from.PlaceInBackpack(fullBowl))
{
dirt.Consume(_dirtNeeded);
m_PlantBowl.Delete();
public static bool IsDirtPatch( object obj )
{
int tileID;
from.LocalOverheadMessage(MessageType.Regular, 0x3B2,
1061895); // You fill the bowl with fresh dirt.
}
else
{
fullBowl.Delete();
if ( obj is Static staticObj && !staticObj.Movable )
tileID = (staticObj.ItemID & 0x3FFF) | 0x4000;
else if ( obj is StaticTarget staticTarget )
tileID = (staticTarget.ItemID & 0x3FFF) | 0x4000;
else if ( obj is LandTarget landTarget )
tileID = landTarget.TileID;
else
return false;
from.LocalOverheadMessage(MessageType.Regular, 0x3B2,
1061894); // There is no room in your backpack for a bowl full of dirt!
}
}
}
else if (IsDirtPatch(targeted))
{
PlantItem fullBowl = new PlantItem(false);
bool contains = false;
if (from.PlaceInBackpack(fullBowl))
{
m_PlantBowl.Delete();
for ( int i = 0; !contains && i < m_DirtPatchTiles.Length; i += 2 )
contains = ( tileID >= m_DirtPatchTiles[i] && tileID <= m_DirtPatchTiles[i + 1] );
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1061895); // You fill the bowl with fresh dirt.
}
else
{
fullBowl.Delete();
return contains;
}
from.LocalOverheadMessage(MessageType.Regular, 0x3B2,
1061894); // There is no room in your backpack for a bowl full of dirt!
}
}
else
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2,
1061893); // You'll want to gather fresh dirt in order to raise a healthy plant!
}
}
private static int[] m_DirtPatchTiles = {
0x9, 0x15,
0x71, 0x7C,
0x82, 0xA7,
0xDC, 0xE3,
0xE8, 0xEB,
0x141, 0x144,
0x14C, 0x15C,
0x169, 0x174,
0x1DC, 0x1EF,
0x272, 0x275,
0x27E, 0x281,
0x2D0, 0x2D7,
0x2E5, 0x2FF,
0x303, 0x31F,
0x32C, 0x32F,
0x33D, 0x340,
0x345, 0x34C,
0x355, 0x358,
0x367, 0x36E,
0x377, 0x37A,
0x38D, 0x390,
0x395, 0x39C,
0x3A5, 0x3A8,
0x3F6, 0x405,
0x547, 0x54E,
0x553, 0x556,
0x597, 0x59E,
0x623, 0x63A,
0x6F3, 0x6FA,
0x777, 0x791,
0x79A, 0x7A9,
0x7AE, 0x7B1,
0x98C, 0x99F,
0x9AC, 0x9BF,
0x5B27, 0x5B3E,
0x71F4, 0x71FB,
0x72C9, 0x72CA,
};
}
}
protected override void OnTargetOutOfRange(Mobile from, object targeted)
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 502825); // That location is too far away
}
}
}
}

View file

@ -3,182 +3,182 @@ using System.Collections.Generic;
namespace Server.Engines.Plants
{
[Flags]
public enum PlantHue
{
Plain = 0x1 | Crossable | Reproduces,
[Flags]
public enum PlantHue
{
Plain = 0x1 | Crossable | Reproduces,
Red = 0x2 | Crossable | Reproduces,
Blue = 0x4 | Crossable | Reproduces,
Yellow = 0x8 | Crossable | Reproduces,
Red = 0x2 | Crossable | Reproduces,
Blue = 0x4 | Crossable | Reproduces,
Yellow = 0x8 | Crossable | Reproduces,
BrightRed = Red | Bright,
BrightBlue = Blue | Bright,
BrightYellow = Yellow | Bright,
BrightRed = Red | Bright,
BrightBlue = Blue | Bright,
BrightYellow = Yellow | Bright,
Purple = Red | Blue,
Green = Blue | Yellow,
Orange = Red | Yellow,
Purple = Red | Blue,
Green = Blue | Yellow,
Orange = Red | Yellow,
BrightPurple = Purple | Bright,
BrightGreen = Green | Bright,
BrightOrange = Orange | Bright,
BrightPurple = Purple | Bright,
BrightGreen = Green | Bright,
BrightOrange = Orange | Bright,
Black = 0x10,
White = 0x20,
Pink = 0x40,
Magenta = 0x80,
Aqua = 0x100,
FireRed = 0x200,
Black = 0x10,
White = 0x20,
Pink = 0x40,
Magenta = 0x80,
Aqua = 0x100,
FireRed = 0x200,
None = 0,
Reproduces = 0x2000000,
Crossable = 0x4000000,
Bright = 0x8000000
}
None = 0,
Reproduces = 0x2000000,
Crossable = 0x4000000,
Bright = 0x8000000
}
public class PlantHueInfo
{
private static Dictionary<PlantHue, PlantHueInfo> m_Table;
public class PlantHueInfo
{
private static Dictionary<PlantHue, PlantHueInfo> m_Table;
static PlantHueInfo()
{
m_Table = new Dictionary<PlantHue, PlantHueInfo>();
static PlantHueInfo()
{
m_Table = new Dictionary<PlantHue, PlantHueInfo>();
m_Table[PlantHue.Plain] = new PlantHueInfo( 0, 1060813, PlantHue.Plain, 0x835 );
m_Table[PlantHue.Red] = new PlantHueInfo( 0x66D, 1060814, PlantHue.Red, 0x24 );
m_Table[PlantHue.Blue] = new PlantHueInfo( 0x53D, 1060815, PlantHue.Blue, 0x6 );
m_Table[PlantHue.Yellow] = new PlantHueInfo( 0x8A5, 1060818, PlantHue.Yellow, 0x38 );
m_Table[PlantHue.BrightRed] = new PlantHueInfo( 0x21, 1060814, PlantHue.BrightRed, 0x21 );
m_Table[PlantHue.BrightBlue] = new PlantHueInfo( 0x5, 1060815, PlantHue.BrightBlue, 0x6 );
m_Table[PlantHue.BrightYellow] = new PlantHueInfo( 0x38, 1060818, PlantHue.BrightYellow, 0x35 );
m_Table[PlantHue.Purple] = new PlantHueInfo( 0xD, 1060816, PlantHue.Purple, 0x10 );
m_Table[PlantHue.Green] = new PlantHueInfo( 0x59B, 1060819, PlantHue.Green, 0x42 );
m_Table[PlantHue.Orange] = new PlantHueInfo( 0x46F, 1060817, PlantHue.Orange, 0x2E );
m_Table[PlantHue.BrightPurple] = new PlantHueInfo( 0x10, 1060816, PlantHue.BrightPurple, 0xD );
m_Table[PlantHue.BrightGreen] = new PlantHueInfo( 0x42, 1060819, PlantHue.BrightGreen, 0x3F );
m_Table[PlantHue.BrightOrange] = new PlantHueInfo( 0x2B, 1060817, PlantHue.BrightOrange, 0x2B );
m_Table[PlantHue.Black] = new PlantHueInfo( 0x455, 1060820, PlantHue.Black, 0 );
m_Table[PlantHue.White] = new PlantHueInfo( 0x481, 1060821, PlantHue.White, 0x481 );
m_Table[PlantHue.Pink] = new PlantHueInfo( 0x48E, 1061854, PlantHue.Pink );
m_Table[PlantHue.Magenta] = new PlantHueInfo( 0x486, 1061852, PlantHue.Magenta );
m_Table[PlantHue.Aqua] = new PlantHueInfo( 0x495, 1061853, PlantHue.Aqua );
m_Table[PlantHue.FireRed] = new PlantHueInfo( 0x489, 1061855, PlantHue.FireRed );
}
m_Table[PlantHue.Plain] = new PlantHueInfo(0, 1060813, PlantHue.Plain, 0x835);
m_Table[PlantHue.Red] = new PlantHueInfo(0x66D, 1060814, PlantHue.Red, 0x24);
m_Table[PlantHue.Blue] = new PlantHueInfo(0x53D, 1060815, PlantHue.Blue, 0x6);
m_Table[PlantHue.Yellow] = new PlantHueInfo(0x8A5, 1060818, PlantHue.Yellow, 0x38);
m_Table[PlantHue.BrightRed] = new PlantHueInfo(0x21, 1060814, PlantHue.BrightRed, 0x21);
m_Table[PlantHue.BrightBlue] = new PlantHueInfo(0x5, 1060815, PlantHue.BrightBlue, 0x6);
m_Table[PlantHue.BrightYellow] = new PlantHueInfo(0x38, 1060818, PlantHue.BrightYellow, 0x35);
m_Table[PlantHue.Purple] = new PlantHueInfo(0xD, 1060816, PlantHue.Purple, 0x10);
m_Table[PlantHue.Green] = new PlantHueInfo(0x59B, 1060819, PlantHue.Green, 0x42);
m_Table[PlantHue.Orange] = new PlantHueInfo(0x46F, 1060817, PlantHue.Orange, 0x2E);
m_Table[PlantHue.BrightPurple] = new PlantHueInfo(0x10, 1060816, PlantHue.BrightPurple, 0xD);
m_Table[PlantHue.BrightGreen] = new PlantHueInfo(0x42, 1060819, PlantHue.BrightGreen, 0x3F);
m_Table[PlantHue.BrightOrange] = new PlantHueInfo(0x2B, 1060817, PlantHue.BrightOrange, 0x2B);
m_Table[PlantHue.Black] = new PlantHueInfo(0x455, 1060820, PlantHue.Black, 0);
m_Table[PlantHue.White] = new PlantHueInfo(0x481, 1060821, PlantHue.White, 0x481);
m_Table[PlantHue.Pink] = new PlantHueInfo(0x48E, 1061854, PlantHue.Pink);
m_Table[PlantHue.Magenta] = new PlantHueInfo(0x486, 1061852, PlantHue.Magenta);
m_Table[PlantHue.Aqua] = new PlantHueInfo(0x495, 1061853, PlantHue.Aqua);
m_Table[PlantHue.FireRed] = new PlantHueInfo(0x489, 1061855, PlantHue.FireRed);
}
public static PlantHueInfo GetInfo( PlantHue plantHue )
{
if (m_Table.TryGetValue( plantHue, out PlantHueInfo info ))
return info;
return m_Table[PlantHue.Plain];
}
private PlantHueInfo(int hue, int name, PlantHue plantHue) : this(hue, name, plantHue, hue)
{
}
public static PlantHue RandomFirstGeneration()
{
switch ( Utility.Random( 4 ) )
{
case 0: return PlantHue.Plain;
case 1: return PlantHue.Red;
case 2: return PlantHue.Blue;
default: return PlantHue.Yellow;
}
}
private PlantHueInfo(int hue, int name, PlantHue plantHue, int gumpHue)
{
Hue = hue;
Name = name;
PlantHue = plantHue;
GumpHue = gumpHue;
}
public static bool CanReproduce( PlantHue plantHue )
{
return (plantHue & PlantHue.Reproduces) != PlantHue.None;
}
public int Hue{ get; }
public static bool IsCrossable( PlantHue plantHue )
{
return (plantHue & PlantHue.Crossable) != PlantHue.None;
}
public int Name{ get; }
public static bool IsBright( PlantHue plantHue )
{
return (plantHue & PlantHue.Bright) != PlantHue.None;
}
public PlantHue PlantHue{ get; }
public static PlantHue GetNotBright( PlantHue plantHue )
{
return plantHue & ~PlantHue.Bright;
}
public int GumpHue{ get; }
public static bool IsPrimary( PlantHue plantHue )
{
return plantHue == PlantHue.Red || plantHue == PlantHue.Blue || plantHue == PlantHue.Yellow;
}
public static PlantHueInfo GetInfo(PlantHue plantHue)
{
if (m_Table.TryGetValue(plantHue, out PlantHueInfo info))
return info;
return m_Table[PlantHue.Plain];
}
public static PlantHue Cross( PlantHue first, PlantHue second )
{
if ( !IsCrossable( first ) || !IsCrossable( second ) )
return PlantHue.None;
public static PlantHue RandomFirstGeneration()
{
switch (Utility.Random(4))
{
case 0: return PlantHue.Plain;
case 1: return PlantHue.Red;
case 2: return PlantHue.Blue;
default: return PlantHue.Yellow;
}
}
if ( Utility.RandomDouble() < 0.01 )
return Utility.RandomBool() ? PlantHue.Black : PlantHue.White;
public static bool CanReproduce(PlantHue plantHue)
{
return (plantHue & PlantHue.Reproduces) != PlantHue.None;
}
if ( first == PlantHue.Plain || second == PlantHue.Plain )
return PlantHue.Plain;
public static bool IsCrossable(PlantHue plantHue)
{
return (plantHue & PlantHue.Crossable) != PlantHue.None;
}
PlantHue notBrightFirst = GetNotBright( first );
PlantHue notBrightSecond = GetNotBright( second );
public static bool IsBright(PlantHue plantHue)
{
return (plantHue & PlantHue.Bright) != PlantHue.None;
}
if ( notBrightFirst == notBrightSecond )
return first | PlantHue.Bright;
public static PlantHue GetNotBright(PlantHue plantHue)
{
return plantHue & ~PlantHue.Bright;
}
bool firstPrimary = IsPrimary( notBrightFirst );
bool secondPrimary = IsPrimary( notBrightSecond );
public static bool IsPrimary(PlantHue plantHue)
{
return plantHue == PlantHue.Red || plantHue == PlantHue.Blue || plantHue == PlantHue.Yellow;
}
if ( firstPrimary && secondPrimary )
return notBrightFirst | notBrightSecond;
public static PlantHue Cross(PlantHue first, PlantHue second)
{
if (!IsCrossable(first) || !IsCrossable(second))
return PlantHue.None;
if ( firstPrimary && !secondPrimary )
return notBrightFirst;
if (Utility.RandomDouble() < 0.01)
return Utility.RandomBool() ? PlantHue.Black : PlantHue.White;
if ( !firstPrimary && secondPrimary )
return notBrightSecond;
if (first == PlantHue.Plain || second == PlantHue.Plain)
return PlantHue.Plain;
return notBrightFirst & notBrightSecond;
}
PlantHue notBrightFirst = GetNotBright(first);
PlantHue notBrightSecond = GetNotBright(second);
public int Hue { get; }
if (notBrightFirst == notBrightSecond)
return first | PlantHue.Bright;
public int Name { get; }
bool firstPrimary = IsPrimary(notBrightFirst);
bool secondPrimary = IsPrimary(notBrightSecond);
public PlantHue PlantHue { get; }
if (firstPrimary && secondPrimary)
return notBrightFirst | notBrightSecond;
public int GumpHue { get; }
if (firstPrimary && !secondPrimary)
return notBrightFirst;
private PlantHueInfo( int hue, int name, PlantHue plantHue ) : this( hue, name, plantHue, hue )
{
}
if (!firstPrimary && secondPrimary)
return notBrightSecond;
private PlantHueInfo( int hue, int name, PlantHue plantHue, int gumpHue )
{
Hue = hue;
Name = name;
PlantHue = plantHue;
GumpHue = gumpHue;
}
return notBrightFirst & notBrightSecond;
}
public bool IsCrossable()
{
return IsCrossable( PlantHue );
}
public bool IsCrossable()
{
return IsCrossable(PlantHue);
}
public bool IsBright()
{
return IsBright( PlantHue );
}
public bool IsBright()
{
return IsBright(PlantHue);
}
public PlantHue GetNotBright()
{
return GetNotBright( PlantHue );
}
public PlantHue GetNotBright()
{
return GetNotBright(PlantHue);
}
public bool IsPrimary()
{
return IsPrimary( PlantHue );
}
}
}
public bool IsPrimary()
{
return IsPrimary(PlantHue);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -2,32 +2,31 @@ using Server.Targeting;
namespace Server.Engines.Plants
{
public class PlantPourTarget : Target
{
private PlantItem m_Plant;
public class PlantPourTarget : Target
{
private PlantItem m_Plant;
public PlantPourTarget( PlantItem plant ) : base( 3, true, TargetFlags.None )
{
m_Plant = plant;
}
public PlantPourTarget(PlantItem plant) : base(3, true, TargetFlags.None)
{
m_Plant = plant;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( !m_Plant.Deleted && from.InRange( m_Plant.GetWorldLocation(), 3 ) && targeted is Item item )
{
m_Plant.Pour( from, item );
}
}
protected override void OnTarget(Mobile from, object targeted)
{
if (!m_Plant.Deleted && from.InRange(m_Plant.GetWorldLocation(), 3) && targeted is Item item)
m_Plant.Pour(from, item);
}
protected override void OnTargetFinish( Mobile from )
{
if ( !m_Plant.Deleted && m_Plant.PlantStatus < PlantStatus.DecorativePlant && from.InRange( m_Plant.GetWorldLocation(), 3 ) && m_Plant.IsUsableBy( from ) )
{
if ( from.HasGump( typeof( MainPlantGump ) ) )
from.CloseGump( typeof( MainPlantGump ) );
protected override void OnTargetFinish(Mobile from)
{
if (!m_Plant.Deleted && m_Plant.PlantStatus < PlantStatus.DecorativePlant &&
from.InRange(m_Plant.GetWorldLocation(), 3) && m_Plant.IsUsableBy(from))
{
if (from.HasGump(typeof(MainPlantGump)))
from.CloseGump(typeof(MainPlantGump));
from.SendGump( new MainPlantGump( m_Plant ) );
}
}
}
}
from.SendGump(new MainPlantGump(m_Plant));
}
}
}
}

View file

@ -3,47 +3,46 @@ using Server.Items;
namespace Server.Engines.Plants
{
public class PlantResourceInfo
{
private static PlantResourceInfo[] m_ResourceList = {
new PlantResourceInfo( PlantType.ElephantEarPlant, PlantHue.BrightRed, typeof( RedLeaves ) ),
new PlantResourceInfo( PlantType.PonytailPalm, PlantHue.BrightRed, typeof( RedLeaves ) ),
new PlantResourceInfo( PlantType.CenturyPlant, PlantHue.BrightRed, typeof( RedLeaves ) ),
new PlantResourceInfo( PlantType.Poppies, PlantHue.BrightOrange, typeof( OrangePetals ) ),
new PlantResourceInfo( PlantType.Bulrushes, PlantHue.BrightOrange, typeof( OrangePetals ) ),
new PlantResourceInfo( PlantType.PampasGrass, PlantHue.BrightOrange, typeof( OrangePetals ) ),
new PlantResourceInfo( PlantType.SnakePlant, PlantHue.BrightGreen, typeof( GreenThorns ) ),
new PlantResourceInfo( PlantType.BarrelCactus, PlantHue.BrightGreen, typeof( GreenThorns ) ),
new PlantResourceInfo( PlantType.CocoaTree, PlantHue.Plain, typeof( CocoaPulp ) )
};
public class PlantResourceInfo
{
private static PlantResourceInfo[] m_ResourceList =
{
new PlantResourceInfo(PlantType.ElephantEarPlant, PlantHue.BrightRed, typeof(RedLeaves)),
new PlantResourceInfo(PlantType.PonytailPalm, PlantHue.BrightRed, typeof(RedLeaves)),
new PlantResourceInfo(PlantType.CenturyPlant, PlantHue.BrightRed, typeof(RedLeaves)),
new PlantResourceInfo(PlantType.Poppies, PlantHue.BrightOrange, typeof(OrangePetals)),
new PlantResourceInfo(PlantType.Bulrushes, PlantHue.BrightOrange, typeof(OrangePetals)),
new PlantResourceInfo(PlantType.PampasGrass, PlantHue.BrightOrange, typeof(OrangePetals)),
new PlantResourceInfo(PlantType.SnakePlant, PlantHue.BrightGreen, typeof(GreenThorns)),
new PlantResourceInfo(PlantType.BarrelCactus, PlantHue.BrightGreen, typeof(GreenThorns)),
new PlantResourceInfo(PlantType.CocoaTree, PlantHue.Plain, typeof(CocoaPulp))
};
public static PlantResourceInfo GetInfo( PlantType plantType, PlantHue plantHue )
{
foreach ( PlantResourceInfo info in m_ResourceList )
{
if ( info.PlantType == plantType && info.PlantHue == plantHue )
return info;
}
private PlantResourceInfo(PlantType plantType, PlantHue plantHue, Type resourceType)
{
PlantType = plantType;
PlantHue = plantHue;
ResourceType = resourceType;
}
return null;
}
public PlantType PlantType{ get; }
public PlantType PlantType { get; }
public PlantHue PlantHue{ get; }
public PlantHue PlantHue { get; }
public Type ResourceType{ get; }
public Type ResourceType { get; }
public static PlantResourceInfo GetInfo(PlantType plantType, PlantHue plantHue)
{
foreach (PlantResourceInfo info in m_ResourceList)
if (info.PlantType == plantType && info.PlantHue == plantHue)
return info;
private PlantResourceInfo( PlantType plantType, PlantHue plantHue, Type resourceType )
{
PlantType = plantType;
PlantHue = plantHue;
ResourceType = resourceType;
}
return null;
}
public Item CreateResource()
{
return (Item)Activator.CreateInstance( ResourceType );
}
}
}
public Item CreateResource()
{
return (Item)Activator.CreateInstance(ResourceType);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,350 +1,372 @@
namespace Server.Engines.Plants
{
public enum PlantType
{
CampionFlowers,
Poppies,
Snowdrops,
Bulrushes,
Lilies,
PampasGrass,
Rushes,
ElephantEarPlant,
Fern,
PonytailPalm,
SmallPalm,
CenturyPlant,
WaterPlant,
SnakePlant,
PricklyPearCactus,
BarrelCactus,
TribarrelCactus,
CommonGreenBonsai,
CommonPinkBonsai,
UncommonGreenBonsai,
UncommonPinkBonsai,
RareGreenBonsai,
RarePinkBonsai,
ExceptionalBonsai,
ExoticBonsai,
Cactus,
FlaxFlowers,
FoxgloveFlowers,
HopsEast,
OrfluerFlowers,
CypressTwisted,
HedgeShort,
JuniperBush,
SnowdropPatch,
Cattails,
PoppyPatch,
SpiderTree,
WaterLily,
CypressStraight,
HedgeTall,
HopsSouth,
SugarCanes,
CocoaTree
}
public enum PlantType
{
CampionFlowers,
Poppies,
Snowdrops,
Bulrushes,
Lilies,
PampasGrass,
Rushes,
ElephantEarPlant,
Fern,
PonytailPalm,
SmallPalm,
CenturyPlant,
WaterPlant,
SnakePlant,
PricklyPearCactus,
BarrelCactus,
TribarrelCactus,
CommonGreenBonsai,
CommonPinkBonsai,
UncommonGreenBonsai,
UncommonPinkBonsai,
RareGreenBonsai,
RarePinkBonsai,
ExceptionalBonsai,
ExoticBonsai,
Cactus,
FlaxFlowers,
FoxgloveFlowers,
HopsEast,
OrfluerFlowers,
CypressTwisted,
HedgeShort,
JuniperBush,
SnowdropPatch,
Cattails,
PoppyPatch,
SpiderTree,
WaterLily,
CypressStraight,
HedgeTall,
HopsSouth,
SugarCanes,
CocoaTree
}
public enum PlantCategory
{
Default,
Common = 1063335, //
Uncommon = 1063336, //
Rare = 1063337, // Bonsai
Exceptional = 1063341, //
Exotic = 1063342, //
Peculiar = 1080528,
Fragrant = 1080529
}
public enum PlantCategory
{
Default,
Common = 1063335, //
Uncommon = 1063336, //
Rare = 1063337, // Bonsai
Exceptional = 1063341, //
Exotic = 1063342, //
Peculiar = 1080528,
Fragrant = 1080529
}
public class PlantTypeInfo
{
private static PlantTypeInfo[] m_Table = {
new PlantTypeInfo( 0xC83, 0, 0, PlantType.CampionFlowers, false, true, true, true, PlantCategory.Default ),
new PlantTypeInfo( 0xC86, 0, 0, PlantType.Poppies, false, true, true, true, PlantCategory.Default ),
new PlantTypeInfo( 0xC88, 0, 10, PlantType.Snowdrops, false, true, true, true, PlantCategory.Default ),
new PlantTypeInfo( 0xC94, -15, 0, PlantType.Bulrushes, false, true, true, true, PlantCategory.Default ),
new PlantTypeInfo( 0xC8B, 0, 0, PlantType.Lilies, false, true, true, true, PlantCategory.Default ),
new PlantTypeInfo( 0xCA5, -8, 0, PlantType.PampasGrass, false, true, true, true, PlantCategory.Default ),
new PlantTypeInfo( 0xCA7, -10, 0, PlantType.Rushes, false, true, true, true, PlantCategory.Default ),
new PlantTypeInfo( 0xC97, -20, 0, PlantType.ElephantEarPlant, true, false, true, true, PlantCategory.Default ),
new PlantTypeInfo( 0xC9F, -20, 0, PlantType.Fern, false, false, true, true, PlantCategory.Default ),
new PlantTypeInfo( 0xCA6, -16, -5, PlantType.PonytailPalm, false, false, true, true, PlantCategory.Default ),
new PlantTypeInfo( 0xC9C, -5, -10, PlantType.SmallPalm, false, false, true, true, PlantCategory.Default ),
new PlantTypeInfo( 0xD31, 0, -27, PlantType.CenturyPlant, true, false, true, true, PlantCategory.Default ),
new PlantTypeInfo( 0xD04, 0, 10, PlantType.WaterPlant, true, false, true, true, PlantCategory.Default ),
new PlantTypeInfo( 0xCA9, 0, 0, PlantType.SnakePlant, true, false, true, true, PlantCategory.Default ),
new PlantTypeInfo( 0xD2C, 0, 10, PlantType.PricklyPearCactus, false, false, true, true, PlantCategory.Default ),
new PlantTypeInfo( 0xD26, 0, 10, PlantType.BarrelCactus, false, false, true, true, PlantCategory.Default ),
new PlantTypeInfo( 0xD27, 0, 10, PlantType.TribarrelCactus, false, false, true, true, PlantCategory.Default ),
new PlantTypeInfo( 0x28DC, -5, 5, PlantType.CommonGreenBonsai, true, false, false, false, PlantCategory.Common ),
new PlantTypeInfo( 0x28DF, -5, 5, PlantType.CommonPinkBonsai, true, false, false, false, PlantCategory.Common ),
new PlantTypeInfo( 0x28DD, -5, 5, PlantType.UncommonGreenBonsai, true, false, false, false, PlantCategory.Uncommon ),
new PlantTypeInfo( 0x28E0, -5, 5, PlantType.UncommonPinkBonsai, true, false, false, false, PlantCategory.Uncommon ),
new PlantTypeInfo( 0x28DE, -5, 5, PlantType.RareGreenBonsai, true, false, false, false, PlantCategory.Rare ),
new PlantTypeInfo( 0x28E1, -5, 5, PlantType.RarePinkBonsai, true, false, false, false, PlantCategory.Rare ),
new PlantTypeInfo( 0x28E2, -5, 5, PlantType.ExceptionalBonsai, true, false, false, false, PlantCategory.Exceptional ),
new PlantTypeInfo( 0x28E3, -5, 5, PlantType.ExoticBonsai, true, false, false, false, PlantCategory.Exotic ),
new PlantTypeInfo( 0x0D25, 0, 0, PlantType.Cactus, false, false, false, false, PlantCategory.Peculiar ),
new PlantTypeInfo( 0x1A9A, 5, 10, PlantType.FlaxFlowers, false, true, false, false, PlantCategory.Peculiar ),
new PlantTypeInfo( 0x0C84, 0, 0, PlantType.FoxgloveFlowers, false, true, false, false, PlantCategory.Peculiar ),
new PlantTypeInfo( 0x1A9F, 5, -25, PlantType.HopsEast, false, false, false, false, PlantCategory.Peculiar ),
new PlantTypeInfo( 0x0CC1, 0, 0, PlantType.OrfluerFlowers, false, true, false, false, PlantCategory.Peculiar ),
new PlantTypeInfo( 0x0CFE, -45, -30, PlantType.CypressTwisted, false, false, false, false, PlantCategory.Peculiar ),
new PlantTypeInfo( 0x0C8F, 0, 0, PlantType.HedgeShort, false, false, false, false, PlantCategory.Peculiar ),
new PlantTypeInfo( 0x0CC8, 0, 0, PlantType.JuniperBush, true, false, false, false, PlantCategory.Peculiar ),
new PlantTypeInfo( 0x0C8E, -20, 0, PlantType.SnowdropPatch, false, true, false, false, PlantCategory.Peculiar ),
new PlantTypeInfo( 0x0CB7, 0, 0, PlantType.Cattails, false, false, false, false, PlantCategory.Peculiar ),
new PlantTypeInfo( 0x0CBE, -20, 0, PlantType.PoppyPatch, false, true, false, false, PlantCategory.Peculiar ),
new PlantTypeInfo( 0x0CC9, 0, 0, PlantType.SpiderTree, false, false, false, false, PlantCategory.Peculiar ),
new PlantTypeInfo( 0x0DC1, -5, 15, PlantType.WaterLily, false, true, false, false, PlantCategory.Peculiar ),
new PlantTypeInfo( 0x0CFB, -45, -30, PlantType.CypressStraight, false, false, false, false, PlantCategory.Peculiar ),
new PlantTypeInfo( 0x0DB8, 0, -20, PlantType.HedgeTall, false, false, false, false, PlantCategory.Peculiar ),
new PlantTypeInfo( 0x1AA1, 10, -25, PlantType.HopsSouth, false, false, false, false, PlantCategory.Peculiar ),
new PlantTypeInfo( 0x246C, -25, -20, PlantType.SugarCanes, false, false, false, false, PlantCategory.Peculiar, 1114898, 1114898, 1094702, 1094703, 1095221, 1113715 ),
new PlantTypeInfo( 0xC9E, -40, -30, PlantType.CocoaTree, false, false, false, true, PlantCategory.Fragrant, 1080536, 1080536, 1080534, 1080531, 1080533, 1113716 )
};
public class PlantTypeInfo
{
private static PlantTypeInfo[] m_Table =
{
new PlantTypeInfo(0xC83, 0, 0, PlantType.CampionFlowers, false, true, true, true, PlantCategory.Default),
new PlantTypeInfo(0xC86, 0, 0, PlantType.Poppies, false, true, true, true, PlantCategory.Default),
new PlantTypeInfo(0xC88, 0, 10, PlantType.Snowdrops, false, true, true, true, PlantCategory.Default),
new PlantTypeInfo(0xC94, -15, 0, PlantType.Bulrushes, false, true, true, true, PlantCategory.Default),
new PlantTypeInfo(0xC8B, 0, 0, PlantType.Lilies, false, true, true, true, PlantCategory.Default),
new PlantTypeInfo(0xCA5, -8, 0, PlantType.PampasGrass, false, true, true, true, PlantCategory.Default),
new PlantTypeInfo(0xCA7, -10, 0, PlantType.Rushes, false, true, true, true, PlantCategory.Default),
new PlantTypeInfo(0xC97, -20, 0, PlantType.ElephantEarPlant, true, false, true, true, PlantCategory.Default),
new PlantTypeInfo(0xC9F, -20, 0, PlantType.Fern, false, false, true, true, PlantCategory.Default),
new PlantTypeInfo(0xCA6, -16, -5, PlantType.PonytailPalm, false, false, true, true, PlantCategory.Default),
new PlantTypeInfo(0xC9C, -5, -10, PlantType.SmallPalm, false, false, true, true, PlantCategory.Default),
new PlantTypeInfo(0xD31, 0, -27, PlantType.CenturyPlant, true, false, true, true, PlantCategory.Default),
new PlantTypeInfo(0xD04, 0, 10, PlantType.WaterPlant, true, false, true, true, PlantCategory.Default),
new PlantTypeInfo(0xCA9, 0, 0, PlantType.SnakePlant, true, false, true, true, PlantCategory.Default),
new PlantTypeInfo(0xD2C, 0, 10, PlantType.PricklyPearCactus, false, false, true, true, PlantCategory.Default),
new PlantTypeInfo(0xD26, 0, 10, PlantType.BarrelCactus, false, false, true, true, PlantCategory.Default),
new PlantTypeInfo(0xD27, 0, 10, PlantType.TribarrelCactus, false, false, true, true, PlantCategory.Default),
new PlantTypeInfo(0x28DC, -5, 5, PlantType.CommonGreenBonsai, true, false, false, false, PlantCategory.Common),
new PlantTypeInfo(0x28DF, -5, 5, PlantType.CommonPinkBonsai, true, false, false, false, PlantCategory.Common),
new PlantTypeInfo(0x28DD, -5, 5, PlantType.UncommonGreenBonsai, true, false, false, false,
PlantCategory.Uncommon),
new PlantTypeInfo(0x28E0, -5, 5, PlantType.UncommonPinkBonsai, true, false, false, false,
PlantCategory.Uncommon),
new PlantTypeInfo(0x28DE, -5, 5, PlantType.RareGreenBonsai, true, false, false, false, PlantCategory.Rare),
new PlantTypeInfo(0x28E1, -5, 5, PlantType.RarePinkBonsai, true, false, false, false, PlantCategory.Rare),
new PlantTypeInfo(0x28E2, -5, 5, PlantType.ExceptionalBonsai, true, false, false, false,
PlantCategory.Exceptional),
new PlantTypeInfo(0x28E3, -5, 5, PlantType.ExoticBonsai, true, false, false, false, PlantCategory.Exotic),
new PlantTypeInfo(0x0D25, 0, 0, PlantType.Cactus, false, false, false, false, PlantCategory.Peculiar),
new PlantTypeInfo(0x1A9A, 5, 10, PlantType.FlaxFlowers, false, true, false, false, PlantCategory.Peculiar),
new PlantTypeInfo(0x0C84, 0, 0, PlantType.FoxgloveFlowers, false, true, false, false, PlantCategory.Peculiar),
new PlantTypeInfo(0x1A9F, 5, -25, PlantType.HopsEast, false, false, false, false, PlantCategory.Peculiar),
new PlantTypeInfo(0x0CC1, 0, 0, PlantType.OrfluerFlowers, false, true, false, false, PlantCategory.Peculiar),
new PlantTypeInfo(0x0CFE, -45, -30, PlantType.CypressTwisted, false, false, false, false,
PlantCategory.Peculiar),
new PlantTypeInfo(0x0C8F, 0, 0, PlantType.HedgeShort, false, false, false, false, PlantCategory.Peculiar),
new PlantTypeInfo(0x0CC8, 0, 0, PlantType.JuniperBush, true, false, false, false, PlantCategory.Peculiar),
new PlantTypeInfo(0x0C8E, -20, 0, PlantType.SnowdropPatch, false, true, false, false, PlantCategory.Peculiar),
new PlantTypeInfo(0x0CB7, 0, 0, PlantType.Cattails, false, false, false, false, PlantCategory.Peculiar),
new PlantTypeInfo(0x0CBE, -20, 0, PlantType.PoppyPatch, false, true, false, false, PlantCategory.Peculiar),
new PlantTypeInfo(0x0CC9, 0, 0, PlantType.SpiderTree, false, false, false, false, PlantCategory.Peculiar),
new PlantTypeInfo(0x0DC1, -5, 15, PlantType.WaterLily, false, true, false, false, PlantCategory.Peculiar),
new PlantTypeInfo(0x0CFB, -45, -30, PlantType.CypressStraight, false, false, false, false,
PlantCategory.Peculiar),
new PlantTypeInfo(0x0DB8, 0, -20, PlantType.HedgeTall, false, false, false, false, PlantCategory.Peculiar),
new PlantTypeInfo(0x1AA1, 10, -25, PlantType.HopsSouth, false, false, false, false, PlantCategory.Peculiar),
new PlantTypeInfo(0x246C, -25, -20, PlantType.SugarCanes, false, false, false, false, PlantCategory.Peculiar,
1114898, 1114898, 1094702, 1094703, 1095221, 1113715),
new PlantTypeInfo(0xC9E, -40, -30, PlantType.CocoaTree, false, false, false, true, PlantCategory.Fragrant,
1080536, 1080536, 1080534, 1080531, 1080533, 1113716)
};
public static PlantTypeInfo GetInfo( PlantType plantType )
{
int index = (int)plantType;
private int m_PlantLabelDecorative;
private int m_PlantLabelFullGrown;
private int m_PlantLabelPlant;
if ( index >= 0 && index < m_Table.Length )
return m_Table[index];
return m_Table[0];
}
// Cliloc overrides
private int m_PlantLabelSeed;
private int m_SeedLabel;
private int m_SeedLabelPlural;
public static PlantType RandomFirstGeneration()
{
switch ( Utility.Random( 3 ) )
{
case 0: return PlantType.CampionFlowers;
case 1: return PlantType.Fern;
default: return PlantType.TribarrelCactus;
}
}
private PlantTypeInfo(int itemID, int offsetX, int offsetY, PlantType plantType, bool containsPlant, bool flowery,
bool crossable, bool reproduces, PlantCategory plantCategory)
: this(itemID, offsetX, offsetY, plantType, containsPlant, flowery, crossable, reproduces, plantCategory, -1, -1,
-1, -1, -1, -1)
{
}
public static PlantType RandomPeculiarGroupOne()
{
switch ( Utility.Random( 6 ) )
{
case 0: return PlantType.Cactus;
case 1: return PlantType.FlaxFlowers;
case 2: return PlantType.FoxgloveFlowers;
case 3: return PlantType.HopsEast;
case 4: return PlantType.CocoaTree;
default: return PlantType.OrfluerFlowers;
}
}
private PlantTypeInfo(int itemID, int offsetX, int offsetY, PlantType plantType, bool containsPlant, bool flowery,
bool crossable, bool reproduces, PlantCategory plantCategory, int plantLabelSeed, int plantLabelPlant,
int plantLabelFullGrown, int plantLabelDecorative, int seedLabel, int seedLabelPlural)
{
ItemID = itemID;
OffsetX = offsetX;
OffsetY = offsetY;
PlantType = plantType;
ContainsPlant = containsPlant;
Flowery = flowery;
Crossable = crossable;
Reproduces = reproduces;
PlantCategory = plantCategory;
m_PlantLabelSeed = plantLabelSeed;
m_PlantLabelPlant = plantLabelPlant;
m_PlantLabelFullGrown = plantLabelFullGrown;
m_PlantLabelDecorative = plantLabelDecorative;
m_SeedLabel = seedLabel;
m_SeedLabelPlural = seedLabelPlural;
}
public static PlantType RandomPeculiarGroupTwo()
{
switch ( Utility.Random( 5 ) )
{
case 0: return PlantType.CypressTwisted;
case 1: return PlantType.HedgeShort;
case 2: return PlantType.JuniperBush;
case 3: return PlantType.CocoaTree;
default: return PlantType.SnowdropPatch;
}
}
public int ItemID{ get; }
public static PlantType RandomPeculiarGroupThree()
{
switch ( Utility.Random( 5 ) )
{
case 0: return PlantType.Cattails;
case 1: return PlantType.PoppyPatch;
case 2: return PlantType.SpiderTree;
case 3: return PlantType.CocoaTree;
default: return PlantType.WaterLily;
}
}
public int OffsetX{ get; }
public static PlantType RandomPeculiarGroupFour()
{
switch ( Utility.Random( 5 ) )
{
case 0: return PlantType.CypressStraight;
case 1: return PlantType.HedgeTall;
case 2: return PlantType.HopsSouth;
case 3: return PlantType.CocoaTree;
default: return PlantType.SugarCanes;
}
}
public int OffsetY{ get; }
public static PlantType RandomBonsai( double increaseRatio )
{
/* Chances of each plant type are equal to the chances of the previous plant type * increaseRatio:
* E.g.:
* chances_of_uncommon = chances_of_common * increaseRatio
* chances_of_rare = chances_of_uncommon * increaseRatio
* ...
*
* If increaseRatio < 1 -> rare plants are actually rarer than the others
* If increaseRatio > 1 -> rare plants are actually more common than the others (it might be the case with certain monsters)
*
* If a plant type (common, uncommon, ...) has 2 different colors, they have the same chances:
* chances_of_green_common = chances_of_pink_common = chances_of_common / 2
* ...
*/
public PlantType PlantType{ get; }
double k1 = increaseRatio >= 0.0 ? increaseRatio : 0.0;
double k2 = k1 * k1;
double k3 = k2 * k1;
double k4 = k3 * k1;
public PlantCategory PlantCategory{ get; }
double exp1 = k1 + 1.0;
double exp2 = k2 + exp1;
double exp3 = k3 + exp2;
double exp4 = k4 + exp3;
public int Name => ItemID < 0x4000 ? 1020000 + ItemID : 1078872 + ItemID;
double rand = Utility.RandomDouble();
public bool ContainsPlant{ get; }
if ( rand < 0.5 / exp4 )
return PlantType.CommonGreenBonsai;
if ( rand < 1.0 / exp4 )
return PlantType.CommonPinkBonsai;
if ( rand < (k1 * 0.5 + 1.0) / exp4 )
return PlantType.UncommonGreenBonsai;
if ( rand < exp1 / exp4 )
return PlantType.UncommonPinkBonsai;
if ( rand < (k2 * 0.5 + exp1) / exp4 )
return PlantType.RareGreenBonsai;
if ( rand < exp2 / exp4 )
return PlantType.RarePinkBonsai;
if ( rand < exp3 / exp4 )
return PlantType.ExceptionalBonsai;
return PlantType.ExoticBonsai;
}
public bool Flowery{ get; }
public static bool IsCrossable( PlantType plantType )
{
return GetInfo( plantType ).Crossable;
}
public bool Crossable{ get; }
public static PlantType Cross( PlantType first, PlantType second )
{
if ( !IsCrossable( first ) || !IsCrossable( second ) )
return PlantType.CampionFlowers;
public bool Reproduces{ get; }
int firstIndex = (int)first;
int secondIndex = (int)second;
public static PlantTypeInfo GetInfo(PlantType plantType)
{
int index = (int)plantType;
if ( firstIndex + 1 == secondIndex || firstIndex == secondIndex + 1 )
return Utility.RandomBool() ? first : second;
return (PlantType)( (firstIndex + secondIndex) / 2 );
}
if (index >= 0 && index < m_Table.Length)
return m_Table[index];
return m_Table[0];
}
public static bool CanReproduce( PlantType plantType )
{
return GetInfo( plantType ).Reproduces;
}
public static PlantType RandomFirstGeneration()
{
switch (Utility.Random(3))
{
case 0: return PlantType.CampionFlowers;
case 1: return PlantType.Fern;
default: return PlantType.TribarrelCactus;
}
}
public int GetPlantLabelSeed( PlantHueInfo hueInfo )
{
if ( m_PlantLabelSeed != -1 )
return m_PlantLabelSeed;
public static PlantType RandomPeculiarGroupOne()
{
switch (Utility.Random(6))
{
case 0: return PlantType.Cactus;
case 1: return PlantType.FlaxFlowers;
case 2: return PlantType.FoxgloveFlowers;
case 3: return PlantType.HopsEast;
case 4: return PlantType.CocoaTree;
default: return PlantType.OrfluerFlowers;
}
}
return hueInfo.IsBright() ? 1061887 : 1061888; // a ~1_val~ of ~2_val~ dirt with a ~3_val~ [bright] ~4_val~ ~5_val~ ~6_val~
}
public static PlantType RandomPeculiarGroupTwo()
{
switch (Utility.Random(5))
{
case 0: return PlantType.CypressTwisted;
case 1: return PlantType.HedgeShort;
case 2: return PlantType.JuniperBush;
case 3: return PlantType.CocoaTree;
default: return PlantType.SnowdropPatch;
}
}
public int GetPlantLabelPlant( PlantHueInfo hueInfo )
{
if ( m_PlantLabelPlant != -1 )
return m_PlantLabelPlant;
public static PlantType RandomPeculiarGroupThree()
{
switch (Utility.Random(5))
{
case 0: return PlantType.Cattails;
case 1: return PlantType.PoppyPatch;
case 2: return PlantType.SpiderTree;
case 3: return PlantType.CocoaTree;
default: return PlantType.WaterLily;
}
}
if ( ContainsPlant )
return hueInfo.IsBright() ? 1060832 : 1060831; // a ~1_val~ of ~2_val~ dirt with a ~3_val~ [bright] ~4_val~ ~5_val~
return hueInfo.IsBright() ? 1061887 : 1061888; // a ~1_val~ of ~2_val~ dirt with a ~3_val~ [bright] ~4_val~ ~5_val~ ~6_val~
}
public static PlantType RandomPeculiarGroupFour()
{
switch (Utility.Random(5))
{
case 0: return PlantType.CypressStraight;
case 1: return PlantType.HedgeTall;
case 2: return PlantType.HopsSouth;
case 3: return PlantType.CocoaTree;
default: return PlantType.SugarCanes;
}
}
public int GetPlantLabelFullGrown( PlantHueInfo hueInfo )
{
if ( m_PlantLabelFullGrown != -1 )
return m_PlantLabelFullGrown;
public static PlantType RandomBonsai(double increaseRatio)
{
/* Chances of each plant type are equal to the chances of the previous plant type * increaseRatio:
* E.g.:
* chances_of_uncommon = chances_of_common * increaseRatio
* chances_of_rare = chances_of_uncommon * increaseRatio
* ...
*
* If increaseRatio < 1 -> rare plants are actually rarer than the others
* If increaseRatio > 1 -> rare plants are actually more common than the others (it might be the case with certain monsters)
*
* If a plant type (common, uncommon, ...) has 2 different colors, they have the same chances:
* chances_of_green_common = chances_of_pink_common = chances_of_common / 2
* ...
*/
if ( ContainsPlant )
return hueInfo.IsBright() ? 1061891 : 1061889; // a ~1_HEALTH~ [bright] ~2_COLOR~ ~3_NAME~
return hueInfo.IsBright() ? 1061892 : 1061890; // a ~1_HEALTH~ [bright] ~2_COLOR~ ~3_NAME~ plant
}
double k1 = increaseRatio >= 0.0 ? increaseRatio : 0.0;
double k2 = k1 * k1;
double k3 = k2 * k1;
double k4 = k3 * k1;
public int GetPlantLabelDecorative( PlantHueInfo hueInfo )
{
if ( m_PlantLabelDecorative != -1 )
return m_PlantLabelDecorative;
double exp1 = k1 + 1.0;
double exp2 = k2 + exp1;
double exp3 = k3 + exp2;
double exp4 = k4 + exp3;
return hueInfo.IsBright() ? 1074267 : 1070973; // a decorative [bright] ~1_COLOR~ ~2_TYPE~
}
double rand = Utility.RandomDouble();
public int GetSeedLabel( PlantHueInfo hueInfo )
{
if ( m_SeedLabel != -1 )
return m_SeedLabel;
if (rand < 0.5 / exp4)
return PlantType.CommonGreenBonsai;
if (rand < 1.0 / exp4)
return PlantType.CommonPinkBonsai;
if (rand < (k1 * 0.5 + 1.0) / exp4)
return PlantType.UncommonGreenBonsai;
if (rand < exp1 / exp4)
return PlantType.UncommonPinkBonsai;
if (rand < (k2 * 0.5 + exp1) / exp4)
return PlantType.RareGreenBonsai;
if (rand < exp2 / exp4)
return PlantType.RarePinkBonsai;
if (rand < exp3 / exp4)
return PlantType.ExceptionalBonsai;
return PlantType.ExoticBonsai;
}
return hueInfo.IsBright() ? 1061918 : 1061917; // [bright] ~1_COLOR~ ~2_TYPE~ seed
}
public static bool IsCrossable(PlantType plantType)
{
return GetInfo(plantType).Crossable;
}
public int GetSeedLabelPlural( PlantHueInfo hueInfo )
{
if ( m_SeedLabelPlural != -1 )
return m_SeedLabelPlural;
public static PlantType Cross(PlantType first, PlantType second)
{
if (!IsCrossable(first) || !IsCrossable(second))
return PlantType.CampionFlowers;
return hueInfo.IsBright() ? 1113493 : 1113492; // ~1_amount~ [bright] ~2_color~ ~3_type~ seeds
}
int firstIndex = (int)first;
int secondIndex = (int)second;
// Cliloc overrides
private int m_PlantLabelSeed;
private int m_PlantLabelPlant;
private int m_PlantLabelFullGrown;
private int m_PlantLabelDecorative;
private int m_SeedLabel;
private int m_SeedLabelPlural;
if (firstIndex + 1 == secondIndex || firstIndex == secondIndex + 1)
return Utility.RandomBool() ? first : second;
return (PlantType)((firstIndex + secondIndex) / 2);
}
public int ItemID { get; }
public static bool CanReproduce(PlantType plantType)
{
return GetInfo(plantType).Reproduces;
}
public int OffsetX { get; }
public int GetPlantLabelSeed(PlantHueInfo hueInfo)
{
if (m_PlantLabelSeed != -1)
return m_PlantLabelSeed;
public int OffsetY { get; }
return
hueInfo.IsBright()
? 1061887
: 1061888; // a ~1_val~ of ~2_val~ dirt with a ~3_val~ [bright] ~4_val~ ~5_val~ ~6_val~
}
public PlantType PlantType { get; }
public int GetPlantLabelPlant(PlantHueInfo hueInfo)
{
if (m_PlantLabelPlant != -1)
return m_PlantLabelPlant;
public PlantCategory PlantCategory { get; }
if (ContainsPlant)
return
hueInfo.IsBright()
? 1060832
: 1060831; // a ~1_val~ of ~2_val~ dirt with a ~3_val~ [bright] ~4_val~ ~5_val~
return
hueInfo.IsBright()
? 1061887
: 1061888; // a ~1_val~ of ~2_val~ dirt with a ~3_val~ [bright] ~4_val~ ~5_val~ ~6_val~
}
public int Name => ( ItemID < 0x4000 ) ? 1020000 + ItemID : 1078872 + ItemID;
public int GetPlantLabelFullGrown(PlantHueInfo hueInfo)
{
if (m_PlantLabelFullGrown != -1)
return m_PlantLabelFullGrown;
public bool ContainsPlant { get; }
if (ContainsPlant)
return hueInfo.IsBright() ? 1061891 : 1061889; // a ~1_HEALTH~ [bright] ~2_COLOR~ ~3_NAME~
return hueInfo.IsBright() ? 1061892 : 1061890; // a ~1_HEALTH~ [bright] ~2_COLOR~ ~3_NAME~ plant
}
public bool Flowery { get; }
public int GetPlantLabelDecorative(PlantHueInfo hueInfo)
{
if (m_PlantLabelDecorative != -1)
return m_PlantLabelDecorative;
public bool Crossable { get; }
return hueInfo.IsBright() ? 1074267 : 1070973; // a decorative [bright] ~1_COLOR~ ~2_TYPE~
}
public bool Reproduces { get; }
public int GetSeedLabel(PlantHueInfo hueInfo)
{
if (m_SeedLabel != -1)
return m_SeedLabel;
private PlantTypeInfo( int itemID, int offsetX, int offsetY, PlantType plantType, bool containsPlant, bool flowery, bool crossable, bool reproduces, PlantCategory plantCategory )
: this( itemID, offsetX, offsetY, plantType, containsPlant, flowery, crossable, reproduces, plantCategory, -1, -1, -1, -1, -1, -1 )
{
}
return hueInfo.IsBright() ? 1061918 : 1061917; // [bright] ~1_COLOR~ ~2_TYPE~ seed
}
private PlantTypeInfo( int itemID, int offsetX, int offsetY, PlantType plantType, bool containsPlant, bool flowery, bool crossable, bool reproduces, PlantCategory plantCategory, int plantLabelSeed, int plantLabelPlant, int plantLabelFullGrown, int plantLabelDecorative, int seedLabel, int seedLabelPlural )
{
ItemID = itemID;
OffsetX = offsetX;
OffsetY = offsetY;
PlantType = plantType;
ContainsPlant = containsPlant;
Flowery = flowery;
Crossable = crossable;
Reproduces = reproduces;
PlantCategory = plantCategory;
m_PlantLabelSeed = plantLabelSeed;
m_PlantLabelPlant = plantLabelPlant;
m_PlantLabelFullGrown = plantLabelFullGrown;
m_PlantLabelDecorative = plantLabelDecorative;
m_SeedLabel = seedLabel;
m_SeedLabelPlural = seedLabelPlural;
}
}
}
public int GetSeedLabelPlural(PlantHueInfo hueInfo)
{
if (m_SeedLabelPlural != -1)
return m_SeedLabelPlural;
return hueInfo.IsBright() ? 1113493 : 1113492; // ~1_amount~ [bright] ~2_color~ ~3_type~ seeds
}
}
}

View file

@ -2,87 +2,90 @@ using Server.Targeting;
namespace Server.Engines.Plants
{
public class PollinateTarget : Target
{
private PlantItem m_Plant;
public class PollinateTarget : Target
{
private PlantItem m_Plant;
public PollinateTarget( PlantItem plant ) : base( 3, true, TargetFlags.None )
{
m_Plant = plant;
}
public PollinateTarget(PlantItem plant) : base(3, true, TargetFlags.None)
{
m_Plant = plant;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( !m_Plant.Deleted && m_Plant.PlantStatus < PlantStatus.DecorativePlant && from.InRange( m_Plant.GetWorldLocation(), 3 ) )
{
if ( !m_Plant.IsUsableBy( from ) )
{
m_Plant.LabelTo( from, 1061856 ); // You must have the item in your backpack or locked down in order to use it.
}
else if ( !m_Plant.IsCrossable )
{
m_Plant.LabelTo( from, 1053050 ); // You cannot gather pollen from a mutated plant!
}
else if ( !m_Plant.PlantSystem.PollenProducing )
{
m_Plant.LabelTo( from, 1053051 ); // You cannot gather pollen from a plant in this stage of development!
}
else if ( m_Plant.PlantSystem.Health < PlantHealth.Healthy )
{
m_Plant.LabelTo( from, 1053052 ); // You cannot gather pollen from an unhealthy plant!
}
else
{
if ( !(targeted is PlantItem targ) || targ.PlantStatus >= PlantStatus.DecorativePlant || targ.PlantStatus <= PlantStatus.BowlOfDirt )
{
m_Plant.LabelTo( from, 1053070 ); // You can only pollinate other specially grown plants!
}
else if ( !targ.IsUsableBy( from ) )
{
targ.LabelTo( from, 1061856 ); // You must have the item in your backpack or locked down in order to use it.
}
else if ( !targ.IsCrossable )
{
targ.LabelTo( from, 1053073 ); // You cannot cross-pollinate with a mutated plant!
}
else if ( !targ.PlantSystem.PollenProducing )
{
targ.LabelTo( from, 1053074 ); // This plant is not in the flowering stage. You cannot pollinate it!
}
else if ( targ.PlantSystem.Health < PlantHealth.Healthy )
{
targ.LabelTo( from, 1053075 ); // You cannot pollinate an unhealthy plant!
}
else if ( targ.PlantSystem.Pollinated )
{
targ.LabelTo( from, 1053072 ); // This plant has already been pollinated!
}
else if ( targ == m_Plant )
{
targ.PlantSystem.Pollinated = true;
targ.PlantSystem.SeedType = m_Plant.PlantType;
targ.PlantSystem.SeedHue = m_Plant.PlantHue;
protected override void OnTarget(Mobile from, object targeted)
{
if (!m_Plant.Deleted && m_Plant.PlantStatus < PlantStatus.DecorativePlant &&
from.InRange(m_Plant.GetWorldLocation(), 3))
{
if (!m_Plant.IsUsableBy(from))
{
m_Plant.LabelTo(from,
1061856); // You must have the item in your backpack or locked down in order to use it.
}
else if (!m_Plant.IsCrossable)
{
m_Plant.LabelTo(from, 1053050); // You cannot gather pollen from a mutated plant!
}
else if (!m_Plant.PlantSystem.PollenProducing)
{
m_Plant.LabelTo(from, 1053051); // You cannot gather pollen from a plant in this stage of development!
}
else if (m_Plant.PlantSystem.Health < PlantHealth.Healthy)
{
m_Plant.LabelTo(from, 1053052); // You cannot gather pollen from an unhealthy plant!
}
else
{
if (!(targeted is PlantItem targ) || targ.PlantStatus >= PlantStatus.DecorativePlant ||
targ.PlantStatus <= PlantStatus.BowlOfDirt)
{
m_Plant.LabelTo(from, 1053070); // You can only pollinate other specially grown plants!
}
else if (!targ.IsUsableBy(from))
{
targ.LabelTo(from,
1061856); // You must have the item in your backpack or locked down in order to use it.
}
else if (!targ.IsCrossable)
{
targ.LabelTo(from, 1053073); // You cannot cross-pollinate with a mutated plant!
}
else if (!targ.PlantSystem.PollenProducing)
{
targ.LabelTo(from, 1053074); // This plant is not in the flowering stage. You cannot pollinate it!
}
else if (targ.PlantSystem.Health < PlantHealth.Healthy)
{
targ.LabelTo(from, 1053075); // You cannot pollinate an unhealthy plant!
}
else if (targ.PlantSystem.Pollinated)
{
targ.LabelTo(from, 1053072); // This plant has already been pollinated!
}
else if (targ == m_Plant)
{
targ.PlantSystem.Pollinated = true;
targ.PlantSystem.SeedType = m_Plant.PlantType;
targ.PlantSystem.SeedHue = m_Plant.PlantHue;
targ.LabelTo( from, 1053071 ); // You pollinate the plant with its own pollen.
}
else
{
targ.PlantSystem.Pollinated = true;
targ.PlantSystem.SeedType = PlantTypeInfo.Cross( m_Plant.PlantType, targ.PlantType );
targ.PlantSystem.SeedHue = PlantHueInfo.Cross( m_Plant.PlantHue, targ.PlantHue );
targ.LabelTo(from, 1053071); // You pollinate the plant with its own pollen.
}
else
{
targ.PlantSystem.Pollinated = true;
targ.PlantSystem.SeedType = PlantTypeInfo.Cross(m_Plant.PlantType, targ.PlantType);
targ.PlantSystem.SeedHue = PlantHueInfo.Cross(m_Plant.PlantHue, targ.PlantHue);
targ.LabelTo( from, 1053076 ); // You successfully cross-pollinate the plant.
}
}
}
}
targ.LabelTo(from, 1053076); // You successfully cross-pollinate the plant.
}
}
}
}
protected override void OnTargetFinish( Mobile from )
{
if ( !m_Plant.Deleted && m_Plant.PlantStatus < PlantStatus.DecorativePlant && m_Plant.PlantStatus != PlantStatus.BowlOfDirt && from.InRange( m_Plant.GetWorldLocation(), 3 ) && m_Plant.IsUsableBy( from ) )
{
from.SendGump( new ReproductionGump( m_Plant ) );
}
}
}
}
protected override void OnTargetFinish(Mobile from)
{
if (!m_Plant.Deleted && m_Plant.PlantStatus < PlantStatus.DecorativePlant &&
m_Plant.PlantStatus != PlantStatus.BowlOfDirt && from.InRange(m_Plant.GetWorldLocation(), 3) &&
m_Plant.IsUsableBy(from)) from.SendGump(new ReproductionGump(m_Plant));
}
}
}

View file

@ -3,268 +3,261 @@ using Server.Network;
namespace Server.Engines.Plants
{
public class ReproductionGump : Gump
{
private PlantItem m_Plant;
public class ReproductionGump : Gump
{
private PlantItem m_Plant;
public ReproductionGump( PlantItem plant ) : base( 20, 20 )
{
m_Plant = plant;
public ReproductionGump(PlantItem plant) : base(20, 20)
{
m_Plant = plant;
DrawBackground();
DrawBackground();
AddButton( 70, 67, 0xD4, 0xD4, 1, GumpButtonType.Reply, 0 ); // Main menu
AddItem( 57, 65, 0x1600 );
AddButton(70, 67, 0xD4, 0xD4, 1, GumpButtonType.Reply, 0); // Main menu
AddItem(57, 65, 0x1600);
AddLabel( 108, 67, 0x835, "Reproduction" );
AddLabel(108, 67, 0x835, "Reproduction");
if ( m_Plant.PlantStatus == PlantStatus.Stage9 )
{
AddButton( 212, 67, 0xD4, 0xD4, 2, GumpButtonType.Reply, 0 ); // Set to decorative
AddItem( 202, 68, 0xC61 );
AddLabel( 216, 66, 0x21, "/" );
}
if (m_Plant.PlantStatus == PlantStatus.Stage9)
{
AddButton(212, 67, 0xD4, 0xD4, 2, GumpButtonType.Reply, 0); // Set to decorative
AddItem(202, 68, 0xC61);
AddLabel(216, 66, 0x21, "/");
}
AddButton( 80, 116, 0xD4, 0xD4, 3, GumpButtonType.Reply, 0 ); // Pollination
AddItem( 66, 117, 0x1AA2 );
AddPollinationState( 106, 116 );
AddButton(80, 116, 0xD4, 0xD4, 3, GumpButtonType.Reply, 0); // Pollination
AddItem(66, 117, 0x1AA2);
AddPollinationState(106, 116);
AddButton( 128, 116, 0xD4, 0xD4, 4, GumpButtonType.Reply, 0 ); // Resources
AddItem( 113, 120, 0x1021 );
AddResourcesState( 149, 116 );
AddButton(128, 116, 0xD4, 0xD4, 4, GumpButtonType.Reply, 0); // Resources
AddItem(113, 120, 0x1021);
AddResourcesState(149, 116);
AddButton( 177, 116, 0xD4, 0xD4, 5, GumpButtonType.Reply, 0 ); // Seeds
AddItem( 160, 121, 0xDCF );
AddSeedsState( 199, 116 );
AddButton(177, 116, 0xD4, 0xD4, 5, GumpButtonType.Reply, 0); // Seeds
AddItem(160, 121, 0xDCF);
AddSeedsState(199, 116);
AddButton( 70, 163, 0xD2, 0xD2, 6, GumpButtonType.Reply, 0 ); // Gather pollen
AddItem( 56, 164, 0x1AA2 );
AddButton(70, 163, 0xD2, 0xD2, 6, GumpButtonType.Reply, 0); // Gather pollen
AddItem(56, 164, 0x1AA2);
AddButton( 138, 163, 0xD2, 0xD2, 7, GumpButtonType.Reply, 0 ); // Gather resources
AddItem( 123, 167, 0x1021 );
AddButton(138, 163, 0xD2, 0xD2, 7, GumpButtonType.Reply, 0); // Gather resources
AddItem(123, 167, 0x1021);
AddButton( 212, 163, 0xD2, 0xD2, 8, GumpButtonType.Reply, 0 ); // Gather seeds
AddItem( 195, 168, 0xDCF );
}
AddButton(212, 163, 0xD2, 0xD2, 8, GumpButtonType.Reply, 0); // Gather seeds
AddItem(195, 168, 0xDCF);
}
private void DrawBackground()
{
AddBackground( 50, 50, 200, 150, 0xE10 );
private void DrawBackground()
{
AddBackground(50, 50, 200, 150, 0xE10);
AddImage( 60, 90, 0xE17 );
AddImage( 120, 90, 0xE17 );
AddImage(60, 90, 0xE17);
AddImage(120, 90, 0xE17);
AddImage( 60, 145, 0xE17 );
AddImage( 120, 145, 0xE17 );
AddImage(60, 145, 0xE17);
AddImage(120, 145, 0xE17);
AddItem( 45, 45, 0xCEF );
AddItem( 45, 118, 0xCF0 );
AddItem(45, 45, 0xCEF);
AddItem(45, 118, 0xCF0);
AddItem( 211, 45, 0xCEB );
AddItem( 211, 118, 0xCEC );
}
AddItem(211, 45, 0xCEB);
AddItem(211, 118, 0xCEC);
}
private void AddPollinationState( int x, int y )
{
PlantSystem system = m_Plant.PlantSystem;
private void AddPollinationState(int x, int y)
{
PlantSystem system = m_Plant.PlantSystem;
if ( !system.PollenProducing )
AddLabel( x, y, 0x35, "-" );
else if ( !system.Pollinated )
AddLabel( x, y, 0x21, "!" );
else
AddLabel( x, y, 0x3F, "+" );
}
if (!system.PollenProducing)
AddLabel(x, y, 0x35, "-");
else if (!system.Pollinated)
AddLabel(x, y, 0x21, "!");
else
AddLabel(x, y, 0x3F, "+");
}
private void AddResourcesState( int x, int y )
{
PlantResourceInfo resInfo = PlantResourceInfo.GetInfo( m_Plant.PlantType, m_Plant.PlantHue );
private void AddResourcesState(int x, int y)
{
PlantResourceInfo resInfo = PlantResourceInfo.GetInfo(m_Plant.PlantType, m_Plant.PlantHue);
PlantSystem system = m_Plant.PlantSystem;
int totalResources = system.AvailableResources + system.LeftResources;
PlantSystem system = m_Plant.PlantSystem;
int totalResources = system.AvailableResources + system.LeftResources;
if ( resInfo == null || totalResources == 0 )
{
AddLabel( x + 5, y, 0x21, "X" );
}
else
{
AddLabel( x, y, PlantHueInfo.GetInfo( m_Plant.PlantHue ).GumpHue,
$"{system.AvailableResources}/{totalResources}");
}
}
if (resInfo == null || totalResources == 0)
AddLabel(x + 5, y, 0x21, "X");
else
AddLabel(x, y, PlantHueInfo.GetInfo(m_Plant.PlantHue).GumpHue,
$"{system.AvailableResources}/{totalResources}");
}
private void AddSeedsState( int x, int y )
{
PlantSystem system = m_Plant.PlantSystem;
int totalSeeds = system.AvailableSeeds + system.LeftSeeds;
private void AddSeedsState(int x, int y)
{
PlantSystem system = m_Plant.PlantSystem;
int totalSeeds = system.AvailableSeeds + system.LeftSeeds;
if ( !m_Plant.Reproduces || totalSeeds == 0 )
{
AddLabel( x + 5, y, 0x21, "X" );
}
else
{
AddLabel( x, y, PlantHueInfo.GetInfo( system.SeedHue ).GumpHue,
$"{system.AvailableSeeds}/{totalSeeds}");
}
}
if (!m_Plant.Reproduces || totalSeeds == 0)
AddLabel(x + 5, y, 0x21, "X");
else
AddLabel(x, y, PlantHueInfo.GetInfo(system.SeedHue).GumpHue,
$"{system.AvailableSeeds}/{totalSeeds}");
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
public override void OnResponse(NetState sender, RelayInfo info)
{
Mobile from = sender.Mobile;
if ( info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant || m_Plant.PlantStatus == PlantStatus.BowlOfDirt )
return;
if (info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant ||
m_Plant.PlantStatus == PlantStatus.BowlOfDirt)
return;
if ( ( info.ButtonID >= 6 && info.ButtonID <= 8 ) && !from.InRange( m_Plant.GetWorldLocation(), 3 ) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3E9, 500446 ); // That is too far away.
return;
}
if ( !m_Plant.IsUsableBy( from ) )
{
m_Plant.LabelTo( from, 1061856 ); // You must have the item in your backpack or locked down in order to use it.
return;
}
if (info.ButtonID >= 6 && info.ButtonID <= 8 && !from.InRange(m_Plant.GetWorldLocation(), 3))
{
from.LocalOverheadMessage(MessageType.Regular, 0x3E9, 500446); // That is too far away.
return;
}
switch ( info.ButtonID )
{
case 1: // Main menu
{
from.SendGump( new MainPlantGump( m_Plant ) );
if (!m_Plant.IsUsableBy(from))
{
m_Plant.LabelTo(from, 1061856); // You must have the item in your backpack or locked down in order to use it.
return;
}
break;
}
case 2: // Set to decorative
{
if ( m_Plant.PlantStatus == PlantStatus.Stage9 )
{
from.SendGump( new SetToDecorativeGump( m_Plant ) );
}
switch (info.ButtonID)
{
case 1: // Main menu
{
from.SendGump(new MainPlantGump(m_Plant));
break;
}
case 3: // Pollination
{
from.Send( new DisplayHelpTopic( 67, true ) ); // POLLINATION STATE
break;
}
case 2: // Set to decorative
{
if (m_Plant.PlantStatus == PlantStatus.Stage9) from.SendGump(new SetToDecorativeGump(m_Plant));
from.SendGump( new ReproductionGump( m_Plant ) );
break;
}
case 3: // Pollination
{
from.Send(new DisplayHelpTopic(67, true)); // POLLINATION STATE
break;
}
case 4: // Resources
{
from.Send( new DisplayHelpTopic( 69, true ) ); // RESOURCE PRODUCTION
from.SendGump(new ReproductionGump(m_Plant));
from.SendGump( new ReproductionGump( m_Plant ) );
break;
}
case 4: // Resources
{
from.Send(new DisplayHelpTopic(69, true)); // RESOURCE PRODUCTION
break;
}
case 5: // Seeds
{
from.Send( new DisplayHelpTopic( 68, true ) ); // SEED PRODUCTION
from.SendGump(new ReproductionGump(m_Plant));
from.SendGump( new ReproductionGump( m_Plant ) );
break;
}
case 5: // Seeds
{
from.Send(new DisplayHelpTopic(68, true)); // SEED PRODUCTION
break;
}
case 6: // Gather pollen
{
if ( !m_Plant.IsCrossable )
{
m_Plant.LabelTo( from, 1053050 ); // You cannot gather pollen from a mutated plant!
}
else if ( !m_Plant.PlantSystem.PollenProducing )
{
m_Plant.LabelTo( from, 1053051 ); // You cannot gather pollen from a plant in this stage of development!
}
else if ( m_Plant.PlantSystem.Health < PlantHealth.Healthy )
{
m_Plant.LabelTo( from, 1053052 ); // You cannot gather pollen from an unhealthy plant!
}
else
{
from.Target = new PollinateTarget( m_Plant );
from.SendLocalizedMessage( 1053054 ); // Target the plant you wish to cross-pollinate to.
from.SendGump(new ReproductionGump(m_Plant));
break;
}
break;
}
case 6: // Gather pollen
{
if (!m_Plant.IsCrossable)
{
m_Plant.LabelTo(from, 1053050); // You cannot gather pollen from a mutated plant!
}
else if (!m_Plant.PlantSystem.PollenProducing)
{
m_Plant.LabelTo(from,
1053051); // You cannot gather pollen from a plant in this stage of development!
}
else if (m_Plant.PlantSystem.Health < PlantHealth.Healthy)
{
m_Plant.LabelTo(from, 1053052); // You cannot gather pollen from an unhealthy plant!
}
else
{
from.Target = new PollinateTarget(m_Plant);
from.SendLocalizedMessage(1053054); // Target the plant you wish to cross-pollinate to.
from.SendGump( new ReproductionGump( m_Plant ) );
break;
}
break;
}
case 7: // Gather resources
{
PlantResourceInfo resInfo = PlantResourceInfo.GetInfo( m_Plant.PlantType, m_Plant.PlantHue );
PlantSystem system = m_Plant.PlantSystem;
from.SendGump(new ReproductionGump(m_Plant));
if ( resInfo == null )
{
if ( m_Plant.IsCrossable )
m_Plant.LabelTo( from, 1053056 ); // This plant has no resources to gather!
else
m_Plant.LabelTo( from, 1053055 ); // Mutated plants do not produce resources!
}
else if ( system.AvailableResources == 0 )
{
m_Plant.LabelTo( from, 1053056 ); // This plant has no resources to gather!
}
else
{
Item resource = resInfo.CreateResource();
break;
}
case 7: // Gather resources
{
PlantResourceInfo resInfo = PlantResourceInfo.GetInfo(m_Plant.PlantType, m_Plant.PlantHue);
PlantSystem system = m_Plant.PlantSystem;
if ( from.PlaceInBackpack( resource ) )
{
system.AvailableResources--;
m_Plant.LabelTo( from, 1053059 ); // You gather resources from the plant.
}
else
{
resource.Delete();
m_Plant.LabelTo( from, 1053058 ); // You attempt to gather as many resources as you can hold, but your backpack is full.
}
}
if (resInfo == null)
{
if (m_Plant.IsCrossable)
m_Plant.LabelTo(from, 1053056); // This plant has no resources to gather!
else
m_Plant.LabelTo(from, 1053055); // Mutated plants do not produce resources!
}
else if (system.AvailableResources == 0)
{
m_Plant.LabelTo(from, 1053056); // This plant has no resources to gather!
}
else
{
Item resource = resInfo.CreateResource();
from.SendGump( new ReproductionGump( m_Plant ) );
if (from.PlaceInBackpack(resource))
{
system.AvailableResources--;
m_Plant.LabelTo(from, 1053059); // You gather resources from the plant.
}
else
{
resource.Delete();
m_Plant.LabelTo(from,
1053058); // You attempt to gather as many resources as you can hold, but your backpack is full.
}
}
break;
}
case 8: // Gather seeds
{
PlantSystem system = m_Plant.PlantSystem;
from.SendGump(new ReproductionGump(m_Plant));
if ( !m_Plant.Reproduces )
{
m_Plant.LabelTo( from, 1053060 ); // Mutated plants do not produce seeds!
}
else if ( system.AvailableSeeds == 0 )
{
m_Plant.LabelTo( from, 1053061 ); // This plant has no seeds to gather!
}
else
{
Seed seed = new Seed( system.SeedType, system.SeedHue, true );
break;
}
case 8: // Gather seeds
{
PlantSystem system = m_Plant.PlantSystem;
if ( from.PlaceInBackpack( seed ) )
{
system.AvailableSeeds--;
m_Plant.LabelTo( from, 1053063 ); // You gather seeds from the plant.
}
else
{
seed.Delete();
m_Plant.LabelTo( from, 1053062 ); // You attempt to gather as many seeds as you can hold, but your backpack is full.
}
}
if (!m_Plant.Reproduces)
{
m_Plant.LabelTo(from, 1053060); // Mutated plants do not produce seeds!
}
else if (system.AvailableSeeds == 0)
{
m_Plant.LabelTo(from, 1053061); // This plant has no seeds to gather!
}
else
{
Seed seed = new Seed(system.SeedType, system.SeedHue, true);
from.SendGump( new ReproductionGump( m_Plant ) );
if (from.PlaceInBackpack(seed))
{
system.AvailableSeeds--;
m_Plant.LabelTo(from, 1053063); // You gather seeds from the plant.
}
else
{
seed.Delete();
m_Plant.LabelTo(from,
1053062); // You attempt to gather as many seeds as you can hold, but your backpack is full.
}
}
break;
}
}
}
}
from.SendGump(new ReproductionGump(m_Plant));
break;
}
}
}
}
}

View file

@ -1,233 +1,227 @@
using System;
using Server.Targeting;
namespace Server.Engines.Plants
{
public class Seed : Item
{
private PlantType m_PlantType;
private PlantHue m_PlantHue;
private bool m_ShowType;
public class Seed : Item
{
private PlantHue m_PlantHue;
private PlantType m_PlantType;
private bool m_ShowType;
[CommandProperty( AccessLevel.GameMaster )]
public PlantType PlantType
{
get => m_PlantType;
set
{
m_PlantType = value;
InvalidateProperties();
}
}
[Constructible]
public Seed() : this(PlantTypeInfo.RandomFirstGeneration(), PlantHueInfo.RandomFirstGeneration(), false)
{
}
[CommandProperty( AccessLevel.GameMaster )]
public PlantHue PlantHue
{
get => m_PlantHue;
set
{
m_PlantHue = value;
Hue = PlantHueInfo.GetInfo( value ).Hue;
InvalidateProperties();
}
}
[Constructible]
public Seed(PlantType plantType, PlantHue plantHue, bool showType) : base(0xDCF)
{
Weight = 1.0;
Stackable = Core.SA;
[CommandProperty( AccessLevel.GameMaster )]
public bool ShowType
{
get => m_ShowType;
set
{
m_ShowType = value;
InvalidateProperties();
}
}
m_PlantType = plantType;
m_PlantHue = plantHue;
m_ShowType = showType;
public override int LabelNumber => 1060810; // seed
Hue = PlantHueInfo.GetInfo(plantHue).Hue;
}
public static Seed RandomBonsaiSeed()
{
return RandomBonsaiSeed( 0.5 );
}
public Seed(Serial serial) : base(serial)
{
}
public static Seed RandomBonsaiSeed( double increaseRatio )
{
return new Seed( PlantTypeInfo.RandomBonsai( increaseRatio ), PlantHue.Plain, false );
}
[CommandProperty(AccessLevel.GameMaster)]
public PlantType PlantType
{
get => m_PlantType;
set
{
m_PlantType = value;
InvalidateProperties();
}
}
public static Seed RandomPeculiarSeed( int group )
{
switch ( group )
{
case 1: return new Seed ( PlantTypeInfo.RandomPeculiarGroupOne(), PlantHue.Plain, false );
case 2: return new Seed ( PlantTypeInfo.RandomPeculiarGroupTwo(), PlantHue.Plain, false );
case 3: return new Seed ( PlantTypeInfo.RandomPeculiarGroupThree(), PlantHue.Plain, false );
default: return new Seed ( PlantTypeInfo.RandomPeculiarGroupFour(), PlantHue.Plain, false );
}
}
[CommandProperty(AccessLevel.GameMaster)]
public PlantHue PlantHue
{
get => m_PlantHue;
set
{
m_PlantHue = value;
Hue = PlantHueInfo.GetInfo(value).Hue;
InvalidateProperties();
}
}
[Constructible]
public Seed() : this( PlantTypeInfo.RandomFirstGeneration(), PlantHueInfo.RandomFirstGeneration(), false )
{
}
[CommandProperty(AccessLevel.GameMaster)]
public bool ShowType
{
get => m_ShowType;
set
{
m_ShowType = value;
InvalidateProperties();
}
}
[Constructible]
public Seed( PlantType plantType, PlantHue plantHue, bool showType ) : base( 0xDCF )
{
Weight = 1.0;
Stackable = Core.SA;
public override int LabelNumber => 1060810; // seed
m_PlantType = plantType;
m_PlantHue = plantHue;
m_ShowType = showType;
public override bool ForceShowProperties => ObjectPropertyList.Enabled;
Hue = PlantHueInfo.GetInfo( plantHue ).Hue;
}
public static Seed RandomBonsaiSeed()
{
return RandomBonsaiSeed(0.5);
}
public Seed( Serial serial ) : base( serial )
{
}
public static Seed RandomBonsaiSeed(double increaseRatio)
{
return new Seed(PlantTypeInfo.RandomBonsai(increaseRatio), PlantHue.Plain, false);
}
public override bool ForceShowProperties => ObjectPropertyList.Enabled;
public static Seed RandomPeculiarSeed(int group)
{
switch (group)
{
case 1: return new Seed(PlantTypeInfo.RandomPeculiarGroupOne(), PlantHue.Plain, false);
case 2: return new Seed(PlantTypeInfo.RandomPeculiarGroupTwo(), PlantHue.Plain, false);
case 3: return new Seed(PlantTypeInfo.RandomPeculiarGroupThree(), PlantHue.Plain, false);
default: return new Seed(PlantTypeInfo.RandomPeculiarGroupFour(), PlantHue.Plain, false);
}
}
private int GetLabel( out string args )
{
PlantTypeInfo typeInfo = PlantTypeInfo.GetInfo( m_PlantType );
PlantHueInfo hueInfo = PlantHueInfo.GetInfo( m_PlantHue );
private int GetLabel(out string args)
{
PlantTypeInfo typeInfo = PlantTypeInfo.GetInfo(m_PlantType);
PlantHueInfo hueInfo = PlantHueInfo.GetInfo(m_PlantHue);
int title;
int title;
if ( m_ShowType || typeInfo.PlantCategory == PlantCategory.Default )
title = hueInfo.Name;
else
title = (int)typeInfo.PlantCategory;
if (m_ShowType || typeInfo.PlantCategory == PlantCategory.Default)
title = hueInfo.Name;
else
title = (int)typeInfo.PlantCategory;
if ( Amount == 1 )
{
if ( m_ShowType )
{
args = $"#{title}\t#{typeInfo.Name}";
return typeInfo.GetSeedLabel( hueInfo );
}
if (Amount == 1)
{
if (m_ShowType)
{
args = $"#{title}\t#{typeInfo.Name}";
return typeInfo.GetSeedLabel(hueInfo);
}
args = $"#{title}";
return hueInfo.IsBright() ? 1060839 : 1060838; // [bright] ~1_val~ seed
}
args = $"#{title}";
return hueInfo.IsBright() ? 1060839 : 1060838; // [bright] ~1_val~ seed
}
if ( m_ShowType )
{
args = $"{Amount}\t#{title}\t#{typeInfo.Name}";
return typeInfo.GetSeedLabelPlural( hueInfo );
}
if (m_ShowType)
{
args = $"{Amount}\t#{title}\t#{typeInfo.Name}";
return typeInfo.GetSeedLabelPlural(hueInfo);
}
args = $"{Amount}\t#{title}";
return hueInfo.IsBright() ? 1113491 : 1113490; // ~1_amount~ [bright] ~2_val~ seeds
}
args = $"{Amount}\t#{title}";
return hueInfo.IsBright() ? 1113491 : 1113490; // ~1_amount~ [bright] ~2_val~ seeds
}
public override void AddNameProperty( ObjectPropertyList list )
{
string args;
list.Add( GetLabel( out args ), args );
}
public override void AddNameProperty(ObjectPropertyList list)
{
string args;
list.Add(GetLabel(out args), args);
}
public override void OnSingleClick( Mobile from )
{
string args;
LabelTo( from, GetLabel( out args ), args );
}
public override void OnSingleClick(Mobile from)
{
string args;
LabelTo(from, GetLabel(out args), args);
}
public override void OnDoubleClick( Mobile from )
{
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042664 ); // You must have the object in your backpack to use it.
return;
}
public override void OnDoubleClick(Mobile from)
{
if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042664); // You must have the object in your backpack to use it.
return;
}
from.Target = new InternalTarget( this );
LabelTo( from, 1061916 ); // Choose a bowl of dirt to plant this seed in.
}
from.Target = new InternalTarget(this);
LabelTo(from, 1061916); // Choose a bowl of dirt to plant this seed in.
}
public override bool StackWith( Mobile from, Item dropped, bool playSound )
{
return dropped is Seed other && other.PlantType == m_PlantType && other.PlantHue == m_PlantHue && other.ShowType == m_ShowType && base.StackWith( from, other, playSound );
}
public override bool StackWith(Mobile from, Item dropped, bool playSound)
{
return dropped is Seed other && other.PlantType == m_PlantType && other.PlantHue == m_PlantHue &&
other.ShowType == m_ShowType && base.StackWith(from, other, playSound);
}
public override void OnAfterDuped( Item newItem )
{
if ( !(newItem is Seed newSeed) )
return;
public override void OnAfterDuped(Item newItem)
{
if (!(newItem is Seed newSeed))
return;
newSeed.PlantType = m_PlantType;
newSeed.PlantHue = m_PlantHue;
newSeed.ShowType = m_ShowType;
}
newSeed.PlantType = m_PlantType;
newSeed.PlantHue = m_PlantHue;
newSeed.ShowType = m_ShowType;
}
private class InternalTarget : Target
{
private Seed m_Seed;
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
public InternalTarget( Seed seed ) : base( -1, false, TargetFlags.None )
{
m_Seed = seed;
CheckLOS = false;
}
writer.Write(2); // version
protected override void OnTarget( Mobile from, object targeted )
{
if ( m_Seed.Deleted )
return;
writer.Write((int)m_PlantType);
writer.Write((int)m_PlantHue);
writer.Write(m_ShowType);
}
if ( !m_Seed.IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042664 ); // You must have the object in your backpack to use it.
return;
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
if ( targeted is PlantItem plant )
{
plant.PlantSeed( from, m_Seed );
}
else if ( targeted is Item item )
{
item.LabelTo( from, 1061919 ); // You must use a seed on a bowl of dirt!
}
else
{
from.SendLocalizedMessage( 1061919 ); // You must use a seed on a bowl of dirt!
}
}
}
int version = reader.ReadInt();
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
m_PlantType = (PlantType)reader.ReadInt();
m_PlantHue = (PlantHue)reader.ReadInt();
m_ShowType = reader.ReadBool();
writer.Write( (int) 2 ); // version
if (Weight != 1.0)
Weight = 1.0;
writer.Write( (int) m_PlantType );
writer.Write( (int) m_PlantHue );
writer.Write( (bool) m_ShowType );
}
if (version < 1)
Stackable = Core.SA;
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
if (version < 2 && PlantHueInfo.IsCrossable(m_PlantHue))
m_PlantHue |= PlantHue.Reproduces;
}
int version = reader.ReadInt();
private class InternalTarget : Target
{
private Seed m_Seed;
m_PlantType = (PlantType)reader.ReadInt();
m_PlantHue = (PlantHue)reader.ReadInt();
m_ShowType = reader.ReadBool();
public InternalTarget(Seed seed) : base(-1, false, TargetFlags.None)
{
m_Seed = seed;
CheckLOS = false;
}
if ( Weight != 1.0 )
Weight = 1.0;
protected override void OnTarget(Mobile from, object targeted)
{
if (m_Seed.Deleted)
return;
if ( version < 1 )
Stackable = Core.SA;
if (!m_Seed.IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042664); // You must have the object in your backpack to use it.
return;
}
if ( version < 2 && PlantHueInfo.IsCrossable( m_PlantHue ) )
m_PlantHue |= PlantHue.Reproduces;
}
}
}
if (targeted is PlantItem plant)
plant.PlantSeed(from, m_Seed);
else if (targeted is Item item)
item.LabelTo(from, 1061919); // You must use a seed on a bowl of dirt!
else
from.SendLocalizedMessage(1061919); // You must use a seed on a bowl of dirt!
}
}
}
}

View file

@ -3,81 +3,82 @@ using Server.Network;
namespace Server.Engines.Plants
{
public class SetToDecorativeGump : Gump
{
private PlantItem m_Plant;
public class SetToDecorativeGump : Gump
{
private PlantItem m_Plant;
public SetToDecorativeGump( PlantItem plant ) : base( 20, 20 )
{
m_Plant = plant;
public SetToDecorativeGump(PlantItem plant) : base(20, 20)
{
m_Plant = plant;
DrawBackground();
DrawBackground();
AddLabel( 115, 85, 0x44, "Set plant" );
AddLabel( 82, 105, 0x44, "to decorative mode?" );
AddLabel(115, 85, 0x44, "Set plant");
AddLabel(82, 105, 0x44, "to decorative mode?");
AddButton( 98, 140, 0x47E, 0x480, 1, GumpButtonType.Reply, 0 ); // Cancel
AddButton(98, 140, 0x47E, 0x480, 1, GumpButtonType.Reply, 0); // Cancel
AddButton( 138, 141, 0xD2, 0xD2, 2, GumpButtonType.Reply, 0 ); // Help
AddLabel( 143, 141, 0x835, "?" );
AddButton(138, 141, 0xD2, 0xD2, 2, GumpButtonType.Reply, 0); // Help
AddLabel(143, 141, 0x835, "?");
AddButton( 168, 140, 0x481, 0x483, 3, GumpButtonType.Reply, 0 ); // Ok
}
AddButton(168, 140, 0x481, 0x483, 3, GumpButtonType.Reply, 0); // Ok
}
private void DrawBackground()
{
AddBackground( 50, 50, 200, 150, 0xE10 );
private void DrawBackground()
{
AddBackground(50, 50, 200, 150, 0xE10);
AddItem( 25, 45, 0xCEB );
AddItem( 25, 118, 0xCEC );
AddItem(25, 45, 0xCEB);
AddItem(25, 118, 0xCEC);
AddItem( 227, 45, 0xCEF );
AddItem( 227, 118, 0xCF0 );
}
AddItem(227, 45, 0xCEF);
AddItem(227, 118, 0xCF0);
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
public override void OnResponse(NetState sender, RelayInfo info)
{
Mobile from = sender.Mobile;
if ( info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus != PlantStatus.Stage9 )
return;
if ( info.ButtonID == 3 && !from.InRange( m_Plant.GetWorldLocation(), 3 ) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3E9, 500446 ); // That is too far away.
return;
}
if (info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus != PlantStatus.Stage9)
return;
if ( !m_Plant.IsUsableBy( from ) )
{
m_Plant.LabelTo( from, 1061856 ); // You must have the item in your backpack or locked down in order to use it.
return;
}
if (info.ButtonID == 3 && !from.InRange(m_Plant.GetWorldLocation(), 3))
{
from.LocalOverheadMessage(MessageType.Regular, 0x3E9, 500446); // That is too far away.
return;
}
switch ( info.ButtonID )
{
case 1: // Cancel
{
from.SendGump( new ReproductionGump( m_Plant ) );
if (!m_Plant.IsUsableBy(from))
{
m_Plant.LabelTo(from, 1061856); // You must have the item in your backpack or locked down in order to use it.
return;
}
break;
}
case 2: // Help
{
from.Send( new DisplayHelpTopic( 70, true ) ); // DECORATIVE MODE
switch (info.ButtonID)
{
case 1: // Cancel
{
from.SendGump(new ReproductionGump(m_Plant));
from.SendGump( new SetToDecorativeGump( m_Plant ) );
break;
}
case 2: // Help
{
from.Send(new DisplayHelpTopic(70, true)); // DECORATIVE MODE
break;
}
case 3: // Ok
{
m_Plant.PlantStatus = PlantStatus.DecorativePlant;
m_Plant.LabelTo( from, 1053077 ); // You prune the plant. This plant will no longer produce resources or seeds, but will require no upkeep.
from.SendGump(new SetToDecorativeGump(m_Plant));
break;
}
}
}
}
break;
}
case 3: // Ok
{
m_Plant.PlantStatus = PlantStatus.DecorativePlant;
m_Plant.LabelTo(from,
1053077); // You prune the plant. This plant will no longer produce resources or seeds, but will require no upkeep.
break;
}
}
}
}
}