Here is the quest giver script I am using. Currently when you turn in a completed quest you get a random piece of armor and some gold. I would like to add a random piece of specific armor like ranger armor to randomly drop as a reward sometimes also. I cant seem to get it right. I have tried adding something like this
Code:
switch (Utility.Random(5))
                          
                            case 0: AddItem(new RangerArms() ); break;
                            case 1: AddItem(new RangerChest() ); break;
                            case 2: AddItem(new RangerGloves() ); break;
                            case 3: AddItem(new RangerGorget() ); break;
                            case 4: AddItem(new RangerLegs() ); break;

But it always appears on the NPC and not in the players pack.

Code:
using System;
using Server;
using System.Collections;
using System.Collections.Generic;
using Server.Items;
using Server.Targeting;
using Server.Gumps;
using Server.Misc;
using Server.Network;
using Server.Spells;
using Server.Commands;
using Server.Mobiles;

namespace Server.Mobiles
{
    [CorpseName( "quest master corpse" )]
    public class QuestGiver : Mobile
    {
                public virtual bool IsInvulnerable{ get{ return false; } }//Invulnerable 1
        [Constructable]
        public QuestGiver()
        {
            //Change NPC characteristics, gear and stats in this section
            InitStats(100, 100, 100);

            Karma = 1000;
            Fame = 1000;
            Hue = Utility.RandomSkinHue();
            Body = 0x190;
            Blessed = true;//Invulnerable 2

          
          
            AddItem( new QuarterStaff() );
            AddItem( new StuddedArms() );
            AddItem( new StuddedLegs() );
            AddItem( new StuddedChest() );
            AddItem( new StuddedGloves() );
            AddItem( new StuddedGorget() );
            AddItem( new Sandals( Utility.RandomNeutralHue() ) );
            AddItem( new BodySash( Utility.RandomNeutralHue() ) );
            AddItem( new Cloak( Utility.RandomNeutralHue() ) );
            //AddItem( new Robe( Utility.RandomNeutralHue() ) );
            Direction = Direction.South;
            Name = NameList.RandomName( "male" );
            Title = "The Quest Master";
            CantWalk = true;
            //Utility.AssignRandomHair( this );
            Item hair = new Item( 0x203C );
                hair.Hue = Utility.RandomHairHue();
                hair.Layer = Layer.Hair;
                hair.Movable = false;
                AddItem( hair );
            //End of section
        }

        public QuestGiver( Serial serial ) : base( serial )
        {
        }

        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 override void OnDoubleClick( Mobile from )
        {
            DisplayPaperdollTo( from );
            Say(String.Format("Hello {0}, just say 'quest' if thou wouldst like to embark on a quest for me.", from.Name));
          
        }
      
        private static void GetRandomAOSStats( out int attributeCount, out int min, out int max, int level )
        {
            int rnd = Utility.Random( 15 );

            if ( level == 6 )
            {
                attributeCount = Utility.RandomMinMax( 2, 6 );
                min = 50; max = 100;
            }
            else if ( level == 5 )
            {
                attributeCount = Utility.RandomMinMax( 2, 4 );
                min = 40; max = 90;
            }
            else if ( level == 4 )
            {
                attributeCount = Utility.RandomMinMax( 2, 3 );
                min = 30; max = 80;
            }
            else if ( level == 3 )
            {
                attributeCount = Utility.RandomMinMax( 1, 3 );
                min = 20; max = 70;
            }
            else if ( level == 2 )
            {
                attributeCount = Utility.RandomMinMax( 1, 2 );
                min = 10; max = 60;
            }
            else
            {
                attributeCount = 10;
                min = 10; max = 20;
            }
        }

        public override bool HandlesOnSpeech( Mobile from )
        {
            if ( from.InRange( this.Location, 12 ) )
                return true;

            return base.HandlesOnSpeech( from );
        }
      
        public override void OnSpeech(SpeechEventArgs e )
        {
            if ( !e.Handled && e.Mobile.InRange( this.Location, 12 ) )
            {
                if (e.Speech == "quest")
                {
                    e.Mobile.SendGump( new QuestGiver_gump( e.Mobile ) );
                }
              
            }

            base.OnSpeech( e );
        }
      
        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            Mobile m = from;
            PlayerMobile mobile = m as PlayerMobile;

            if ( mobile != null)
            {
                     if(dropped is Gold && dropped.Amount==100)//Change the amount of gold per lvl quest here
                     {
                    mobile.AddToBackpack ( new QuestScroll(1) );
                    this.PrivateOverheadMessage( MessageType.Regular, 89, false, "Return the Quest parchment to me when you are done...for your reward.", mobile.NetState );
                         return true;
                     }
                     else if(dropped is Gold && dropped.Amount==200)//Change the amount of gold per lvl quest here
                     {
                    mobile.AddToBackpack ( new QuestScroll(2) );
                    this.PrivateOverheadMessage( MessageType.Regular, 89, false, "Return the Quest parchment to me when you are done...for your reward.", mobile.NetState );
                         return true;
                     }
                     else if(dropped is Gold && dropped.Amount==300)//Change the amount of gold per lvl quest here
                     {
                    mobile.AddToBackpack ( new QuestScroll(3) );
                    this.PrivateOverheadMessage( MessageType.Regular, 89, false, "Return the Quest parchment to me when you are done...for your reward.", mobile.NetState );
                         return true;
                     }
                     else if(dropped is Gold && dropped.Amount==400)//Change the amount of gold per lvl quest here
                     {
                    mobile.AddToBackpack ( new QuestScroll(4) );
                    this.PrivateOverheadMessage( MessageType.Regular, 89, false, "Return the Quest parchment to me when you are done...for your reward.", mobile.NetState );
                         return true;
                     }
                     else if(dropped is Gold && dropped.Amount==500)//Change the amount of gold per lvl quest here
                     {
                    mobile.AddToBackpack ( new QuestScroll(5) );
                    this.PrivateOverheadMessage( MessageType.Regular, 89, false, "Return the Quest parchment to me when you are done...for your reward.", mobile.NetState );
                         return true;
                     }
                     else if(dropped is Gold && dropped.Amount==600)//Change the amount of gold per lvl quest here
                     {
                    mobile.AddToBackpack ( new QuestScroll(6) );
                    this.PrivateOverheadMessage( MessageType.Regular, 89, false, "Return the Quest parchment to me when you are done...for your reward.", mobile.NetState );
                         return true;
                     }
                     else if(dropped is Gold)//Customize message when wrong amount of gold is given below
                     {
                    this.PrivateOverheadMessage( MessageType.Regular, 89, false, "That is not the amount I am looking for.", mobile.NetState );
                         return false;
                     }
                else if( dropped is QuestScroll )
                     {
                    QuestScroll m_Quest = (QuestScroll)dropped;

                         if(m_Quest.NNeed > m_Quest.NGot)
                         {
                        mobile.AddToBackpack ( dropped );//Customize message when quest scroll is incomplete below
                        this.PrivateOverheadMessage( MessageType.Regular, 89, false, "Thou hast not completed thy quest.", mobile.NetState );
                             return false;
                         }

                        string sMessage = "";//Customize message when valid quest scroll is complete and turned in below
                        if (m_Quest.NType == 1){ sMessage = "I see thou art victorious. Here is thy reward."; }
                        else { sMessage = "Ahh...you have found " + m_Quest.NItemName + "! Here is thy reward"; }

                        if ( Utility.RandomMinMax( 1, 4 ) == 1 )
                        {
                        mobile.AddToBackpack ( new Gold( m_Quest.NLevel * Utility.RandomMinMax( 250, 400 ) ) );
                        }
                        else
                        {

                        mobile.AddToBackpack ( new Gold( m_Quest.NLevel * Utility.RandomMinMax( 150, 300 ) ) );
  
                        Item item;

                        item = Loot.RandomArmorOrShieldOrWeapon();              

                        if ( item is BaseWeapon )
                        {
                            BaseWeapon weapon = (BaseWeapon)item;
  
                            weapon.DamageLevel = (WeaponDamageLevel)Utility.Random( 6 );
                            weapon.AccuracyLevel = (WeaponAccuracyLevel)Utility.Random( 6 );
                            weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random( 6 );
                          

                            mobile.AddToBackpack ( item );
                        }
                        else if ( item is BaseArmor )
                        {
                            BaseArmor armor = (BaseArmor)item;

                            armor.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
                            armor.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );

                            mobile.AddToBackpack ( item );
                        }
                        else if( item is BaseHat )
                        {
                            BaseHat hat = (BaseHat)item;
  
                            mobile.AddToBackpack ( item );
                        }
                        else if( item is BaseJewel )
                        {
                            int attributeCount;
                            int min, max;

                            GetRandomAOSStats( out attributeCount, out min, out max, m_Quest.NLevel );

                            mobile.AddToBackpack ( item );
                        }
                        }
                                    this.PrivateOverheadMessage(MessageType.Regular, 89, false, sMessage, mobile.NetState);

                        dropped.Delete();
              
                        return true;
                }
                else
                {
                    mobile.AddToBackpack ( dropped );
                    this.PrivateOverheadMessage(MessageType.Regular, 89, false, "I have no need for this...", mobile.NetState); return true;
                }
            }

                    return false;
        }
    }
}

namespace Server.Gumps
{
    public class QuestGiver_gump : Gump
    {
        public static void Initialize()
        {
            CommandSystem.Register( "QuestGiver_gump", AccessLevel.GameMaster, new CommandEventHandler( QuestGiver_gump_OnCommand ) );
            //CommandSystem.Register( "Quest", AccessLevel.Player, new CommandEventHandler( QuestGiver_gump_OnCommand ) );//Allows players to use command instead of context menu to activate gump
        }

        private static void QuestGiver_gump_OnCommand( CommandEventArgs e )
        {
            e.Mobile.SendGump( new QuestGiver_gump( e.Mobile ) );
        }
      
      
        public QuestGiver_gump( Mobile owner ) : base( 50,50 )
        {
            AddPage( 0 );
            AddImageTiled(  54, 33, 369, 400, 2624 );
            AddAlphaRegion( 54, 33, 369, 400 );
            AddImageTiled( 416, 39, 44, 389, 203 );

            AddImage( 97, 49, 9005 );
            AddImageTiled( 58, 39, 29, 390, 10460 );
            AddImageTiled( 412, 37, 31, 389, 10460 );
            AddLabel( 140, 60, 0x34, "The Quest Master" );

            AddHtml( 107, 140, 300, 230, " < BODY > " +
            //////////////////////  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  THIS IS THE LENGTH OF THE TEXT ALLOWED //
            "<BASEFONT COLOR=YELLOW>Hail brave adventurer. I am the local<BR>" +
            "<BASEFONT COLOR=YELLOW>quest master. If anything needs to be<BR>" +
            "<BASEFONT COLOR=YELLOW>done around here...I am the one to see.<BR>" +
            "<BASEFONT COLOR=YELLOW>Although I am not supposed to hire any<BR>" +
            "<BASEFONT COLOR=YELLOW>citizens, you look like you can handle<BR>" +
            "<BASEFONT COLOR=YELLOW>yourself. Of course, I could get in<BR>" +
            "<BASEFONT COLOR=YELLOW>much trouble if they find out that I<BR>" +
            "<BASEFONT COLOR=YELLOW>let slip what needs to be done, as gold<BR>" +
            "<BASEFONT COLOR=YELLOW>is rare and usually the nobles want to<BR>" +
            "<BASEFONT COLOR=YELLOW>get the riches for themselves.<BR>" +
            "<BASEFONT COLOR=YELLOW><BR>" +
            "<BASEFONT COLOR=YELLOW>I'll tell you what, you slip a few gold<BR>" +
            "<BASEFONT COLOR=YELLOW>coins my way, and I will be a little<BR>" +
            "<BASEFONT COLOR=YELLOW>careless about what I say. The more<BR>" +
            "<BASEFONT COLOR=YELLOW>gold I get...the more careless I will<BR>" +
            "<BASEFONT COLOR=YELLOW>speak.<BR>" +
            "<BASEFONT COLOR=YELLOW><BR>" +
            "<BASEFONT COLOR=YELLOW>100 Gold - Level 1 Quest<BR>" +//List amount of gold required in gump for lvl quest
            "<BASEFONT COLOR=YELLOW>200 Gold - Level 2 Quest<BR>" +//List amount of gold required in gump for lvl quest
            "<BASEFONT COLOR=YELLOW>300 Gold - Level 3 Quest<BR>" +//List amount of gold required in gump for lvl quest
            "<BASEFONT COLOR=YELLOW>400 Gold - Level 4 Quest<BR>" +//List amount of gold required in gump for lvl quest
            "<BASEFONT COLOR=YELLOW>500 Gold - Level 5 Quest<BR>" +//List amount of gold required in gump for lvl quest
            "<BASEFONT COLOR=YELLOW>600 Gold - Level 6 Quest<BR>" +//List amount of gold required in gump for lvl quest
            "<BASEFONT COLOR=YELLOW><BR>" +
            "<BASEFONT COLOR=YELLOW>Simply follow the quest by targeting a<BR>" +
            "<BASEFONT COLOR=YELLOW>corpse of a slain creature. The corpse<BR>" +
            "<BASEFONT COLOR=YELLOW>must be a creature you are in a<BR>" +
            "<BASEFONT COLOR=YELLOW>quest to slay.<BR>" +
            "<BASEFONT COLOR=YELLOW><BR>" +
            "<BASEFONT COLOR=YELLOW><BR>" +
            "<BASEFONT COLOR=YELLOW>Rewards very from much gold or some<BR>" +
            "<BASEFONT COLOR=YELLOW>gold and a magical item.<BR>" +
            "</BODY>", false, true);

            AddImage( 430, 9, 10441);
            AddImageTiled( 40, 38, 17, 391, 9263 );
            AddImage( 6, 25, 10421 );
            AddImage( 34, 12, 10420 );
            AddImageTiled( 94, 25, 342, 15, 10304 );
            AddImageTiled( 40, 427, 415, 16, 10304 );
            AddImage( -10, 314, 10402 );
            AddImage( 56, 150, 10411 );
            AddImage( 155, 120, 2103 );
            AddImage( 136, 84, 96 );
            AddButton( 225, 390, 0xF7, 0xF8, 0, GumpButtonType.Reply, 0 );
        }

