设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2145|回复: 6
打印 上一主题 下一主题

[已经解决] RMVX对战画面

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
23 小时
注册时间
2011-10-15
帖子
18
跳转到指定楼层
1
发表于 2011-10-15 08:26:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
哪位高手指点一下怎么在对战中显示我方角色和对我方造成伤害的技能?写脚本的话需要怎么写?

Lv1.梦旅人

梦石
0
星屑
71
在线时间
288 小时
注册时间
2011-9-22
帖子
226
2
发表于 2011-10-15 08:43:03 | 只看该作者
把效果范围设置成我方单体,在基本伤害上加上正数就是“对我方造成伤害”的技能了...
http://img165.poco.cn/mypoco/myphoto/20110922/20/6420219220110922203357086.jpg
永不停歇的追尋者。
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
85
在线时间
424 小时
注册时间
2009-8-3
帖子
984
3
发表于 2011-10-15 11:33:09 | 只看该作者
搜索。。。
回复

使用道具 举报

Lv1.梦旅人

追从自然的旅行者
奇特空·煦

梦石
0
星屑
107
在线时间
1387 小时
注册时间
2010-12-31
帖子
4944

开拓者贵宾

4
发表于 2011-10-15 12:01:48 | 只看该作者
请不要无视置顶贴和搜索功能
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
55
在线时间
103 小时
注册时间
2011-10-7
帖子
35
5
发表于 2011-10-15 13:39:53 | 只看该作者
您懂脚本的话才好写,不用脚本就建议插入图片和文章吧,虽然辛苦一点,不过比较简单。
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
2 小时
注册时间
2011-9-25
帖子
5
6
发表于 2011-10-15 14:30:08 | 只看该作者
就是在地图上显示伤害,没什么特别。
事实上有些偷懒,伤害的相关部分完全是从XP拷贝的。

教学正文:

在事件里输入脚本:
get_character(事件编号).damage = 伤害数值
get_character(事件编号).critical = true
get_character(事件编号).damage_pop = true

事件编号就是地图上的事件编号,0为本事件,-1为角色,其他则为编号。
伤害数值为负数就是恢复的效果,伤害数值也可以为字符,不一定是数字。
如果不需要CRITICAL的伤害,彩色那行脚本不用写。




class Game_Character
  attr_accessor :damage
  attr_accessor :damage_pop
  attr_accessor :critical
  alias new_initialize initialize
  def initialize
    new_initialize
    @damage = 0
    @damage_pop = false
    @critical = false
  end
end

class Sprite_Character < Sprite_Base
  def initialize(viewport, character = nil)
    super(viewport)
    @character = character
    @balloon_duration = 0
    @_damage_duration = 0
    @damage_x = 0
    @damage_y = 0
    update
  end
  alias new_update update
  def update
    new_update
    update_damage
    if @character.damage_pop == true
      start_damage(@character.damage,@character.critical)
      @character.damage_pop = false
      @character.critical = false
    end
  end
  def start_damage(value, critical)
    dispose_damage
    if value.is_a?(Numeric)
      damage_string = value.abs.to_s
    else
      damage_string = value.to_s
    end
    bitmap = Bitmap.new(160, 48)
    bitmap.font.name = "Arial Black"
    bitmap.font.size = 28
    bitmap.font.color.set(0, 0, 0)
    bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
    bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
    bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
    bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
    if value.is_a?(Numeric) and value < 0
      bitmap.font.color.set(176, 255, 144)
    else
      bitmap.font.color.set(255, 255, 255)
    end
    bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
    if critical
      bitmap.font.size = 20
      bitmap.font.color.set(0, 0, 0)
      bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
      bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
      bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
      bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
      bitmap.font.color.set(255, 255, 255)
      bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
    end
    @_damage_sprite = ::Sprite.new(self.viewport)
    @_damage_sprite.bitmap = bitmap
    @_damage_sprite.ox = 80
    @_damage_sprite.oy = 20
    @_damage_sprite.x = self.x
    @_damage_sprite.y = self.y - self.oy
    @_damage_sprite.z = 3000
    @_damage_duration = 40
    @damage_x = @character.screen_x
    @damage_y = @character.screen_y
    update_damage
  end
  def update_damage
    if @_damage_duration > 0
      @damage_sprite.x += (@character.screen_x - @damage_x)
      @damage_sprite.y += (@character.screen_y - @damage_y)
      @damage_x = @character.screen_x
      @damage_y = @character.screen_y
      @_damage_duration -= 1
      case @_damage_duration
      when 38..39
        @_damage_sprite.y -= 4
      when 36..37
        @_damage_sprite.y -= 2
      when 34..35
        @_damage_sprite.y += 2
      when 28..33
        @_damage_sprite.y += 4
      end
      @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
      if @_damage_duration == 0
        dispose_damage
      end
    end
  end
  def dispose_damage
    if @_damage_sprite != nil
      @_damage_sprite.bitmap.dispose
      @_damage_sprite.dispose
      @_damage_sprite = nil
      @_damage_duration = 0
    end
  end
