Project1

标题: 转:战斗中换人,口袋口袋依旧是口袋 口袋换人系统 [打印本页]

作者: px.凤翔九天    时间: 2010-12-16 22:42
标题: 转:战斗中换人,口袋口袋依旧是口袋 口袋换人系统
以前曾经写了一个,貌似那个贴已经失踪到不懂哪里去了,所以今天重写了一个。而且之前写那个还可以玩围攻,这个是模仿口袋的战斗换人,功能就是那样,没得介绍,插入脚本后即可用。
  1. module LimBattlePlug
    4 `, N: b/ s- M! s

  2. * S5 q# E9 y# A3 b, o) ?
  3. # 队伍最大人数
    . ]5 R9 }1 @5 i
  4. MaxPartySize = 8
    2 u8 a/ y; d& \
  5. : G4 {; z) w- r- w
  6. # 出战人数
    3 ~; x* V; M+ ], q2 l0 `7 x4 S
  7. MaxBattlerSize = 1
    % C) ~; m% [; H" w; r/ A0 [
  8. # F+ y5 c2 Z: n' z( P, O& M
  9. # 换人语句0 H. }1 i1 {5 ]0 D8 N
  10. WordChangeBattler = "换人"
    , J0 C7 Z# h, X+ D7 J( F& E3 c# r# Y

  11. % \! U4 Q8 B$ P* ]
  12. # 换人时播放的动画3 ?' S4 @/ _+ }$ N; }# J( n
  13. AnimationChangeBattler = 260 G# O. C. R* r, [

  14. ) H9 B$ C2 n4 V: V" C
  15. end
    $ r2 D$ }+ x# ~( p

  16. / I6 q) l1 e( d5 {; n8 K7 R
  17. class Game_BattleAction
    ! x) t! x) T0 `' f/ J$ c* R. f0 \2 J
  18.   attr_accessor :change_to_battler
    , R1 D- |1 q# f. x
  19.   # 初始化
    6 V( J  V7 a" _$ S1 y
  20.   alias lbp_initialize initialize* r9 Q2 S" S& B4 t* v
  21.   def initialize; n5 p. H0 {8 ~
  22.     lbp_initialize
    - B0 V! c' l/ v/ a! O$ p5 d
  23.     @change_to_battler = 0
    . `/ o1 n6 a! ^/ F* s5 a
  24.   end
    % I0 c, N- W, |
  25.   # 欲更换角色编号, `* K6 y, ~. E/ j8 s, _5 ~
  26.   def set_change_battler
    , F1 b1 h1 X* B2 g
  27.     @kind = 3# F. d( B+ y! f6 `7 E6 f! }* }
  28.   end' O; M* t+ {( e, j  B' m0 O
  29.   # 判断行动是否为更换角色2 ?! d5 g* `, n9 l# b4 X8 f) D6 r
  30.   def is_change_battler?2 g  C8 D2 b& t# s  |4 B7 x
  31.     return (@kind == 3)+ v! n0 P5 S( U+ W+ E6 ]) {+ o
  32.   end
    : r2 v% C( H* x2 N- [6 Y/ ^! ]( p
  33. end
    9 {0 K4 x0 @- }2 e0 E0 _

  34. % v7 ]9 t" s: _' y+ S. X5 D
  35. class Game_Party1 I. }  \5 Y$ R3 B
  36.   include LimBattlePlug
    ( i8 t, p) g- A6 E/ W
  37.   attr_reader :actors2# g0 C/ w. j: N9 c/ U' ~, [
  38.   alias lpb_initialize initialize
    3 ?0 l* W. R# f5 b/ n
  39.   def initialize
    0 o' o1 w6 w+ @
  40.     lpb_initialize# R4 Q* F  [; U  I( B( ?
  41.     @actors2 = []
    1 P1 M8 M/ t5 y
  42.   end
    $ w# M( a2 O/ @, V7 X7 E
  43.   # 角色加入
    5 ~7 L  O  Q4 ^5 N7 |
  44.   def add_actor(actor_id)
    " V& z. m! H; z: E% V" x' z# F& M
  45.     actor = $game_actors[actor_id]( f- U" b. W' h1 `+ N; r! L
  46.     if @actors.size < MaxPartySize and not @actors.include?(actor)9 L$ H7 V5 w4 G* _( N! E( t
  47.       @actors.push(actor)
    $ E2 f3 _* w8 p2 \1 k
  48.       $game_player.refresh
    3 O# a5 z/ l/ p) X6 N* z' i2 o7 H
  49.     end3 H/ z+ p* `+ l- `1 \$ u
  50.   end' y, M5 v/ M, M6 S  j! r' q
  51.   # 设置战斗的角色3 A" J' W& Y' ^- |: o5 ?. }
  52.   def set_actor_to_battle* l0 R  v1 ]0 h' B, Q
  53.     @actors2 = []8 o. s' J1 z4 s& z
  54.     @actors.each do |actor|
      e# d" Z# Q+ _+ c
  55.       @actors2.push(actor)4 @' C7 g, Y/ \2 O2 j$ m
  56.     end
    & Y, p1 i$ c  l, O9 {  G7 D) |
  57.     @actors = []
    " r% c; @9 N( G7 G
  58.     @actors2.each do |actor|
    2 E; P, e" J% ]
  59.       @actors.push(actor)
    ' g' M# l! ]0 N
  60.       break if @actors.size == MaxBattlerSize
    ! O$ `  v6 Z$ z0 X* y. I: j
  61.     end
    # D3 x" m5 e1 w1 c% S( b( ^+ u# n
  62.   end" I7 f% I9 x* r) L2 }2 Q
  63.   # 还原战斗的角色
    " A! q  Q3 C. N* U' i
  64.   def set_actor_to_normal
    - s& {+ t- h6 }$ {. k; N
  65.     @actors = []
    3 W+ b$ E: z. F
  66.     @actors2.each do |actor|/ m7 O. l! I2 N6 |% w% A6 q& j
  67.       @actors.push(actor)
    2 `  S; c4 \8 ^
  68.     end! V; Y' V* o  c" z! p" x" U
  69.   end
    8 Q* Y  b$ L. Z3 V+ D' @
  70.   # 获取角色id数组, z6 m- p: s9 A3 J, W1 h5 d  r
  71.   def get_actors_id
    3 y, L9 z! N# f- @/ u+ j8 y/ a
  72.     id = []
    % H& d; b! B  c4 N8 s
  73.     @actors.each{|actor|id.push(actor.id)}. z/ |( W9 \1 Z$ g1 d
  74.     return id  B+ T/ e& A2 C
  75.   end
      U! k; \  _, o7 z& D0 E/ `
  76.   # 获取角色id数组+ c" u1 |& W" T
  77.   def get_actors2_id
    ( d9 t8 Z2 R2 f' }* L7 p
  78.     id = []4 j" i3 W) ?9 [$ t6 d2 Z+ L+ Z
  79.     @actors2.each{|actor|id.push(actor.id)}6 I- x; Q! k1 Y- Q, t7 W- l/ u) _
  80.     return id1 O* l3 p) Q) @6 r& e1 m" }
  81.   end
    ( w7 S% N0 `9 _# K( N8 j- g
  82.   # 兑换角色7 A% \8 B& N$ U' E& ~9 D
  83.   def change_actor(index,id): s' |) o9 t, l) M* z- G
  84.     @actors[index] = $game_actors[id]) V% s' k0 C$ O+ V
  85.   end( |: Z  \) I# D
  86.   # 全灭判定- O$ C" \- @  Q9 r6 O
  87.   def all_dead?
    0 Z0 J' e! L/ F9 H( z, Z
  88.     # 同伴人数为 0 的情况下
    % t' R5 d  n2 i/ g. t
  89.     if $game_party.actors.size == 0% t/ d& ~- n9 F: k- ^$ m3 n% z
  90.       return false% x2 {# g/ c7 E4 R5 ?0 X
  91.     end0 [* Q+ K3 S+ N
  92.     # 同伴中无人 HP 在 0 以上! P* u9 O/ J$ V6 y0 S- B
  93.     for actor in @actors2  _8 z9 C  d6 t# {# y7 X
  94.       if actor.hp > 09 p, t7 ]- R3 I# _4 ~
  95.         return false9 v) T; s: ]* }' @0 D5 D4 h( F
  96.       end5 i7 B" D7 q7 ]) z( N6 [
  97.     end1 M9 B& |" k& N) P
  98.     for actor in @actors& K; y. o. d! Y, |/ d0 Q
  99.       if actor.hp > 0
    : K8 p# o( T/ m
  100.         return false  c3 Z$ x! V* Z; H, ?8 x
  101.       end
    : m- d0 l: j8 u9 ]( v
  102.     end
    4 V9 O3 M1 O' {' B9 C) t
  103.     # 全灭
    & l7 v2 T7 E. v7 v2 {* T
  104.     return true1 D, `6 P. a- L9 X- B
  105.   end. T  R. X5 t8 P5 M
  106.   # 其他角色) [1 R2 Z# F% a* C! f  D6 j" a
  107.   def other_actors0 {: X; R% F0 n( @6 T! _- |4 T
  108.     actors = []
    % B* I) |, C# X. ^& \3 j
  109.     @actors2.each{|actor|actors.push(actor) if [email protected]?(actor)}
    + J& x5 D& u1 M
  110.     return actors- o; f% S/ r  R; v
  111.   end
    + ^' q# F6 r! A+ D8 b$ E8 F3 _# ?
  112.   # 角色位置互换
    ' M+ u1 |* V2 u# _% [6 n3 W8 W3 z
  113.   def change_actor_pos(id1,id2)
    9 N! r# \* l$ D( c# E- o5 r
  114.     actor_id = []
    ' J; C# U5 _4 W; b, V
  115.     @actors.each do |actor|
    " v! m4 ~' d  ?% \
  116.       actor_id.push(actor.id)" B  L* g# H9 ?% Z1 S/ L
  117.     end
    ' Q4 v" S6 g: o2 S& T# {7 v( U  o
  118.     return if !actor_id.include?(id1) and !actor_id.include?(id2)
    " C! @4 f2 k+ c4 h
  119.     id1_index = id2_index = -1
    ( b9 ~7 z1 e2 Y' N0 p' @$ Z  r6 G
  120.     (0...actor_id.size).each do |i|. ]" M7 S$ J% ^
  121.       if actor_id[i] == id1( V& W; X$ }$ f. e, n
  122.         id1_index = i
    ( J) u3 P2 b0 I1 |# u7 f7 f9 l
  123.       elsif actor_id[i] == id2
    / B& _, }, y( E* H/ I5 m- y
  124.         id2_index = i4 A. h' R( k6 z+ ]9 I
  125.       end
    : `6 Q$ a" {& ?* c" E
  126.     end
    * z/ T' h% ^) @& U% c
  127.     temp_actor = @actors[id1_index]
    # Q1 T2 f1 ?2 M) Z% f* ]/ y
  128.     @actors[id1_index] = @actors[id2_index]
    7 s1 s- l; l% \/ ^* f
  129.     @actors[id2_index] = temp_actor
    ) Z) H6 v) A1 V* R8 z. g
  130.   end! s9 m( G' O: \
  131. end# S* d! i  S' n$ h
  132. $ Q- B$ N; c$ `' [9 ]
  133. class Window_Actor < Window_Selectable$ h! L" v+ H) m6 V
  134.   # 初始化
    4 F" A& k* q" O* K; ^
  135.   def initialize
    , X5 [! U" ~7 Z
  136.     super(0,64,640,256)
    . A5 S/ o& r8 l) ]: m
  137.     self.back_opacity = 160
    % K/ [5 u: t0 |( j6 d  K
  138.     refresh9 v% A3 C! H9 \4 n
  139.     self.index = -1
      N, U# U: V9 x* g6 l  f8 X
  140.     self.active = false) S+ _+ {( @4 P" t$ U% K: |: L  z
  141.   end; s) Q) e3 ^4 `. k
  142.   # 刷新. g6 V" ?! R, I" Q) a+ I
  143.   def refresh6 L5 M) t5 W) I4 L3 b- H6 h
  144.     @item_max = $game_party.actors2.size  f! E  Z, b) Y6 q
  145.     @data = []
    $ J* g. m* t; P' ]2 Y1 O
  146.     $game_party.actors.each do |actor|9 B; X2 G1 r3 d: d0 _, Y& E
  147.       @data.push(actor)/ F$ t8 T- u, t" C/ ]
  148.     end5 [/ p# v8 Q4 w# X9 F: Q6 ?
  149.     $game_party.actors2.each do |actor|0 T/ @0 t- @+ C$ x
  150.       @data.push(actor) if [email protected]?(actor)
    $ g9 Y+ S- Y' u" O
  151.     end
    7 f. C8 t8 }. a8 ~  c) ~5 E1 ~
  152.     if self.contents != nil9 ~. s, n8 D$ R0 c9 N
  153.       self.contents.clear
    6 N" v5 y3 c* |5 {* c- o1 @
  154.       self.contents = nil; F/ X; ?. L" L  g8 z
  155.     end
    # y5 D) `/ M3 F, t2 ]( w
  156.     self.contents = Bitmap.new(608,@data.size*32)
    ! B- a- y1 {! t3 Z% `% |' Q
  157.     x = 4
    . s3 }6 N# D$ ~$ o$ ^4 d4 E! E& }' p
  158.     y = 0) U# m7 ~- P$ i, ^7 ]( h) b/ Z9 O
  159.     @data.each do |actor|
    + A( r5 m& W' M* B% ^3 P* C
  160.       bitmap = RPG::Cache.character(actor.character_name,actor.character_hue)1 Y* f! b( c- H- P$ Z+ u
  161.       rect = Rect.new(0,0,bitmap.width/4,31)
    ) F& r7 n, U: i; E4 L4 q! |7 \
  162.       self.contents.blt(x+16-bitmap.width/8,y,bitmap,rect)$ z' a6 j& b: y" D+ G+ O9 _$ H; F
  163.       draw_actor_name(actor,x+36,y)
    ( X. ?5 U. ^- h6 J! |" \
  164.       draw_actor_state(actor,156,y)2 i7 O8 Y# l# t0 g3 A5 p9 `3 T
  165.       draw_actor_hp(actor,x+256,y,96)
    & |0 z# m. r! w# n# g9 C
  166.       draw_actor_sp(actor,x+376,y,96)
    & p% U6 c7 }( \+ Q
  167.       if $game_party.actors.include?(actor)
    ' \% G1 Q- @; d" K* r
  168.         self.contents.font.color = text_color(6)
      Q# q6 K3 y) P. o: g
  169.         cword = "出战"% K4 q: _; W) S, u7 e2 F. y5 c
  170.       else2 E' \1 S6 P0 I
  171.         self.contents.font.color = text_color(0)5 |" X1 w3 o& |4 x# H/ Z
  172.         cword = "待战". q! C- j2 H; |1 u2 G1 D  z" g
  173.       end0 j* H; ?5 d8 @
  174.       self.contents.draw_text(x+496,y,60,32,cword)! A7 v* A8 s4 B7 u6 v" L
  175.       y += 32
    8 g  }! X; k! Z8 ?& M. s. `
  176.     end
    9 `6 z: W/ u% a9 h
  177.   end
    9 ~% |4 s1 q) `: |
  178.   # 获取当前角色编号7 J( V5 B' b1 c( O9 x1 o
  179.   def actor_id( ?& ^7 Z. D6 _, n6 o2 C
  180.     return @data[self.index].id( o4 J" p) e7 X5 `1 d: T
  181.   end
    . k% C  j# |7 |4 Z; ]+ d/ \1 B
  182.   # 刷新帮助
    & A; W. j( @1 r7 H) S2 |" L
  183.   def update_help
    * D% N% ]( O' K" x! i
  184.     @help_window.set_text(@data[self.index] == nil ?\/ y0 R4 w8 \+ U6 m1 `5 h5 V8 L; {
  185.                           "" : @data[self.index].name)
    - u% B7 ~. F5 ~" \; p! R. E  A
  186.   end
      G6 G& F1 j1 ^( S
  187. end
      |, t$ F3 P$ j$ A7 [% L

  188. 2 ]$ M" c' X# s+ n
  189. class Scene_Battle
    3 L/ x. ?: P( O8 g7 e
  190.   include LimBattlePlug! ?5 J3 A* l9 t* u
  191.   # 初始化7 A1 w0 _4 ]$ I8 F* e
  192.   def initialize2 V$ \. Q2 M, p  F2 j3 a, w
  193.     $game_party.set_actor_to_battle' V: w# k. r. C6 `
  194.   end
    * g: t1 N3 w$ R' L; }* g
  195.   # 主处理- d. N3 v9 p) L1 A0 O4 ^! ^: f4 k8 R
  196.   def main8 z' Z# X& c% S' F% C
  197.     # 初始化战斗用的各种暂时数据
    # C- p7 o2 F; [& h) ~; `1 u
  198.     $game_temp.in_battle = true
    . @3 u4 k/ a4 p9 b
  199.     $game_temp.battle_turn = 0
    1 A, R4 s4 U, S" Y4 m2 u* X& G
  200.     $game_temp.battle_event_flags.clear7 b: M. |$ L4 l! V! S9 p8 N. v
  201.     $game_temp.battle_abort = false5 j  J9 V4 ]- K+ S: {6 f' [" a9 t
  202.     $game_temp.battle_main_phase = false3 u, f2 L8 m0 {4 q9 V
  203.     $game_temp.battleback_name = $game_map.battleback_name: L0 F# T' o& `8 @& j; D; g0 M
  204.     $game_temp.forcing_battler = nil9 b, d! @* k0 |
  205.     # 初始化战斗用事件解释器* O+ a1 q) J% Q; |+ A# c
  206.     $game_system.battle_interpreter.setup(nil, 0)2 D) [3 ^4 F2 W6 T, E5 U, T
  207.     # 准备队伍! G0 i4 V4 y2 S2 |
  208.     @troop_id = $game_temp.battle_troop_id
    , F" A1 h; z7 e6 M
  209.     $game_troop.setup(@troop_id)
    & |5 q/ C1 z) t8 W. z# [8 q7 W
  210.     # 生成角色命令窗口
    # A/ s( |) t. O2 k  ]
  211.     s1 = $data_system.words.attack% [4 q/ \6 K/ k( t. o# L5 U% c
  212.     s2 = $data_system.words.skill
    ' k6 ?* q( ~: y: B1 k, M: e5 |9 c
  213.     s3 = $data_system.words.guard1 a9 C1 @' o. V* w
  214.     s4 = $data_system.words.item
    5 i. Z& Q+ N% |6 y  i
  215.     s5 = WordChangeBattler! P7 e1 ?' R$ {# c! F" ]
  216.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4,s5])
    5 w) Y! t' r( o/ n3 {7 ~* l$ S0 A
  217.     @actor_command_window.y = 1281 w9 V' j6 w3 H' }4 h7 D
  218.     @actor_command_window.back_opacity = 160) I) A" e9 Q* S& N! F, k8 W
  219.     @actor_command_window.active = false1 O* U7 a, q5 n- w! M
  220.     @actor_command_window.visible = false
    3 J7 _3 P7 K/ x6 @3 {( e
  221.     # 生成其它窗口3 m" r1 C" j) q' q
  222.     @party_command_window = Window_PartyCommand.new
    8 n- A9 j% M) x8 y3 c! _: L: W
  223.     @help_window = Window_Help.new" }8 Y. w* `0 Q* j- w) Z9 r
  224.     @help_window.back_opacity = 160
    - A+ `; e0 o* z
  225.     @help_window.visible = false+ u! d" T4 p! V7 ]$ c) \
  226.     @status_window = Window_BattleStatus.new
    0 O* d) ]7 K! m- Z4 e* ]8 N
  227.     @message_window = Window_Message.new
    % r% w+ R) ?2 v% u1 ^$ r
  228.     # 生成活动块3 k7 \* _5 T: R! A
  229.     @spriteset = Spriteset_Battle.new
    8 r, X7 p# L1 Q' z) i8 l) t  T# @
  230.     # 初始化等待计数
    " g+ z3 ?$ B* L3 w: N3 R
  231.     @wait_count = 0
    6 n, [" s9 O3 F) O1 c1 u  [
  232.     # 执行过渡
    + a7 p- g$ [# ?9 M
  233.     if $data_system.battle_transition == ""
    9 G3 h2 [9 _5 V& y- s5 ~" t# D
  234.       Graphics.transition(20); n1 [0 J0 x9 S* J6 g1 F8 P" V& \
  235.     else% D! C& G, ?9 \, @+ y  L  x
  236.       Graphics.transition(40, "Graphics/Transitions/" +0 v" R' W$ w- b! f+ J
  237.         $data_system.battle_transition)& b( l: _# T. e9 D
  238.     end8 |. o" r; i( S1 ]2 w
  239.     # 开始自由战斗回合
    0 s3 t$ t" z7 G' y9 N5 g
  240.     start_phase1
    # q# x9 t6 U9 a, }
  241.     # 主循环
    ' Y) m: f# w. C2 U7 E7 i
  242.     loop do1 j5 Q, s6 a$ H/ g6 f
  243.       # 刷新游戏画面
    ; v& M$ @# `% j" N
  244.       Graphics.update1 K' h! ]: B( p9 i6 H8 ^; g' M
  245.       # 刷新输入信息
    : |$ d2 I* h- ]; a
  246.       Input.update
    # F" F& t. n  R
  247.       # 刷新画面: a" K  n* v' A- R
  248.       update# ^& O" B/ {' s/ P% q
  249.       # 如果画面切换的话就中断循环
    " D. @( S- R+ b) c: f
  250.       if $scene != self
    : d' w' v% z* m: {% C( l
  251.         break2 @* u( B  _/ U5 F- ^
  252.       end% N6 e7 @' |; C$ q0 Z; g/ y
  253.     end! n1 s" D4 \" v4 f. f
  254.     # 刷新地图
    0 `8 y; \$ y7 s" |1 |3 K6 y0 W
  255.     $game_map.refresh* d% v+ j6 }" Y+ Y  `7 O* D4 ~, T
  256.     # 准备过渡
    $ r* Z1 c! \- W- D8 r, H3 c
  257.     Graphics.freeze
    ) c( {7 l( [% `! B" `4 C
  258.     # 释放窗口; {3 @# p! c+ ~0 z
  259.     @actor_command_window.dispose8 _3 x' _1 ]% g+ u) c  E$ g; _1 Z
  260.     @party_command_window.dispose8 @8 Q! W# l* U, J/ z% t  t& R
  261.     @help_window.dispose
    $ S  c( Y' E, F+ W
  262.     @status_window.dispose
    ) E9 |; q, ]; J
  263.     @message_window.dispose8 K2 G6 Q$ Z$ y4 H
  264.     if @skill_window != nil* F4 e% x$ G3 J0 Q* v
  265.       @skill_window.dispose( ?) p- @" d/ J  R, V
  266.     end* ^+ A9 {9 a" j0 J3 V+ l5 m9 ?
  267.     if @item_window != nil. F& u0 l$ N; ^3 D# [
  268.       @item_window.dispose! ?+ D& w% y8 |; U6 [9 d% t; m
  269.     end9 N# ~+ L+ r6 r7 |  L/ A9 Z# A
  270.     if @actor_window != nil
      `, }; B  `" X' T7 l# V
  271.       @actor_window.dispose
    % ]! t, L+ {! N- h5 q1 w
  272.     end) _; I3 J- i; A: _- \. M9 Q
  273.     if @result_window != nil9 K4 S+ Q- q1 e" p5 D
  274.       @result_window.dispose
    ; o& F& e9 F! |
  275.     end$ _6 C( R" y+ W
  276.     # 释放活动块0 S* K' O$ G; k6 u+ J
  277.     @spriteset.dispose8 b( p6 z; `0 c; c
  278.     # 标题画面切换中的情况) ?, E( `% P5 X( Q; n
  279.     if $scene.is_a?(Scene_Title)/ a& N, ?# d9 E/ f' S. G  \9 ]
  280.       # 淡入淡出画面8 Z: R7 R5 w2 n3 C' Z3 J5 L
  281.       Graphics.transition
    9 H; K# ]% o* L/ ^: y
  282.       Graphics.freeze0 Z7 d2 m* c3 t' W) ^
  283.     end
    + M' d% H5 d$ M0 W7 d
  284.     # 战斗测试或者游戏结束以外的画面切换中的情况
    " r( r- U* G* Q) A+ Z
  285.     if $BTEST and not $scene.is_a?(Scene_Gameover)! \0 n1 f0 h" c; v$ s( W
  286.       $scene = nil
    ( W& [8 U  O, o* K' U0 E
  287.     end7 ^4 A- q1 p% b! }
  288.   end+ |- @0 T7 v, B" f+ E' m
  289.   # 战斗结束& }+ \% [& \& Q+ t) f) y
  290.   alias lpb_battle_end battle_end) ]( `% C  ?4 R: b( w2 ~6 @
  291.   def battle_end(n)
    % Q- D( j" U" [3 \4 N9 k: Q! N  k
  292.     lpb_battle_end(n)  `& w# N( D) J
  293.     $game_party.set_actor_to_normal! D' r. Z, p) ]6 V
  294.   end0 g6 N0 y" E: e3 Q' w, R. V
  295.   # 开始回合3
    - j# q; t" W1 ^/ }% d+ w+ j  P2 A9 H) _- d
  296.   alias lbp_start_phase3 start_phase3# f. H6 D1 }, G" V" _& G0 b
  297.   def start_phase3/ D0 E/ K* h. L- X( a
  298.     @changed_battler_id = []
    0 ^3 W% m* d: f! U6 Q
  299.     lbp_start_phase3
    + k: W4 l1 t2 [3 w  R# i
  300.   end8 q  @: B9 ]- c- g# L
  301.   # 刷新角色命令回合画面+ I" M6 n# }4 |- G1 h9 r+ ?
  302.   def update_phase3
    / @% S1 r4 S3 P+ D$ U( k$ _; S  N
  303.     # 敌人光标有效的情况下) _7 t7 z- Z. P" z7 F2 e) x
  304.     if @enemy_arrow != nil
    9 J' w  i( w! B
  305.       update_phase3_enemy_select4 _2 d, E1 ~, J3 n9 S# U
  306.     # 角色光标有效的情况下
    $ L! n& W+ m+ o- o4 J
  307.     elsif @actor_arrow != nil
    2 u  Q8 _' e/ P  w' g8 [/ f; ^  B
  308.       update_phase3_actor_select, D" |( k$ a  Q; I/ }: Q- w
  309.     # 特技窗口有效的情况下
    % P2 {9 _' Z, I7 ~3 \$ ^$ d! r
  310.     elsif @skill_window != nil
    - ~; D7 E  F! E. H. y
  311.       update_phase3_skill_select5 C+ `# F6 w1 H  _+ s- j. S* x
  312.     # 物品窗口有效的情况下
    / E& P7 E* \2 J; E
  313.     elsif @item_window != nil
    5 C1 K1 D! t1 Q9 f% V
  314.       update_phase3_item_select
    ) }+ R7 O. f( Q8 x% O1 a
  315.     elsif @actor_window != nil" s6 x. V8 Y% Q) c; T. C: Y  Z5 m/ n
  316.       update_phase3_battler_select
    ! L: F9 C. }7 T  c/ R# h
  317.     # 角色指令窗口有效的情况下9 A& D1 B0 t* g7 G: O
  318.     elsif @actor_command_window.active
    - P0 Q/ T# W# Z4 |. F. H
  319.       update_phase3_basic_command
    4 J6 h4 u0 b" e% a
  320.     end
    ( t! \9 a1 Z- t% c1 V3 y3 ?+ Z% t: i
  321.   end
    ! f2 m* ~; z0 n
  322.   # 角色基本命令
    $ K4 x7 v* C; K/ ~/ q
  323.   def update_phase3_basic_command- G4 K  f$ e& m; B( K
  324.     # 按下 B 键的情况下3 N! E- G! U& ^, E. W
  325.     if Input.trigger?(Input::B)
    ; D! N& l% C) [. p
  326.       # 演奏取消 SE6 I7 N6 h7 m1 n! M: C& h- [. r) g
  327.       $game_system.se_play($data_system.cancel_se)
    ( v$ T+ }, w6 ^& _3 N  `6 b2 `
  328.       # 转向前一个角色的指令输入/ m* @5 l: R: F; F) ^! h
  329.       phase3_prior_actor7 e7 ]) ~6 A7 V7 K( E% ^# A! ^3 N7 Y
  330.       return0 i2 q* S/ E8 G( ]. v# N! u
  331.     end& w2 s# h( G$ p$ F& a
  332.     # 按下 C 键的情况下
    5 E4 g  Q6 c0 I! U) Z
  333.     if Input.trigger?(Input::C): T6 a8 `  F+ q$ t
  334.       # 角色指令窗口光标位置分之
    9 v! @; Q2 y: v5 |+ y) j: l; s0 E
  335.       case @actor_command_window.index
    " D" o0 B9 ]0 D5 X; f& {* l. f
  336.       when 0  # 攻击
    ; H' X! B% N# K, g& N
  337.         # 演奏确定 SE# Q5 J' u- l$ m9 n, I0 g+ {; L
  338.         $game_system.se_play($data_system.decision_se)
    ( ^' B, W, x. r# k+ \
  339.         # 设置行动
    - L. H& o! `) Y2 k; e+ W' C! a
  340.         @active_battler.current_action.kind = 02 ]/ n& \: B6 E  r. d9 x
  341.         @active_battler.current_action.basic = 0
    ) y+ h. ]9 r2 J8 _2 c' b' y
  342.         # 开始选择敌人+ _. v3 X8 {; g. ~# S" x
  343.         start_enemy_select2 \% P  L/ |; Z- V
  344.       when 1  # 特技7 N2 c/ H* W4 N, s3 r/ K$ g
  345.         # 演奏确定 SE
    ) Q% I0 Y+ K$ P  W. _
  346.         $game_system.se_play($data_system.decision_se)! [$ _3 x( P* G1 \8 D1 u: V# ~
  347.         # 设置行动. z& I( r# P" k, h% }
  348.         @active_battler.current_action.kind = 1" a1 n! F* [( K1 W, v: u
  349.         # 开始选择特技
    # c. h' @: ]' v' ]( n, M( E
  350.         start_skill_select& t2 W$ n' H: i% ^# `  L
  351.       when 2  # 防御
    % j: }$ l& ~- e* }& j
  352.         # 演奏确定 SE
    % O: a. b+ O9 ~2 O9 o1 w' E
  353.         $game_system.se_play($data_system.decision_se)6 @6 Q, Z. W7 b. F5 y
  354.         # 设置行动! C6 e0 T; c* m, n5 M% w$ G' h
  355.         @active_battler.current_action.kind = 05 Q$ I4 n) L* C8 w' d  e
  356.         @active_battler.current_action.basic = 1
    3 d7 Q7 w$ Z& [! B( s
  357.         # 转向下一位角色的指令输入
    ' N' n; L  q3 v2 p9 }; b) g
  358.         phase3_next_actor- c# x0 f6 Q& h3 [; O
  359.       when 3  # 物品  F: H; A; h  s7 w+ p# q5 G& Y
  360.         # 演奏确定 SE
    5 P& H1 J* h  u/ u9 ~, C- G
  361.         $game_system.se_play($data_system.decision_se)) r4 _8 `( e7 B( I
  362.         # 设置行动1 z, ^, r0 {+ P, K3 F0 Q
  363.         @active_battler.current_action.kind = 2
    9 Q4 G; N/ T& Y1 I4 f! I0 n6 a7 M$ y& }
  364.         # 开始选择物品" y& a+ Q7 [2 H
  365.         start_item_select/ X( u* Y- G% l3 i* s
  366.       when 4 # 换人8 m" }' P( N# ^' r1 ?
  367.         $game_system.se_play($data_system.decision_se)
    1 z! ~" ^) u9 K) C5 ~* M: v
  368.         @active_battler.current_action.set_change_battler
    1 E6 S. k3 S" H. u  K3 V6 x: l/ M
  369.         start_battler_select
    . r# D9 a) b$ f" Y" [& ?: x
  370.       end2 f; [" m- k' l* M! }: @6 O
  371.       return) k2 e$ X1 N: Z" L1 L/ Z1 e0 U
  372.     end
    9 y3 X* u9 k* y2 b9 Y# d
  373.   end: D( R* E! ~! V) o2 t% x+ P
  374.   # 开始角色选择
    ; \( G, V, A- d: R: G) P' E
  375.   def start_battler_select" {* b9 W$ V0 b, {- W5 Y$ k$ [
  376.     @actor_window = Window_Actor.new9 [' b6 u7 H5 Y
  377.     @actor_window.active = true3 ~' |0 Z* A; b( A
  378.     @actor_window.index = 08 F5 L8 c7 Z( D& w% G
  379.     @actor_window.help_window = @help_window
    . I8 D( L# T- P8 J3 _1 r
  380.     @actor_command_window.active = false
    1 b" H7 q: L& u6 T4 ]% G
  381.     @actor_command_window.visible = false
    $ x# T, @, N7 f+ C9 q/ H
  382.   end' _; N9 z6 r* ]: h4 Q0 M: p
  383.   # 结束角色选择
      H* X: Z0 Y' q; G
  384.   def end_battler_select: @4 j) M+ v! @, D
  385.     @actor_window.dispose
    5 ~+ f# m1 s8 {0 i6 ?; b
  386.     @actor_window = nil
    " p4 C% i; \4 l% x& K4 W
  387.     @help_window.visible = false: B) a9 y' J2 Q9 \  y
  388.     @actor_command_window.active = true1 H& K2 ~( ~: ?' G4 |, a
  389.     @actor_command_window.visible = true
    % }( i  P/ Y7 F) A; G& W
  390.   end/ \9 v7 l) x1 p+ T
  391.   # 刷新角色选择
    * ?( s- S* E7 g5 _& }; Q7 Y. q
  392.   def update_phase3_battler_select
    9 S  s: s* H( i1 N3 z
  393.     @actor_window.visible = true0 [+ p1 R- M* k. `( n
  394.     @actor_window.update
    : b* O; P9 I6 r# l( h. F* w0 p
  395.     if Input.trigger?(Input::B)
    ' Q  e- ]& p0 c: k
  396.       $game_system.se_play($data_system.cancel_se)
    3 b7 w, z, x% @' }+ q
  397.       end_battler_select+ a7 x( ~' F- Y# j
  398.       return+ ]$ f; M: a+ g- L& j. \
  399.     end
    * G! @% I+ `+ Y, @( z& z
  400.     if Input.trigger?(Input::C)
    6 N2 [1 I1 _# W* V! j1 F
  401.       actor_id = @actor_window.actor_id8 }6 A* m2 I3 n- y/ h
  402.       if $game_party.get_actors_id.include?(actor_id) or1 G8 i% L: i8 ~7 l$ N: `
  403.          $game_actors[actor_id].dead? or / Z+ v8 ]& S# l. U; G8 _# {
  404.          @changed_battler_id.include?(actor_id)
    ! d4 F4 @% W8 c( }
  405.         $game_system.se_play($data_system.buzzer_se): \& y4 K" |4 ^6 K8 D* Y3 w! _
  406.         return
    % b: g& `! {, K& V/ M( k. X  e
  407.       end
    1 l0 s$ x6 ?$ J. N. i
  408.       $game_system.se_play($data_system.decision_se)
    2 D; e) H- u$ z" Y- b8 y+ D* Y' _3 x
  409.       @active_battler.current_action.change_to_battler = actor_id
    . v: p/ O+ T; c! V: A" @- J
  410.       @changed_battler_id.push(actor_id)5 |4 n# @5 ]( J1 }& ~+ s3 a4 ]. B- h
  411.       end_battler_select& b/ z) Y0 S: |5 g7 N
  412.       phase3_next_actor
    , i% e6 m& R! o8 b
  413.       return/ l. s/ y' x% y9 I
  414.     end$ v  J( u$ U5 K" V0 b# k9 C
  415.   end
    0 T: z8 ^0 i6 I: B& C4 K( z
  416.   # 行动方动画; }  a/ H0 R6 u
  417.   def update_phase4_step3
    : p0 a) D3 x! ~8 Y, L: d
  418.     if @active_battler.current_action.is_change_battler?
    & f6 n$ X: p3 D/ d9 \3 j* h4 \
  419.       @animation1_id = AnimationChangeBattler
    ; c; X* h* K9 R& e* i
  420.       @target_battlers = []
    9 X3 O  c; _% i6 d) [% E
  421.     end/ E9 c* M" I: A/ D7 \, G
  422.     # 行动方动画 (ID 为 0 的情况下是白色闪烁)/ J/ C% J1 [/ G) Z( z0 W" |, b
  423.     if @animation1_id == 0* z1 r; a3 S" X1 O7 Y. T2 M
  424.       @active_battler.white_flash = true" ?5 F* w& A) Y
  425.     else
    0 a+ Q: `6 Z1 c% G
  426.       @active_battler.animation_id = @animation1_id, ~+ s% ?, x; A; l
  427.       @active_battler.animation_hit = true
    6 {3 m8 d; X7 a8 F+ b  `0 b
  428.     end
    - p% d2 @; M& h2 R+ d
  429.     # 移至步骤 4* w% `8 ]9 i+ q4 B6 J# q
  430.     @phase4_step = 4" d* b5 q0 p+ ~1 @% F( R
  431.   end
    ; K6 y7 R6 `8 g! d8 m; t
  432.   # 对象方动画
    / Z; ]6 W: e2 p8 ?- e
  433.   def update_phase4_step4
      F$ z/ c3 p% V7 p2 F9 H
  434.     if @active_battler.current_action.is_change_battler?
    + ?% r5 b( G' n7 s2 [: |$ o; l
  435.       actor1_id = @active_battler.current_action.change_to_battler/ d% h$ j! {( b; Z
  436.       actor2_id = @active_battler.id
    " C* n7 u6 a6 w0 b
  437.       (0...$game_party.actors.size).each do |i|
    3 X# `( ^3 E9 {1 g0 V. e6 x
  438.         if $game_party.actors[i].id == actor2_id, L& B" K( I9 G# b. I! l' @
  439.           $game_party.change_actor(i,actor1_id)
    / x, n0 Y+ k9 q8 J1 ?2 h; ^
  440.           @active_battler = $game_actors[actor1_id]: e& u: S1 h. s3 ]2 q) B7 |
  441.           @status_window.refresh
    % f1 ]' n0 J" y1 f9 ~
  442.         end
    ( ~; g+ I! O# _6 B% y  {( f
  443.       end
    1 T! y) h! J- ]) e0 p& ?
  444.     end
    7 [1 j8 y- G4 }& N2 F, h9 M! Y9 N
  445.     # 对像方动画
      ]- J2 Y1 |( ?. }" h9 ?
  446.     for target in @target_battlers! g* M- s; U; R4 f, X
  447.       target.animation_id = @animation2_id" |5 a/ N* p, z3 M
  448.       target.animation_hit = (target.damage != "Miss")
    + W+ m2 _' @& j6 Y$ r( a9 W
  449.     end. M0 v% o# s& ?- X* Z/ i
  450.     # 限制动画长度、最低 8 帧8 R% ~4 z1 j* h3 c* ]+ w# \
  451.     @wait_count = 8
    3 ^7 W0 N% @! z- C' k. e
  452.     # 移至步骤 53 e9 Z+ ~) `, K. T1 I3 }0 O
  453.     @phase4_step = 56 {' f, k, G; b: d/ P
  454.   end# ]0 Y6 n. n; f" D" O( E
  455.   # 公共事件6 P" ~' N4 b7 e% A, C
  456.   def update_phase4_step63 f4 k! `- s9 C( b8 Q6 @0 _1 q
  457.     @target_battlers.each do |target|0 [# X0 }5 P, t4 F& t7 Y3 M2 w
  458.       if target.is_a?(Game_Actor) and target.dead? and( @& G" b) ^" i7 V9 ^6 V
  459.          !$game_party.other_actors.all?{|actor|actor.dead?}% i  q" L9 V+ _+ x% Q8 T
  460.         @actor_window = Window_Actor.new* r/ a1 l$ |" M8 J' u
  461.         @actor_window.index = 03 i  i$ H$ {9 M# ]8 j
  462.         @actor_window.active = true3 V! ]- Z# u0 D9 N& o
  463.         @actor_window.help_window = @help_window# H3 a1 K; B, l- t
  464.         actor_id = -1
    ( l9 v* K" S( ?3 ~. G) I7 O4 Z
  465.         loop do
    8 i' `- U. _: Y
  466.           Graphics.update0 W5 t& a; T2 h7 a: ?% f
  467.           Input.update( l; M5 f' y8 x, f$ T" Q) X- R
  468.           @actor_window.update" j$ t. n# {# z3 C% A: b
  469.           if Input.trigger?(Input::C)# \) o% a' h. a" R* W
  470.             actor = $game_actors[@actor_window.actor_id]* p% `" e4 {, y/ b
  471.             if actor.dead? or. P( q( u* r7 U7 N
  472.                (@changed_battler_id.include?(actor.id) and . v; _% i  a# h/ H7 O
  473.                 target.current_action.change_to_battler != actor.id) or
    . E* Q" ?4 n2 Y% p
  474.                $game_party.actors.include?(actor)9 O6 N8 v1 O2 N& l; H; ]
  475.               $game_system.se_play($data_system.buzzer_se)
    ; I0 \: z; }! ^& v; d( I
  476.             else
    0 x+ ]% L$ l) a) g- ~( R
  477.               actor_id = actor.id
    ' ?$ Y7 L6 d0 V) i
  478.             end6 w7 Y. j. D. g. |/ a
  479.           end
    - e) V3 a& j% [# p
  480.           break if actor_id >= 0
    & o* r: k  X2 J
  481.         end
    7 p1 I! f4 D& b7 K8 J
  482.         @actor_window.visible = false
    ; u7 |- R  Y4 q5 }( f& H9 `; M
  483.         @actor_window.dispose$ e" S' p* v$ x- s0 x. W1 ?; `( s
  484.         @actor_window = nil2 v" A0 H; P1 ]4 |1 J" k
  485.         @help_window.visible = false
    0 W& [9 \+ i8 I: b0 j
  486.         (0...$game_party.actors.size).each do |i|0 s+ R" w! P( H) m1 o1 g
  487.           if $game_party.actors[i].id == target.id
    & d& Y2 [; `9 ^7 V+ ?1 T
  488.             $game_party.change_actor(i,actor_id)
    . h% R4 B2 `/ N5 x8 W. C5 @
  489.             @status_window.refresh" V! T6 A$ P8 L; j8 p2 v: B
  490.           end
    2 o- @* [- @, o5 r! _' i3 m
  491.         end
    , l3 y3 b: l8 m( X. B5 f$ \
  492.       end
    : A: C, @7 h1 D
  493.     end
    8 b1 l& P0 F2 S! G8 A6 x# `
  494.     # 清除强制行动对像的战斗者
    4 l# l0 i: O$ L0 v
  495.     $game_temp.forcing_battler = nil! J; M. }* u1 Q$ |" y
  496.     # 公共事件 ID 有效的情况下  `4 ~, J8 A% D
  497.     if @common_event_id > 0- b# q1 C; K  Y2 }* W
  498.       # 设置事件4 O  }( l# o$ h3 J
  499.       common_event = $data_common_events[@common_event_id]2 t+ g' ]; ]0 o" E  H
  500.       $game_system.battle_interpreter.setup(common_event.list, 0)6 _* U/ g3 t7 w  R8 {& d2 V- H' w3 S
  501.     end" z/ V! _# m% n$ e$ ?
  502.     # 移至步骤 14 Q; T0 e$ |1 o2 @* U4 k4 d) t
  503.     @phase4_step = 1
    9 A- i& M8 f5 ^; E  n, t
  504.   end
    ) J: \. g' ~% G6 v. M$ V6 W, y
  505. end
    ! Y. l' ]6 {- _6 j* A, e$ Z

  506. 9 a% @% r! N7 _4 U
  507. class Window_MenuStatus
    + m7 x0 ]1 R% F8 j0 x
  508.   def refresh. p, ]' w4 m0 ~/ P2 `' ^- a. u6 E& E) k  |
  509.     self.contents.clear
    # x( x, u$ L' R; `
  510.     @item_max = $game_party.actors.size
    1 c' T6 i5 [% Q" d
  511.     for i in 0...$game_party.actors.size, J/ w/ s, H% b* w* p) l' M+ q
  512.       x = 4
    1 |* ^7 X: ]6 R& `2 j6 ^! N% r
  513.       y = i * 32! m; K/ G: R: E& c. R2 W' N
  514.       actor = $game_party.actors[i]
    3 p3 `" W' e) f
  515.       bitmap = RPG::Cache.character(actor.character_name,actor.character_hue)
    ( L1 P) U+ a  q: R9 w, {
  516.       rect = Rect.new(0,0,bitmap.width/4,31). m5 P& C  g9 [# O9 j& r6 [; h$ B
  517.       self.contents.blt(x+16-bitmap.width/8,y,bitmap,rect)
    4 d. e* M+ R2 ~, w' f* V
  518.       draw_actor_name(actor, x+36, y)2 M! f& d% H$ R3 a& ]
  519.       draw_actor_state(actor, x + 136,y)
    2 z% |( }3 |# G! z
  520.       draw_actor_hp(actor, x + 236, y,96)$ S# a: y& Z( W- j
  521.       draw_actor_sp(actor, x + 336, y,96)
    % D# |0 J# {1 {& Y9 W
  522.     end' [% V" F# ?: N/ T& F$ l
  523.   end- |" f0 P- J7 ]$ m
  524.   def update_cursor_rect. I4 v* S0 d5 x' c
  525.     super  m4 b7 r$ O+ p8 U3 V& g; e* ~
  526.   end6 X( \6 a7 e1 E1 J& z1 b
  527. end
复制代码
说明:这个东西是转自enghao_lim的一篇帖子,版权归原作者所有。
作者: 姬文翔    时间: 2011-3-25 03:32
我现在就在用这个做一个类似的游戏。但用了这个脚本后发现有个大问题! O. Y. n- w! L' u: j8 e- Q4 p
只有最后解决掉敌人的那个人才能得到经验……怎样改成只要是在该场战斗中出过场的都可以得到一些经验呢?
作者: 1584927450    时间: 2012-6-30 15:17
LZ能否帮我写个XP的口袋脚本,和你此帖的脚本功能一样,但是是四个队员出战,剩下的待命,可换人那种,求求你了,这是我梦寐以求的口袋脚本!!!!!!!!!!!!!!!!!




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1