        public override void OnResponse( NetState state, RelayInfo info )
        {
            Mobile from = state.Mobile;
            switch ( info.ButtonID )
            {
                case 0:{ break; }
            }
        }
    }
}

Please help! LOL
 
I know nothing, but since I happened to see it first and might have an idea, I'll respond.

It looks like you used AddItem, which is why it's adding the items to the quest giver's pack. In Scripts/Misc/CharacterCreation, we can see the example of PackItem, like shown below:

Code:
PackItem(new RedBook("a book", m.Name, 20, true));

As a complete noob, I would attempt the same with your code, like this:

Code:
case 0: PackItem(new RangerArms() ); break

In other words, just go through your code (or Search:Replace) changing out AddItem for PackItem. See how she flies.
 
Eric thanks for the reply. I was able to get this to drop a random piece of ranger armor by using this
Code:
else if ( item is BaseArmor )
                        {
                            BaseArmor armor = (BaseArmor)item;

                            armor.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
                            armor.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
                           
                           

                            mobile.AddToBackpack ( item );
                        }
//Begin Here//                   switch (Utility.Random(5))
                        {
                            case 0: mobile.AddToBackpack(new RangerArms() ); break;
                            case 1: mobile.AddToBackpack(new RangerChest() ); break;
                            case 2: mobile.AddToBackpack(new RangerGloves() ); break;
                            case 3: mobile.AddToBackpack(new RangerGorget() ); break;
                            case 4: mobile.AddToBackpack(new RangerLegs() ); break;
                        }

But it drops a random piece of ranger armor every time a quest is complete. I would like the armor to only drop sometimes but not always.
 
