#W# Source and Scripts added. Added Scripts/Settings.cs to expose some basic tweak able settings.
This commit is contained in:
parent
b51c58f514
commit
3045c83799
3512 changed files with 627673 additions and 0 deletions
176
Scripts/Engines/Spawner/ProximitySpawner.cs
Normal file
176
Scripts/Engines/Spawner/ProximitySpawner.cs
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class ProximitySpawner : Spawner
|
||||
{
|
||||
private int m_TriggerRange;
|
||||
private TextDefinition m_SpawnMessage;
|
||||
private bool m_InstantFlag;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int TriggerRange
|
||||
{
|
||||
get { return m_TriggerRange; }
|
||||
set { m_TriggerRange = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public TextDefinition SpawnMessage
|
||||
{
|
||||
get { return m_SpawnMessage; }
|
||||
set { m_SpawnMessage = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool InstantFlag
|
||||
{
|
||||
get { return m_InstantFlag; }
|
||||
set { m_InstantFlag = value; }
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public ProximitySpawner()
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public ProximitySpawner( string spawnName )
|
||||
: base( spawnName )
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public ProximitySpawner( int amount, int minDelay, int maxDelay, int team, int homeRange, string spawnName )
|
||||
: base( amount, minDelay, maxDelay, team, homeRange, spawnName )
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public ProximitySpawner( int amount, int minDelay, int maxDelay, int team, int homeRange, string spawnName, int triggerRange, string spawnMessage, bool instantFlag )
|
||||
: base( amount, minDelay, maxDelay, team, homeRange, spawnName )
|
||||
{
|
||||
m_TriggerRange = triggerRange;
|
||||
m_SpawnMessage = TextDefinition.Parse( spawnMessage );
|
||||
m_InstantFlag = instantFlag;
|
||||
}
|
||||
|
||||
public ProximitySpawner( int amount, TimeSpan minDelay, TimeSpan maxDelay, int team, int homeRange, List<string> spawnNames )
|
||||
: base( amount, minDelay, maxDelay, team, homeRange, spawnNames )
|
||||
{
|
||||
}
|
||||
|
||||
public ProximitySpawner( int amount, TimeSpan minDelay, TimeSpan maxDelay, int team, int homeRange, List<string> spawnNames, int triggerRange, TextDefinition spawnMessage, bool instantFlag )
|
||||
: base( amount, minDelay, maxDelay, team, homeRange, spawnNames )
|
||||
{
|
||||
m_TriggerRange = triggerRange;
|
||||
m_SpawnMessage = spawnMessage;
|
||||
m_InstantFlag = instantFlag;
|
||||
}
|
||||
|
||||
public override string DefaultName
|
||||
{
|
||||
get { return "Proximity Spawner"; }
|
||||
}
|
||||
|
||||
public override void DoTimer( TimeSpan delay )
|
||||
{
|
||||
if ( !Running )
|
||||
return;
|
||||
|
||||
End = DateTime.UtcNow + delay;
|
||||
}
|
||||
|
||||
public override void Respawn()
|
||||
{
|
||||
RemoveSpawned();
|
||||
|
||||
End = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public override void Spawn()
|
||||
{
|
||||
for ( int i = 0; i < SpawnNamesCount; ++i )
|
||||
{
|
||||
for ( int j = 0; j < Count; ++j )
|
||||
Spawn( i );
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CheckSpawnerFull()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool HandlesOnMovement { get { return true; } }
|
||||
|
||||
public virtual bool ValidTrigger( Mobile m )
|
||||
{
|
||||
if ( m is BaseCreature )
|
||||
{
|
||||
BaseCreature bc = (BaseCreature)m;
|
||||
|
||||
if ( !bc.Controlled && !bc.Summoned )
|
||||
return false;
|
||||
}
|
||||
else if ( !m.Player )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return ( m.Alive && !m.IsDeadBondedPet && m.CanBeDamaged() && !m.Hidden );
|
||||
}
|
||||
|
||||
public override void OnMovement( Mobile m, Point3D oldLocation )
|
||||
{
|
||||
if ( !Running )
|
||||
return;
|
||||
|
||||
if ( IsEmpty && End <= DateTime.UtcNow && m.InRange( GetWorldLocation(), m_TriggerRange ) && m.Location != oldLocation && ValidTrigger( m ) )
|
||||
{
|
||||
TextDefinition.SendMessageTo( m, m_SpawnMessage );
|
||||
|
||||
DoTimer();
|
||||
Spawn();
|
||||
|
||||
if ( m_InstantFlag )
|
||||
{
|
||||
foreach ( ISpawnable spawned in Spawned )
|
||||
{
|
||||
if ( spawned is Mobile )
|
||||
((Mobile)spawned).Combatant = m;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ProximitySpawner( Serial serial )
|
||||
: base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
|
||||
writer.Write( m_TriggerRange );
|
||||
TextDefinition.Serialize( writer, m_SpawnMessage );
|
||||
writer.Write( m_InstantFlag );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
m_TriggerRange = reader.ReadInt();
|
||||
m_SpawnMessage = TextDefinition.Deserialize( reader );
|
||||
m_InstantFlag = reader.ReadBool();
|
||||
}
|
||||
}
|
||||
}
|
||||
1103
Scripts/Engines/Spawner/Spawner.cs
Normal file
1103
Scripts/Engines/Spawner/Spawner.cs
Normal file
File diff suppressed because it is too large
Load diff
142
Scripts/Engines/Spawner/SpawnerGump.cs
Normal file
142
Scripts/Engines/Spawner/SpawnerGump.cs
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Network;
|
||||
using Server.Gumps;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class SpawnerGump : Gump
|
||||
{
|
||||
private Spawner m_Spawner;
|
||||
|
||||
public SpawnerGump( Spawner spawner ) : base( 50, 50 )
|
||||
{
|
||||
m_Spawner = spawner;
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
AddBackground( 0, 0, 410, 371, 5054 );
|
||||
|
||||
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, "Apply" );
|
||||
|
||||
AddButton( 110, 325, 0xFB4, 0xFB6, 2, GumpButtonType.Reply, 0 );
|
||||
AddLabel( 143, 325, 0x384, "Bring to Home" );
|
||||
|
||||
AddButton( 110, 347, 0xFA8, 0xFAA, 3, GumpButtonType.Reply, 0 );
|
||||
AddLabel( 143, 347, 0x384, "Total Respawn" );
|
||||
|
||||
for ( int i = 0; i < 13; i++ )
|
||||
{
|
||||
AddButton( 5, ( 22 * i ) + 20, 0xFA5, 0xFA7, 4 + (i * 2), GumpButtonType.Reply, 0 );
|
||||
AddButton( 38, ( 22 * i ) + 20, 0xFA2, 0xFA4, 5 + (i * 2), GumpButtonType.Reply, 0 );
|
||||
|
||||
AddImageTiled( 71, ( 22 * i ) + 20, 309, 23, 0xA40 );
|
||||
AddImageTiled( 72, ( 22 * i ) + 21, 307, 21, 0xBBC );
|
||||
|
||||
string str = "";
|
||||
|
||||
if ( i < spawner.SpawnNames.Count )
|
||||
{
|
||||
str = (string)spawner.SpawnNames[i];
|
||||
int count = m_Spawner.CountCreatures( str );
|
||||
|
||||
AddLabel( 382, ( 22 * i ) + 20, 0, count.ToString() );
|
||||
}
|
||||
|
||||
AddTextEntry( 75, ( 22 * i ) + 21, 304, 21, 0, i, str );
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> CreateArray( RelayInfo info, Mobile from )
|
||||
{
|
||||
List<string> creaturesName = new List<string>();
|
||||
|
||||
for ( int i = 0; i < 13; i++ )
|
||||
{
|
||||
TextRelay te = info.GetTextEntry( i );
|
||||
|
||||
if ( te != null )
|
||||
{
|
||||
string str = te.Text;
|
||||
|
||||
if ( str.Length > 0 )
|
||||
{
|
||||
str = str.Trim();
|
||||
|
||||
string t = Spawner.ParseType( str );
|
||||
|
||||
Type type = ScriptCompiler.FindTypeByName( t );
|
||||
|
||||
if ( type != null )
|
||||
creaturesName.Add( str );
|
||||
else
|
||||
from.SendMessage( "{0} is not a valid type name.", t );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return creaturesName;
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState state, RelayInfo info )
|
||||
{
|
||||
if ( m_Spawner.Deleted || state.Mobile.AccessLevel < AccessLevel.GameMaster )
|
||||
return;
|
||||
|
||||
switch ( info.ButtonID )
|
||||
{
|
||||
case 0: // Closed
|
||||
{
|
||||
return;
|
||||
}
|
||||
case 1: // Apply
|
||||
{
|
||||
m_Spawner.SpawnNames = CreateArray( info, state.Mobile );
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // Bring to Home
|
||||
{
|
||||
m_Spawner.BringToHome();
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // Total Respawn
|
||||
{
|
||||
m_Spawner.Respawn();
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
int buttonID = info.ButtonID - 4;
|
||||
int index = buttonID / 2;
|
||||
int type = buttonID % 2;
|
||||
|
||||
TextRelay entry = info.GetTextEntry( index );
|
||||
|
||||
if ( entry != null && entry.Text.Length > 0 )
|
||||
{
|
||||
if ( type == 0 ) // Spawn creature
|
||||
m_Spawner.Spawn( entry.Text );
|
||||
else // Remove creatures
|
||||
m_Spawner.RemoveSpawned( entry.Text );
|
||||
|
||||
m_Spawner.SpawnNames = CreateArray( info, state.Mobile );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
state.Mobile.SendGump( new SpawnerGump( m_Spawner ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Scripts/Engines/Spawner/SpawnerType.cs
Normal file
14
Scripts/Engines/Spawner/SpawnerType.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class SpawnerType
|
||||
{
|
||||
public static Type GetType( string name )
|
||||
{
|
||||
return ScriptCompiler.FindTypeByName( name );
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue