#W# Initial Commit: Avatars Conquest

This commit is contained in:
WarrentyExpired 2026-07-03 20:19:48 -04:00
commit 8eae46895e
7512 changed files with 416187 additions and 0 deletions

View file

@ -0,0 +1,699 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Gumps;
using Server.Spells;
using Server.Spells.Fourth;
using Server.Spells.Sixth;
using Server.Spells.Seventh;
namespace Server.Regions
{
public enum SpawnZLevel
{
Lowest,
Highest,
Random
}
public class BaseRegion : Region
{
public static void Configure()
{
Region.DefaultRegionType = typeof( BaseRegion );
}
private string m_RuneName;
private bool m_NoLogoutDelay;
private SpawnEntry[] m_Spawns;
private SpawnZLevel m_SpawnZLevel;
private bool m_ExcludeFromParentSpawns;
public string RuneName{ get{ return m_RuneName; } set{ m_RuneName = value; } }
public bool NoLogoutDelay{ get{ return m_NoLogoutDelay; } set{ m_NoLogoutDelay = value; } }
public SpawnEntry[] Spawns
{
get{ return m_Spawns; }
set
{
if ( m_Spawns != null )
{
for ( int i = 0; i < m_Spawns.Length; i++ )
m_Spawns[i].Delete();
}
m_Spawns = value;
}
}
public SpawnZLevel SpawnZLevel{ get{ return m_SpawnZLevel; } set{ m_SpawnZLevel = value; } }
public bool ExcludeFromParentSpawns{ get{ return m_ExcludeFromParentSpawns; } set{ m_ExcludeFromParentSpawns = value; } }
public override void OnUnregister()
{
base.OnUnregister();
this.Spawns = null;
}
public static string GetRuneNameFor( Region region )
{
while ( region != null )
{
BaseRegion br = region as BaseRegion;
if ( br != null && br.m_RuneName != null )
return br.m_RuneName;
region = region.Parent;
}
return null;
}
public override TimeSpan GetLogoutDelay( Mobile m )
{
if ( m_NoLogoutDelay )
{
if ( m.Aggressors.Count == 0 && m.Aggressed.Count == 0 && !m.Criminal )
return TimeSpan.Zero;
}
return base.GetLogoutDelay( m );
}
public static bool CanSpawn( Region region, params Type[] types )
{
while ( region != null )
{
if ( !region.AllowSpawn() )
return false;
BaseRegion br = region as BaseRegion;
if ( br != null )
{
if ( br.Spawns != null )
{
for ( int i = 0; i < br.Spawns.Length; i++ )
{
SpawnEntry entry = br.Spawns[i];
if ( entry.Definition.CanSpawn( types ) )
return true;
}
}
if ( br.ExcludeFromParentSpawns )
return false;
}
region = region.Parent;
}
return false;
}
public override void OnEnter( Mobile m )
{
base.OnEnter(m);
if ( m.Mounted && NoMounts( m, m.Location ) && m is PlayerMobile )
Server.Mobiles.StableMaster.DismountPlayer( m );
if ( m is BaseCreature && ((BaseCreature)m).SeaCreature )
{
m.PlaySound( 0x026 );
Effects.SendLocationEffect( m.Location, m.Map, 0x35B2, 16 );
m.Delete();
}
}
public override void OnExit( Mobile m )
{
base.OnExit(m);
if ( !m.Mounted && m is PlayerMobile )
Server.Mobiles.StableMaster.GetLastMounted( m );
}
public override bool OnBeginSpellCast( Mobile m, ISpell s )
{
if ( ( s is MarkSpell || s is RecallSpell || s is GateTravelSpell ) && SpellHelper.NoRecall( m.Location, m ) )
{
m.SendMessage( "For some strange reason, you cannot cast this spell!" );
m.FixedEffect( 0x3735, 6, 30 );
m.PlaySound( 0x5C );
return false;
}
return base.OnBeginSpellCast( m, s );
}
public override bool AcceptsSpawnsFrom( Region region )
{
if ( region == this || !m_ExcludeFromParentSpawns )
return base.AcceptsSpawnsFrom( region );
return false;
}
private Rectangle3D[] m_Rectangles;
private int[] m_RectangleWeights;
private int m_TotalWeight;
private static List<Rectangle3D> m_RectBuffer1 = new List<Rectangle3D>();
private static List<Rectangle3D> m_RectBuffer2 = new List<Rectangle3D>();
private void InitRectangles()
{
if ( m_Rectangles != null )
return;
// Test if area rectangles are overlapping, and in that case break them into smaller non overlapping rectangles
for ( int i = 0; i < this.Area.Length; i++ )
{
m_RectBuffer2.Add( this.Area[i] );
for ( int j = 0; j < m_RectBuffer1.Count && m_RectBuffer2.Count > 0; j++ )
{
Rectangle3D comp = m_RectBuffer1[j];
for ( int k = m_RectBuffer2.Count - 1; k >= 0; k-- )
{
Rectangle3D rect = m_RectBuffer2[k];
int l1 = rect.Start.X, r1 = rect.End.X, t1 = rect.Start.Y, b1 = rect.End.Y;
int l2 = comp.Start.X, r2 = comp.End.X, t2 = comp.Start.Y, b2 = comp.End.Y;
if ( l1 < r2 && r1 > l2 && t1 < b2 && b1 > t2 )
{
m_RectBuffer2.RemoveAt( k );
int sz = rect.Start.Z;
int ez = rect.End.X;
if ( l1 < l2 )
{
m_RectBuffer2.Add( new Rectangle3D( new Point3D( l1, t1, sz ), new Point3D( l2, b1, ez ) ) );
}
if ( r1 > r2 )
{
m_RectBuffer2.Add( new Rectangle3D( new Point3D( r2, t1, sz ), new Point3D( r1, b1, ez ) ) );
}
if ( t1 < t2 )
{
m_RectBuffer2.Add( new Rectangle3D( new Point3D( Math.Max( l1, l2 ), t1, sz ), new Point3D( Math.Min( r1, r2 ), t2, ez ) ) );
}
if ( b1 > b2 )
{
m_RectBuffer2.Add( new Rectangle3D( new Point3D( Math.Max( l1, l2 ), b2, sz ), new Point3D( Math.Min( r1, r2 ), b1, ez ) ) );
}
}
}
}
m_RectBuffer1.AddRange( m_RectBuffer2 );
m_RectBuffer2.Clear();
}
m_Rectangles = m_RectBuffer1.ToArray();
m_RectBuffer1.Clear();
m_RectangleWeights = new int[m_Rectangles.Length];
for ( int i = 0; i < m_Rectangles.Length; i++ )
{
Rectangle3D rect = m_Rectangles[i];
int weight = rect.Width * rect.Height;
m_RectangleWeights[i] = weight;
m_TotalWeight += weight;
}
}
private static List<Int32> m_SpawnBuffer1 = new List<Int32>();
private static List<Item> m_SpawnBuffer2 = new List<Item>();
public Point3D RandomSpawnLocation( int spawnHeight, bool land, bool water, Point3D home, int range )
{
Map map = this.Map;
if ( map == Map.Internal )
return Point3D.Zero;
InitRectangles();
if ( m_TotalWeight <= 0 )
return Point3D.Zero;
for ( int i = 0; i < 10; i++ ) // Try 10 times
{
int x, y, minZ, maxZ;
if ( home == Point3D.Zero )
{
int rand = Utility.Random( m_TotalWeight );
x = int.MinValue; y = int.MinValue;
minZ = int.MaxValue; maxZ = int.MinValue;
for ( int j = 0; j < m_RectangleWeights.Length; j++ )
{
int curWeight = m_RectangleWeights[j];
if ( rand < curWeight )
{
Rectangle3D rect = m_Rectangles[j];
x = rect.Start.X + rand % rect.Width;
y = rect.Start.Y + rand / rect.Width;
minZ = rect.Start.Z;
maxZ = rect.End.Z;
break;
}
rand -= curWeight;
}
}
else
{
x = Utility.RandomMinMax( home.X - range, home.X + range );
y = Utility.RandomMinMax( home.Y - range, home.Y + range );
minZ = int.MaxValue; maxZ = int.MinValue;
for ( int j = 0; j < this.Area.Length; j++ )
{
Rectangle3D rect = this.Area[j];
if ( x >= rect.Start.X && x < rect.End.X && y >= rect.Start.Y && y < rect.End.Y )
{
minZ = rect.Start.Z;
maxZ = rect.End.Z;
break;
}
}
if ( minZ == int.MaxValue )
continue;
}
if ( x < 0 || y < 0 || x >= map.Width || y >= map.Height )
continue;
LandTile lt = map.Tiles.GetLandTile( x, y );
int ltLowZ = 0, ltAvgZ = 0, ltTopZ = 0;
map.GetAverageZ( x, y, ref ltLowZ, ref ltAvgZ, ref ltTopZ );
TileFlag ltFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags;
bool ltImpassable = ( (ltFlags & TileFlag.Impassable) != 0 );
if ( !lt.Ignored && ltAvgZ >= minZ && ltAvgZ < maxZ )
if ( (ltFlags & TileFlag.Wet) != 0 ) {
if ( water )
m_SpawnBuffer1.Add( ltAvgZ );
}
else if ( land && !ltImpassable )
m_SpawnBuffer1.Add( ltAvgZ );
StaticTile[] staticTiles = map.Tiles.GetStaticTiles( x, y, true );
for ( int j = 0; j < staticTiles.Length; j++ )
{
StaticTile tile = staticTiles[j];
ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue];
int tileZ = tile.Z + id.CalcHeight;
if ( tileZ >= minZ && tileZ < maxZ )
if ( (id.Flags & TileFlag.Wet) != 0 ) {
if ( water )
m_SpawnBuffer1.Add( tileZ );
}
else if ( land && id.Surface && !id.Impassable )
m_SpawnBuffer1.Add( tileZ );
}
Sector sector = map.GetSector( x, y );
for ( int j = 0; j < sector.Items.Count; j++ )
{
Item item = sector.Items[j];
if ( !(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint( x, y ) )
{
m_SpawnBuffer2.Add( item );
if ( !item.Movable )
{
ItemData id = item.ItemData;
int itemZ = item.Z + id.CalcHeight;
if ( itemZ >= minZ && itemZ < maxZ )
if ( (id.Flags & TileFlag.Wet) != 0 ) {
if ( water )
m_SpawnBuffer1.Add( itemZ );
}
else if ( land && id.Surface && !id.Impassable )
m_SpawnBuffer1.Add( itemZ );
}
}
}
if ( m_SpawnBuffer1.Count == 0 )
{
m_SpawnBuffer1.Clear();
m_SpawnBuffer2.Clear();
continue;
}
int z;
switch ( m_SpawnZLevel )
{
case SpawnZLevel.Lowest:
{
z = int.MaxValue;
for ( int j = 0; j < m_SpawnBuffer1.Count; j++ )
{
int l = m_SpawnBuffer1[j];
if ( l < z )
z = l;
}
break;
}
case SpawnZLevel.Highest:
{
z = int.MinValue;
for ( int j = 0; j < m_SpawnBuffer1.Count; j++ )
{
int l = m_SpawnBuffer1[j];
if ( l > z )
z = l;
}
break;
}
default: // SpawnZLevel.Random
{
int index = Utility.Random( m_SpawnBuffer1.Count );
z = m_SpawnBuffer1[index];
break;
}
}
m_SpawnBuffer1.Clear();
if ( !Region.Find( new Point3D( x, y, z ), map ).AcceptsSpawnsFrom( this ) )
{
m_SpawnBuffer2.Clear();
continue;
}
int top = z + spawnHeight;
bool ok = true;
for ( int j = 0; j < m_SpawnBuffer2.Count; j++ )
{
Item item = m_SpawnBuffer2[j];
ItemData id = item.ItemData;
if ( ( id.Surface || id.Impassable ) && item.Z + id.CalcHeight > z && item.Z < top )
{
ok = false;
break;
}
}
m_SpawnBuffer2.Clear();
if ( !ok )
continue;
if ( ltImpassable && ltAvgZ > z && ltLowZ < top )
continue;
for ( int j = 0; j < staticTiles.Length; j++ )
{
StaticTile tile = staticTiles[j];
ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue];
if ( ( id.Surface || id.Impassable ) && tile.Z + id.CalcHeight > z && tile.Z < top )
{
ok = false;
break;
}
}
if ( !ok )
continue;
for ( int j = 0; j < sector.Mobiles.Count; j++ )
{
Mobile m = sector.Mobiles[j];
if ( m.X == x && m.Y == y && ( m.AccessLevel == AccessLevel.Player || !m.Hidden ) )
if ( m.Z + 16 > z && m.Z < top )
{
ok = false;
break;
}
}
if ( ok )
return new Point3D( x, y, z );
}
return Point3D.Zero;
}
public override string ToString()
{
if ( this.Name != null )
return this.Name;
else if ( this.RuneName != null )
return this.RuneName;
else
return this.GetType().Name;
}
public BaseRegion( string name, Map map, int priority, params Rectangle2D[] area ) : base( name, map, priority, area )
{
}
public BaseRegion( string name, Map map, int priority, params Rectangle3D[] area ) : base( name, map, priority, area )
{
}
public BaseRegion( string name, Map map, Region parent, params Rectangle2D[] area ) : base( name, map, parent, area )
{
}
public BaseRegion( string name, Map map, Region parent, params Rectangle3D[] area ) : base( name, map, parent, area )
{
}
public BaseRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
{
ReadString( xml["rune"], "name", ref m_RuneName, false );
bool logoutDelayActive = true;
ReadBoolean( xml["logoutDelay"], "active", ref logoutDelayActive, false );
m_NoLogoutDelay = !logoutDelayActive;
XmlElement spawning = xml["spawning"];
if ( spawning != null )
{
ReadBoolean( spawning, "excludeFromParent", ref m_ExcludeFromParentSpawns, false );
SpawnZLevel zLevel = SpawnZLevel.Lowest;
ReadEnum( spawning, "zLevel", ref zLevel, false );
m_SpawnZLevel = zLevel;
List<SpawnEntry> list = new List<SpawnEntry>();
foreach ( XmlNode node in spawning.ChildNodes )
{
XmlElement el = node as XmlElement;
if ( el != null )
{
SpawnDefinition def = SpawnDefinition.GetSpawnDefinition( el );
if ( def == null )
continue;
int id = 0;
if ( !ReadInt32( el, "id", ref id, true ) )
continue;
int amount = 0;
if ( !ReadInt32( el, "amount", ref amount, true ) )
continue;
TimeSpan minSpawnTime = SpawnEntry.DefaultMinSpawnTime;
ReadTimeSpan( el, "minSpawnTime", ref minSpawnTime, false );
TimeSpan maxSpawnTime = SpawnEntry.DefaultMaxSpawnTime;
ReadTimeSpan( el, "maxSpawnTime", ref maxSpawnTime, false );
Point3D home = Point3D.Zero;
int range = 0;
XmlElement homeEl = el["home"];
if ( ReadPoint3D( homeEl, map, ref home, false ) )
ReadInt32( homeEl, "range", ref range, false );
Direction dir = SpawnEntry.InvalidDirection;
ReadEnum( el["direction"], "value" , ref dir, false );
SpawnEntry entry = new SpawnEntry( id, this, home, range, dir, def, amount, minSpawnTime, maxSpawnTime );
list.Add( entry );
}
}
if ( list.Count > 0 )
{
m_Spawns = list.ToArray();
}
}
}
public static Point3D GetBoatWater( int x, int y, Map map, int range )
{
bool WaterOk = false;
Point3D loc = new Point3D(0, 0, 0);
Map tm = map;
int tx = 0;
int ty = 0;
int tz = 0;
int r = 0;
LandTile t = tm.Tiles.GetLandTile(tx, ty);
while ( !WaterOk )
{
tx = Utility.RandomMinMax( x+range, x-range );
ty = Utility.RandomMinMax( y+range, y-range );
tz = tm.GetAverageZ(tx, ty);
t = tm.Tiles.GetLandTile(tx, ty);
if ( IsWaterTile ( t.ID ) )
WaterOk = true;
if ( WaterOk )
loc = new Point3D(tx, ty, tz);
r++; // SAFETY CATCH
if ( r > 50 )
{
WaterOk = true;
}
}
return loc;
}
public static bool IsWaterTile ( int id )
{
if ( id==0x00A8 || id==0x00A9 || id==0x00AA || id==0x00AB )
return true;
return false;
}
public static bool TestOcean( Map map, int x, int y, int distance )
{
int results = 0;
LandTile seaTile1 = map.Tiles.GetLandTile( x-distance, y-distance );
LandTile seaTile2 = map.Tiles.GetLandTile( x, y-distance );
LandTile seaTile3 = map.Tiles.GetLandTile( x+distance, y-distance );
LandTile seaTile4 = map.Tiles.GetLandTile( x-distance, y );
LandTile seaTile5 = map.Tiles.GetLandTile( x+distance, y );
LandTile seaTile6 = map.Tiles.GetLandTile( x-distance, y+distance );
LandTile seaTile7 = map.Tiles.GetLandTile( x, y+distance );
LandTile seaTile8 = map.Tiles.GetLandTile( x+distance, y+distance );
if ( !IsWaterTile( seaTile1.ID ) ){ results ++; }
if ( !IsWaterTile( seaTile2.ID ) ){ results ++; }
if ( !IsWaterTile( seaTile3.ID ) ){ results ++; }
if ( !IsWaterTile( seaTile4.ID ) ){ results ++; }
if ( !IsWaterTile( seaTile5.ID ) ){ results ++; }
if ( !IsWaterTile( seaTile6.ID ) ){ results ++; }
if ( !IsWaterTile( seaTile7.ID ) ){ results ++; }
if ( !IsWaterTile( seaTile8.ID ) ){ results ++; }
if ( results > 0 )
return false;
return true;
}
public static Point3D GetOceanSpot()
{
bool IsWater = false;
Point3D loc = new Point3D(0, 0, 0);
Point3D failover = new Point3D(100, 100, -5);
Map map = Map.Britannia;
int tx = 0;
int ty = 0;
int tz = 0;
bool run = true;
int r = 0;
while ( run )
{
tx = Utility.RandomMinMax( 26, 7142 );
ty = Utility.RandomMinMax( 26, 4070 );
tz = map.GetAverageZ(tx, ty);
LandTile t = map.Tiles.GetLandTile(tx, ty);
if ( IsWaterTile( t.ID ) && TestOcean( map, tx, ty, 10 ) )
IsWater = true;
Point3D locale = new Point3D(tx, ty, tz);
Region reg = Region.Find( locale, map );
if ( tz != -5 )
IsWater = false;
if ( IsWater && reg == map.DefaultRegion )
{
loc = locale;
run = false;
}
r++; // SAFETY CATCH
if ( r > 5000 && run )
{
loc = failover;
run = false;
}
}
return loc;
}
}
}

View file

@ -0,0 +1,28 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using Server;
using Server.Commands;
using Server.Mobiles;
using Server.Spells;
namespace Server.Regions
{
public class BuildingRegion : TownRegion
{
public BuildingRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
{
}
public override bool AllowHousing( Mobile from, Point3D p )
{
return false;
}
public override bool NoMounts( Mobile from, Point3D p )
{
return true;
}
}
}

View file

@ -0,0 +1,30 @@
using System;
using System.Xml;
using Server;
using Server.Mobiles;
using Server.Gumps;
namespace Server.Regions
{
public class CaveRegion : BaseRegion
{
public CaveRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
{
}
public override bool AllowHousing( Mobile from, Point3D p )
{
return false;
}
public override bool NoMounts( Mobile from, Point3D p )
{
return true;
}
public override void AlterLightLevel( Mobile m, ref int global, ref int personal )
{
global = LightCycle.CaveLevel;
}
}
}

View file

@ -0,0 +1,18 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using Server;
using Server.Commands;
using Server.Mobiles;
using Server.Spells;
namespace Server.Regions
{
public class DangerRegion : MountlessRegion
{
public DangerRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
{
}
}
}

View file

@ -0,0 +1,81 @@
using System;
using System.Xml;
using Server;
using Server.Mobiles;
using Server.Gumps;
using Server.Network;
namespace Server.Regions
{
public class DungeonRegion : BaseRegion
{
public DungeonRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
{
}
public override bool AllowHousing( Mobile from, Point3D p )
{
return false;
}
public override bool NoMounts( Mobile from, Point3D p )
{
return true;
}
public override void AlterLightLevel( Mobile m, ref int global, ref int personal )
{
global = LightCycle.DungeonLevel;
}
public override bool CanUseStuckMenu( Mobile m )
{
return false;
}
public override void OnEnter( Mobile m )
{
base.OnEnter( m );
if ( m is PlayerMobile )
m.SendMessage( "You have entered " + this.Name + "." );
}
public override void OnExit(Mobile m)
{
base.OnExit( m );
if ( m is PlayerMobile )
{
if ( !PlayersLeftInRegion( m, this ) )
{
foreach ( Mobile creature in World.Mobiles.Values )
if ( creature.Region == this && creature is BaseCreature )
{
BaseCreature dweller = (BaseCreature)creature;
Point3D loc = dweller.Home;
if ( loc.X > 0 && dweller.RangeHome < 10 && dweller.SummonMaster == null && dweller.ControlMaster == null )
{
dweller.Location = dweller.Home;
}
}
}
}
}
public static bool PlayersLeftInRegion( Mobile from, Region region )
{
bool occupied = false;
foreach ( NetState state in NetState.Instances )
{
Mobile m = state.Mobile;
if ( m != null && m != from && m.Region == region )
{
occupied = true;
}
}
return occupied;
}
}
}

