This commit is contained in:
mark 2006-06-15 04:14:30 +00:00
commit 47711d616e
2644 changed files with 479454 additions and 0 deletions

View file

@ -0,0 +1,96 @@
using System;
using Server;
using Server.Mobiles;
using Server.Network;
using Server.Multis;
namespace Server.Items
{
public class BarkeepContract : Item
{
public override string DefaultName
{
get { return "a barkeep contract"; }
}
[Constructable]
public BarkeepContract() : base( 0x14F0 )
{
Weight = 1.0;
LootType = LootType.Blessed;
}
public BarkeepContract( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 ); //version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void OnDoubleClick( Mobile from )
{
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
else if ( from.AccessLevel >= AccessLevel.GameMaster )
{
from.SendLocalizedMessage( 503248 ); // Your godly powers allow you to place this vendor whereever you wish.
Mobile v = new PlayerBarkeeper( from, BaseHouse.FindHouseAt( from ) );
v.Direction = from.Direction & Direction.Mask;
v.MoveToWorld( from.Location, from.Map );
this.Delete();
}
else
{
BaseHouse house = BaseHouse.FindHouseAt( from );
if ( house == null || !house.IsOwner( from ) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, false, "You are not the full owner of this house." );
}
else if ( !house.CanPlaceNewBarkeep() )
{
from.SendLocalizedMessage( 1062490 ); // That action would exceed the maximum number of barkeeps for this house.
}
else
{
bool vendor, contract;
BaseHouse.IsThereVendor( from.Location, from.Map, out vendor, out contract );
if ( vendor )
{
from.SendLocalizedMessage( 1062677 ); // You cannot place a vendor or barkeep at this location.
}
else if ( contract )
{
from.SendLocalizedMessage( 1062678 ); // You cannot place a vendor or barkeep on top of a rental contract!
}
else
{
Mobile v = new PlayerBarkeeper( from, house );
v.Direction = from.Direction & Direction.Mask;
v.MoveToWorld( from.Location, from.Map );
this.Delete();
}
}
}
}
}
}

View file

@ -0,0 +1,102 @@
using System;
using Server.Network;
using Server.Prompts;
using Server.Items;
using Server.Targeting;
namespace Server.Items
{
public class ClothingBlessTarget : Target // Create our targeting class (which we derive from the base target class)
{
private ClothingBlessDeed m_Deed;
public ClothingBlessTarget( ClothingBlessDeed deed ) : base( 1, false, TargetFlags.None )
{
m_Deed = deed;
}
protected override void OnTarget( Mobile from, object target ) // Override the protected OnTarget() for our feature
{
if ( m_Deed.Deleted || m_Deed.RootParent != from )
return;
if ( target is BaseClothing )
{
BaseClothing item = (BaseClothing)target;
if ( item.LootType == LootType.Blessed || item.BlessedFor == from || (Mobile.InsuranceEnabled && item.Insured) ) // Check if its already newbied (blessed)
{
from.SendLocalizedMessage( 1045113 ); // That item is already blessed
}
else if ( item.LootType != LootType.Regular )
{
from.SendLocalizedMessage( 1045114 ); // You can not bless that item
}
else if ( !item.CanBeBlessed || item.RootParent != from )
{
from.SendLocalizedMessage( 500509 ); // You cannot bless that object
}
else
{
item.LootType = LootType.Blessed;
from.SendLocalizedMessage( 1010026 ); // You bless the item....
m_Deed.Delete(); // Delete the bless deed
}
}
else
{
from.SendLocalizedMessage( 500509 ); // You cannot bless that object
}
}
}
public class ClothingBlessDeed : Item // Create the item class which is derived from the base item class
{
public override string DefaultName
{
get { return "a clothing bless deed"; }
}
[Constructable]
public ClothingBlessDeed() : base( 0x14F0 )
{
Weight = 1.0;
LootType = LootType.Blessed;
}
public ClothingBlessDeed( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
LootType = LootType.Blessed;
int version = reader.ReadInt();
}
public override bool DisplayLootType{ get{ return false; } }
public override void OnDoubleClick( Mobile from ) // Override double click of the deed to call our target
{
if ( !IsChildOf( from.Backpack ) ) // Make sure its in their pack
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
else
{
from.SendLocalizedMessage( 1005018 ); // What would you like to bless? (Clothes Only)
from.Target = new ClothingBlessTarget( this ); // Call our target
}
}
}
}

View file

@ -0,0 +1,199 @@
using System;
using Server.Targeting;
using Server.Network;
namespace Server.Items
{
public interface ICommodity
{
string Description{ get; }
}
public class CommodityDeed : Item
{
private Item m_Commodity;
[CommandProperty( AccessLevel.GameMaster )]
public Item Commodity
{
get
{
return m_Commodity;
}
}
public bool SetCommodity( Item item )
{
InvalidateProperties();
if ( m_Commodity == null && item is ICommodity )
{
m_Commodity = item;
m_Commodity.Internalize();
InvalidateProperties();
return true;
}
else
{
return false;
}
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
writer.Write( m_Commodity );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 0:
{
m_Commodity = reader.ReadItem();
break;
}
}
}
public CommodityDeed( Item commodity ) : base( 0x14F0 )
{
Weight = 1.0;
Hue = 0x47;
m_Commodity = commodity;
LootType = LootType.Blessed;
}
[Constructable]
public CommodityDeed() : this( null )
{
}
public CommodityDeed( Serial serial ) : base( serial )
{
}
public override void OnDelete()
{
if ( m_Commodity != null )
m_Commodity.Delete();
base.OnDelete();
}
public override int LabelNumber{ get{ return m_Commodity == null ? 1047016 : 1047017; } }
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties( list );
if ( m_Commodity != null )
list.Add( 1060658, "#{0}\t{1}", m_Commodity.LabelNumber, m_Commodity.Amount ); // ~1_val~: ~2_val~
}
public override void OnSingleClick( Mobile from )
{
base.OnSingleClick( from );
if ( m_Commodity != null )
from.Send( new UnicodeMessage( Serial, ItemID, MessageType.Label, 0x3B2, 3, "ENU", "", ((ICommodity)m_Commodity).Description ) );
}
public override void OnDoubleClick( Mobile from )
{
int number;
BankBox box = from.BankBox;
if ( m_Commodity != null )
{
if ( box != null && IsChildOf( box ) )
{
number = 1047031; // The commodity has been redeemed.
box.DropItem( m_Commodity );
m_Commodity = null;
Delete();
}
else
{
number = 1047024; // To claim the resources ....
}
}
else if ( box == null || !IsChildOf( box ) )
{
number = 1047026; // That must be in your bank box to use it.
}
else
{
number = 1047029; // Target the commodity to fill this deed with.
from.Target = new InternalTarget( this );
}
from.SendLocalizedMessage( number );
}
private class InternalTarget : Target
{
private CommodityDeed m_Deed;
public InternalTarget( CommodityDeed deed ) : base( 3, false, TargetFlags.None )
{
m_Deed = deed;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( m_Deed.Deleted )
return;
int number;
if ( m_Deed.Commodity != null )
{
number = 1047028; // The commodity deed has already been filled.
}
else if ( targeted is Item )
{
BankBox box = from.BankBox;
if ( box != null && m_Deed.IsChildOf( box ) && ((Item)targeted).IsChildOf( box ) )
{
if ( m_Deed.SetCommodity( (Item) targeted ) )
{
number = 1047030; // The commodity deed has been filled.
}
else
{
number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
}
}
else
{
number = 1047026; // That must be in your bank box to use it.
}
}
else
{
number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
}
from.SendLocalizedMessage( number );
}
}
}
}

View file

@ -0,0 +1,149 @@
using System;
using Server;
using Server.Mobiles;
using Server.Targeting;
using Server.Engines.Craft;
namespace Server.Items
{
[TypeAlias( "Server.Items.DragonBarding" )]
public class DragonBardingDeed : Item, ICraftable
{
private bool m_Exceptional;
private Mobile m_Crafter;
private CraftResource m_Resource;
public override int LabelNumber{ get{ return m_Exceptional ? 1053181 : 1053012; } } // dragon barding deed
[CommandProperty( AccessLevel.GameMaster )]
public Mobile Crafter{ get{ return m_Crafter; } set{ m_Crafter = value; InvalidateProperties(); } }
[CommandProperty( AccessLevel.GameMaster )]
public bool Exceptional{ get{ return m_Exceptional; } set{ m_Exceptional = value; InvalidateProperties(); } }
[CommandProperty( AccessLevel.GameMaster )]
public CraftResource Resource{ get{ return m_Resource; } set{ m_Resource = value; Hue = CraftResources.GetHue( value ); InvalidateProperties(); } }
public DragonBardingDeed() : base( 0x14F0 )
{
Weight = 1.0;
}
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
if ( m_Exceptional && m_Crafter != null )
list.Add( 1050043, m_Crafter.Name ); // crafted by ~1_NAME~
}
public override void OnDoubleClick( Mobile from )
{
if ( IsChildOf( from.Backpack ) )
{
from.BeginTarget( 6, false, TargetFlags.None, new TargetCallback( OnTarget ) );
from.SendLocalizedMessage( 1053024 ); // Select the swamp dragon you wish to place the barding on.
}
else
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
}
public virtual void OnTarget( Mobile from, object obj )
{
if ( Deleted )
return;
SwampDragon pet = obj as SwampDragon;
if ( pet == null || pet.HasBarding )
{
from.SendLocalizedMessage( 1053025 ); // That is not an unarmored swamp dragon.
}
else if ( !pet.Controlled || pet.ControlMaster != from )
{
from.SendLocalizedMessage( 1053026 ); // You can only put barding on a tamed swamp dragon that you own.
}
else if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1060640 ); // The item must be in your backpack to use it.
}
else
{
pet.BardingExceptional = this.Exceptional;
pet.BardingCrafter = this.Crafter;
pet.BardingHP = pet.BardingMaxHP;
pet.BardingResource = this.Resource;
pet.HasBarding = true;
pet.Hue = this.Hue;
this.Delete();
from.SendLocalizedMessage( 1053027 ); // You place the barding on your swamp dragon. Use a bladed item on your dragon to remove the armor.
}
}
public DragonBardingDeed( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 1 ); // version
writer.Write( (bool) m_Exceptional );
writer.Write( (Mobile) m_Crafter );
writer.Write( (int) m_Resource );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 1:
case 0:
{
m_Exceptional = reader.ReadBool();
m_Crafter = reader.ReadMobile();
if ( version < 1 )
reader.ReadInt();
m_Resource = (CraftResource) reader.ReadInt();
break;
}
}
}
#region ICraftable Members
public int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue )
{
Exceptional = ( quality >= 2 );
if ( makersMark )
Crafter = from;
Type resourceType = typeRes;
if ( resourceType == null )
resourceType = craftItem.Ressources.GetAt( 0 ).ItemType;
Resource = CraftResources.GetFromType( resourceType );
CraftContext context = craftSystem.GetContext( from );
if ( context != null && context.DoNotColor )
Hue = 0;
return quality;
}
#endregion
}
}

View file

