public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            switch ((RFButtons)info.ButtonID)
            {
            case RFButtons.AddRareButton:
            {
                // Make sure a group has been defined (if one has, one will be
                // selected by default - group 0)
                if (RareFactory.DODGroup.Count == 0)
                {
                    from.SendMessage("You must define a Dynamic Object Definition Group before adding rares.");
                    break;
                }

                from.SendMessage("Select the item you wish to use as a template for this rare...");
                from.Target = new RareTarget();
                break;
            }

            case RFButtons.DelRareButton:
            {
                if (RareFactory.ViewingDODGroup.DODInst.Count == 0)
                {
                    from.SendMessage("There are no rares to delete!");
                    break;
                }

                from.SendMessage("Are you sure you wish to delete this rare? (y/n)");
                from.Prompt = new DelConfirmPrompt(from);
                break;
            }


            case RFButtons.NextRareButton:
            {
                if (RareFactory.DODGroup.Count == 0)
                {
                    from.SendMessage("No rares defined!");
                    break;
                }

                // The .ViewingDODIndex references the relative index
                // within this particular DODGroup

                DODGroup dg = (DODGroup)RareFactory.DODGroup[RareFactory.ViewingDODGroupIndex];

                if ((RareFactory.ViewingDODIndex + 1) >= dg.DODInst.Count)
                {
                    from.SendMessage("Last rare in group!");
                    break;
                }
                else
                {
                    RareFactory.ViewingDODIndex++;
                    break;
                }
            }

            case RFButtons.PrevRareButton:
            {
                if (RareFactory.DODGroup.Count == 0)
                {
                    from.SendMessage("No rares defined!");
                    break;
                }

                // The .ViewingDODIndex references the relative index
                // within this particular DODGroup

                if (RareFactory.ViewingDODIndex == 0)
                {
                    from.SendMessage("First rare in group!");
                    break;
                }
                else
                {
                    RareFactory.ViewingDODIndex--;
                    break;
                }
            }

            case RFButtons.TestButton:
            {
                if (RareFactory.DODGroup.Count == 0)
                {
                    from.SendMessage("Define Dynamic Object Definition Groups and objects (rares) before attempting to generate test batches.");
                    break;
                }

                if (((DODGroup)RareFactory.DODGroup[RareFactory.ViewingDODGroupIndex]).DODInst.Count == 0)
                {
                    from.SendMessage("You must add rares to the group before attempting to generate test batches.");
                    break;
                }

                int prevCur = RareFactory.ViewingDOD.CurIndex;

                // Generates a complete set of rares as a test
                from.SendMessage("Generating example rare set...");

                for (int i = RareFactory.ViewingDOD.StartIndex; i <= RareFactory.ViewingDOD.LastIndex; i++)
                {
                    // Create a new item
                    DODInstance dodi    = RareFactory.ViewingDOD;
                    Item        newitem = RareFactory.DupeItem(dodi.RareTemplate);

                    newitem.Movable = true;
                    dodi.CurIndex   = (short)i;
                    dodi.DynamicFill(newitem);
                    from.AddToBackpack(newitem);
                }

                RareFactory.ViewingDOD.CurIndex = (short)prevCur;

                from.SendMessage("Completed. {0} rares generated and added to your backpack.",
                                 (RareFactory.ViewingDOD.LastIndex -
                                  RareFactory.ViewingDOD.StartIndex) + 1);

                break;
            }

            default:
            {
                return;
            }
            }

            RareFactory.ReloadViews(from);
        }
        // spawners can now spawn special lootpacks with per item drop rates.
        public ArrayList CreateItem(Item lootPack)
        {
            LogHelper Logger = null;
            ArrayList items  = new ArrayList();

            try
            {
                if (lootPack == null || lootPack.Deleted == true)
                {
                    return(null);
                }

                Logger = new LogHelper("LootPack.log", false, true);

                if (lootPack is Container)
                {
                    if ((lootPack as Container).Factory)
                    {                           // only one item from factory has a chance at a drop
                        if ((lootPack as Container).DropRate >= Utility.RandomDouble())
                        {
                            if ((lootPack as Container).Items.Count > 0)
                            {
                                Item item = (lootPack as Container).Items[Utility.Random((lootPack as Container).Items.Count)] as Item;
                                Item temp = RareFactory.DupeItem(item);
                                if (temp != null)
                                {
                                    Logger.Log(LogType.Item, this, string.Format("Dropped lootpack item {0}", temp));
                                    temp.DropRate = 1.0;                                        // should not be set, but lets be safe
                                    items.Add(temp);
                                    return(items);
                                }
                            }
                        }
                    }
                    else
                    {
                        // each item from a container has a chance at a drop
                        foreach (Item item in lootPack.Items)
                        {                               // drop chance
                            if (item.DropRate >= Utility.RandomDouble())
                            {
                                Item temp = RareFactory.DupeItem(item);
                                if (temp != null)
                                {
                                    Logger.Log(LogType.Item, this, string.Format("Dropped lootpack item {0}", temp));
                                    temp.DropRate = 1.0;                                        // all this does is save the sizeof(double) for each item generated
                                    items.Add(temp);
                                }
                            }
                        }

                        return(items);
                    }
                }
                else
                {
                    // drop chance
                    if (lootPack.DropRate >= Utility.RandomDouble())
                    {
                        Item temp = RareFactory.DupeItem(RareFactory.DupeItem(lootPack));
                        if (temp != null)
                        {
                            Logger.Log(LogType.Item, this, string.Format("Dropped lootpack item {0}", temp));
                            temp.DropRate = 1.0;                                // all this does is save the sizeof(double) for each item generated
                            items.Add(temp);
                            return(items);
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                LogHelper.LogException(exc);
            }
            finally
            {
                if (Logger != null)
                {
                    Logger.Finish();
                }
            }

            return(items);
        }