1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
| #==============================================================================
#
# Chest Drop Randomizer v1.01
# by AdiktuzMiko
# --- Date Created: 15/05/2012
# --- Last Date Updated: 15/05/2012
# --- Level: Normal
# Requires: n/a
#
# Basically, this allows you to easily randomize items that you obtain from
# chests, etc. It also displays a message which tells you what item and how
# many of it was obtained.
#
#==============================================================================
#==============================================================================
# How To Install:
#
# Just put this anywhere before main and you're good to go.
#==============================================================================
#==============================================================================
# How To Use:
#
# Just call one of these functions:
#
# Chest::AddArmor(value, low, high, equip) -> for armor type items
# Chest::AddWeapon(value, low, high, equip) -> for weapon type items
# Chest::AddItem(value, low, high) -> for other items
#
# value = the amount of item to be added
# low = the low bound for the randomization [corresponds to id in the database]
# high = the high bound for the randomization [corresponds to id in the database]
# equip = whether to include the equipped items when checking
# for the maximum amount of item that the player can have
# -> by default, this is false
#
# Example:
#
# Chest::AddArmor(2, 1, 3)
#
# this will result to having 2 pieces of an armor which is randomized from
# the armor with the id of 1 up to the armor with an id of 3 at the database
#
# Since equip was not set, it will be false by default, so if for example
# the armor I obtained was armor 1, then I have 1 of it equipped and 97
# on the inventory, if the item limit is set to 99, then I will now have
# 99 armor 1 in the inventory + 1 equipped
#
# if I set it to true, I will only have 98 on my inventory even I originally have
# 97 only and the value was set to 2, since the 1 equipped will be included
# in the counting of item number
#
# To show the item obtain message just call
# Chest::ShowItemMessage()
#
# Note: Only call this function after you have finished adding all the item
# drops for the specific event, else it might malfunction.
#
# See the example events for a concrete look at how it is used.
#
#==============================================================================
#==============================================================================
# Changelog
#==============================================================================
#
#Version 1.01 - changed it into a module
#
#==============================================================================
POPUP_SOUND = 'Chime2'
POPUP_SOUND_VOLUME = 100
POPUP_SOUND_PITCH = 150
module Chest
#==============================================================================
# Do not touch anything below this line unless you know what you are doing.
#==============================================================================
$textitem = []
$textcount = 0
def self.ShowItemMessage
unless $game_message.busy
Audio.se_play('Audio/SE/' + POPUP_SOUND, POPUP_SOUND_VOLUME, POPUP_SOUND_PITCH)
$game_message.face_name = ""
$game_message.face_index = 0
$game_message.background = 1
$game_message.position = "bottom"
for i in 1..$textcount
$game_message.texts.push($textitem[i])
end
$textitem.clear()
$textcount = 0
end
return false
end
def self.AddArmor(value, low, high, equip = false)
ite = $data_armors[low + rand(high - low + 1)]
$game_party.gain_item(item, value, equip)
$textcount += 1
$textitem[$textcount] = (item.name + " (x" + value.to_s + ") acquired!")
end
def self.AddItem(value, low, high)
ite = $data_items[low + rand(high - low + 1) ]
$game_party.gain_item(item, value, false)
$textcount += 1
$textitem[$textcount] = (item.name + " (x" + value.to_s + ") acquired!")
end
def self.AddWeapon(value, low, high,equip = false)
ite = $data_weapons[low + rand(high - low + 1)]
$game_party.gain_item(item, value, equip)
$textcount += 1
$textitem[$textcount] = (item.name + " (x" + value.to_s + ") acquired!")
end
end |