Project1
标题:
RMVX对战画面
[打印本页]
作者:
best324401
时间:
2011-10-15 08:26
标题:
RMVX对战画面
哪位高手指点一下怎么在对战中显示我方角色和对我方造成伤害的技能?写脚本的话需要怎么写? dsu_plus_rewardpost_czw
作者:
羁绊の终
时间:
2011-10-15 08:43
把效果范围设置成我方单体,在基本伤害上加上正数就是“对我方造成伤害”的技能了...
作者:
wsmyzc
时间:
2011-10-15 11:33
搜索。。。
作者:
Kimu
时间:
2011-10-15 12:01
请不要无视置顶贴和搜索功能
作者:
恒失败者
时间:
2011-10-15 13:39
您懂脚本的话才好写,不用脚本就建议插入图片和文章吧,虽然辛苦一点,不过比较简单。
作者:
857539182
时间:
2011-10-15 14:30
就是在地图上显示伤害,没什么特别。
事实上有些偷懒,伤害的相关部分完全是从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
作者:
黑之翅膀
时间:
2011-10-18 20:01
显示角色的战斗图:
#==============================================================================
# ■ Window_BattleStatus
#------------------------------------------------------------------------------
# 显示战斗画面同伴状态的窗口。
#==============================================================================
class Window_BattleStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 0, 416, 128)
self.contents.font.size = 18
refresh
self.active = false
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.members.size
for i in 0...@item_max
draw_item(i)
end
draw_6Rface(@index) if @index >= 0
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
actor = $game_party.members[index]
draw_actor_name(actor, 124, rect.y + 2)
begin_x = self.contents.text_size(actor.name).width + 4
draw_actor_state(actor, begin_x, rect.y, 24)
draw_actor_hp(actor, 230, rect.y, 65)
draw_actor_mp(actor, 310, rect.y, 65)
end
#--------------------------------------------------------------------------
# ● 描绘人物头像
# index : 项目编号
#--------------------------------------------------------------------------
def draw_6Rface(index)
rect = Rect.new(0, 0, 96, 96)
self.contents.clear_rect(rect)
actor = $game_party.members[index]
draw_actor_face(actor, 0, 0, 96)
end
#--------------------------------------------------------------------------
# ● 设置光标的位置
# index : 新的光标位置
#--------------------------------------------------------------------------
def index=(index)
@index = index
update_cursor
refresh
end
#--------------------------------------------------------------------------
# ● 获取项目描画矩形
# index : 项目编号
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.width = contents.width - 113
rect.height = WLH
rect.x = 113
rect.y = index / @column_max * WLH
return rect
end
#--------------------------------------------------------------------------
# ● 更新光标矩形
#--------------------------------------------------------------------------
def update_cursor
if @index < 0 # 光标位置不满 0 的情况下
self.cursor_rect.empty # 光标无效
else # 光标位 0 以上的情况下
row = @index / @column_max # 获取当前的行
if row < top_row # 当前行被显示开头行前面的情况下
self.top_row = row # 从当前行向开头行滚动
end
if row > bottom_row # 当前行被显示末尾行之后的情况下
self.bottom_row = row # 从当前行向末尾滚动
end
rect = item_rect(@index) # 获取选择项的矩形
rect.y -= self.oy # 矩形滚动的位置加起来
self.cursor_rect = rect # 更新光标矩形
end
end
end
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1