Could you add 1 to the case options and either add nothing or add something useless or worthless? Oh wait, no, there's a way to add only by chance. Didn't I find that adding rough stones to the miner's possibilities? Let me see if I can figure out how to calculate a chance for drop instead of a random.
 
Could you add 1 to the case options and either add nothing or add something useless or worthless? Oh wait, no, there's a way to add only by chance. Didn't I find that adding rough stones to the miner's possibilities? Let me see if I can figure out how to calculate a chance for drop instead of a random.

Ok this is how you do it
Code:
                  if (Utility.Random(100) < 30) // 30% chance to drop   
                            switch (Utility.Random(5))
                            {
                                case 0: mobile.AddToBackpack(new RangerArms() ); break;
                                case 1: mobile.AddToBackpack(new RangerChest() ); break;
                                case 2: mobile.AddToBackpack(new RangerGloves() ); break;
                                case 3: mobile.AddToBackpack(new RangerGorget() ); break;
                                case 4: mobile.AddToBackpack(new RangerLegs() ); break;
                            }

Now the ranger armor only has a 30% chance to drop. Profit! :D
 
Ok, I found where mining can give you a chance at something, or nothing at all. After adding the RoughStones to your mining.cs (yes I know it's got nothing to do with you, but it's a working piece of code on a random drop), we would see this:

