Full Version : Kills and Deaths
xmlspawner >>Scripting Support >>Kills and Deaths
<< Prev | Next >>
kobra- 04-26-2006
[B]Hello, i am trying to get the kills/deaths system to work on my server, can u please help me - ill post code of my playermobile below (IN RED IS WHAT I ADDED!)

CODE
using System; using System.Collections; using Server; using Server.Misc; using Server.Items;
using Server.Gumps;
using Server.Multis;
using Server.Engines.Help;
using Server.ContextMenus;
using Server.Network;
using Server.Spells;
using Server.Spells.Fifth;
using Server.Spells.Seventh;
using Server.Targeting;
using Server.Engines.Quests;
using Server.Factions;
using Server.Regions;
using Server.Accounting;
namespace Server.Mobiles
{
[Flags]
public enum PlayerFlag // First 16 bits are reserved for default-distro use, start custom flags at 0x00010000
{
None = 0x00000000,
Glassblowing = 0x00000001,
Masonry = 0x00000002,
SandMining = 0x00000004,
StoneMining = 0x00000008,
ToggleMiningStone = 0x00000010,
KarmaLocked = 0x00000020,
AutoRenewInsurance = 0x00000040,
UseOwnFilter = 0x00000080,
PublicMyRunUO = 0x00000100,
PagingSquelched = 0x00000200,
Young = 0x00000400
}
public enum NpcGuild
{
None,
MagesGuild,
WarriorsGuild,
ThievesGuild,
RangersGuild,
HealersGuild,
MinersGuild,
MerchantsGuild,
TinkersGuild,
TailorsGuild,
FishermensGuild,
BardsGuild,
BlacksmithsGuild
}
public enum SolenFriendship
{
None,
Red,
Black
}
public class PlayerMobile : Mobile
{
private class CountAndTimeStamp
{
private int m_Count;
private DateTime m_Stamp;
public CountAndTimeStamp()
{
}
public DateTime TimeStamp { get{ return m_Stamp; } }
public int Count
{
get { return m_Count; }
set { m_Count = value; m_Stamp = DateTime.Now; }
}
}
private DesignContext m_DesignContext;
private NpcGuild m_NpcGuild;
private DateTime m_NpcGuildJoinTime;
private TimeSpan m_NpcGuildGameTime;
private PlayerFlag m_Flags;
private int m_StepsTaken;
private int m_Profession;
[COLOR=red]private int m_Deaths = 0;
private int m_Kills = 0;
[CommandProperty( AccessLevel.GameMaster )]
public int Deaths
{
get{ return m_Deaths; }
set{ m_Deaths = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public int Kills
{
get{ return m_Kills; }
set{ m_Kills = value; }
}[/COLOR]
//Start Pvp Point System
private int m_TotalPoints;
private int m_TotalWins;
private int m_TotalLoses;
private int m_TotalResKills;
private int m_TotalResKilled;
private Mobile m_LastPwner;
private Mobile m_LastPwned;
private DateTime m_ResKillTime;
private int m_TotalPointsLost;
private int m_TotalPointsSpent;
private string m_PvpRank = "Newbie";
[CommandProperty( AccessLevel.GameMaster )]
public string PvpRank
{
get{ return m_PvpRank; }
set{ m_PvpRank = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
public int TotalPoints
{
get{ return m_TotalPoints; }
set{ m_TotalPoints = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public int TotalWins
{
get{ return m_TotalWins; }
set{ m_TotalWins = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public int TotalLoses
{
get{ return m_TotalLoses; }
set{ m_TotalLoses = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public int TotalResKills
{
get{ return m_TotalResKills; }
set{ m_TotalResKills = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public int TotalResKilled
{
get{ return m_TotalResKilled; }
set{ m_TotalResKilled = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public Mobile LastPwner
{
get{ return m_LastPwner; }
set{ m_LastPwner = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public Mobile LastPwned
{
get{ return m_LastPwned; }
set{ m_LastPwned = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public TimeSpan ResKillTime
{
get
{
TimeSpan ts = m_ResKillTime - DateTime.Now;
if ( ts < TimeSpan.Zero )
ts = TimeSpan.Zero;
return ts;
}
set
{
try{ m_ResKillTime = DateTime.Now + value; }
catch{}
}
}
[CommandProperty( AccessLevel.GameMaster )]
public int TotalPointsLost
{
get{ return m_TotalPointsLost; }
set{ m_TotalPointsLost = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public int TotalPointsSpent
{
get{ return m_TotalPointsSpent; }
set{ m_TotalPointsSpent = value; }
}
//End Pvp Point System
[CommandProperty( AccessLevel.GameMaster )]
public int Profession
{
get{ return m_Profession; }
set{ m_Profession = value; }
}
public int StepsTaken
{
get{ return m_StepsTaken; }
set{ m_StepsTaken = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public NpcGuild NpcGuild
{
get{ return m_NpcGuild; }
set{ m_NpcGuild = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public DateTime NpcGuildJoinTime
{
get{ return m_NpcGuildJoinTime; }
set{ m_NpcGuildJoinTime = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public TimeSpan NpcGuildGameTime
{
get{ return m_NpcGuildGameTime; }
set{ m_NpcGuildGameTime = value; }
}
public PlayerFlag Flags
{
get{ return m_Flags; }
set{ m_Flags = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool PagingSquelched
{
get{ return GetFlag( PlayerFlag.PagingSquelched ); }
set{ SetFlag( PlayerFlag.PagingSquelched, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool Glassblowing
{
get{ return GetFlag( PlayerFlag.Glassblowing ); }
set{ SetFlag( PlayerFlag.Glassblowing, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool Masonry
{
get{ return GetFlag( PlayerFlag.Masonry ); }
set{ SetFlag( PlayerFlag.Masonry, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool SandMining
{
get{ return GetFlag( PlayerFlag.SandMining ); }
set{ SetFlag( PlayerFlag.SandMining, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool StoneMining
{
get{ return GetFlag( PlayerFlag.StoneMining ); }
set{ SetFlag( PlayerFlag.StoneMining, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool ToggleMiningStone
{
get{ return GetFlag( PlayerFlag.ToggleMiningStone ); }
set{ SetFlag( PlayerFlag.ToggleMiningStone, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool KarmaLocked
{
get{ return GetFlag( PlayerFlag.KarmaLocked ); }
set{ SetFlag( PlayerFlag.KarmaLocked, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool AutoRenewInsurance
{
get{ return GetFlag( PlayerFlag.AutoRenewInsurance ); }
set{ SetFlag( PlayerFlag.AutoRenewInsurance, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool UseOwnFilter
{
get{ return GetFlag( PlayerFlag.UseOwnFilter ); }
set{ SetFlag( PlayerFlag.UseOwnFilter, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool PublicMyRunUO
{
get{ return GetFlag( PlayerFlag.PublicMyRunUO ); }
set{ SetFlag( PlayerFlag.PublicMyRunUO, value ); InvalidateMyRunUO(); }
}
public static Direction GetDirection4( Point3D from, Point3D to )
{
int dx = from.X - to.X;
int dy = from.Y - to.Y;
int rx = dx - dy;
int ry = dx + dy;
Direction ret;
if ( rx >= 0 && ry >= 0 )
ret = Direction.West;
else if ( rx >= 0 && ry < 0 )
ret = Direction.South;
else if ( rx < 0 && ry < 0 )
ret = Direction.East;
else
ret = Direction.North;
return ret;
}
public override bool OnDroppedItemToWorld( Item item, Point3D location )
{
if ( !base.OnDroppedItemToWorld( item, location ) )
return false;
BounceInfo bi = item.GetBounce();
if ( bi != null )
{
Type type = item.GetType();
if ( type.IsDefined( typeof( FurnitureAttribute ), true ) || type.IsDefined( typeof( DynamicFlipingAttribute ), true ) )
{
object[] objs = type.GetCustomAttributes( typeof( FlipableAttribute ), true );
if ( objs != null && objs.Length > 0 )
{
FlipableAttribute fp = objs[0] as FlipableAttribute;
if ( fp != null )
{
int[] itemIDs = fp.ItemIDs;
Point3D oldWorldLoc = bi.m_WorldLoc;
Point3D newWorldLoc = location;
if ( oldWorldLoc.X != newWorldLoc.X || oldWorldLoc.Y != newWorldLoc.Y )
{
Direction dir = GetDirection4( oldWorldLoc, newWorldLoc );
if ( itemIDs.Length == 2 )
{
switch ( dir )
{
case Direction.North:
case Direction.South: item.ItemID = itemIDs[0]; break;
case Direction.East:
case Direction.West: item.ItemID = itemIDs[1]; break;
}
}
else if ( itemIDs.Length == 4 )
{
switch ( dir )
{
case Direction.South: item.ItemID = itemIDs[0]; break;
case Direction.East: item.ItemID = itemIDs[1]; break;
case Direction.North: item.ItemID = itemIDs[2]; break;
case Direction.West: item.ItemID = itemIDs[3]; break;
}
}
}
}
}
}
}
return true;
}
public bool GetFlag( PlayerFlag flag )
{
return ( (m_Flags & flag) != 0 );
}
public void SetFlag( PlayerFlag flag, bool value )
{
if ( value )
m_Flags |= flag;
else
m_Flags &= ~flag;
}
public DesignContext DesignContext
{
get{ return m_DesignContext; }
set{ m_DesignContext = value; }
}
public static void Initialize()
{
if ( FastwalkPrevention )
{
PacketHandler ph = PacketHandlers.GetHandler( 0x02 );
ph.ThrottleCallback = new ThrottlePacketCallback( MovementThrottle_Callback );
}
EventSink.Login += new LoginEventHandler( OnLogin );
EventSink.Logout += new LogoutEventHandler( OnLogout );
EventSink.Connected += new ConnectedEventHandler( EventSink_Connected );
EventSink.Disconnected += new DisconnectedEventHandler( EventSink_Disconnected );
}
public override void OnSkillInvalidated( Skill skill )
{
if ( Core.AOS && skill.SkillName == SkillName.MagicResist )
UpdateResistances();
}
public override int GetMaxResistance( ResistanceType type )
{
int max = base.GetMaxResistance( type );
if ( type != ResistanceType.Physical && 60 < max && Spells.Fourth.CurseSpell.UnderEffect( this ) )
max = 60;
return max;
}
private int m_LastGlobalLight = -1, m_LastPersonalLight = -1;
public override void OnNetStateChanged()
{
m_LastGlobalLight = -1;
m_LastPersonalLight = -1;
}
public override void ComputeBaseLightLevels( out int global, out int personal )
{
global = LightCycle.ComputeLevelFor( this );
if ( this.LightLevel < 21 && AosAttributes.GetValue( this, AosAttribute.NightSight ) > 0 )
personal = 21;
else
personal = this.LightLevel;
}
public override void CheckLightLevels( bool forceResend )
{
NetState ns = this.NetState;
if ( ns == null )
return;
int global, personal;
ComputeLightLevels( out global, out personal );
if ( !forceResend )
forceResend = ( global != m_LastGlobalLight || personal != m_LastPersonalLight );
if ( !forceResend )
return;
m_LastGlobalLight = global;
m_LastPersonalLight = personal;
ns.Send( GlobalLightLevel.Instantiate( global ) );
ns.Send( new PersonalLightLevel( this, personal ) );
}
public override int GetMinResistance( ResistanceType type )
{
int magicResist = (int)(Skills[SkillName.MagicResist].Value * 10);
int min = int.MinValue;
if ( magicResist >= 1000 )
min = 40 + ((magicResist - 1000) / 50);
else if ( magicResist >= 400 )
min = (magicResist - 400) / 15;
if ( min > MaxPlayerResistance )
min = MaxPlayerResistance;
int baseMin = base.GetMinResistance( type );
if ( min < baseMin )
min = baseMin;
return min;
}
private static void OnLogin( LoginEventArgs e )
{
Mobile from = e.Mobile;
SacrificeVirtue.CheckAtrophy( from );
JusticeVirtue.CheckAtrophy( from );
CompassionVirtue.CheckAtrophy( from );
if ( AccountHandler.LockdownLevel > AccessLevel.Player )
{
string notice;
Accounting.Account acct = from.Account as Accounting.Account;
if ( acct == null || !acct.HasAccess( from.NetState ) )
{
if ( from.AccessLevel == AccessLevel.Player )
notice = "The server is currently under lockdown. No players are allowed to log in at this time.";
else
notice = "The server is currently under lockdown. You do not have sufficient access level to connect.";
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), new TimerStateCallback( Disconnect ), from );
}
else if ( from.AccessLevel == AccessLevel.Administrator )
{
notice = "The server is currently under lockdown. As you are an administrator, you may change this from the [Admin gump.";
}
else
{
notice = "The server is currently under lockdown. You have sufficient access level to connect.";
}
from.SendGump( new NoticeGump( 1060637, 30720, notice, 0xFFC000, 300, 140, null, null ) );
}
}
private bool m_NoDeltaRecursion;
public void ValidateEquipment()
{
if ( m_NoDeltaRecursion || Map == null || Map == Map.Internal )
return;
if ( this.Items == null )
return;
m_NoDeltaRecursion = true;
Timer.DelayCall( TimeSpan.Zero, new TimerCallback( ValidateEquipment_Sandbox ) );
}
private void ValidateEquipment_Sandbox()
{
try
{
if ( Map == null || Map == Map.Internal )
return;
ArrayList items = this.Items;
if ( items == null )
return;
bool moved = false;
int str = this.Str;
int dex = this.Dex;
int intel = this.Int;
#region Factions
int factionItemCount = 0;
#endregion
Mobile from = this;
for ( int i = items.Count - 1; i >= 0; --i )
{
if ( i >= items.Count )
continue;
Item item = (Item)items[i];
if ( item is BaseWeapon )
{
BaseWeapon weapon = (BaseWeapon)item;
bool drop = false;
if ( dex < weapon.DexRequirement )
drop = true;
else if ( str < AOS.Scale( weapon.StrRequirement, 100 - weapon.GetLowerStatReq() ) )
drop = true;
else if ( intel < weapon.IntRequirement )
drop = true;
if ( drop )
{
string name = weapon.Name;
if ( name == null )
name = String.Format( "#{0}", weapon.LabelNumber );
from.SendLocalizedMessage( 1062001, name ); // You can no longer wield your ~1_WEAPON~
from.AddToBackpack( weapon );
moved = true;
}
}
else if ( item is BaseArmor )
{
BaseArmor armor = (BaseArmor)item;
bool drop = false;
if ( !armor.AllowMaleWearer && from.Body.IsMale && from.AccessLevel < AccessLevel.GameMaster )
{
drop = true;
}
else if ( !armor.AllowFemaleWearer && from.Body.IsFemale && from.AccessLevel < AccessLevel.GameMaster )
{
drop = true;
}
else
{
int strBonus = armor.ComputeStatBonus( StatType.Str ), strReq = armor.ComputeStatReq( StatType.Str );
int dexBonus = armor.ComputeStatBonus( StatType.Dex ), dexReq = armor.ComputeStatReq( StatType.Dex );
int intBonus = armor.ComputeStatBonus( StatType.Int ), intReq = armor.ComputeStatReq( StatType.Int );
if ( dex < dexReq || (dex + dexBonus) < 1 )
drop = true;
else if ( str < strReq || (str + strBonus) < 1 )
drop = true;
else if ( intel < intReq || (intel + intBonus) < 1 )
drop = true;
}
if ( drop )
{
string name = armor.Name;
if ( name == null )
name = String.Format( "#{0}", armor.LabelNumber );
if ( armor is BaseShield )
from.SendLocalizedMessage( 1062003, name ); // You can no longer equip your ~1_SHIELD~
else
from.SendLocalizedMessage( 1062002, name ); // You can no longer wear your ~1_ARMOR~
from.AddToBackpack( armor );
moved = true;
}
}
FactionItem factionItem = FactionItem.Find( item );
if ( factionItem != null )
{
bool drop = false;
Faction ourFaction = Faction.Find( this );
if ( ourFaction == null || ourFaction != factionItem.Faction )
drop = true;
else if ( ++factionItemCount > FactionItem.GetMaxWearables( this ) )
drop = true;
if ( drop )
{
from.AddToBackpack( item );
moved = true;
}
}
}
if ( moved )
from.SendLocalizedMessage( 500647 ); // Some equipment has been moved to your backpack.
}
catch ( Exception e )
{
Console.WriteLine( e );
}
finally
{
m_NoDeltaRecursion = false;
}
}
public override void Delta( MobileDelta flag )
{
base.Delta( flag );
if ( (flag & MobileDelta.Stat) != 0 )
ValidateEquipment();
if ( (flag & (MobileDelta.Name | MobileDelta.Hue)) != 0 )
InvalidateMyRunUO();
}
private static void Disconnect( object state )
{
NetState ns = ((Mobile)state).NetState;
if ( ns != null )
ns.Dispose();
}
private static void OnLogout( LogoutEventArgs e )
{
}
private static void EventSink_Connected( ConnectedEventArgs e )
{
PlayerMobile pm = e.Mobile as PlayerMobile;
if ( pm != null )
{
pm.m_SessionStart = DateTime.Now;
if ( pm.m_Quest != null )
pm.m_Quest.StartTimer();
pm.BedrollLogout = false;
}
}
private static void EventSink_Disconnected( DisconnectedEventArgs e )
{
Mobile from = e.Mobile;
DesignContext context = DesignContext.Find( from );
if ( context != null )
{
/* Client disconnected
* - Remove design context
* - Eject all from house
* - Restore relocated entities
*/
// Remove design context
DesignContext.Remove( from );
// Eject all from house
from.RevealingAction();
foreach ( Item item in context.Foundation.GetItems() )
item.Location = context.Foundation.BanLocation;
foreach ( Mobile mobile in context.Foundation.GetMobiles() )
mobile.Location = context.Foundation.BanLocation;
// Restore relocated entities
context.Foundation.RestoreRelocatedEntities();
}
PlayerMobile pm = e.Mobile as PlayerMobile;
if ( pm != null )
{
pm.m_GameTime += (DateTime.Now - pm.m_SessionStart);
if ( pm.m_Quest != null )
pm.m_Quest.StopTimer();
pm.m_SpeechLog = null;
}
}
public override void RevealingAction()
{
if ( m_DesignContext != null )
return;
Spells.Sixth.InvisibilitySpell.RemoveTimer( this );
base.RevealingAction();
}
public override void OnSubItemAdded( Item item )
{
if ( AccessLevel < AccessLevel.GameMaster && item.IsChildOf( this.Backpack ) )
{
int maxWeight = WeightOverloading.GetMaxWeight( this );
int curWeight = Mobile.BodyWeight + this.TotalWeight;
if ( curWeight > maxWeight )
this.SendLocalizedMessage( 1019035, true, String.Format( " : {0} / {1}", curWeight, maxWeight ) );
}
}
public override bool CanBeHarmful( Mobile target, bool message, bool ignoreOurBlessedness )
{
if ( m_DesignContext != null || (target is PlayerMobile && ((PlayerMobile)target).m_DesignContext != null) )
return false;
if ( (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier )
{
if ( message )
{
if ( target.Title == null )
SendMessage( "{0} the vendor cannot be harmed.", target.Name );
else
SendMessage( "{0} {1} cannot be harmed.", target.Name, target.Title );
}
return false;
}
return base.CanBeHarmful( target, message, ignoreOurBlessedness );
}
public override bool CanBeBeneficial( Mobile target, bool message, bool allowDead )
{
if ( m_DesignContext != null || (target is PlayerMobile && ((PlayerMobile)target).m_DesignContext != null) )
return false;
return base.CanBeBeneficial( target, message, allowDead );
}
public override bool CheckContextMenuDisplay( IEntity target )
{
return ( m_DesignContext == null );
}
public override void OnItemAdded( Item item )
{
base.OnItemAdded( item );
if ( item is BaseArmor || item is BaseWeapon )
{
Hits=Hits; Stam=Stam; Mana=Mana;
}
if ( this.NetState != null )
CheckLightLevels( false );
InvalidateMyRunUO();
}
public override void OnItemRemoved( Item item )
{
base.OnItemRemoved( item );
if ( item is BaseArmor || item is BaseWeapon )
{
Hits=Hits; Stam=Stam; Mana=Mana;
}
if ( this.NetState != null )
CheckLightLevels( false );
InvalidateMyRunUO();
}
public override double ArmorRating
{
get
{
BaseArmor ar;
double rating = 0.0;
ar = NeckArmor as BaseArmor;
if ( ar != null )
rating += ar.ArmorRatingScaled;
ar = HandArmor as BaseArmor;
if ( ar != null )
rating += ar.ArmorRatingScaled;
ar = HeadArmor as BaseArmor;
if ( ar != null )
rating += ar.ArmorRatingScaled;
ar = ArmsArmor as BaseArmor;
if ( ar != null )
rating += ar.ArmorRatingScaled;
ar = LegsArmor as BaseArmor;
if ( ar != null )
rating += ar.ArmorRatingScaled;
ar = ChestArmor as BaseArmor;
if ( ar != null )
rating += ar.ArmorRatingScaled;
ar = ShieldArmor as BaseArmor;
if ( ar != null )
rating += ar.ArmorRatingScaled;
return VirtualArmor + VirtualArmorMod + rating;
}
}
public override int HitsMax
{
get
{
int strBase;
int strOffs = GetStatOffset( StatType.Str );
if ( Core.AOS )
{
strBase = this.Str;
strOffs += AosAttributes.GetValue( this, AosAttribute.BonusHits );
}
else
{
strBase = this.RawStr;
}
return (strBase / 2) + 50 + strOffs;
}
}
public override int StamMax
{
get{ return base.StamMax + AosAttributes.GetValue( this, AosAttribute.BonusStam ); }
}
public override int ManaMax
{
get{ return base.ManaMax + AosAttributes.GetValue( this, AosAttribute.BonusMana ); }
}
public override bool Move( Direction d )
{
NetState ns = this.NetState;
if ( ns != null )
{
GumpCollection gumps = ns.Gumps;
for ( int i = 0; i < gumps.Count; ++i )
{
if ( gumps[i] is ResurrectGump )
{
if ( Alive )
{
CloseGump( typeof( ResurrectGump ) );
}
else
{
SendLocalizedMessage( 500111 ); // You are frozen and cannot move.
return false;
}
}
}
}
TimeSpan speed = ComputeMovementSpeed( d );
if ( !base.Move( d ) )
return false;
m_NextMovementTime += speed;
return true;
}
public override bool CheckMovement( Direction d, out int newZ )
{
DesignContext context = m_DesignContext;
if ( context == null )
return base.CheckMovement( d, out newZ );
HouseFoundation foundation = context.Foundation;
newZ = foundation.Z + HouseFoundation.GetLevelZ( context.Level );
int newX = this.X, newY = this.Y;
Movement.Movement.Offset( d, ref newX, ref newY );
int startX = foundation.X + foundation.Components.Min.X + 1;
int startY = foundation.Y + foundation.Components.Min.Y + 1;
int endX = startX + foundation.Components.Width - 1;
int endY = startY + foundation.Components.Height - 2;
return ( newX >= startX && newY >= startY && newX < endX && newY < endY && Map == foundation.Map );
}
public override bool AllowItemUse( Item item )
{
return DesignContext.Check( this );
}
public override bool AllowSkillUse( SkillName skill )
{
return DesignContext.Check( this );
}
private bool m_LastProtectedMessage;
private int m_NextProtectionCheck = 10;
public virtual void RecheckTownProtection()
{
m_NextProtectionCheck = 10;
Regions.GuardedRegion reg = this.Region as Regions.GuardedRegion;
bool isProtected = ( reg != null && !reg.IsDisabled() );
if ( isProtected != m_LastProtectedMessage )
{
if ( isProtected )
SendLocalizedMessage( 500112 ); // You are now under the protection of the town guards.
else
SendLocalizedMessage( 500113 ); // You have left the protection of the town guards.
m_LastProtectedMessage = isProtected;
}
}
public override void MoveToWorld( Point3D loc, Map map )
{
base.MoveToWorld( loc, map );
RecheckTownProtection();
}
public override void SetLocation( Point3D loc, bool isTeleport )
{
if ( !isTeleport && AccessLevel == AccessLevel.Player )
{
// moving, not teleporting
int zDrop = ( this.Location.Z - loc.Z );
if ( zDrop > 20 ) // we fell more than one story
Hits -= ((zDrop / 20) * 10) - 5; // deal some damage; does not kill, disrupt, etc
}
base.SetLocation( loc, isTeleport );
if ( isTeleport || --m_NextProtectionCheck == 0 )
RecheckTownProtection();
}
public override void GetContextMenuEntries( Mobile from, ArrayList list )
{
base.GetContextMenuEntries( from, list );
if ( from == this )
{
if ( m_Quest != null )
m_Quest.GetContextMenuEntries( list );
if ( Alive && InsuranceEnabled )
{
list.Add( new CallbackEntry( 6201, new ContextCallback( ToggleItemInsurance ) ) );
if ( AutoRenewInsurance )
list.Add( new CallbackEntry( 6202, new ContextCallback( CancelRenewInventoryInsurance ) ) );
else
list.Add( new CallbackEntry( 6200, new ContextCallback( AutoRenewInventoryInsurance ) ) );
}
// TODO: Toggle champ titles
BaseHouse house = BaseHouse.FindHouseAt( this );
if ( house != null )
{
if ( Alive && house.InternalizedVendors.Count > 0 && house.IsOwner( this ) )
list.Add( new CallbackEntry( 6204, new ContextCallback( GetVendor ) ) );
if ( house.IsAosRules )
list.Add( new CallbackEntry( 6207, new ContextCallback( LeaveHouse ) ) );
}
if ( m_JusticeProtectors.Count > 0 )
list.Add( new CallbackEntry( 6157, new ContextCallback( CancelProtection ) ) );
}
}
private void CancelProtection()
{
for ( int i = 0; i < m_JusticeProtectors.Count; ++i )
{
Mobile prot = (Mobile)m_JusticeProtectors[i];
string args = String.Format( "{0}\t{1}", this.Name, prot.Name );
prot.SendLocalizedMessage( 1049371, args ); // The protective relationship between ~1_PLAYER1~ and ~2_PLAYER2~ has been ended.
this.SendLocalizedMessage( 1049371, args ); // The protective relationship between ~1_PLAYER1~ and ~2_PLAYER2~ has been ended.
}
m_JusticeProtectors.Clear();
}
private void ToggleItemInsurance()
{
if ( !CheckAlive() )
return;
BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
SendLocalizedMessage( 1060868 ); // Target the item you wish to toggle insurance status on <ESC> to cancel
}
private bool CanInsure( Item item )
{
if ( item is Container || item is BagOfSending )
return false;
if ( item is Spellbook || item is Runebook || item is PotionKeg || item is Sigil )
return false;
if ( item.Stackable )
return false;
if ( item.LootType == LootType.Cursed )
return false;
if ( item.ItemID == 0x204E ) // death shroud
return false;
return true;
}
private void ToggleItemInsurance_Callback( Mobile from, object obj )
{
if ( !CheckAlive() )
return;
Item item = obj as Item;
if ( item == null || !item.IsChildOf( this ) )
{
BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
SendLocalizedMessage( 1060871, "", 0x23 ); // You can only insure items that you have equipped or that are in your backpack
}
else if ( item.Insured )
{
item.Insured = false;
SendLocalizedMessage( 1060874, "", 0x35 ); // You cancel the insurance on the item
BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
SendLocalizedMessage( 1060868, "", 0x23 ); // Target the item you wish to toggle insurance status on <ESC> to cancel
}
else if ( !CanInsure( item ) )
{
BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
SendLocalizedMessage( 1060869, "", 0x23 ); // You cannot insure that
}
else if ( item.LootType == LootType.Blessed || item.LootType == LootType.Newbied || item.BlessedFor == from )
{
BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
SendLocalizedMessage( 1060870, "", 0x23 ); // That item is blessed and does not need to be insured
SendLocalizedMessage( 1060869, "", 0x23 ); // You cannot insure that
}
else
{
if ( !item.PayedInsurance )
{
if ( Banker.Withdraw( from, 600 ) )
{
SendLocalizedMessage( 1060398, "600" ); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
item.PayedInsurance = true;
}
else
{
SendLocalizedMessage( 1061079, "", 0x23 ); // You lack the funds to purchase the insurance
return;
}
}
item.Insured = true;
SendLocalizedMessage( 1060873, "", 0x23 ); // You have insured the item
BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
SendLocalizedMessage( 1060868, "", 0x23 ); // Target the item you wish to toggle insurance status on <ESC> to cancel
}
}
private void AutoRenewInventoryInsurance()
{
if ( !CheckAlive() )
return;
SendLocalizedMessage( 1060881, "", 0x23 ); // You have selected to automatically reinsure all insured items upon death
AutoRenewInsurance = true;
}
private void CancelRenewInventoryInsurance()
{
if ( !CheckAlive() )
return;
SendLocalizedMessage( 1061075, "", 0x23 ); // You have cancelled automatically reinsuring all insured items upon death
AutoRenewInsurance = false;
}
// TODO: Champ titles, toggle
private void GetVendor()
{
BaseHouse house = BaseHouse.FindHouseAt( this );
if ( CheckAlive() && house != null && house.IsOwner( this ) && house.InternalizedVendors.Count > 0 )
{
CloseGump( typeof( ReclaimVendorGump ) );
SendGump( new ReclaimVendorGump( house ) );
}
}
private void LeaveHouse()
{
BaseHouse house = BaseHouse.FindHouseAt( this );
if ( house != null )
this.Location = house.BanLocation;
}
private delegate void ContextCallback();
private class CallbackEntry : ContextMenuEntry
{
private ContextCallback m_Callback;
public CallbackEntry( int number, ContextCallback callback ) : this( number, -1, callback )
{
}
public CallbackEntry( int number, int range, ContextCallback callback ) : base( number, range )
{
m_Callback = callback;
}
public override void OnClick()
{
if ( m_Callback != null )
m_Callback();
}
}
public override void OnDoubleClick( Mobile from )
{
if ( this == from && !Warmode )
{
IMount mount = Mount;
if ( mount != null && !DesignContext.Check( this ) )
return;
}
base.OnDoubleClick( from );
}
public override void DisplayPaperdollTo( Mobile to )
{
if ( DesignContext.Check( this ) )
base.DisplayPaperdollTo( to );
}
private static bool m_NoRecursion;
public override bool CheckEquip( Item item )
{
if ( !base.CheckEquip( item ) )
return false;
#region Factions
FactionItem factionItem = FactionItem.Find( item );
if ( factionItem != null )
{
Faction faction = Faction.Find( this );
if ( faction == null )
{
SendLocalizedMessage( 1010371 ); // You cannot equip a faction item!
return false;
}
else if ( faction != factionItem.Faction )
{
SendLocalizedMessage( 1010372 ); // You cannot equip an opposing faction's item!
return false;
}
else
{
int maxWearables = FactionItem.GetMaxWearables( this );
for ( int i = 0; i < Items.Count; ++i )
{
Item equiped = (Item)Items[i];
if ( item != equiped && FactionItem.Find( equiped ) != null )
{
if ( --maxWearables == 0 )
{
SendLocalizedMessage( 1010373 ); // You do not have enough rank to equip more faction items!
return false;
}
}
}
}
}
#endregion
if ( this.AccessLevel < AccessLevel.GameMaster && item.Layer != Layer.Mount && this.HasTrade )
{
BounceInfo bounce = item.GetBounce();
if ( bounce != null )
{
if ( bounce.m_Parent is Item )
{
Item parent = (Item) bounce.m_Parent;
if ( parent == this.Backpack || parent.IsChildOf( this.Backpack ) )
return true;
}
else if ( bounce.m_Parent == this )
{
return true;
}
}
SendLocalizedMessage( 1004042 ); // You can only equip what you are already carrying while you have a trade pending.
return false;
}
return true;
}
public override bool CheckTrade( Mobile to, Item item, SecureTradeContainer cont, bool message, bool checkItems, int plusItems, int plusWeight )
{
int msgNum = 0;
if ( cont == null )
{
if ( to.Holding != null )
msgNum = 1062727; // You cannot trade with someone who is dragging something.
else if ( this.HasTrade )
msgNum = 1062781; // You are already trading with someone else!
else if ( to.HasTrade )
msgNum = 1062779; // That person is already involved in a trade
}
if ( msgNum == 0 )
{
if ( cont != null )
{
plusItems += cont.TotalItems;
plusWeight += cont.TotalWeight;
}
if ( this.Backpack == null || !this.Backpack.CheckHold( this, item, false, checkItems, plusItems, plusWeight ) )
msgNum = 1004040; // You would not be able to hold this if the trade failed.
else if ( to.Backpack == null || !to.Backpack.CheckHold( to, item, false, checkItems, plusItems, plusWeight ) )
msgNum = 1004039; // The recipient of this trade would not be able to carry this.
else
msgNum = CheckContentForTrade( item );
}
if ( msgNum != 0 )
{
if ( message )
this.SendLocalizedMessage( msgNum );
return false;
}
return true;
}
private static int CheckContentForTrade( Item item )
{
if ( item is TrapableContainer && ((TrapableContainer)item).TrapType != TrapType.None )
return 1004044; // You may not trade trapped items.
if ( SkillHandlers.StolenItem.IsStolen( item ) )
return 1004043; // You may not trade recently stolen items.
if ( item is Container )
{
foreach ( Item subItem in item.Items )
{
int msg = CheckContentForTrade( subItem );
if ( msg != 0 )
return msg;
}
}
return 0;
}
public override bool CheckNonlocalDrop( Mobile from, Item item, Item target )
{
if ( !base.CheckNonlocalDrop( from, item, target ) )
return false;
if ( from.AccessLevel >= AccessLevel.GameMaster )
return true;
Container pack = this.Backpack;
if ( from == this && this.HasTrade && ( target == pack || target.IsChildOf( pack ) ) )
{
BounceInfo bounce = item.GetBounce();
if ( bounce != null && bounce.m_Parent is Item )
{
Item parent = (Item) bounce.m_Parent;
if ( parent == pack || parent.IsChildOf( pack ) )
return true;
}
SendLocalizedMessage( 1004041 ); // You can't do that while you have a trade pending.
return false;
}
return true;
}
protected override void OnLocationChange( Point3D oldLocation )
{
CheckLightLevels( false );
DesignContext context = m_DesignContext;
if ( context == null || m_NoRecursion )
return;
m_NoRecursion = true;
HouseFoundation foundation = context.Foundation;
int newX = this.X, newY = this.Y;
int newZ = foundation.Z + HouseFoundation.GetLevelZ( context.Level );
int startX = foundation.X + foundation.Components.Min.X + 1;
int startY = foundation.Y + foundation.Components.Min.Y + 1;
int endX = startX + foundation.Components.Width - 1;
int endY = startY + foundation.Components.Height - 2;
if ( newX >= startX && newY >= startY && newX < endX && newY < endY && Map == foundation.Map )
{
if ( Z != newZ )
Location = new Point3D( X, Y, newZ );
m_NoRecursion = false;
return;
}
Location = new Point3D( foundation.X, foundation.Y, newZ );
Map = foundation.Map;
m_NoRecursion = false;
}
public override bool OnMoveOver( Mobile m )
{
if ( m is BaseCreature && !((BaseCreature)m).Controled )
return false;
return base.OnMoveOver( m );
}
protected override void OnMapChange( Map oldMap )
{
if ( (Map != Faction.Facet && oldMap == Faction.Facet) || (Map == Faction.Facet && oldMap != Faction.Facet) )
InvalidateProperties();
DesignContext context = m_DesignContext;
if ( context == null || m_NoRecursion )
return;
m_NoRecursion = true;
HouseFoundation foundation = context.Foundation;
if ( Map != foundation.Map )
Map = foundation.Map;
m_NoRecursion = false;
}
public override void OnDamage( int amount, Mobile from, bool willKill )
{
int disruptThreshold;
if ( !Core.AOS )
disruptThreshold = 0;
else if ( from != null && from.Player )
disruptThreshold = 18;
else
disruptThreshold = 25;
if ( amount > disruptThreshold )
{
BandageContext c = BandageContext.GetContext( this );
if ( c != null )
c.Slip();
}
WeightOverloading.FatigueOnDamage( this, amount );
base.OnDamage( amount, from, willKill );
}
public static int ComputeSkillTotal( Mobile m )
{
int total = 0;
for ( int i = 0; i < m.Skills.Length; ++i )
total += m.Skills[i].BaseFixedPoint;
return ( total / 10 );
}
public override void Resurrect()
{
bool wasAlive = this.Alive;
base.Resurrect();
if ( this.Alive && !wasAlive )
{
Item deathRobe = new DeathRobe();
if ( !EquipItem( deathRobe ) )
deathRobe.Delete();
}
}
private Mobile m_InsuranceAward;
private int m_InsuranceCost;
private int m_InsuranceBonus;
public override bool OnBeforeDeath()
{
m_InsuranceCost = 0;
m_InsuranceAward = base.FindMostRecentDamager( false );
if ( m_InsuranceAward is BaseCreature )
{
Mobile master = ((BaseCreature)m_InsuranceAward).GetMaster();
if ( master != null )
m_InsuranceAward = master;
}
if ( m_InsuranceAward != null && (!m_InsuranceAward.Player || m_InsuranceAward == this) )
m_InsuranceAward = null;
if ( m_InsuranceAward is PlayerMobile )
((PlayerMobile)m_InsuranceAward).m_InsuranceBonus = 0;
Mobile kill = FindMostRecentDamager( false );
if ( kill is PlayerMobile )
{
PlayerMobile killer = (PlayerMobile)kill;
if ( PvpPointSystem.EnablePointSystem == true )
PvpPointSystem.GivePoints( this, killer );
if ( PvpPointSystem.EnableRankSystem == true )
PvpPointSystem.CheckTitle( this, killer );
}
return base.OnBeforeDeath();
}
private bool CheckInsuranceOnDeath( Item item )
{
if ( InsuranceEnabled && item.Insured )
{
if ( AutoRenewInsurance )
{
int cost = ( m_InsuranceAward == null ? 600 : 300 );
if ( Banker.Withdraw( this, cost ) )
{
m_InsuranceCost += cost;
item.PayedInsurance = true;
}
else
{
SendLocalizedMessage( 1061079, "", 0x23 ); // You lack the funds to purchase the insurance
item.PayedInsurance = false;
item.Insured = false;
}
}
else
{
item.PayedInsurance = false;
item.Insured = false;
}
if ( m_InsuranceAward != null )
{
if ( Banker.Deposit( m_InsuranceAward, 300 ) )
{
if ( m_InsuranceAward is PlayerMobile )
((PlayerMobile)m_InsuranceAward).m_InsuranceBonus += 300;
}
}
return true;
}
return false;
}
public override DeathMoveResult GetParentMoveResultFor( Item item )
{
if ( CheckInsuranceOnDeath( item ) )
return DeathMoveResult.MoveToBackpack;
DeathMoveResult res = base.GetParentMoveResultFor( item );
if ( res == DeathMoveResult.MoveToCorpse && item.Movable && this.Young )
res = DeathMoveResult.MoveToBackpack;
return res;
}
public override DeathMoveResult GetInventoryMoveResultFor( Item item )
{
if ( CheckInsuranceOnDeath( item ) )
return DeathMoveResult.MoveToBackpack;
DeathMoveResult res = base.GetInventoryMoveResultFor( item );
if ( res == DeathMoveResult.MoveToCorpse && item.Movable && this.Young )
res = DeathMoveResult.MoveToBackpack;
return res;
}
public override void OnDeath( Container c )
{
base.OnDeath( c );
HueMod = -1;
NameMod = null;
SavagePaintExpiration = TimeSpan.Zero;
SetHairMods( -1, -1 );
PolymorphSpell.StopTimer( this );
IncognitoSpell.StopTimer( this );
DisguiseGump.StopTimer( this );
EndAction( typeof( PolymorphSpell ) );
EndAction( typeof( IncognitoSpell ) );
MeerMage.StopEffect( this, false );
SkillHandlers.StolenItem.ReturnOnDeath( this, c );
[COLOR=red][B]if( kill is PlayerMobile );
killer.Deaths+1;
{
PlayerMobile killer = ( PlayerMobile )Kills;
killer.Kills+1;
}
}
}[/B][/COLOR]
if ( m_PermaFlags.Count > 0 )
{
m_PermaFlags.Clear();
if ( c is Corpse )
((Corpse)c).Criminal = true;
if ( SkillHandlers.Stealing.ClassicMode )
Criminal = true;
}
if ( this.Kills >= 5 && DateTime.Now >= m_NextJustAward )
{
Mobile m = FindMostRecentDamager( false );
if( m is BaseCreature )
m = ((BaseCreature)m).GetMaster();
if ( m != null && m.Player && m != this )
{
bool gainedPath = false;
int theirTotal = ComputeSkillTotal( m );
int ourTotal = ComputeSkillTotal( this );
int pointsToGain = 1 + ((theirTotal - ourTotal) / 50);
if ( pointsToGain < 1 )
pointsToGain = 1;
else if ( pointsToGain > 4 )
pointsToGain = 4;
if ( VirtueHelper.Award( m, VirtueName.Justice, pointsToGain, ref gainedPath ) )
{
if ( gainedPath )
m.SendLocalizedMessage( 1049367 ); // You have gained a path in Justice!
else
m.SendLocalizedMessage( 1049363 ); // You have gained in Justice.
m.FixedParticles( 0x375A, 9, 20, 5027, EffectLayer.Waist );
m.PlaySound( 0x1F7 );
m_NextJustAward = DateTime.Now + TimeSpan.FromMinutes( pointsToGain * 2 );
}
}
}
if ( m_InsuranceCost > 0 )
SendLocalizedMessage( 1060398, m_InsuranceCost.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
if ( m_InsuranceAward is PlayerMobile )
{
PlayerMobile pm = (PlayerMobile)m_InsuranceAward;
if ( pm.m_InsuranceBonus > 0 )
pm.SendLocalizedMessage( 1060397, pm.m_InsuranceBonus.ToString() )

ArteGordon- 04-26-2006
killer.Deaths+1;
killer.Kills+1;
these lines just take the value of Deaths and Kills and add one to them, but they dont assign that new incremented value back to Deaths and Kills. In other words, they dont actually change the value of anything.
You want to use something like
killer.Deaths += 1;
killer.Kills += 1;
which does the same thing as
killer.Deaths = killer.Deaths + 1;
killer.Kills = killer.Kills + 1;
(edit)
you also appear to have a number of problems this code

QUOTE
if( kill is PlayerMobile ); killer.Deaths+1; { PlayerMobile killer = ( PlayerMobile )Kills; killer.Kills+1;
}
}
}

PlayerMobile killer = ( PlayerMobile )Kills;
You cant cast Kills to the type PlayerMobile. Kills is just an integer.
if( kill is PlayerMobile )
You cant refer to the 'kill' variable since it is not defined anywhere.
You also have too many closing brackets '}', and you have a semicolon at the end of your if statement which shouldnt be there
if( kill is PlayerMobile );
and this line
killer.Deaths+1;
is outside of your {} code block that follows the if statement.
That code just isnt going to work there. It appears that you have a significantly modified PlayerMobile.cs OnDeath method so the installation instructions for whatever system you are trying to install are probably not going to match your PlayerMobile.cs
You might try the following code instead

CODE
Mobile killer = this.FindMostRecentDamager( true ); if ( killer is PlayerMobile) { Deaths++; ((PlayerMobile )killer).Kills++;
}

kobra- 04-26-2006
OK - i deleted all this

CODE
if( kill is PlayerMobile ); killer.Deaths+1; { PlayerMobile killer = ( PlayerMobile )Kills; killer.Kills+1;
}
}
}

and replaced with this

CODE
Mobile killer = this.FindMostRecentDamager( true ); if ( killer is PlayerMobile) { Deaths++; ((PlayerMobile )killer).Kills++;
}

here is my updated playermobile

CODE
using System; using System.Collections; using Server; using Server.Misc; using Server.Items;
using Server.Gumps;
using Server.Multis;
using Server.Engines.Help;
using Server.ContextMenus;
using Server.Network;
using Server.Spells;
using Server.Spells.Fifth;
using Server.Spells.Seventh;
using Server.Targeting;
using Server.Engines.Quests;
using Server.Factions;
using Server.Regions;
using Server.Accounting;
namespace Server.Mobiles
{
[Flags]
public enum PlayerFlag // First 16 bits are reserved for default-distro use, start custom flags at 0x00010000
{
None = 0x00000000,
Glassblowing = 0x00000001,
Masonry = 0x00000002,
SandMining = 0x00000004,
StoneMining = 0x00000008,
ToggleMiningStone = 0x00000010,
KarmaLocked = 0x00000020,
AutoRenewInsurance = 0x00000040,
UseOwnFilter = 0x00000080,
PublicMyRunUO = 0x00000100,
PagingSquelched = 0x00000200,
Young = 0x00000400
}
public enum NpcGuild
{
None,
MagesGuild,
WarriorsGuild,
ThievesGuild,
RangersGuild,
HealersGuild,
MinersGuild,
MerchantsGuild,
TinkersGuild,
TailorsGuild,
FishermensGuild,
BardsGuild,
BlacksmithsGuild
}
public enum SolenFriendship
{
None,
Red,
Black
}
public class PlayerMobile : Mobile
{
private class CountAndTimeStamp
{
private int m_Count;
private DateTime m_Stamp;
public CountAndTimeStamp()
{
}
public DateTime TimeStamp { get{ return m_Stamp; } }
public int Count
{
get { return m_Count; }
set { m_Count = value; m_Stamp = DateTime.Now; }
}
}
private DesignContext m_DesignContext;
private NpcGuild m_NpcGuild;
private DateTime m_NpcGuildJoinTime;
private TimeSpan m_NpcGuildGameTime;
private PlayerFlag m_Flags;
private int m_StepsTaken;
private int m_Profession;
private int m_Deaths = 0;
private int m_Kills = 0;
[CommandProperty( AccessLevel.GameMaster )]
public int Deaths
{
get{ return m_Deaths; }
set{ m_Deaths = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public int Kills
{
get{ return m_Kills; }
set{ m_Kills = value; }
}
//Start Pvp Point System
private int m_TotalPoints;
private int m_TotalWins;
private int m_TotalLoses;
private int m_TotalResKills;
private int m_TotalResKilled;
private Mobile m_LastPwner;
private Mobile m_LastPwned;
private DateTime m_ResKillTime;
private int m_TotalPointsLost;
private int m_TotalPointsSpent;
private string m_PvpRank = "Newbie";
[CommandProperty( AccessLevel.GameMaster )]
public string PvpRank
{
get{ return m_PvpRank; }
set{ m_PvpRank = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
public int TotalPoints
{
get{ return m_TotalPoints; }
set{ m_TotalPoints = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public int TotalWins
{
get{ return m_TotalWins; }
set{ m_TotalWins = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public int TotalLoses
{
get{ return m_TotalLoses; }
set{ m_TotalLoses = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public int TotalResKills
{
get{ return m_TotalResKills; }
set{ m_TotalResKills = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public int TotalResKilled
{
get{ return m_TotalResKilled; }
set{ m_TotalResKilled = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public Mobile LastPwner
{
get{ return m_LastPwner; }
set{ m_LastPwner = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public Mobile LastPwned
{
get{ return m_LastPwned; }
set{ m_LastPwned = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public TimeSpan ResKillTime
{
get
{
TimeSpan ts = m_ResKillTime - DateTime.Now;
if ( ts < TimeSpan.Zero )
ts = TimeSpan.Zero;
return ts;
}
set
{
try{ m_ResKillTime = DateTime.Now + value; }
catch{}
}
}
[CommandProperty( AccessLevel.GameMaster )]
public int TotalPointsLost
{
get{ return m_TotalPointsLost; }
set{ m_TotalPointsLost = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public int TotalPointsSpent
{
get{ return m_TotalPointsSpent; }
set{ m_TotalPointsSpent = value; }
}
//End Pvp Point System
[CommandProperty( AccessLevel.GameMaster )]
public int Profession
{
get{ return m_Profession; }
set{ m_Profession = value; }
}
public int StepsTaken
{
get{ return m_StepsTaken; }
set{ m_StepsTaken = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public NpcGuild NpcGuild
{
get{ return m_NpcGuild; }
set{ m_NpcGuild = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public DateTime NpcGuildJoinTime
{
get{ return m_NpcGuildJoinTime; }
set{ m_NpcGuildJoinTime = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public TimeSpan NpcGuildGameTime
{
get{ return m_NpcGuildGameTime; }
set{ m_NpcGuildGameTime = value; }
}
public PlayerFlag Flags
{
get{ return m_Flags; }
set{ m_Flags = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool PagingSquelched
{
get{ return GetFlag( PlayerFlag.PagingSquelched ); }
set{ SetFlag( PlayerFlag.PagingSquelched, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool Glassblowing
{
get{ return GetFlag( PlayerFlag.Glassblowing ); }
set{ SetFlag( PlayerFlag.Glassblowing, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool Masonry
{
get{ return GetFlag( PlayerFlag.Masonry ); }
set{ SetFlag( PlayerFlag.Masonry, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool SandMining
{
get{ return GetFlag( PlayerFlag.SandMining ); }
set{ SetFlag( PlayerFlag.SandMining, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool StoneMining
{
get{ return GetFlag( PlayerFlag.StoneMining ); }
set{ SetFlag( PlayerFlag.StoneMining, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool ToggleMiningStone
{
get{ return GetFlag( PlayerFlag.ToggleMiningStone ); }
set{ SetFlag( PlayerFlag.ToggleMiningStone, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool KarmaLocked
{
get{ return GetFlag( PlayerFlag.KarmaLocked ); }
set{ SetFlag( PlayerFlag.KarmaLocked, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool AutoRenewInsurance
{
get{ return GetFlag( PlayerFlag.AutoRenewInsurance ); }
set{ SetFlag( PlayerFlag.AutoRenewInsurance, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool UseOwnFilter
{
get{ return GetFlag( PlayerFlag.UseOwnFilter ); }
set{ SetFlag( PlayerFlag.UseOwnFilter, value ); }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool PublicMyRunUO
{
get{ return GetFlag( PlayerFlag.PublicMyRunUO ); }
set{ SetFlag( PlayerFlag.PublicMyRunUO, value ); InvalidateMyRunUO(); }
}
public static Direction GetDirection4( Point3D from, Point3D to )
{
int dx = from.X - to.X;
int dy = from.Y - to.Y;
int rx = dx - dy;
int ry = dx + dy;
Direction ret;
if ( rx >= 0 && ry >= 0 )
ret = Direction.West;
else if ( rx >= 0 && ry < 0 )
ret = Direction.South;
else if ( rx < 0 && ry < 0 )
ret = Direction.East;
else
ret = Direction.North;
return ret;
}
public override bool OnDroppedItemToWorld( Item item, Point3D location )
{
if ( !base.OnDroppedItemToWorld( item, location ) )
return false;
BounceInfo bi = item.GetBounce();
if ( bi != null )
{
Type type = item.GetType();
if ( type.IsDefined( typeof( FurnitureAttribute ), true ) || type.IsDefined( typeof( DynamicFlipingAttribute ), true ) )
{
object[] objs = type.GetCustomAttributes( typeof( FlipableAttribute ), true );
if ( objs != null && objs.Length > 0 )
{
FlipableAttribute fp = objs[0] as FlipableAttribute;
if ( fp != null )
{
int[] itemIDs = fp.ItemIDs;
Point3D oldWorldLoc = bi.m_WorldLoc;
Point3D newWorldLoc = location;
if ( oldWorldLoc.X != newWorldLoc.X || oldWorldLoc.Y != newWorldLoc.Y )
{
Direction dir = GetDirection4( oldWorldLoc, newWorldLoc );
if ( itemIDs.Length == 2 )
{
switch ( dir )
{
case Direction.North:
case Direction.South: item.ItemID = itemIDs[0]; break;
case Direction.East:
case Direction.West: item.ItemID = itemIDs[1]; break;
}
}
else if ( itemIDs.Length == 4 )
{
switch ( dir )
{
case Direction.South: item.ItemID = itemIDs[0]; break;
case Direction.East: item.ItemID = itemIDs[1]; break;
case Direction.North: item.ItemID = itemIDs[2]; break;
case Direction.West: item.ItemID = itemIDs[3]; break;
}
}
}
}
}
}
}
return true;
}
public bool GetFlag( PlayerFlag flag )
{
return ( (m_Flags & flag) != 0 );
}
public void SetFlag( PlayerFlag flag, bool value )
{
if ( value )
m_Flags |= flag;
else
m_Flags &= ~flag;
}
public DesignContext DesignContext
{
get{ return m_DesignContext; }
set{ m_DesignContext = value; }
}
public static void Initialize()
{
if ( FastwalkPrevention )
{
PacketHandler ph = PacketHandlers.GetHandler( 0x02 );
ph.ThrottleCallback = new ThrottlePacketCallback( MovementThrottle_Callback );
}
EventSink.Login += new LoginEventHandler( OnLogin );
EventSink.Logout += new LogoutEventHandler( OnLogout );
EventSink.Connected += new ConnectedEventHandler( EventSink_Connected );
EventSink.Disconnected += new DisconnectedEventHandler( EventSink_Disconnected );
}
public override void OnSkillInvalidated( Skill skill )
{
if ( Core.AOS && skill.SkillName == SkillName.MagicResist )
UpdateResistances();
}
public override int GetMaxResistance( ResistanceType type )
{
int max = base.GetMaxResistance( type );
if ( type != ResistanceType.Physical && 60 < max && Spells.Fourth.CurseSpell.UnderEffect( this ) )
max = 60;
return max;
}
private int m_LastGlobalLight = -1, m_LastPersonalLight = -1;
public override void OnNetStateChanged()
{
m_LastGlobalLight = -1;
m_LastPersonalLight = -1;
}
public override void ComputeBaseLightLevels( out int global, out int personal )
{
global = LightCycle.ComputeLevelFor( this );
if ( this.LightLevel < 21 && AosAttributes.GetValue( this, AosAttribute.NightSight ) > 0 )
personal = 21;
else
personal = this.LightLevel;
}
public override void CheckLightLevels( bool forceResend )
{
NetState ns = this.NetState;
if ( ns == null )
return;
int global, personal;
ComputeLightLevels( out global, out personal );
if ( !forceResend )
forceResend = ( global != m_LastGlobalLight || personal != m_LastPersonalLight );
if ( !forceResend )
return;
m_LastGlobalLight = global;
m_LastPersonalLight = personal;
ns.Send( GlobalLightLevel.Instantiate( global ) );
ns.Send( new PersonalLightLevel( this, personal ) );
}
public override int GetMinResistance( ResistanceType type )
{
int magicResist = (int)(Skills[SkillName.MagicResist].Value * 10);
int min = int.MinValue;
if ( magicResist >= 1000 )
min = 40 + ((magicResist - 1000) / 50);
else if ( magicResist >= 400 )
min = (magicResist - 400) / 15;
if ( min > MaxPlayerResistance )
min = MaxPlayerResistance;
int baseMin = base.GetMinResistance( type );
if ( min < baseMin )
min = baseMin;
return min;
}
private static void OnLogin( LoginEventArgs e )
{
Mobile from = e.Mobile;
SacrificeVirtue.CheckAtrophy( from );
JusticeVirtue.CheckAtrophy( from );
CompassionVirtue.CheckAtrophy( from );
if ( AccountHandler.LockdownLevel > AccessLevel.Player )
{
string notice;
Accounting.Account acct = from.Account as Accounting.Account;
if ( acct == null || !acct.HasAccess( from.NetState ) )
{
if ( from.AccessLevel == AccessLevel.Player )
notice = "The server is currently under lockdown. No players are allowed to log in at this time.";
else
notice = "The server is currently under lockdown. You do not have sufficient access level to connect.";
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), new TimerStateCallback( Disconnect ), from );
}
else if ( from.AccessLevel == AccessLevel.Administrator )
{
notice = "The server is currently under lockdown. As you are an administrator, you may change this from the [Admin gump.";
}
else
{
notice = "The server is currently under lockdown. You have sufficient access level to connect.";
}
from.SendGump( new NoticeGump( 1060637, 30720, notice, 0xFFC000, 300, 140, null, null ) );
}
}
private bool m_NoDeltaRecursion;
public void ValidateEquipment()
{
if ( m_NoDeltaRecursion || Map == null || Map == Map.Internal )
return;
if ( this.Items == null )
return;
m_NoDeltaRecursion = true;
Timer.DelayCall( TimeSpan.Zero, new TimerCallback( ValidateEquipment_Sandbox ) );
}
private void ValidateEquipment_Sandbox()
{
try
{
if ( Map == null || Map == Map.Internal )
return;
ArrayList items = this.Items;
if ( items == null )
return;
bool moved = false;
int str = this.Str;
int dex = this.Dex;
int intel = this.Int;
#region Factions
int factionItemCount = 0;
#endregion
Mobile from = this;
for ( int i = items.Count - 1; i >= 0; --i )
{
if ( i >= items.Count )
continue;
Item item = (Item)items[i];
if ( item is BaseWeapon )
{
BaseWeapon weapon = (BaseWeapon)item;
bool drop = false;
if ( dex < weapon.DexRequirement )
drop = true;
else if ( str < AOS.Scale( weapon.StrRequirement, 100 - weapon.GetLowerStatReq() ) )
drop = true;
else if ( intel < weapon.IntRequirement )
drop = true;
if ( drop )
{
string name = weapon.Name;
if ( name == null )
name = String.Format( "#{0}", weapon.LabelNumber );
from.SendLocalizedMessage( 1062001, name ); // You can no longer wield your ~1_WEAPON~
from.AddToBackpack( weapon );
moved = true;
}
}
else if ( item is BaseArmor )
{
BaseArmor armor = (BaseArmor)item;
bool drop = false;
if ( !armor.AllowMaleWearer && from.Body.IsMale && from.AccessLevel < AccessLevel.GameMaster )
{
drop = true;
}
else if ( !armor.AllowFemaleWearer && from.Body.IsFemale && from.AccessLevel < AccessLevel.GameMaster )
{
drop = true;
}
else
{
int strBonus = armor.ComputeStatBonus( StatType.Str ), strReq = armor.ComputeStatReq( StatType.Str );
int dexBonus = armor.ComputeStatBonus( StatType.Dex ), dexReq = armor.ComputeStatReq( StatType.Dex );
int intBonus = armor.ComputeStatBonus( StatType.Int ), intReq = armor.ComputeStatReq( StatType.Int );
if ( dex < dexReq || (dex + dexBonus) < 1 )
drop = true;
else if ( str < strReq || (str + strBonus) < 1 )
drop = true;
else if ( intel < intReq || (intel + intBonus) < 1 )
drop = true;
}
if ( drop )
{
string name = armor.Name;
if ( name == null )
name = String.Format( "#{0}", armor.LabelNumber );
if ( armor is BaseShield )
from.SendLocalizedMessage( 1062003, name ); // You can no longer equip your ~1_SHIELD~
else
from.SendLocalizedMessage( 1062002, name ); // You can no longer wear your ~1_ARMOR~
from.AddToBackpack( armor );
moved = true;
}
}
FactionItem factionItem = FactionItem.Find( item );
if ( factionItem != null )
{
bool drop = false;
Faction ourFaction = Faction.Find( this );
if ( ourFaction == null || ourFaction != factionItem.Faction )
drop = true;
else if ( ++factionItemCount > FactionItem.GetMaxWearables( this ) )
drop = true;
if ( drop )
{
from.AddToBackpack( item );
moved = true;
}
}
}
if ( moved )
from.SendLocalizedMessage( 500647 ); // Some equipment has been moved to your backpack.
}
catch ( Exception e )
{
Console.WriteLine( e );
}
finally
{
m_NoDeltaRecursion = false;
}
}
public override void Delta( MobileDelta flag )
{
base.Delta( flag );
if ( (flag & MobileDelta.Stat) != 0 )
ValidateEquipment();
if ( (flag & (MobileDelta.Name | MobileDelta.Hue)) != 0 )
InvalidateMyRunUO();
}
private static void Disconnect( object state )
{
NetState ns = ((Mobile)state).NetState;
if ( ns != null )
ns.Dispose();
}
private static void OnLogout( LogoutEventArgs e )
{
}
private static void EventSink_Connected( ConnectedEventArgs e )
{
PlayerMobile pm = e.Mobile as PlayerMobile;
if ( pm != null )
{
pm.m_SessionStart = DateTime.Now;
if ( pm.m_Quest != null )
pm.m_Quest.StartTimer();
pm.BedrollLogout = false;
}
}
private static void EventSink_Disconnected( DisconnectedEventArgs e )
{
Mobile from = e.Mobile;
DesignContext context = DesignContext.Find( from );
if ( context != null )
{
/* Client disconnected
* - Remove design context
* - Eject all from house
* - Restore relocated entities
*/
// Remove design context
DesignContext.Remove( from );
// Eject all from house
from.RevealingAction();
foreach ( Item item in context.Foundation.GetItems() )
item.Location = context.Foundation.BanLocation;
foreach ( Mobile mobile in context.Foundation.GetMobiles() )
mobile.Location = context.Foundation.BanLocation;
// Restore relocated entities
context.Foundation.RestoreRelocatedEntities();
}
PlayerMobile pm = e.Mobile as PlayerMobile;
if ( pm != null )
{
pm.m_GameTime += (DateTime.Now - pm.m_SessionStart);
if ( pm.m_Quest != null )
pm.m_Quest.StopTimer();
pm.m_SpeechLog = null;
}
}
public override void RevealingAction()
{
if ( m_DesignContext != null )
return;
Spells.Sixth.InvisibilitySpell.RemoveTimer( this );
base.RevealingAction();
}
public override void OnSubItemAdded( Item item )
{
if ( AccessLevel < AccessLevel.GameMaster && item.IsChildOf( this.Backpack ) )
{
int maxWeight = WeightOverloading.GetMaxWeight( this );
int curWeight = Mobile.BodyWeight + this.TotalWeight;
if ( curWeight > maxWeight )
this.SendLocalizedMessage( 1019035, true, String.Format( " : {0} / {1}", curWeight, maxWeight ) );
}
}
public override bool CanBeHarmful( Mobile target, bool message, bool ignoreOurBlessedness )
{
if ( m_DesignContext != null || (target is PlayerMobile && ((PlayerMobile)target).m_DesignContext != null) )
return false;
if ( (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier )
{
if ( message )
{
if ( target.Title == null )
SendMessage( "{0} the vendor cannot be harmed.", target.Name );
else
SendMessage( "{0} {1} cannot be harmed.", target.Name, target.Title );
}
return false;
}
return base.CanBeHarmful( target, message, ignoreOurBlessedness );
}
public override bool CanBeBeneficial( Mobile target, bool message, bool allowDead )
{
if ( m_DesignContext != null || (target is PlayerMobile && ((PlayerMobile)target).m_DesignContext != null) )
return false;
return base.CanBeBeneficial( target, message, allowDead );
}
public override bool CheckContextMenuDisplay( IEntity target )
{
return ( m_DesignContext == null );
}
public override void OnItemAdded( Item item )
{
base.OnItemAdded( item );
if ( item is BaseArmor || item is BaseWeapon )
{
Hits=Hits; Stam=Stam; Mana=Mana;
}
if ( this.NetState != null )
CheckLightLevels( false );
InvalidateMyRunUO();
}
public override void OnItemRemoved( Item item )
{
base.OnItemRemoved( item );
if ( item is BaseArmor || item is BaseWeapon )
{
Hits=Hits; Stam=Stam; Mana=Mana;
}
if ( this.NetState != null )
CheckLightLevels( false );
InvalidateMyRunUO();
}
public override double ArmorRating
{
get
{
BaseArmor ar;
double rating = 0.0;
ar = NeckArmor as BaseArmor;
if ( ar != null )
rating += ar.ArmorRatingScaled;
ar = HandArmor as BaseArmor;
if ( ar != null )
rating += ar.ArmorRatingScaled;
ar = HeadArmor as BaseArmor;
if ( ar != null )
rating += ar.ArmorRatingScaled;
ar = ArmsArmor as BaseArmor;
if ( ar != null )
rating += ar.ArmorRatingScaled;
ar = LegsArmor as BaseArmor;
if ( ar != null )
rating += ar.ArmorRatingScaled;
ar = ChestArmor as BaseArmor;
if ( ar != null )
rating += ar.ArmorRatingScaled;
ar = ShieldArmor as BaseArmor;
if ( ar != null )
rating += ar.ArmorRatingScaled;
return VirtualArmor + VirtualArmorMod + rating;
}
}
public override int HitsMax
{
get
{
int strBase;
int strOffs = GetStatOffset( StatType.Str );
if ( Core.AOS )
{
strBase = this.Str;
strOffs += AosAttributes.GetValue( this, AosAttribute.BonusHits );
}
else
{
strBase = this.RawStr;
}
return (strBase / 2) + 50 + strOffs;
}
}
public override int StamMax
{
get{ return base.StamMax + AosAttributes.GetValue( this, AosAttribute.BonusStam ); }
}
public override int ManaMax
{
get{ return base.ManaMax + AosAttributes.GetValue( this, AosAttribute.BonusMana ); }
}
public override bool Move( Direction d )
{
NetState ns = this.NetState;
if ( ns != null )
{
GumpCollection gumps = ns.Gumps;
for ( int i = 0; i < gumps.Count; ++i )
{
if ( gumps[i] is ResurrectGump )
{
if ( Alive )
{
CloseGump( typeof( ResurrectGump ) );
}
else
{
SendLocalizedMessage( 500111 ); // You are frozen and cannot move.
return false;
}
}
}
}
TimeSpan speed = ComputeMovementSpeed( d );
if ( !base.Move( d ) )
return false;
m_NextMovementTime += speed;
return true;
}
public override bool CheckMovement( Direction d, out int newZ )
{
DesignContext context = m_DesignContext;
if ( context == null )
return base.CheckMovement( d, out newZ );
HouseFoundation foundation = context.Foundation;
newZ = foundation.Z + HouseFoundation.GetLevelZ( context.Level );
int newX = this.X, newY = this.Y;
Movement.Movement.Offset( d, ref newX, ref newY );
int startX = foundation.X + foundation.Components.Min.X + 1;
int startY = foundation.Y + foundation.Components.Min.Y + 1;
int endX = startX + foundation.Components.Width - 1;
int endY = startY + foundation.Components.Height - 2;
return ( newX >= startX && newY >= startY && newX < endX && newY < endY && Map == foundation.Map );
}
public override bool AllowItemUse( Item item )
{
return DesignContext.Check( this );
}
public override bool AllowSkillUse( SkillName skill )
{
return DesignContext.Check( this );
}
private bool m_LastProtectedMessage;
private int m_NextProtectionCheck = 10;
public virtual void RecheckTownProtection()
{
m_NextProtectionCheck = 10;
Regions.GuardedRegion reg = this.Region as Regions.GuardedRegion;
bool isProtected = ( reg != null && !reg.IsDisabled() );
if ( isProtected != m_LastProtectedMessage )
{
if ( isProtected )
SendLocalizedMessage( 500112 ); // You are now under the protection of the town guards.
else
SendLocalizedMessage( 500113 ); // You have left the protection of the town guards.
m_LastProtectedMessage = isProtected;
}
}
public override void MoveToWorld( Point3D loc, Map map )
{
base.MoveToWorld( loc, map );
RecheckTownProtection();
}
public override void SetLocation( Point3D loc, bool isTeleport )
{
if ( !isTeleport && AccessLevel == AccessLevel.Player )
{
// moving, not teleporting
int zDrop = ( this.Location.Z - loc.Z );
if ( zDrop > 20 ) // we fell more than one story
Hits -= ((zDrop / 20) * 10) - 5; // deal some damage; does not kill, disrupt, etc
}
base.SetLocation( loc, isTeleport );
if ( isTeleport || --m_NextProtectionCheck == 0 )
RecheckTownProtection();
}
public override void GetContextMenuEntries( Mobile from, ArrayList list )
{
base.GetContextMenuEntries( from, list );
if ( from == this )
{
if ( m_Quest != null )
m_Quest.GetContextMenuEntries( list );
if ( Alive && InsuranceEnabled )
{
list.Add( new CallbackEntry( 6201, new ContextCallback( ToggleItemInsurance ) ) );
if ( AutoRenewInsurance )
list.Add( new CallbackEntry( 6202, new ContextCallback( CancelRenewInventoryInsurance ) ) );
else
list.Add( new CallbackEntry( 6200, new ContextCallback( AutoRenewInventoryInsurance ) ) );
}
// TODO: Toggle champ titles
BaseHouse house = BaseHouse.FindHouseAt( this );
if ( house != null )
{
if ( Alive && house.InternalizedVendors.Count > 0 && house.IsOwner( this ) )
list.Add( new CallbackEntry( 6204, new ContextCallback( GetVendor ) ) );
if ( house.IsAosRules )
list.Add( new CallbackEntry( 6207, new ContextCallback( LeaveHouse ) ) );
}
if ( m_JusticeProtectors.Count > 0 )
list.Add( new CallbackEntry( 6157, new ContextCallback( CancelProtection ) ) );
}
}
private void CancelProtection()
{
for ( int i = 0; i < m_JusticeProtectors.Count; ++i )
{
Mobile prot = (Mobile)m_JusticeProtectors[i];
string args = String.Format( "{0}\t{1}", this.Name, prot.Name );
prot.SendLocalizedMessage( 1049371, args ); // The protective relationship between ~1_PLAYER1~ and ~2_PLAYER2~ has been ended.
this.SendLocalizedMessage( 1049371, args ); // The protective relationship between ~1_PLAYER1~ and ~2_PLAYER2~ has been ended.
}
m_JusticeProtectors.Clear();
}
private void ToggleItemInsurance()
{
if ( !CheckAlive() )
return;
BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
SendLocalizedMessage( 1060868 ); // Target the item you wish to toggle insurance status on <ESC> to cancel
}
private bool CanInsure( Item item )
{
if ( item is Container || item is BagOfSending )
return false;
if ( item is Spellbook || item is Runebook || item is PotionKeg || item is Sigil )
return false;
if ( item.Stackable )
return false;
if ( item.LootType == LootType.Cursed )
return false;
if ( item.ItemID == 0x204E ) // death shroud
return false;
return true;
}
private void ToggleItemInsurance_Callback( Mobile from, object obj )
{
if ( !CheckAlive() )
return;
Item item = obj as Item;
if ( item == null || !item.IsChildOf( this ) )
{
BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
SendLocalizedMessage( 1060871, "", 0x23 ); // You can only insure items that you have equipped or that are in your backpack
}
else if ( item.Insured )
{
item.Insured = false;
SendLocalizedMessage( 1060874, "", 0x35 ); // You cancel the insurance on the item
BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
SendLocalizedMessage( 1060868, "", 0x23 ); // Target the item you wish to toggle insurance status on <ESC> to cancel
}
else if ( !CanInsure( item ) )
{
BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
SendLocalizedMessage( 1060869, "", 0x23 ); // You cannot insure that
}
else if ( item.LootType == LootType.Blessed || item.LootType == LootType.Newbied || item.BlessedFor == from )
{
BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
SendLocalizedMessage( 1060870, "", 0x23 ); // That item is blessed and does not need to be insured
SendLocalizedMessage( 1060869, "", 0x23 ); // You cannot insure that
}
else
{
if ( !item.PayedInsurance )
{
if ( Banker.Withdraw( from, 600 ) )
{
SendLocalizedMessage( 1060398, "600" ); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
item.PayedInsurance = true;
}
else
{
SendLocalizedMessage( 1061079, "", 0x23 ); // You lack the funds to purchase the insurance
return;
}
}
item.Insured = true;
SendLocalizedMessage( 1060873, "", 0x23 ); // You have insured the item
BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ToggleItemInsurance_Callback ) );
SendLocalizedMessage( 1060868, "", 0x23 ); // Target the item you wish to toggle insurance status on <ESC> to cancel
}
}
private void AutoRenewInventoryInsurance()
{
if ( !CheckAlive() )
return;
SendLocalizedMessage( 1060881, "", 0x23 ); // You have selected to automatically reinsure all insured items upon death
AutoRenewInsurance = true;
}
private void CancelRenewInventoryInsurance()
{
if ( !CheckAlive() )
return;
SendLocalizedMessage( 1061075, "", 0x23 ); // You have cancelled automatically reinsuring all insured items upon death
AutoRenewInsurance = false;
}
// TODO: Champ titles, toggle
private void GetVendor()
{
BaseHouse house = BaseHouse.FindHouseAt( this );
if ( CheckAlive() && house != null && house.IsOwner( this ) && house.InternalizedVendors.Count > 0 )
{
CloseGump( typeof( ReclaimVendorGump ) );
SendGump( new ReclaimVendorGump( house ) );
}
}
private void LeaveHouse()
{
BaseHouse house = BaseHouse.FindHouseAt( this );
if ( house != null )
this.Location = house.BanLocation;
}
private delegate void ContextCallback();
private class CallbackEntry : ContextMenuEntry
{
private ContextCallback m_Callback;
public CallbackEntry( int number, ContextCallback callback ) : this( number, -1, callback )
{
}
public CallbackEntry( int number, int range, ContextCallback callback ) : base( number, range )
{
m_Callback = callback;
}
public override void OnClick()
{
if ( m_Callback != null )
m_Callback();
}
}
public override void OnDoubleClick( Mobile from )
{
if ( this == from && !Warmode )
{
IMount mount = Mount;
if ( mount != null && !DesignContext.Check( this ) )
return;
}
base.OnDoubleClick( from );
}
public override void DisplayPaperdollTo( Mobile to )
{
if ( DesignContext.Check( this ) )
base.DisplayPaperdollTo( to );
}
private static bool m_NoRecursion;
public override bool CheckEquip( Item item )
{
if ( !base.CheckEquip( item ) )
return false;
#region Factions
FactionItem factionItem = FactionItem.Find( item );
if ( factionItem != null )
{
Faction faction = Faction.Find( this );
if ( faction == null )
{
SendLocalizedMessage( 1010371 ); // You cannot equip a faction item!
return false;
}
else if ( faction != factionItem.Faction )
{
SendLocalizedMessage( 1010372 ); // You cannot equip an opposing faction's item!
return false;
}
else
{
int maxWearables = FactionItem.GetMaxWearables( this );
for ( int i = 0; i < Items.Count; ++i )
{
Item equiped = (Item)Items[i];
if ( item != equiped && FactionItem.Find( equiped ) != null )
{
if ( --maxWearables == 0 )
{
SendLocalizedMessage( 1010373 ); // You do not have enough rank to equip more faction items!
return false;
}
}
}
}
}
#endregion
if ( this.AccessLevel < AccessLevel.GameMaster && item.Layer != Layer.Mount && this.HasTrade )
{
BounceInfo bounce = item.GetBounce();
if ( bounce != null )
{
if ( bounce.m_Parent is Item )
{
Item parent = (Item) bounce.m_Parent;
if ( parent == this.Backpack || parent.IsChildOf( this.Backpack ) )
return true;
}
else if ( bounce.m_Parent == this )
{
return true;
}
}
SendLocalizedMessage( 1004042 ); // You can only equip what you are already carrying while you have a trade pending.
return false;
}
return true;
}
public override bool CheckTrade( Mobile to, Item item, SecureTradeContainer cont, bool message, bool checkItems, int plusItems, int plusWeight )
{
int msgNum = 0;
if ( cont == null )
{
if ( to.Holding != null )
msgNum = 1062727; // You cannot trade with someone who is dragging something.
else if ( this.HasTrade )
msgNum = 1062781; // You are already trading with someone else!
else if ( to.HasTrade )
msgNum = 1062779; // That person is already involved in a trade
}
if ( msgNum == 0 )
{
if ( cont != null )
{
plusItems += cont.TotalItems;
plusWeight += cont.TotalWeight;
}
if ( this.Backpack == null || !this.Backpack.CheckHold( this, item, false, checkItems, plusItems, plusWeight ) )
msgNum = 1004040; // You would not be able to hold this if the trade failed.
else if ( to.Backpack == null || !to.Backpack.CheckHold( to, item, false, checkItems, plusItems, plusWeight ) )
msgNum = 1004039; // The recipient of this trade would not be able to carry this.
else
msgNum = CheckContentForTrade( item );
}
if ( msgNum != 0 )
{
if ( message )
this.SendLocalizedMessage( msgNum );
return false;
}
return true;
}
private static int CheckContentForTrade( Item item )
{
if ( item is TrapableContainer && ((TrapableContainer)item).TrapType != TrapType.None )
return 1004044; // You may not trade trapped items.
if ( SkillHandlers.StolenItem.IsStolen( item ) )
return 1004043; // You may not trade recently stolen items.
if ( item is Container )
{
foreach ( Item subItem in item.Items )
{
int msg = CheckContentForTrade( subItem );
if ( msg != 0 )
return msg;
}
}
return 0;
}
public override bool CheckNonlocalDrop( Mobile from, Item item, Item target )
{
if ( !base.CheckNonlocalDrop( from, item, target ) )
return false;
if ( from.AccessLevel >= AccessLevel.GameMaster )
return true;
Container pack = this.Backpack;
if ( from == this && this.HasTrade && ( target == pack || target.IsChildOf( pack ) ) )
{
BounceInfo bounce = item.GetBounce();
if ( bounce != null && bounce.m_Parent is Item )
{
Item parent = (Item) bounce.m_Parent;
if ( parent == pack || parent.IsChildOf( pack ) )
return true;
}
SendLocalizedMessage( 1004041 ); // You can't do that while you have a trade pending.
return false;
}
return true;
}
protected override void OnLocationChange( Point3D oldLocation )
{
CheckLightLevels( false );
DesignContext context = m_DesignContext;
if ( context == null || m_NoRecursion )
return;
m_NoRecursion = true;
HouseFoundation foundation = context.Foundation;
int newX = this.X, newY = this.Y;
int newZ = foundation.Z + HouseFoundation.GetLevelZ( context.Level );
int startX = foundation.X + foundation.Components.Min.X + 1;
int startY = foundation.Y + foundation.Components.Min.Y + 1;
int endX = startX + foundation.Components.Width - 1;
int endY = startY + foundation.Components.Height - 2;
if ( newX >= startX && newY >= startY && newX < endX && newY < endY && Map == foundation.Map )
{
if ( Z != newZ )
Location = new Point3D( X, Y, newZ );
m_NoRecursion = false;
return;
}
Location = new Point3D( foundation.X, foundation.Y, newZ );
Map = foundation.Map;
m_NoRecursion = false;
}
public override bool OnMoveOver( Mobile m )
{
if ( m is BaseCreature && !((BaseCreature)m).Controled )
return false;
return base.OnMoveOver( m );
}
protected override void OnMapChange( Map oldMap )
{
if ( (Map != Faction.Facet && oldMap == Faction.Facet) || (Map == Faction.Facet && oldMap != Faction.Facet) )
InvalidateProperties();
DesignContext context = m_DesignContext;
if ( context == null || m_NoRecursion )
return;
m_NoRecursion = true;
HouseFoundation foundation = context.Foundation;
if ( Map != foundation.Map )
Map = foundation.Map;
m_NoRecursion = false;
}
public override void OnDamage( int amount, Mobile from, bool willKill )
{
int disruptThreshold;
if ( !Core.AOS )
disruptThreshold = 0;
else if ( from != null && from.Player )
disruptThreshold = 18;
else
disruptThreshold = 25;
if ( amount > disruptThreshold )
{
BandageContext c = BandageContext.GetContext( this );
if ( c != null )
c.Slip();
}
WeightOverloading.FatigueOnDamage( this, amount );
base.OnDamage( amount, from, willKill );
}
public static int ComputeSkillTotal( Mobile m )
{
int total = 0;
for ( int i = 0; i < m.Skills.Length; ++i )
total += m.Skills[i].BaseFixedPoint;
return ( total / 10 );
}
public override void Resurrect()
{
bool wasAlive = this.Alive;
base.Resurrect();
if ( this.Alive && !wasAlive )
{
Item deathRobe = new DeathRobe();
if ( !EquipItem( deathRobe ) )
deathRobe.Delete();
}
}
private Mobile m_InsuranceAward;
private int m_InsuranceCost;
private int m_InsuranceBonus;
public override bool OnBeforeDeath()
{
m_InsuranceCost = 0;
m_InsuranceAward = base.FindMostRecentDamager( false );
if ( m_InsuranceAward is BaseCreature )
{
Mobile master = ((BaseCreature)m_InsuranceAward).GetMaster();
if ( master != null )
m_InsuranceAward = master;
}
if ( m_InsuranceAward != null && (!m_InsuranceAward.Player || m_InsuranceAward == this) )
m_InsuranceAward = null;
if ( m_InsuranceAward is PlayerMobile )
((PlayerMobile)m_InsuranceAward).m_InsuranceBonus = 0;
Mobile kill = FindMostRecentDamager( false );
if ( kill is PlayerMobile )
{
PlayerMobile killer = (PlayerMobile)kill;
if ( PvpPointSystem.EnablePointSystem == true )
PvpPointSystem.GivePoints( this, killer );
if ( PvpPointSystem.EnableRankSystem == true )
PvpPointSystem.CheckTitle( this, killer );
}
return base.OnBeforeDeath();
}
private bool CheckInsuranceOnDeath( Item item )
{
if ( InsuranceEnabled && item.Insured )
{
if ( AutoRenewInsurance )
{
int cost = ( m_InsuranceAward == null ? 600 : 300 );
if ( Banker.Withdraw( this, cost ) )
{
m_InsuranceCost += cost;
item.PayedInsurance = true;
}
else
{
SendLocalizedMessage( 1061079, "", 0x23 ); // You lack the funds to purchase the insurance
item.PayedInsurance = false;
item.Insured = false;
}
}
else
{
item.PayedInsurance = false;
item.Insured = false;
}
if ( m_InsuranceAward != null )
{
if ( Banker.Deposit( m_InsuranceAward, 300 ) )
{
if ( m_InsuranceAward is PlayerMobile )
((PlayerMobile)m_InsuranceAward).m_InsuranceBonus += 300;
}
}
return true;
}
return false;
}
public override DeathMoveResult GetParentMoveResultFor( Item item )
{
if ( CheckInsuranceOnDeath( item ) )
return DeathMoveResult.MoveToBackpack;
DeathMoveResult res = base.GetParentMoveResultFor( item );
if ( res == DeathMoveResult.MoveToCorpse && item.Movable && this.Young )
res = DeathMoveResult.MoveToBackpack;
return res;
}
public override DeathMoveResult GetInventoryMoveResultFor( Item item )
{
if ( CheckInsuranceOnDeath( item ) )
return DeathMoveResult.MoveToBackpack;
DeathMoveResult res = base.GetInventoryMoveResultFor( item );
if ( res == DeathMoveResult.MoveToCorpse && item.Movable && this.Young )
res = DeathMoveResult.MoveToBackpack;
return res;
}
public override void OnDeath( Container c )
{
base.OnDeath( c );
HueMod = -1;
NameMod = null;
SavagePaintExpiration = TimeSpan.Zero;
SetHairMods( -1, -1 );
PolymorphSpell.StopTimer( this );
IncognitoSpell.StopTimer( this );
DisguiseGump.StopTimer( this );
EndAction( typeof( PolymorphSpell ) );
EndAction( typeof( IncognitoSpell ) );
MeerMage.StopEffect( this, false );
SkillHandlers.StolenItem.ReturnOnDeath( this, c );
Mobile killer = this.FindMostRecentDamager( true );
if ( killer is PlayerMobile)
{
Deaths++;
((PlayerMobile )killer).Kills++;
}
if ( m_PermaFlags.Count > 0 )
{
m_PermaFlags.Clear();
if ( c is Corpse )
((Corpse)c).Criminal = true;
if ( SkillHandlers.Stealing.ClassicMode )
Criminal = true;
}
if ( this.Kills >= 5 && DateTime.Now >= m_NextJustAward )
{
Mobile m = FindMostRecentDamager( false );
if( m is BaseCreature )
m = ((BaseCreature)m).GetMaster();
if ( m != null && m.Player && m != this )
{
bool gainedPath = false;
int theirTotal = ComputeSkillTotal( m );
int ourTotal = ComputeSkillTotal( this );
int pointsToGain = 1 + ((theirTotal - ourTotal) / 50);
if ( pointsToGain < 1 )
pointsToGain = 1;
else if ( pointsToGain > 4 )
pointsToGain = 4;
if ( VirtueHelper.Award( m, VirtueName.Justice, pointsToGain, ref gainedPath ) )
{
if ( gainedPath )
m.SendLocalizedMessage( 1049367 ); // You have gained a path in Justice!
else
m.SendLocalizedMessage( 1049363 ); // You have gained in Justice.
m.FixedParticles( 0x375A, 9, 20, 5027, EffectLayer.Waist );
m.PlaySound( 0x1F7 );
m_NextJustAward = DateTime.Now + TimeSpan.FromMinutes(

ArteGordon- 04-26-2006
read the end of my last post. Your code just isnt going to work. Try replacing it with the code that I suggested instead.
kobra- 04-26-2006
and here is the new errors

CODE
RunUO - [www.runuo.com] Version 1.0.0, Build 36918 Scripts: Compiling C# scripts...failed (1 errors, 2 warnings) - Warning: Scripts\Mobiles\PlayerMobile.cs: CS0108: (line 103, column 14) The k eyword new is required on 'Server.Mobiles.PlayerMobile.Kills' because it hides i
nherited member 'Server.Mobile.Kills'
- Warning: Scripts\Spells\Base\Spell.cs: CS0162: (line 170, column 4) Unreachab
le code detected
- Error: Scripts\Mobiles\PlayerMobile.cs: CS0128: (line 1740, column 11) A loca
l variable named 'killer' is already defined in this scope
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

ArteGordon- 04-26-2006

QUOTE (kobra @ April 26, 2006 04:02 pm)
and here is the new errors

CODE
RunUO - [www.runuo.com] Version 1.0.0, Build 36918 Scripts: Compiling C# scripts...failed (1 errors, 2 warnings) - Warning: Scripts\Mobiles\PlayerMobile.cs: CS0108: (line 103, column 14) The k eyword new is required on 'Server.Mobiles.PlayerMobile.Kills' because it hides i
nherited member 'Server.Mobile.Kills'
- Warning: Scripts\Spells\Base\Spell.cs: CS0162: (line 170, column 4) Unreachab
le code detected
- Error: Scripts\Mobiles\PlayerMobile.cs: CS0128: (line 1740, column 11) A loca
l variable named 'killer' is already defined in this scope
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

the first two errors are due to code earlier in the script.

QUOTE
- Warning: Scripts\Mobiles\PlayerMobile.cs: CS0108: (line 103, column 14) The k eyword new is required on 'Server.Mobiles.PlayerMobile.Kills' because it hides i nherited member 'Server.Mobile.Kills'

CODE
[CommandProperty( AccessLevel.GameMaster )] public int Kills { get{ return m_Kills; } set{ m_Kills = value; }
}

there is already a property called Kills on all mobiles so you dont need to define another one.

QUOTE
- Error: Scripts\Mobiles\PlayerMobile.cs: CS0128: (line 1740, column 11) A loca l variable named 'killer' is already defined in this scope Scripts: One or more scripts failed to compile or no script files were found.

that means that somewhere else in the OnDeath method a variable named 'killer' is defined, so just use a different variable name in the code I posted.
kobra- 04-26-2006
I use Mobile so here is the code

CODE
if ( Mobile is PlayerMobile) { Deaths++; ((PlayerMobile )Mobile).Kills++; }

And here is the errors...

CODE
- Error: Scripts\Mobiles\PlayerMobile.cs: CS0118: (line 1674, column 8) 'Server .Mobile' denotes a 'class' where a 'variable' was expected - Error: Scripts\Mobiles\PlayerMobile.cs: CS0118: (line 1677, column 20) 'Serve r.Mobile' denotes a 'class' where a 'variable' was expected
- Error: Scripts\Mobiles\PlayerMobile.cs: CS0128: (line 1740, column 11) A loca
l variable named 'killer' is already defined in this scope
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

Dont know what i did wrong, i ddi what u said just make a different variable name so i chose Mobile
ArteGordon- 04-26-2006
you cannot use 'Mobile' as a variable name since it is already being used as the name of a class. Use something safe and unique like 'mykiller'
kobra- 04-27-2006
Ok i cahnged the entire code to this

CODE
Mobile whokilled = this.FindMostRecentDamager( true ); if ( whokilled is PlayerMobile) { Deaths++; ((PlayerMobile )whokilled).Kills++;
}

Now i have NO ERRORS and server starts up perfect!! But kills/deaths do not show up under name and the kills does not show up when i do [props on a player on deaths do, but i tink its cause it has samename as the 'kills' refering to the LongTerm and ShortTerm, i am just concerned to get kills/deaths to show up i tried to make a player and it didnt show up on player - any help is well appriciated and thanks for everything so far!!!!!
I also attached my full playermobile.cs cause it never fully fits in the code so..thanks again!!!
ArteGordon- 04-27-2006
just because you add those properties does not mean that they will appear as part of the name. You would have to add that explicitly to the name string in the GetNameProperties override.
The Kills property that you are using is the same as that normally used to keep track of murders. If you want to have a separate property like that, then you would need to give it a different name.
(edit)
I looked at your playermobile and you are adding them, but you are using the same cliloc number 1060660 for them all. You cannot do that. You have to use a different cliloc number for each string.

QUOTE
list.Add( 1060660, "Deaths\t{0}", m_Deaths );

kobra- 04-27-2006
So if i leave the cliloc number for deaths the same, what do i put it for kills to make them show under name?
kobra- 04-27-2006
here is code - changed the clilic number and it still dont show kills/deaths

CODE
public override void AddNameProperties( ObjectPropertyList list ) { if ( m_Deaths > 0 ) { if ( AccessLevel == AccessLevel.Player )
{
list.Add( 1060662, "Deaths\t{0}", m_Deaths );
}
else if ( AccessLevel == AccessLevel.Player )
{
list.Add( 1060662, "Deaths\t0" );
}
}
if ( m_Kills > 0 )
{
if ( AccessLevel == AccessLevel.Player )
list.Add( 1060663, "Kills\t{0}", m_Kills );
}
base.AddNameProperties( list );

ArteGordon- 04-27-2006
that is not the entire method. What is the rest of it?
kobra- 04-27-2006
I dont know. Thats all i ever had - i attached my full playermobile.cs again if ya needa look there - unsure
kobra- 04-27-2006
i also was looking threw the script support and saw asmir had the same prob. I copied one of the codes u told him to use i tried this on my server

CODE
if (AccessLevel == AccessLevel.Player) { if (m_Kills > 0) list.Add(1060660, "Kills\t{0}", m_Kills); else
list.Add(1060660, "Deaths\t0");
if (m_Deaths > 0)
list.Add(1060661, "Deaths\t{0}", m_Deaths);
else
list.Add(1060661, "Deaths\t0");
}

I got no errors and it ran fine but download the attachment picture, the kills and deaths and the name is all messed up. Kills do not show. Deaths are where the name is and the Name is where Deaths are supposed to be LOL!! i dunno what to edit to get thsi working fine but this code seems pretty rite - it was the one u suggested Asmir to use in the kills/deaths system post he did a while back