end

可能有些人认为XP默认的不好看,想要用图片显示,所以这里也做了准备。
图片素材(注:图片请放入picture的文件夹底下):

class Game_Character
  attr_accessor :damage
  attr_accessor :damage_pop
  attr_accessor :critical
  alias new_initialize initialize
  def initialize
    new_initialize
    @damage = 0
    @damage_pop = false
    @critical = false
  end
end

class Sprite_Character < Sprite_Base
  def initialize(viewport, character = nil)
    super(viewport)
    @character = character
    @balloon_duration = 0
    @_damage_duration = 0
    @damage_x = 0
    @damage_y = 0
    update
  end
  alias new_update update
  def update
    new_update
    update_damage
    if @character.damage_pop == true
      start_damage(@character.damage,@character.critical)
      @character.damage_pop = false
      @character.critical = false
    end
  end
  def start_damage(value, critical)
    dispose_damage
    if value.is_a?(Numeric)
      damage_string = value.abs.to_s
    else
      damage_string = value.to_s
    end
    bitmap = Bitmap.new(162, 64)
    bitmap.font.name = "Arial Black"
    bitmap.font.size = 28
    if value.is_a?(Numeric)
      damage_array = damage_string.scan(/./)
      damage_x = 81 - damage_string.size * 9
      if value < 0
        rect_y = 32
      else
        rect_y = 0
      end
      for char in damage_array
        number = char.to_i
        bitmap.blt(damage_x, 32, Cache.picture("Damage"),
        Rect.new(number * 18, rect_y, 18, 32))
        damage_x += 18
      end
    else
      unless value == "Miss"
        bitmap.font.color.set(0, 0, 0)
        bitmap.draw_text(-1, 27, 162, 36, damage_string, 1)
        bitmap.draw_text(+1, 27, 162, 36, damage_string, 1)
        bitmap.draw_text(-1, 29, 162, 36, damage_string, 1)
        bitmap.draw_text(+1, 29, 162, 36, damage_string, 1)
        bitmap.font.color.set(255, 255, 255)
        bitmap.draw_text(0, 28, 162, 36, damage_string, 1)
      else
        bitmap.blt(36, 28, Cache.picture("Damage"), Rect.new(90, 64, 90, 32))
      end
    end
    if critical
      bitmap.blt(36, 0, Cache.picture("Damage"), Rect.new(0, 64, 90, 32))
    end
    @_damage_sprite = ::Sprite.new(self.viewport)
    @_damage_sprite.bitmap = bitmap
    @_damage_sprite.ox = 81
    @_damage_sprite.oy = 20
    @_damage_sprite.x = self.x
    @_damage_sprite.y = self.y - self.oy * 3 / 2
    @_damage_sprite.z = 3000
    @_damage_duration = 40
    @damage_x = @character.screen_x
    @damage_y = @character.screen_y
    update_damage
  end
  def update_damage
    if @_damage_duration > 0
      @damage_sprite.x += (@character.screen_x - @damage_x)
      @damage_sprite.y += (@character.screen_y - @damage_y)
      @damage_x = @character.screen_x
      @damage_y = @character.screen_y
      @_damage_duration -= 1
      case @_damage_duration
      when 38..39
        @_damage_sprite.y -= 4
      when 36..37
        @_damage_sprite.y -= 2
      when 34..35
        @_damage_sprite.y += 2
      when 28..33
        @_damage_sprite.y += 4
      end
      @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
      if @_damage_duration == 0
        dispose_damage
      end
    end
  end
  def dispose_damage
    if @_damage_sprite != nil
      @_damage_sprite.bitmap.dispose
      @_damage_sprite.dispose
      @_damage_sprite = nil
      @_damage_duration = 0
    end
  end
end
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
134 小时
注册时间
2009-3-29
帖子
470
7
发表于 2011-10-18 20:01:26 | 只看该作者
显示角色的战斗图:
  1. #==============================================================================
  2. # ■ Window_BattleStatus
  3. #------------------------------------------------------------------------------
  4. #  显示战斗画面同伴状态的窗口。
  5. #==============================================================================

  6. class Window_BattleStatus < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(0, 0, 416, 128)
  12.     self.contents.font.size = 18
  13.     refresh
  14.     self.active = false
  15.   end
  16.   #--------------------------------------------------------------------------
  17.   # ● 释放
  18.   #--------------------------------------------------------------------------
  19.   def dispose
  20.     super
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 刷新
  24.   #--------------------------------------------------------------------------
  25.   def refresh
  26.     self.contents.clear
  27.     @item_max = $game_party.members.size
  28.     for i in 0...@item_max
  29.       draw_item(i)
  30.     end
  31.     draw_6Rface(@index) if @index >= 0
  32.   end
  33.   #--------------------------------------------------------------------------
  34.   # ● 描绘项目
  35.   #     index : 项目编号
  36.   #--------------------------------------------------------------------------
  37.   def draw_item(index)
  38.     rect = item_rect(index)
  39.     rect.x += 4
  40.     rect.width -= 8
  41.     self.contents.clear_rect(rect)
  42.     self.contents.font.color = normal_color
  43.     actor = $game_party.members[index]
  44.     draw_actor_name(actor, 124, rect.y + 2)
  45.     begin_x = self.contents.text_size(actor.name).width + 4
  46.     draw_actor_state(actor, begin_x, rect.y, 24)
  47.     draw_actor_hp(actor, 230, rect.y, 65)
  48.     draw_actor_mp(actor, 310, rect.y, 65)
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # ● 描绘人物头像
  52.   #     index : 项目编号
  53.   #--------------------------------------------------------------------------
  54.   def draw_6Rface(index)
  55.     rect = Rect.new(0, 0, 96, 96)
  56.     self.contents.clear_rect(rect)
  57.     actor = $game_party.members[index]
  58.     draw_actor_face(actor, 0, 0, 96)
  59.   end  
  60.   #--------------------------------------------------------------------------
  61.   # ● 设置光标的位置
  62.   #     index : 新的光标位置
  63.   #--------------------------------------------------------------------------
  64.   def index=(index)
  65.     @index = index
  66.     update_cursor
  67.     refresh
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # ● 获取项目描画矩形
  71.   #     index : 项目编号
  72.   #--------------------------------------------------------------------------
  73.   def item_rect(index)
  74.     rect = Rect.new(0, 0, 0, 0)
  75.     rect.width = contents.width - 113
  76.     rect.height = WLH
  77.     rect.x = 113
  78.     rect.y = index / @column_max * WLH
  79.     return rect
  80.   end  
  81.   #--------------------------------------------------------------------------
  82.   # ● 更新光标矩形
  83.   #--------------------------------------------------------------------------
  84.   def update_cursor
  85.     if @index < 0                   # 光标位置不满 0 的情况下
  86.       self.cursor_rect.empty        # 光标无效
  87.     else                            # 光标位 0 以上的情况下
  88.       row = @index / @column_max    # 获取当前的行
  89.       if row < top_row              # 当前行被显示开头行前面的情况下
  90.         self.top_row = row          # 从当前行向开头行滚动
  91.       end
  92.       if row > bottom_row           # 当前行被显示末尾行之后的情况下
  93.         self.bottom_row = row       # 从当前行向末尾滚动
  94.       end
  95.       rect = item_rect(@index)      # 获取选择项的矩形
  96.       rect.y -= self.oy             # 矩形滚动的位置加起来
  97.       self.cursor_rect = rect       # 更新光标矩形
  98.     end
  99.   end
  100. end
复制代码
黑之结界勇士
回复

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-22 20:53

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表