Code:
if ( Core.ML )
            {
                oreAndStone.BonusResources = new BonusHarvestResource[]
                {
                    new BonusHarvestResource( 0, 98.498, null, null ), //Nothing   //Note: Rounded the below to .0167 instead of 1/6th of a %.  Close enough
                    new BonusHarvestResource( 100, .167, 1072562, typeof( BlueDiamond ) ),
                    new BonusHarvestResource( 100, .167, 1072567, typeof( DarkSapphire ) ),
                    new BonusHarvestResource( 100, .167, 1072570, typeof( EcruCitrine ) ),
                    new BonusHarvestResource( 100, .167, 1072564, typeof( FireRuby ) ),
                    new BonusHarvestResource( 100, .167, 1072566, typeof( PerfectEmerald ) ),
                    new BonusHarvestResource( 100, .167, 1072568, typeof( Turquoise ) ),
                    new BonusHarvestResource( 100, .5, "you dig up a Rough Stone and put it in your backpack", typeof( RoughStone ))//added for runecrafting

"*******^^^ these ammounts all added up should = 100 ** 98.498 + ( .0167 * 6 ) + .5 = ? if not 100 change 98.498 til its correct. ************************************ this is how you change the rate at wich they may be mined up .5 and 98.498 %chance to get ore"

Meaning that to set up your code properly, maybe something closer to that would work for you. If you can adapt it for yourself, that gives you a chance at a random drop or simply nothing, and you set the ratio of how often each drop occurs.
 
Ok, I found where mining can give you a chance at something, or nothing at all. After adding the RoughStones to your mining.cs (yes I know it's got nothing to do with you, but it's a working piece of code on a random drop), we would see this:

Code:
if ( Core.ML )
            {
                oreAndStone.BonusResources = new BonusHarvestResource[]
                {
                    new BonusHarvestResource( 0, 98.498, null, null ), //Nothing   //Note: Rounded the below to .0167 instead of 1/6th of a %.  Close enough
                    new BonusHarvestResource( 100, .167, 1072562, typeof( BlueDiamond ) ),
                    new BonusHarvestResource( 100, .167, 1072567, typeof( DarkSapphire ) ),
                    new BonusHarvestResource( 100, .167, 1072570, typeof( EcruCitrine ) ),
                    new BonusHarvestResource( 100, .167, 1072564, typeof( FireRuby ) ),
                    new BonusHarvestResource( 100, .167, 1072566, typeof( PerfectEmerald ) ),
                    new BonusHarvestResource( 100, .167, 1072568, typeof( Turquoise ) ),
                    new BonusHarvestResource( 100, .5, "you dig up a Rough Stone and put it in your backpack", typeof( RoughStone ))//added for runecrafting

"*******^^^ these ammounts all added up should = 100 ** 98.498 + ( .0167 * 6 ) + .5 = ? if not 100 change 98.498 til its correct. ************************************ this is how you change the rate at wich they may be mined up .5 and 98.498 %chance to get ore"

Meaning that to set up your code properly, maybe something closer to that would work for you. If you can adapt it for yourself, that gives you a chance at a random drop or simply nothing, and you set the ratio of how often each drop occurs.


Looks like we posted at the same time LOL
 
Oh wow, crap, that's a whole lot easier, cleaner, less overhaul, and obviously actually correct. Next week our sermon is on the blind leading the blind. Don't forget to Send Me Your Money! (Suicidal Tendencies)
[doublepost=1532563320][/doublepost]I just realized I need to know how to code random drops in the future. Yes, same time, the Internubble is weird. Bookmarked. :D
 
Oh wow, crap, that's a whole lot easier, cleaner, less overhaul, and obviously actually correct. Next week our sermon is on the blind leading the blind. Don't forget to Send Me Your Money! (Suicidal Tendencies)
[doublepost=1532563320][/doublepost]I just realized I need to know how to code random drops in the future. Yes, same time, the Internubble is weird. Bookmarked. :D


If you want drops to have special properties you can do something like this
Code:
                                RangerArms ra = new RangerArms();
                                RangerChest rc = new RangerChest();
                                RangerGloves rg = new RangerGloves();
                                RangerGorget rgg = new RangerGorget();
                                RangerLegs rl = new RangerLegs();
                       
                                ra.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
                                rc.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
                                rg.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
                                rgg.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
                                rl.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
                           
                                ra.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
                                rc.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
                                rg.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
                                rgg.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
                                rl.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
                           
                       
                            if (Utility.Random(100) < 10) // 10% chance to drop
                            switch (Utility.Random(5))
                            {
                                case 0: mobile.AddToBackpack( ra ); break;
                                case 1: mobile.AddToBackpack( rc ); break;
                                case 2: mobile.AddToBackpack( rg ); break;
                                case 3: mobile.AddToBackpack( rgg ); break;
                                case 4: mobile.AddToBackpack( rl ); break;
                           

                            }

Here we have added random durability and protection for each generated piece of specific armor type we defined. Otherwise if you want completely random drops with random properties you could do this which is from the script above.

Code:
Item item;

                        item = Loot.RandomArmorOrShieldOrWeapon();           

                        if ( item is BaseWeapon )
                        {
                            BaseWeapon weapon = (BaseWeapon)item;

                            weapon.DamageLevel = (WeaponDamageLevel)Utility.Random( 6 );
                            weapon.AccuracyLevel = (WeaponAccuracyLevel)Utility.Random( 6 );
                            weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random( 6 );
                       

                            mobile.AddToBackpack ( item );
                        }
                        else if ( item is BaseArmor )
                        {
                            BaseArmor armor = (BaseArmor)item;

                            armor.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
                            armor.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );

                            mobile.AddToBackpack ( item );
                       
                        }

This just drops a random weapon or armor or shield and assigns random levels of damage, accuracy, protection, durability etc.
 
Last edited:
Wow, great, thank you so much @Aschnyder26. I just wanted you to know that not only do I appreciate all the extra work you went to to show the correct way to do this, but I'm sure others who will come after me do, too. Thanks for keeping the learning alive.
 
Not really a good way to do it there @Aschnyder26 simply because you still did create all these items even if they are not added to the backpack.

This would result in the items landing in the interal area. Off to work but I will write a different approach when I get back
 
Wow, great, thank you so much @Aschnyder26. I just wanted you to know that not only do I appreciate all the extra work you went to to show the correct way to do this, but I'm sure others who will come after me do, too. Thanks for keeping the learning alive.

It was just A way not necessarily the right way or the best way as PyrO mentioned. Also @PyrO thanks!
 
Hehe. Well I'm going through the magic 8 ball tutorial right now, so I am learning the correct way to do things from the best. I just also appreciate any thinking that can get me closer to whatever solution I'm working on.

Don't worry, the masters are still training me thru tutes. :)
 
Not really a good way to do it there @Aschnyder26 simply because you still did create all these items even if they are not added to the backpack.

This would result in the items landing in the interal area. Off to work but I will write a different approach when I get back
Also @PyrO does that mean that this method in the script I'm using creates all bunch of items in the internal area also?
Code:
                        mobile.AddToBackpack ( new Gold( m_Quest.NLevel * Utility.RandomMinMax( 150, 300 ) ) );
  
                        Item item;

                        item = Loot.RandomArmorOrShieldOrWeapon();              

                        if ( item is BaseWeapon )
                        {
                            BaseWeapon weapon = (BaseWeapon)item;
  
                            weapon.DamageLevel = (WeaponDamageLevel)Utility.Random( 6 );
                            weapon.AccuracyLevel = (WeaponAccuracyLevel)Utility.Random( 6 );
                            weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random( 6 );
                          

                            mobile.AddToBackpack ( item );
                        }
                        else if ( item is BaseArmor )
                        {
                            BaseArmor armor = (BaseArmor)item;

                            armor.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
                            armor.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );

                            mobile.AddToBackpack ( item );
                          
                        }

Or were you just referring to this
Code:
                                RangerArms ra = new RangerArms();
                                RangerChest rc = new RangerChest();
                                RangerGloves rg = new RangerGloves();
                                RangerGorget rgg = new RangerGorget();
                                RangerLegs rl = new RangerLegs();
                           
                                ra.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
                                rc.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
                                rg.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
                                rgg.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
                                rl.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
                               
                                ra.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
                                rc.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
                                rg.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
                                rgg.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
                                rl.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
                               
                           
                            if (Utility.Random(100) < 10) // 10% chance to drop   
                            switch (Utility.Random(5))
                            {
                                case 0: mobile.AddToBackpack( ra ); break;
                                case 1: mobile.AddToBackpack( rc ); break;
                                case 2: mobile.AddToBackpack( rg ); break;
                                case 3: mobile.AddToBackpack( rgg ); break;
                                case 4: mobile.AddToBackpack( rl ); break;
                               

                            }
 
Last edited:
I was just refereing to the later part, in the first one I dont really see an issue, if you would be a bit paranoid you could add an else statement to it that would delete the item again, but that shouldnt really trigger unless there are issues in the lootpacks ^^

this is how I would go with it, maybe the random double / float but the normal random works fine too.
Granted I was lazy and didnt boot it up but it looks fine to me atm so :p

Code:
if (mobile != null && Utility.Random(100) < 30) // 30% chance to drop 
{
	BaseArmor drop = null;
	switch (Utility.Random(5))
	{
		case 0: drop = new RangerArms(); break;
		case 1: drop = new RangerChest(); break;
		case 2: drop = new RangerGloves(); break;
		case 3: drop = new RangerGorget(); break;
		case 4: drop = new RangerLegs(); break;
	}
	drop.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
	drop.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
	mobile.AddToBackpack(drop);
}
 
I was just refereing to the later part, in the first one I dont really see an issue, if you would be a bit paranoid you could add an else statement to it that would delete the item again, but that shouldnt really trigger unless there are issues in the lootpacks ^^

this is how I would go with it, maybe the random double / float but the normal random works fine too.
Granted I was lazy and didnt boot it up but it looks fine to me atm so :p

Code:
if (mobile != null && Utility.Random(100) < 30) // 30% chance to drop
{
	BaseArmor drop = null;
	switch (Utility.Random(5))
	{
		case 0: drop = new RangerArms(); break;
		case 1: drop = new RangerChest(); break;
		case 2: drop = new RangerGloves(); break;
		case 3: drop = new RangerGorget(); break;
		case 4: drop = new RangerLegs(); break;
	}
	drop.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
	drop.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
	mobile.AddToBackpack(drop);
}
Thanks PyrO that works great! Thank you for taking the time to do that. Much appreciated. I checked to see if it was adding items when spawning and this way it isn't adding extra items to the internal map but the other way actually was. Now I have noticed that the script in general seems to add items to the map when you turn in a quest even without the ranger armor, so I'm glad you mentioned that or I would have never thought to check! :D
 
Last edited:
Back