My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
#==============================================================================
# ■ メガテンっぽいオートバトル
# @version 0.03 11/01/10
# @author さば缶
#------------------------------------------------------------------------------
# 女神転生のようなオートバトルシステムを組み込みます。
#
# ■オートバトルの方法
# パーティーコマンド選択中、もしくはアクターコマンド選択中に、
# AUTO_BATTLE_BUTTON で設定したボタンを押すと、
# オートバトルが開始されます。
# オートバトル中は、アクターの行動が全員通常攻撃になります。
# オートバトル中は戦闘アニメーションが表示されません。
# オート戦闘の継続ターンは一度押すとずっとオート戦闘が続き、
# 設定したキーかキャンセルキーを押せばオート状態が解除され、
# 全員が行動を終えた次のターンから選択できるようになります。
#
# ■スクリプトコマンド
# ○オートバトルを終了する
# キャンセルボタンを押したのと同じ効果を得られます。
# イベントコマンド3ページ目のスクリプトで以下のように記述します
# stop_auto_battle
#
# ○オートバトルを直ちに終了する
# ターンの途中であろうと、すぐさまオートバトルを終了させます。
# イベントコマンド3ページ目のスクリプトで以下のように記述します
# stop_auto_battle_immediately
#
# ○オートバトル中かどうかを調べる
# イベントコマンド1ページ目の条件分岐のスクリプトで以下のように記述します
# auto_battle?
#
# ○オートバトル用メッセージを表示する
# デフォだと、○○たちは一生懸命戦っている。 という文を表示します。
# メッセージ表示イベントの後、オートバトル中の場合に
# 元の文を表示させることを意図しています。
# イベントコマンド3ページ目のスクリプトで以下のように記述します
# display_auto_battle_message
#==============================================================================
module Saba
module SJAuto
# このボタンを押すとオートバトルが開始されます。
AUTO_BATTLE_BUTTON = Input::X
end
end

module Vocab
AutoBattle = "%sは一生懸命戦っている。"
end

$imported = {} if $imported == nil
$imported["MefatenAutoBattle"] = true


unless $imported["LargeParty"]
class Game_Party
def battle_members
return members
end
end
end


class Game_Temp
attr_accessor :auto_battle_mode
attr_accessor :reserve_end_auto_battle
alias saba_sjauto_initialize initialize
def initialize
saba_sjauto_initialize
@auto_battle_mode = false
@reserve_end_auto_battle = false
end
end

class Game_Actor
def make_attack_action
@action.clear
return unless movable?
action = Game_BattleAction.new(self)
action.set_attack
action.evaluate
@action = action
end
end

class Window_BattleMessage
alias saba_sjauto_clear clear
def clear
unless $game_temp.auto_battle_mode
saba_sjauto_clear
refresh
end
end
end

