Anyway, this was very easy, I hope it works fine. If you find bugs, tell me!
#------------------------------------------------------------------
#------------------------------------------------------------------
# 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