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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
| ################################################################################
=begin
Script de reserve d'objet
Auteur : ASHKA
Important !!
Placer ceci en insertion de script au tout debut du jeu ( premiere map )
( Dans un event en demarrage auto, puis apres activation d'un interrupteur local )
for i in $data_items
$reserve_objet[i.id] = 0
end
for i in $data_weapons
$reserve_arme[i.id] = 0
end
for i in $data_armors
$reserve_armure[i.id] = 0
end
Appel en insertion de script :
$scene = Scene_Reserve.new
=end
################################################################################
class Scene_Reserve < Scene_Base
def initialize(menu_index = 0)
@menu_index = menu_index
end
def start
super
create_menu_background
@help_window = Window_Help.new
@command = Window_Entete.new
@command.help_window = @help_window
@command.index = @menu_index
@sac = Window_Item.new(0, 120, 544, 296)
@sac.index = -1
@sac.visible = true
@sac.active = false
@reserve = Window_Reserve.new
@reserve.index = -1
@reserve.visible = false
@reserve.active = false
@transfert = Window_Transfert.new
@transfert.z = 150
@transfert.visible = false
end
def terminate
super
dispose_menu_background
@help_window.dispose
@command.dispose
@sac.dispose
@reserve.dispose
@transfert.dispose
end
def update
super
update_menu_background
@help_window.update
@command.update
@sac.update
@reserve.update
@transfert.update
if @command.active
update_command
elsif @sac.active
update_sac
elsif @reserve.active
update_reserve
elsif @transfert.visible
update_transfert
end
end
def update_command
case @command.index
when 0
@sac.visible = true
@reserve.visible = false
when 1
@sac.visible = false
@reserve.visible = true
end
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
Sound.play_decision
case @command.index
when 0
@sac.active = true
@sac.index = 0
@command.active = false
@command.index = -1
when 1
@reserve.active = true
@reserve.index = 0
@command.active = false
@command.index = -1
end
end
end
def update_sac
if Input.trigger?(Input::B)
Sound.play_cancel
@command.active = true
@command.index = 0
@sac.active = false
@sac.index = -1
elsif Input.trigger?(Input::C)
@type = "sac"
@item = @sac.item
if @item != nil
Sound.play_decision
max = $game_party.item_number(@item)
@transfert.set(@type, @item, max)
@transfert.visible = true
@sac.active = false
else
Sound.play_buzzer
end
end
end
def update_reserve
if Input.trigger?(Input::B)
Sound.play_cancel
@command.active = true
@command.index = 1
@reserve.active = false
@reserve.index = -1
elsif Input.trigger?(Input::C)
@type = "reserve"
@item = @reserve.item
if @item != nil
Sound.play_decision
if @item.is_a?(RPG::Item)
max = $reserve_objet[@item.id]
elsif @item.is_a?(RPG::Weapon)
max = $reserve_arme[@item.id]
elsif @item.is_a?(RPG::Armor)
max = $reserve_armure[@item.id]
end
@transfert.set(@type, @item, max)
@transfert.visible = true
@reserve.active = false
else
Sound.play_buzzer
end
end
end
def update_transfert
if Input.trigger?(Input::B)
Sound.play_cancel
if @type == "sac"
@sac.active = true
elsif @type == "reserve"
@reserve.active = true
end
@transfert.visible = false
elsif Input.trigger?(Input::C)
Sound.play_decision
if @type == "sac"
$game_party.lose_item(@item, @transfert.number)
if @item.is_a?(RPG::Item)
$reserve_objet[@item.id] += @transfert.number
elsif @item.is_a?(RPG::Weapon)
$reserve_arme[@item.id] += @transfert.number
elsif @item.is_a?(RPG::Armor)
$reserve_armure[@item.id] += @transfert.number
end
@sac.active = true
@sac.refresh
@reserve.refresh
@transfert.visible = false
elsif @type == "reserve"
if @item.is_a?(RPG::Item)
$reserve_objet[@item.id] -= @transfert.number
elsif @item.is_a?(RPG::Weapon)
$reserve_arme[@item.id] -= @transfert.number
elsif @item.is_a?(RPG::Armor)
$reserve_armure[@item.id] -= @transfert.number
end
$game_party.gain_item(@item, @transfert.number)
@reserve.active = true
@reserve.refresh
@sac.refresh
@transfert.visible = false
end
end
end
end # Scene_Reserve
################################################################################
class Window_Transfert < Window_Base
def initialize
super(32, 157, 480, 102)
@type = type
@depart = nil
@max = 1
@number = 0
end
def set(type, depart, max)
@type = type
@depart = depart
@max = max
@number = 0
refresh
end
def number
return @number
end
def refresh
self.contents.clear
self.contents.font.color = normal_color
if @type == "sac"
self.contents.draw_text(200, 0, 100, 32, "Inventaire", 1)
self.contents.draw_text(300, 0, 50, 32, " ==> ", 1)
self.contents.draw_text(350, 0, 100, 32, "Reserve", 1)
elsif @type == "reserve"
self.contents.draw_text(200, 0, 100, 32, "Reserve", 1)
self.contents.draw_text(300, 0, 50, 32, " ==> ", 1)
self.contents.draw_text(350, 0, 100, 32, "Inventaire", 1)
end
draw_item_name(@depart, 0, 40)
if @depart.is_a?(RPG::Item)
num = $reserve_objet[@depart.id]
elsif @depart.is_a?(RPG::Weapon)
num = $reserve_arme[@depart.id]
elsif @depart.is_a?(RPG::Armor)
num = $reserve_armure[@depart.id]
end
if @type == "sac"
self.contents.draw_text(240, 40, 40, 32, ($game_party.item_number(@depart) - @number).to_s)
self.contents.draw_text(300, 40, 50, 32, " ==> ", 1)
self.contents.draw_text(390, 40, 40, 32, (num + @number).to_s)
elsif @type == "reserve"
self.contents.draw_text(240, 40, 40, 32, (num - @number).to_s)
self.contents.draw_text(300, 40, 50, 32, " ==> ", 1)
self.contents.draw_text(390, 40, 40, 32, ($game_party.item_number(@depart) + @number).to_s)
end
end
def update
super
if self.active
last_number = @number
if Input.repeat?(Input::RIGHT) and @number < @max
unless @type == "reserve" and ($game_party.item_number(@depart) + @number) == 99
@number += 1
end
end
if Input.repeat?(Input::LEFT) and @number >= 1
@number -= 1
end
if Input.repeat?(Input::UP) and (@number + 10) <= @max
unless @type == "reserve" and ($game_party.item_number(@depart) + @number + 10) > 99
@number += 10
end
end
if Input.repeat?(Input::DOWN) and (@number - 10) >= 0
@number -= 10
end
if @number != last_number
Sound.play_cursor
refresh
end
end
end
end
################################################################################
class Window_Reserve < Window_Selectable
def initialize
super(0, 120, 544, 296)
@column_max = 2
self.index = 0
refresh
end
def item
return @data[self.index]
end
def include?(item)
return false if item == nil
if $game_temp.in_battle
return false unless item.is_a?(RPG::Item)
end
return true
end
def enable?(item)
return $game_party.item_can_use?(item)
end
def refresh
@data = []
for item in $data_items
if $reserve_objet[item.id] != 0
next unless include?(item)
@data.push(item)
if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
self.index = @data.size - 1
end
end
end
for item in $data_weapons
if $reserve_arme[item.id] != 0
next unless include?(item)
@data.push(item)
end
end
for item in $data_armors
if $reserve_armure[item.id] != 0
next unless include?(item)
@data.push(item)
end
end
@data.push(nil) if include?(nil)
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if item != nil
if item.is_a?(RPG::Item)
number = $reserve_objet[item.id]
elsif item.is_a?(RPG::Weapon)
number = $reserve_arme[item.id]
elsif item.is_a?(RPG::Armor)
number = $reserve_armure[item.id]
end
enabled = enable?(item)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enabled)
self.contents.draw_text(rect, sprintf(":%2d", number), 2)
end
end
def update_help
@help_window.set_text(item == nil ? "" : item.description)
end
end
################################################################################
class Window_Entete < Window_Selectable
def initialize
super(0, 56, 544, 64)
@item_max = 2
@column_max = 2
@index = -1
refresh
end
def refresh
self.contents.clear
@data = ["Inventaire", "Reserve"]
for i in 0..@data.size
self.contents.draw_text(i * 256, 0, 256, 32, @data[i].to_s, 1)
end
end
def update_cursor
if @index < 0
self.cursor_rect.empty
else
row = @index / @column_max
if row < top_row
self.top_row = row
end
if row > bottom_row
self.bottom_row = row
end
rect = Rect.new(0, 0, 0, 0)
rect.width = 256
rect.height = WLH
rect.x = @index * 256
rect.y = 5
self.cursor_rect = rect
end
end
def update_help
text = ""
case @index
when 0
text = "Permet de gerer les objets de l'inventaire."
when 1
text = "Permet de gerer les objets mis en reserve."
end
@help_window.set_text(text, 1)
end
end # class Window_Detection
################################################################################
class Scene_Title < Scene_Base
def start
super
$reserve_objet = Hash.new(0)
$reserve_arme = Hash.new(0)
$reserve_armure = Hash.new(0)
load_database # Load database
create_game_objects # Create game objects
check_continue # Determine if continue is enabled
create_title_graphic # Create title graphic
create_command_window # Create command window
play_title_music # Play title screen music
end
end
################################################################################
class Scene_File < Scene_Base
def write_save_data(file)
characters = []
for actor in $game_party.members
characters.push([actor.character_name, actor.character_index])
end
$game_system.save_count += 1
$game_system.version_id = $data_system.version_id
@last_bgm = RPG::BGM::last
@last_bgs = RPG::BGS::last
Marshal.dump(characters, file)
Marshal.dump(Graphics.frame_count, file)
Marshal.dump(@last_bgm, file)
Marshal.dump(@last_bgs, file)
Marshal.dump($game_system, file)
Marshal.dump($game_message, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
Marshal.dump($reserve_objet, file)
Marshal.dump($reserve_arme, file)
Marshal.dump($reserve_armure, file)
end
def read_save_data(file)
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
@last_bgm = Marshal.load(file)
@last_bgs = Marshal.load(file)
$game_system = Marshal.load(file)
$game_message = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
$reserve_objet = Marshal.load(file)
$reserve_arme = Marshal.load(file)
$reserve_armure = Marshal.load(file)
if $game_system.version_id != $data_system.version_id
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
end
end |