Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -1,130 +1,130 @@
|
|||
using System;
|
||||
using Server.Network;
|
||||
using Server.Mobiles;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
[FlippableAttribute( 0xA57, 0xA58, 0xA59 )]
|
||||
public class Bedroll : Item
|
||||
{
|
||||
[Constructible]
|
||||
public Bedroll() : base( 0xA57 )
|
||||
{
|
||||
Weight = 5.0;
|
||||
}
|
||||
[Flippable(0xA57, 0xA58, 0xA59)]
|
||||
public class Bedroll : Item
|
||||
{
|
||||
[Constructible]
|
||||
public Bedroll() : base(0xA57)
|
||||
{
|
||||
Weight = 5.0;
|
||||
}
|
||||
|
||||
public Bedroll( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public Bedroll(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( Parent != null || !VerifyMove( from ) )
|
||||
return;
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (Parent != null || !VerifyMove(from))
|
||||
return;
|
||||
|
||||
if ( !from.InRange( this, 2 ) )
|
||||
{
|
||||
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
|
||||
return;
|
||||
}
|
||||
if (!from.InRange(this, 2))
|
||||
{
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ItemID == 0xA57 ) // rolled
|
||||
{
|
||||
Direction dir = PlayerMobile.GetDirection4( from.Location, Location );
|
||||
if (ItemID == 0xA57) // rolled
|
||||
{
|
||||
Direction dir = PlayerMobile.GetDirection4(from.Location, Location);
|
||||
|
||||
if ( dir == Direction.North || dir == Direction.South )
|
||||
ItemID = 0xA55;
|
||||
else
|
||||
ItemID = 0xA56;
|
||||
}
|
||||
else // unrolled
|
||||
{
|
||||
ItemID = 0xA57;
|
||||
if (dir == Direction.North || dir == Direction.South)
|
||||
ItemID = 0xA55;
|
||||
else
|
||||
ItemID = 0xA56;
|
||||
}
|
||||
else // unrolled
|
||||
{
|
||||
ItemID = 0xA57;
|
||||
|
||||
if ( !from.HasGump( typeof( LogoutGump ) ) )
|
||||
{
|
||||
CampfireEntry entry = Campfire.GetEntry( from );
|
||||
if (!from.HasGump(typeof(LogoutGump)))
|
||||
{
|
||||
CampfireEntry entry = Campfire.GetEntry(from);
|
||||
|
||||
if ( entry != null && entry.Safe )
|
||||
from.SendGump( new LogoutGump( entry, this ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (entry != null && entry.Safe)
|
||||
from.SendGump(new LogoutGump(entry, this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class LogoutGump : Gump
|
||||
{
|
||||
private Timer m_CloseTimer;
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
private CampfireEntry m_Entry;
|
||||
private Bedroll m_Bedroll;
|
||||
writer.WriteEncodedInt(0); // version
|
||||
}
|
||||
|
||||
public LogoutGump( CampfireEntry entry, Bedroll bedroll ) : base( 100, 0 )
|
||||
{
|
||||
m_Entry = entry;
|
||||
m_Bedroll = bedroll;
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
m_CloseTimer = Timer.DelayCall( TimeSpan.FromSeconds( 10.0 ), CloseGump );
|
||||
int version = reader.ReadEncodedInt();
|
||||
}
|
||||
|
||||
AddBackground( 0, 0, 400, 350, 0xA28 );
|
||||
private class LogoutGump : Gump
|
||||
{
|
||||
private Bedroll m_Bedroll;
|
||||
private Timer m_CloseTimer;
|
||||
|
||||
AddHtmlLocalized( 100, 20, 200, 35, 1011015, false, false ); // <center>Logging out via camping</center>
|
||||
private CampfireEntry m_Entry;
|
||||
|
||||
/* Using a bedroll in the safety of a camp will log you out of the game safely.
|
||||
* If this is what you wish to do choose CONTINUE and you will be logged out.
|
||||
* Otherwise, select the CANCEL button to avoid logging out at this time.
|
||||
* The camp will remain secure for 10 seconds at which time this window will close
|
||||
* and you not be logged out.
|
||||
*/
|
||||
AddHtmlLocalized( 50, 55, 300, 140, 1011016, true, true );
|
||||
public LogoutGump(CampfireEntry entry, Bedroll bedroll) : base(100, 0)
|
||||
{
|
||||
m_Entry = entry;
|
||||
m_Bedroll = bedroll;
|
||||
|
||||
AddButton( 45, 298, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 80, 300, 110, 35, 1011011, false, false ); // CONTINUE
|
||||
m_CloseTimer = Timer.DelayCall(TimeSpan.FromSeconds(10.0), CloseGump);
|
||||
|
||||
AddButton( 200, 298, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 235, 300, 110, 35, 1011012, false, false ); // CANCEL
|
||||
}
|
||||
AddBackground(0, 0, 400, 350, 0xA28);
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
PlayerMobile pm = m_Entry.Player;
|
||||
AddHtmlLocalized(100, 20, 200, 35, 1011015, false, false); // <center>Logging out via camping</center>
|
||||
|
||||
m_CloseTimer.Stop();
|
||||
/* Using a bedroll in the safety of a camp will log you out of the game safely.
|
||||
* If this is what you wish to do choose CONTINUE and you will be logged out.
|
||||
* Otherwise, select the CANCEL button to avoid logging out at this time.
|
||||
* The camp will remain secure for 10 seconds at which time this window will close
|
||||
* and you not be logged out.
|
||||
*/
|
||||
AddHtmlLocalized(50, 55, 300, 140, 1011016, true, true);
|
||||
|
||||
if ( Campfire.GetEntry( pm ) != m_Entry )
|
||||
return;
|
||||
AddButton(45, 298, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(80, 300, 110, 35, 1011011, false, false); // CONTINUE
|
||||
|
||||
if ( info.ButtonID == 1 && m_Entry.Safe && m_Bedroll.Parent == null && m_Bedroll.IsAccessibleTo( pm )
|
||||
&& m_Bedroll.VerifyMove( pm ) && m_Bedroll.Map == pm.Map && pm.InRange( m_Bedroll, 2 ) )
|
||||
{
|
||||
pm.PlaceInBackpack( m_Bedroll );
|
||||
AddButton(200, 298, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(235, 300, 110, 35, 1011012, false, false); // CANCEL
|
||||
}
|
||||
|
||||
pm.BedrollLogout = true;
|
||||
sender.Dispose();
|
||||
}
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
PlayerMobile pm = m_Entry.Player;
|
||||
|
||||
Campfire.RemoveEntry( m_Entry );
|
||||
}
|
||||
m_CloseTimer.Stop();
|
||||
|
||||
private void CloseGump()
|
||||
{
|
||||
Campfire.RemoveEntry( m_Entry );
|
||||
m_Entry.Player.CloseGump( typeof( LogoutGump ) );
|
||||
}
|
||||
}
|
||||
if (Campfire.GetEntry(pm) != m_Entry)
|
||||
return;
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
if (info.ButtonID == 1 && m_Entry.Safe && m_Bedroll.Parent == null && m_Bedroll.IsAccessibleTo(pm)
|
||||
&& m_Bedroll.VerifyMove(pm) && m_Bedroll.Map == pm.Map && pm.InRange(m_Bedroll, 2))
|
||||
{
|
||||
pm.PlaceInBackpack(m_Bedroll);
|
||||
|
||||
writer.WriteEncodedInt( 0 ); // version
|
||||
}
|
||||
pm.BedrollLogout = true;
|
||||
sender.Dispose();
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
Campfire.RemoveEntry(m_Entry);
|
||||
}
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
}
|
||||
}
|
||||
private void CloseGump()
|
||||
{
|
||||
Campfire.RemoveEntry(m_Entry);
|
||||
m_Entry.Player.CloseGump(typeof(LogoutGump));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,204 +1,198 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server.Network;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public enum CampfireStatus
|
||||
{
|
||||
Burning,
|
||||
Extinguishing,
|
||||
Off
|
||||
}
|
||||
public enum CampfireStatus
|
||||
{
|
||||
Burning,
|
||||
Extinguishing,
|
||||
Off
|
||||
}
|
||||
|
||||
public class Campfire : Item
|
||||
{
|
||||
public static readonly int SecureRange = 7;
|
||||
public class Campfire : Item
|
||||
{
|
||||
public static readonly int SecureRange = 7;
|
||||
|
||||
private static readonly Hashtable m_Table = new Hashtable();
|
||||
private static readonly Hashtable m_Table = new Hashtable();
|
||||
|
||||
public static CampfireEntry GetEntry( Mobile player )
|
||||
{
|
||||
return (CampfireEntry) m_Table[player];
|
||||
}
|
||||
private ArrayList m_Entries;
|
||||
|
||||
public static void RemoveEntry( CampfireEntry entry )
|
||||
{
|
||||
m_Table.Remove( entry.Player );
|
||||
entry.Fire.m_Entries.Remove( entry );
|
||||
}
|
||||
private Timer m_Timer;
|
||||
|
||||
private Timer m_Timer;
|
||||
public Campfire() : base(0xDE3)
|
||||
{
|
||||
Movable = false;
|
||||
Light = LightType.Circle300;
|
||||
|
||||
private ArrayList m_Entries;
|
||||
m_Entries = new ArrayList();
|
||||
|
||||
public Campfire() : base( 0xDE3 )
|
||||
{
|
||||
Movable = false;
|
||||
Light = LightType.Circle300;
|
||||
Created = DateTime.UtcNow;
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), OnTick);
|
||||
}
|
||||
|
||||
m_Entries = new ArrayList();
|
||||
public Campfire(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
Created = DateTime.UtcNow;
|
||||
m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), TimeSpan.FromSeconds( 1.0 ), OnTick );
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime Created{ get; }
|
||||
|
||||
public Campfire( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public CampfireStatus Status
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (ItemID)
|
||||
{
|
||||
case 0xDE3:
|
||||
return CampfireStatus.Burning;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public DateTime Created { get; }
|
||||
case 0xDE9:
|
||||
return CampfireStatus.Extinguishing;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public CampfireStatus Status
|
||||
{
|
||||
get
|
||||
{
|
||||
switch ( ItemID )
|
||||
{
|
||||
case 0xDE3:
|
||||
return CampfireStatus.Burning;
|
||||
default:
|
||||
return CampfireStatus.Off;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (Status == value)
|
||||
return;
|
||||
|
||||
case 0xDE9:
|
||||
return CampfireStatus.Extinguishing;
|
||||
switch (value)
|
||||
{
|
||||
case CampfireStatus.Burning:
|
||||
ItemID = 0xDE3;
|
||||
Light = LightType.Circle300;
|
||||
break;
|
||||
|
||||
default:
|
||||
return CampfireStatus.Off;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if ( Status == value )
|
||||
return;
|
||||
case CampfireStatus.Extinguishing:
|
||||
ItemID = 0xDE9;
|
||||
Light = LightType.Circle150;
|
||||
break;
|
||||
|
||||
switch ( value )
|
||||
{
|
||||
case CampfireStatus.Burning:
|
||||
ItemID = 0xDE3;
|
||||
Light = LightType.Circle300;
|
||||
break;
|
||||
default:
|
||||
ItemID = 0xDEA;
|
||||
Light = LightType.ArchedWindowEast;
|
||||
ClearEntries();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case CampfireStatus.Extinguishing:
|
||||
ItemID = 0xDE9;
|
||||
Light = LightType.Circle150;
|
||||
break;
|
||||
public static CampfireEntry GetEntry(Mobile player)
|
||||
{
|
||||
return (CampfireEntry)m_Table[player];
|
||||
}
|
||||
|
||||
default:
|
||||
ItemID = 0xDEA;
|
||||
Light = LightType.ArchedWindowEast;
|
||||
ClearEntries();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void RemoveEntry(CampfireEntry entry)
|
||||
{
|
||||
m_Table.Remove(entry.Player);
|
||||
entry.Fire.m_Entries.Remove(entry);
|
||||
}
|
||||
|
||||
private void OnTick()
|
||||
{
|
||||
DateTime now = DateTime.UtcNow;
|
||||
TimeSpan age = now - Created;
|
||||
private void OnTick()
|
||||
{
|
||||
DateTime now = DateTime.UtcNow;
|
||||
TimeSpan age = now - Created;
|
||||
|
||||
if ( age >= TimeSpan.FromSeconds( 100.0 ) )
|
||||
Delete();
|
||||
else if ( age >= TimeSpan.FromSeconds( 90.0 ) )
|
||||
Status = CampfireStatus.Off;
|
||||
else if ( age >= TimeSpan.FromSeconds( 60.0 ) )
|
||||
Status = CampfireStatus.Extinguishing;
|
||||
if (age >= TimeSpan.FromSeconds(100.0))
|
||||
Delete();
|
||||
else if (age >= TimeSpan.FromSeconds(90.0))
|
||||
Status = CampfireStatus.Off;
|
||||
else if (age >= TimeSpan.FromSeconds(60.0))
|
||||
Status = CampfireStatus.Extinguishing;
|
||||
|
||||
if ( Status == CampfireStatus.Off || Deleted )
|
||||
return;
|
||||
if (Status == CampfireStatus.Off || Deleted)
|
||||
return;
|
||||
|
||||
foreach ( CampfireEntry entry in new ArrayList( m_Entries ) )
|
||||
{
|
||||
if ( !entry.Valid || entry.Player.NetState == null )
|
||||
{
|
||||
RemoveEntry( entry );
|
||||
}
|
||||
else if ( !entry.Safe && now - entry.Start >= TimeSpan.FromSeconds( 30.0 ) )
|
||||
{
|
||||
entry.Safe = true;
|
||||
entry.Player.SendLocalizedMessage( 500621 ); // The camp is now secure.
|
||||
}
|
||||
}
|
||||
foreach (CampfireEntry entry in new ArrayList(m_Entries))
|
||||
if (!entry.Valid || entry.Player.NetState == null)
|
||||
{
|
||||
RemoveEntry(entry);
|
||||
}
|
||||
else if (!entry.Safe && now - entry.Start >= TimeSpan.FromSeconds(30.0))
|
||||
{
|
||||
entry.Safe = true;
|
||||
entry.Player.SendLocalizedMessage(500621); // The camp is now secure.
|
||||
}
|
||||
|
||||
IPooledEnumerable<NetState> eable = GetClientsInRange( SecureRange );
|
||||
IPooledEnumerable<NetState> eable = GetClientsInRange(SecureRange);
|
||||
|
||||
foreach ( NetState state in eable )
|
||||
{
|
||||
if ( state.Mobile is PlayerMobile pm && GetEntry( pm ) == null )
|
||||
{
|
||||
CampfireEntry entry = new CampfireEntry( pm, this );
|
||||
foreach (NetState state in eable)
|
||||
if (state.Mobile is PlayerMobile pm && GetEntry(pm) == null)
|
||||
{
|
||||
CampfireEntry entry = new CampfireEntry(pm, this);
|
||||
|
||||
m_Table[pm] = entry;
|
||||
m_Entries.Add( entry );
|
||||
m_Table[pm] = entry;
|
||||
m_Entries.Add(entry);
|
||||
|
||||
pm.SendLocalizedMessage( 500620 ); // You feel it would take a few moments to secure your camp.
|
||||
}
|
||||
}
|
||||
pm.SendLocalizedMessage(500620); // You feel it would take a few moments to secure your camp.
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
eable.Free();
|
||||
}
|
||||
|
||||
private void ClearEntries()
|
||||
{
|
||||
if ( m_Entries == null )
|
||||
return;
|
||||
private void ClearEntries()
|
||||
{
|
||||
if (m_Entries == null)
|
||||
return;
|
||||
|
||||
foreach ( CampfireEntry entry in new ArrayList( m_Entries ) )
|
||||
{
|
||||
RemoveEntry( entry );
|
||||
}
|
||||
}
|
||||
foreach (CampfireEntry entry in new ArrayList(m_Entries)) RemoveEntry(entry);
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
m_Timer?.Stop();
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
m_Timer?.Stop();
|
||||
|
||||
ClearEntries();
|
||||
}
|
||||
ClearEntries();
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
int version = reader.ReadInt();
|
||||
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public class CampfireEntry
|
||||
{
|
||||
private bool m_Safe;
|
||||
public class CampfireEntry
|
||||
{
|
||||
private bool m_Safe;
|
||||
|
||||
public PlayerMobile Player { get; }
|
||||
public CampfireEntry(PlayerMobile player, Campfire fire)
|
||||
{
|
||||
Player = player;
|
||||
Fire = fire;
|
||||
Start = DateTime.UtcNow;
|
||||
m_Safe = false;
|
||||
}
|
||||
|
||||
public Campfire Fire { get; }
|
||||
public PlayerMobile Player{ get; }
|
||||
|
||||
public DateTime Start { get; }
|
||||
public Campfire Fire{ get; }
|
||||
|
||||
public bool Valid => !Fire.Deleted && Fire.Status != CampfireStatus.Off && Player.Map == Fire.Map && Player.InRange( Fire, Campfire.SecureRange );
|
||||
public DateTime Start{ get; }
|
||||
|
||||
public bool Safe
|
||||
{
|
||||
get => Valid && m_Safe;
|
||||
set => m_Safe = value;
|
||||
}
|
||||
public bool Valid => !Fire.Deleted && Fire.Status != CampfireStatus.Off && Player.Map == Fire.Map &&
|
||||
Player.InRange(Fire, Campfire.SecureRange);
|
||||
|
||||
public CampfireEntry( PlayerMobile player, Campfire fire )
|
||||
{
|
||||
Player = player;
|
||||
Fire = fire;
|
||||
Start = DateTime.UtcNow;
|
||||
m_Safe = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool Safe
|
||||
{
|
||||
get => Valid && m_Safe;
|
||||
set => m_Safe = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,115 +4,114 @@ using Server.Regions;
|
|||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class Kindling : Item
|
||||
{
|
||||
[Constructible]
|
||||
public Kindling() : this( 1 )
|
||||
{
|
||||
}
|
||||
public class Kindling : Item
|
||||
{
|
||||
[Constructible]
|
||||
public Kindling() : this(1)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public Kindling( int amount ) : base( 0xDE1 )
|
||||
{
|
||||
Stackable = true;
|
||||
Weight = 5.0;
|
||||
Amount = amount;
|
||||
}
|
||||
[Constructible]
|
||||
public Kindling(int amount) : base(0xDE1)
|
||||
{
|
||||
Stackable = true;
|
||||
Weight = 5.0;
|
||||
Amount = amount;
|
||||
}
|
||||
|
||||
public Kindling( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public Kindling(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( !VerifyMove( from ) )
|
||||
return;
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!VerifyMove(from))
|
||||
return;
|
||||
|
||||
if ( !from.InRange( GetWorldLocation(), 2 ) )
|
||||
{
|
||||
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
|
||||
return;
|
||||
}
|
||||
if (!from.InRange(GetWorldLocation(), 2))
|
||||
{
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
|
||||
return;
|
||||
}
|
||||
|
||||
Point3D fireLocation = GetFireLocation( from );
|
||||
Point3D fireLocation = GetFireLocation(from);
|
||||
|
||||
if ( fireLocation == Point3D.Zero )
|
||||
{
|
||||
from.SendLocalizedMessage( 501695 ); // There is not a spot nearby to place your campfire.
|
||||
}
|
||||
else if ( !from.CheckSkill( SkillName.Camping, 0.0, 100.0 ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 501696 ); // You fail to ignite the campfire.
|
||||
}
|
||||
else
|
||||
{
|
||||
Consume();
|
||||
if (fireLocation == Point3D.Zero)
|
||||
{
|
||||
from.SendLocalizedMessage(501695); // There is not a spot nearby to place your campfire.
|
||||
}
|
||||
else if (!from.CheckSkill(SkillName.Camping, 0.0, 100.0))
|
||||
{
|
||||
from.SendLocalizedMessage(501696); // You fail to ignite the campfire.
|
||||
}
|
||||
else
|
||||
{
|
||||
Consume();
|
||||
|
||||
if ( !Deleted && Parent == null )
|
||||
from.PlaceInBackpack( this );
|
||||
if (!Deleted && Parent == null)
|
||||
from.PlaceInBackpack(this);
|
||||
|
||||
new Campfire().MoveToWorld( fireLocation, from.Map );
|
||||
}
|
||||
}
|
||||
new Campfire().MoveToWorld(fireLocation, from.Map);
|
||||
}
|
||||
}
|
||||
|
||||
private Point3D GetFireLocation( Mobile from )
|
||||
{
|
||||
if ( from.Region.IsPartOf( typeof( DungeonRegion ) ) )
|
||||
return Point3D.Zero;
|
||||
private Point3D GetFireLocation(Mobile from)
|
||||
{
|
||||
if (from.Region.IsPartOf(typeof(DungeonRegion)))
|
||||
return Point3D.Zero;
|
||||
|
||||
if ( Parent == null )
|
||||
return Location;
|
||||
if (Parent == null)
|
||||
return Location;
|
||||
|
||||
ArrayList list = new ArrayList( 4 );
|
||||
ArrayList list = new ArrayList(4);
|
||||
|
||||
AddOffsetLocation( from, 0, -1, list );
|
||||
AddOffsetLocation( from, -1, 0, list );
|
||||
AddOffsetLocation( from, 0, 1, list );
|
||||
AddOffsetLocation( from, 1, 0, list );
|
||||
AddOffsetLocation(from, 0, -1, list);
|
||||
AddOffsetLocation(from, -1, 0, list);
|
||||
AddOffsetLocation(from, 0, 1, list);
|
||||
AddOffsetLocation(from, 1, 0, list);
|
||||
|
||||
if ( list.Count == 0 )
|
||||
return Point3D.Zero;
|
||||
if (list.Count == 0)
|
||||
return Point3D.Zero;
|
||||
|
||||
int idx = Utility.Random( list.Count );
|
||||
return (Point3D) list[idx];
|
||||
}
|
||||
int idx = Utility.Random(list.Count);
|
||||
return (Point3D)list[idx];
|
||||
}
|
||||
|
||||
private void AddOffsetLocation( Mobile from, int offsetX, int offsetY, ArrayList list )
|
||||
{
|
||||
Map map = from.Map;
|
||||
private void AddOffsetLocation(Mobile from, int offsetX, int offsetY, ArrayList list)
|
||||
{
|
||||
Map map = from.Map;
|
||||
|
||||
int x = from.X + offsetX;
|
||||
int y = from.Y + offsetY;
|
||||
int x = from.X + offsetX;
|
||||
int y = from.Y + offsetY;
|
||||
|
||||
Point3D loc = new Point3D( x, y, from.Z );
|
||||
Point3D loc = new Point3D(x, y, from.Z);
|
||||
|
||||
if ( map.CanFit( loc, 1 ) && from.InLOS( loc ) )
|
||||
{
|
||||
list.Add( loc );
|
||||
}
|
||||
else
|
||||
{
|
||||
loc = new Point3D( x, y, map.GetAverageZ( x, y ) );
|
||||
if (map.CanFit(loc, 1) && from.InLOS(loc))
|
||||
{
|
||||
list.Add(loc);
|
||||
}
|
||||
else
|
||||
{
|
||||
loc = new Point3D(x, y, map.GetAverageZ(x, y));
|
||||
|
||||
if ( map.CanFit( loc, 1 ) && from.InLOS( loc ) )
|
||||
list.Add( loc );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (map.CanFit(loc, 1) && from.InLOS(loc))
|
||||
list.Add(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue