查看: 2219|回复: 4

[已经解决] 角色第二次战斗还是死亡动态图

[复制链接]
梦石
0
星屑
1556
在线时间
626 小时
注册时间
2010-8-5
回帖
317
发表于 2014-10-16 22:26:21 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
我把大于20的角色设置成死亡后,第二次战斗时回复全状态.但是问题来了,虽然实现了效果

但是第一场战斗中 角色死亡后 呈现 死亡图,第二次战斗开始的样子还是 死亡图,行动后才变成待机图。

请问要在哪地方修改?这个是第二次战斗时回复全状态脚本[pre lang="ruby" line="1"]class Scene_Battle
  def initialize
    #recover_hpsp
  end
  
  def recover_hpsp
    #baby = []
    #for baby_id in 21..50
    #  baby << $game_actors[baby_id]
    #end
    for actor in $game_party.actors# + baby
      if actor.dead?
        actor.states.delete(1)
        if actor.id < 20
          actor.hp = Integer(actor.maxhp * 0.05)
          actor.sp = Integer(actor.maxsp * 0.05)
        elsif actor.id > 20
          actor.hp = actor.maxhp
          actor.sp = actor.maxsp
        end
        actor.hp = 1 if actor.hp < 1
        actor.sp = 1 if actor.sp < 1
      end
    end
  end
  
  alias battle_end_recover_hpsp battle_end
  def battle_end(result)
    battle_end_recover_hpsp(result)
    recover_hpsp
  end
end[/pre]

这个是Sprite_Battler
[pre lang="ruby" line="1"]#==============================================================================
# ■ Sprite_Battler
#------------------------------------------------------------------------------
#  战斗显示用活动块。Game_Battler 类的实例监视、
# 活动块的状态的监视。
#==============================================================================

class Sprite_Battler < RPG::Sprite
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_accessor :battler                  # 战斗者
  attr_accessor :select_index
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     viewport : 显示端口
  #     battler  : 战斗者 (Game_Battler)
  #--------------------------------------------------------------------------
  def initialize(viewport, battler = nil)
    super(viewport)
    @battler = battler
    @battler_visible = false
    @number = 0
    @sprite_contens = Sprite.new#(viewport)
    @sprite_contens.x = 0
    @sprite_contens.y = 0
    @sprite_contens.z = 0
    @sprite_contens.bitmap = Bitmap.new(640,480)
    @select_index = -1
  end
  #--------------------------------------------------------------------------
  # ● 释放
  #--------------------------------------------------------------------------
  def dispose
   
    if self.bitmap != nil
      self.bitmap.dispose
    end
    if @sprite_contens.bitmap != nil
      @sprite_contens.bitmap.dispose
    end
    super
  end
  #--------------------------------------------------------------------------
  # ● 战斗中名字的描绘
  #--------------------------------------------------------------------------
  def draw_actor_name(actor, x, y)
    @sprite_contens.bitmap.font.color = Color.new(0, 230, 50, 255)
    @sprite_contens.bitmap.font.size = 16
    @sprite_contens.bitmap.draw_text(x, y, 60, 65, actor.name,1)
    @sprite_contens.z = 9
  end
  #--------------------------------------------------------------------------
  # ● 战斗血条描绘
  #--------------------------------------------------------------------------
  def draw_battle_hp(actor, x, y)
    # 底图描绘
    battle_hp_bitmap = RPG::Cache.picture("战斗条框")
    src_rect = Rect.new(0, 0, battle_hp_bitmap.width, battle_hp_bitmap.height)
    @sprite_contens.bitmap.blt(x+12, y+41, battle_hp_bitmap, src_rect)
    @sprite_contens.z = 999
    # 血条显示
    battle_hp_bitmap = RPG::Cache.picture("战斗血条")
    hp_width = battle_hp_bitmap.width * actor.hp / actor.maxhp
    src_rect = Rect.new(0, 0, hp_width, battle_hp_bitmap.height)
    @sprite_contens.bitmap.blt(x+13, y+42, battle_hp_bitmap, src_rect)
    @sprite_contens.z = 999

  end
  
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    super
   
      #刷新战斗血条
    if @battler.is_a?(Game_Actor)
      if not @sprite_contens.disposed?
        if @battler_hp == 0 and not @battler.dead?
          @sprite_contens.bitmap.clear
          @sprite_contens.x = @battler.screen_x
          @sprite_contens.y = @battler.screen_y
          @sprite_contens.z = @battler.screen_z + 10
          draw_actor_name(@battler, 0, 0)
          #draw_battle_sp(@battler, 0, 27)
          draw_battle_hp(@battler, 0, 0)
          @battler_hp = @battler.hp
        end
        if @wait_count.to_i != 0
          @sprite_contens.visible = false
        else
          @sprite_contens.visible = true
        end
      end
    elsif @battler.is_a?(Game_Enemy)
      unless @sprite_contens.disposed?
        if @battler.hp0?
          @sprite_contens.bitmap.clear
        end
      if @wait_count.to_i != 0
        @sprite_contens.visible = false
      else
        @sprite_contens.visible = true
      end
      end
    end


    # 战斗者为 nil 的情况下
    if @battler == nil
      self.bitmap = nil
      loop_animation(nil)
      return
    end
    # 文件名和色相与当前情况有差异的情况下
    if @battler.battler_name != @battler_name or
       @battler.battler_hue != @battler_hue
      # 获取、设置位图
      @battler_name = @battler.battler_name
      @battler_hue = @battler.battler_hue
      self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
      @width = bitmap.width
      @height = bitmap.height
      self.ox = @width / 2
      self.oy = @height
      # 如果是战斗不能或者是隐藏状态就把透明度设置成 0
      if @battler.dead? or @battler.hidden
        self.opacity = 0
      end
    end
    if @battler.startactive == "移动" or @battler.startactive == "返回" or @battler.startactive == "挨打" or @battler.startactive == "防御" or @battler.startactive == "死亡"
      if Graphics.frame_count % 2 == 0
        unless BattlerName[@battler.file_name].nil?
          @number = (@number + 1) % BattlerName[@battler.file_name][@battler.startactive].size
          self.bitmap = RPG::Cache.battler(BattlerName[@battler.file_name][@battler.startactive][@number], @battler_hue)
          #Graphics.update
        end
      end
    else
      if Graphics.frame_count % 3 == 0
        unless BattlerName[@battler.file_name].nil?
          @number = (@number + 1) % BattlerName[@battler.file_name][@battler.startactive].size
          self.bitmap = RPG::Cache.battler(BattlerName[@battler.file_name][@battler.startactive][@number], @battler_hue)
        end
      end
    end
    if @a != 1
Mouse.set_bitmap("4.ani",[0,0,11,1])
@a = 1
end

    x, y = Mouse.get_mouse_pos
    if  x >= self.x - self.ox and x <= self.x + self.ox and y >= self.y - self.oy and y <= self.y and
        self.bitmap.get_pixel(x - self.x + self.ox + self.src_rect.x, y - self.y + self.oy + self.src_rect.y).alpha > 0
       self.tone.set(80, 80, 80)
       @sprite_contens.bitmap.font.color = Color.new(0,30, 50, 0)
         if @battler.is_a?(Game_Enemy)
           # 这里修改光标,攻击敌人的光标什么名i在?4
           if $Battle_Skill_Select or $Battle_Item_Select
          #  Mouse.mouse_cursor("5.ani",[0,0,11,1])
           else
          #  Mouse.mouse_cursor("4.ani",[0,0,11,1])
           end
           if Mouse.trigger?(0x01)
             $select_index = @battler.index
           end
         else
          if $Battle_Skill_Select or $Battle_Item_Select
          #  Mouse.mouse_cursor("5.ani",[0,0,11,1])
          end   
         end
    else
       self.tone.set(0, 0, 0)
       # 复原普通鼠标
   #    Mouse.mouse_cursor("mouse.ani",[0,0,11,1])   
    end
     
     

     
     
     
     
     
     
     
    # 动画 ID 与当前的情况有差异的情况下
    if @battler.damage == nil and #音乐咩。。。
       @battler.state_animation_id != @state_animation_id
      @state_animation_id = @battler.state_animation_id
      loop_animation($data_animations[@state_animation_id])
    end
   
    # 不可见的情况下
    unless @battler_visible
    # 出现
      if not @battler.hidden and not @battler.dead? and
         (@battler.damage == nil or @battler.damage_pop)
        appear
        @battler_visible = true
      end
    end
    # 可见的情况下
    if @battler_visible
      # 逃跑
      if @battler.hidden
        $game_system.se_play($data_system.escape_se)
        escape
        @battler_visible = false
      end
      # 白色闪烁
      if @battler.white_flash
        whiten
        @battler.white_flash = false
      end
      # 动画
      if @battler.animation_id != 0
        animation = $data_animations[@battler.animation_id]
        animation(animation, @battler.animation_hit)
        @battler.animation_id = 0
      end
      #伤害
if @battler.damage_pop
  if @battler.damage.is_a?(Numeric) and @battler.damage > 0
    for i in 1..5
      self.x += @battler.is_a?(Game_Actor) ? 8 : -8
      self.y += @battler.is_a?(Game_Actor) ? 5 : -5
      Graphics.update
    end
    for i in 1..5
      self.x += @battler.is_a?(Game_Actor) ? -8 : 8
      self.y += @battler.is_a?(Game_Actor) ? -5 : 5
      Graphics.update
    end
  end
  damage(@battler.damage, @battler.critical)
  @battler.damage = nil
  @battler.critical = false
  @battler.damage_pop = false
end
      # korapusu★★★★★★★★★★★★★★★★★★★★★★★★★★★★
      if @battler.damage == nil and @battler.dead?
        if @battler.is_a?(Game_Enemy)
          $game_system.se_play($data_system.enemy_collapse_se)
          @battler.startactive = "静态"
        else
          $game_system.se_play($data_system.actor_collapse_se)
         @battler.startactive = "静态"
        end
        @battler_visible = false
      end
    end
# 设置活动块的坐标
    self.x = @battler.screen_x
    self.y = @battler.screen_y
    self.z = @battler.screen_z
    @mx = self.bitmap.height
    if @battler.is_a?(Game_Actor)
        @sprite_contens.bitmap.clear
        @sprite_contens.x = @battler.screen_x - 30
        @sprite_contens.y = @battler.screen_y  - @mx -  20
        @sprite_contens.z = self.z
        draw_actor_name(@battler, 0,@mx)
        draw_battle_hp(@battler, 0,0)
      elsif @battler.is_a?(Game_Enemy)
        @sprite_contens.bitmap.clear
        @sprite_contens.x = @battler.screen_x - 30
        @sprite_contens.y = @battler.screen_y - 20
        draw_actor_name(@battler, 0, 0)
      end
    end
   end
[/pre]
梦石
0
星屑
55
在线时间
218 小时
注册时间
2013-12-17
回帖
368
发表于 2014-10-17 20:33:53 | 显示全部楼层
尝试在第二次战斗回复的时候修改战斗者的状态。

点评

脚本贴上来了。。  发表于 2014-10-17 21:57
RM脚本定制/修改/整合 群:143356012(入群注明来意)
回复

使用道具 举报

梦石
0
星屑
9292
在线时间
2504 小时
注册时间
2011-5-20
回帖
14521

开拓者

发表于 2014-10-18 15:45:07 | 显示全部楼层
先试试看第一次战斗死亡用技能物品复活后会不会变吧
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复

使用道具 举报

幻想天神

梦石
0
星屑
55
在线时间
166 小时
注册时间
2012-3-24
回帖
355
发表于 2014-10-18 17:49:54 | 显示全部楼层
应该是提前修改战斗图吧。。吼吼
回复

使用道具 举报

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
回帖
1223
发表于 2014-10-19 07:29:22 | 显示全部楼层
本帖最后由 恐惧剑刃 于 2014-10-19 07:31 编辑

如果删掉复活脚本可以恢复正常的话(我总觉得不太可能!!!!)请删掉def initialize 以及下方的end
可能是重定义了方法。其实这个复活脚本和真移位一点边都不沾不会冲突。


初始化检测
  1. class Scene_Battle
  2.   def initialize
  3.     for actor in $game_party.actors
  4.       if actor.exist?
  5.         actor.startactive = "待机"
  6.       end
  7.     end
  8.   end
  9. end
复制代码
如果加入此脚本可以修复此BUG说明是初始化的问题,
看看Game_Battler 1中initialize部分的 @startactive = "待机"。


除此以外想不到其他可能!

点评

代入那个代码就OK了  发表于 2014-10-20 17:06

评分

参与人数 1星屑 +150 收起 理由
RyanBern + 150 塞糖

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部