Creating a new weapon property.
Ok, instead of posting my whole BaseWeapon Script, I figured I would just post the variable, and the error that occurs.
I have a variable defined by my Critical system called Crit.
I would like weapons to have a Crit rating defined in base weapon.
For serialization I changed version to 9 from 8.
What works:
When I add a weapon, and use [props to change its CritRate, and equip the item, the Crit value on the playermobile changes.
What doesn't work:
Deserialization! When I save the server and reload, it prompts me to delete all Baseweapons.
Adding via override on weapon script.
This shoots an error in the compiler that the variable isn't writable.
Any suggestions on what I'm doing wrong?
Ok, instead of posting my whole BaseWeapon Script, I figured I would just post the variable, and the error that occurs.
I have a variable defined by my Critical system called Crit.
I would like weapons to have a Crit rating defined in base weapon.
Code:
//Custom
private int m_CritRate;
//Custom
[CommandProperty( AccessLevel.GameMaster )]
public int CritRate
{
get{ return ( m_CritRate ); }
set{ m_CritRate = CritRate; InvalidateProperties();}
}
public override bool OnEquip( Mobile from )
{
//Crit Droth
if ( CritRate != 0 )
{
PlayerMobile pmfrom = from as PlayerMobile;
pmfrom.Crit += m_CritRate;
return base.OnEquip( from );
}
{
For serialization I changed version to 9 from 8.
Code:
writer.Write( (int) m_CritRate );
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 9:
{
Critical = reader.ReadInt();
m_CritRate = reader.ReadInt();
goto case 8;
}
What works:
When I add a weapon, and use [props to change its CritRate, and equip the item, the Crit value on the playermobile changes.
What doesn't work:
Deserialization! When I save the server and reload, it prompts me to delete all Baseweapons.
Adding via override on weapon script.
Code:
public override int CritRate{ get{ return 5; } }
This shoots an error in the compiler that the variable isn't writable.
Any suggestions on what I'm doing wrong?