- Fixed spawner to correctly spawn sea creatures on water tiles.

- Fixed the individual clear button in the spawner gump.
- The spawner gump now reloads unless it is closed or cancel is pressed.
- Fixed conflicting button IDs in AdminGump.
- Fixed the Developer and Owner accesslevel buttons for accounts in AdminGump.
- Owners are now allowed to set other accounts as Owner.
- The client gump now accounts for the visibility list when checking visibility of higher accesslevel focus mobs.
- The hue of the Protector shroud is now picked randomly as well, it is no longer the inverse of their boots hue.
This commit is contained in:
eos 2012-05-13 01:51:14 +00:00
parent 6962ed06bf
commit e372d20b00
5 changed files with 98 additions and 33 deletions

View file

@ -544,21 +544,21 @@ namespace Server.Mobiles
ISpawnable spawned = CreateSpawnedObject( index );
if (spawned == null)
if ( spawned == null )
return;
spawned.Spawner = this;
m_Spawned.Add(spawned);
m_Spawned.Add( spawned );
Point3D loc = (spawned is BaseVendor ? this.Location : GetSpawnPosition());
Point3D loc = ( spawned is BaseVendor ? this.Location : GetSpawnPosition( spawned ) );
spawned.OnBeforeSpawn(loc, map);
spawned.OnBeforeSpawn( loc, map );
InvalidateProperties();
spawned.MoveToWorld(loc, map);
spawned.MoveToWorld( loc, map );
if (spawned is BaseCreature)
if ( spawned is BaseCreature )
{
BaseCreature bc = (BaseCreature)spawned;
@ -577,36 +577,93 @@ namespace Server.Mobiles
}
public Point3D GetSpawnPosition()
{
return GetSpawnPosition( null );
}
public Point3D GetSpawnPosition( ISpawnable spawned )
{
Map map = Map;
if ( map == null )
return Location;
// Try 10 times to find a Spawnable location.
for ( int i = 0; i < 10; i++ )
bool waterMob, waterOnlyMob;
if ( spawned is Mobile )
{
Mobile mob = (Mobile)spawned;
waterMob = mob.CanSwim;
waterOnlyMob = ( mob.CanSwim && mob.CantWalk );
}
else
{
waterMob = false;
waterOnlyMob = false;
}
// Try 10 times to find a spawnable location.
for ( int i = 0; i < 10; ++i )
{
int x, y;
if ( m_HomeRange > 0 ) {
x = Location.X + (Utility.Random( (m_HomeRange * 2) + 1 ) - m_HomeRange);
y = Location.Y + (Utility.Random( (m_HomeRange * 2) + 1 ) - m_HomeRange);
} else {
if ( m_HomeRange > 0 )
{
x = Location.X + ( Utility.Random( ( m_HomeRange * 2 ) + 1 ) - m_HomeRange );
y = Location.Y + ( Utility.Random( ( m_HomeRange * 2 ) + 1 ) - m_HomeRange );
}
else
{
x = Location.X;
y = Location.Y;
}
int z = Map.GetAverageZ( x, y );
int mapZ = map.GetAverageZ( x, y );
if ( Map.CanSpawnMobile( new Point2D( x, y ), this.Z ) )
return new Point3D( x, y, this.Z );
else if ( Map.CanSpawnMobile( new Point2D( x, y ), z ) )
return new Point3D( x, y, z );
if ( waterMob )
{
if ( IsValidWater( map, x, y, this.Z ) )
return new Point3D( x, y, this.Z );
else if ( IsValidWater( map, x, y, mapZ ) )
return new Point3D( x, y, mapZ );
}
if ( !waterOnlyMob )
{
if ( map.CanSpawnMobile( x, y, this.Z ) )
return new Point3D( x, y, this.Z );
else if ( map.CanSpawnMobile( x, y, mapZ ) )
return new Point3D( x, y, mapZ );
}
}
return this.Location;
}
public static bool IsValidWater( Map map, int x, int y, int z )
{
if ( !Region.Find( new Point3D( x, y, z ), map ).AllowSpawn() || !map.CanFit( x, y, z, 16, false, true, false ) )
return false;
LandTile landTile = map.Tiles.GetLandTile( x, y );
if ( landTile.Z == z && ( TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Wet ) != 0 )
return true;
StaticTile[] staticTiles = map.Tiles.GetStaticTiles( x, y, true );
for ( int i = 0; i < staticTiles.Length; ++i )
{
StaticTile staticTile = staticTiles[i];
if ( staticTile.Z == z && ( TileData.ItemTable[staticTile.ID & TileData.MaxItemValue].Flags & TileFlag.Wet ) != 0 )
return true;
}
return false;
}
public void DoTimer()
{
if ( !m_Running )
@ -710,7 +767,7 @@ namespace Server.Mobiles
{
Defrag();
for ( int i = 0; i < m_Spawned.Count; ++i )
for ( int i = m_Spawned.Count - 1; i >= 0; --i )
{
IEntity e = m_Spawned[i];

View file

@ -18,13 +18,13 @@ namespace Server.Mobiles
AddBackground( 0, 0, 410, 371, 5054 );
AddLabel( 95, 1, 0, "Creatures List" );
AddLabel( 160, 1, 0, "Creatures List" );
AddButton( 5, 347, 0xFB1, 0xFB3, 0, GumpButtonType.Reply, 0 );
AddLabel( 38, 347, 0x384, "Cancel" );
AddButton( 5, 325, 0xFB7, 0xFB9, 1, GumpButtonType.Reply, 0 );
AddLabel( 38, 325, 0x384, "Okay" );
AddLabel( 38, 325, 0x384, "Apply" );
AddButton( 110, 325, 0xFB4, 0xFB6, 2, GumpButtonType.Reply, 0 );
AddLabel( 143, 325, 0x384, "Bring to Home" );
@ -87,28 +87,28 @@ namespace Server.Mobiles
public override void OnResponse( NetState state, RelayInfo info )
{
if ( m_Spawner.Deleted )
if ( m_Spawner.Deleted || state.Mobile.AccessLevel < AccessLevel.GameMaster )
return;
switch ( info.ButtonID )
{
case 0: // Closed
{
break;
return;
}
case 1: // Okay
case 1: // Apply
{
m_Spawner.SpawnNames = CreateArray( info, state.Mobile );
break;
}
case 2: // Bring everything home
case 2: // Bring to Home
{
m_Spawner.BringToHome();
break;
}
case 3: // Complete respawn
case 3: // Total Respawn
{
m_Spawner.Respawn();
@ -135,6 +135,8 @@ namespace Server.Mobiles
break;
}
}
state.Mobile.SendGump( new SpawnerGump( m_Spawner ) );
}
}
}