My favorites
▼
|
Sign in
sabakan
RPGツクールVXのスクリプト素材置き場です
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
戦闘システム関係
/
戦闘中の装備変更.rb
‹r165
r286
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
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
#==============================================================================
# ■ 戦闘中の装備変更
# @version 0.21 11/01/18
# @author さば缶
#------------------------------------------------------------------------------
# 戦闘中に装備を変更できます。
#==============================================================================
module Saba
module EquipInBattle
# 装備の解除を許可する場合、true に設定します。
ENABLE_REMOVE = true
# ボタンの離しで装備を決定する場合、true に設定します。
DECIDE_AT_RELEASE = true
# ヘルプウィンドウを表示する場合、true に設定します。
SHOW_HELP_WINDOW = true
# 装備ウィンドウを開いている間、LRキーで装備の種類を変更できるようにする場合 true に設定します。
ENABLE_LR_PAGE_CHANGE = false
# LRキーで装備の種類を変更できるようにする場合の、ページの順番です。
# 1→武器
# 2→盾(二刀流だと武器2)
# 3→頭防具
# 4→身体防具
# 5→装飾品
# です。
#
# ※ KGC さんの装備拡張と併用する場合、
# 1→武器
# 2→EQUIP_TYPE の 1 番目
# 3→EQUIP_TYPE の 2 番目
# 4→EQUIP_TYPE の 3 番目・・・・・・ になります。
#
# ENABLE_LR_PAGE_CHANGE が true の時のみ有効です。
PAGE_ORDER = [1, 2, 3] # LR で武器、盾、頭防具がきりかわる
# 装備部位を表示する場合、true に設定します。
SHOW_EQUIP_TYPE = true
# 装備部位を表示するテキストのフォントサイズです。
LABEL_FONT_SIZE = 16
# 装備部位を表示するテキスト位置です。
LABEL_X = 280
LABEL_Y = 98
# 部位を変更するボタンです。
# デフォルトでは
# 1→武器
# 2→盾(二刀流だと武器2)
# 3→頭防具
# 4→身体防具
# 5→装飾品
# です。
# 6以降は予備。
#
# ※ KGC さんの装備拡張と併用する場合、
# 1→武器
# 2→EQUIP_TYPE の 1 番目
# 3→EQUIP_TYPE の 2 番目
# 4→EQUIP_TYPE の 3 番目・・・・・・ になります。
EQUIP1_BUTTON = Input::A
EQUIP2_BUTTON = Input::X
EQUIP3_BUTTON = nil
EQUIP4_BUTTON = nil
EQUIP5_BUTTON = nil
EQUIP6_BUTTON = nil
EQUIP7_BUTTON = nil
EQUIP8_BUTTON = nil
# ウサギマスクさん家の弾丸に対応、する予定。
BULLET_BUTTON = nil
# 装備変更のステータスウィンドウの座標です。
STATUS_WINDOW_X = 54
STATUS_WINDOW_Y = 128
# 装備アイテムのウィンドウの座標です。
EQUIP_WINDOW_X = 276
EQUIP_WINDOW_Y = 128
# 装備アイテムのウィンドウの横幅です。
EQUIP_WINDOW_WIDTH = 266
# 装備アイテムウィンドウの行数です。
EQUIP_WINDOW_LINE_NUMBER = 5
# 装備変更により、ターンを消費するかどうかのフラグです。
CONSUME_TURN = false
###### 以下、ターンを消費する場合用の設定です。
# 装備変更メッセージの表示時間です。
EQUIP_MESSAGE_WAIT = 45
# 装備変更時のメッセージです。
EQUIP_MESSAGE = "%sは %s を装備した。"
# 装備アイテムが存在せず、装備変更に失敗した時のメッセージです。
FAILED_TO_EQUIP_MESSAGE = "%sは %s を装備しようとしたができなかった。"
# 装備を外した時のメッセージです。
REMOVE_EQUIP_MESSAGE = "%s は装備を外した。"
############
# 弾丸専用の装備タイプ。さわらなくても大丈夫だと思います。
BULLET_TYPE = 12345
# 装備変更の種類。こっちもさわらないで大丈夫かと。
EQUIP_KIND = 8714
end
end
$imported = {} if $imported == nil
$imported["EquipInBattle"] = true
class Window_EquipBattle < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# x : ウィンドウの X 座標
# y : ウィンドウの Y 座標
# width : ウィンドウの幅
# height : ウィンドウの高さ
#--------------------------------------------------------------------------
def initialize(x, y, width, height, actor, equip_type, equip_index)
super(x, y, width, height)
@actor = actor
@equip_type = equip_type
@equip_index = equip_index
@column_max = 1
self.index = 0
refresh
end
#--------------------------------------------------------------------------
# ● アイテムの取得
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
def changed?
return self.index != 0
end
#--------------------------------------------------------------------------
# ● アイテムをリストに含めるかどうか
# item : アイテム
#--------------------------------------------------------------------------
def include?(item)
if item == nil
if Saba::EquipInBattle::ENABLE_REMOVE
return @actor.equips[@equip_index] != nil
else
return false
end
end
if @equip_type == 0 || (@equip_type == 1 and @actor.two_swords_style)
return false unless item.is_a?(RPG::Weapon)
elsif @equip_type == Saba::EquipInBattle::BULLET_TYPE
return item.bullet?
else
return false unless item.is_a?(RPG::Armor)
return false unless item.kind == @equip_type - 1
end
return false unless @actor.equippable?(item)
if $imported["EquipExtension"]
return false unless @actor.ep_condition_clear?(@equip_index, item) # EP 不足
end
return true
end
#--------------------------------------------------------------------------
# ● アイテムを許可状態で表示するかどうか
# item : アイテム
#--------------------------------------------------------------------------
def enable?(item)
return true
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
@data = []
if @equip_type == Saba::EquipInBattle::BULLET_TYPE
@data += [@actor.bullet]
else
@data += [@actor.equips[@equip_index]]
end
for item in $game_party.items
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
@data.push(nil) if include?(nil)
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# ● 項目の描画
# index : 項目番号
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if item != nil
number = $game_party.item_number(item)
enabled = enable?(item)
rect.width -= 4
draw_item_name(item, rect.x + 24, rect.y, enabled)
if index == 0 && ! @actor.weapons.empty?
bitmap = Cache.system("equip_marker")
self.contents.blt(rect.x, rect.y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
else
self.contents.draw_text(rect, sprintf(":%2d", number), 2)
end
end
end
def draw_item_name(item, x, y, enabled = true)
if item != nil
draw_icon(item.icon_index, x, y, enabled)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
w = Saba::EquipInBattle::EQUIP_WINDOW_WIDTH - 112
self.contents.draw_text(x + 24, y, w, WLH, item.name)
end
end
#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def update_help
return if @help_window == nil
@help_window.set_text(item == nil ? "" : item.description)
end
end
class Scene_Battle
#--------------------------------------------------------------------------
# ● アクターコマンド選択の更新
#--------------------------------------------------------------------------
alias saba_equip_in_battle_update_actor_command_selection update_actor_command_selection
def update_actor_command_selection
if @equip_window != nil
@equip_window.update
update_status_window
if Saba::EquipInBattle::DECIDE_AT_RELEASE
unless Input.press?(@equip_button)
decide_equip
end
else
if Input.trigger?(Input::C)
decide_equip
end
if Input.trigger?(Input::B)
cancel_equip
end
end
if Saba::EquipInBattle::ENABLE_LR_PAGE_CHANGE
if Input.trigger?(Input::R)
next_page
refresh_equip_window
elsif Input.trigger?(Input::L)
previous_page
refresh_equip_window
end
end
return
else
if change_equip?
open_equip_window
return
end
end
saba_equip_in_battle_update_actor_command_selection
end
def refresh_equip_window
close_equip_window
open_equip_window(false)
Sound.play_cursor
update_equip_label
end
def change_equip?
if Saba::EquipInBattle::EQUIP1_BUTTON != nil && Input.trigger?(Saba::EquipInBattle::EQUIP1_BUTTON)
@equip_button = Saba::EquipInBattle::EQUIP1_BUTTON
@equip_type = 0
elsif Saba::EquipInBattle::EQUIP2_BUTTON != nil && Input.trigger?(Saba::EquipInBattle::EQUIP2_BUTTON)
@equip_button = Saba::EquipInBattle::EQUIP2_BUTTON
@equip_type = 1
elsif Saba::EquipInBattle::EQUIP3_BUTTON != nil && Input.trigger?(Saba::EquipInBattle::EQUIP3_BUTTON)
@equip_button = Saba::EquipInBattle::EQUIP3_BUTTON
@equip_type = 2
elsif Saba::EquipInBattle::EQUIP4_BUTTON != nil && Input.trigger?(Saba::EquipInBattle::EQUIP4_BUTTON)
@equip_button = Saba::EquipInBattle::EQUIP4_BUTTON
@equip_type = 3
elsif Saba::EquipInBattle::EQUIP5_BUTTON != nil && Input.trigger?(Saba::EquipInBattle::EQUIP5_BUTTON)
@equip_button = Saba::EquipInBattle::EQUIP5_BUTTON
@equip_type = 4
elsif Saba::EquipInBattle::EQUIP6_BUTTON != nil && Input.trigger?(Saba::EquipInBattle::EQUIP6_BUTTON)
@equip_button = Saba::EquipInBattle::EQUIP6_BUTTON
@equip_type = 5
elsif Saba::EquipInBattle::EQUIP7_BUTTON != nil && Input.trigger?(Saba::EquipInBattle::EQUIP7_BUTTON)
@equip_button = Saba::EquipInBattle::EQUIP7_BUTTON
@equip_type = 6
elsif Saba::EquipInBattle::EQUIP8_BUTTON != nil && Input.trigger?(Saba::EquipInBattle::EQUIP8_BUTTON)
@equip_button = Saba::EquipInBattle::EQUIP8_BUTTON
@equip_type = 7
elsif Saba::EquipInBattle::BULLET_BUTTON != nil && Input.trigger?(Saba::EquipInBattle::BULLET_BUTTON)
return false unless @active_battler.equip_gun?
@equip_button = Saba::EquipInBattle::BULLET_BUTTON
@equip_type = Saba::EquipInBattle::BULLET_TYPE
else
return false
end
@equip_index = @equip_type
if $imported["EquipExtension"]
if @equip_type != 0
@equip_type = KGC::EquipExtension::EQUIP_TYPE[@equip_type - 1] + 1
end
end
return true
end
def next_page
index = Saba::EquipInBattle::PAGE_ORDER.index(@equip_index + 1)
return if index == nil
index += 1
if Saba::EquipInBattle::PAGE_ORDER.size == index
index = 0
end
@equip_type = Saba::EquipInBattle::PAGE_ORDER[index] - 1
@equip_index = @equip_type
if $imported["EquipExtension"]
if @equip_type != 0
@equip_type = KGC::EquipExtension::EQUIP_TYPE[@equip_type - 1] + 1
end
end
end
def previous_page
index = Saba::EquipInBattle::PAGE_ORDER.index(@equip_index + 1)
return if index == nil
index -= 1
if Saba::EquipInBattle::PAGE_ORDER.size == index
index = 0
end
@equip_type = Saba::EquipInBattle::PAGE_ORDER[index] - 1
@equip_type = Saba::EquipInBattle::PAGE_ORDER[index] - 1
@equip_index = @equip_type
if $imported["EquipExtension"]
if @equip_type != 0
@equip_type = KGC::EquipExtension::EQUIP_TYPE[@equip_type - 1] + 1
end
end
end
def cancel_equip
Sound.play_cancel
close_equip_window
update_action_forecast if $imported["KisekiBattle"] && Saba::EquipInBattle::CONSUME_TURN
end
def decide_equip
unless @equip_window.changed?
cancel_equip
else
if Saba::EquipInBattle::CONSUME_TURN
if @equip_type == Saba::EquipInBattle::BULLET_TYPE
@active_battler.action.set_bullet(@equip_window.item)
else
@active_battler.action.equip(@equip_index, @equip_window.item)
end
Sound.play_decision
close_equip_window
next_actor
else
if @equip_type == Saba::EquipInBattle::BULLET_TYPE
@active_battler.set_bullet(@equip_window.item)
@rest_bullet_window.setup(@active_battler)
else
@active_battler.change_equip(@equip_index, @equip_window.item, false)
end
Sound.play_equip
close_equip_window
end
end
end
#--------------------------------------------------------------------------
# ● ステータスウィンドウの更新
#--------------------------------------------------------------------------
def update_status_window
unless @equip_window.changed?
@equip_status.set_new_parameters(nil, nil, nil, nil)
else
if $imported["EquipExtension"]
temp_actor = Marshal.load(Marshal.dump(@active_battler))
else
temp_actor = @active_battler.clone
end
if @equip_type == Saba::EquipInBattle::BULLET_TYPE
temp_actor.set_bullet(@equip_window.item)
else
temp_actor.change_equip(@equip_index, @equip_window.item, true)
end
new_atk = temp_actor.atk
new_def = temp_actor.def
new_spi = temp_actor.spi
new_agi = temp_actor.agi
@equip_status.set_new_parameters(new_atk, new_def, new_spi, new_agi)
end
@equip_status.update
end
def close_equip_window
@equip_window.dispose
@equip_window = nil
@equip_status.dispose
@equip_status = nil
@equip_label_sprite.bitmap.dispose
@equip_label_sprite.dispose
@equip_label_sprite = nil
if $imported["SekaijuBattle"]
@face_sprite.appear = true
if Saba::EquipInBattle::SHOW_HELP_WINDOW
@help_window.row_max = 1 if $imported["HelpExtension"]
@help_window.set_text(Saba::Sekaiju::COMMAND_MESSAGE)
@equip_help_window = nil
return
end
end
@equip_help_window.dispose
@equip_help_window = nil
end
def open_equip_window(play_se = true)
if $imported["SekaijuBattle"]
@face_sprite.hide = true
@face_sprite.appear = false
end
if @active_battler.fix_equipment
Sound.play_buzzer if play_se
return
end
Sound.play_decision if play_se
line_number = Saba::EquipInBattle::EQUIP_WINDOW_LINE_NUMBER
x = Saba::EquipInBattle::EQUIP_WINDOW_X
y = Saba::EquipInBattle::EQUIP_WINDOW_Y
w = Saba::EquipInBattle::EQUIP_WINDOW_WIDTH
h = Window_Base::WLH * line_number + 32
@equip_window = Window_EquipBattle.new(x, y, w, h, @active_battler, @equip_type, @equip_index)
@equip_window.visible = true
@equip_status = Window_EquipStatus.new(Saba::EquipInBattle::STATUS_WINDOW_X, Saba::EquipInBattle::STATUS_WINDOW_Y, @active_battler)
if $imported["SekaijuBattle"] && Saba::EquipInBattle::SHOW_HELP_WINDOW
@equip_help_window = @help_window
else
@equip_help_window = Window_Help.new
end
@equip_help_window.visible = Saba::EquipInBattle::SHOW_HELP_WINDOW
if $imported["HelpExtension"]
@equip_help_window.row_max = KGC::HelpExtension::ROW_MAX
end
@equip_window.help_window = @equip_help_window
create_label_sprite
update_action_forecast if $imported["KisekiBattle"] && Saba::EquipInBattle::CONSUME_TURN
end
def create_label_sprite
return if @equip_label_sprite != nil
@equip_label_sprite = Sprite_Base.new
@equip_label_sprite.bitmap = Bitmap.new(200, 40)
@equip_label_sprite.bitmap.font.size = Saba::EquipInBattle::LABEL_FONT_SIZE
@equip_label_sprite.x = Saba::EquipInBattle::LABEL_X
@equip_label_sprite.y = Saba::EquipInBattle::LABEL_Y
update_equip_label
end
def update_equip_label
return unless Saba::EquipInBattle::SHOW_EQUIP_TYPE
@equip_label_sprite.bitmap.clear_rect(0, 0, 200, 40)
@equip_label_sprite.bitmap.draw_text(0, 0, 200, 40, equip_label)
end
def equip_label
case @equip_type
when 0
return Vocab::weapon1 if @active_battler.two_swords_style
return Vocab::weapon
when 1
return Vocab::weapon2 if @active_battler.two_swords_style
return Vocab::armor1
when 2
return Vocab::armor2
when 3
return Vocab::armor3
when 4
return Vocab::armor4
end
if $imported["EquipExtension"]
types = KGC::EquipExtension::EXTRA_EQUIP_KIND
return types[@equip_type - 5]
end
return ""
end
if $imported["SekaijuBattle"]
def update_info_viewport
unless @state_mode && (Saba::Sekaiju::INFO_TYPE == 1)
@actor_command_window.update if (! @waiting) && (@equip_window == nil)
end
if Saba::Sekaiju::INFO_TYPE == 2
unless Saba::Sekaiju::DISPLAY_ALWAYS
@enemy_state_sprite.visible = @status_window.state_mode
end
end
@status_window.update
@enemy_damage_sprite.update
@enemy_state_sprite.update
if @face_sprite.hide
if @actor_viewport.ox < 576
@actor_viewport.ox += Saba::Sekaiju::DISTANCE_PER_FRAME
else
@face_sprite.hide = false
end
elsif @face_sprite.appear
if @actor_viewport.ox > 0
@actor_viewport.ox -= Saba::Sekaiju::DISTANCE_PER_FRAME
else
@face_sprite.appear = false
end
end
end
else
def update_info_viewport
@party_command_window.update
@actor_command_window.update if @equip_window == nil
@status_window.update
if @party_command_window.active and @info_viewport.ox > 0
@info_viewport.ox -= 16
elsif @actor_command_window.active and @info_viewport.ox < 128
@info_viewport.ox += 16
end
end
end
#--------------------------------------------------------------------------
# ● 戦闘行動の実行
#--------------------------------------------------------------------------
alias saba_equip_in_battle_execute_action execute_action
def execute_action
saba_equip_in_battle_execute_action
if @active_battler.action.equip?
execute_equip
return
end
end
#--------------------------------------------------------------------------
# ● 装備の変更
#--------------------------------------------------------------------------
def execute_equip
actor = @active_battler
Sound.play_equip
item = actor.action.equip_item
if item == nil
text = sprintf(Saba::EquipInBattle::REMOVE_EQUIP_MESSAGE, actor.name)
actor.change_equip(actor.action.equip_type, item, false)
elsif $game_party.item_number(item) == 0
text = sprintf(Saba::EquipInBattle::FAILED_TO_EQUIP_MESSAGE, actor.name, item.name)
else
text = sprintf(Saba::EquipInBattle::EQUIP_MESSAGE, actor.name, item.name)
actor.change_equip(actor.action.equip_type, item, false)
end
@message_window.add_instant_text(text)
wait(Saba::EquipInBattle::EQUIP_MESSAGE_WAIT)
end
end
class Game_BattleAction
attr_reader :equip_type
attr_reader :equip_item
def equip(equip_type, equip_item)
@kind = Saba::EquipInBattle::EQUIP_KIND
@basic = 0
@equip_type = equip_type
@equip_item = equip_item
end
def equip?
return @kind == Saba::EquipInBattle::EQUIP_KIND
end
alias saba_equip_in_battle_clear clear
def clear
saba_equip_in_battle_clear
@equip_type = nil
@equip_item = nil
end
end
Show details
Hide details
Change log
r282
by taniguchi03 on Jan 18, 2011
Diff
装備固定のキャラの装備が変更できてしまうバグを修正
Go to:
...係/戦闘中の装備変更.rb
Project members,
sign in
to write a code review
Older revisions
r165
by s...@sabakan.cc on Oct 16, 2009
Diff
バグ修正
r164
by s...@sabakan.cc on Oct 16, 2009
Diff
初期パラメータを変更
r163
by s...@sabakan.cc on Oct 16, 2009
Diff
KGCさんの装備拡張と併用可能にした
All revisions of this file
File info
Size: 21042 bytes, 594 lines
View raw file
Powered by
Google Project Hosting