ModernUO/Scripts/Engines/Spawner/ProximitySpawner.cs
eos a0e13d5007 - Future ML craftables added to the special repair list until the craft system is updated.
- Items can now be repaired while wearing them.
- Items can now be fortified while wearing them.
- Fixed repair deed messages not sending.
- Sound effect added to powder of fortifying.
- Map issue for fishing and SOSs fixed, where it would not allow fishing in empty resource banks when not on the target SOS map.
- Added proximity spawner.
- Improved spawner mouseover menu, now also shows types set on the spawner which are not yet spawned.
- Fixed spawners only deleting half of their spawned objects when deleted.
- Added the ability to set TextDefinition objects in the props gump.
- WaitTeleporters now round delays to nearest in the remaining time messages.
- Updated TextDefinition to be more usable; made it parsable from string and added safe serialization/deserialization methods.
- Improved checking whether a mobile can flee.
- Monsters that give ML minor artifacts will no longer flee when low on hits (like paragons).
- Monsters that give ML minor artifacts will no longer spawn as paragon.
- Fixed issue with pets not eating certain foods.
- AI and targeting fixes for Red Death, Pyre and Swoop.
- Fame and karma added to Rend.
- Swoop corrected to have 0 karma.
- Stat and skill tweaks for Putrefier.
- Changelings will no longer show their fame title when morphed.
- Added travel restrictions for ML dungeons.
- Fixed issue of travel restriction message displaying twice.
- Monster teleporting is no longer affected by region travel restrictions.
2012-03-07 18:59:52 +00:00

176 lines
4.1 KiB
C#

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.Now + delay;
}
public override void Respawn()
{
RemoveSpawned();
End = DateTime.Now;
}
public override void Spawn()
{
for ( int i = 0; i < SpawnNamesCount; ++i )
{
for ( int j = 0; j < Count; ++j )
Spawn( i );
}
}
public override bool CheckSpawnCount()
{
return true;
}
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.Now && 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();
}
}
}