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