revert crafting updates of SVN538. Per Mark: changing baseclasses is a bad idea.
This commit is contained in:
parent
7399519cf7
commit
e86794c4e6
130 changed files with 1007 additions and 4906 deletions
|
|
@ -1,159 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Network;
|
||||
using Server.Engines.Craft;
|
||||
using Server.Misc;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public enum CraftQuality
|
||||
{
|
||||
Low,
|
||||
Regular,
|
||||
Exceptional
|
||||
}
|
||||
|
||||
public abstract class BaseCraftableItem : Item, ICraftable
|
||||
{
|
||||
private Mobile m_Crafter;
|
||||
private CraftQuality m_Quality;
|
||||
private CraftResource m_Resource;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public Mobile Crafter
|
||||
{
|
||||
get { return m_Crafter; }
|
||||
set { m_Crafter = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public CraftQuality Quality
|
||||
{
|
||||
get { return m_Quality; }
|
||||
set { m_Quality = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public CraftResource Resource
|
||||
{
|
||||
get { return m_Resource; }
|
||||
set
|
||||
{
|
||||
if ( m_Resource != value )
|
||||
{
|
||||
m_Resource = value;
|
||||
Hue = CraftResources.GetHue( m_Resource );
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Old Item Serialization Vars
|
||||
/* DO NOT USE! Only used in serialization of furniture that originally derived from Item */
|
||||
private bool m_InheritsItem;
|
||||
private int m_OldVersion;
|
||||
|
||||
protected bool InheritsItem
|
||||
{
|
||||
get{ return m_InheritsItem; }
|
||||
}
|
||||
|
||||
protected int OldVersion
|
||||
{
|
||||
get{ return m_OldVersion; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
public virtual CraftResource DefaultResource{ get{ return CraftResource.RegularWood; } }
|
||||
public virtual bool DisplaysResource{ get{ return true; } }
|
||||
//For odd entries that can be crafted exceptionally with maker's mark but don't actually display a maker's mark
|
||||
public virtual bool DisplaysMakersMark{ get{ return true; } }
|
||||
|
||||
public BaseCraftableItem( int itemID ) : base( itemID )
|
||||
{
|
||||
m_Quality = CraftQuality.Regular;
|
||||
Resource = DefaultResource;
|
||||
}
|
||||
|
||||
public BaseCraftableItem(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
|
||||
if ( m_Crafter != null && DisplaysMakersMark )
|
||||
list.Add( 1050043, m_Crafter.Name ); // crafted by ~1_NAME~
|
||||
|
||||
if ( m_Quality == CraftQuality.Exceptional )
|
||||
list.Add( 1060636 ); // exceptional
|
||||
|
||||
if( ( m_Resource >= CraftResource.OakWood && m_Resource <= CraftResource.Frostwood ) && Hue == CraftResources.GetHue( m_Resource ) && DisplaysResource )
|
||||
list.Add( CraftResources.GetLocalizationNumber( m_Resource ) ); // resource name
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int) 1);
|
||||
|
||||
writer.Write( m_Crafter );
|
||||
writer.WriteEncodedInt( (int) m_Quality );
|
||||
writer.WriteEncodedInt( (int) m_Resource );
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
m_Crafter = reader.ReadMobile();
|
||||
m_Quality = (CraftQuality)reader.ReadEncodedInt();
|
||||
m_Resource = (CraftResource)reader.ReadEncodedInt();
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_InheritsItem = true;
|
||||
m_OldVersion = version;
|
||||
m_Quality = CraftQuality.Regular;
|
||||
m_Resource = DefaultResource;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue )
|
||||
{
|
||||
if ( Core.ML )
|
||||
{
|
||||
Quality = (CraftQuality)quality;
|
||||
|
||||
if ( makersMark )
|
||||
Crafter = from;
|
||||
|
||||
Type resourceType = typeRes;
|
||||
|
||||
if ( resourceType == null )
|
||||
resourceType = craftItem.Resources.GetAt( 0 ).ItemType;
|
||||
|
||||
Resource = CraftResources.GetFromType( resourceType );
|
||||
|
||||
CraftContext context = craftSystem.GetContext( from );
|
||||
|
||||
if ( context != null && context.DoNotColor )
|
||||
Hue = 0;
|
||||
}
|
||||
|
||||
return (int)Quality;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,683 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Network;
|
||||
using Server.Engines.Craft;
|
||||
using Server.Factions;
|
||||
using AMA = Server.Items.ArmorMeditationAllowance;
|
||||
using AMT = Server.Items.ArmorMaterialType;
|
||||
using ABT = Server.Items.ArmorBodyType;
|
||||
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public abstract class BaseOtherEquipable : Item, ICraftable, IAosAttributes
|
||||
{
|
||||
private Mobile m_Crafter;
|
||||
private CraftQuality m_Quality;
|
||||
private CraftResource m_Resource;
|
||||
private bool m_PlayerConstructed;
|
||||
|
||||
private AosAttributes m_AosAttributes;
|
||||
private AosArmorAttributes m_AosArmorAttributes;
|
||||
private AosSkillBonuses m_AosSkillBonuses;
|
||||
|
||||
private BonusAttribute[] m_BonusRandomAttributes;
|
||||
private double m_OriginalWeight;
|
||||
|
||||
private int m_StrReq = -1, m_DexReq = -1, m_IntReq = -1;
|
||||
|
||||
public virtual bool AllowMaleWearer{ get{ return true; } }
|
||||
public virtual bool AllowFemaleWearer{ get{ return true; } }
|
||||
|
||||
public virtual Race RequiredRace { get { return null; } }
|
||||
|
||||
public virtual int AosStrReq{ get{ return 0; } }
|
||||
public virtual int AosDexReq{ get{ return 0; } }
|
||||
public virtual int AosIntReq{ get{ return 0; } }
|
||||
|
||||
public virtual int OldStrReq{ get{ return 0; } }
|
||||
public virtual int OldDexReq{ get{ return 0; } }
|
||||
public virtual int OldIntReq{ get{ return 0; } }
|
||||
|
||||
public virtual CraftResource DefaultResource{ get{ return CraftResource.RegularWood; } }
|
||||
|
||||
public override void OnAfterDuped( Item newItem )
|
||||
{
|
||||
BaseOtherEquipable otherEquip = newItem as BaseOtherEquipable;
|
||||
|
||||
if ( otherEquip == null )
|
||||
return;
|
||||
|
||||
otherEquip.m_AosAttributes = new AosAttributes( newItem, m_AosAttributes );
|
||||
otherEquip.m_AosArmorAttributes = new AosArmorAttributes( newItem, m_AosArmorAttributes );
|
||||
otherEquip.m_AosSkillBonuses = new AosSkillBonuses( newItem, m_AosSkillBonuses );
|
||||
otherEquip.m_BonusRandomAttributes = m_BonusRandomAttributes;
|
||||
}
|
||||
|
||||
#region Getters/Setters
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool PlayerConstructed
|
||||
{
|
||||
get{ return m_PlayerConstructed; }
|
||||
set{ m_PlayerConstructed = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int StrRequirement
|
||||
{
|
||||
get{ return ( m_StrReq == -1 ? Core.AOS ? AosStrReq : OldStrReq : m_StrReq ); }
|
||||
set{ m_StrReq = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int DexRequirement
|
||||
{
|
||||
get{ return ( m_DexReq == -1 ? Core.AOS ? AosDexReq : OldDexReq : m_DexReq ); }
|
||||
set{ m_DexReq = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int IntRequirement
|
||||
{
|
||||
get{ return ( m_IntReq == -1 ? Core.AOS ? AosIntReq : OldIntReq : m_IntReq ); }
|
||||
set{ m_IntReq = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public CraftResource Resource
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Resource;
|
||||
}
|
||||
set
|
||||
{
|
||||
if ( m_Resource != value )
|
||||
{
|
||||
if ( Core.AOS && !CraftResources.IsStandard( m_Resource ) )
|
||||
{
|
||||
BonusAttributesHelper.RemoveAttrsFrom( this, GetResourceBonusAttrs() );
|
||||
BonusAttributesHelper.RemoveAttrsFrom( this, RandomAttributes );
|
||||
RandomAttributes = null;
|
||||
}
|
||||
|
||||
m_Resource = value;
|
||||
Hue = CraftResources.GetHue( m_Resource );
|
||||
|
||||
if ( Core.AOS && !CraftResources.IsStandard( m_Resource ) )
|
||||
{
|
||||
// Enhance sets RandomAttributes so check if it's null/empty first before getting new random attributes.
|
||||
if ( RandomAttributes == null || RandomAttributes.Length == 0 )
|
||||
RandomAttributes = BonusAttributesHelper.GetRandomAttributes( GetResourceRandomAttrs(), GetResourceAttrs().RandomAttributeCount );
|
||||
|
||||
BonusAttributesHelper.ApplyAttributesTo( this, GetResourceBonusAttrs() );
|
||||
BonusAttributesHelper.ApplyAttributesTo( this, RandomAttributes );
|
||||
}
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public Mobile Crafter
|
||||
{
|
||||
get{ return m_Crafter; }
|
||||
set{ m_Crafter = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public CraftQuality Quality
|
||||
{
|
||||
get{ return m_Quality; }
|
||||
set{ m_Quality = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public AosAttributes Attributes
|
||||
{
|
||||
get{ return m_AosAttributes; }
|
||||
set{}
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public AosArmorAttributes ArmorAttributes
|
||||
{
|
||||
get{ return m_AosArmorAttributes; }
|
||||
set{}
|
||||
}
|
||||
|
||||
public BonusAttribute[] RandomAttributes
|
||||
{
|
||||
get { return m_BonusRandomAttributes; }
|
||||
set { m_BonusRandomAttributes = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Old Item Serialization Vars
|
||||
/* Only used in serialization of other equipables that originally derived from Item */
|
||||
private bool m_InheritsItem;
|
||||
private int m_OldVersion;
|
||||
|
||||
protected bool InheritsItem
|
||||
{
|
||||
get{ return m_InheritsItem; }
|
||||
}
|
||||
|
||||
protected int OldVersion
|
||||
{
|
||||
get{ return m_OldVersion; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
public CraftAttributeInfo GetResourceAttrs()
|
||||
{
|
||||
CraftResourceInfo info = CraftResources.GetInfo( m_Resource );
|
||||
|
||||
if ( info == null )
|
||||
return CraftAttributeInfo.Blank;
|
||||
|
||||
return info.AttributeInfo;
|
||||
}
|
||||
|
||||
public BonusAttribute[] GetResourceBonusAttrs()
|
||||
{
|
||||
CraftAttributeInfo attrInfo = GetResourceAttrs();
|
||||
|
||||
return attrInfo.OtherAttributes;
|
||||
}
|
||||
|
||||
public BonusAttribute[] GetResourceRandomAttrs()
|
||||
{
|
||||
CraftAttributeInfo attrInfo = GetResourceAttrs();
|
||||
|
||||
return attrInfo.OtherRandomAttributes;
|
||||
}
|
||||
|
||||
public int ComputeStatReq( StatType type )
|
||||
{
|
||||
int v;
|
||||
|
||||
if ( type == StatType.Str )
|
||||
v = StrRequirement;
|
||||
else if ( type == StatType.Dex )
|
||||
v = DexRequirement;
|
||||
else
|
||||
v = IntRequirement;
|
||||
|
||||
return AOS.Scale( v, 100 - GetLowerStatReq() );
|
||||
}
|
||||
|
||||
|
||||
public BaseOtherEquipable( int itemID ) : base( itemID )
|
||||
{
|
||||
m_Quality = CraftQuality.Regular;
|
||||
Resource = DefaultResource;
|
||||
|
||||
m_AosAttributes = new AosAttributes( this );
|
||||
m_AosArmorAttributes = new AosArmorAttributes( this );
|
||||
m_AosSkillBonuses = new AosSkillBonuses( this );
|
||||
|
||||
m_OriginalWeight = Weight;
|
||||
}
|
||||
|
||||
public BaseOtherEquipable( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
#region Serialization/Deserialization
|
||||
private static void SetSaveFlag( ref SaveFlag flags, SaveFlag toSet, bool setIf )
|
||||
{
|
||||
if ( setIf )
|
||||
flags |= toSet;
|
||||
}
|
||||
|
||||
private static bool GetSaveFlag( SaveFlag flags, SaveFlag toGet )
|
||||
{
|
||||
return ( (flags & toGet) != 0 );
|
||||
}
|
||||
|
||||
[Flags]
|
||||
private enum SaveFlag
|
||||
{
|
||||
None = 0x00000000,
|
||||
Attributes = 0x00000001,
|
||||
ArmorAttributes = 0x00000002,
|
||||
Crafter = 0x00000004,
|
||||
Quality = 0x00000008,
|
||||
Resource = 0x00000010,
|
||||
StrReq = 0x00000020,
|
||||
DexReq = 0x00000040,
|
||||
IntReq = 0x00000080,
|
||||
SkillBonuses = 0x00000100,
|
||||
PlayerConstructed = 0x00000200,
|
||||
BonusRandomAttributes = 0x00000400
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 1 ); // version
|
||||
|
||||
SaveFlag flags = SaveFlag.None;
|
||||
|
||||
SetSaveFlag( ref flags, SaveFlag.Attributes, !m_AosAttributes.IsEmpty );
|
||||
SetSaveFlag( ref flags, SaveFlag.ArmorAttributes, !m_AosArmorAttributes.IsEmpty );
|
||||
SetSaveFlag( ref flags, SaveFlag.Crafter, m_Crafter != null );
|
||||
SetSaveFlag( ref flags, SaveFlag.Quality, m_Quality != CraftQuality.Regular );
|
||||
SetSaveFlag( ref flags, SaveFlag.Resource, m_Resource != DefaultResource );
|
||||
SetSaveFlag( ref flags, SaveFlag.StrReq, m_StrReq != -1 );
|
||||
SetSaveFlag( ref flags, SaveFlag.DexReq, m_DexReq != -1 );
|
||||
SetSaveFlag( ref flags, SaveFlag.IntReq, m_IntReq != -1 );
|
||||
SetSaveFlag( ref flags, SaveFlag.SkillBonuses, !m_AosSkillBonuses.IsEmpty );
|
||||
SetSaveFlag( ref flags, SaveFlag.PlayerConstructed, m_PlayerConstructed != false );
|
||||
SetSaveFlag( ref flags, SaveFlag.BonusRandomAttributes, m_BonusRandomAttributes != null && m_BonusRandomAttributes.Length > 0 );
|
||||
|
||||
writer.WriteEncodedInt( (int) flags );
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.Attributes ) )
|
||||
m_AosAttributes.Serialize( writer );
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.ArmorAttributes ) )
|
||||
m_AosArmorAttributes.Serialize( writer );
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.Crafter ) )
|
||||
writer.Write( (Mobile) m_Crafter );
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.Quality ) )
|
||||
writer.WriteEncodedInt( (int) m_Quality );
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.Resource ) )
|
||||
writer.WriteEncodedInt( (int) m_Resource );
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.StrReq ) )
|
||||
writer.WriteEncodedInt( (int) m_StrReq );
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.DexReq ) )
|
||||
writer.WriteEncodedInt( (int) m_DexReq );
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.IntReq ) )
|
||||
writer.WriteEncodedInt( (int) m_IntReq );
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.SkillBonuses ) )
|
||||
m_AosSkillBonuses.Serialize( writer );
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.BonusRandomAttributes ) )
|
||||
{
|
||||
writer.Write( m_BonusRandomAttributes.Length );
|
||||
for ( int i = 0; i < m_BonusRandomAttributes.Length; i++ )
|
||||
m_BonusRandomAttributes[i].Serialize( writer );
|
||||
}
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
SaveFlag flags = (SaveFlag)reader.ReadEncodedInt();
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.Attributes ) )
|
||||
m_AosAttributes = new AosAttributes( this, reader );
|
||||
else
|
||||
m_AosAttributes = new AosAttributes( this );
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.ArmorAttributes ) )
|
||||
m_AosArmorAttributes = new AosArmorAttributes( this, reader );
|
||||
else
|
||||
m_AosArmorAttributes = new AosArmorAttributes( this );
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.Crafter ) )
|
||||
m_Crafter = reader.ReadMobile();
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.Quality ) )
|
||||
m_Quality = (CraftQuality)reader.ReadEncodedInt();
|
||||
else
|
||||
m_Quality = CraftQuality.Regular;
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.Resource ) )
|
||||
m_Resource = (CraftResource)reader.ReadEncodedInt();
|
||||
else
|
||||
m_Resource = DefaultResource;
|
||||
|
||||
if ( m_Resource == CraftResource.None )
|
||||
m_Resource = DefaultResource;
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.StrReq ) )
|
||||
m_StrReq = reader.ReadEncodedInt();
|
||||
else
|
||||
m_StrReq = -1;
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.DexReq ) )
|
||||
m_DexReq = reader.ReadEncodedInt();
|
||||
else
|
||||
m_DexReq = -1;
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.IntReq ) )
|
||||
m_IntReq = reader.ReadEncodedInt();
|
||||
else
|
||||
m_IntReq = -1;
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.SkillBonuses ) )
|
||||
m_AosSkillBonuses = new AosSkillBonuses( this, reader );
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.PlayerConstructed ) )
|
||||
m_PlayerConstructed = true;
|
||||
|
||||
if ( GetSaveFlag( flags, SaveFlag.BonusRandomAttributes ) )
|
||||
{
|
||||
m_BonusRandomAttributes = new BonusAttribute[reader.ReadInt()];
|
||||
|
||||
for( int i = 0; i < m_BonusRandomAttributes.Length; i++ )
|
||||
m_BonusRandomAttributes[i] = new BonusAttribute( reader );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_InheritsItem = true;
|
||||
m_OldVersion = version;
|
||||
m_AosAttributes = new AosAttributes( this );
|
||||
m_AosArmorAttributes = new AosArmorAttributes( this );
|
||||
m_Quality = CraftQuality.Regular;
|
||||
m_Resource = DefaultResource;
|
||||
m_PlayerConstructed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_AosSkillBonuses == null )
|
||||
m_AosSkillBonuses = new AosSkillBonuses( this );
|
||||
|
||||
if ( Core.AOS && Parent is Mobile )
|
||||
m_AosSkillBonuses.AddTo( (Mobile)Parent );
|
||||
|
||||
if ( Parent is Mobile )
|
||||
((Mobile)Parent).CheckStatTimers();
|
||||
}
|
||||
#endregion
|
||||
|
||||
public int GetLowerStatReq()
|
||||
{
|
||||
if ( !Core.AOS )
|
||||
return 0;
|
||||
|
||||
int v = m_AosArmorAttributes.LowerStatReq;
|
||||
|
||||
if ( v > 100 )
|
||||
v = 100;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public void ModifyWeight()
|
||||
{
|
||||
double v = 0;
|
||||
|
||||
v = 100 - GetWeightBonus();
|
||||
|
||||
Weight = m_OriginalWeight * (v / 100);
|
||||
}
|
||||
|
||||
public int GetWeightBonus()
|
||||
{
|
||||
CraftAttributeInfo attrInfo = GetResourceAttrs();
|
||||
|
||||
int v = Attributes.LowerWeight;
|
||||
|
||||
if ( v > 100 )
|
||||
v = 100;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public override bool CanEquip( Mobile from )
|
||||
{
|
||||
if( !Ethics.Ethic.CheckEquip( from, this ) )
|
||||
return false;
|
||||
|
||||
if( from.AccessLevel < AccessLevel.GameMaster )
|
||||
{
|
||||
if( RequiredRace != null && from.Race != RequiredRace )
|
||||
{
|
||||
if( RequiredRace == Race.Elf )
|
||||
from.SendLocalizedMessage( 1072203 ); // Only Elves may use this.
|
||||
else
|
||||
from.SendMessage( "Only {0} may use this.", RequiredRace.PluralName );
|
||||
|
||||
return false;
|
||||
}
|
||||
else if( !AllowMaleWearer && !from.Female )
|
||||
{
|
||||
if( AllowFemaleWearer )
|
||||
from.SendLocalizedMessage( 1010388 ); // Only females can wear this.
|
||||
else
|
||||
from.SendMessage( "You may not wear this." );
|
||||
|
||||
return false;
|
||||
}
|
||||
else if( !AllowFemaleWearer && from.Female )
|
||||
{
|
||||
if( AllowMaleWearer )
|
||||
from.SendLocalizedMessage( 1063343 ); // Only males can wear this.
|
||||
else
|
||||
from.SendMessage( "You may not wear this." );
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int strReq = ComputeStatReq( StatType.Str );
|
||||
int dexReq = ComputeStatReq( StatType.Dex );
|
||||
int intReq = ComputeStatReq( StatType.Int );
|
||||
|
||||
if( from.Dex < dexReq )
|
||||
{
|
||||
from.SendLocalizedMessage( 502077 ); // You do not have enough dexterity to equip this item.
|
||||
return false;
|
||||
}
|
||||
else if( from.Str < strReq )
|
||||
{
|
||||
from.SendLocalizedMessage( 500213 ); // You are not strong enough to equip that.
|
||||
return false;
|
||||
}
|
||||
else if( from.Int < intReq )
|
||||
{
|
||||
from.SendMessage( "You are not smart enough to equip that." );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return base.CanEquip( from );
|
||||
}
|
||||
|
||||
public override bool OnEquip( Mobile from )
|
||||
{
|
||||
from.CheckStatTimers();
|
||||
|
||||
int strBonus = m_AosAttributes.BonusStr;
|
||||
int dexBonus = m_AosAttributes.BonusDex;
|
||||
int intBonus = m_AosAttributes.BonusInt;
|
||||
|
||||
if ( strBonus != 0 || dexBonus != 0 || intBonus != 0 )
|
||||
{
|
||||
string modName = this.Serial.ToString();
|
||||
|
||||
if ( strBonus != 0 )
|
||||
from.AddStatMod( new StatMod( StatType.Str, modName + "Str", strBonus, TimeSpan.Zero ) );
|
||||
|
||||
if ( dexBonus != 0 )
|
||||
from.AddStatMod( new StatMod( StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero ) );
|
||||
|
||||
if ( intBonus != 0 )
|
||||
from.AddStatMod( new StatMod( StatType.Int, modName + "Int", intBonus, TimeSpan.Zero ) );
|
||||
}
|
||||
|
||||
return base.OnEquip( from );
|
||||
}
|
||||
|
||||
public override void OnAdded( object parent )
|
||||
{
|
||||
if ( parent is Mobile )
|
||||
{
|
||||
Mobile from = (Mobile)parent;
|
||||
|
||||
if ( Core.AOS )
|
||||
m_AosSkillBonuses.AddTo( from );
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnRemoved( object parent )
|
||||
{
|
||||
if ( parent is Mobile )
|
||||
{
|
||||
Mobile m = (Mobile)parent;
|
||||
string modName = this.Serial.ToString();
|
||||
|
||||
m.RemoveStatMod( modName + "Str" );
|
||||
m.RemoveStatMod( modName + "Dex" );
|
||||
m.RemoveStatMod( modName + "Int" );
|
||||
|
||||
if ( Core.AOS )
|
||||
m_AosSkillBonuses.Remove();
|
||||
|
||||
m.CheckStatTimers();
|
||||
}
|
||||
|
||||
base.OnRemoved( parent );
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
|
||||
if ( m_Crafter != null )
|
||||
list.Add( 1050043, m_Crafter.Name ); // crafted by ~1_NAME~
|
||||
|
||||
if ( m_Quality == CraftQuality.Exceptional )
|
||||
list.Add( 1060636 ); // exceptional
|
||||
|
||||
if ( m_AosSkillBonuses != null )
|
||||
m_AosSkillBonuses.GetProperties( list );
|
||||
|
||||
int prop;
|
||||
|
||||
if ( ( m_Resource >= CraftResource.OakWood && m_Resource <= CraftResource.Frostwood ) && Hue == CraftResources.GetHue( m_Resource ) )
|
||||
list.Add( CraftResources.GetLocalizationNumber( m_Resource ) );
|
||||
|
||||
if ( (prop = m_AosAttributes.WeaponDamage) != 0 )
|
||||
list.Add( 1060401, prop.ToString() ); // damage increase ~1_val~%
|
||||
|
||||
if ( (prop = m_AosAttributes.DefendChance) != 0 )
|
||||
list.Add( 1060408, prop.ToString() ); // defense chance increase ~1_val~%
|
||||
|
||||
if ( (prop = m_AosAttributes.BonusDex ) != 0 )
|
||||
list.Add( 1060409, prop.ToString() ); // dexterity bonus ~1_val~
|
||||
|
||||
if ( (prop = m_AosAttributes.EnhancePotions) != 0 )
|
||||
list.Add( 1060411, prop.ToString() ); // enhance potions ~1_val~%
|
||||
|
||||
if ( (prop = m_AosAttributes.CastRecovery) != 0 )
|
||||
list.Add( 1060412, prop.ToString() ); // faster cast recovery ~1_val~
|
||||
|
||||
if ( (prop = m_AosAttributes.CastSpeed) != 0 )
|
||||
list.Add( 1060413, prop.ToString() ); // faster casting ~1_val~
|
||||
|
||||
if ( (prop = m_AosAttributes.AttackChance) != 0 )
|
||||
list.Add( 1060415, prop.ToString() ); // hit chance increase ~1_val~%
|
||||
|
||||
if ( (prop = m_AosAttributes.BonusHits) != 0 )
|
||||
list.Add( 1060431, prop.ToString() ); // hit point increase ~1_val~
|
||||
|
||||
if ( (prop = m_AosAttributes.BonusInt) != 0 )
|
||||
list.Add( 1060432, prop.ToString() ); // intelligence bonus ~1_val~
|
||||
|
||||
if ( (prop = m_AosAttributes.LowerManaCost) != 0 )
|
||||
list.Add( 1060433, prop.ToString() ); // lower mana cost ~1_val~%
|
||||
|
||||
if ( (prop = m_AosAttributes.LowerRegCost) != 0 )
|
||||
list.Add( 1060434, prop.ToString() ); // lower reagent cost ~1_val~%
|
||||
|
||||
if ( (prop = GetLowerStatReq()) != 0 )
|
||||
list.Add( 1060435, prop.ToString() ); // lower requirements ~1_val~%
|
||||
|
||||
if ( (prop = m_AosAttributes.Luck) != 0 )
|
||||
list.Add( 1060436, prop.ToString() ); // luck ~1_val~
|
||||
|
||||
if ( (prop = m_AosAttributes.BonusMana) != 0 )
|
||||
list.Add( 1060439, prop.ToString() ); // mana increase ~1_val~
|
||||
|
||||
if ( (prop = m_AosAttributes.RegenMana) != 0 )
|
||||
list.Add( 1060440, prop.ToString() ); // mana regeneration ~1_val~
|
||||
|
||||
if ( (prop = m_AosAttributes.NightSight) != 0 )
|
||||
list.Add( 1060441 ); // night sight
|
||||
|
||||
if ( (prop = m_AosAttributes.ReflectPhysical) != 0 )
|
||||
list.Add( 1060442, prop.ToString() ); // reflect physical damage ~1_val~%
|
||||
|
||||
if ( (prop = m_AosAttributes.RegenStam) != 0 )
|
||||
list.Add( 1060443, prop.ToString() ); // stamina regeneration ~1_val~
|
||||
|
||||
if ( (prop = m_AosAttributes.RegenHits) != 0 )
|
||||
list.Add( 1060444, prop.ToString() ); // hit point regeneration ~1_val~
|
||||
|
||||
if ( (prop = m_AosAttributes.SpellChanneling) != 0 )
|
||||
list.Add( 1060482 ); // spell channeling
|
||||
|
||||
if ( (prop = m_AosAttributes.SpellDamage) != 0 )
|
||||
list.Add( 1060483, prop.ToString() ); // spell damage increase ~1_val~%
|
||||
|
||||
if ( (prop = m_AosAttributes.BonusStam) != 0 )
|
||||
list.Add( 1060484, prop.ToString() ); // stamina increase ~1_val~
|
||||
|
||||
if ( (prop = m_AosAttributes.BonusStr) != 0 )
|
||||
list.Add( 1060485, prop.ToString() ); // strength bonus ~1_val~
|
||||
|
||||
if ( (prop = m_AosAttributes.WeaponSpeed) != 0 )
|
||||
list.Add( 1060486, prop.ToString() ); // swing speed increase ~1_val~%
|
||||
|
||||
if ( (prop = ComputeStatReq( StatType.Str )) > 0 )
|
||||
list.Add( 1061170, prop.ToString() ); // strength requirement ~1_val~
|
||||
}
|
||||
|
||||
#region ICraftable Members
|
||||
|
||||
public virtual int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue )
|
||||
{
|
||||
if ( Core.ML )
|
||||
{
|
||||
Quality = (CraftQuality)quality;
|
||||
|
||||
if ( makersMark )
|
||||
Crafter = from;
|
||||
|
||||
Type resourceType = typeRes;
|
||||
|
||||
if ( resourceType == null )
|
||||
resourceType = craftItem.Resources.GetAt( 0 ).ItemType;
|
||||
|
||||
Resource = CraftResources.GetFromType( resourceType );
|
||||
PlayerConstructed = true;
|
||||
|
||||
CraftContext context = craftSystem.GetContext( from );
|
||||
|
||||
if ( context != null && context.DoNotColor )
|
||||
Hue = 0;
|
||||
}
|
||||
|
||||
return quality;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -1,416 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public static class BonusAttributesHelper
|
||||
{
|
||||
#region Random Attributes
|
||||
|
||||
/// <summary>
|
||||
/// <para>Returns a <see cref="BonusAttribute"/> array populated with one unique random attribute
|
||||
/// chosen from '<paramref name="randAttrs"/>' array -or- returns null if a null or empty array is supplied.</para>
|
||||
/// </summary>
|
||||
public static BonusAttribute[] GetRandomAttributes( BonusAttribute[] randAttrs )
|
||||
{
|
||||
return GetRandomAttributes( randAttrs, 1 );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Returns a <see cref="BonusAttribute"/> array populated with '<paramref name="numOfAttr"/>' unique random attributes
|
||||
/// chosen from '<paramref name="randAttrs"/>' array -or- returns null if a null or empty array is supplied.</para>
|
||||
/// </summary>
|
||||
public static BonusAttribute[] GetRandomAttributes( BonusAttribute[] randAttrs, int numOfAttr )
|
||||
{
|
||||
BonusAttribute[] toAttrs = null;
|
||||
|
||||
if ( randAttrs != null && randAttrs.Length > 0 && numOfAttr > 0)
|
||||
{
|
||||
toAttrs = new BonusAttribute[numOfAttr];
|
||||
|
||||
int avail = 0;
|
||||
|
||||
List<int> numList = new List<int>();
|
||||
|
||||
for ( int i = 0; i < randAttrs.Length; ++i )
|
||||
numList.Add( avail++ );
|
||||
|
||||
if ( numOfAttr > randAttrs.Length )
|
||||
numOfAttr = randAttrs.Length;
|
||||
|
||||
int v;
|
||||
|
||||
for ( int i = 0; i < numOfAttr; ++i )
|
||||
{
|
||||
v = Utility.Random(avail--);
|
||||
|
||||
toAttrs[i] = randAttrs[numList[v]];
|
||||
|
||||
numList.RemoveAt(v);
|
||||
}
|
||||
}
|
||||
|
||||
return toAttrs;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Apply Attributes
|
||||
public static void ApplyAttributesTo( Item item, BonusAttribute[] attributes )
|
||||
{
|
||||
if ( attributes != null && attributes.Length > 0 )
|
||||
{
|
||||
int cold = 0, nrgy = 0, fire = 0, pois = 0, chaos = 0, direct = 0;
|
||||
|
||||
for ( int i = 0; i < attributes.Length; i++ )
|
||||
{
|
||||
if ( attributes[i].Attribute == null )
|
||||
continue;
|
||||
|
||||
Type attrType = attributes[i].Attribute.GetType();
|
||||
|
||||
if ( attrType == typeof( AosAttribute ) )
|
||||
{
|
||||
if ( item is IAosAttributes )
|
||||
ApplyAttribute( ((IAosAttributes)item).Attributes, (AosAttribute)attributes[i].Attribute, attributes[i].Amount );
|
||||
}
|
||||
else if ( attrType == typeof( AosArmorAttribute ) )
|
||||
{
|
||||
if ( (AosArmorAttribute)attributes[i].Attribute == AosArmorAttribute.DurabilityBonus )
|
||||
ApplyDurability( item, attributes[i].Amount );
|
||||
else if ( item is BaseArmor )
|
||||
ApplyAttribute( ((BaseArmor)item).ArmorAttributes, (AosArmorAttribute)attributes[i].Attribute, attributes[i].Amount );
|
||||
else if ( item is BaseOtherEquipable )
|
||||
ApplyAttribute( ((BaseOtherEquipable)item).ArmorAttributes, (AosArmorAttribute)attributes[i].Attribute, attributes[i].Amount );
|
||||
}
|
||||
else if ( attrType == typeof( AosWeaponAttribute ) )
|
||||
{
|
||||
if ( (AosWeaponAttribute)attributes[i].Attribute == AosWeaponAttribute.DurabilityBonus )
|
||||
ApplyDurability( item, attributes[i].Amount );
|
||||
else if ( item is BaseWeapon )
|
||||
ApplyAttribute( ((BaseWeapon)item).WeaponAttributes, (AosWeaponAttribute)attributes[i].Attribute, attributes[i].Amount );
|
||||
}
|
||||
else if ( attrType == typeof( AosElementAttribute ) )
|
||||
{
|
||||
if ( item is BaseWeapon )
|
||||
{
|
||||
switch ( (AosElementAttribute)attributes[i].Attribute )
|
||||
{
|
||||
case AosElementAttribute.Cold: cold = attributes[i].Amount; break;
|
||||
case AosElementAttribute.Energy: nrgy = attributes[i].Amount; break;
|
||||
case AosElementAttribute.Fire: fire = attributes[i].Amount; break;
|
||||
case AosElementAttribute.Poison: pois = attributes[i].Amount; break;
|
||||
case AosElementAttribute.Chaos: chaos = attributes[i].Amount; break;
|
||||
case AosElementAttribute.Direct: direct = attributes[i].Amount; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( attrType == typeof( ResistanceType ) )
|
||||
{
|
||||
if ( item is BaseArmor )
|
||||
ApplyResistance( (BaseArmor)item, (ResistanceType)attributes[i].Attribute, attributes[i].Amount );
|
||||
}
|
||||
}
|
||||
|
||||
if ( item is BaseWeapon )
|
||||
ApplyElementDamages( (BaseWeapon)item, cold, nrgy, fire, pois, chaos, direct );
|
||||
}
|
||||
}
|
||||
|
||||
public static void ApplyAttribute( AosAttributes attrs, AosAttribute attr, int amount )
|
||||
{
|
||||
if ( attr == AosAttribute.SpellChanneling && attrs.SpellChanneling == 0 )
|
||||
{
|
||||
attrs[attr] = 1;
|
||||
attrs.CastSpeed--;
|
||||
}
|
||||
else
|
||||
attrs[attr] += amount;
|
||||
}
|
||||
|
||||
public static void ApplyAttribute( AosArmorAttributes attrs, AosArmorAttribute attr, int amount )
|
||||
{
|
||||
if ( attr == AosArmorAttribute.MageArmor && attrs.MageArmor == 0 )
|
||||
attrs[attr] = 1;
|
||||
else
|
||||
attrs[attr] += amount;
|
||||
}
|
||||
|
||||
public static void ApplyAttribute( AosWeaponAttributes attrs, AosWeaponAttribute attr, int amount )
|
||||
{
|
||||
attrs[attr] += amount;
|
||||
}
|
||||
|
||||
public static void ApplyAttribute( AosElementAttributes attrs, AosElementAttribute attr, int amount )
|
||||
{
|
||||
attrs[attr] += amount;
|
||||
}
|
||||
|
||||
public static void ApplyElementDamages( BaseWeapon weapon, int cold, int nrgy, int fire, int pois, int chaos, int direct )
|
||||
{
|
||||
|
||||
int weapPhys, weapCold, weapNrgy, weapFire, weapPois, weapChaos, weapDirect;
|
||||
|
||||
weapon.GetDamageTypes( null, out weapPhys, out weapFire, out weapCold, out weapPois, out weapNrgy, out weapChaos, out weapDirect );
|
||||
|
||||
weapPhys = weapon.ApplyAttributeElementDamage( cold, ref weapCold, weapPhys );
|
||||
weapPhys = weapon.ApplyAttributeElementDamage( nrgy, ref weapNrgy, weapPhys );
|
||||
weapPhys = weapon.ApplyAttributeElementDamage( fire, ref weapFire, weapPhys );
|
||||
weapPhys = weapon.ApplyAttributeElementDamage( pois, ref weapPois, weapPhys );
|
||||
weapPhys = weapon.ApplyAttributeElementDamage( chaos, ref weapChaos, weapPhys );
|
||||
weapPhys = weapon.ApplyAttributeElementDamage( direct, ref weapDirect, weapPhys );
|
||||
|
||||
weapon.AosElementDamages.Physical = weapPhys;
|
||||
weapon.AosElementDamages.Cold = weapCold;
|
||||
weapon.AosElementDamages.Energy = weapNrgy;
|
||||
weapon.AosElementDamages.Fire = weapFire;
|
||||
weapon.AosElementDamages.Poison = weapPois;
|
||||
weapon.AosElementDamages.Chaos = weapChaos;
|
||||
weapon.AosElementDamages.Direct = weapDirect;
|
||||
}
|
||||
|
||||
public static void ApplyResistance( BaseArmor ar, ResistanceType res, int amount )
|
||||
{
|
||||
switch ( res )
|
||||
{
|
||||
case ResistanceType.Physical: ar.PhysicalBonus += amount; break;
|
||||
case ResistanceType.Fire: ar.FireBonus += amount; break;
|
||||
case ResistanceType.Cold: ar.ColdBonus += amount; break;
|
||||
case ResistanceType.Poison: ar.PoisonBonus += amount; break;
|
||||
case ResistanceType.Energy: ar.EnergyBonus += amount; break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ApplyDurability( Item item, int amount )
|
||||
{
|
||||
if ( item is IDurability )
|
||||
{
|
||||
IDurability durableItem = (IDurability)item;
|
||||
|
||||
durableItem.MaxHitPoints = ( ( 100 + amount ) * durableItem.MaxHitPoints ) / 100;
|
||||
|
||||
if ( durableItem.MaxHitPoints > 255 )
|
||||
durableItem.MaxHitPoints = 255;
|
||||
|
||||
durableItem.HitPoints = durableItem.MaxHitPoints; // Item is repaired upon enhancing
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Remove Attributes
|
||||
public static void RemoveAttrsFrom( Item item, BonusAttribute[] attributes )
|
||||
{
|
||||
if ( attributes != null && attributes.Length > 0 )
|
||||
{
|
||||
int cold = 0, nrgy = 0, fire = 0, pois = 0, chaos = 0, direct = 0;
|
||||
|
||||
for ( int i = 0; i < attributes.Length; i++ )
|
||||
{
|
||||
if ( attributes[i].Attribute == null )
|
||||
continue;
|
||||
|
||||
Type attrType = attributes[i].Attribute.GetType();
|
||||
|
||||
if ( attrType == typeof( AosAttribute ) )
|
||||
{
|
||||
if ( item is IAosAttributes )
|
||||
RemoveAttribute( ((IAosAttributes)item).Attributes, (AosAttribute)attributes[i].Attribute, attributes[i].Amount );
|
||||
}
|
||||
else if ( attrType == typeof( AosArmorAttribute ) )
|
||||
{
|
||||
if ( (AosArmorAttribute)attributes[i].Attribute == AosArmorAttribute.DurabilityBonus )
|
||||
RemoveDurability( item, attributes[i].Amount );
|
||||
else if ( item is BaseArmor )
|
||||
RemoveAttribute( ((BaseArmor)item).ArmorAttributes, (AosArmorAttribute)attributes[i].Attribute, attributes[i].Amount );
|
||||
else if ( item is BaseOtherEquipable )
|
||||
RemoveAttribute( ((BaseOtherEquipable)item).ArmorAttributes, (AosArmorAttribute)attributes[i].Attribute, attributes[i].Amount );
|
||||
}
|
||||
else if ( attrType == typeof( AosWeaponAttribute ) )
|
||||
{
|
||||
if ( (AosWeaponAttribute)attributes[i].Attribute == AosWeaponAttribute.DurabilityBonus )
|
||||
RemoveDurability( item, attributes[i].Amount );
|
||||
else if ( item is BaseWeapon )
|
||||
RemoveAttribute( ((BaseWeapon)item).WeaponAttributes, (AosWeaponAttribute)attributes[i].Attribute, attributes[i].Amount );
|
||||
}
|
||||
else if ( attrType == typeof( AosElementAttribute ) )
|
||||
{
|
||||
if ( item is BaseWeapon )
|
||||
{
|
||||
switch ( (AosElementAttribute)attributes[i].Attribute )
|
||||
{
|
||||
case AosElementAttribute.Cold: cold = attributes[i].Amount; break;
|
||||
case AosElementAttribute.Energy: nrgy = attributes[i].Amount; break;
|
||||
case AosElementAttribute.Fire: fire = attributes[i].Amount; break;
|
||||
case AosElementAttribute.Poison: pois = attributes[i].Amount; break;
|
||||
case AosElementAttribute.Chaos: chaos = attributes[i].Amount; break;
|
||||
case AosElementAttribute.Direct: direct = attributes[i].Amount; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( attrType == typeof( ResistanceType ) )
|
||||
{
|
||||
if ( item is BaseArmor )
|
||||
RemoveResistance( (BaseArmor)item, (ResistanceType)attributes[i].Attribute, attributes[i].Amount );
|
||||
}
|
||||
}
|
||||
|
||||
if ( item is BaseWeapon )
|
||||
RemoveElementDamages( (BaseWeapon)item, cold, nrgy, fire, pois, chaos, direct );
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveAttribute( AosAttributes attrs, AosAttribute attr, int amount )
|
||||
{
|
||||
if ( attr == AosAttribute.SpellChanneling && attrs.SpellChanneling > 0 )
|
||||
{
|
||||
attrs[attr] = 0;
|
||||
attrs.CastSpeed++;
|
||||
}
|
||||
else
|
||||
attrs[attr] = Math.Max( attrs[attr] - amount, 0 );
|
||||
}
|
||||
|
||||
public static void RemoveAttribute( AosArmorAttributes attrs, AosArmorAttribute attr, int amount )
|
||||
{
|
||||
if ( attr == AosArmorAttribute.MageArmor && attrs.MageArmor > 0 )
|
||||
attrs[attr] = 0;
|
||||
else
|
||||
attrs[attr] = Math.Max( attrs[attr] - amount, 0 );
|
||||
}
|
||||
|
||||
public static void RemoveAttribute( AosWeaponAttributes attrs, AosWeaponAttribute attr, int amount )
|
||||
{
|
||||
attrs[attr] = Math.Max( attrs[attr] - amount, 0 );
|
||||
}
|
||||
|
||||
public static void RemoveAttribute( AosElementAttributes attrs, AosElementAttribute attr, int amount )
|
||||
{
|
||||
attrs[attr] = Math.Max( attrs[attr] - amount, 0 );
|
||||
}
|
||||
|
||||
public static void RemoveElementDamages( BaseWeapon weapon, int cold, int nrgy, int fire, int pois, int chaos, int direct )
|
||||
{
|
||||
|
||||
int weapPhys, weapCold, weapNrgy, weapFire, weapPois, weapChaos, weapDirect;
|
||||
|
||||
weapon.GetDamageTypes( null, out weapPhys, out weapFire, out weapCold, out weapPois, out weapNrgy, out weapChaos, out weapDirect );
|
||||
|
||||
// Remove the element damages in reverse order they were applied in.
|
||||
|
||||
weapPhys = weapon.RemoveAttributeElementDamage( direct, ref weapDirect, weapPhys );
|
||||
weapPhys = weapon.RemoveAttributeElementDamage( chaos, ref weapChaos, weapPhys );
|
||||
weapPhys = weapon.RemoveAttributeElementDamage( pois, ref weapPois, weapPhys );
|
||||
weapPhys = weapon.RemoveAttributeElementDamage( fire, ref weapFire, weapPhys );
|
||||
weapPhys = weapon.RemoveAttributeElementDamage( nrgy, ref weapNrgy, weapPhys );
|
||||
weapPhys = weapon.RemoveAttributeElementDamage( cold, ref weapCold, weapPhys );
|
||||
|
||||
weapon.AosElementDamages.Physical = weapPhys;
|
||||
weapon.AosElementDamages.Cold = weapCold;
|
||||
weapon.AosElementDamages.Energy = weapNrgy;
|
||||
weapon.AosElementDamages.Fire = weapFire;
|
||||
weapon.AosElementDamages.Poison = weapPois;
|
||||
weapon.AosElementDamages.Chaos = weapChaos;
|
||||
weapon.AosElementDamages.Direct = weapDirect;
|
||||
}
|
||||
|
||||
public static void RemoveResistance( BaseArmor ar, ResistanceType res, int amount )
|
||||
{
|
||||
switch ( res )
|
||||
{
|
||||
case ResistanceType.Physical: ar.PhysicalBonus = Math.Max( ar.PhysicalBonus - amount, 0 ); break;
|
||||
case ResistanceType.Fire: ar.FireBonus = Math.Max( ar.ColdBonus - amount, 0 ); break;
|
||||
case ResistanceType.Cold: ar.ColdBonus = Math.Max( ar.FireBonus - amount, 0 ); break;
|
||||
case ResistanceType.Poison: ar.PoisonBonus = Math.Max( ar.PoisonBonus - amount, 0 ); break;
|
||||
case ResistanceType.Energy: ar.EnergyBonus = Math.Max( ar.EnergyBonus - amount, 0 ); break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveDurability( Item item, int amount )
|
||||
{
|
||||
if ( item is IDurability )
|
||||
{
|
||||
IDurability durableItem = (IDurability)item;
|
||||
|
||||
durableItem.MaxHitPoints = ( ( 100 + amount ) * durableItem.MaxHitPoints ) / 100;
|
||||
durableItem.HitPoints = durableItem.MaxHitPoints;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public sealed class BonusAttribute
|
||||
{
|
||||
private object m_Attribute;
|
||||
private int m_Amount;
|
||||
|
||||
public object Attribute{ get{ return m_Attribute; } }
|
||||
public int Amount{ get{ return m_Amount; } }
|
||||
|
||||
#region Constructors
|
||||
public BonusAttribute( AosAttribute attr, int amount ) : this( (object)attr, amount )
|
||||
{
|
||||
}
|
||||
|
||||
public BonusAttribute( AosArmorAttribute attr, int amount ) : this( (object)attr, amount )
|
||||
{
|
||||
}
|
||||
|
||||
public BonusAttribute( AosWeaponAttribute attr, int amount ) : this( (object)attr, amount )
|
||||
{
|
||||
}
|
||||
|
||||
public BonusAttribute( AosElementAttribute attr, int amount ) : this( (object)attr, amount )
|
||||
{
|
||||
}
|
||||
|
||||
public BonusAttribute( ResistanceType attr, int amount ) : this( (object)attr, amount )
|
||||
{
|
||||
}
|
||||
|
||||
private BonusAttribute( object attr, int amount )
|
||||
{
|
||||
m_Attribute = attr;
|
||||
m_Amount = amount;
|
||||
}
|
||||
|
||||
public BonusAttribute( GenericReader reader )
|
||||
{
|
||||
Deserialize( reader );
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.Write( (int) 0 ); // version
|
||||
|
||||
writer.Write( m_Attribute.GetType().ToString() ); // Enum type
|
||||
writer.Write( m_Attribute.ToString() ); // Enum value
|
||||
writer.Write( (int) m_Amount );
|
||||
}
|
||||
|
||||
public void Deserialize( GenericReader reader )
|
||||
{
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
string type = reader.ReadString();
|
||||
string enumValue = reader.ReadString();
|
||||
|
||||
try {
|
||||
m_Attribute = Enum.Parse( Type.GetType( type ), enumValue );
|
||||
}
|
||||
catch {
|
||||
Console.WriteLine( "Unable to create Enum of type {0} with value of {1}.", type, enumValue );
|
||||
}
|
||||
|
||||
m_Amount = reader.ReadInt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -65,31 +65,19 @@ namespace Server.Items
|
|||
public class FlipableAttribute : Attribute
|
||||
{
|
||||
private int[] m_ItemIDs;
|
||||
private bool m_IsDynamicFlipable;
|
||||
|
||||
public int[] ItemIDs
|
||||
{
|
||||
get { return m_ItemIDs; }
|
||||
}
|
||||
|
||||
public bool IsDynamicFlipable
|
||||
{
|
||||
get { return m_IsDynamicFlipable; }
|
||||
}
|
||||
|
||||
public FlipableAttribute()
|
||||
: this( null )
|
||||
{
|
||||
}
|
||||
|
||||
public FlipableAttribute( params int[] itemIDs )
|
||||
: this( true, itemIDs )
|
||||
public FlipableAttribute( params int[] itemIDs )
|
||||
{
|
||||
}
|
||||
|
||||
public FlipableAttribute( bool isDynamicFlipable, params int[] itemIDs)
|
||||
{
|
||||
m_IsDynamicFlipable = isDynamicFlipable;
|
||||
m_ItemIDs = itemIDs;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,11 +8,9 @@ using Server.Prompts;
|
|||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.ContextMenus;
|
||||
using Server.Engines.Craft;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
[CraftItemID( 0x2311 )]
|
||||
public class PlayerBBSouth : BasePlayerBB
|
||||
{
|
||||
public override int LabelNumber{ get{ return 1062421; } } // bulletin board (south)
|
||||
|
|
@ -42,7 +40,6 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
|
||||
[CraftItemID( 0x2312 )]
|
||||
public class PlayerBBEast : BasePlayerBB
|
||||
{
|
||||
public override int LabelNumber{ get{ return 1062420; } } // bulletin board (east)
|
||||
|
|
@ -72,15 +69,12 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
|
||||
public abstract class BasePlayerBB : Item, ISecurable, ICraftable
|
||||
public abstract class BasePlayerBB : Item, ISecurable
|
||||
{
|
||||
private PlayerBBMessage m_Greeting;
|
||||
private List<PlayerBBMessage> m_Messages;
|
||||
private string m_Title;
|
||||
private SecureLevel m_Level;
|
||||
|
||||
private Mobile m_Crafter;
|
||||
private CraftQuality m_Quality;
|
||||
|
||||
public List<PlayerBBMessage> Messages
|
||||
{
|
||||
|
|
@ -106,20 +100,6 @@ namespace Server.Items
|
|||
get{ return m_Level; }
|
||||
set{ m_Level = value; }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public Mobile Crafter
|
||||
{
|
||||
get { return m_Crafter; }
|
||||
set { m_Crafter = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public CraftQuality Quality
|
||||
{
|
||||
get { return m_Quality; }
|
||||
set { m_Quality = value; InvalidateProperties(); }
|
||||
}
|
||||
|
||||
public BasePlayerBB( int itemID ) : base( itemID )
|
||||
{
|
||||
|
|
@ -130,17 +110,6 @@ namespace Server.Items
|
|||
public BasePlayerBB( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
|
||||
if ( m_Crafter != null )
|
||||
list.Add( 1050043, m_Crafter.Name ); // crafted by ~1_NAME~
|
||||
|
||||
if ( m_Quality == CraftQuality.Exceptional )
|
||||
list.Add( 1060636 ); // exceptional
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
|
||||
{
|
||||
|
|
@ -152,10 +121,7 @@ namespace Server.Items
|
|||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 2 );
|
||||
|
||||
writer.Write( m_Crafter );
|
||||
writer.WriteEncodedInt( (int) m_Quality );
|
||||
writer.Write( (int) 1 );
|
||||
|
||||
writer.Write( (int) m_Level );
|
||||
|
||||
|
|
@ -185,12 +151,6 @@ namespace Server.Items
|
|||
|
||||
switch ( version )
|
||||
{
|
||||
case 2:
|
||||
{
|
||||
m_Crafter = reader.ReadMobile();
|
||||
m_Quality = (CraftQuality)reader.ReadEncodedInt();
|
||||
goto case 1;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
m_Level = (SecureLevel)reader.ReadInt();
|
||||
|
|
@ -200,9 +160,6 @@ namespace Server.Items
|
|||
{
|
||||
if ( version < 1 )
|
||||
m_Level = SecureLevel.Anyone;
|
||||
|
||||
if ( version < 2 )
|
||||
m_Quality = CraftQuality.Regular;
|
||||
|
||||
m_Title = reader.ReadString();
|
||||
|
||||
|
|
@ -218,7 +175,7 @@ namespace Server.Items
|
|||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CheckAccess( BaseHouse house, Mobile from )
|
||||
|
|
@ -240,31 +197,6 @@ namespace Server.Items
|
|||
else if ( CheckAccess( house, from ) )
|
||||
from.SendGump( new PlayerBBGump( from, house, this, 0 ) );
|
||||
}
|
||||
|
||||
public virtual int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue )
|
||||
{
|
||||
if ( Core.ML )
|
||||
{
|
||||
Quality = (CraftQuality)quality;
|
||||
|
||||
if ( makersMark )
|
||||
Crafter = from;
|
||||
|
||||
Type resourceType = typeRes;
|
||||
|
||||
if ( resourceType == null )
|
||||
resourceType = craftItem.Resources.GetAt( 0 ).ItemType;
|
||||
|
||||
Hue = CraftResources.GetHue( CraftResources.GetFromType( resourceType ) );
|
||||
|
||||
CraftContext context = craftSystem.GetContext( from );
|
||||
|
||||
if ( context != null && context.DoNotColor )
|
||||
Hue = 0;
|
||||
}
|
||||
|
||||
return quality;
|
||||
}
|
||||
|
||||
public class PostPrompt : Prompt
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue