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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
| #===================================================================
# Equipment Requirements [VX]
# by Ayene
# 27.01.2010 ver 1.2
# www.ultimateam.pl
#===================================================================
# Description:
# The script allows you to set requirements for weapon and armor.
# For instance, outfitting a hero with two-handed axe would be possible
# only after reaching a specific level or having adequate statistics.
# Also added an option that allows to require certain skills.
#
# Instruction:
# To use the script insert tag into the "Notes" box located in the
# Weapon or Armor tab of the database:
# <stat_require LV, MAXHP, MAXMP, ATK, DEF, SPI, AGI>,
# where:
# LV - required actor's level
# MAXHP - maximum HP
# MAXMP - maximum MP
# ATK - Attack
# DEF - Defence
# SPI - Spirit
# AGI - Agility
#
# For example:
# If you want a character to equip a weapon at level 6, provided that
# it has 120 max HP, 40 Attack, 70 Defence,
# add in the specified weapon's "Note" box:
# <stat_require 6, 120, 0, 40, 70, 0, 0>
#
# Next, to equip an armor, which "requires" adequate agility:
# <stat_require 0, 0, 0, 0, 0, 0, 50>
#
# To set that the specified armor can be equipped only after gaining
# certain skill(s), add in "Note" box:
# <skill_require ID, ID, ...>
# where:
# ID - required skill(s) ID(s)
# For example:
# To equip an weapon, that "requires" skills ID 10 and 40:
# <skill_require 10, 40>
#===================================================================
module AYENE
module ItemSpec
ITEM_SPEC = /<(?:STAT_REQUIRE|stat_require)\s*(\d+)\s*, \s*(\d+), \s*(\d+), \s*(\d+), \s*(\d+), \s*(\d+), \s*(\d+)>/i
WEAPON_TEXT = "Pour équiper cette arme vous devez avoir:"
ARMOR_TEXT = "Pour équiper cette armure vous devez avoir:"
ACC_TEXT = "Pour équiper cet accessoire vous devez avoir:"
PARAM_NAMES = ["Niveau", "Max HP", "Max MP", "Attaqua", "Défense", "Intelligence", "Agilité", "Magie:"]
SKILL_SPEC = /<(?:SKILL_REQUIRE|skill_require)[ ]*(\d+(?:[ ]*,[ ]*\d+)*)>/i
SHOW_SKILL_REC = true # Show which skill is needed? (true/false)
end
end
#===================================================================
# ** RPG::BaseItem
#===================================================================
class RPG::BaseItem
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :spec_params
#--------------------------------------------------------------------------
# * Requirements Initialization
#--------------------------------------------------------------------------
def equip_req_ini
@spec_params = {}
(0..6).each{|i| @spec_params<i> = 0}
@spec_params[7] = []
self.note.split(/[\r\n]+/).each { |line|
case line
when AYENE::ItemSpec::ITEM_SPEC
@spec_params[0] = $1.to_i
@spec_params[1] = $2.to_i
@spec_params[2] = $3.to_i
@spec_params[3] = $4.to_i
@spec_params[4] = $5.to_i
@spec_params[5] = $6.to_i
@spec_params[6] = $7.to_i
end
}
self.note.split(/[\r\n]+/).each { |line|
case line
when AYENE::ItemSpec::SKILL_SPEC
$1.scan(/\d+/).each { |num|
skill_id = num.to_i
@spec_params[7].push(skill_id) if $data_skills[skill_id] != nil
}
end
}
end
end
#===================================================================
# ** RPG::Weapon
#===================================================================
class RPG::Weapon < RPG::BaseItem
#--------------------------------------------------------------------------
# * Requirements Text
#--------------------------------------------------------------------------
def eqreq_text
return AYENE::ItemSpec::WEAPON_TEXT
end
end
#===================================================================
# ** RPG::Armor
#===================================================================
class RPG::Armor < RPG::BaseItem
#--------------------------------------------------------------------------
# * Requirements Text
#--------------------------------------------------------------------------
def eqreq_text
case kind
when 3
return AYENE::ItemSpec::ACC_TEXT
else
return AYENE::ItemSpec::ARMOR_TEXT
end
end
end
#===================================================================
# ** Game_Actor
#===================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Determine if Item can be Equipped (Actor's Parameters)
#--------------------------------------------------------------------------
def equip_allowed?(item)
return true if (item.spec_params[0] <= level && item.spec_params[1] <= base_maxhp &&
item.spec_params[2] <= base_maxmp && item.spec_params[3] <= base_atk &&
item.spec_params[4] <= base_def && item.spec_params[5] <= base_spi &&
item.spec_params[6] <= base_agi) && equip_skill_allowed?(item)
return false
end
#--------------------------------------------------------------------------
# * Determine if Item can be Equipped (Actor's Skills )
#--------------------------------------------------------------------------
def equip_skill_allowed?(item)
item.spec_params[7].each{|skill_id|
return false if !skill_learn?($data_skills[skill_id])
}
return true
end
end
#===================================================================
# ** Game_Interpreter
#===================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# * Aliased Definitions
#--------------------------------------------------------------------------
alias aye_eqreq_command_315 command_315
alias aye_eqreq_command_316 command_316
alias aye_eqreq_command_317 command_317
alias aye_eqreq_command_318 command_318
#--------------------------------------------------------------------------
# * Check Equipment
# actor : actor
#--------------------------------------------------------------------------
def check_change_equip(actor)
for i in 0..4
item = actor.equips<i>
actor.change_equip(i, nil) if !item.nil? && !actor.equip_allowed?(item)
end
end
#--------------------------------------------------------------------------
# * Change EXP
#--------------------------------------------------------------------------
def command_315
aye_eqreq_command_315
iterate_actor_id(@params[0]) do |actor|
check_change_equip(actor)
end
end
#--------------------------------------------------------------------------
# * Change Level
#--------------------------------------------------------------------------
def command_316
aye_eqreq_command_316
iterate_actor_id(@params[0]) do |actor|
check_change_equip(actor)
end
end
#--------------------------------------------------------------------------
# * Change Parameters
#--------------------------------------------------------------------------
def command_317
aye_eqreq_command_317
iterate_actor_id(@params[0]) do |actor|
check_change_equip(actor)
end
end
#--------------------------------------------------------------------------
# * Change Skills
#--------------------------------------------------------------------------
def command_318
aye_eqreq_command_318
iterate_actor_id(@params[0]) do |actor|
check_change_equip(actor)
end
end
end
#===================================================================
# ** Window_EquipReq
#===================================================================
class Window_EquipReq < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# item : item
# data : parameters (array)
# actor : actor
# skill : skill
#--------------------------------------------------------------------------
def initialize(item, data, actor, skill)
if skill.empty? or !AYENE::ItemSpec::SHOW_SKILL_REC
height = (data.size+1) / 2 * WLH + WLH + 32
else
height = (data.size+1) / 2 * WLH + WLH + 32 + WLH * [skill.size, 7].min
end
super(42, 180 - height/2, 460, height)
self.back_opacity = 255
self.contents.font.color = crisis_color
self.contents.draw_text(4, 0, self.width - 40, WLH, item.eqreq_text, 1)
x = 10
y = WLH
data.each_with_index{|array, i|
self.contents.font.color = system_color
self.contents.draw_text(x+i%2*240, y+i/2*WLH, 200, WLH, AYENE::ItemSpec::PARAM_NAMES[array[0]].to_s, 0)
self.contents.font.color = normal_color
self.contents.draw_text(x+120+i%2*240, y+i/2*WLH, 40, WLH, array[1].to_s, 2)
}
if !skill.empty? and AYENE::ItemSpec::SHOW_SKILL_REC
size = (data.size+1)/2*WLH
self.contents.font.color = system_color
self.contents.draw_text(x, y+size, 200, WLH, AYENE::ItemSpec::PARAM_NAMES[7].to_s, 0)
self.contents.font.color = normal_color
skill.each_with_index{|id, i|
self.contents.draw_text(x+140, y+size+WLH*i, 200, WLH, "- #{$data_skills[id].name}", 0)
}
end
end
end
#===================================================================
# ** Window_EquipItem
#===================================================================
class Window_EquipItem < Window_Item
#--------------------------------------------------------------------------
# * Determine if item is enabled
#--------------------------------------------------------------------------
def enable?(item)
return @actor.equip_allowed?(item)
end
end
#===================================================================
# ** Scene_Title
#===================================================================
class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# * Aliased Definitions
#--------------------------------------------------------------------------
alias aye_eqreq_sctit_loaddata load_database
#--------------------------------------------------------------------------
# * Load Database (aliased)
#--------------------------------------------------------------------------
def load_database
aye_eqreq_sctit_loaddata
for group in [$data_weapons, $data_armors]
for obj in group
next if obj.nil?
obj.equip_req_ini
end
end
end
end
#===================================================================
# ** Scene_Equip
#===================================================================
class Scene_Equip < Scene_Base
#--------------------------------------------------------------------------
# * Aliased Definitions
#--------------------------------------------------------------------------
alias aye_eqreq_sceq_update update
alias aye_eqreq_sceq_upditsel update_item_selection
#--------------------------------------------------------------------------
# * Update Frame (aliased)
#--------------------------------------------------------------------------
def update
if @eqreq_window != nil
update_eqreq_window
else
aye_eqreq_sceq_update
end
end
#--------------------------------------------------------------------------
# * Update Item Selection (aliased)
#--------------------------------------------------------------------------
def update_item_selection
@item = @item_window.item
if @item != nil and !@actor.equip_allowed?(@item) and Input.trigger?(Input::C)
Sound.play_buzzer
@item_window.active = false
show_eqreq_window
else
aye_eqreq_sceq_upditsel
end
end
#--------------------------------------------------------------------------
# * Show Requirements Window
#--------------------------------------------------------------------------
def show_eqreq_window
@frame = 0
data = []
@item.spec_params.each {|type, value|
data.push([type, value]) if value > 0 if type < 7
}
data.sort!{|a,b| a[0] <=> b[0]}
skill = @item.spec_params[7]
@eqreq_window = Window_EquipReq.new(@item, data, @actor, skill)
end
#--------------------------------------------------------------------------
# * Update Requirements Window
#--------------------------------------------------------------------------
def update_eqreq_window
@frame < 200 ? @frame += 1 : @frame = 0
if @frame == 200 or Input.trigger?(Input::C) or Input.trigger?(Input::B)
@eqreq_window.dispose
@eqreq_window = nil
@item_window.active = true
end
end
end |