Reorganizes Project (#41)
This commit is contained in:
parent
08bf44af9a
commit
3614a66aee
3499 changed files with 79 additions and 55 deletions
95
Projects/Scripts/Items/Misc/PoolOfAcid.cs
Normal file
95
Projects/Scripts/Items/Misc/PoolOfAcid.cs
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
using System;
|
||||
using Server.Mobiles;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class PoolOfAcid : Item
|
||||
{
|
||||
private TimeSpan m_Duration;
|
||||
private int m_MinDamage;
|
||||
private int m_MaxDamage;
|
||||
private DateTime m_Created;
|
||||
private bool m_Drying;
|
||||
private Timer m_Timer;
|
||||
|
||||
[Constructible]
|
||||
public PoolOfAcid() : this( TimeSpan.FromSeconds( 10.0 ), 2, 5 )
|
||||
{
|
||||
}
|
||||
|
||||
public override string DefaultName => "a pool of acid";
|
||||
|
||||
[Constructible]
|
||||
public PoolOfAcid( TimeSpan duration, int minDamage, int maxDamage )
|
||||
: base( 0x122A )
|
||||
{
|
||||
Hue = 0x3F;
|
||||
Movable = false;
|
||||
|
||||
m_MinDamage = minDamage;
|
||||
m_MaxDamage = maxDamage;
|
||||
m_Created = DateTime.UtcNow;
|
||||
m_Duration = duration;
|
||||
|
||||
m_Timer = Timer.DelayCall( TimeSpan.Zero, TimeSpan.FromSeconds( 1 ), OnTick );
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
m_Timer?.Stop();
|
||||
}
|
||||
|
||||
private void OnTick()
|
||||
{
|
||||
DateTime now = DateTime.UtcNow;
|
||||
TimeSpan age = now - m_Created;
|
||||
|
||||
if ( age > m_Duration ) {
|
||||
Delete();
|
||||
} else {
|
||||
if ( !m_Drying && age > (m_Duration - age) )
|
||||
{
|
||||
m_Drying = true;
|
||||
ItemID = 0x122B;
|
||||
}
|
||||
|
||||
List<Mobile> toDamage = new List<Mobile>();
|
||||
|
||||
foreach( Mobile m in GetMobilesInRange( 0 ) )
|
||||
{
|
||||
if ( m.Alive && !m.IsDeadBondedPet && (!(m is BaseCreature bc) || bc.Controlled || bc.Summoned) )
|
||||
{
|
||||
toDamage.Add( m );
|
||||
}
|
||||
}
|
||||
|
||||
for ( int i = 0; i < toDamage.Count; i++ )
|
||||
Damage( toDamage[i] );
|
||||
}
|
||||
}
|
||||
public override bool OnMoveOver( Mobile m )
|
||||
{
|
||||
Damage( m );
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Damage ( Mobile m )
|
||||
{
|
||||
m.Damage( Utility.RandomMinMax( m_MinDamage, m_MaxDamage ) );
|
||||
}
|
||||
|
||||
public PoolOfAcid( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
//Don't serialize these
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue