Full Version : Deserialize problem
xmlspawner >>Scripting Support >>Deserialize problem
<< Prev | Next >>
olsyke- 06-30-2006
ah a pretty similar problem just occured for me... i tried to use the adcanced archery script but couldnt get the part with deserialisation to work... now everytime i wanna boot it asks me for a differend item to delete... its not even only Žbows its anything really...
what can i do ?
ArteGordon- 06-30-2006

QUOTE (olsyke @ June 30, 2006 11:12 am)
ah a pretty similar problem just occured for me... i tried to use the adcanced archery script but couldnt get the part with deserialisation to work... now everytime i wanna boot it asks me for a differend item to delete... its not even only Žbows its anything really...
what can i do ?

that sounds like a different problem.
I believe that system has you change the serialization of certain base classes, so once you make a save with that system in place, you cannot just remove it, you have to back out of the serialization/deserialization in those classes.
If you have messed up the ser/deser, your best bet is to go back to a backup from before installing that system.
olsyke- 06-30-2006
hehe absolutly no idea how to do this ^^ but i actually wanna use the system not get rid of it
ArteGordon- 06-30-2006
you are going to have to post the scripts with the modified serialize/deserialize methods to figure out how to recover.
olsyke- 06-30-2006
as far as i know its only the bows itself causing this so it probly is the same step for every bow's.cs

CODE
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); if (Weight == 7.0)
Weight = 6.0;
if (version == 0)
version = 1;
switch ( version )
{
case 1:
{
m_ArrowType = (ArrowType)reader.ReadEncodedInt();
goto case 0;
}
case 0:
{
break;
}
}
}
}
}

somewhere around here
ArteGordon- 06-30-2006

QUOTE
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); if (Weight == 7.0)
Weight = 6.0;
if (version == 0)
version = 1;
switch ( version )
{
case 1:
{
m_ArrowType = (ArrowType)reader.ReadEncodedInt();
goto case 0;
}
case 0:
{
break;
}
}
}

I would remove the code in red.
Since this new bow is derived from the CBaseRanged which may have a different serialization/deserialization from the normal BaseRanged class, that could also cause problems.
You would have to post that script as well to figure that out.
olsyke- 06-30-2006

CODE
/* _________________________________ -=(_)_______________________________)=- / . . . ____ . ___ _/ /~ / / / / / / )2005 / (~ (____(___/ (____ / /___/ (
\ ----------------------------- \
\ lucidnagual@gmail.com \
\_ =================== \
\ -Admin of "The Conjuring"- \
\_ =================== ~\
) Advanced Archery )
/~ Version [2].0.1 _/
_/_______________________________/
-=(_)_______________________________)=-
*/
using System;
using Server.Items;
using Server.Network;
using Server.Spells;
using Server.Mobiles;
namespace Server.Items
{
public abstract class CBaseRanged : BaseMeleeWeapon
{
public static readonly TimeSpan PlayerFreezeDuration = TimeSpan.FromSeconds(3.0);
public static readonly TimeSpan NPCFreezeDuration = TimeSpan.FromSeconds(6.0);
public abstract int EffectID { get; }
public abstract Type AmmoType { get; }
public abstract Item Ammo { get; }
public override int DefHitSound { get { return 0x234; } }
public override int DefMissSound { get { return 0x238; } }
public override SkillName DefSkill { get { return SkillName.Archery; } }
public override WeaponType DefType { get { return WeaponType.Ranged; } }
public override WeaponAnimation DefAnimation { get { return WeaponAnimation.ShootXBow; } }
public override SkillName AccuracySkill { get { return SkillName.Archery; } }
public CBaseRanged( int itemID ) : base( itemID )
{
}
public CBaseRanged(Serial serial) : base( serial )
{
}
public override void OnDoubleClick( Mobile from )
{
base.OnDoubleClick( from );
}
public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
{
// Make sure we've been standing still for one second
if (DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds(Core.AOS ? 0.5 : 1.0)) || (Core.AOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot))
{
bool canSwing = true;
if (Core.AOS)
{
canSwing = (!attacker.Paralyzed && !attacker.Frozen);
if (canSwing)
{
Spell sp = attacker.Spell as Spell;
canSwing = (sp == null || !sp.IsCasting || !sp.BlocksMovement);
}
}
if (canSwing && attacker.HarmfulCheck(defender))
{
attacker.DisruptiveAction();
attacker.Send(new Swing(0, attacker, defender));
/*bool doubleS = false;
WeaponAbility ability = WeaponAbility.GetCurrentAbility(attacker);
if (ability is DoubleShot && ((int)(Math.Max(attacker.Skills[SkillName.Bushido].Value, attacker.Skills[SkillName.Ninjitsu].Value))) >= Utility.Random(130))
doubleS = true;*/
if (OnFired(attacker, defender))
{
if (CheckHit(attacker, defender))
OnHit(attacker, defender);
else
OnMiss(attacker, defender);
//if (doubleS) OnSwing(attacker, defender);
}
}
return GetDelay(attacker);
}
else
{
return TimeSpan.FromSeconds(0.25);
}
}
public override void OnHit(Mobile attacker, Mobile defender)
{
if ( attacker == null || defender == null )
return;
if (AmmoType == typeof( PoisonArrow ) )
{
switch (Utility.Random(4))
{
case 0: defender.ApplyPoison(defender, Poison.Deadly);
defender.FixedParticles(0x3728, 200, 25, 69, EffectLayer.Waist); break;
case 1: defender.ApplyPoison(defender, Poison.Greater);
defender.FixedParticles(0x3728, 200, 25, 69, EffectLayer.Waist); break;
case 2: defender.ApplyPoison(defender, Poison.Regular);
defender.FixedParticles(0x3728, 200, 25, 69, EffectLayer.Waist); break;
case 3: defender.ApplyPoison(defender, Poison.Lesser);
defender.FixedParticles(0x3728, 200, 25, 69, EffectLayer.Waist); break;
}
}
else if (AmmoType == typeof( PoisonBolt ) )
{
switch (Utility.Random(4))
{
case 0: defender.ApplyPoison(defender, Poison.Deadly);
defender.FixedParticles(0x3728, 200, 25, 69, EffectLayer.Waist); break;
case 1: defender.ApplyPoison(defender, Poison.Greater);
defender.FixedParticles(0x3728, 200, 25, 69, EffectLayer.Waist); break;
case 2: defender.ApplyPoison(defender, Poison.Regular);
defender.FixedParticles(0x3728, 200, 25, 69, EffectLayer.Waist); break;
case 3: defender.ApplyPoison(defender, Poison.Lesser);
defender.FixedParticles(0x3728, 200, 25, 69, EffectLayer.Waist); break;
}
}
else if (AmmoType == typeof( ExplosiveArrow ) )
{
switch (Utility.Random(3))
{
case 0: defender.FixedParticles(0x36BD, 20, 10, 5044, EffectLayer.Waist);
defender.PlaySound(0x307);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(10, 50), 0, 100, 0, 0, 0); break;
case 1: defender.FixedParticles(0x36BD, 20, 10, 5044, EffectLayer.Waist);
defender.PlaySound(0x307);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(30, 70), 0, 100, 0, 0, 0); break;
case 2: defender.FixedParticles(0x36BD, 20, 10, 5044, EffectLayer.Waist);
defender.PlaySound(0x307);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(50, 100), 0, 100, 0, 0, 0); break;
}
}
else if (AmmoType == typeof( ExplosiveBolt ) )
{
switch (Utility.Random(3))
{
case 0: defender.FixedParticles(0x36BD, 20, 10, 5044, EffectLayer.Waist);
defender.PlaySound(0x307);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(10, 50), 0, 100, 0, 0, 0); break;
case 1: defender.FixedParticles(0x36BD, 20, 10, 5044, EffectLayer.Waist);
defender.PlaySound(0x307);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(30, 70), 0, 100, 0, 0, 0); break;
case 2: defender.FixedParticles(0x36BD, 20, 10, 5044, EffectLayer.Waist);
defender.PlaySound(0x307);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(50, 100), 0, 100, 0, 0, 0); break;
}
}
else if (AmmoType == typeof( ArmorPiercingArrow ) )
{
switch (Utility.Random(3))
{
case 0: defender.PlaySound(0x56);
defender.FixedParticles(0x3728, 200, 25, 9942, EffectLayer.Waist);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(10, 50), 100, 0, 0, 0, 0); break;
case 1: defender.PlaySound(0x56);
defender.FixedParticles(0x3728, 200, 25, 9942, EffectLayer.Waist);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(30, 70), 100, 0, 0, 0, 0); break;
case 2: defender.PlaySound(0x56);
defender.FixedParticles(0x3728, 200, 25, 9942, EffectLayer.Waist);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(50, 100), 100, 0, 0, 0, 0); break;
}
}
else if (AmmoType == typeof( ArmorPiercingBolt ) )
{
switch (Utility.Random(3))
{
case 0: defender.PlaySound(0x56);
defender.FixedParticles(0x3728, 200, 25, 9942, EffectLayer.Waist);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(10, 50), 100, 0, 0, 0, 0); break;
case 1: defender.PlaySound(0x56);
defender.FixedParticles(0x3728, 200, 25, 9942, EffectLayer.Waist);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(30, 70), 100, 0, 0, 0, 0); break;
case 2: defender.PlaySound(0x56);
defender.FixedParticles(0x3728, 200, 25, 9942, EffectLayer.Waist);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(50, 100), 100, 0, 0, 0, 0); break;
}
}
else if (AmmoType == typeof( FreezeArrow ) )
{
switch (Utility.Random(3))
{
case 0: defender.PlaySound(0x204);
defender.Freeze(defender.Player ? PlayerFreezeDuration : NPCFreezeDuration);
defender.FixedEffect(0x376A, 9, 32);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(10, 50), 0, 0, 100, 0, 0); break;
case 1: defender.PlaySound(0x204);
defender.Freeze(defender.Player ? PlayerFreezeDuration : NPCFreezeDuration);
defender.FixedEffect(0x376A, 9, 32);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(30, 70), 0, 0, 100, 0, 0); break;
case 2: defender.PlaySound(0x204);
defender.Freeze(defender.Player ? PlayerFreezeDuration : NPCFreezeDuration);
defender.FixedEffect(0x376A, 9, 32);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(50, 100), 0, 0, 100, 0, 0); break;
}
}
else if (AmmoType == typeof( FreezeBolt ) )
{
switch (Utility.Random(3))
{
case 0: defender.PlaySound(0x204);
defender.Freeze(defender.Player ? PlayerFreezeDuration : NPCFreezeDuration);
defender.FixedEffect(0x376A, 9, 32);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(10, 50), 0, 0, 100, 0, 0); break;
case 1: defender.PlaySound(0x204);
defender.Freeze(defender.Player ? PlayerFreezeDuration : NPCFreezeDuration);
defender.FixedEffect(0x376A, 9, 32);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(30, 70), 0, 0, 100, 0, 0); break;
case 2: defender.PlaySound(0x204);
defender.Freeze(defender.Player ? PlayerFreezeDuration : NPCFreezeDuration);
defender.FixedEffect(0x376A, 9, 32);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(50, 100), 0, 0, 100, 0, 0); break;
}
}
else if (AmmoType == typeof( LightningArrow ) )
{
switch (Utility.Random(3))
{
case 0: defender.PlaySound(1471);
defender.BoltEffect(0);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(10, 50), 100, 0, 0, 0, 0); break;
case 1: defender.PlaySound(1471);
defender.BoltEffect(0);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(30, 70), 100, 0, 0, 0, 0); break;
case 2: defender.PlaySound(1471);
defender.BoltEffect(0);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(50, 100), 100, 0, 0, 0, 0); break;
}
}
else if (AmmoType == typeof( LightningBolt ) )
{
switch (Utility.Random(3))
{
case 0: defender.PlaySound(1471);
defender.BoltEffect(0);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(10, 50), 100, 0, 0, 0, 0); break;
case 1: defender.PlaySound(1471);
defender.BoltEffect(0);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(30, 70), 100, 0, 0, 0, 0); break;
case 2: defender.PlaySound(1471);
defender.BoltEffect(0);
attacker.DoHarmful(defender);
AOS.Damage(defender, attacker, Utility.RandomMinMax(50, 100), 100, 0, 0, 0, 0); break;
}
}
else if (Ammo == null)
attacker.SendMessage("You are out of arrows, or may have to choose a different type of arrow by double clicking the bow.");
if (attacker.Player && !defender.Player && (defender.Body.IsAnimal || defender.Body.IsMonster) && 0.4 >= Utility.RandomDouble())
defender.AddToBackpack(Ammo);
base.OnHit(attacker, defender);
}
public override void OnMiss(Mobile attacker, Mobile defender)
{
if ( attacker == null || defender == null )
return;
if (attacker.Player && 0.4 >= Utility.RandomDouble())
Ammo.MoveToWorld(new Point3D(defender.X + Utility.RandomMinMax(-1, 1), defender.Y + Utility.RandomMinMax(-1, 1), defender.Z), defender.Map);
base.OnMiss(attacker, defender);
}
public virtual bool OnFired( Mobile attacker, Mobile defender )
{
Container pack = attacker.Backpack;
Container quiver = attacker.FindItemOnLayer(Layer.MiddleTorso) as Container;
if ( attacker == null || defender == null || pack == null || quiver == null )
return false;
//dracana - chance to not consume ammo if quiver equipped
if ( attacker.Player && (((BaseQuiver)quiver).LowerAmmoCost > Utility.Random( 100 )) )
return true;
if ( attacker.Player && ( quiver == null || !quiver.ConsumeTotal( AmmoType, 1 )))
return false;
if ( attacker.Player && ( pack == null || !pack.ConsumeTotal( AmmoType, 1 )))
return false;
attacker.MovingEffect( defender, EffectID, 18, 1, false, false );
return true;
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)2); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 2:
case 1:
{
break;
}
case 0:
{
/*m_EffectID =*/
reader.ReadInt();
break;
}
}
if (version < 2)
{
WeaponAttributes.MageWeapon = 0;
WeaponAttributes.UseBestSkill = 0;
}
}
}
}