class Scene_Battle
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
alias saba_sjauto_start start
def start
saba_sjauto_start
$game_temp.auto_battle_mode = false
$game_temp.reserve_end_auto_battle = false
end
#--------------------------------------------------------------------------
# ● パーティコマンド選択の更新
#--------------------------------------------------------------------------
alias saba_sjauto_update_party_command_selection update_party_command_selection
def update_party_command_selection
if auto_battle_button_pressed?
start_auto_battle
return
end
saba_sjauto_update_party_command_selection
end
#--------------------------------------------------------------------------
# ● パーティコマンド選択の開始
#--------------------------------------------------------------------------
alias saba_sjauto_start_party_command_selection start_party_command_selection
def start_party_command_selection
if $game_temp.in_battle
@status_window.refresh
@status_window.index = @actor_index = -1
@active_battler = nil
@info_viewport.visible = true
@message_window.visible = false
if $game_temp.reserve_end_auto_battle
$game_temp.reserve_end_auto_battle = false
$game_temp.auto_battle_mode = false
end
if $game_temp.auto_battle_mode
execute_auto_battle
else
saba_sjauto_start_party_command_selection
end
end
end
#--------------------------------------------------------------------------
# ● アクターコマンド選択の更新
#--------------------------------------------------------------------------
alias saba_sjauto_update_actor_command_selection update_actor_command_selection
def update_actor_command_selection
if auto_battle_button_pressed?
start_auto_battle
return
end
saba_sjauto_update_actor_command_selection
end
#--------------------------------------------------------------------------
# ● オートバトルボタンが押されたかを判定します。
#--------------------------------------------------------------------------
def auto_battle_button_pressed?
button = Saba::SJAuto::AUTO_BATTLE_BUTTON
return Input.trigger?(button)
end
#--------------------------------------------------------------------------
# ● オートバトルのキャンセルボタンが押されたかを判定します。
#--------------------------------------------------------------------------
def auto_battle_cancel_button_pressed?
button = Saba::SJAuto::AUTO_BATTLE_BUTTON
return true if Input.trigger?(button)
return true if Input.trigger?(Input::B)
return false
end
#--------------------------------------------------------------------------
# ● オートバトルを開始します。
#--------------------------------------------------------------------------
def start_auto_battle
Sound.play_decision
@message_window.clear
$game_temp.auto_battle_mode = true
@can_cancel_auto = false
execute_auto_battle
display_auto_battle_message
end
#--------------------------------------------------------------------------
# ● オートバトルメッセージを表示します。
#--------------------------------------------------------------------------
def display_auto_battle_message
@message_window.saba_sjauto_clear
message = sprintf(Vocab::AutoBattle, $game_party.name)
@message_window.add_instant_text(message)
end
#--------------------------------------------------------------------------
# ● オートバトルを実行します。
#--------------------------------------------------------------------------
def execute_auto_battle
for actor in $game_party.battle_members
actor.make_attack_action
end
start_main
end
#--------------------------------------------------------------------------
# ● オートバトルを終了します。
#--------------------------------------------------------------------------
def end_auto_battle
Sound.play_cancel
$game_temp.reserve_end_auto_battle = true
end
#--------------------------------------------------------------------------
# ● 基本更新処理
# main : メインの update メソッドからの呼び出し
#--------------------------------------------------------------------------
alias saba_sjauto_update_basic update_basic
def update_basic(main = false)
@can_cancel_auto = true if main
if $game_temp.auto_battle_mode && (! $game_temp.reserve_end_auto_battle) && @can_cancel_auto
end_auto_battle if auto_battle_cancel_button_pressed?
end
saba_sjauto_update_basic(main)
end
#--------------------------------------------------------------------------
# ● 戦闘行動の実行
#--------------------------------------------------------------------------
alias saba_sjauto_execute_action execute_action
def execute_action
if $game_temp.auto_battle_mode
unless @active_battler.actor?
@status_window.index = -1
wait(10)
end
end
saba_sjauto_execute_action
end
#--------------------------------------------------------------------------
# ● 戦闘行動の実行 : 攻撃
#--------------------------------------------------------------------------
alias saba_sjauto_execute_action_attack execute_action_attack
def execute_action_attack
unless $game_temp.auto_battle_mode
saba_sjauto_execute_action_attack
return
end
if @active_battler.actor?
@status_window.index = $game_party.battle_members.index(@active_battler)
if $imported["SekaijuBattle"]
@face_sprite.appear = false
wait(10)
end
end
targets = @active_battler.action.make_targets
for target in targets
target.attack_effect(@active_battler)
display_action_effects(target)
end
end
#--------------------------------------------------------------------------
# ● 戦闘行動の実行 : 防御
#--------------------------------------------------------------------------
alias saba_sjauto_execute_action_guard execute_action_guard
def execute_action_guard
unless $game_temp.auto_battle_mode
saba_sjauto_execute_action_guard
return
end
unless @active_battler.actor?
@status_window.index = -1
end
end
#--------------------------------------------------------------------------
# ● 戦闘行動の実行 : 逃走
#--------------------------------------------------------------------------
alias saba_sjauto_execute_action_escape execute_action_escape
def execute_action_escape
unless $game_temp.auto_battle_mode
saba_sjauto_execute_action_escape
return
end
unless @active_battler.actor?
@status_window.index = -1
end
@active_battler.escape
Sound.play_escape
end
#--------------------------------------------------------------------------
# ● 戦闘行動の実行 : 待機
#--------------------------------------------------------------------------
alias saba_sjauto_execute_action_wait execute_action_wait
def execute_action_wait
unless $game_temp.auto_battle_mode
saba_sjauto_execute_action_wait
return
end
unless @active_battler.actor?
@status_window.index = -1
end
end
#--------------------------------------------------------------------------
# ● 戦闘行動の実行 : スキル
#--------------------------------------------------------------------------
alias saba_sjauto_execute_action_skill execute_action_skill
def execute_action_skill
unless $game_temp.auto_battle_mode
saba_sjauto_execute_action_skill
return
end
unless @active_battler.actor?
@status_window.index = -1
end
skill = @active_battler.action.skill
targets = @active_battler.action.make_targets
display_animation(targets, skill.animation_id)
@active_battler.mp -= @active_battler.calc_mp_cost(skill)
$game_temp.common_event_id = skill.common_event_id
for target in targets
target.skill_effect(@active_battler, skill)
display_action_effects(target, skill)
end
end
#--------------------------------------------------------------------------
# ● 勝利の処理
#--------------------------------------------------------------------------
alias saba_sjauto_process_victory process_victory
def process_victory
@status_window.index = -1
saba_sjauto_process_victory
end
#--------------------------------------------------------------------------
# ● アニメーションの表示
# targets : 対象者の配列
# animation_id : アニメーション ID (-1: 通常攻撃と同じ)
#--------------------------------------------------------------------------
alias saba_sjauto_display_animation display_animation
def display_animation(targets, animation_id)
return if $game_temp.auto_battle_mode
saba_sjauto_display_animation(targets, animation_id)
end
#--------------------------------------------------------------------------
# ● 攻撃アニメーションの表示
# targets : 対象者の配列
# 敵キャラの場合は [敵の通常攻撃] 効果音を演奏して一瞬待つ。
# アクターの場合は二刀流を考慮 (左手武器は反転して表示) 。
#--------------------------------------------------------------------------
alias saba_sjauto_display_attack_animation display_attack_animation
def display_attack_animation(targets)
return if $game_temp.auto_battle_mode
saba_sjauto_display_attack_animation(targets)
end
#--------------------------------------------------------------------------
# ● 通常アニメーションの表示
# targets : 対象者の配列
# animation_id : アニメーション ID
# mirror : 左右反転
#--------------------------------------------------------------------------
alias saba_sjauto_display_normal_animation display_normal_animation
def display_normal_animation(targets, animation_id, mirror = false)
return if $game_temp.auto_battle_mode
saba_sjauto_display_normal_animation(targets, animation_id, mirror)
end
#--------------------------------------------------------------------------
# ● 行動結果の表示
# target : 対象者
# obj : スキルまたはアイテム
#--------------------------------------------------------------------------
alias saba_sjauto_display_action_effects display_action_effects
def display_action_effects(target, obj = nil)
unless $game_temp.auto_battle_mode
saba_sjauto_display_action_effects(target, obj)
return
end
unless target.skipped
display_critical(target, obj)
display_damage(target, obj)
display_state_changes(target, obj)
end
end
#--------------------------------------------------------------------------
# ● クリティカルヒットの表示
# target : 対象者
# obj : スキルまたはアイテム
#--------------------------------------------------------------------------
alias saba_sjauto_display_critical display_critical
def display_critical(target, obj = nil)
return if $game_temp.auto_battle_mode
saba_sjauto_display_critical(target, obj)
end
#--------------------------------------------------------------------------
# ● ダメージの表示
# target : 対象者
# obj : スキルまたはアイテム
#--------------------------------------------------------------------------
alias saba_sjauto_display_damage display_damage
def display_damage(target, obj = nil)
unless $game_temp.auto_battle_mode
saba_sjauto_display_damage(target, obj)
return
end
if target.missed
elsif target.evaded
else
display_hp_damage(target, obj)
display_mp_damage(target, obj)
end
end
#--------------------------------------------------------------------------
# ● ミスの表示
# target : 対象者
# obj : スキルまたはアイテム
#--------------------------------------------------------------------------
alias saba_sjauto_display_miss display_miss
def display_miss(target, obj = nil)
return if $game_temp.auto_battle_mode
saba_sjauto_display_miss(target, obj)
end
#--------------------------------------------------------------------------
# ● 回避の表示
# target : 対象者
# obj : スキルまたはアイテム
#--------------------------------------------------------------------------
alias saba_sjauto_display_evasion display_evasion
def display_evasion(target, obj = nil)
return if $game_temp.auto_battle_mode
saba_sjauto_display_evasion(target, obj)
end
#--------------------------------------------------------------------------
# ● HP ダメージ表示
# target : 対象者
# obj : スキルまたはアイテム
#--------------------------------------------------------------------------
alias saba_sjauto_display_hp_damage display_hp_damage
def display_hp_damage(target, obj = nil)
unless $game_temp.auto_battle_mode
saba_sjauto_display_hp_damage(target, obj)
return
end
if target.hp_damage == 0 # ノーダメージ
elsif target.absorbed # 吸収
elsif target.hp_damage > 0 # ダメージ
if target.actor?
Sound.play_actor_damage
$game_troop.screen.start_shake(5, 5, 10)
else
Sound.play_enemy_damage
target.blink = true
end
else # 回復
Sound.play_recovery
end
wait(30)
end
#--------------------------------------------------------------------------
# ● MP ダメージ表示
# target : 対象者
# obj : スキルまたはアイテム
#--------------------------------------------------------------------------
alias saba_sjauto_display_mp_damage display_mp_damage
def display_mp_damage(target, obj = nil)
return if $game_temp.auto_battle_mode
saba_sjauto_display_mp_damage(target, obj)
end
#--------------------------------------------------------------------------
# ● 現在のステートの表示
#--------------------------------------------------------------------------
alias saba_sjauto_display_current_state display_current_state
def display_current_state
return if $game_temp.auto_battle_mode
saba_sjauto_display_current_state
end
#--------------------------------------------------------------------------
# ● ステート変化の表示
# target : 対象者
# obj : スキルまたはアイテム
#--------------------------------------------------------------------------
alias saba_sjauto_display_state_changes display_state_changes
def display_state_changes(target, obj = nil)
unless $game_temp.auto_battle_mode
saba_sjauto_display_state_changes(target, obj)
return
end
return if target.missed or target.evaded
return unless target.states_active?
display_added_states(target, obj)
end
#--------------------------------------------------------------------------
# ● 付加されたステートの表示
# target : 対象者
# obj : スキルまたはアイテム
#--------------------------------------------------------------------------
alias saba_sjauto_display_added_states display_added_states
def display_added_states(target, obj = nil)
unless $game_temp.auto_battle_mode
saba_sjauto_display_added_states(target, obj)
return
end
for state in target.added_states
if state.id == 1 # 戦闘不能
target.perform_collapse
wait(20)
end
end
end
#--------------------------------------------------------------------------
# ● 解除されたステートの表示
# target : 対象者
# obj : スキルまたはアイテム
#--------------------------------------------------------------------------
alias saba_sjauto_display_removed_states display_removed_states
def display_removed_states(target, obj = nil)
return if $game_temp.auto_battle_mode
saba_sjauto_display_removed_states(target, obj)
end
#--------------------------------------------------------------------------
# ● 変化しなかったステートの表示
# target : 対象者
# obj : スキルまたはアイテム
# すでに眠っている相手をさらに眠らせようとした場合など。
#--------------------------------------------------------------------------
alias saba_sjauto_display_remained_states display_remained_states
def display_remained_states(target, obj = nil)
return if $game_temp.auto_battle_mode
saba_sjauto_display_remained_states(target, obj)
end
#--------------------------------------------------------------------------
# ● 失敗の表示
# target : 対象者 (アクター)
# obj : スキルまたはアイテム
#--------------------------------------------------------------------------
alias saba_sjauto_display_failure display_failure
def display_failure(target, obj)
return if $game_temp.auto_battle_mode
saba_sjauto_display_failure(target, obj)
end
end

class Game_Interpreter
def stop_auto_battle
$game_temp.reserve_end_auto_battle = true
end
def stop_auto_battle_immediately
$game_temp.auto_battle_mode = false
end
def auto_battle?
return $game_temp.auto_battle_mode
end
def display_auto_battle_message
if $scene.is_a?(Scene_Battle)
$scene.display_auto_battle_message
end
end
end

Change log

r281 by s...@sabakan.cc on Jan 9, 2011   Diff
防御メッセージがでないバグを修正
Go to: 
Project members, sign in to write a code review

Older revisions

r172 by s...@sabakan.cc on Nov 13, 2009   Diff
ステート継続の文がでてしまうバグを修正した
r170 by s...@sabakan.cc on Oct 30, 2009   Diff
メガテンっぽいオートバトルを新規追加
All revisions of this file

File info

Size: 21808 bytes, 541 lines
Powered by Google Project Hosting