RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[Resolved] Item Packs - [Thanks The Mormegil]

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 84
Item Packs
September 29th 2010



Summary
I know that this can be done with eventing its just it could be done easier with scripting and note tags.
Could someone make an item feature (through scripting) such as when you open (use item) a package you get different items out of it? (I am having trouble explaining...)

Features Desired
  • <S I/W/A/G : #> (Specific item and ammount.)
  • <R I/W/A/G : #> (Specific item and random ammount 0 up to #.)
  • For the random item if a package has more than 1 item drop/spawn feature it could possibly allow for 0 of an item to drop.
  • <MaximumItem #> (To limit how many items can drop from set package if you have more than 1 drop type...)
  • I/W/A/G as in Item,Weapon,Armor,Gold

Mockups
<<Its a script request for an item feature so no mockup... So here is a written example>>
Say there is an item "Damaged Box of Bullets"
Damaged Box of Bullets:
<R I:50 10> would spawn 1-10 of said item/armor/weapon.
<R I:51 5> would spawn 1-5 of said item/armor/weapon.

YES I know it can be done through EVENTS but I prefer to not make tons of events when it could be scripted.
Besides using the note tab would make it so simple and one would have a lot less chances to mess up.

Games its been in
  • I have no idea at all.
  • Could be done with eventing its just making an entire event tree when multiple item possibilities occur could get annoying for everyone.



Did you search?
<<YES>>

Where did you search?
  • hbgames
  • rpgmakervx
  • rmrk

What did you search for?
  • Item Package/Item Scripts (and in many many different ways)
« Last Edit: October 14, 2010, 05:12:06 PM by wsensor »

**
Rep:
Level 75
RMRK Junior
You should use the template, really...

**
Rep:
Level 75
RMRK Junior
Anyway, this was very easy, I hope it works fine. If you find bugs, tell me!

Code: [Select]
#------------------------------------------------------------------
#------------------------------------------------------------------
#                    The Mormegil's Item Pack
#                             v 1.0
#------------------------------------------------------------------
#------------------------------------------------------------------
# This script's purpose is to create some items that, when used,
# generate other items. For instance, you could create random gift boxes
# or bullet containers, or even trading cards booster packs! Useful for
# minigames too, or to create an easy random boon with just a couple of items
# and no mad eventing-fu.
# This script is easy to use, but beware the notetags! They are a bit difficult
# to use... Also, if you want to use lists, you'll need to configure a bit the script itself,
# but nothing too difficult.
#
# NOTETAG DESCRIPTION:
# Here is a list of notetags and their use.
# <item pack - max items item_number>
#    Substitute item_number with a number.
#    This notetag fixes a cap (item_number) for items to generate: if
#    any more items are generated after that, they will be deleted.
#    Remember that items are generated in notetags' order.
# <item pack - fixed: item_type item_ID item_number>
#    Substitute item_type with any one of: armor, weapon, item.
#    Substitute item_ID with the object's ID.
#    Substitute item_number with an integer.
#    This notetags generates a certain amount (item_number) of a specified item.
# <item pack - random: item_type item_ID item_range..item_range>
#    Substitute item_type with any one of: armor, weapon, item.
#    Substitute item_ID with the object's ID.
#    Substitute item_range with an integer in both instances.
#    This notetag generates a random amount (between the two item_range numbers)
#    of a specified item.
# <item pack - list: list_name>
#    Substitute list_name with your chosen list's name.
#    This command generates one item out of a list of specified items randomly.
#    You need to configure lists to use them - see below to know how!
#
# One last warning: the item's effect is usable just from the item scene. That could have problems with
# some custom item scenes - unlikely - and you should limit the item to "Usable in Menu Only" to avoid problems.
# Also, you MUST make the item with no target. Well, it even makes sense!
#------------------------------------------------------------------
#
#     $$$$$$$$$$$$$$$ CUSTOMIZATION OPTIONS $$$$$$$$$$$$$$$$$$$$
#
# If you want to use a list, you can create it directly here! To do so, create a name with just letters
# (say, "EXAMPLELIST") and add it to the following hash.
# As usual, beware the syntax! Every comma is important!
#
module TheMormegil      # DO NOT REMOVE!
  module ItemPack      # DO NOT REMOVE!
    LIST_HASH = {      # DO NOT REMOVE!
# Now, this is an example of a list. It generates a random item between the first 10 items, the
# first 10 weapons and the first 10 armors of the database.

      "EXAMPLELIST" => [
           ["item", 1, 1], # This is how to add an item to the list. In order, item type, item ID and number.

                        ["item", 2, 1], ["item", 3, 1], ["item", 4, 1], ["item", 5, 1],
                        ["item", 6, 1], ["item", 7, 1], ["item", 8, 1], ["item", 9, 1], ["item", 10, 1],
                        ["armor", 1, 1], ["armor", 2, 1], ["armor", 3, 1], ["armor", 4, 1], ["armor", 5, 1],
                        ["armor", 6, 1], ["armor", 7, 1], ["armor", 8, 1], ["armor", 9, 1], ["armor", 10, 1],
                        ["weapon", 1, 1], ["weapon", 2, 1], ["weapon", 3, 1], ["weapon", 4, 1], ["weapon", 5, 1],
                        ["weapon", 6, 1], ["weapon", 7, 1], ["weapon", 8, 1], ["weapon", 9, 1],

                        ["weapon", 10, 1] ],   #No last comma, but a bracket, and than comma!!
#
# You can create your lists here:



# Now, stop editing.
   }
  end
