Kouri
Member
I get this error when I'm trying to add my mobile.
The script in question is just a modified elf brigand script, but, here it is.
The error calls out a line from Mobile.cs, here is that section and line. (Marked with arrow)
Code:
00:15:55 System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. ---> System.NullReferenceException: Object refer
ence not set to an instance of an object.
at Server.Items.BaseArmor.OnAdded(Object parent)
at Server.Mobile.AddItem(Item item) in c:\Users\BackUp-POS\Desktop\ServUO-mas
ter\Server\Mobile.cs:line 6658
at Server.Mobiles.DrowLord..ctor()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeConstructor(IRuntimeMethodInfo method, O
bject[] args, SignatureStruct& signature, RuntimeType declaringType)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, B
inder binder, Object[] parameters, CultureInfo culture)
at Server.Commands.Add.Build(Mobile from, ConstructorInfo ctor, Object[] valu
es, String[,] props, PropertyInfo[] realProps, Boolean& sendError)
at Server.Commands.Add.Build(Mobile from, Point3D start, Point3D end, Constru
ctorInfo ctor, Object[] values, String[,] props, PropertyInfo[] realProps, List`
1 packs, Boolean outline, Boolean mapAvg)
The script in question is just a modified elf brigand script, but, here it is.
Code:
using System;
using Server.Items;
namespace Server.Mobiles
{
[CorpseName("an elf corpse")]
public class DrowArcher : BaseCreature
{
[Constructable]
public DrowArcher() : base(AIType.AI_Archer, FightMode.Closest, 10, 1, 0.2, 0.4)// TODO spellweaving AI
{
this.Race = Race.Elf;
if (this.Female = Utility.RandomBool())
{
this.Body = 606;
this.Name = NameList.RandomName("Elf Female");
}
else
{
this.Body = 605;
this.Name = NameList.RandomName("Elf Male");
}
this.Title = "drow archer";
this.Hue = this.Race.RandomSkinHue();
this.SetStr(86, 100);
this.SetDex(81, 95);
this.SetInt(61, 75);
this.SetDamage(10, 23);
this.SetStr( 96, 115 );
this.SetDex( 86, 105 );
this.SetInt( 51, 65 );
this.SetDamage( 23, 27 );
this.SetDamageType( ResistanceType.Physical, 100 );
this.SetResistance(ResistanceType.Physical, 10, 15);
this.SetResistance(ResistanceType.Fire, 10, 15);
this.SetResistance(ResistanceType.Cold, 10, 15);
this.SetResistance(ResistanceType.Poison, 10, 15);
this.SetResistance(ResistanceType.Energy, 10, 15);
this.SetSkill( SkillName.Archery, 60.0, 82.5 );
this.SetSkill( SkillName.Poisoning, 60.0, 82.5 );
this.SetSkill( SkillName.MagicResist, 57.5, 80.0 );
this.SetSkill( SkillName.Swords, 60.0, 82.5 );
this.SetSkill( SkillName.Tactics, 60.0, 82.5 );
this.Fame = 5000;
this.Karma = -5000;
this.VirtualArmor = 28;
this.AddItem(new Shirt(Utility.RandomNeutralHue()));
switch ( Utility.Random( 2 ) )
{
case 0:
{
this.AddItem(new LeafChest(Utility.RandomBlueHue()));
this.AddItem(new LeafArms(Utility.RandomBlueHue()));
this.AddItem(new LeafGorget(Utility.RandomBlueHue()));
this.AddItem(new LeafGloves(Utility.RandomBlueHue()));
switch ( Utility.Random( 2 ) )
{
case 0:this.AddItem(new LeafLegs(Utility.RandomBlueHue())); break;
case 1:this.AddItem(new LeafTonlet(Utility.RandomBlueHue())); break;
}
} break;
case 1:
{
this.AddItem(new HideChest(Utility.RandomBlueHue()));
this.AddItem(new HidePauldrons(Utility.RandomBlueHue()));
this.AddItem(new HideGorget(Utility.RandomBlueHue()));
this.AddItem(new HideGloves(Utility.RandomBlueHue()));
this.AddItem(new HidePants(Utility.RandomBlueHue()));
} break;
}
switch (Utility.Random( 4 ))
{
case 1: this.AddItem(new RavenHelm(1175)); break;
case 2: this.AddItem(new VultureHelm(1175)); break;
case 3: this.AddItem(new WingedHelm(1175)); break;
}
switch (Utility.Random(4))
{
case 0:this.AddItem(new Sandals()); break;
case 1:this.AddItem(new ElvenBoots()); break;
case 2:this.AddItem(new Boots()); break;
case 3:this.AddItem(new ThighBoots()); break;
}
this.HairItemID = this.Race.RandomHair(this.Female);
this.HairHue = this.Race.RandomHairHue();
switch ( Utility.Random( 2 ) )
{
case 0:
{
this.AddItem( new RepeatingCrossbow() );
this.PackItem( new Bolt( Utility.Random( 50, 120 ) ) );
}break;
case 1:
{
this.AddItem( new ElvenCompositeLongbow() );
this.PackItem( new Arrow( Utility.Random( 50, 120 ) ) );
}break;
}
}
public override void GenerateLoot()
{
this.AddLoot( LootPack.Average, 3 );
this.PackMagicItems( 1, 2 );
this.PackItem( new Bandage( Utility.RandomMinMax( 1, 15 ) ) );
}
public DrowArcher(Serial serial) : base(serial)
{
}
public override OppositionGroup OppositionGroup
{
get{ return OppositionGroup.ElvesAndDrow; }
}
public override bool AlwaysMurderer{ get{ return true; } }
public override bool ShowFameTitle{ get{ return false; } }
public override bool CanRummageCorpses{ get{ return true; } }
public override void OnDeath(Container c)
{
base.OnDeath(c);
if (Utility.RandomDouble() < 0.75)
c.DropItem(new SeveredElfEars());
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
}
The error calls out a line from Mobile.cs, here is that section and line. (Marked with arrow)
Code:
public void AddItem(Item item)
{
if (item == null || item.Deleted)
{
return;
}
if (item.Parent == this)
{
return;
}
else if (item.Parent is Mobile)
{
((Mobile)item.Parent).RemoveItem(item);
}
else if (item.Parent is Item)
{
((Item)item.Parent).RemoveItem(item);
}
else
{
item.SendRemovePacket();
}
item.Parent = this;
item.Map = m_Map;
m_Items.Add(item);
if (!item.IsVirtualItem)
{
UpdateTotal(item, TotalType.Gold, item.TotalGold);
UpdateTotal(item, TotalType.Items, item.TotalItems + 1);
UpdateTotal(item, TotalType.Weight, item.TotalWeight + item.PileWeight);
}
item.Delta(ItemDelta.Update);
-------->> item.OnAdded(this);
OnItemAdded(item);
if (item.PhysicalResistance != 0 || item.FireResistance != 0 || item.ColdResistance != 0 ||
item.PoisonResistance != 0 || item.EnergyResistance != 0)
{
UpdateResistances();
}
}