#W# Initial Commit: Avatars Conquest
This commit is contained in:
commit
8eae46895e
7512 changed files with 416187 additions and 0 deletions
144
Scripts/Items/Skill Items/Camping/BedRolled.cs
Normal file
144
Scripts/Items/Skill Items/Camping/BedRolled.cs
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Network;
|
||||
using Server.Regions;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
[FlipableAttribute( 0xA58, 0xA59 )]
|
||||
public class BedRolled : Item
|
||||
{
|
||||
[Constructable]
|
||||
public BedRolled() : base( 0xA58 )
|
||||
{
|
||||
Weight = 5.0;
|
||||
Utility.RandomMinMax( 0xA58, 0xA59 );
|
||||
}
|
||||
|
||||
public BedRolled( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
|
||||
private bool BedsNearby( Mobile from )
|
||||
{
|
||||
foreach( Item i in GetItemsInRange( 20 ) )
|
||||
{
|
||||
if ( i is Bedroll )
|
||||
{
|
||||
Bedroll bed = (Bedroll)i;
|
||||
|
||||
if ( bed.Owner == from )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( from is PlayerMobile )
|
||||
{
|
||||
PlayerMobile pm = (PlayerMobile)from;
|
||||
|
||||
if ( BedsNearby( from ) )
|
||||
{
|
||||
from.SendMessage( "You already have a bedroll laid out!" );
|
||||
}
|
||||
else if ( !Server.Items.Kindling.EnemiesNearby( from ) )
|
||||
{
|
||||
from.SendMessage( "It is not safe enough to setup camp!" );
|
||||
}
|
||||
else if ( DateTime.Now >= pm.Bedroll )
|
||||
{
|
||||
if ( !this.VerifyMove( from ) )
|
||||
return;
|
||||
|
||||
if ( !from.InRange( this.GetWorldLocation(), 2 ) )
|
||||
{
|
||||
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
|
||||
return;
|
||||
}
|
||||
|
||||
Point3D bedLocation = GetBedLocation( from );
|
||||
|
||||
if ( bedLocation == Point3D.Zero )
|
||||
{
|
||||
from.SendMessage( "There is not a spot nearby to place your bedroll." );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !this.Deleted && this.Parent == null )
|
||||
from.PlaceInBackpack( this );
|
||||
|
||||
new Bedroll( from ).MoveToWorld( bedLocation, from.Map );
|
||||
pm.Bedroll = DateTime.Now + TimeSpan.FromMinutes( 10.0 );
|
||||
this.Delete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage( "You can only lay out a bedroll every 10 minutes!" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Point3D GetBedLocation( Mobile from )
|
||||
{
|
||||
if ( !Kindling.CampAllowed( from ) )
|
||||
return Point3D.Zero;
|
||||
|
||||
if ( this.Parent == null )
|
||||
return this.Location;
|
||||
|
||||
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 );
|
||||
|
||||
if ( list.Count == 0 )
|
||||
return Point3D.Zero;
|
||||
|
||||
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;
|
||||
|
||||
int x = from.X + offsetX;
|
||||
int y = from.Y + offsetY;
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
139
Scripts/Items/Skill Items/Camping/Bedroll.cs
Normal file
139
Scripts/Items/Skill Items/Camping/Bedroll.cs
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Network;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class Bedroll : Item
|
||||
{
|
||||
private Timer m_Timer;
|
||||
private DateTime m_Created;
|
||||
private Mobile m_Owner;
|
||||
|
||||
public Bedroll( Mobile owner ) : base( 0x0A55 )
|
||||
{
|
||||
ItemID = Utility.RandomMinMax( 0x0A55, 0x0A56 );
|
||||
m_Owner = owner;
|
||||
Movable = false;
|
||||
m_Created = DateTime.Now;
|
||||
m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), TimeSpan.FromSeconds( 1.0 ), new TimerCallback( OnTick ) );
|
||||
}
|
||||
|
||||
public Bedroll( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.Counselor, AccessLevel.GameMaster )]
|
||||
public Mobile Owner
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Owner;
|
||||
}
|
||||
set{ m_Owner = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public DateTime Created
|
||||
{
|
||||
get{ return m_Created; }
|
||||
}
|
||||
|
||||
private bool EnemiesNearby()
|
||||
{
|
||||
foreach( Mobile m in GetMobilesInRange( 20 ) )
|
||||
{
|
||||
if ( m is PlayerMobile && m.Combatant != null && m.InRange( m.Combatant.Location, 20 ) && m.Combatant.InLOS( m ) )
|
||||
return true;
|
||||
else if ( m is BaseCreature && !((BaseCreature)m).Controlled && !((BaseCreature)m).Summoned && ((BaseCreature)m).FightMode == FightMode.Closest )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void OnTick()
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
TimeSpan age = now - this.Created;
|
||||
|
||||
if ( age >= TimeSpan.FromSeconds( 100.0 ) )
|
||||
RollUp();
|
||||
|
||||
if ( this.Deleted )
|
||||
return;
|
||||
|
||||
List<Mobile> toRest = new List<Mobile>();
|
||||
if ( !EnemiesNearby() )
|
||||
{
|
||||
foreach( Mobile m in GetMobilesInRange( 3 ) )
|
||||
{
|
||||
if ( m is PlayerMobile && m == m_Owner )
|
||||
toRest.Add( m );
|
||||
}
|
||||
|
||||
for ( int i = 0; i < toRest.Count; i++ )
|
||||
Rest( toRest[i] );
|
||||
}
|
||||
}
|
||||
|
||||
public void RollUp()
|
||||
{
|
||||
if ( m_Owner != null )
|
||||
{
|
||||
Container cont = m_Owner.Backpack;
|
||||
if ( cont != null )
|
||||
m_Owner.AddToBackpack( new BedRolled() );
|
||||
}
|
||||
|
||||
this.Delete();
|
||||
}
|
||||
|
||||
public void Rest( Mobile m )
|
||||
{
|
||||
if ( m.Hunger > 4 && m.Thirst > 4 )
|
||||
{
|
||||
if ( m.Stam < m.StamMax )
|
||||
m.Stam++;
|
||||
if ( m.Hits < m.HitsMax )
|
||||
{
|
||||
int hits = (int)(1 * Server.Misc.Settings.HitPoints());
|
||||
if ( hits < 1 )
|
||||
hits = 1;
|
||||
|
||||
m.Hits = m.Hits + hits;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( m_Owner == from )
|
||||
RollUp();
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
if ( m_Timer != null )
|
||||
m_Timer.Stop();
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 ); // version
|
||||
writer.Write( (Mobile) m_Owner );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
m_Owner = reader.ReadMobile();
|
||||
RollUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
160
Scripts/Items/Skill Items/Camping/Campfire.cs
Normal file
160
Scripts/Items/Skill Items/Camping/Campfire.cs
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Network;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public enum CampfireStatus
|
||||
{
|
||||
Burning,
|
||||
Extinguishing,
|
||||
Off
|
||||
}
|
||||
|
||||
public class Campfire : Item
|
||||
{
|
||||
private Timer m_Timer;
|
||||
private DateTime m_Created;
|
||||
|
||||
public Campfire() : base( 0xDE3 )
|
||||
{
|
||||
Movable = false;
|
||||
Light = LightType.Circle300;
|
||||
m_Created = DateTime.Now;
|
||||
m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), TimeSpan.FromSeconds( 1.0 ), new TimerCallback( OnTick ) );
|
||||
}
|
||||
|
||||
public Campfire( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public DateTime Created
|
||||
{
|
||||
get{ return m_Created; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public CampfireStatus Status
|
||||
{
|
||||
get
|
||||
{
|
||||
switch ( this.ItemID )
|
||||
{
|
||||
case 0xDE3:
|
||||
return CampfireStatus.Burning;
|
||||
|
||||
case 0xDE9:
|
||||
return CampfireStatus.Extinguishing;
|
||||
|
||||
default:
|
||||
return CampfireStatus.Off;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if ( this.Status == value )
|
||||
return;
|
||||
|
||||
switch ( value )
|
||||
{
|
||||
case CampfireStatus.Burning:
|
||||
this.ItemID = 0xDE3;
|
||||
this.Light = LightType.Circle300;
|
||||
break;
|
||||
|
||||
case CampfireStatus.Extinguishing:
|
||||
this.ItemID = 0xDE9;
|
||||
this.Light = LightType.Circle150;
|
||||
break;
|
||||
|
||||
default:
|
||||
this.ItemID = 0xDEA;
|
||||
this.Light = LightType.ArchedWindowEast;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool EnemiesNearby()
|
||||
{
|
||||
foreach( Mobile m in GetMobilesInRange( 20 ) )
|
||||
{
|
||||
if ( m is PlayerMobile && m.Combatant != null && m.InRange( m.Combatant.Location, 20 ) && m.Combatant.InLOS( m ) )
|
||||
return true;
|
||||
else if ( m is BaseCreature && !((BaseCreature)m).Controlled && !((BaseCreature)m).Summoned && ((BaseCreature)m).FightMode == FightMode.Closest )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void OnTick()
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
TimeSpan age = now - this.Created;
|
||||
|
||||
if ( age >= TimeSpan.FromSeconds( 100.0 ) )
|
||||
this.Delete();
|
||||
else if ( age >= TimeSpan.FromSeconds( 90.0 ) )
|
||||
this.Status = CampfireStatus.Off;
|
||||
else if ( age >= TimeSpan.FromSeconds( 60.0 ) )
|
||||
this.Status = CampfireStatus.Extinguishing;
|
||||
|
||||
if ( this.Status == CampfireStatus.Off || this.Deleted )
|
||||
return;
|
||||
|
||||
List<Mobile> toRest = new List<Mobile>();
|
||||
if ( !EnemiesNearby() )
|
||||
{
|
||||
foreach( Mobile m in GetMobilesInRange( 6 ) )
|
||||
{
|
||||
if ( m is PlayerMobile )
|
||||
toRest.Add( m );
|
||||
}
|
||||
|
||||
for ( int i = 0; i < toRest.Count; i++ )
|
||||
Rest( toRest[i] );
|
||||
}
|
||||
}
|
||||
|
||||
public void Rest( Mobile m )
|
||||
{
|
||||
if ( m.Hunger > 4 && m.Thirst > 4 )
|
||||
{
|
||||
if ( m.Stam < m.StamMax )
|
||||
m.Stam++;
|
||||
if ( m.Hits < m.HitsMax )
|
||||
{
|
||||
int hits = (int)(1 * Server.Misc.Settings.HitPoints());
|
||||
if ( hits < 1 )
|
||||
hits = 1;
|
||||
|
||||
m.Hits = m.Hits + hits;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
if ( m_Timer != null )
|
||||
m_Timer.Stop();
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
this.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
183
Scripts/Items/Skill Items/Camping/Kindling.cs
Normal file
183
Scripts/Items/Skill Items/Camping/Kindling.cs
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Network;
|
||||
using Server.Regions;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class Kindling : Item
|
||||
{
|
||||
[Constructable]
|
||||
public Kindling() : this( 1 )
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public Kindling( int amount ) : base( 0xDE1 )
|
||||
{
|
||||
Stackable = true;
|
||||
Weight = 5.0;
|
||||
Amount = amount;
|
||||
}
|
||||
|
||||
public Kindling( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
|
||||
public static bool EnemiesNearby( Mobile from )
|
||||
{
|
||||
foreach( Mobile m in from.GetMobilesInRange( 20 ) )
|
||||
{
|
||||
if ( m is PlayerMobile && m.Combatant != null && m.InRange( m.Combatant.Location, 20 ) && m.Combatant.InLOS( m ) )
|
||||
return true;
|
||||
else if ( m is BaseCreature && !((BaseCreature)m).Controlled && !((BaseCreature)m).Summoned && ((BaseCreature)m).FightMode == FightMode.Closest )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool CampAllowed( Mobile from )
|
||||
{
|
||||
if ( from.Region.IsPartOf( typeof( InnRegion ) ) )
|
||||
return false;
|
||||
|
||||
if ( from.Region.IsPartOf( typeof( HouseRegion ) ) )
|
||||
return false;
|
||||
|
||||
if ( from.Region.IsPartOf( typeof( GateRegion ) ) )
|
||||
return false;
|
||||
|
||||
if ( from.Region.IsPartOf( typeof( GardenRegion ) ) )
|
||||
return false;
|
||||
|
||||
if ( from.Region.IsPartOf( typeof( BuildingRegion ) ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
|
||||
private bool CampsNearby()
|
||||
{
|
||||
foreach( Item i in GetItemsInRange( 20 ) )
|
||||
{
|
||||
if ( i is Campfire )
|
||||
{
|
||||
Campfire fire = (Campfire)i;
|
||||
|
||||
if ( fire.Status != CampfireStatus.Off )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( from is PlayerMobile )
|
||||
{
|
||||
PlayerMobile pm = (PlayerMobile)from;
|
||||
|
||||
if ( CampsNearby() )
|
||||
{
|
||||
from.SendMessage( "There is already a camp nearby!" );
|
||||
}
|
||||
else if ( !EnemiesNearby( from ) )
|
||||
{
|
||||
from.SendMessage( "It is not safe enough to setup camp!" );
|
||||
}
|
||||
else if ( DateTime.Now >= pm.Camp )
|
||||
{
|
||||
if ( !this.VerifyMove( from ) )
|
||||
return;
|
||||
|
||||
if ( !from.InRange( this.GetWorldLocation(), 2 ) )
|
||||
{
|
||||
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
|
||||
return;
|
||||
}
|
||||
|
||||
Point3D fireLocation = GetFireLocation( from );
|
||||
|
||||
if ( fireLocation == Point3D.Zero )
|
||||
{
|
||||
from.SendLocalizedMessage( 501695 ); // There is not a spot nearby to place your campfire.
|
||||
}
|
||||
else
|
||||
{
|
||||
Consume();
|
||||
|
||||
if ( !this.Deleted && this.Parent == null )
|
||||
from.PlaceInBackpack( this );
|
||||
|
||||
new Campfire().MoveToWorld( fireLocation, from.Map );
|
||||
pm.Camp = DateTime.Now + TimeSpan.FromMinutes( 10.0 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage( "You can only build a camp fire every 10 minutes!" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Point3D GetFireLocation( Mobile from )
|
||||
{
|
||||
if ( !CampAllowed( from ) )
|
||||
return Point3D.Zero;
|
||||
|
||||
if ( this.Parent == null )
|
||||
return this.Location;
|
||||
|
||||
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 );
|
||||
|
||||
if ( list.Count == 0 )
|
||||
return Point3D.Zero;
|
||||
|
||||
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;
|
||||
|
||||
int x = from.X + offsetX;
|
||||
int y = from.Y + offsetY;
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue