Help pls . . stubborn script

Discussion in 'Script Support' started by PigPen-divinity, Jan 7, 2018.

  1. PigPen-divinity

    PigPen-divinity Sorceror

    Joined:
    May 20, 2006
    Messages:
    1,453
    Likes Received:
    41
    Okay . . after three days of 'errors' and searching and hair pulling I finally got this script to compile but the resulting NPC does not do what I am trying to make happen. Basically he does 'Nothing'.

    This NPC is supposed to:
    1) check the player 'talking' to him for a specific quest marker (BaseCampMarker)
    2) if it exists then check to see how many other players might be in the hunting group
    3) Delete the specific quest marker (BaseCampMarker)
    4) Replace that quest marker with a new one based on the size of the hunting group

    Note: I am trying to make this work so I can spawn different numbers of monsters depending on the size of the hunting party.
    Here is my latest script. If you see any hairs . . they are the last ones I owned *grins*
    I would really appreciate some help.

    Many Thanks
    *bows*

    Code:
    using System;
    using System.Collections;
    using Server.Items;
    using Server.Targeting;
    using Server.ContextMenus;
    using Server.Gumps;
    using Server.Misc;
    using Server.Network;
    using Server.Spells;
    using System.Collections.Generic;
    namespace Server.Mobiles
    {
        [CorpseName( "viking hunter corpse" )]
        public class  VikingQG: Mobile
        {
            public virtual bool IsInvulnerable{ get{ return true; } }
            [Constructable]
            public VikingQG()
            {
                Name = "Torstein";
                Title = "the guard";
                Body = 401;
                Hue = Utility.RandomSkinHue();
                Blessed = true;
                LongPants p = new LongPants();
                p.Hue = 1701;
                p.Name = "Viking Pants";
                p.LootType = LootType.Blessed;
                AddItem( p );
                DragonChest dc = new DragonChest();
                dc.Hue = 1701;
                dc.Name = "Viking Chest";
                dc.LootType = LootType.Blessed;
                AddItem( dc );
                DragonArms da = new DragonArms();
                da.Hue = 1701;
                da.Name = "Viking Arms";
                da.LootType = LootType.Blessed;
                AddItem( da );
                Boots b = new Boots();
                b.Hue = 1701;
                b.Name = "Viking Boots";
                b.LootType = LootType.Blessed;
                AddItem( b );
                this.HairItemID = 0x203C;
                this.HairHue = 2125;
                WoodenShield sh = new WoodenShield();
                sh.LootType = LootType.Blessed;
                AddItem( sh );
                                                      
                VikingSword bow = new VikingSword();
                bow.LootType = LootType.Blessed;
                AddItem(bow);
            }
            public VikingQG( Serial serial ) : base( serial )
            {
            }
            public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
            {
                base.GetContextMenuEntries( from, list );
                list.Add( new VikingQGEntry( from, this ) );
            }
            public override void Serialize( GenericWriter writer )
            {
                base.Serialize( writer );
                writer.Write( (int) 0 );
            }
            public override void Deserialize( GenericReader reader )
            {
                base.Deserialize( reader );
                int version = reader.ReadInt();
            }
            public void DoSpecialAbility( Mobile from )
            {
                DecideSpawnSize();
            }
            public void DecideSpawnSize()
            {
                if( this.Map == null )
                    return;
                ArrayList list = new ArrayList();
                foreach ( Mobile m in this.GetMobilesInRange( 20 ) )
                {
                    if ( m == this || !CanBeHarmful( m ) )
                    {
                        continue;
                    }
                    if ( m.Player )
                    {
                        list.Add( m );
                    }
                }
                foreach ( Mobile m in list )
                {
                    if (m is PlayerMobile)
                    {
                        Item checkmarker = m.Backpack.FindItemByType(typeof(BaseCampMarker));
                        if ( checkmarker == null )
                        {
                            this.Say("You do not impress me.");
                            return;
                        }
                        if ( checkmarker != null )
                        {
                            if (list.Count <= 0 )
                            {
                                return;
                            }
                            if (list.Count <= 1 )
                            {
                                this.Say("You impress me. You can enter.");
                                m.AddToBackpack( new BaseCampMarker01() );
                                checkmarker.Delete();
                                return;
                            }
                            if (list.Count <= 2 )
                            {
                                this.Say("You impress me. You can enter.");
                                m.AddToBackpack( new BaseCampMarker02() );
                                checkmarker.Delete();
                                return;
                            }
                            if (list.Count <= 3 )
                            {
                                this.Say("You impress me. You can enter.");
                                m.AddToBackpack( new BaseCampMarker03() );
                                checkmarker.Delete();
                                return;
                            }
                            if (list.Count >= 4 )
                            {
                                this.Say("You impress me. You can enter.");
                                m.AddToBackpack( new BaseCampMarker04() );
                                checkmarker.Delete();
                                return;
                            }
                        }
                    }
                }
            }
            public class VikingQGEntry : ContextMenuEntry
            {
                private VikingQG m_Giver;
                private Mobile m_From;
              
                public VikingQGEntry( Mobile from, VikingQG giver ) : base( 6146, 3 )
                {
                    m_Giver = giver;
                    m_From = from;
                }
                public override void OnClick()
                {
                    if( !( m_From is PlayerMobile ) )
                    {
                        return;
                    }
                    m_Giver.DoSpecialAbility( m_From );
                }
            }
            public override bool OnDragDrop( Mobile from, Item dropped )
            {                
                    Mobile m = from;
                PlayerMobile mobile = m as PlayerMobile;
                if ( mobile != null)
                {
                        this.PrivateOverheadMessage( MessageType.Regular, 11, false, "Hey! Don't drop things on me.", mobile.NetState );
                  
                }
                return false;
            }
        }
    }
    [/code
     
  2. PigPen-divinity

    PigPen-divinity Sorceror

    Joined:
    May 20, 2006
    Messages:
    1,453
    Likes Received:
    41
    I have continued trying to solve this. I have been unable to get the 'DoSpecialAbility' and 'DecideSpawnSize' to work so I decided to try bringing all that back inside the 'OnClick'. Now I am back to getting an error I cannot solve.
    Here is the latest script . .
    Code:
    using System;
    using System.Collections;
    using Server.Items;
    using Server.Targeting;
    using Server.ContextMenus;
    using Server.Gumps;
    using Server.Misc;
    using Server.Network;
    using Server.Spells;
    using System.Collections.Generic;
    namespace Server.Mobiles
    {
        [CorpseName( "viking hunter corpse" )]
        public class  VikingQG: Mobile
        {
            public virtual bool IsInvulnerable{ get{ return true; } }
            [Constructable]
            public VikingQG()
            {
                Name = "Torstein";
                Title = "the guard";
                Body = 401;
                Hue = Utility.RandomSkinHue();
                Blessed = true;
                LongPants p = new LongPants();
                p.Hue = 1701;
                p.Name = "Viking Pants";
                p.LootType = LootType.Blessed;
                AddItem( p );
                DragonChest dc = new DragonChest();
                dc.Hue = 1701;
                dc.Name = "Viking Chest";
                dc.LootType = LootType.Blessed;
                AddItem( dc );
                DragonArms da = new DragonArms();
                da.Hue = 1701;
                da.Name = "Viking Arms";
                da.LootType = LootType.Blessed;
                AddItem( da );
                Boots b = new Boots();
                b.Hue = 1701;
                b.Name = "Viking Boots";
                b.LootType = LootType.Blessed;
                AddItem( b );
                this.HairItemID = 0x203C;
                this.HairHue = 2125;
                WoodenShield sh = new WoodenShield();
                sh.LootType = LootType.Blessed;
                AddItem( sh );
                                                      
                VikingSword bow = new VikingSword();
                bow.LootType = LootType.Blessed;
                AddItem(bow);
            }
            public VikingQG( Serial serial ) : base( serial )
            {
            }
            public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
            {
                base.GetContextMenuEntries( from, list );
                list.Add( new VikingQGEntry( from, this ) );
            }
            public override void Serialize( GenericWriter writer )
            {
                base.Serialize( writer );
                writer.Write( (int) 0 );
            }
            public override void Deserialize( GenericReader reader )
            {
                base.Deserialize( reader );
                int version = reader.ReadInt();
            }
            public class VikingQGEntry : ContextMenuEntry
            {
                private VikingQG m_Giver;
                private Mobile m_From;
              
                public VikingQGEntry( Mobile from, VikingQG giver ) : base( 6146, 3 )
                {
                    m_Giver = giver;
                    m_From = from;
                }
                public override void OnClick()
                {
                    if( m_From.Map == null )
                        return;
                    ArrayList list = new ArrayList();
                    foreach ( Mobile m in this.GetMobilesInRange( 20 ) )
                    {
                        if ( m == this || !CanBeHarmful( m ) )
                        {
                            continue;
                        }
                        if ( m.Player )
                        {
                            list.Add( m );
                        }
                    }
                    foreach ( Mobile m in list )
                    {
                        if (m is PlayerMobile)
                        {
                            Item checkmarker = m.Backpack.FindItemByType(typeof(BaseCampMarker));
                            if ( checkmarker == null )
                            {
                                m_Giver.Say("You do not impress me.");
                                return;
                            }
                            if ( checkmarker != null )
                            {
                                if (list.Count <= 0 )
                                {
                                    return;
                                }
                                if (list.Count <= 1 )
                                {
                                    m_Giver.Say("You impress me. You can enter.");
                                    m.AddToBackpack( new BaseCampMarker01() );
                                    checkmarker.Delete();
                                    return;
                                }
                                if (list.Count <= 2 )
                                {
                                    m_Giver.Say("You impress me. You can enter.");
                                    m.AddToBackpack( new BaseCampMarker02() );
                                    checkmarker.Delete();
                                    return;
                                }
                                if (list.Count <= 3 )
                                {
                                    m_Giver.Say("You impress me. You can enter.");
                                    m.AddToBackpack( new BaseCampMarker03() );
                                    checkmarker.Delete();
                                    return;
                                }
                                if (list.Count >= 4 )
                                {
                                    m_Giver.Say("You impress me. You can enter.");
                                    m.AddToBackpack( new BaseCampMarker04() );
                                    checkmarker.Delete();
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            public override bool OnDragDrop( Mobile from, Item dropped )
            {                
                    Mobile m = from;
                PlayerMobile mobile = m as PlayerMobile;
                if ( mobile != null)
                {
                        this.PrivateOverheadMessage( MessageType.Regular, 11, false, "Hey! Don't drop things on me.", mobile.NetState );
                  
                }
                return false;
            }
        }
    }
    
    and here is the error I am getting now . . .
    Code:
    Errors:
     + Customs/Quest to add - Viking Outpost/Mobile QGs/VikingQG.cs:
        CS1061: Line 103: 'Server.Mobiles.VikingQG.VikingQGEntry' does not contain a definition for 'GetMobilesInRange' and no extension method 'GetMobilesInRange' accepting a first argument of type 'Server.Mobiles.VikingQG.VikingQGEntry' could be found (are you missing a using directive or an assembly reference?)
    
    Does anyone see a way to solve this?
    Any help is appreciated.
    Many Thanks
     
  3. PigPen-divinity

    PigPen-divinity Sorceror

    Joined:
    May 20, 2006
    Messages:
    1,453
    Likes Received:
    41
    Solved - Thanks.

    Had to replace m with m_Giver or m_From in a few places
     
  4. Enroq

    Enroq Sorceror

    Joined:
    Jan 28, 2011
    Messages:
    1,940
    Likes Received:
    230
    Sorry, homie. I didn't even see your post. I have a bad habit of only looking at the top five now that we have the new posts on the side. We must be picking up in activity because it used to be that wasn't a problem. Don't be afraid to send a PM.
     
  5. PigPen-divinity

    PigPen-divinity Sorceror

    Joined:
    May 20, 2006
    Messages:
    1,453
    Likes Received:
    41
    Thank you . . I appreciate that a lot. Nice to know a wise resource is around *smiles*

    I will try hard not to be a pest.

    *bows*
     
  6. Enroq

    Enroq Sorceror

    Joined:
    Jan 28, 2011
    Messages:
    1,940
    Likes Received:
    230
    So far from wise am I..

    But I do know a little C# :p
     

Share This Page