here it comes
ArteGordon- 06-30-2006
looks ok. Just make the change I posted.
olsyke- 06-30-2006
ok gonna go for it right away....
another thing besieds... i read you got shard and diddnt know ! whats the url ?
*EDIT
okay tried it but it still came up with wanting to delete a wooden.chest
there is also another warning about serialisation maybe thats got something to do with it ?
ArteGordon- 06-30-2006

QUOTE (olsyke @ June 30, 2006 11:34 am)
ok gonna go for it right away.... another thing besieds... i read you got shard and diddnt know ! whats the url ?

it's a private shard. just friends and family.
olsyke- 06-30-2006
ahh for update view above...
0.o does it even pay writing such a great system just for a private shard !?
ArteGordon- 06-30-2006

QUOTE (olsyke @ June 30, 2006 11:34 am)
ok gonna go for it right away.... another thing besieds... i read you got shard and diddnt know ! whats the url ? *EDIT okay tried it but it still came up with wanting to delete a wooden.chest there is also another warning about serialisation maybe thats got something to do with it ?

those are different errors resulting from some other change that you must have made to the serialization of some other class, probably the container class.
The basetub error is yet a different error which is something in your custom basetub script (I dont know what that class is).
olsyke- 06-30-2006
well okay im gonna search around... but actually ist also deletes pottet plants and whatever you want ....
ArteGordon- 06-30-2006
did you just add that one custom system?
olsyke- 06-30-2006
yeah i did... but just sumbled upon something !
the quivers delivered along with the system are containers aswell !

CODE
public override void Deserialize( GenericReader reader ) { base.Deserialize( reader ); int version = reader.ReadInt(); switch ( version )
{
case 2:
{
m_Redux = reader.ReadDouble();
goto case 1;
}
case 1:
{
m_LowerAmmoCost = reader.ReadInt();
goto case 0;
}
case 0:
{
m_Crafter = reader.ReadMobile();
m_AosAttributes = new AosAttributes( this, reader );
m_AosSkillBonuses = new AosSkillBonuses( this, reader );
m_Owner = (Mobile) reader.ReadMobile();
break;
}
}
}
}
}

would it work just like this ?

CODE
[COLOR=red]/[/COLOR]base.Deserialize( reader ); [COLOR=red] /[/COLOR]int version = reader.ReadInt();

*edit awww just learned not to use code tags within [code][/code] ^^