Project1

标题: 请问怎样让战斗不能的角色的战斗图变更而不是消失? [打印本页]

作者: H·H·Y    时间: 2011-8-15 09:17
标题: 请问怎样让战斗不能的角色的战斗图变更而不是消失?
        原本RMXP战斗时角色在HP为0是会变成红色,然后渐变成透明。
        我有个想法:让角色HP为0时就变更战斗图比如像190-Down这类的看似死掉的图。本人脚本盲,有劳各位帮忙写个脚本,在下感激不尽~dsu_plus_rewardpost_czw
作者: xiezhen6805    时间: 2011-8-15 11:37
  1. #==============================================================================
  2. # ■ Sprite_Battler
  3. #------------------------------------------------------------------------------
  4. #  战斗显示用活动块。Game_Battler 类的实例监视、
  5. # 活动块的状态的监视。
  6. #==============================================================================

  7. class Sprite_Battler < RPG::Sprite
  8.   #--------------------------------------------------------------------------
  9.   # ● 定义实例变量
  10.   #--------------------------------------------------------------------------
  11.   attr_accessor :battler                  # 战斗者
  12.   #--------------------------------------------------------------------------
  13.   # ● 初始化对像
  14.   #     viewport : 显示端口
  15.   #     battler  : 战斗者 (Game_Battler)
  16.   #--------------------------------------------------------------------------
  17.   def initialize(viewport, battler = nil)
  18.     super(viewport)
  19.     @battler = battler
  20.     @battler_visible = false
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 释放
  24.   #--------------------------------------------------------------------------
  25.   def dispose
  26.     if self.bitmap != nil
  27.       self.bitmap.dispose
  28.     end
  29.     super
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # ● 刷新画面
  33.   #--------------------------------------------------------------------------
  34.   def update
  35.     super
  36.     # 战斗者为 nil 的情况下
  37.     if @battler == nil
  38.       self.bitmap = nil
  39.       loop_animation(nil)
  40.       return
  41.     end
  42.     # 文件名和色相与当前情况有差异的情况下
  43.     if @battler.battler_name != @battler_name or
  44.        @battler.battler_hue != @battler_hue
  45.       @battler_hue = @battler.battler_hue
  46.       # 获取、设置位图
  47.       @battler_name = @battler.battler_name
  48.       self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  49.       @width = bitmap.width
  50.       @height = bitmap.height
  51.       self.ox = @width / 2
  52.       self.oy = @height
  53.     end
  54.     # 动画 ID 与当前的情况有差异的情况下
  55.     if @battler.damage == nil and
  56.        @battler.state_animation_id != @state_animation_id
  57.       @state_animation_id = @battler.state_animation_id
  58.       loop_animation($data_animations[@state_animation_id])
  59.     end
  60.     # 应该被显示的角色的情况下
  61.     if @battler.is_a?(Game_Actor) and @battler_visible
  62.       # 不是主状态的时候稍稍降低点透明度
  63.       if $game_temp.battle_main_phase
  64.         self.opacity += 3 if self.opacity < 255
  65.       else
  66.         self.opacity -= 3 if self.opacity > 207
  67.       end
  68.     end
  69.     # 明灭
  70.     if @battler.blink
  71.       blink_on
  72.     else
  73.       blink_off
  74.     end
  75.     # 不可见的情况下
  76.     unless @battler_visible
  77.       # 出现 ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  78.       if not @battler.hidden and not @battler.dead? and
  79.          (@battler.damage == nil or @battler.damage_pop)
  80.         if @battler.is_a?(Game_Enemy)
  81.           appear
  82.         else
  83.           @battler.battler_name = @battler.battler_name.split(/_/)[0]
  84.         end
  85.         @battler_visible = true
  86.       end
  87.     end
  88.     # 可见的情况下
  89.     if @battler_visible
  90.       # 逃跑
  91.       if @battler.hidden
  92.         $game_system.se_play($data_system.escape_se)
  93.         escape
  94.         @battler_visible = false
  95.       end
  96.       # 白色闪烁
  97.       if @battler.white_flash
  98.         whiten
  99.         @battler.white_flash = false
  100.       end
  101.       # 动画
  102.       if @battler.animation_id != 0
  103.         animation = $data_animations[@battler.animation_id]
  104.         animation(animation, @battler.animation_hit)
  105.         @battler.animation_id = 0
  106.       end
  107.       # 伤害
  108.       if @battler.damage_pop
  109.         damage(@battler.damage, @battler.critical)
  110.         @battler.damage = nil
  111.         @battler.critical = false
  112.         @battler.damage_pop = false
  113.       end
  114.       # korapusu★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  115.       if @battler.damage == nil and @battler.dead?
  116.         if @battler.is_a?(Game_Enemy)
  117.           $game_system.se_play($data_system.enemy_collapse_se)
  118.           collapse
  119.           # 如果是战斗不能或者是隐藏状态就把透明度设置成 0
  120.           self.opacity = 0
  121.         else
  122.           $game_system.se_play($data_system.actor_collapse_se)
  123.           @battler.battler_name = @battler.battler_name.split(/_/)[0]
  124.           @battler.battler_name = @battler.battler_name + "_d"
  125.         end
  126.         @battler_visible = false
  127.       end
  128.     end
  129.     # 设置活动块的坐标
  130.     self.x = @battler.screen_x
  131.     self.y = @battler.screen_y
  132.     self.z = @battler.screen_z
  133.   end
  134. end
复制代码
替换脚本Sprite_Battler,然后在battler文件夹里,阿尔西斯的死亡图就是“阿尔西斯_d”,直接照搬过来的。。。
作者: H·H·Y    时间: 2011-8-15 13:30
本帖最后由 H·H·Y 于 2011-8-15 13:41 编辑
xiezhen6805 发表于 2011-8-15 11:37
替换脚本Sprite_Battler,然后在battler文件夹里,阿尔西斯的死亡图就是“阿尔西斯_d”,直接照搬过来的。 ...


请问那个84行和124行的“(/_/)”是要填写什么么?
我用了脚本之后呼出战斗页面时他说:

脚本 'Sprite_Battler' 的 84 行 发生了 NoMethodError。
undefined method `battler_name=' for #<Game_Actor:0x1253ca8>


作者: xiezhen6805    时间: 2011-8-15 15:43
H·H·Y 发表于 2011-8-15 13:30
请问那个84行和124行的“(/_/)”是要填写什么么?
我用了脚本之后呼出战斗页面时他说:

忘记了,Game_Battler 1里面定义实例变量的第一句attr_reader   :battler_name的reader改成accessor,上面那个脚本不用动,比如你battler文件夹里面有个名为“阿尔西斯”的战斗图,那么battler文件夹中要放一个“阿尔西斯_d”的战斗图作为死亡后的战斗图,那个84行和124行的语句是指战斗图名忽略掉_这个字符后面的内容。。




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