@ -0,0 +1,147 @@
using System;
using Server.Mobiles;
using Server.Network;
using Server.Prompts;
using Server.Items;
using Server.Targeting;
using Server.Gumps;
namespace Server.Items
{
public class HairRestylingDeed : Item
{
public override int LabelNumber{ get{ return 1041061; } } // a coupon for a free hair restyling
[Constructable]
public HairRestylingDeed() : base( 0x14F0 )
{
Weight = 1.0;
LootType = LootType.Blessed;
}
public HairRestylingDeed( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void OnDoubleClick( Mobile from )
{
if ( from.Race == Race.Elf )
{
from.SendMessage( "This isn't implemented for elves yet. Sorry!" );
return;
}
if ( !IsChildOf( from.Backpack ) )
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
else
from.SendGump( new InternalGump( from, this ) );
}
private class InternalGump : Gump
{
private Mobile m_From;
private HairRestylingDeed m_Deed;
public InternalGump( Mobile from, HairRestylingDeed deed ) : base( 50, 50 )
{
m_From = from;
m_Deed = deed;
from.CloseGump( typeof( InternalGump ) );
AddBackground( 100, 10, 400, 385, 0xA28 );
AddHtmlLocalized( 100, 25, 400, 35, 1013008, false, false );
AddButton( 175, 340, 0xFA5, 0xFA7, 0x0, GumpButtonType.Reply, 0 ); // CANCEL
AddHtmlLocalized( 210, 342, 90, 35, 1011012, false, false );// <CENTER>HAIRSTYLE SELECTION MENU</center>
AddBackground( 220, 60, 50, 50, 0xA3C );
AddBackground( 220, 115, 50, 50, 0xA3C );
AddBackground( 220, 170, 50, 50, 0xA3C );
AddBackground( 220, 225, 50, 50, 0xA3C );
AddBackground( 425, 60, 50, 50, 0xA3C );
AddBackground( 425, 115, 50, 50, 0xA3C );
AddBackground( 425, 170, 50, 50, 0xA3C );
AddBackground( 425, 225, 50, 50, 0xA3C );
AddBackground( 425, 280, 50, 50, 0xA3C );
AddHtmlLocalized( 150, 75, 80, 35, 1011052, false, false ); // Short
AddHtmlLocalized( 150, 130, 80, 35, 1011053, false, false ); // Long
AddHtmlLocalized( 150, 185, 80, 35, 1011054, false, false ); // Ponytail
AddHtmlLocalized( 150, 240, 80, 35, 1011055, false, false ); // Mohawk
AddHtmlLocalized( 355, 75, 80, 35, 1011047, false, false ); // Pageboy
AddHtmlLocalized( 355, 130, 80, 35, 1011048, false, false ); // Receding
AddHtmlLocalized( 355, 185, 80, 35, 1011049, false, false ); // 2-tails
AddHtmlLocalized( 355, 240, 80, 35, 1011050, false, false ); // Topknot
AddHtmlLocalized( 355, 295, 80, 35, 1011064, false, false ); // Bald
AddImage( 153, 20, 0xC60C );
AddImage( 153, 65, 0xED24 );
AddImage( 153, 120, 0xED1E );
AddImage( 153, 185, 0xC60F );
AddImage( 358, 18, 0xED26 );
AddImage( 358, 75, 0xEDE5 );
AddImage( 358, 120, 0xED23 );
AddImage( 362, 190, 0xED29 );
AddButton( 118, 73, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0 );
AddButton( 118, 128, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0 );
AddButton( 118, 183, 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0 );
AddButton( 118, 238, 0xFA5, 0xFA7, 5, GumpButtonType.Reply, 0 );
AddButton( 323, 73, 0xFA5, 0xFA7, 6, GumpButtonType.Reply, 0 );
AddButton( 323, 128, 0xFA5, 0xFA7, 7, GumpButtonType.Reply, 0 );
AddButton( 323, 183, 0xFA5, 0xFA7, 8, GumpButtonType.Reply, 0 );
AddButton( 323, 238, 0xFA5, 0xFA7, 9, GumpButtonType.Reply, 0 );
AddButton( 323, 292, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 );
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( m_Deed.Deleted )
return;
if ( info.ButtonID > 0 )
{
int itemID = 0;
switch ( info.ButtonID )
{
case 2: itemID = 0x203B; break;
case 3: itemID = 0x203C; break;
case 4: itemID = 0x203D; break;
case 5: itemID = 0x2044; break;
case 6: itemID = 0x2045; break;
case 7: itemID = m_From.Female ? 0x2046 : 0x2048; break;
case 8: itemID = 0x2049; break;
case 9: itemID = 0x204A; break;
}
if ( m_From is PlayerMobile )
{
PlayerMobile pm = (PlayerMobile)m_From;
pm.SetHairMods( -1, -1 ); // clear any hairmods (disguise kit, incognito)
}
m_From.HairItemID = itemID;
m_Deed.Delete();
}
}
}
}
}

View file

@ -0,0 +1,161 @@
using System;
using Server;
using Server.Items;
using Server.Gumps;
using Server.Multis;
using Server.Network;
using Server.Targeting;
namespace Server.Items
{
public class HolidayTreeDeed : Item
{
public override int LabelNumber{ get{ return 1041116; } } // a deed for a holiday tree
[Constructable]
public HolidayTreeDeed() : base( 0x14F0 )
{
Hue = 0x488;
Weight = 1.0;
LootType = LootType.Blessed;
}
public HolidayTreeDeed( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
LootType = LootType.Blessed;
}
public bool ValidatePlacement( Mobile from, Point3D loc )
{
if ( from.AccessLevel >= AccessLevel.GameMaster )
return true;
if ( !from.InRange( this.GetWorldLocation(), 1 ) )
{
from.SendLocalizedMessage( 500446 ); // That is too far away.
return false;
}
if ( DateTime.Now.Month != 12 )
{
from.SendLocalizedMessage( 1005700 ); // You will have to wait till next December to put your tree back up for display.
return false;
}
Map map = from.Map;
if ( map == null )
return false;
BaseHouse house = BaseHouse.FindHouseAt( loc, map, 20 );
if ( house == null || !house.IsFriend( from ) )
{
from.SendLocalizedMessage( 1005701 ); // The holiday tree can only be placed in your house.
return false;
}
if ( !map.CanFit( loc, 20 ) )
{
from.SendLocalizedMessage( 500269 ); // You cannot build that there.
return false;
}
return true;
}
public void BeginPlace( Mobile from, HolidayTreeType type )
{
from.BeginTarget( -1, true, TargetFlags.None, new TargetStateCallback( Placement_OnTarget ), type );
}
public void Placement_OnTarget( Mobile from, object targeted, object state )
{
IPoint3D p = targeted as IPoint3D;
if ( p == null )
return;
Point3D loc = new Point3D( p );
if ( p is StaticTarget )
loc.Z -= TileData.ItemTable[((StaticTarget)p).ItemID & 0x3FFF].CalcHeight; /* NOTE: OSI does not properly normalize Z positioning here.
* A side affect is that you can only place on floors (due to the CanFit call).
* That functionality may be desired. And so, it's included in this script.
*/
if ( ValidatePlacement( from, loc ) )
EndPlace( from, (HolidayTreeType) state, loc );
}
public void EndPlace( Mobile from, HolidayTreeType type, Point3D loc )
{
this.Delete();
new HolidayTree( from, type, loc );
}
public override void OnDoubleClick( Mobile from )
{
from.CloseGump( typeof( HolidayTreeChoiceGump ) );
from.SendGump( new HolidayTreeChoiceGump( from, this ) );
}
}
public class HolidayTreeChoiceGump : Gump
{
private Mobile m_From;
private HolidayTreeDeed m_Deed;
public HolidayTreeChoiceGump( Mobile from, HolidayTreeDeed deed ) : base( 200, 200 )
{
m_From = from;
m_Deed = deed;
AddPage( 0 );
AddBackground( 0, 0, 220, 120, 5054 );
AddBackground( 10, 10, 200, 100, 3000 );
AddButton( 20, 35, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 35, 145, 25, 1018322, false, false ); // Classic
AddButton( 20, 65, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 65, 145, 25, 1018321, false, false ); // Modern
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( m_Deed.Deleted )
return;
switch ( info.ButtonID )
{
case 1:
{
m_Deed.BeginPlace( m_From, HolidayTreeType.Classic );
break;
}
case 2:
{
m_Deed.BeginPlace( m_From, HolidayTreeType.Modern );
break;
}
}
}
}
}

View file

@ -0,0 +1,46 @@
using System;
using Server.Network;
using Server.Prompts;
using Server.Items;
namespace Server.Items
{
public class NameChangeDeed : Item
{
public override string DefaultName
{
get { return "a name change deed"; }
}
[Constructable]
public NameChangeDeed() : base( 0x14F0 )
{
base.Weight = 1.0;
}
public NameChangeDeed( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void OnDoubleClick( Mobile from )
{
// Do namechange
}
}
}

View file

@ -0,0 +1,198 @@
using System;
using Server.Network;
using Server.Prompts;
using Server.Items;
using Server.Targeting;
using Server.Gumps;
namespace Server.Items
{
public class NewPlayerTicket : Item
{
private Mobile m_Owner;
[CommandProperty( AccessLevel.GameMaster )]
public Mobile Owner
{
get{ return m_Owner; }
set{ m_Owner = value; }
}
public override int LabelNumber{ get{ return 1062094; } } // a young player ticket
[Constructable]
public NewPlayerTicket() : base( 0x14EF )
{
Weight = 1.0;
LootType = LootType.Blessed;
}
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
list.Add( 1041492 ); // This is half a prize ticket! Double-click this ticket and target any other ticket marked NEW PLAYER and get a prize! This ticket will only work for YOU, so don't give it away!
}
public override bool DisplayLootType{ get{ return false; } }
public NewPlayerTicket( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
writer.Write( (Mobile) m_Owner );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 0:
{
m_Owner = reader.ReadMobile();
break;
}
}
if ( Name == "a young player ticket" )
Name = null;
}
public override void OnDoubleClick( Mobile from )
{
if ( from != m_Owner )
{
from.SendLocalizedMessage( 501926 ); // This isn't your ticket! Shame on you! You have to use YOUR ticket.
}
else if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
else
{
from.SendLocalizedMessage( 501927 ); // Target any other ticket marked NEW PLAYER to win a prize.
from.Target = new InternalTarget( this );
}
}
private class InternalTarget : Target
{
private NewPlayerTicket m_Ticket;
public InternalTarget( NewPlayerTicket ticket ) : base( 2, false, TargetFlags.None )
{
m_Ticket = ticket;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted == m_Ticket )
{
from.SendLocalizedMessage( 501928 ); // You can't target the same ticket!
}
else if ( targeted is NewPlayerTicket )
{
NewPlayerTicket theirTicket = targeted as NewPlayerTicket;
Mobile them = theirTicket.m_Owner;
if ( them == null || them.Deleted )
{
from.SendLocalizedMessage( 501930 ); // That is not a valid ticket.
}
else
{
from.SendGump( new InternalGump( from, m_Ticket ) );
them.SendGump( new InternalGump( them, theirTicket ) );
}
}
else if ( targeted is Item && ((Item)targeted).ItemID == 0x14F0 )
{
from.SendLocalizedMessage( 501931 ); // You need to find another ticket marked NEW PLAYER.
}
else
{
from.SendLocalizedMessage( 501929 ); // You will need to select a ticket.
}
}
}
private class InternalGump : Gump
{
private Mobile m_From;
private NewPlayerTicket m_Ticket;
public InternalGump( Mobile from, NewPlayerTicket ticket ) : base( 50, 50 )
{
m_From = from;
m_Ticket = ticket;
AddBackground( 0, 0, 400, 385, 0xA28 );
AddHtmlLocalized( 30, 45, 340, 70, 1013011, true, true ); // Choose the gift you prefer. WARNING: if you cancel, and your partner does not, you will need to find another matching ticket!
AddButton( 46, 128, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 130, 320, 35, 1013012, false, false ); // A sextant
AddButton( 46, 163, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 165, 320, 35, 1013013, false, false ); // A coupon for a single hair restyling
AddButton( 46, 198, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 200, 320, 35, 1013014, false, false ); // A spellbook with all 1st - 4th spells.
AddButton( 46, 233, 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 235, 320, 35, 1013015, false, false ); // A wand of fireworks
AddButton( 46, 268, 0xFA5, 0xFA7, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 270, 320, 35, 1013016, false, false ); // A spyglass
AddButton( 46, 303, 0xFA5, 0xFA7, 6, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 80, 305, 320, 35, 1013017, false, false ); // Dyes and a dye tub
AddButton( 120, 340, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 154, 342, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( m_Ticket.Deleted )
return;
int number = 0;
Item item = null;
Item item2 = null;
switch ( info.ButtonID )
{
case 1: item = new Sextant(); number = 1010494; break; // A sextant has been placed in your backpack.
case 2: item = new HairRestylingDeed(); number = 501933; break; // A coupon for a free hair restyling has been placed in your backpack.
case 3: item = new Spellbook( 0xFFFFFFFF ); number = 1010495; break; // A spellbook with all 1st to 4th circle spells has been placed in your backpack.
case 4: item = new FireworksWand(); number = 501935; break; // A wand of fireworks has been placed in your backpack.
case 5: item = new Spyglass(); number = 501936; break; // A spyglass has been placed in your backpack.
case 6: item = new DyeTub(); item2 = new Dyes(); number = 501937; break; // The dyes and dye tub have been placed in your backpack.
}
if ( item != null )
{
m_Ticket.Delete();
m_From.SendLocalizedMessage( number );
m_From.AddToBackpack( item );
if ( item2 != null )
m_From.AddToBackpack( item2 );
}
}
}
}
}

View file

@ -0,0 +1,368 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Multis;
using Server.ContextMenus;
using Server.Gumps;
using Server.Mobiles;
using Server.Targeting;
namespace Server.Items
{
public class VendorRentalContract : Item
{
public override int LabelNumber{ get{ return 1062332; } } // a vendor rental contract
private VendorRentalDuration m_Duration;
private int m_Price;
private bool m_LandlordRenew;
private Mobile m_Offeree;
private Timer m_OfferExpireTimer;
public VendorRentalDuration Duration
{
get{ return m_Duration; }
set
{
if ( value != null )
m_Duration = value;
}
}
[CommandProperty( AccessLevel.GameMaster )]
public int Price
{
get{ return m_Price; }
set{ m_Price = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool LandlordRenew
{
get{ return m_LandlordRenew; }
set{ m_LandlordRenew = value; }
}
public Mobile Offeree
{
get{ return m_Offeree; }
set
{
if ( m_OfferExpireTimer != null )
{
m_OfferExpireTimer.Stop();
m_OfferExpireTimer = null;
}
m_Offeree = value;
if ( value != null )
{
m_OfferExpireTimer = new OfferExpireTimer( this );
m_OfferExpireTimer.Start();
}
InvalidateProperties();
}
}
[Constructable]
public VendorRentalContract() : base( 0x14F0 )
{
Weight = 1.0;
Hue = 0x672;
m_Duration = VendorRentalDuration.Instances[0];
m_Price = 1500;
}
public VendorRentalContract( Serial serial ) : base( serial )
{
}
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
if ( Offeree != null )
list.Add( 1062368, Offeree.Name ); // Being Offered To ~1_NAME~
}
public bool IsLandlord( Mobile m )
{
if ( IsLockedDown )
{
BaseHouse house = BaseHouse.FindHouseAt( this );
if ( house != null && house.DecayType != DecayType.Condemned )
return house.IsOwner( m );
}
return false;
}
public bool IsUsableBy( Mobile from, bool byLandlord, bool byBackpack, bool noOfferee, bool sendMessage )
{
if ( this.Deleted || !from.CheckAlive( sendMessage ) )
return false;
if ( noOfferee && Offeree != null )
{
if ( sendMessage )
from.SendLocalizedMessage( 1062343 ); // That item is currently in use.
return false;
}
if ( byBackpack && IsChildOf( from.Backpack ) )
return true;
if ( byLandlord && IsLandlord( from ) )
{
if ( from.Map != this.Map || !from.InRange( this, 5 ) )
{
if ( sendMessage )
from.SendLocalizedMessage( 501853 ); // Target is too far away.
return false;
}
return true;
}
return false;
}
public override void OnDelete()
{
if ( IsLockedDown )
{
BaseHouse house = BaseHouse.FindHouseAt( this );
if ( house != null )
{
house.VendorRentalContracts.Remove( this );
}
}
}
public override void OnDoubleClick( Mobile from )
{
if ( Offeree != null )
{
from.SendLocalizedMessage( 1062343 ); // That item is currently in use.
}
else if ( !IsLockedDown )
{
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1062334 ); // This item must be in your backpack to be used.
return;
}
BaseHouse house = BaseHouse.FindHouseAt( from );
if ( house == null || !house.IsOwner( from ) )
{
from.SendLocalizedMessage( 1062333 ); // You must be standing inside of a house that you own to make use of this contract.
}
else if ( !house.IsAosRules )
{
from.SendMessage( "Rental contracts can only be placed in AOS-enabled houses." );
}
else if ( !house.Public )
{
from.SendLocalizedMessage( 1062335 ); // Rental contracts can only be placed in public houses.
}
else if ( !house.CanPlaceNewVendor() )
{
from.SendLocalizedMessage( 1062352 ); // You do not have enought storage available to place this contract.
}
else
{
from.SendLocalizedMessage( 1062337 ); // Target the exact location you wish to rent out.
from.Target = new RentTarget( this );
}
}
else if ( IsLandlord( from ) )
{
if ( from.InRange( this, 5 ) )
{
from.CloseGump( typeof( VendorRentalContractGump ) );
from.SendGump( new VendorRentalContractGump( this, from ) );
}
else
{
from.SendLocalizedMessage( 501853 ); // Target is too far away.
}
}
}
public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
{
base.GetContextMenuEntries( from, list );
if ( IsUsableBy( from, true, true, true, false ) )
{
list.Add( new ContractOptionEntry( this ) );
}
}
private class ContractOptionEntry : ContextMenuEntry
{
private VendorRentalContract m_Contract;
public ContractOptionEntry( VendorRentalContract contract ) : base( 6209 )
{
m_Contract = contract;
}
public override void OnClick()
{
Mobile from = Owner.From;
if ( m_Contract.IsUsableBy( from, true, true, true, true ) )
{
from.CloseGump( typeof( VendorRentalContractGump ) );
from.SendGump( new VendorRentalContractGump( m_Contract, from ) );
}
}
}
private class RentTarget : Target
{
private VendorRentalContract m_Contract;
public RentTarget( VendorRentalContract contract ) : base( -1, false, TargetFlags.None )
{
m_Contract = contract;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( !m_Contract.IsUsableBy( from, false, true, true, true ) )
return;
IPoint3D location = targeted as IPoint3D;
if ( location == null )
return;
Point3D pLocation = new Point3D( location );
Map map = from.Map;
BaseHouse house = BaseHouse.FindHouseAt( pLocation, map, 0 );
if ( house == null || !house.IsOwner( from ) )
{
from.SendLocalizedMessage( 1062338 ); // The location being rented out must be inside of your house.
}
else if ( BaseHouse.FindHouseAt( from ) != house )
{
from.SendLocalizedMessage( 1062339 ); // You must be located inside of the house in which you are trying to place the contract.
}
else if ( !house.IsAosRules )
{
from.SendMessage( "Rental contracts can only be placed in AOS-enabled houses." );
}
else if ( !house.Public )
{
from.SendLocalizedMessage( 1062335 ); // Rental contracts can only be placed in public houses.
}
else if ( house.DecayType == DecayType.Condemned )
{
from.SendLocalizedMessage( 1062468 ); // You cannot place a contract in a condemned house.
}
else if ( !house.CanPlaceNewVendor() )
{
from.SendLocalizedMessage( 1062352 ); // You do not have enought storage available to place this contract.
}
else if ( !map.CanFit( pLocation, 16, false, false ) )
{
from.SendLocalizedMessage( 1062486 ); // A vendor cannot exist at that location. Please try again.
}
else
{
bool vendor, contract;
BaseHouse.IsThereVendor( pLocation, map, out vendor, out contract );
if ( vendor )
{
from.SendLocalizedMessage( 1062342 ); // You may not place a rental contract at this location while other beings occupy it.
}
else if ( contract )
{
from.SendLocalizedMessage( 1062341 ); // That location is cluttered. Please clear out any objects there and try again.
}
else
{
m_Contract.MoveToWorld( pLocation, map );
if ( !house.LockDown( from, m_Contract ) )
{
from.AddToBackpack( m_Contract );
}
}
}
}
protected override void OnTargetCancel( Mobile from, TargetCancelType cancelType )
{
from.SendLocalizedMessage( 1062336 ); // You decide not to place the contract at this time.
}
}
private class OfferExpireTimer : Timer
{
private VendorRentalContract m_Contract;
public OfferExpireTimer( VendorRentalContract contract ) : base( TimeSpan.FromSeconds( 30.0 ) )
{
m_Contract = contract;
Priority = TimerPriority.OneSecond;
}
protected override void OnTick()
{
Mobile offeree = m_Contract.Offeree;
if ( offeree != null )
{
offeree.CloseGump( typeof( VendorRentalOfferGump ) );
m_Contract.Offeree = null;
}
}
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.WriteEncodedInt( 0 ); // version
writer.WriteEncodedInt( m_Duration.ID );
writer.Write( (int) m_Price );
writer.Write( (bool) m_LandlordRenew );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadEncodedInt();
int durationID = reader.ReadEncodedInt();
if ( durationID < VendorRentalDuration.Instances.Length )
m_Duration = VendorRentalDuration.Instances[durationID];
else
m_Duration = VendorRentalDuration.Instances[0];
m_Price = reader.ReadInt();
m_LandlordRenew = reader.ReadBool();
}
}
}