Too much errors in Guardian Room, it is deleted to leave place for a new one.

This commit is contained in:
daedalus 2009-10-24 18:27:30 +00:00
parent 26eb53f2b5
commit 7c5453d101
4 changed files with 0 additions and 1095 deletions

View file

@ -1,87 +0,0 @@
using System;
using Server;
using Server.Items;
using Server.Engines.Doom;
namespace Server.Mobiles
{
[CorpseName( "a dark guardians' corpse" )]
public class DarkGuardian : BaseCreature
{
[Constructable]
public DarkGuardian() : base( AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4 )
{
Name = "a dark guardian";
Body = 78;
BaseSoundID = 0x3E9;
SetStr( 125, 150 );
SetDex( 100, 120 );
SetInt( 200, 235 );
SetHits( 150, 180 );
SetDamage( 43, 48 );
SetDamageType( ResistanceType.Physical, 10 );
SetDamageType( ResistanceType.Cold, 40 );
SetDamageType( ResistanceType.Energy, 50 );
SetResistance( ResistanceType.Physical, 40, 50 );
SetResistance( ResistanceType.Fire, 20, 45 );
SetResistance( ResistanceType.Cold, 50, 60 );
SetResistance( ResistanceType.Poison, 20, 45 );
SetResistance( ResistanceType.Energy, 30, 40 );
SetSkill( SkillName.EvalInt, 40.1, 50);
SetSkill( SkillName.Magery, 50.1, 60.0 );
SetSkill( SkillName.Meditation, 85.1, 95.0 );
SetSkill( SkillName.MagicResist, 50.1, 70.0 );
SetSkill( SkillName.Tactics, 50.1, 70.0 );
Fame = 5000;
Karma = -5000;
VirtualArmor = 50;
PackNecroReg( 15, 25 );
PackItem( new DaemonBone( 30 ) );
}
public DarkGuardian( Serial serial ) : base( serial )
{
}
public override void GenerateLoot()
{
AddLoot( LootPack.Rich );
AddLoot( LootPack.MedScrolls, 2 );
}
public override OppositionGroup OppositionGroup
{
get{ return OppositionGroup.FeyAndUndead; }
}
public override int TreasureMapLevel{ get{ return 2; } }
public override bool BleedImmune{ get{ return true; } }
public override Poison PoisonImmune{ get{ return Poison.Lethal; } }
public override bool Unprovokable { get { return true; } }
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.WriteEncodedInt( 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadEncodedInt();
if ( Region is GuardianRoomRegion )
Delete();
}
}
}

View file

@ -1,599 +0,0 @@
using System;
using System.Collections.Generic;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Regions;
using Server.Commands;
namespace Server.Engines.Doom
{
public class GuardianRoomRegion : BaseRegion
{
private static GuardianRoomRegion m_Region;
public static void Initialize()
{
CommandSystem.Register( "GenGuardianRoom", AccessLevel.Administrator, new CommandEventHandler( GenRoom_OnCommand ) );
}
[Usage( "GenGuardianRoom" )]
[Description( "Generates guardian room in doom." )]
public static void GenRoom_OnCommand( CommandEventArgs e )
{
e.Mobile.SendMessage( "Generating room, please wait." );
int count = 0;
// doors
MetalDoor north = FindItem( new GuardianRoomDoor( DoorFacing.NorthCCW ), 0, 355, 14, -1, Map.Malas, ref count ) as MetalDoor;
MetalDoor south = FindItem( new GuardianRoomDoor( DoorFacing.SouthCW ), 0, 355, 15, -1, Map.Malas, ref count ) as MetalDoor;
if ( north != null && south != null )
{
north.Link = south;
south.Link = north;
}
// pentagram center
FindItem( new Static( 0xFEA ), 0x835, 365, 15, -1, Map.Malas, ref count );
// ghost teleporters
Teleporter tele;
tele = FindItem( new GhostTeleporter(), 0x835, 354, 14, -1, Map.Malas, ref count ) as Teleporter;
if ( tele != null )
{
tele.PointDest = new Point3D( 349, 176, 14 );
tele.MapDest = Map.Malas;
}
tele = FindItem( new GhostTeleporter(), 0x835, 354, 15, -1, Map.Malas, ref count ) as Teleporter;
if ( tele != null )
{
tele.PointDest = new Point3D( 349, 176, 14 );
tele.MapDest = Map.Malas;
}
// treasure chest spawner
Spawner spawner = new Spawner( 3, 1, 5, 0, 9, "GuardianTreasureChest" );
spawner = FindItem( spawner, 0, 365, 15, 0, Map.Malas, ref count ) as Spawner;
if ( spawner != null )
{
spawner.Movable = false;
spawner.Respawn();
}
if ( count > 0 )
e.Mobile.SendMessage( "Room generating complete. {0} items were generated.", count );
else
e.Mobile.SendMessage( "Room generating complete. No changes neccessary." );
}
public static Item FindItem( Item item, int hue, int x, int y, int z, Map map, ref int count )
{
Point3D p = new Point3D( x, y, z );
Type type = item.GetType();
foreach ( Item i in map.GetItemsInRange( p, 0 ) )
{
if ( i.GetType() == type && i.ItemID == item.ItemID && i.Hue == hue )
{
item.Delete();
return i;
}
}
count++;
item.MoveToWorld( p, map );
if ( hue > 0 )
item.Hue = hue;
return item;
}
private BaseDoor m_Door;
private List<Mobile> m_Dead;
private Timer m_Timer;
private int m_LightLevel;
public List<Mobile> Dead
{
get { return m_Dead; }
}
public bool Active
{
get { return m_Timer != null && m_Timer.Running; }
}
private static Rectangle2D[] m_Bounds = new Rectangle2D[]
{
new Rectangle2D( new Point2D( 356, 5 ), new Point2D( 375, 25 ) )
};
public GuardianRoomRegion( BaseDoor door ) : base( "NorthDoomPoisonRoom", Map.Malas, 51, m_Bounds )
{
m_Door = door;
m_Dead = new List<Mobile>();
m_LightLevel = LightCycle.DungeonLevel;
m_Guardians = new List<Mobile>();
ExcludeFromParentSpawns = true;
}
public override void OnEnter( Mobile m )
{
if ( !Active && IsTrappable( m, true ) )
m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( Utility.RandomMinMax( 5, 35 ) ), new TimerCallback( StartTrap ) );
}
public override void OnDeath( Mobile m )
{
base.OnDeath( m );
if ( m.IsDeadBondedPet || ( m.Player && m.AccessLevel == AccessLevel.Player ) )
m_Dead.Add( m );
if ( m is DarkGuardian )
m_Guardians.Remove( m );
if ( m_Guardians.Count == 0 )
Timer.DelayCall( TimeSpan.FromSeconds( 5 ), new TimerCallback( StopTrap ) );
List<Mobile> list = GetPoisonableMobiles();
list.Remove( m );
if ( list.Count == 0 )
Timer.DelayCall( TimeSpan.FromSeconds( 5 ), new TimerCallback( StopTrap ) );
}
public override void AlterLightLevel( Mobile m, ref int global, ref int personal )
{
global = m_LightLevel;
}
public virtual void PoisonMobiles( Poison poison, int ticks )
{
List<Mobile> list = GetPoisonableMobiles();
int number = 0;
int hue = 0x485;
if ( ticks % 12 == 0 ) // every 60 seconds
{
switch ( poison.Level )
{
// It is becoming more difficult for you to breathe as the poisons in the room become more concentrated.
case 1: number = 1050001; break;
// You begin to panic as the poison clouds thicken.
case 2: number = 1050003; break;
// Terror grips your spirit as you realize you may never leave this room alive.
case 3: number = 1050056; break;
case 4:
if ( ticks < 50 )
{
number = 1050057; // The end is near. You feel hopeless and desolate. The poison is beginning to stiffen your muscles.
}
else
{
hue = 0x23F3;
number = 1062091; // The poison is becoming too much for you to bear. You fear that you may die at any moment.
}
break;
}
}
foreach ( Mobile m in list )
{
if ( m.Player && number > 0 )
m.SendLocalizedMessage( number, null, hue );
if ( ( m.Poison == null || m.Poison.Level < poison.Level ) )
m.ApplyPoison( null, poison );
}
}
public virtual void HurtMobiles( int level )
{
foreach ( Mobile m in GetPoisonableMobiles() )
{
if ( m.Player )
{
m.Say( 1062092 ); // Your body reacts violently from the pain.
m.Animate( 32, 5, 1, true, false, 0 );
}
m.Damage( Utility.Random( 15, 20 ) );
if ( level >= 10 )
m.Kill();
}
}
public virtual List<Mobile> GetPoisonableMobiles()
{
List<Mobile> list = new List<Mobile>();
foreach ( Mobile m in GetMobiles() )
{
if ( IsTrappable( m, false ) )
list.Add( m );
}
return list;
}
public virtual bool IsTrappable( Mobile m, bool trapStart )
{
if ( m.Alive )
{
if ( m.Player && m.AccessLevel == AccessLevel.Player )
return true;
BaseCreature bc = m as BaseCreature;
if ( bc != null )
{
Mobile master = null;
if ( bc.Controlled && bc.ControlMaster != null )
master = bc.ControlMaster;
else if ( !trapStart && bc.Summoned && bc.SummonMaster != null )
master = bc.SummonMaster;
if ( master != null )
return master.Player && master.AccessLevel == AccessLevel.Player;
}
}
return false;
}
public virtual bool CanStart( List<Mobile> list )
{
foreach ( Mobile m in list )
if ( IsTrappable( m, true ) )
return true;
return false;
}
public virtual void RestartTrap()
{
if ( !Active )
StartTrap();
}
public virtual void StartTrap()
{
List<Mobile> list = GetPoisonableMobiles();
if ( !CanStart( list ) )
return;
m_Timer = new PoisonRoomTimer( this );
m_Timer.Start();
if ( m_Door != null )
{
m_Door.Locked = true;
m_Door.Open = false;
if ( m_Door.Link != null )
{
m_Door.Link.Locked = true;
m_Door.Link.Open = false;
Effects.PlaySound( m_Door.Link.Location, Map, 0x1FF );
}
Effects.PlaySound( m_Door.Location, Map, 0x1FF );
}
foreach ( Mobile m in list )
m.SendLocalizedMessage( 1050000, null, 0x41 ); // The locks on the door click loudly and you begin to hear a faint hissing near the walls.
for ( int i = m_Dead.Count - 1; i >= 0; i-- )
if ( m_Dead[ i ].Alive )
m_Dead.RemoveAt( i );
SpawnGuardians( list.Count * 2 );
}
public virtual void StopTrap()
{
Timer.DelayCall( TimeSpan.FromSeconds( Utility.RandomMinMax( 30, 60 ) ), new TimerCallback( RestartTrap ) );
if ( m_Door != null )
{
m_Door.Locked = false;
if ( m_Door.Link != null )
{
m_Door.Link.Locked = false;
Effects.PlaySound( m_Door.Link.Location, Map, 0x1FF );
}
Effects.PlaySound( m_Door.Location, Map, 0x1FF );
}
if ( m_Timer != null && m_Timer.Running )
m_Timer.Stop();
foreach ( Mobile m in GetPlayers() )
m.SendLocalizedMessage( 1050055, null, 0x41 ); // You hear the doors unlocking and the hissing stops.
ClearGuardians();
}
#region Spawns
private List<Mobile> m_Guardians;
public void SpawnGuardians( int amount )
{
for ( int i = 0; i < amount; ++i )
{
DarkGuardian guardian = new DarkGuardian();
switch ( Utility.Random( 4 ) )
{
case 0: guardian.MoveToWorld( new Point3D( 364, 15, -1 ), Map.Malas ); break;
case 1: guardian.MoveToWorld( new Point3D( 366, 15, -1 ), Map.Malas ); break;
case 2: guardian.MoveToWorld( new Point3D( 365, 14, -1 ), Map.Malas ); break;
case 3: guardian.MoveToWorld( new Point3D( 365, 16, -1 ), Map.Malas ); break;
}
m_Guardians.Add( guardian );
}
}
public void ClearGuardians()
{
foreach ( Mobile m in m_Guardians )
{
if ( m.Alive && !m.Deleted )
{
Effects.SendLocationParticles( EffectItem.Create( m.Location, m.Map, EffectItem.DefaultDuration ), 0x3728, 8, 20, 5042 );
Effects.PlaySound( m, m.Map, 0x201 );
m.Delete();
}
}
m_Guardians.Clear();
}
#endregion
#region Effects
private static Point3D[] m_GasLocations = new Point3D[]
{
// west
new Point3D( 356, 7, -1 ), new Point3D( 356, 13, -1 ),
new Point3D( 356, 16, -1 ), new Point3D( 356, 22, -1 ),
// north
new Point3D( 358, 6, -1 ), new Point3D( 363, 6, -1 ),
new Point3D( 368, 6, -1 ), new Point3D( 373, 6, -1 )
};
public virtual void DoGasEffect()
{
for ( int i = Utility.RandomMinMax( 2, 4 ); i > 0; i-- )
{
int pos = Utility.Random( m_GasLocations.Length );
int itemID;
if ( pos <= 3 )
itemID = 0x1145;
else
itemID = 0x113A;
Effects.SendLocationParticles( EffectItem.Create( m_GasLocations[ pos ], Map, EffectItem.DefaultDuration ), itemID, 1, 100, 0, 4, 0x139D, 0 );
}
}
private static int[] m_PoisonEffects = new int[]
{
0x36B0, 0x36BD, 0x36CB
};
public virtual void DoPoisonEffect( int level )
{
int hue = 0;
switch ( level )
{
default:
case 0: hue = 0xA6; break;
case 1: hue = 0xAA; break;
case 2: hue = 0xAC; break;
case 3: hue = 0xA8; break;
case 4: hue = 0xA4; break;
}
for ( int i = Utility.RandomMinMax( 5, 7 ); i > 0; i-- )
{
Point3D p = RandomSpawnLocation( 0, true, true, Point3D.Zero, 0 );
if ( p != Point3D.Zero )
{
IEntity e = EffectItem.Create( p, Map, EffectItem.DefaultDuration );
int itemID = Utility.RandomList( m_PoisonEffects );
int duration = Utility.RandomMinMax( 150, 200 );
Effects.SendLocationParticles( e, itemID, 1, duration, hue, 0, 0x139D, 0 );
}
}
}
#endregion
public class PoisonRoomTimer : Timer
{
private GuardianRoomRegion m_Room;
private int m_Count;
public PoisonRoomTimer( GuardianRoomRegion room ) : base( TimeSpan.FromSeconds( 1 ), TimeSpan.FromSeconds( 1 ) )
{
m_Room = room;
m_Count = 0;
}
public int CurrentPoisonLevel()
{
int poisonLevel = 1 + m_Count / 20;
if ( poisonLevel > 4 )
poisonLevel = 4;
return poisonLevel;
}
protected override void OnTick()
{
m_Count++;
if ( m_Count % 5 == 0 && m_Room.Active )
{
int level = CurrentPoisonLevel();
m_Room.PoisonMobiles( Poison.GetPoison( level ), m_Count / 5 );
}
if ( m_Count % 8 == 0 && m_Room.Active )
{
m_Room.DoPoisonEffect( CurrentPoisonLevel() );
m_Room.DoGasEffect();
}
if ( m_Count >= 720 && m_Count % 10 == 0 && m_Room.Active )
m_Room.HurtMobiles( ( m_Count - 720 ) / 10 );
}
}
public class GhostTeleporter : Teleporter
{
private static BaseRegion m_GhostRegion;
private static Rectangle2D[] m_GhostRegionBounds = new Rectangle2D[]
{
new Rectangle2D( new Point2D( 345, 180 ), new Point2D( 352, 184 ) ),
new Rectangle2D( new Point2D( 342, 172 ), new Point2D( 344, 181 ) ),
new Rectangle2D( new Point2D( 345, 169 ), new Point2D( 352, 172 ) )
};
[Constructable]
public GhostTeleporter() : base()
{
Name = "GhostTeleporter";
if ( m_GhostRegion == null )
{
m_GhostRegion = new BaseRegion( "DoomGhostTeleportRegion", Map.Malas, 55, m_GhostRegionBounds );
m_GhostRegion.Register();
}
}
public GhostTeleporter( Serial serial ) : base( serial )
{
}
public override bool OnMoveOver( Mobile m )
{
if ( !DiedInside( m ) )
return true;
return base.OnMoveOver( m );
}
public bool DiedInside( Mobile m )
{
bool valid = false;
if ( m_Region != null )
valid = m_Region.Dead.Remove( m );
return valid && !m.Alive;
}
public override void DoTeleport( Mobile m )
{
if ( m.Corpse != null && !m.Corpse.Deleted )
{
Point3D location = Point3D.Zero;
if ( m_GhostRegion != null )
location = m_GhostRegion.RandomSpawnLocation( 0, true, false, Point3D.Zero, 0 );
if ( location == Point3D.Zero )
location = new Point3D( 349, 176, 14 );
m.Corpse.MoveToWorld( location, Map.Malas );
m.MoveToWorld( location, Map.Malas );
}
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.WriteEncodedInt( 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadEncodedInt();
if ( m_GhostRegion == null )
{
m_GhostRegion = new BaseRegion( "DoomGhostTeleportRegion", Map.Malas, 55, m_GhostRegionBounds );
m_GhostRegion.Register();
}
}
}
public class GuardianRoomDoor : MetalDoor
{
public GuardianRoomDoor( DoorFacing facing ) : base( facing )
{
if ( m_Region == null )
{
m_Region = new GuardianRoomRegion( this );
m_Region.Register();
}
}
public GuardianRoomDoor( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.WriteEncodedInt( 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadEncodedInt();
Locked = false;
if ( m_Region == null )
{
m_Region = new GuardianRoomRegion( this );
m_Region.Register();
}
}
}
}
}

View file

@ -1,179 +0,0 @@
using System;
using Server;
using Server.Engines.Doom;
namespace Server.Items
{
public class GuardianTreasureChest : LockableContainer
{
private const int m_Level = 6;
public override bool Decays { get { return true; } }
public override int DefaultGumpID { get { return 0x42; } }
public override int DefaultDropSound { get { return 0x42; } }
public override Rectangle2D Bounds
{
get { return new Rectangle2D( 18, 105, 144, 73 ); }
}
private Timer m_DecayTimer;
[Constructable]
public GuardianTreasureChest() : base( 0xE41 )
{
SetChestAppearance();
Movable = false;
/* TrapType = TrapType.ExplosionTrap;
TrapPower = m_Level * Utility.Random( 20, 35 );*/
Locked = true;
RequiredSkill = 99;
LockLevel = RequiredSkill - Utility.Random( 1, 10 );
MaxLockLevel = RequiredSkill + 21;
// According to OSI, loot in level 4 chest is:
// Gold 500 - 900
// Reagents
// Scrolls
// Blank scrolls
// Potions
// Gems
// Magic Wand
// Magic weapon
// Magic armour
// Magic clothing (not implemented)
// Magic jewelry (not implemented)
// Crystal ball (not implemented)
// Gold
DropItem( new Gold( Utility.Random( 300, 325 ) ) );
// Reagents
for ( int i = Utility.Random( 1, m_Level ); i > 1; i-- )
{
Item ReagentLoot = Loot.RandomReagent();
ReagentLoot.Amount = 12;
DropItem( ReagentLoot );
}
// Scrolls
for ( int i = Utility.Random( 1, m_Level ); i > 1; i-- )
{
Item ScrollLoot = Loot.RandomScroll( 0, 47, SpellbookType.Regular );
ScrollLoot.Amount = 16;
DropItem( ScrollLoot );
}
// Drop blank scrolls
DropItem( new BlankScroll( Utility.Random( 1, m_Level ) ) );
// Potions
for ( int i = Utility.Random( 1, m_Level ); i > 1; i-- )
{
Item PotionLoot = Loot.RandomPotion();
DropItem( PotionLoot );
}
// Gems
for ( int i = Utility.Random( 1, m_Level ); i > 1; i-- )
{
Item GemLoot = Loot.RandomGem();
GemLoot.Amount = 15;
DropItem( GemLoot );
}
// Magic Wand
for ( int i = Utility.Random( 1, m_Level ); i > 1; i-- )
DropItem( Loot.RandomWand() );
// Equipment
for ( int i = Utility.Random( 1, m_Level ); i > 1; i-- )
{
Item item = Loot.RandomArmorOrShieldOrWeapon();
if ( item is BaseWeapon )
{
BaseWeapon weapon = (BaseWeapon) item;
weapon.DamageLevel = (WeaponDamageLevel) Utility.Random( m_Level );
weapon.AccuracyLevel = (WeaponAccuracyLevel) Utility.Random( m_Level );
weapon.DurabilityLevel = (WeaponDurabilityLevel) Utility.Random( m_Level );
weapon.Quality = WeaponQuality.Regular;
}
else if ( item is BaseArmor )
{
BaseArmor armor = (BaseArmor) item;
armor.ProtectionLevel = (ArmorProtectionLevel) Utility.Random( m_Level );
armor.Durability = (ArmorDurabilityLevel) Utility.Random( m_Level );
armor.Quality = ArmorQuality.Regular;
}
DropItem( item );
}
// Clothing
for ( int i = Utility.Random( 1, 2 ); i > 1; i-- )
DropItem( Loot.RandomClothing() );
// Jewelry
for ( int i = Utility.Random( 1, 2 ); i > 1; i-- )
DropItem( Loot.RandomJewelry() );
// Crystal ball (not implemented)
m_DecayTimer = Timer.DelayCall( TimeSpan.FromMinutes( Utility.RandomMinMax( 1, 5 ) ), new TimerCallback( Delete ) );
}
private void SetChestAppearance()
{
bool facing = Utility.RandomBool();
switch ( Utility.RandomList( 0, 1, 2 ) )
{
case 0:// Wooden Chest
ItemID = ( facing ? 0xE42 : 0xE43 );
GumpID = 0x49;
break;
case 1:// Metal Chest
ItemID = ( facing ? 0x9AB : 0xE7C );
GumpID = 0x4A;
break;
case 2:// Metal Golden Chest
ItemID = ( facing ? 0xE40 : 0xE41 );
GumpID = 0x42;
break;
}
}
public override void OnAfterDelete()
{
if ( m_DecayTimer != null || m_DecayTimer.Running )
m_DecayTimer.Stop();
m_DecayTimer = null;
}
public GuardianTreasureChest( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.WriteEncodedInt( 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadEncodedInt();
m_DecayTimer = Timer.DelayCall( TimeSpan.FromMinutes( Utility.RandomMinMax( 1, 5 ) ), new TimerCallback( Delete ) );
}
}
}

View file

@ -1,230 +0,0 @@
using System;
using System.Collections.Generic;
using Server;
using Server.Mobiles;
using Server.Regions;
using Server.Spells.Fourth;
using Server.Spells.Sixth;
using Server.Spells.Seventh;
using Server.Spells.Chivalry;
namespace Server.Misc
{
public class PoisonRoom
{
public virtual int GasEffects { get { return 3; } }
public virtual double TimePerPoisonCast { get { return 3; } }
public virtual int TicksPerPoisonLevel { get { return 15; } }
public virtual Poison MinPoisonLevel { get { return Poison.Lesser; } }
public virtual Poison MaxPoisonLevel { get { return Poison.Lethal; } }
public virtual int GasEffectHeight { get { return 0; } }
public virtual bool HasPoisonSoundEffect { get { return true; } }
protected PoisonRoomRegion m_Region;
protected PoisonRoomTimer m_Timer;
protected int m_EffectHue = 1166;
protected int m_EffectId = 4518;
protected int m_EffectDuration = 16;
protected List<Mobile> m_Dead;
public List<Mobile> Dead
{
get { return m_Dead; }
}
public PoisonRoom( string name, Map map, int priority, Rectangle2D[] rect, int LightLevel )
{
m_Region = new PoisonRoomRegion( this, name, map, priority, rect, LightLevel );
m_Region.Register();
m_Dead = new List<Mobile>();
}
public virtual void OnEnter( Mobile m )
{
if ( m.AccessLevel == AccessLevel.Player && m_Timer == null )
StartGas();
}
public virtual void OnPoison( Poison poison, int tick )
{
}
public virtual void StartGas()
{
m_Timer = new PoisonRoomTimer( this );
m_Timer.Start();
}
public virtual void StopGas()
{
if ( m_Timer != null )
m_Timer.Stop();
m_Timer = null;
}
public virtual void OnExit( Mobile m )
{
if ( GetPoisonableMobiles( m ).Count == 0 )
{
StopGas();
return;
}
}
public virtual void OnDeath( Mobile m )
{
m_Dead.Add( m );
}
public virtual void DoGasEffect()
{
for ( int i = 0; i < this.GasEffects; ++i )
RandomGasEffect();
}
public virtual void RandomGasEffect()
{
Point3D location = m_Region.RandomSpawnLocation( GasEffectHeight, true, true, Point3D.Zero, 0 );
if ( location != Point3D.Zero )
{
Effects.SendLocationEffect( location, m_Region.Map, 4518, 16, 1, 1166, 0 );
if ( HasPoisonSoundEffect )
Effects.PlaySound( location, m_Region.Map, 0x231 );
}
}
public virtual void PoisonPlayers( Poison poison )
{
List<Mobile> list = GetPoisonableMobiles( null );
foreach ( Mobile m in list )
{
if ( ( m.Poison == null || m.Poison.Level < poison.Level ) )
m.ApplyPoison( null, poison );
}
}
public int CurrentPoisonLevel()
{
if ( m_Timer != null )
return m_Timer.CurrentPoisonLevel();
return 0;
}
protected virtual bool IsPoisonable( Mobile m )
{
if ( m.AccessLevel == AccessLevel.Player && m.CheckAlive() && ( m.Player || ( m is BaseCreature && ((BaseCreature)m).Controlled ) ) )
return true;
return false;
}
public virtual List<Mobile> GetPoisonableMobiles( Mobile toexclude )
{
List<Mobile> list = new List<Mobile>();
List<Mobile> templist = m_Region.GetMobiles();
foreach ( Mobile m in templist )
{
if ( IsPoisonable( m ) )
list.Add( m );
}
if ( toexclude != null )
list.Remove( toexclude );
return list;
}
public class PoisonRoomTimer : Timer
{
private PoisonRoom m_Room;
private int m_Count = 0;
public PoisonRoomTimer( PoisonRoom room ) : base( TimeSpan.FromSeconds( 0 ), TimeSpan.FromSeconds( room.TimePerPoisonCast ) )
{
m_Room = room;
}
public int CurrentPoisonLevel()
{
int poisonLevel = m_Room.MinPoisonLevel.Level + m_Count / m_Room.TicksPerPoisonLevel;
if ( poisonLevel > m_Room.MaxPoisonLevel.Level )
poisonLevel = m_Room.MaxPoisonLevel.Level;
return poisonLevel;
}
protected override void OnTick()
{
m_Count++;
int poisonLevel = CurrentPoisonLevel();
m_Room.OnPoison( Poison.GetPoison( poisonLevel ), m_Count );
m_Room.PoisonPlayers( Poison.GetPoison( poisonLevel ) );
m_Room.DoGasEffect();
}
}
public class PoisonRoomRegion : BaseRegion
{
private PoisonRoom m_Room;
private int m_LightLevel;
public PoisonRoomRegion( PoisonRoom room, string name, Map map, int priority, Rectangle2D[] rect, int lightlevel ) : base( name, map, priority, rect )
{
ExcludeFromParentSpawns = true;
m_Room = room;
m_LightLevel = lightlevel;
}
public override void OnEnter( Mobile m )
{
base.OnEnter( m );
m_Room.OnEnter( m );
}
public override void OnExit( Mobile m )
{
base.OnExit( m );
m_Room.OnExit( m );
}
public override void OnDeath( Mobile m )
{
base.OnDeath( m );
m_Room.OnDeath( m );
}
public override bool OnResurrect( Mobile from )
{
return true;
}
public override void AlterLightLevel( Mobile m, ref int global, ref int personal )
{
global = m_LightLevel;
}
public override bool OnBeginSpellCast( Mobile m, ISpell s )
{
if ( ( s is MarkSpell || s is GateTravelSpell || s is RecallSpell || s is SacredJourneySpell ) && m.AccessLevel == AccessLevel.Player )
{
m.SendLocalizedMessage( 501802 ); // Thy spell doth not appear to work...
return false;
}
return base.OnBeginSpellCast( m, s );
}
}
}
}