Project1
标题:
转:战斗中换人,口袋口袋依旧是口袋 口袋换人系统
[打印本页]
作者:
px.凤翔九天
时间:
2010-12-16 22:42
标题:
转:战斗中换人,口袋口袋依旧是口袋 口袋换人系统
以前曾经写了一个,貌似那个贴已经失踪到不懂哪里去了,所以今天重写了一个。而且之前写那个还可以玩围攻,这个是模仿口袋的战斗换人,功能就是那样,没得介绍,插入脚本后即可用。
module LimBattlePlug
) _4 A7 v, b# l# x1 V( {
" R) j2 J; u5 |" E6 b I
# 队伍最大人数
$ }7 ^! z& M- ?, B
MaxPartySize = 8
: G$ v4 K3 S! M+ ~; ]% v y
7 S8 n# ~+ ^! c9 }+ j( m
# 出战人数
7 a0 U3 B5 P8 F) x+ s- Q
MaxBattlerSize = 1
9 o5 _! r2 M( t; d$ q/ K
, H3 W5 f* L1 E3 R5 |, r V* t$ l
# 换人语句
/ q+ q2 M2 Z& p! E5 j! \$ B
WordChangeBattler = "换人"
; ~* B% i" O' T$ m) Y
- `' a2 |+ V( C
# 换人时播放的动画
$ Q- W0 y7 O2 |8 N
AnimationChangeBattler = 26
. m& T. d, |/ T" }6 }: b$ q/ |
; P/ E0 A$ a! `2 [) V( S( T' P0 f
end
: p; w& o _ Z' ^. q8 H& X
& e) h' k% B ?$ u: _- n
class Game_BattleAction
% @4 j- ~8 v0 O$ h0 ~
attr_accessor :change_to_battler
, x4 [# k6 z4 L- D7 C w
# 初始化
* V, e5 Z' Q1 x! }* d* ?: c, i, c
alias lbp_initialize initialize
1 ]% n0 ^, a. Q$ D
def initialize
1 f# Z3 g h6 A1 q' [* `
lbp_initialize
8 }; ?2 |' o& T0 H& C9 h
@change_to_battler = 0
, x1 I# i! C8 ?: ^( G$ E' ^! D9 L4 S
end
$ K! m& w0 H( w( a% x
# 欲更换角色编号
% m0 m$ T% I6 k* W
def set_change_battler
$ G& D) ^( x* n
@kind = 3
) `* R5 L- F' G# v3 X* W
end
0 u/ w% P5 B( U! `) X0 k
# 判断行动是否为更换角色
. v, H$ U7 ]" d& R* e
def is_change_battler?
$ O6 l) W5 d4 `1 i' f% m0 |/ d# b
return (@kind == 3)
' O) |4 |( g# [! t! R9 e
end
* o2 y* E6 I9 T) r, J+ ]' T
end
; s7 s P8 `" q% `
% t0 C0 n! P0 [2 n, N7 y
class Game_Party
7 ~0 y! ? K/ a3 c. U: c) I
include LimBattlePlug
3 Q, s( Y& J. P& r z( n
attr_reader :actors2
' s l* T3 F6 M8 t$ P; i
alias lpb_initialize initialize
/ m. B) x) S. t- u
def initialize
! \$ ?! K( e g& e, j: O$ M" m2 h
lpb_initialize
: u2 r. ~* }" X
@actors2 = []
: e. Z9 z V1 E- I6 b' e
end
9 p) L* W$ y" Z% A" }
# 角色加入
$ u% n M3 a9 ^# U! q6 P$ r
def add_actor(actor_id)
$ _5 _, w( p8 W, ^8 ~
actor = $game_actors[actor_id]
2 @# W# n @3 g
if @actors.size < MaxPartySize and not @actors.include?(actor)
6 X8 f9 F+ ] Y1 H! n
@actors.push(actor)
( N9 E* L" S' v2 S
$game_player.refresh
' J# e8 q' F |: ?/ X
end
, Z. w/ F5 E4 Y" \
end
& @" @- }; ]) K5 N8 x2 L9 e8 m
# 设置战斗的角色
8 n9 c& w( }' E% Y: z: B
def set_actor_to_battle
1 x5 [6 U+ C% m7 T
@actors2 = []
2 s6 }7 j; W. l% x" }/ S1 k
@actors.each do |actor|
# d) r2 a! c& M8 L! j3 r
@actors2.push(actor)
5 _, ^, P, ^8 U' }* x, o& ?
end
# f/ W! g4 o9 b0 v2 j/ P
@actors = []
- T2 I1 t& E4 Q3 k ]8 W7 J
@actors2.each do |actor|
4 |7 o) Z, {5 r7 d. N4 O5 m- L
@actors.push(actor)
8 ?: I6 T8 s4 K& X
break if @actors.size == MaxBattlerSize
- W: O5 H9 v* d& n' P3 }
end
! |. R, Z' L1 M* C6 [7 L
end
( v. g# W3 I# ], s. N
# 还原战斗的角色
9 M4 \0 ?, k8 o C
def set_actor_to_normal
3 t7 N' F1 E# B" J% o, I0 I9 t( u
@actors = []
8 p, e5 v. a. e% a( {+ o. p$ H5 u5 r
@actors2.each do |actor|
# ^% z" t6 J$ d4 n8 f5 t
@actors.push(actor)
$ @$ b6 f& Q% v5 u
end
4 Z' q2 h$ g6 P. }7 W: `/ @
end
3 K* m; _4 p7 R; j/ u
# 获取角色id数组
! ]9 i# m9 E/ V
def get_actors_id
4 s0 u9 i: n1 @- E1 o5 I8 z
id = []
# g$ l( {. Z$ o2 X
@actors.each{|actor|id.push(actor.id)}
$ a1 E% A0 H3 S/ `, H; p% q
return id
$ _5 K2 d* x! _- R2 a# n5 d. S
end
7 N2 N2 N0 s& P: M2 l' u" A
# 获取角色id数组
s, W' y% m7 p) F* q# W
def get_actors2_id
+ T, _% L0 Z6 A' @
id = []
' f+ t5 u6 K$ V6 E) S" q5 D& P
@actors2.each{|actor|id.push(actor.id)}
* X: _8 y0 _+ ^# r: M( c& r; v0 y3 P
return id
3 W t; U9 F- A
end
* g8 u, X5 A ] \
# 兑换角色
# y9 A: B2 T& t' P( I
def change_actor(index,id)
) ~& y$ m' \2 {2 f2 @
@actors[index] = $game_actors[id]
: K3 r4 _) `3 i! z5 F, |% [
end
( s4 x8 G' `( K& N1 e/ `' E
# 全灭判定
/ \5 _) S$ f) x
def all_dead?
P+ m' O: f! J0 J3 Y- O# Q( ]
# 同伴人数为 0 的情况下
8 x9 F# h4 U) ~
if $game_party.actors.size == 0
% C: ?* F W) y/ m! _6 k/ j) z
return false
, ?3 `) o) s0 Q9 \
end
0 Z1 x) n4 r$ K
# 同伴中无人 HP 在 0 以上
: q$ q# J3 l' T1 p! E0 ~# d H
for actor in @actors2
* e* _- a# t& \5 y
if actor.hp > 0
+ z9 }. C5 w4 `; ~# ~+ o- i7 E
return false
7 Q" n6 M% y2 A3 q3 F
end
: _8 x% C' ~9 i: M8 V, y: `, t
end
# Y7 c! V; x5 M
for actor in @actors
8 `) _6 [' j: @; \+ C
if actor.hp > 0
+ s! O4 L5 d" f& c5 U
return false
5 S3 _# }* e8 d9 K& H, ]6 D8 ^
end
% s) f+ G! v: {
end
+ s' F1 t" u* I3 c
# 全灭
8 d8 @" j( x1 F5 Q, M$ f8 Z, q9 B
return true
7 n5 e8 f3 e: d* x
end
( V; w% w n# l) y- Q
# 其他角色
& s; l9 \7 v' B) |& }) U$ w& @
def other_actors
' V ^. j5 z$ G+ M v$ ]
actors = []
7 U. b# q1 ?$ \( M6 k6 P; Z. K- N
@actors2.each{|actor|actors.push(actor) if
[email protected]
?(actor)}
5 _4 t- o, |" Y' T G! D( g7 E/ J
return actors
: H P0 B& a' S6 N' U ?$ H
end
' c5 ?/ g4 i4 s8 O& o, R) R1 \( ]: [
# 角色位置互换
7 Y; i" |0 D, B3 g( t
def change_actor_pos(id1,id2)
5 K, r: f( x; _- D3 n
actor_id = []
0 `6 @7 T1 D" P4 _: d' l! Z- i
@actors.each do |actor|
) I A2 s; H# u0 c8 y0 U& f' G
actor_id.push(actor.id)
1 C' Y0 [. L4 O' `$ K3 n+ I& ^
end
( n3 S g2 b& r4 J$ D
return if !actor_id.include?(id1) and !actor_id.include?(id2)
. F% Y# g1 _) P0 M5 o) t
id1_index = id2_index = -1
' B5 l, T' @$ n( q* ?
(0...actor_id.size).each do |i|
+ e) J$ K; [! ]7 c' T2 a. ?- b
if actor_id[i] == id1
, w( m1 D/ X" m9 D8 X" J0 f: z& E
id1_index = i
6 ]: W- Q9 k) Y, `
elsif actor_id[i] == id2
2 {8 g+ ], u7 J: {1 c: F! s
id2_index = i
1 B0 z8 J6 T1 Z6 n
end
. }0 S' c2 \7 o& ~2 `% T$ e
end
0 s( ]4 X# H$ i, k f F) V
temp_actor = @actors[id1_index]
" `* E+ {- x% I6 x) Z6 ]
@actors[id1_index] = @actors[id2_index]
, v3 s2 k: A% W3 m
@actors[id2_index] = temp_actor
' L! f: k% Z) U% q' e/ ]
end
/ k. a% ]9 A5 C5 e- v& j0 g5 a
end
4 G! e0 Y A3 S" v: v2 M' C5 N! u
$ q3 }, K! d" A6 Z
class Window_Actor < Window_Selectable
7 e* ]4 z4 m9 E0 U' J4 v, K
# 初始化
/ I1 e. v% F7 E" K- r5 T! U
def initialize
% y$ Z& c3 n) x) d j' \" P
super(0,64,640,256)
. a8 i; e8 C0 B' ^
self.back_opacity = 160
5 b q2 G. O) k9 d' d, z
refresh
3 l! _$ \! w, _" Y. z% \1 M& \" w
self.index = -1
7 s$ T; f* s' s, o7 l
self.active = false
) t4 e$ m7 i# a( A8 ?, M; n
end
! E: u' U/ r- B! R9 ]) L: c
# 刷新
! @$ ~8 }* b+ G" ]" N
def refresh
2 {6 f D; |" h7 `6 x% T0 T$ y
@item_max = $game_party.actors2.size
8 _ W- b3 s$ n% f% F
@data = []
$ F2 O5 ?* X% O# _" g* c1 r
$game_party.actors.each do |actor|
4 X& ~2 H* q3 F3 f2 x, K
@data.push(actor)
5 i h7 G, i: V, \- {9 w
end
" K+ |$ S; ?1 b `, v! }" s' w+ T
$game_party.actors2.each do |actor|
1 e3 U" v& F \, q, |) `4 w
@data.push(actor) if
[email protected]
?(actor)
1 j( a# X5 f$ r5 p
end
- E2 c( d, H) p
if self.contents != nil
9 ~. |' L' V+ v9 ~* a( N+ j
self.contents.clear
3 g M5 M* k' o2 t5 _$ u2 Y. I
self.contents = nil
, i0 F" U$ Z, w, ?( k
end
0 Y9 X# O. e: z4 J, I7 }0 n$ i8 y
self.contents = Bitmap.new(608,@data.size*32)
% G0 O6 X$ H% L, J
x = 4
3 L' r' d& z" z$ E% v! ?
y = 0
1 C. j( H2 F: Z8 Z/ m& q7 N
@data.each do |actor|
j) b7 X' j# ^# p& r
bitmap = RPG::Cache.character(actor.character_name,actor.character_hue)
! S( ]. ^' v9 q+ Q8 T
rect = Rect.new(0,0,bitmap.width/4,31)
$ U. L3 D, J, F2 I5 M# W
self.contents.blt(x+16-bitmap.width/8,y,bitmap,rect)
' x' _. k, [7 |& H* Q; Q2 C& R+ R
draw_actor_name(actor,x+36,y)
( |% W7 [: F( r
draw_actor_state(actor,156,y)
. \ T* U8 Q$ s7 g1 ]( h
draw_actor_hp(actor,x+256,y,96)
1 f. p0 K: f6 o% y. Z @: \
draw_actor_sp(actor,x+376,y,96)
/ A) w" ?# \' [. W
if $game_party.actors.include?(actor)
; ]( S: {; a& |2 \( x) x2 z
self.contents.font.color = text_color(6)
8 i, Y! E+ ?! ]' V+ K
cword = "出战"
' Q2 o- s0 z$ r' T* h
else
2 C: j3 H$ q% m$ J3 j8 `
self.contents.font.color = text_color(0)
! S( W: w6 j$ }' x# ?7 g" i% P
cword = "待战"
( ]0 o# B" v# E) L7 J
end
/ H u9 b1 O B: u
self.contents.draw_text(x+496,y,60,32,cword)
9 r6 S) k& q1 E8 P+ y
y += 32
/ z, h$ |0 s+ q
end
! a8 t1 B% v9 |% `$ E( [! b$ Q
end
0 k' {; u( b0 R# H' o7 k
# 获取当前角色编号
$ } q# C9 F9 t; ^3 O# e5 F
def actor_id
" L9 [4 q' |; U
return @data[self.index].id
0 i1 H; r2 N" k$ h7 U8 R+ f8 m. p
end
! o- s% ~1 H& p6 K1 R
# 刷新帮助
4 z, {: p: Y; d7 ^4 Q( ~- K) c
def update_help
) p: M: s* \* V* n: M6 Q5 d
@help_window.set_text(@data[self.index] == nil ?\
# f( i, w3 ^8 b- q5 q3 S9 f' U# ~. b5 P
"" : @data[self.index].name)
* M' l5 y5 [- R" N. V
end
% p( ^7 N! y) F& a$ P2 H- @ [
end
' B3 ^# k- Y O; h
! Z e$ E0 z2 P) d( e
class Scene_Battle
& g7 I( V* s, m) g0 T; a; m
include LimBattlePlug
& O% F" A6 L2 h( G! U- S# y9 M L, q
# 初始化
1 m1 `7 y/ }4 V0 a1 C
def initialize
# B+ L% ^- @( i, {) b* h+ r# y
$game_party.set_actor_to_battle
% P/ U# l$ }, d W
end
9 T" F& ?& c5 b- ?+ Q( T
# 主处理
0 e( \% U5 b5 P/ W4 g+ o
def main
4 V0 h( H* k2 B
# 初始化战斗用的各种暂时数据
l/ [8 c, v! {9 [" S
$game_temp.in_battle = true
) t6 ~7 B% _- z1 @
$game_temp.battle_turn = 0
0 f. h2 f( D; W( R6 K4 X
$game_temp.battle_event_flags.clear
3 R( A" X" [8 T7 C1 ]: @
$game_temp.battle_abort = false
% T1 i' q- I ]+ R# A: F c
$game_temp.battle_main_phase = false
e% ~* L2 y; `% l" S7 b* F& o* t
$game_temp.battleback_name = $game_map.battleback_name
w; ]' r9 h$ F. J" F% _3 T9 Y: O) e J' p
$game_temp.forcing_battler = nil
5 P/ c; _: h3 F- T5 P o
# 初始化战斗用事件解释器
' O& q! o# G+ S# ]
$game_system.battle_interpreter.setup(nil, 0)
, g5 H0 H7 p9 T% C7 x, y% W
# 准备队伍
$ A( i4 N( R4 d* b( Z5 n
@troop_id = $game_temp.battle_troop_id
+ m0 q7 k. u. c
$game_troop.setup(@troop_id)
9 S1 K! O$ A/ n1 }
# 生成角色命令窗口
' g1 d2 ^' E: B- z6 P- z
s1 = $data_system.words.attack
) u# s5 S+ Z. A2 s. r
s2 = $data_system.words.skill
6 H* }! i7 Z8 E# H9 I
s3 = $data_system.words.guard
: }, K2 w& N* S0 n
s4 = $data_system.words.item
/ l6 \: ]$ Y8 \* D: j
s5 = WordChangeBattler
9 V1 O7 ^( f; E1 t; l
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4,s5])
8 m( {* n/ Y9 ^& d; p
@actor_command_window.y = 128
3 K3 c; i5 W+ |; L4 m+ v8 H
@actor_command_window.back_opacity = 160
7 d0 I+ G- L! s: N( g: |, J! V+ p
@actor_command_window.active = false
( f7 w: Y0 F8 r$ w3 Z
@actor_command_window.visible = false
7 p: y$ p1 l0 g4 c( T0 W
# 生成其它窗口
4 J& w% m7 E) @
@party_command_window = Window_PartyCommand.new
' M) y8 P4 m# L6 |8 D
@help_window = Window_Help.new
' j& `7 z) U& J* u4 k$ H6 _
@help_window.back_opacity = 160
1 h/ R* z+ R, n' Q
@help_window.visible = false
' s& S; G0 p- k$ Y& S
@status_window = Window_BattleStatus.new
' Y# z% Z+ h% e) K
@message_window = Window_Message.new
. ^% f' _/ Y' `# p: `
# 生成活动块
; H8 {, }$ X% ~: X
@spriteset = Spriteset_Battle.new
2 q3 ~9 g( e7 H0 v
# 初始化等待计数
9 r. u. A" M7 [6 a. Z8 q
@wait_count = 0
) z) p& [1 ?! x
# 执行过渡
0 t+ X6 T/ v$ g! r% ?( N5 e
if $data_system.battle_transition == ""
# i; R& V4 U7 G
Graphics.transition(20)
+ {7 C: B$ N1 ~) A$ e
else
! i" g% ~: v0 x4 f5 w5 Z
Graphics.transition(40, "Graphics/Transitions/" +
9 n9 C0 \2 W2 x4 w- l# ^
$data_system.battle_transition)
/ a6 B1 G; ]) X1 Z6 D- t) B
end
$ u t. r$ d% n) f! {8 F
# 开始自由战斗回合
/ Y Y3 e1 x# T: n- P
start_phase1
5 {# ~" T' S4 j& O7 {
# 主循环
" g1 s( O2 e: G$ r3 y
loop do
6 p J1 g, X# |) q& }
# 刷新游戏画面
. ]6 X1 D* O! `5 R
Graphics.update
- g4 f- F- ?3 f( V; \2 n1 |" ]6 G
# 刷新输入信息
/ }+ ^1 p2 d' ~
Input.update
* z, @* E$ Q3 ?$ h( Q& m5 V, Z
# 刷新画面
* }# p8 t4 T# { A R: y0 I# |# d
update
. j8 ]1 X* K( r$ p7 A6 {: d
# 如果画面切换的话就中断循环
& D" F; F5 x0 n9 O# T& ^ t
if $scene != self
/ I4 P: t0 U5 X4 G) R
break
$ ~2 y- t. }+ m$ j; [+ g" V
end
7 N: l- z9 \8 o0 b" [
end
. g+ w6 f9 k+ h! S3 I" ~1 L
# 刷新地图
: ~6 d/ f# _! q) d' b" Q( X0 C4 g9 C
$game_map.refresh
# d7 S" r1 `! ]! J. Q6 l: ~
# 准备过渡
( ^) [) j# d; P, J$ [5 R$ Q, d
Graphics.freeze
& X1 I2 P) S$ A7 R& `# {% y+ u
# 释放窗口
2 t( |1 \- z( t% P
@actor_command_window.dispose
0 w. D9 A; q2 n2 G) p4 b, s7 W, Z* X, G
@party_command_window.dispose
: v! R# h8 m$ D6 d7 _
@help_window.dispose
6 p- J2 U; m8 q; W0 T
@status_window.dispose
6 I' P, C; ?; c/ ~
@message_window.dispose
2 s1 u8 u3 g3 i u( Q+ {. _3 ~
if @skill_window != nil
" Q: \3 T, F: y
@skill_window.dispose
# \6 t, i7 y$ m8 W6 S9 e
end
0 R5 j! q z' B$ E$ u) u: Y
if @item_window != nil
; i+ g3 l6 O3 l% Z, [& g- _
@item_window.dispose
1 b* L( i1 L8 m, c# L
end
& v" y) ]7 g1 z- M# E6 V
if @actor_window != nil
) B; Q( H+ a {) N0 [
@actor_window.dispose
! K) M4 M C0 K8 `& j. ?8 [
end
" \$ }" ~6 K# B' t
if @result_window != nil
# h. _" n/ D$ G" e3 W' L
@result_window.dispose
1 [7 ^ L2 Q1 n$ g5 y: V- U
end
- Q6 F" X. l$ z( X8 A
# 释放活动块
* g5 M/ P+ z+ ~; g4 c
@spriteset.dispose
% c; t4 i5 N4 s% A0 U9 m8 q- A$ [
# 标题画面切换中的情况
: ~' H, B- H6 h3 S$ Q7 l* c' m# F
if $scene.is_a?(Scene_Title)
J/ b, b9 e" T& n+ j
# 淡入淡出画面
& h% t% h" W8 A2 g+ b$ l( f
Graphics.transition
( V4 Y- p( H; @0 D
Graphics.freeze
2 b* r4 [/ e) l, N! W
end
1 N$ B/ l9 m. H: s) J0 @# p" V5 O
# 战斗测试或者游戏结束以外的画面切换中的情况
/ g. v! h4 V0 u0 ]1 u
if $BTEST and not $scene.is_a?(Scene_Gameover)
& `2 K) d1 f; P
$scene = nil
0 Q9 g! ~4 U2 u! n' z
end
6 [5 R/ I4 A, R# }
end
7 k, ]6 H% `) w
# 战斗结束
$ N x( K& m" V$ j) G+ N9 @8 Q2 d
alias lpb_battle_end battle_end
% U. u. e( D/ e& G, |: X
def battle_end(n)
: i, m; Q# T! @! S) @' m* _! y
lpb_battle_end(n)
! q8 Z% e+ H7 l) q
$game_party.set_actor_to_normal
) l% a7 T0 i; N. w. |& p3 H3 y& i3 q
end
+ @8 W7 I/ m- s
# 开始回合3
$ S+ F7 d8 ?+ _; r% `& P
alias lbp_start_phase3 start_phase3
' `( s( i. @, M
def start_phase3
s# F G' s3 S D
@changed_battler_id = []
; w, s# H# `! U7 {
lbp_start_phase3
6 m; S1 B# I% g$ I: V0 B4 S! t
end
0 R4 W E' P2 W
# 刷新角色命令回合画面
# d/ O( E4 I( C, \# O$ K
def update_phase3
1 n8 N- m6 [7 Z; e. ~, I' R
# 敌人光标有效的情况下
& X* R; K8 ?; f- l# N, N
if @enemy_arrow != nil
* q8 ~3 u$ A9 u
update_phase3_enemy_select
) V! ^+ V( f& M5 a; Y
# 角色光标有效的情况下
1 s6 U( Q: Q+ b* h0 j9 m
elsif @actor_arrow != nil
, \" I7 v" {1 {# F9 @) M( c9 q
update_phase3_actor_select
7 h/ i" s) c( i/ m
# 特技窗口有效的情况下
" q' \# N% c+ `* j% N
elsif @skill_window != nil
0 s6 ~3 j x8 x$ B* a' E0 p4 p
update_phase3_skill_select
0 j% E: G4 g+ M# p7 _
# 物品窗口有效的情况下
% a# P' x3 |: S# U: c
elsif @item_window != nil
3 p2 y$ c/ B0 D4 r, ]+ a( F: s+ }+ z/ H
update_phase3_item_select
1 O7 r( H4 K; v. e9 h' a' Q! `
elsif @actor_window != nil
2 f) X! [3 }5 S: c) b
update_phase3_battler_select
# Q | c8 K& O+ D2 ?2 u
# 角色指令窗口有效的情况下
, P) t( a! }, S% w/ ]2 g8 Y# @+ q
elsif @actor_command_window.active
1 l) I( B5 y c& r
update_phase3_basic_command
; G! y; U# K% v9 x
end
0 R0 h6 s) Z- V0 B
end
2 d. B$ Q5 q3 u# a {% I6 T U; g5 g
# 角色基本命令
! T# o- c3 ]' |3 {& n4 r5 f% m
def update_phase3_basic_command
9 h" k" u+ Z, q2 C
# 按下 B 键的情况下
. g. {. [7 r9 p+ O/ E
if Input.trigger?(Input::B)
0 v- h8 N. s' K9 I7 `
# 演奏取消 SE
! ^8 N1 q$ a) V. R
$game_system.se_play($data_system.cancel_se)
1 n' E, H# n! r" }+ i
# 转向前一个角色的指令输入
$ W) m1 o3 e6 X4 H: S$ e
phase3_prior_actor
$ Q9 v G! ~) {8 K
return
) G1 Y0 |; L6 v9 D
end
0 W8 D2 i4 I8 S I( r
# 按下 C 键的情况下
: F/ M/ y$ n0 ~3 _; B
if Input.trigger?(Input::C)
* f* E S/ X# j/ {2 F. p
# 角色指令窗口光标位置分之
" i. e; R% ?) d/ ]- f1 F
case @actor_command_window.index
5 s4 p# t* R+ [+ q" h/ n
when 0 # 攻击
/ D3 C, j3 }0 J- @. Q+ f6 L0 P: v
# 演奏确定 SE
+ Y3 O* M% f# o" v# s, Z
$game_system.se_play($data_system.decision_se)
3 F" V4 I8 S- G: I! b
# 设置行动
4 q" H/ w0 Y$ B6 d1 W0 `1 r' T2 M
@active_battler.current_action.kind = 0
. z8 c, u- V0 Z) ^% {
@active_battler.current_action.basic = 0
8 r$ } N/ W& x% K
# 开始选择敌人
. {4 y/ a4 `4 s4 @7 A
start_enemy_select
, f; e/ S2 D5 F& h
when 1 # 特技
. d6 u% n) Z6 y9 |6 M& u
# 演奏确定 SE
9 W! D5 D q/ |7 S% [
$game_system.se_play($data_system.decision_se)
w1 R$ b8 ]# C( a# c4 J7 G
# 设置行动
* I+ a) k9 P$ |6 S) w
@active_battler.current_action.kind = 1
- t+ W& Z3 f* ^8 z) z' W
# 开始选择特技
* h% T6 \; r7 U5 R. {" C0 P
start_skill_select
4 [: ]4 h# k, @) o9 w6 C' Z. @
when 2 # 防御
1 x, a9 }$ W3 O+ X
# 演奏确定 SE
: `, c0 _+ p7 u! e
$game_system.se_play($data_system.decision_se)
; s, }. i6 F1 P
# 设置行动
1 k' a5 ^7 _/ U" w
@active_battler.current_action.kind = 0
0 l) j' }2 J8 X) l/ T! d+ U
@active_battler.current_action.basic = 1
6 A$ @; w, [" L6 B5 T$ Q2 O) o1 p8 J
# 转向下一位角色的指令输入
. ]2 D' `/ ? q0 g8 \2 m
phase3_next_actor
6 n) G1 m1 g% D% M7 m L, X
when 3 # 物品
, g9 }3 l' u2 X8 ^7 E% o! ~
# 演奏确定 SE
: }! `3 @% a& p1 y0 @3 n4 u/ B+ o- j' x* S
$game_system.se_play($data_system.decision_se)
2 `( Y( R# x7 T9 S% L5 ~% A
# 设置行动
+ @! Z1 n& ^$ q6 u$ U
@active_battler.current_action.kind = 2
& c5 E' ^; e& p' h7 \
# 开始选择物品
1 P: `4 X) B+ r! O) ` p$ l- U$ v: u
start_item_select
# M3 a' E; W( a0 w# f9 r
when 4 # 换人
0 n( R1 |: y* N \% g" w
$game_system.se_play($data_system.decision_se)
% g, S/ G9 F" q6 b& w; f/ F( J
@active_battler.current_action.set_change_battler
" G; X+ c ?' n% V4 D) q
start_battler_select
5 w7 w1 q6 |# O
end
) [. [; B9 q, c* S" @, w( b2 L
return
0 U: @$ {2 f v$ Y* P& Y
end
6 K! E! L& u0 N l( D1 W6 [! q- K
end
9 F+ y2 l& K7 i, I) u
# 开始角色选择
6 [! T2 j) Y1 j3 h. [
def start_battler_select
3 Y; \& {6 O M( z( L8 {
@actor_window = Window_Actor.new
6 k$ }' `3 `& Y! I0 `
@actor_window.active = true
* `' a" K" ?' I1 U! j
@actor_window.index = 0
% l+ s* a4 w0 t6 z5 J
@actor_window.help_window = @help_window
l; n' v, j0 u7 Q( i6 f/ G
@actor_command_window.active = false
$ M" I2 q$ L; T3 u8 _4 n, _
@actor_command_window.visible = false
% T3 [$ J7 h# D; S+ r* @
end
# A2 H `: V# h
# 结束角色选择
/ ]3 |! E, k6 |3 [+ M) b1 P
def end_battler_select
1 j; C0 `3 F' U# [, S
@actor_window.dispose
' w$ x2 _5 O! c& }. |# f
@actor_window = nil
: o3 z. X: U _5 [- k
@help_window.visible = false
q B; c& z& y+ K, W' Y
@actor_command_window.active = true
7 V) x3 X2 f% Z, y3 R1 D. ~, d" q
@actor_command_window.visible = true
" t, I* H0 d! p% k) Q% Y& _
end
. f: @% B, `0 R8 W, W6 D% p
# 刷新角色选择
Y( H8 t% \: r* F8 p; p# x
def update_phase3_battler_select
1 k8 u( ~+ q7 N: |% L8 l8 X
@actor_window.visible = true
' _2 E. g! q8 P4 y& x
@actor_window.update
$ r) n' {; m, H9 C: ~3 L/ s7 j
if Input.trigger?(Input::B)
. r g+ q ^( e5 B
$game_system.se_play($data_system.cancel_se)
# t' k) p) m1 i
end_battler_select
/ y& \ Q3 ?2 b* h9 U% k
return
2 h7 n D; I5 q9 q
end
- g0 \4 [3 U: d5 n& P4 k
if Input.trigger?(Input::C)
- B& A6 B( y+ n" z$ ~7 w
actor_id = @actor_window.actor_id
+ {+ L% v; Q# F5 K
if $game_party.get_actors_id.include?(actor_id) or
% Q$ i; ?$ t2 E7 Q; _) s
$game_actors[actor_id].dead? or
/ ^8 }: R8 S1 J7 J6 A0 ]! }, W6 r
@changed_battler_id.include?(actor_id)
5 l, r6 O& B4 K. i
$game_system.se_play($data_system.buzzer_se)
3 C1 A# n X; \1 B
return
- P/ r/ [! Y8 K6 `8 u! X
end
- m% L4 I8 |, k+ }( o' \; n' T# i
$game_system.se_play($data_system.decision_se)
7 H6 K$ t$ z. g$ M l6 S
@active_battler.current_action.change_to_battler = actor_id
2 R: J9 A' T1 t) l$ g, m
@changed_battler_id.push(actor_id)
. o; Q6 X3 `3 ~2 l- M- {/ s1 O% P
end_battler_select
5 Z8 Z% P8 o% q$ N
phase3_next_actor
5 T) C4 i0 u0 c) H+ c. g
return
4 ] Y; J4 m+ A! a- f7 x
end
5 d% \9 v1 k" {/ _" s! Y
end
, a s1 w2 u0 E
# 行动方动画
) {) q1 M- t1 a. N, T# I
def update_phase4_step3
3 Y' }% _1 H$ K) ^7 h# ]
if @active_battler.current_action.is_change_battler?
$ A* |8 M+ `" X; n
@animation1_id = AnimationChangeBattler
. Z. h" R% F. w' w$ L/ u! x
@target_battlers = []
4 r; f& Y' d" d6 j8 f7 B
end
# U/ _+ d! [/ p: d; @. o
# 行动方动画 (ID 为 0 的情况下是白色闪烁)
& d% N( k" v- a0 G! T& V8 Y
if @animation1_id == 0
/ X5 y3 T s# `& e7 b
@active_battler.white_flash = true
! I x$ a! l7 k9 S
else
( l6 }# o5 H/ L# Y" D* i$ E
@active_battler.animation_id = @animation1_id
" {$ l2 |7 f0 p' P2 m$ c3 u8 |
@active_battler.animation_hit = true
' q& x- T3 r ?
end
0 F; N! a+ |$ @. @7 G/ n: D6 O* u# U
# 移至步骤 4
/ L9 r/ [6 j. X% C# J/ f
@phase4_step = 4
! f( `; h$ S; P. V
end
b6 G7 t; ]' r1 @; q- J
# 对象方动画
5 U$ ?, T% q. T4 i2 u9 w* n
def update_phase4_step4
3 {2 r+ E5 {( }& g* I9 k9 F
if @active_battler.current_action.is_change_battler?
" `; W; f" }& J/ b* z! i. t- o
actor1_id = @active_battler.current_action.change_to_battler
& ?* \& D0 Y6 v
actor2_id = @active_battler.id
# T& I' u$ B( ~2 k, |; J
(0...$game_party.actors.size).each do |i|
! z: X* ^4 i& D' ^
if $game_party.actors[i].id == actor2_id
1 p/ T9 C' \) E4 g0 k
$game_party.change_actor(i,actor1_id)
* I! I" y9 c; _0 s0 S( X
@active_battler = $game_actors[actor1_id]
) H! @8 Y: i# n
@status_window.refresh
9 B y2 ]' ]$ x+ v
end
& Q5 Y1 ?, n& y% X
end
) p3 |' S$ o& ?, K0 |5 b; u
end
) U) g6 D0 t2 l/ ?
# 对像方动画
7 j4 E* k/ @) L- \1 b- W* q p$ U) v
for target in @target_battlers
* j1 ^( F# i% ^* ]' `
target.animation_id = @animation2_id
8 k2 q, f6 H) K1 ^! U$ U
target.animation_hit = (target.damage != "Miss")
' e) M! q% G' N" C" M( G! _
end
% F7 \1 G% Q5 e3 @8 e! V
# 限制动画长度、最低 8 帧
3 L( e+ d W7 S7 v
@wait_count = 8
& t3 g2 B5 b. E3 b- E3 g: _
# 移至步骤 5
9 t. s* `* \" o& T; D8 Q
@phase4_step = 5
; F; R( |5 R! h
end
. l* C/ B9 t! i, q2 O( Y1 L
# 公共事件
# W% ^! S% }7 D6 M1 Z* N
def update_phase4_step6
4 p, [+ K8 s: z# `
@target_battlers.each do |target|
/ s2 @2 n, ?' x" Y+ t. F0 K6 s! A
if target.is_a?(Game_Actor) and target.dead? and
/ F, K) m4 d5 I) ?& U
!$game_party.other_actors.all?{|actor|actor.dead?}
+ s. {8 M+ z4 F8 V+ ~
@actor_window = Window_Actor.new
3 E# X+ A" y) ?5 Y1 a) R- P. H
@actor_window.index = 0
9 g9 K* p2 i- U H! @( I
@actor_window.active = true
) M5 s0 u1 }' \% b2 I8 Z; k O
@actor_window.help_window = @help_window
9 S0 J2 M0 C+ V* d2 r
actor_id = -1
4 |, j+ c$ i% {8 Z" S4 g) t
loop do
& t$ B2 \2 @0 G" G7 s" A
Graphics.update
) x n* A2 }. f2 K: w7 J F
Input.update
. ~6 X" [' l5 |1 Z. u& E/ W2 p
@actor_window.update
3 x4 K! F+ B4 m2 K1 e0 W4 \
if Input.trigger?(Input::C)
, }3 b( H) t+ ^7 u: u' d. f/ B
actor = $game_actors[@actor_window.actor_id]
( o" N/ q- t7 y% T& G
if actor.dead? or
% [0 G8 Y% u2 R; d
(@changed_battler_id.include?(actor.id) and
9 |- r8 H3 g1 z b/ J% K$ I2 K
target.current_action.change_to_battler != actor.id) or
4 o6 w; N. e e; L* |
$game_party.actors.include?(actor)
) s$ a, X6 x3 z) ?
$game_system.se_play($data_system.buzzer_se)
# |) v( e4 u! P! r! O
else
; |$ S) p5 M. S* S+ {! \
actor_id = actor.id
; N3 k* D& b3 [3 D
end
; o& S( j6 J: P' u
end
- g: p( Q# U ]7 }2 t
break if actor_id >= 0
$ n- _+ w5 n; i
end
$ S: r" s+ b0 _0 d
@actor_window.visible = false
; j) Z) ?, j W, W- k- k
@actor_window.dispose
! v7 z) y% w% n
@actor_window = nil
: |2 H0 n K* b# c# R
@help_window.visible = false
/ C& q3 v4 W% ~# i
(0...$game_party.actors.size).each do |i|
2 e- I* X! k4 H% l% l' U- d9 C) x
if $game_party.actors[i].id == target.id
% g( \+ y' r8 Y$ \! |, U( ?( n! O; G
$game_party.change_actor(i,actor_id)
6 H6 ]* d7 k$ x, e8 V' R+ N
@status_window.refresh
( E( m0 m5 p8 o4 z: k* O
end
& e! h4 m E$ D2 k+ u' U, Q
end
5 K+ t6 R; b# L5 h
end
, w9 Y% I" s% `% F4 ~
end
5 }9 S f$ ^ A) G7 j
# 清除强制行动对像的战斗者
/ N: f) b, ^# {3 C4 } b6 Z
$game_temp.forcing_battler = nil
$ I' X# Q. W& c1 o
# 公共事件 ID 有效的情况下
- v1 j0 F$ V0 h8 m3 b! n7 a& [" U
if @common_event_id > 0
3 u- t R; V+ d# t, G5 G: t
# 设置事件
7 O$ e$ A+ s! l$ G
common_event = $data_common_events[@common_event_id]
0 |8 E8 a% J" E* v5 U/ X' q- G
$game_system.battle_interpreter.setup(common_event.list, 0)
7 s9 L' a3 Y( h. c9 B
end
/ f, l0 d* D- j8 b3 d* ~
# 移至步骤 1
* M) z) A# \0 ~# W
@phase4_step = 1
0 q4 t* ]: @) o {5 X3 ?9 o3 }7 H# R
end
. I7 l% B; U% v5 N# Y4 t, ]
end
* T; L3 D8 z: ]: d! ]( m1 V
4 u- g) Y# J, V/ {8 U* @
class Window_MenuStatus
9 \/ W: i( ^# G, X; e4 f1 C* a; w
def refresh
3 l* Q6 Q- @1 a$ n
self.contents.clear
, Q' i; B9 F N) V" k
@item_max = $game_party.actors.size
' B7 N: r" ?2 b+ f. Y
for i in 0...$game_party.actors.size
' p3 y7 J8 Q' v+ f: y8 p+ y8 |. [' F
x = 4
6 C# M& F2 Q$ |% [9 w" x
y = i * 32
% q# W; `# R0 c: A, Z4 e ?
actor = $game_party.actors[i]
/ _7 ^( G6 a$ F q
bitmap = RPG::Cache.character(actor.character_name,actor.character_hue)
. A d: t% Y) y9 I: ?! n6 w5 x
rect = Rect.new(0,0,bitmap.width/4,31)
6 m3 B* T8 m3 s3 r1 [
self.contents.blt(x+16-bitmap.width/8,y,bitmap,rect)
# e( Z& t: s5 F; J& Q% j3 F4 g
draw_actor_name(actor, x+36, y)
- Z8 E! p: U" |+ O0 T2 `( E8 `' T
draw_actor_state(actor, x + 136,y)
- H0 u: a& {, O' i$ C
draw_actor_hp(actor, x + 236, y,96)
7 W Z( U" e2 w" y2 N( O- O) v
draw_actor_sp(actor, x + 336, y,96)
9 p+ ?" V) j4 m5 `
end
# D" t- T1 V/ [: V
end
# e5 w" K, I" l% r+ I
def update_cursor_rect
0 x7 D* E) E: w! h q" [4 F# w
super
3 P/ ~& ?( C! v4 v
end
- T( m/ G5 }8 F
end
复制代码
说明:这个东西是转自enghao_lim的一篇帖子,版权归原作者所有。
作者:
姬文翔
时间:
2011-3-25 03:32
我现在就在用这个做一个类似的游戏。但用了这个脚本后发现有个大问题
4 ~( {7 j# U' R8 u
只有最后解决掉敌人的那个人才能得到经验……怎样改成只要是在该场战斗中出过场的都可以得到一些经验呢?
作者:
1584927450
时间:
2012-6-30 15:17
LZ能否帮我写个XP的口袋脚本,和你此帖的脚本功能一样,但是是四个队员出战,剩下的待命,可换人那种,求求你了,这是我梦寐以求的口袋脚本!!!!!!!!!!!!!!!!!
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1