View file

@ -0,0 +1,20 @@
using System;
using System.Xml;
using Server;
using Server.Mobiles;
using Server.Gumps;
namespace Server.Regions
{
public class GardenRegion : BaseRegion
{
public GardenRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
{
}
public override bool AllowHousing( Mobile from, Point3D p )
{
return false;
}
}
}

View file

@ -0,0 +1,28 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using Server;
using Server.Commands;
using Server.Mobiles;
using Server.Spells;
namespace Server.Regions
{
public class GateRegion : TownRegion
{
public GateRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
{
}
public override bool AllowHousing( Mobile from, Point3D p )
{
return false;
}
public override bool AllowHarmful( Mobile from, Mobile target )
{
return false;
}
}
}

View file

@ -0,0 +1,18 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using Server;
using Server.Commands;
using Server.Mobiles;
using Server.Spells;
namespace Server.Regions
{
public class GraveRegion : MountlessRegion
{
public GraveRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
{
}
}
}

View file

@ -0,0 +1,402 @@
using System;
using Server;
using Server.Mobiles;
using Server.Items;
using Server.Multis;
using Server.Spells;
using Server.Spells.Sixth;
using Server.Guilds;
using Server.Gumps;
namespace Server.Regions
{
public class HouseRegion : BaseRegion
{
public static readonly int HousePriority = Region.DefaultPriority + 1;
private BaseHouse m_House;
public static void Initialize()
{
EventSink.Login += new LoginEventHandler( OnLogin );
}
public override bool NoMounts( Mobile from, Point3D p )
{
return true;
}
public static void OnLogin( LoginEventArgs e )
{
BaseHouse house = BaseHouse.FindHouseAt( e.Mobile );
if ( house != null && !house.Public && !house.IsFriend( e.Mobile ) )
e.Mobile.Location = house.BanLocation;
}
public HouseRegion( BaseHouse house ) : base( null, house.Map, HousePriority, GetArea( house ) )
{
m_House = house;
Point3D ban = house.RelativeBanLocation;
this.GoLocation = new Point3D( house.X + ban.X, house.Y + ban.Y, house.Z + ban.Z );
}
private static Rectangle3D[] GetArea( BaseHouse house )
{
int x = house.X;
int y = house.Y;
int z = house.Z;
Rectangle2D[] houseArea = house.Area;
Rectangle3D[] area = new Rectangle3D[houseArea.Length];
for ( int i = 0; i < area.Length; i++ )
{
Rectangle2D rect = houseArea[i];
area[i] = Region.ConvertTo3D( new Rectangle2D( x + rect.Start.X, y + rect.Start.Y, rect.Width, rect.Height ) );
}
return area;
}
public override bool SendInaccessibleMessage( Item item, Mobile from )
{
if ( item is Container )
item.SendLocalizedMessageTo( from, 501647 ); // That is secure.
else
item.SendLocalizedMessageTo( from, 1061637 ); // You are not allowed to access this.
return true;
}
public override bool CheckAccessibility( Item item, Mobile from )
{
return m_House.CheckAccessibility( item, from );
}
private bool m_Recursion;
// Use OnLocationChanged instead of OnEnter because it can be that we enter a house region even though we're not actually inside the house
public override void OnLocationChanged( Mobile m, Point3D oldLocation )
{
if ( m_Recursion )
return;
base.OnLocationChanged( m, oldLocation );
m_Recursion = true;
if ( m is BaseCreature && ((BaseCreature)m).NoHouseRestrictions )
{
}
else if ( m is BaseCreature && ((BaseCreature)m).IsHouseSummonable && !(BaseCreature.Summoning || m_House.IsInside( oldLocation, 16 )) )
{
}
else if ( (m_House.Public || !m_House.IsAosRules) && m_House.IsBanned( m ) && m_House.IsInside( m ) )
{
m.Location = m_House.BanLocation;
m.SendLocalizedMessage( 501284 ); // You may not enter.
}
else if ( m_House.IsAosRules && !m_House.Public && !m_House.HasAccess( m ) && m_House.IsInside( m ) )
{
m.Location = m_House.BanLocation;
m.SendLocalizedMessage( 501284 ); // You may not enter.
}
else if ( m_House.IsCombatRestricted( m ) && m_House.IsInside( m ) && !m_House.IsInside( oldLocation, 16 ) )
{
m.Location = m_House.BanLocation;
m.SendLocalizedMessage( 1061637 ); // You are not allowed to access this.
}
else if ( m_House is HouseFoundation )
{
HouseFoundation foundation = (HouseFoundation)m_House;
if ( foundation.Customizer != null && foundation.Customizer != m && m_House.IsInside( m ) )
m.Location = m_House.BanLocation;
}
if ( m_House.InternalizedVendors.Count > 0 && m_House.IsInside( m ) && !m_House.IsInside( oldLocation, 16 ) && m_House.IsOwner( m ) && m.Alive && !m.HasGump( typeof( NoticeGump ) ) )
{
/* This house has been customized recently, and vendors that work out of this
* house have been temporarily relocated. You must now put your vendors back to work.
* To do this, walk to a location inside the house where you wish to station
* your vendor, then activate the context-sensitive menu on your avatar and
* select "Get Vendor".
*/
m.SendGump( new NoticeGump( 1060635, 30720, 1061826, 32512, 320, 180, null, null ) );
}
m_Recursion = false;
}
public override bool OnMoveInto( Mobile from, Direction d, Point3D newLocation, Point3D oldLocation )
{
if ( !base.OnMoveInto( from, d, newLocation, oldLocation ) )
return false;
if ( from is BaseCreature && ((BaseCreature)from).NoHouseRestrictions )
{
}
else if ( from is BaseCreature && !((BaseCreature)from).Controlled ) // Untamed creatures cannot enter public houses
{
return false;
}
else if ( from is BaseCreature && ((BaseCreature)from).IsHouseSummonable && !(BaseCreature.Summoning || m_House.IsInside( oldLocation, 16 )) )
{
return false;
}
else if ( from is BaseCreature && !((BaseCreature)from).Controlled && m_House.IsAosRules && !m_House.Public)
{
return false;
}
else if ( (m_House.Public || !m_House.IsAosRules) && m_House.IsBanned( from ) && m_House.IsInside( newLocation, 16 ) )
{
from.Location = m_House.BanLocation;
from.SendLocalizedMessage( 501284 ); // You may not enter.
return false;
}
else if ( m_House.IsAosRules && !m_House.Public && !m_House.HasAccess( from ) && m_House.IsInside( newLocation, 16 ) )
{
from.SendLocalizedMessage( 501284 ); // You may not enter.
return false;
}
else if ( m_House.IsCombatRestricted( from ) && !m_House.IsInside( oldLocation, 16 ) && m_House.IsInside( newLocation, 16 ) )
{
from.SendLocalizedMessage( 1061637 ); // You are not allowed to access this.
return false;
}
else if ( m_House is HouseFoundation )
{
HouseFoundation foundation = (HouseFoundation)m_House;
if ( foundation.Customizer != null && foundation.Customizer != from && m_House.IsInside( newLocation, 16 ) )
return false;
}
if ( m_House.InternalizedVendors.Count > 0 && m_House.IsInside( from ) && !m_House.IsInside( oldLocation, 16 ) && m_House.IsOwner( from ) && from.Alive && !from.HasGump( typeof( NoticeGump ) ) )
{
/* This house has been customized recently, and vendors that work out of this
* house have been temporarily relocated. You must now put your vendors back to work.
* To do this, walk to a location inside the house where you wish to station
* your vendor, then activate the context-sensitive menu on your avatar and
* select "Get Vendor".
*/
from.SendGump( new NoticeGump( 1060635, 30720, 1061826, 32512, 320, 180, null, null ) );
}
return true;
}
public override bool OnDecay( Item item )
{
if ( (m_House.IsLockedDown( item ) || m_House.IsSecure( item )) && m_House.IsInside( item ) )
return false;
else
return base.OnDecay(item );
}
public static TimeSpan CombatHeatDelay = TimeSpan.FromSeconds( 30.0 );
public override TimeSpan GetLogoutDelay( Mobile m )
{
if ( m_House.IsFriend( m ) && m_House.IsInside( m ) )
{
for ( int i = 0; i < m.Aggressed.Count; ++i )
{
AggressorInfo info = m.Aggressed[i];
if ( info.Defender.Player && (DateTime.Now - info.LastCombatTime) < CombatHeatDelay )
return base.GetLogoutDelay( m );
}
return TimeSpan.Zero;
}
return base.GetLogoutDelay( m );
}
public override void OnSpeech( SpeechEventArgs e )
{
base.OnSpeech( e );
Mobile from = e.Mobile;
Item sign = m_House.Sign;
bool isOwner = m_House.IsOwner( from );
bool isCoOwner = isOwner || m_House.IsCoOwner( from );
bool isFriend = isCoOwner || m_House.IsFriend( from );
if ( !isFriend )
return;
if ( !from.Alive )
return;
if ( !m_House.IsInside( from ) || !m_House.IsActive )
return;
else if ( e.HasKeyword( 0x33 ) ) // remove thyself
{
if ( isFriend )
{
from.SendLocalizedMessage( 501326 ); // Target the individual to eject from this house.
from.Target = new HouseKickTarget( m_House );
}
else
{
from.SendLocalizedMessage( 502094 ); // You must be in your house to do this.
}
}
else if ( e.HasKeyword( 0x34 ) ) // I ban thee
{
if ( !isFriend )
{
from.SendLocalizedMessage( 502094 ); // You must be in your house to do this.
}
else if ( !m_House.Public && m_House.IsAosRules )
{
from.SendLocalizedMessage( 1062521 ); // You cannot ban someone from a private house. Revoke their access instead.
}
else
{
from.SendLocalizedMessage( 501325 ); // Target the individual to ban from this house.
from.Target = new HouseBanTarget( true, m_House );
}
}
else if ( e.HasKeyword( 0x23 ) ) // I wish to lock this down
{
if ( isCoOwner )
{
from.SendLocalizedMessage( 502097 ); // Lock what down?
from.Target = new LockdownTarget( false, m_House );
}
else if ( isFriend )
{
from.SendLocalizedMessage( 1010587 ); // You are not a co-owner of this house.
}
else
{
from.SendLocalizedMessage( 502094 ); // You must be in your house to do this.
}
}
else if ( e.HasKeyword( 0x24 ) ) // I wish to release this
{
if ( isCoOwner )
{
from.SendLocalizedMessage( 502100 ); // Choose the item you wish to release
from.Target = new LockdownTarget( true, m_House );
}
else if ( isFriend )
{
from.SendLocalizedMessage( 1010587 ); // You are not a co-owner of this house.
}
else
{
from.SendLocalizedMessage( 502094 ); // You must be in your house to do this.
}
}
else if ( e.HasKeyword( 0x25 ) ) // I wish to secure this
{
if ( isOwner )
{
from.SendLocalizedMessage( 502103 ); // Choose the item you wish to secure
from.Target = new SecureTarget( false, m_House );
}
else
{
from.SendLocalizedMessage( 502094 ); // You must be in your house to do this.
}
}
else if ( e.HasKeyword( 0x26 ) ) // I wish to unsecure this
{
if ( isOwner )
{
from.SendLocalizedMessage( 502106 ); // Choose the item you wish to unsecure
from.Target = new SecureTarget( true, m_House );
}
else
{
from.SendLocalizedMessage( 502094 ); // You must be in your house to do this.
}
}
else if ( e.HasKeyword( 0x27 ) ) // I wish to place a strongbox
{
if ( isOwner )
{
from.SendLocalizedMessage( 502109 ); // Owners do not get a strongbox of their own.
}
else if ( isCoOwner )
{
m_House.AddStrongBox( from );
}
else if ( isFriend )
{
from.SendLocalizedMessage( 1010587 ); // You are not a co-owner of this house.
}
else
{
from.SendLocalizedMessage( 502094 ); // You must be in your house to do this.
}
}
else if ( e.HasKeyword( 0x28 ) ) // trash barrel
{
if ( isCoOwner )
{
m_House.AddTrashBarrel( from );
}
else if ( isFriend )
{
from.SendLocalizedMessage( 1010587 ); // You are not a co-owner of this house.
}
else
{
from.SendLocalizedMessage( 502094 ); // You must be in your house to do this.
}
}
}
public override bool OnDoubleClick( Mobile from, object o )
{
if ( o is Container )
{
Container c = (Container)o;
SecureAccessResult res = m_House.CheckSecureAccess( from, c );
switch ( res )
{
case SecureAccessResult.Insecure: break;
case SecureAccessResult.Accessible: return true;
case SecureAccessResult.Inaccessible: c.SendLocalizedMessageTo( from, 1010563 ); return false;
}
}
return base.OnDoubleClick( from, o );
}
public override bool OnSingleClick( Mobile from, object o )
{
if ( o is Item )
{
Item item = (Item)o;
if ( m_House.IsLockedDown( item ) )
item.LabelTo( from, 501643 ); // [locked down]
else if ( m_House.IsSecure( item ) )
item.LabelTo( from, 501644 ); // [locked down & secure]
}
return base.OnSingleClick( from, o );
}
public BaseHouse House
{
get
{
return m_House;
}
}
}
}