end
#
#------------------------------------------------------------------
#------------------------------------------------------------------
#------------------------------------------------------------------

#                   STOP EDITING PAST THIS POINT!
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#


$imported = {} if $imported == nil
$imported["Item_Pack"] = true

module TheMormegil
  module Regexp
    ITEM_PACK_MAX_ITEMS = /<item\spack\s\-\smax\sitems\s(\d+?)>/i
    ITEM_PACK_FIXED = /<item\spack\s\-\sfixed:\s(\w+)\s(\d+?)\s(\d+?)>/i
    ITEM_PACK_RANDOM = /<item\spack\s\-\srandom:\s(\w+)\s(\d+?)\s(\d+?)\.\.(\d+?)>/i
    ITEM_PACK_LIST = /<item\spack\s\-\slist:\s(\w+)>/i
  end
end

class Scene_Item < Scene_Base
  alias item_pack_use_item use_item_nontarget
  def use_item_nontarget
    item_pack_use_item
    pack = []
    lines = @item.note.split(/[\r\n]+/)
    for line in lines
      if line =~ TheMormegil::Regexp::ITEM_PACK_FIXED
        id = $2.to_i
        n = $3.to_i
        case $1.upcase
        when "ARMOR"
          item = $data_armors[id]
        when "ITEM"
          item = $data_items[id]
        when "WEAPON"
          item = $data_weapons[id]
        end
        i = 1
        while i <= n
          pack.push(item)
          i += 1
        end
      elsif line =~ TheMormegil::Regexp::ITEM_PACK_RANDOM
        id = $2.to_i
        start_range = $3.to_i
        end_range = $4.to_i
        n = rand(end_range - start_range) + start_range
        case $1.upcase
        when "ARMOR"
          item = $data_armors[id]
        when "ITEM"
          item = $data_items[id]
        when "WEAPON"
          item = $data_weapons[id]
        end
        i = 1
        while i <= n
          pack.push(item)
          i += 1
        end
      elsif line =~ TheMormegil::Regexp::ITEM_PACK_LIST
        key_for_list = $1
        list = TheMormegil::ItemPack::LIST_HASH[key_for_list]
        key_for_item = rand(list.size)
        item_array = list[key_for_item]
        id = item_array[1]
        n = item_array[2]
        case item_array[0].upcase
        when "ARMOR"
          item = $data_armors[id]
        when "ITEM"
          item = $data_items[id]
        when "WEAPON"
          item = $data_weapons[id]
        end
        i = 1
        while i <= n
          pack.push(item)
          i += 1
        end
      end
    end
    max_items = pack.size
    for line in lines
      if line =~ TheMormegil::Regexp::ITEM_PACK_MAX_ITEMS
        max_items = $1.to_i
      end
    end
    i = 0
    while i < max_items
      $game_party.gain_item(pack[i], 1)
      i += 1
    end
  end
end

**
Rep:
Level 84
Thank you!

I was originally doing this through events and it got really annoying and confusing after awhile.

-edit-

This has been really useful for me so far. Thank you.
« Last Edit: October 07, 2010, 06:00:20 PM by wsensor »