Lemke

Member
Hello guys,just getting server crash when using shrink on item with the next coded on the shrinkcommand:
Here the target code:

C#:
protected override void OnTarget( Mobile from, object target )
        {
            BaseCreature pet = target as BaseCreature;

            if ( target == from )
                from.SendMessage( "You cannot shrink yourself!" );
            else if ( pet.Allured )
                from.SendMessage( "You cannot shrink a summoned creature!" );
            else if ( target is BaseTalismanSummon )
                from.SendMessage( "You cannot shrink a summoned creature!" );
            //////////////////////
                else if ( pet.Poisoned )
                from.SendMessage( "You cannot shrink a poisoned pet!" );
                else if ( pet.Hits != pet.HitsMax )
                from.SendMessage( "You cannot shrink your pet without full hits!" );
                else if ( pet.Str != pet.RawStr )
                from.SendMessage( "You cannot shrink your pet his stats are under magic effect!" );
                else if ( pet.Dex != pet.RawDex )
                from.SendMessage( "You cannot shrink your pet his stats are under magic effect!" );
                else if ( pet.Int != pet.RawInt )
                from.SendMessage( "You cannot shrink your pet his stats are under magic effect!" );
                /////////////////////////
            else if ( target is Item )
                from.SendMessage( "You cannot shrink that!" );
            else if ( target is EtherealMount )
                from.SendMessage( "You cannot shrink that!" );

            else if ( target is PlayerMobile )
                from.SendMessage( "That person gives you a dirty look!" );

            else if ( Server.Spells.SpellHelper.CheckCombat( from ) )
                from.SendMessage( "You cannot shrink your pet while you are fighting." );

            else if ( pet == null )
                from.SendMessage( "That is not a pet!" );

            else if ( ( pet.BodyValue == 400 || pet.BodyValue == 401 ) && pet.Controlled == false )
                from.SendMessage( "That person gives you a dirty look!" );

            else if ( pet.IsDeadPet )
                from.SendMessage( "You cannot shrink the dead!" );

            else if ( pet.Summoned )
                from.SendMessage( "You cannot shrink a summoned creature!" );

            else if ( !m_StaffCommand && pet.Combatant != null && pet.InRange( pet.Combatant, 12 ) && pet.Map == pet.Combatant.Map )
                from.SendMessage( "Your pet is fighting; you cannot shrink it yet." );

            else if ( pet.BodyMod != 0 )
                from.SendMessage( "You cannot shrink your pet while it is polymorphed." );

            else if ( !m_StaffCommand && pet.Controlled == false )
                from.SendMessage( "You cannot not shrink wild creatures." );

            else if ( !m_StaffCommand && pet.ControlMaster != from )
                from.SendMessage( "That is not your pet." );

            else if ( !m_StaffCommand && ShrinkItem.IsPackAnimal( pet ) && ( null != pet.Backpack && pet.Backpack.Items.Count > 0 ) )
                from.SendMessage( "You must unload this pet's pack before it can be shrunk." );

            else
            {
                if ( pet.ControlMaster != from && !pet.Controlled )
                {
                    SpawnEntry se = pet.Spawner as SpawnEntry;
                    if ( se != null && se.UnlinkOnTaming )
                    {
                        pet.Spawner.Remove((ISpawnable)pet);
                        pet.Spawner = null;
                    }

                    pet.CurrentWayPoint = null;
                    pet.ControlMaster = from;
                    pet.Controlled = true;
                    pet.ControlTarget = null;
                    pet.ControlOrder = OrderType.Come;
                    pet.Guild = null;
                    pet.Delta( MobileDelta.Noto );
                }

                IEntity p1 = new Entity( Serial.Zero, new Point3D( from.X, from.Y, from.Z ), from.Map );
                IEntity p2 = new Entity( Serial.Zero, new Point3D( from.X, from.Y, from.Z + 50 ), from.Map );

                Effects.SendMovingParticles( p2, p1, ShrinkTable.Lookup( pet ), 1, 0, true, false, 0, 3, 1153, 1, 0, EffectLayer.Head, 0x100 );
                from.PlaySound( 492 );
                from.AddToBackpack( new ShrinkItem( pet ) );

                if ( !m_StaffCommand && null != m_ShrinkTool && m_ShrinkTool.ShrinkCharges > 0 )
                    m_ShrinkTool.ShrinkCharges--;
            }
        }
Here the error im getting:

C#:
ServUO Version 0.5, Build 6996.26785
Operating System: Microsoft Windows NT 6.2.9200.0
.NET Framework: 4.0.30319.42000
Time: 03/24/2020 17:02:47
Mobiles: 45380
Items: 437783
Exception:
System.NullReferenceException: Object reference not set as an instance of an object.
   in Xanthos.ShrinkSystem.ShrinkTarget.OnTarget (Mobile from, Object target)
   in Server.Targeting.Target.Invoke (Mobile from, Object targeted)
   in Server.Network.PacketHandlers.TargetResponse (NetState state, PacketReader pvSrc)
   in Server.Network.MessagePump.HandleReceive (NetState ns)
   in Server.Network.MessagePump.Slice ()
   in Server.Core.Main (String [] args)
Any advice?Thank you!
 

Active Shards

Donations

Total amount
$50.00
Goal
$1,000.00
Back