View file

@ -0,0 +1,38 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using Server;
using Server.Commands;
using Server.Mobiles;
using Server.Spells;
namespace Server.Regions
{
public class InnRegion : TownRegion
{
public InnRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
{
}
public override bool AllowHousing( Mobile from, Point3D p )
{
return false;
}
public override bool NoMounts( Mobile from, Point3D p )
{
return true;
}
public override bool AllowHarmful( Mobile from, Mobile target )
{
return false;
}
public override TimeSpan GetLogoutDelay( Mobile m )
{
return TimeSpan.Zero;
}
}
}

304
Scripts/Regions/LandMap.cs Normal file
View file

@ -0,0 +1,304 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using Server.Commands;
namespace Server.Misc
{
public class MapFunctions
{
public static void Initialize()
{
CommandSystem.Register( "Map", AccessLevel.Player, new CommandEventHandler( EventSink_OnCommand ) );
}
[Usage( "Map" )]
[Description( "Brings up the World Map." )]
public static void EventSink_OnCommand( CommandEventArgs e )
{
(e.Mobile).CloseGump( typeof( MapGump ) );
(e.Mobile).SendGump( new MapGump( e.Mobile ) );
}
public static int NumLocations()
{
return 83;
}
public static bool HasLocation( PlayerMobile pm, int location )
{
string s = pm.MapMarkers;
int i = (location-1) * 2;
char c = s[i];
if ( c == '1' )
return true;
return false;
}
public static string SetLocations( PlayerMobile pm )
{
string locations = pm.MapMarkers;
if ( locations == null || locations.Length < ( NumLocations() * 2 ) )
{
int cycle = NumLocations();
while ( cycle > 0 )
{
cycle--;
locations = locations + "1#"; // CHANGE THIS AFTER TESTING ------------------------------------------------------------------
}
pm.MapMarkers = locations;
}
return locations;
}
public static void AddLocations( Mobile m, int location )
{
if ( m != null && m is PlayerMobile )
{
string locations = ((PlayerMobile)m).MapMarkers;
locations = SetLocations( (PlayerMobile)m );
if ( locations.Length > 0 )
{
string[] discoveries = locations.Split('#');
string entry = "";
int num = 1;
foreach ( string keyset in discoveries )
{
string sets = "1";
if ( keyset != "1" ){ sets = "0"; }
if ( location == num ){ entry = entry + "1#"; }
else { entry = entry + sets + "#"; }
num++;
}
while ( num < NumLocations()+1 )
{
entry = entry + "0#";
num++;
}
((PlayerMobile)m).MapMarkers = entry;
}
}
}
public static int Pin( int x, int n )
{
if ( x < 1 )
n++;
else
n=0;
return n;
}
public static string LocationInfo( int loc, int section )
{
string name = "";
int x = 0;
int y = 0;
string c = "";
string i = "true";
int d = 0;
int nxt = 1;
int hue = 0;
int s = 0;
if ( loc == nxt ){ name = "Britain"; x=2169; y=1579; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Yew"; x=1534; y=863; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Prison"; x=1003; y=969; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Minoc"; x=2879; y=486; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Skara Brae"; d = 2; x=738; y=1871; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Jhelom"; x=1065; y=3157; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Trinsic"; x=2029; y=2630; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Paws"; x=1983; y=2163; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Buccaneer's Den"; x=2644; y=2213; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Magincia"; x=3429; y=2427; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Moonglow"; x=4153; y=1982; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Lyceum"; d = 1; x=3865; y=1627; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Zoo"; x=4048; y=1681; } nxt = Pin( x, nxt );
if ( x < 1 ){ hue++; }
if ( loc == nxt ){ name = "Deceit"; d = 2; x=4194; y=1308; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Despise"; x=1649; y=1223; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Destard"; x=1536; y=2636; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Wrong"; x=2403; y=625; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Covetous"; x=2888; y=658; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Shame"; x=1383; y=1741; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Hythloth"; x=4240; y=3397; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Stygian Abyss"; d = 1; x=4209; y=2962; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Terathan Keep"; x=5298; y=1132; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Ancient Pyramid"; x=5494; y=678; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Wailing Halls"; x=1548; y=1081; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Exodus Ruins"; x=669; y=3480; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Silent Tomb"; d = 1; x=2048; y=1935; } nxt = Pin( x, nxt );
if ( x < 1 ){ hue++; s=0; }
if ( loc == nxt ){ name = "Deep Forest"; x=1081; y=1110; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Lock Lake"; x=2453; y=1301; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Lost Hope Bay"; x=2569; y=720; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "High Steppes"; x=2297; y=885; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Bog of Desolation"; x=1925; y=2381; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Brittany Bay"; x=2017; y=1721; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Drylands"; x=3685; y=1017; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Bloody Plains"; x=3033; y=825; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Isle of the Avatar"; x=3951; y=3545; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Terfin"; x=3419; y=3189; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Abandoned Isles"; x=1325; y=3440; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Deadman Isles"; x=2437; y=3273; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Valorian Isles"; x=997; y=2641; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Spiritwood"; x=1061; y=2001; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Isle of Fire"; x=537; y=3273; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Verity Isle"; x=4053; y=1801; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Dagger Isle"; x=4141; y=960; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Janus Isle"; x=4268; y=1245; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Spektran"; x=3193; y=3001; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Cape of Heroes"; x=1770; y=3161; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Serpent Isle"; x=5277; y=858; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Restful Dunes"; x=6084; y=2237; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Daemon Islands"; x=4888; y=2105; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Isles of the Dead"; x=2185; y=1928; } nxt = Pin( x, nxt );
if ( x < 1 ){ hue++; s=0; }
if ( loc == nxt ){ name = "Humility"; d = 2; x=4127; y=3000; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Honesty"; x=4137; y=1091; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Sacrifice"; x=3743; y=927; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Justice"; d = 1; x=1653; y=548; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Compassion"; x=2488; y=1482; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Spirituality"; d = 1; x=1003; y=1852; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Valor"; d = 1; x=1244; y=3411; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Honor"; x=1876; y=2824; } nxt = Pin( x, nxt );
if ( x < 1 ){ hue++; s=1; }
if ( loc == nxt ){ name = "Brigands"; x=1165; y=1177; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Hobgoblins"; x=1231; y=1059; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Graveyard"; x=1548; y=1016; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Graveyard"; x=2655; y=524; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Savages"; d = 1; x=5648; y=626; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Savages"; x=5774; y=1301; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Cemetery"; x=3432; y=1041; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Brigands"; x=3074; y=1120; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Orcs"; x=2209; y=819; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Graveyard"; x=547; y=1758; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Ratmen"; x=1291; y=2253; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Brigands"; x=4245; y=1721; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Cemetery"; x=4012; y=1879; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Hobgoblins"; x=5747; y=1869; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Savages"; x=6386; y=1744; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Graveyard"; d = 1; x=3517; y=2363; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Brigands"; x=2078; y=2904; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Cemetery"; d = 2; x=1888; y=2658; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Ratmen"; x=1602; y=2790; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Graveyard"; x=989; y=3025; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Orcs"; x=2349; y=3425; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Cemetery"; x=2203; y=2104; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Spider Cave"; x=739; y=1206; } nxt = Pin( x, nxt );
if ( x < 1 ){ hue++; s=0; }
if ( loc == nxt ){ name = "Goblin Keep"; x=1951; y=1274; } nxt = Pin( x, nxt );
if ( loc == nxt ){ name = "Plunderer's Port"; x=6589; y=2370; } nxt = Pin( x, nxt );
if ( hue == 0 ){ c = "#FCFF00"; } // YELLOW Towns
else if ( hue == 1 ){ c = "#FF0000"; } // RED Dungeons
else if ( hue == 2 ){ c = "#00FF0C"; i = "false"; } // GREEN Lands
else if ( hue == 3 ){ c = "#00A8FF"; } // BLUE Shrines
else if ( hue == 4 ){ c = "#FFA200"; i = "false"; } // ORANGE Places
else if ( hue == 5 ){ c = "#D200FF"; } // PURPLE Danger
else if ( hue == 6 ){ c = "#00FFFF"; } // AQUA ???????
string xx = ((int)(x/4)).ToString();
string yy = ((int)(y/4)).ToString();
if ( section == 1 )
return xx;
else if ( section == 2 )
return yy;
else if ( section == 3 )
return c;
else if ( section == 4 )
return i;
else if ( section == 5 )
return d.ToString();
else if ( section == 6 )
return s.ToString();
return name;
}
}
public class MapGump : Gump
{
public MapGump( Mobile m ) : base( 0, 0 )
{
MapFunctions.SetLocations( (PlayerMobile)m );
int cycle = MapFunctions.NumLocations();
int spot = 0;
int xx = 30;
int yy = 5;
int x = 0;
int y = 0;
this.Closable=true;
this.Disposable=true;
this.Dragable=true;
this.Resizable=false;
AddPage(0);
AddImage(xx, yy, 12105);
AddImage(0, 0, 12104);
bool icon = true;
int d = 0;
int s = 0;
string s1 = "";
string s2 = "";
while ( cycle > 0 )
{
cycle--;
spot++;
if ( MapFunctions.HasLocation( (PlayerMobile)m, spot ) )
{
x = xx-7 + int.Parse( MapFunctions.LocationInfo( spot, 1 ) );
y = yy-7 + int.Parse( MapFunctions.LocationInfo( spot, 2 ) );
icon = bool.Parse( MapFunctions.LocationInfo( spot, 4 ) );
d = int.Parse( MapFunctions.LocationInfo( spot, 5 ) );
s = int.Parse( MapFunctions.LocationInfo( spot, 6 ) );
if ( x > 0 )
{
s1 = "<BIG>";
s2 = "</BIG>";
if ( s == 1 )
{
s1 = "";
s2 = "";
}
if ( icon ){ AddImage(x, y, 12106); x=x+15; }
if ( d == 1 ){ x = x - 16; y = y - 18; }
else if ( d == 2 ){ x = x - 15; y = y + 12; }
AddHtml( x, y, 200, 48, @"<BODY><BASEFONT Color=" + MapFunctions.LocationInfo( spot, 3 ) + ">" + s1 + MapFunctions.LocationInfo( spot, 0 ) + s2 + "</BASEFONT></BODY>", (bool)false, (bool)false);
}
}
}
}
}
}

View file

@ -0,0 +1,25 @@
using System;
using System.Xml;
using Server;
using Server.Mobiles;
using Server.Gumps;
namespace Server.Regions
{
public class MountlessRegion : BaseRegion
{
public MountlessRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
{
}
public override bool AllowHousing( Mobile from, Point3D p )
{
return false;
}
public override bool NoMounts( Mobile from, Point3D p )
{
return true;
}
}
}

View file

@ -0,0 +1,26 @@
using System;
using System.Xml;
using Server;
namespace Server.Regions
{
public class NoHousingRegion : BaseRegion
{
/* - False: this uses 'stupid OSI' house placement checking: part of the house may be placed here provided that the center is not in the region
* - True: this uses 'smart RunUO' house placement checking: no part of the house may be in the region
*/
private bool m_SmartChecking;
public bool SmartChecking{ get{ return m_SmartChecking; } }
public NoHousingRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
{
ReadBoolean( xml["smartNoHousing"], "active", ref m_SmartChecking, false );
}
public override bool AllowHousing( Mobile from, Point3D p )
{
return m_SmartChecking;
}
}
}

View file

@ -0,0 +1,23 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using Server;
using Server.Commands;
using Server.Mobiles;
using Server.Spells;
namespace Server.Regions
{
public class OutskirtRegion : BaseRegion
{
public OutskirtRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
{
}
public override bool AllowHousing( Mobile from, Point3D p )
{
return true;
}
}
}

View file

@ -0,0 +1,18 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using Server;
using Server.Commands;
using Server.Mobiles;
using Server.Spells;
namespace Server.Regions
{
public class PirateRegion : MountlessRegion
{
public PirateRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
{
}
}
}

View file

@ -0,0 +1,141 @@
using System;
using Server;
using Server.Mobiles;
using Server.Network;
using Server.Regions;
using Server.Items;
namespace Server.Misc
{
class RegionMusic
{
public static bool isLand( Region region )
{
if ( ( region.IsDefault || region.Name == null || region.Name == "" ) )
return true;
return false;
}
public static void MusicRegion( Mobile from, Map map, Point3D loc, Point3D old )
{
Region regOld = Region.Find( old, map );
Region regNew = Region.Find( loc, map );
bool changeMusic = true;
if ( regOld != regNew )
{
if ( ( regNew is BuildingRegion && regOld is InnRegion ) ||
( regNew is InnRegion && regOld is BuildingRegion ) )
{ changeMusic = true; }
else if (
regNew is TreasureRegion || regOld is TreasureRegion ||
regNew is UnderworldEntrance || regOld is UnderworldEntrance ||
regNew is GardenRegion || regOld is GardenRegion ||
regNew is BuildingRegion || regOld is BuildingRegion ||
regNew is GateRegion || regOld is GateRegion ||
regNew is ShrineRegion || regOld is ShrineRegion ||
regNew is HouseRegion || regOld is HouseRegion )
{ changeMusic = false; }
else if (
( regNew is OutskirtRegion && regOld is TownRegion ) ||
( regNew is TownRegion && regOld is OutskirtRegion )
)
{ changeMusic = false; }
if ( changeMusic )
{
MusicName toPlay = LandMusic[Utility.Random(LandMusic.Length)];
if ( regNew is CaveRegion )
toPlay = CaveMusic[Utility.Random(CaveMusic.Length)];
else if ( regNew is DungeonRegion )
toPlay = DungeonMusic[Utility.Random(DungeonMusic.Length)];
else if ( regNew is GraveRegion )
toPlay = DungeonMusic[Utility.Random(DungeonMusic.Length)];
else if ( regNew is DangerRegion )
toPlay = DungeonMusic[Utility.Random(DungeonMusic.Length)];
else if ( regNew is PirateRegion )
toPlay = CaveMusic[Utility.Random(CaveMusic.Length)];
else if ( regNew is InnRegion )
toPlay = TavernMusic[Utility.Random(TavernMusic.Length)];
else if ( regNew is BuildingRegion )
toPlay = VillageMusic[Utility.Random(VillageMusic.Length)];
else if ( regNew is TownRegion )
toPlay = VillageMusic[Utility.Random(VillageMusic.Length)];
else if ( regNew is OutskirtRegion )
toPlay = VillageMusic[Utility.Random(VillageMusic.Length)];
from.Send(PlayMusic.GetInstance(toPlay));
}
}
}
public static MusicName[] TavernMusic = new MusicName[]
{
MusicName.Tavern01,
MusicName.Tavern02,
MusicName.Tavern03,
MusicName.Tavern04,
MusicName.Tavern05
};
public static MusicName[] VillageMusic = new MusicName[]
{
MusicName.Britain1,
MusicName.Bucsden,
MusicName.Jhelom,
MusicName.Magincia,
MusicName.Minoc,
MusicName.Ocllo,
MusicName.Serpents,
MusicName.Skarabra,
MusicName.Trinsic,
MusicName.Vesper,
MusicName.Wind,
MusicName.Yew,
MusicName.InTown01,
MusicName.Nujelm,
MusicName.Cove,
MusicName.Moonglow
};
public static MusicName[] CaveMusic = new MusicName[]
{
MusicName.Create1,
MusicName.OldUlt02,
MusicName.OldUlt03,
MusicName.OldUlt05,
MusicName.OldUlt06,
MusicName.Samlethe,
MusicName.Cave01,
MusicName.Jungle_a,
MusicName.Swamp_a,
MusicName.Jungle_a
};
public static MusicName[] DungeonMusic = new MusicName[]
{
MusicName.OldUlt03,
MusicName.OldUlt05,
MusicName.Samlethe,
MusicName.Dungeon9,
MusicName.Dungeon2,
MusicName.Dungeon3,
MusicName.Approach
};
public static MusicName[] LandMusic = new MusicName[]
{
MusicName.Create1,
MusicName.OldUlt02,
MusicName.OldUlt03,
MusicName.Linelle,
MusicName.Forest_a,
MusicName.Mountn_a,
MusicName.Plains_a,
MusicName.Victory,
MusicName.Travel
};
}
}

View file

@ -0,0 +1,28 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using Server;
using Server.Commands;
using Server.Mobiles;
using Server.Spells;
namespace Server.Regions
{
public class ShrineRegion : BaseRegion
{
public ShrineRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
{
}
public override bool AllowHousing( Mobile from, Point3D p )
{
return false;
}
public override bool AllowHarmful( Mobile from, Mobile target )
{
return false;
}
}
}

View file

@ -0,0 +1,20 @@
using System;
using System.Xml;
using Server;
using Server.Mobiles;
using Server.Gumps;
namespace Server.Regions
{
public class ShrinesRegion : CaveRegion
{
public ShrinesRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
{
}
public override bool AllowHarmful( Mobile from, Mobile target )
{
return false;
}
}
}

View file

@ -0,0 +1,373 @@
using System;
using System.Collections;
using System.IO;
using System.Xml;
using Server;
using Server.Mobiles;
using Server.Items;
using System.Collections.Generic;
namespace Server.Regions
{
public abstract class SpawnDefinition
{
protected SpawnDefinition()
{
}
public abstract ISpawnable Spawn( SpawnEntry entry );
public abstract bool CanSpawn( params Type[] types );
public static SpawnDefinition GetSpawnDefinition( XmlElement xml )
{
switch ( xml.Name )
{
case "object":
{
Type type = null;
if ( !Region.ReadType( xml, "type", ref type ) )
return null;
if ( typeof( Mobile ).IsAssignableFrom( type ) )
{
return SpawnMobile.Get( type );
}
else if ( typeof( Item ).IsAssignableFrom( type ) )
{
return SpawnItem.Get( type );
}
else
{
Console.WriteLine( "Invalid type '{0}' in a SpawnDefinition", type.FullName );
return null;
}
}
case "group":
{
string group = null;
if ( !Region.ReadString( xml, "name", ref group ) )
return null;
SpawnDefinition def = (SpawnDefinition) SpawnGroup.Table[group];
if ( def == null )
{
Console.WriteLine( "Could not find group '{0}' in a SpawnDefinition", group );
return null;
}
else
{
return def;
}
}
default:
{
return null;
}
}
}
}
public abstract class SpawnType : SpawnDefinition
{
private Type m_Type;
private bool m_Init;
public Type Type{ get{ return m_Type; } }
public abstract int Height{ get; }
public abstract bool Land{ get; }
public abstract bool Water{ get; }
protected SpawnType( Type type )
{
m_Type = type;
m_Init = false;
}
protected void EnsureInit()
{
if ( m_Init )
return;
Init();
m_Init = true;
}
protected virtual void Init()
{
}
public override ISpawnable Spawn( SpawnEntry entry )
{
BaseRegion region = entry.Region;
Map map = region.Map;
Point3D loc = entry.RandomSpawnLocation( this.Height, this.Land, this.Water );
if ( loc == Point3D.Zero )
return null;
return Construct( entry, loc, map );
}
protected abstract ISpawnable Construct( SpawnEntry entry, Point3D loc, Map map );
public override bool CanSpawn( params Type[] types )
{
for ( int i = 0; i < types.Length; i++ )
{
if ( types[i] == m_Type )
return true;
}
return false;
}
}
public class SpawnMobile : SpawnType
{
private static Hashtable m_Table = new Hashtable();
public static SpawnMobile Get( Type type )
{
SpawnMobile sm = (SpawnMobile) m_Table[type];
if ( sm == null )
{
sm = new SpawnMobile( type );
m_Table[type] = sm;
}
return sm;
}
protected bool m_Land;
protected bool m_Water;
public override int Height{ get{ return 16; } }
public override bool Land{ get{ EnsureInit(); return m_Land; } }
public override bool Water{ get{ EnsureInit(); return m_Water; } }
protected SpawnMobile( Type type ) : base( type )
{
}
protected override void Init()
{
Mobile mob = (Mobile) Activator.CreateInstance( Type );
m_Land = !mob.CantWalk;
m_Water = mob.CanSwim;
mob.Delete();
}
protected override ISpawnable Construct(SpawnEntry entry, Point3D loc, Map map)
{
Mobile mobile = CreateMobile();
BaseCreature creature = mobile as BaseCreature;
if ( creature != null )
{
creature.Home = entry.HomeLocation;
creature.RangeHome = entry.HomeRange;
}
if ( entry.Direction != SpawnEntry.InvalidDirection )
mobile.Direction = entry.Direction;
mobile.OnBeforeSpawn( loc, map );
mobile.MoveToWorld( loc, map );
mobile.OnAfterSpawn();
return mobile;
}
protected virtual Mobile CreateMobile()
{
return (Mobile) Activator.CreateInstance( Type );
}
}
public class SpawnItem : SpawnType
{
private static Hashtable m_Table = new Hashtable();
public static SpawnItem Get( Type type )
{
SpawnItem si = (SpawnItem) m_Table[type];
if ( si == null )
{
si = new SpawnItem( type );
m_Table[type] = si;
}
return si;
}
protected int m_Height;
public override int Height{ get{ EnsureInit(); return m_Height; } }
public override bool Land{ get{ return true; } }
public override bool Water{ get{ return false; } }
protected SpawnItem( Type type ) : base( type )
{
}
protected override void Init()
{
Item item = (Item) Activator.CreateInstance( Type );
m_Height = item.ItemData.Height;
item.Delete();
}
protected override ISpawnable Construct( SpawnEntry entry, Point3D loc, Map map )
{
Item item = CreateItem();
item.OnBeforeSpawn( loc, map );
item.MoveToWorld( loc, map );
item.OnAfterSpawn();
return item;
}
protected virtual Item CreateItem()
{
return (Item) Activator.CreateInstance( Type );
}
}
public class SpawnGroupElement
{
private SpawnDefinition m_SpawnDefinition;
private int m_Weight;
public SpawnDefinition SpawnDefinition{ get{ return m_SpawnDefinition; } }
public int Weight{ get{ return m_Weight; } }
public SpawnGroupElement( SpawnDefinition spawnDefinition, int weight )
{
m_SpawnDefinition = spawnDefinition;
m_Weight = weight;
}
}
public class SpawnGroup : SpawnDefinition
{
private static Hashtable m_Table = new Hashtable();
public static Hashtable Table{ get{ return m_Table; } }
public static void Register( SpawnGroup group )
{
if ( m_Table.Contains( group.Name ) )
Console.WriteLine( "Warning: Double SpawnGroup name '{0}'", group.Name );
else
m_Table[group.Name] = group;
}
static SpawnGroup()
{
string path = Path.Combine( Core.BaseDirectory, "Data/Config/SpawnDefinitions.xml" );
if ( !File.Exists( path ) )
return;
try
{
XmlDocument doc = new XmlDocument();
doc.Load( path );
XmlElement root = doc["spawnDefinitions"];
if ( root == null )
return;
foreach ( XmlElement xmlDef in root.SelectNodes( "spawnGroup" ) )
{
string name = null;
if ( !Region.ReadString( xmlDef, "name", ref name ) )
continue;
List<SpawnGroupElement> list = new List<SpawnGroupElement>();
foreach ( XmlNode node in xmlDef.ChildNodes )
{
XmlElement el = node as XmlElement;
if ( el != null )
{
SpawnDefinition def = GetSpawnDefinition( el );
if ( def == null )
continue;
int weight = 1;
Region.ReadInt32( el, "weight", ref weight, false );
SpawnGroupElement groupElement = new SpawnGroupElement( def, weight );
list.Add( groupElement );
}
}
SpawnGroupElement[] elements = list.ToArray();
SpawnGroup group = new SpawnGroup( name, elements );
Register( group );
}
}
catch ( Exception ex )
{
Console.WriteLine( "Could not load SpawnDefinitions.xml: " + ex.Message );
}
}
private string m_Name;
private SpawnGroupElement[] m_Elements;
private int m_TotalWeight;
public string Name{ get{ return m_Name; } }
public SpawnGroupElement[] Elements{ get{ return m_Elements; } }
public SpawnGroup( string name, SpawnGroupElement[] elements )
{
m_Name = name;
m_Elements = elements;
m_TotalWeight = 0;
for ( int i = 0; i < elements.Length; i++ )
m_TotalWeight += elements[i].Weight;
}
public override ISpawnable Spawn(SpawnEntry entry)
{
int index = Utility.Random( m_TotalWeight );
for ( int i = 0; i < m_Elements.Length; i++ )
{
SpawnGroupElement element = m_Elements[i];
if ( index < element.Weight )
return element.SpawnDefinition.Spawn( entry );
index -= element.Weight;
}
return null;
}
public override bool CanSpawn( params Type[] types )
{
for ( int i = 0; i < m_Elements.Length; i++ )
{
if ( m_Elements[i].SpawnDefinition.CanSpawn( types ) )
return true;
}
return false;
}
}
}

View file

@ -0,0 +1,465 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Mobiles;
using Server.Commands;
namespace Server.Regions
{
public class SpawnEntry : ISpawner
{
public static readonly TimeSpan DefaultMinSpawnTime = TimeSpan.FromMinutes( 2.0 );
public static readonly TimeSpan DefaultMaxSpawnTime = TimeSpan.FromMinutes( 5.0 );
private static Hashtable m_Table = new Hashtable();
public static Hashtable Table{ get{ return m_Table; } }
// When a creature's AI is deactivated (PlayerRangeSensitive optimization) does it return home?
public bool ReturnOnDeactivate{ get{ return true; } }
// Are creatures unlinked on taming (true) or should they also go out of the region (false)?
public bool UnlinkOnTaming{ get{ return false; } }
// Are unlinked and untamed creatures removed after 20 hours?
public bool RemoveIfUntamed{ get{ return true; } }
public static readonly Direction InvalidDirection = Direction.Running;
private int m_ID;
private BaseRegion m_Region;
private Point3D m_Home;
private int m_Range;
private Direction m_Direction;
private SpawnDefinition m_Definition;
private List<ISpawnable> m_SpawnedObjects;
private int m_Max;
private TimeSpan m_MinSpawnTime;
private TimeSpan m_MaxSpawnTime;
private bool m_Running;
private DateTime m_NextSpawn;
private Timer m_SpawnTimer;
public int ID{ get{ return m_ID; } }
public BaseRegion Region{ get{ return m_Region; } }
public Point3D HomeLocation{ get{ return m_Home; } }
public int HomeRange{ get{ return m_Range; } }
public Direction Direction{ get{ return m_Direction; } }
public SpawnDefinition Definition{ get{ return m_Definition; } }
public List<ISpawnable> SpawnedObjects{ get{ return m_SpawnedObjects; } }
public int Max{ get{ return m_Max; } }
public TimeSpan MinSpawnTime{ get{ return m_MinSpawnTime; } }
public TimeSpan MaxSpawnTime{ get{ return m_MaxSpawnTime; } }
public bool Running{ get{ return m_Running; } }
public bool Complete{ get{ return m_SpawnedObjects.Count >= m_Max; } }
public bool Spawning{ get{ return m_Running && !this.Complete; } }
public SpawnEntry( int id, BaseRegion region, Point3D home, int range, Direction direction, SpawnDefinition definition, int max, TimeSpan minSpawnTime, TimeSpan maxSpawnTime )
{
m_ID = id;
m_Region = region;
m_Home = home;
m_Range = range;
m_Direction = direction;
m_Definition = definition;
m_SpawnedObjects = new List<ISpawnable>();
m_Max = max;
m_MinSpawnTime = minSpawnTime;
m_MaxSpawnTime = maxSpawnTime;
m_Running = false;
if ( m_Table.Contains( id ) )
Console.WriteLine( "Warning: double SpawnEntry ID '{0}'", id );
else
m_Table[id] = this;
}
public Point3D RandomSpawnLocation( int spawnHeight, bool land, bool water )
{
return m_Region.RandomSpawnLocation( spawnHeight, land, water, m_Home, m_Range );
}
public void Start()
{
if ( m_Running )
return;
m_Running = true;
CheckTimer();
}
public void Stop()
{
if ( !m_Running )
return;
m_Running = false;
CheckTimer();
}
private void Spawn()
{
ISpawnable spawn = m_Definition.Spawn(this);
if ( spawn != null )
Add( spawn );
}
private void Add( ISpawnable spawn )
{
m_SpawnedObjects.Add( spawn );
spawn.Spawner = this;
if ( spawn is BaseCreature )
((BaseCreature)spawn).RemoveIfUntamed = this.RemoveIfUntamed;
}
void ISpawner.Remove( ISpawnable spawn )
{
m_SpawnedObjects.Remove( spawn );
CheckTimer();
}
private TimeSpan RandomTime()
{
int min = (int) m_MinSpawnTime.TotalSeconds;
int max = (int) m_MaxSpawnTime.TotalSeconds;
int rand = Utility.RandomMinMax( min, max );
return TimeSpan.FromSeconds( rand );
}
private void CheckTimer()
{
if ( this.Spawning )
{
if ( m_SpawnTimer == null )
{
TimeSpan time = RandomTime();
m_SpawnTimer = Timer.DelayCall( time, new TimerCallback( TimerCallback ) );
m_NextSpawn = DateTime.Now + time;
}
}
else if ( m_SpawnTimer != null )
{
m_SpawnTimer.Stop();
m_SpawnTimer = null;
}
}
private void TimerCallback()
{
int amount = Math.Max( (m_Max - m_SpawnedObjects.Count) / 3, 1 );
for ( int i = 0; i < amount; i++ )
Spawn();
m_SpawnTimer = null;
CheckTimer();
}
public void DeleteSpawnedObjects()
{
InternalDeleteSpawnedObjects();
m_Running = false;
CheckTimer();
}
private void InternalDeleteSpawnedObjects()
{
foreach ( ISpawnable spawnable in m_SpawnedObjects )
{
spawnable.Spawner = null;
bool uncontrolled = !(spawnable is BaseCreature) || !((BaseCreature)spawnable).Controlled;
if( uncontrolled )
spawnable.Delete();
}
m_SpawnedObjects.Clear();
}
public void Respawn()
{
InternalDeleteSpawnedObjects();
for ( int i = 0; !this.Complete && i < m_Max; i++ )
Spawn();
m_Running = true;
CheckTimer();
}
public void Delete()
{
m_Max = 0;
InternalDeleteSpawnedObjects();
if ( m_SpawnTimer != null )
{
m_SpawnTimer.Stop();
m_SpawnTimer = null;
}
if ( m_Table[m_ID] == this )
m_Table.Remove( m_ID );
}
public void Serialize( GenericWriter writer )
{
writer.Write( (int) m_SpawnedObjects.Count );
for ( int i = 0; i < m_SpawnedObjects.Count; i++ )
{
ISpawnable spawn = m_SpawnedObjects[i];
int serial = spawn.Serial;
writer.Write( (int) serial );
}
writer.Write( (bool) m_Running );
if ( m_SpawnTimer != null )
{
writer.Write( true );
writer.WriteDeltaTime( (DateTime) m_NextSpawn );
}
else
{
writer.Write( false );
}
}
public void Deserialize( GenericReader reader, int version )
{
int count = reader.ReadInt();
for ( int i = 0; i < count; i++ )
{
int serial = reader.ReadInt();
ISpawnable spawnableEntity = World.FindEntity( serial ) as ISpawnable;
if (spawnableEntity != null)
Add(spawnableEntity);
}
m_Running = reader.ReadBool();
if ( reader.ReadBool() )
{
m_NextSpawn = reader.ReadDeltaTime();
if ( this.Spawning )
{
if ( m_SpawnTimer != null )
m_SpawnTimer.Stop();
TimeSpan delay = m_NextSpawn - DateTime.Now;
m_SpawnTimer = Timer.DelayCall( delay > TimeSpan.Zero ? delay : TimeSpan.Zero, new TimerCallback( TimerCallback ) );
}
}
CheckTimer();
}
private static List<IEntity> m_RemoveList;
public static void Remove( GenericReader reader, int version )
{
int count = reader.ReadInt();
for ( int i = 0; i < count; i++ )
{
int serial = reader.ReadInt();
IEntity entity = World.FindEntity( serial );
if ( entity != null )
{
if ( m_RemoveList == null )
m_RemoveList = new List<IEntity>();
m_RemoveList.Add( entity );
}
}
reader.ReadBool(); // m_Running
if ( reader.ReadBool() )
reader.ReadDeltaTime(); // m_NextSpawn
}
public static void Initialize()
{
if ( m_RemoveList != null )
{
foreach ( IEntity ent in m_RemoveList )
{
ent.Delete();
}
m_RemoveList = null;
}
SpawnPersistence.EnsureExistence();
CommandSystem.Register( "RespawnAllRegions", AccessLevel.Administrator, new CommandEventHandler( RespawnAllRegions_OnCommand ) );
CommandSystem.Register( "RespawnRegion", AccessLevel.GameMaster, new CommandEventHandler( RespawnRegion_OnCommand ) );
CommandSystem.Register( "DelAllRegionSpawns", AccessLevel.Administrator, new CommandEventHandler( DelAllRegionSpawns_OnCommand ) );
CommandSystem.Register( "DelRegionSpawns", AccessLevel.GameMaster, new CommandEventHandler( DelRegionSpawns_OnCommand ) );
CommandSystem.Register( "StartAllRegionSpawns", AccessLevel.Administrator, new CommandEventHandler( StartAllRegionSpawns_OnCommand ) );
CommandSystem.Register( "StartRegionSpawns", AccessLevel.GameMaster, new CommandEventHandler( StartRegionSpawns_OnCommand ) );
CommandSystem.Register( "StopAllRegionSpawns", AccessLevel.Administrator, new CommandEventHandler( StopAllRegionSpawns_OnCommand ) );
CommandSystem.Register( "StopRegionSpawns", AccessLevel.GameMaster, new CommandEventHandler( StopRegionSpawns_OnCommand ) );
}
private static BaseRegion GetCommandData( CommandEventArgs args )
{
Mobile from = args.Mobile;
Region reg;
if ( args.Length == 0 )
{
reg = from.Region;
}
else
{
string name = args.GetString( 0 );
//reg = (Region) from.Map.Regions[name];
if ( !from.Map.Regions.TryGetValue( name, out reg ) )
{
from.SendMessage( "Could not find region '{0}'.", name );
return null;
}
}
BaseRegion br = reg as BaseRegion;
if ( br == null || br.Spawns == null )
{
from.SendMessage( "There are no spawners in region '{0}'.", reg );
return null;
}
return br;
}
[Usage( "RespawnAllRegions" )]
[Description( "Respawns all regions and sets the spawners as running." )]
public static void RespawnAllRegions_OnCommand( CommandEventArgs args )
{
foreach ( SpawnEntry entry in m_Table.Values )
{
entry.Respawn();
}
args.Mobile.SendMessage( "All regions have respawned." );
}
[Usage( "RespawnRegion [<region name>]" )]
[Description( "Respawns the region in which you are (or that you provided) and sets the spawners as running." )]
private static void RespawnRegion_OnCommand( CommandEventArgs args )
{
BaseRegion region = GetCommandData( args );
if ( region == null )
return;
for ( int i = 0; i < region.Spawns.Length; i++ )
region.Spawns[i].Respawn();
args.Mobile.SendMessage( "Region '{0}' has respawned.", region );
}
[Usage( "DelAllRegionSpawns" )]
[Description( "Deletes all spawned objects of every regions and sets the spawners as not running." )]
private static void DelAllRegionSpawns_OnCommand( CommandEventArgs args )
{
foreach ( SpawnEntry entry in m_Table.Values )
{
entry.DeleteSpawnedObjects();
}
args.Mobile.SendMessage( "All region spawned objects have been deleted." );
}
[Usage( "DelRegionSpawns [<region name>]" )]
[Description( "Deletes all spawned objects of the region in which you are (or that you provided) and sets the spawners as not running." )]
private static void DelRegionSpawns_OnCommand( CommandEventArgs args )
{
BaseRegion region = GetCommandData( args );
if ( region == null )
return;
for ( int i = 0; i < region.Spawns.Length; i++ )
region.Spawns[i].DeleteSpawnedObjects();
args.Mobile.SendMessage( "Spawned objects of region '{0}' have been deleted.", region );
}
[Usage( "StartAllRegionSpawns" )]
[Description( "Sets the region spawners of all regions as running." )]
private static void StartAllRegionSpawns_OnCommand( CommandEventArgs args )
{
foreach ( SpawnEntry entry in m_Table.Values )
{
entry.Start();
}
args.Mobile.SendMessage( "All region spawners have started." );
}
[Usage( "StartRegionSpawns [<region name>]" )]
[Description( "Sets the region spawners of the region in which you are (or that you provided) as running." )]
private static void StartRegionSpawns_OnCommand( CommandEventArgs args )
{
BaseRegion region = GetCommandData( args );
if ( region == null )
return;
for ( int i = 0; i < region.Spawns.Length; i++ )
region.Spawns[i].Start();
args.Mobile.SendMessage( "Spawners of region '{0}' have started.", region );
}
[Usage( "StopAllRegionSpawns" )]
[Description( "Sets the region spawners of all regions as not running." )]
private static void StopAllRegionSpawns_OnCommand( CommandEventArgs args )
{
foreach ( SpawnEntry entry in m_Table.Values )
{
entry.Stop();
}
args.Mobile.SendMessage( "All region spawners have stopped." );
}
[Usage( "StopRegionSpawns [<region name>]" )]
[Description( "Sets the region spawners of the region in which you are (or that you provided) as not running." )]
private static void StopRegionSpawns_OnCommand( CommandEventArgs args )
{
BaseRegion region = GetCommandData( args );
if ( region == null )
return;
for ( int i = 0; i < region.Spawns.Length; i++ )
region.Spawns[i].Stop();
args.Mobile.SendMessage( "Spawners of region '{0}' have stopped.", region );
}
}
}

View file

@ -0,0 +1,69 @@
using System;
using System.Collections;
using Server;
namespace Server.Regions
{
public class SpawnPersistence : Item
{
private static SpawnPersistence m_Instance;
public SpawnPersistence Instance{ get{ return m_Instance; } }
public static void EnsureExistence()
{
if ( m_Instance == null )
m_Instance = new SpawnPersistence();
}
public override string DefaultName
{
get { return "Region spawn persistence - Internal"; }
}
private SpawnPersistence() : base( 1 )
{
Movable = false;
}
public SpawnPersistence( Serial serial ) : base( serial )
{
m_Instance = this;
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.WriteEncodedInt( 0 ); // version
writer.Write( (int) SpawnEntry.Table.Values.Count );
foreach ( SpawnEntry entry in SpawnEntry.Table.Values )
{
writer.Write( (int) entry.ID );
entry.Serialize( writer );
}
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadEncodedInt();
int count = reader.ReadInt();
for ( int i = 0; i < count; i++ )
{
int id = reader.ReadInt();
SpawnEntry entry = (SpawnEntry) SpawnEntry.Table[id];
if ( entry != null )
entry.Deserialize( reader, version );
else
SpawnEntry.Remove( reader, version );
}
}
}
}

View file

@ -0,0 +1,34 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using Server;
using Server.Commands;
using Server.Mobiles;
using Server.Spells;
namespace Server.Regions
{
public class TownRegion : BaseRegion
{
public TownRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
{
}
public override bool OnBeginSpellCast( Mobile m, ISpell s )
{
if ( !s.OnCastInTown( this ) )
{
m.SendLocalizedMessage( 500946 ); // You cannot cast this in town!
return false;
}
return base.OnBeginSpellCast( m, s );
}
public override bool AllowHousing( Mobile from, Point3D p )
{
return true;
}
}
}

View file

@ -0,0 +1,77 @@
using System;
using System.IO;
using System.Collections;
using Server;
using Server.Regions;
namespace Server
{
public class UnderworldEntrance : BaseRegion
{
private const int Range = 10; // No house may be placed within 5 tiles of the entrances
public UnderworldEntrance( int x, int y, Map map ): base( null, map, Region.DefaultPriority, new Rectangle2D( x - Range, y - Range, 1 + (Range * 2), 1 + (Range * 2) ) )
{
GoLocation = new Point3D( x, y, map.GetAverageZ( x, y ) );
Register();
}
public static void Initialize()
{
string filePath = Path.Combine( Core.BaseDirectory, "Data/Config/entrances.cfg" );
int i = 0, x = 0, y = 0;
if ( File.Exists( filePath ) )
{
using ( StreamReader ip = new StreamReader( filePath ) )
{
string line;
while ( (line = ip.ReadLine()) != null )
{
i++;
try
{
string[] split = line.Split( ' ' );
x = Convert.ToInt32( split[0] );
y = Convert.ToInt32( split[1] );
try
{
new UnderworldEntrance( x, y, Map.Britannia );
}
catch ( Exception e )
{
Console.WriteLine( "{0} {1} {2} {3}", i, x, y, e );
}
}
catch
{
Console.WriteLine( "Warning: Error in Line '{0}' of Data/Config/treasure.cfg", line );
}
}
}
}
}
public override bool AllowHousing( Mobile from, Point3D p )
{
return false;
}
public override void OnEnter( Mobile m )
{
if ( m.AccessLevel > AccessLevel.Player )
m.SendMessage( "You have entered a protected underworld entrance area." );
}
public override void OnExit( Mobile m )
{
if ( m.AccessLevel > AccessLevel.Player )
m.SendMessage( "You have left a protected underworld entrance area." );
}
}
}