Project1
标题:
兼容问题
[打印本页]
作者:
PAME
时间:
2009-5-16 23:24
标题:
兼容问题
#==============================================================================
# ■ Sprite_Base
#------------------------------------------------------------------------------
# 处理动画显示追加活动块的类变量。
# todo list:
# 1、为了多技能改变色调的时候不出错,最好给screen记录一个当前默认的标准颜色
# 2、彩虹神剑的伤血方法,将damage作为参数建立
#==============================================================================
$animation_hitpause = 0 # 打击感专用变量,击打的时候这个数字上升
# 在需要刷新的scene(如战斗和ARPG地图),这个值权重极高
# 如果>0,则-1,并且屏蔽其他所有按键以外的刷新。
# $game_system.animation_lag = 4 # 动画的延时,这个考虑以后可以作为动态的,越小越快,最小为1
class Sprite_Base < Sprite
#--------------------------------------------------------------------------
# ● 类变量
# @@animations 用来记录动画正在播放,防止同一时间多次在同位置播放全屏动画
# @@_reference_count 用来记录哪些素材正在被使用
#--------------------------------------------------------------------------
@@animations = []
@@_reference_count = {}
HITPAUSE_KR = 3 # 打击感宽容度,宽容度越高击中的停顿感越差,推荐0.5 - 3
# 建议将这里设置为一个大数,用$animation_sp定协议制作打击感
#--------------------------------------------------------------------------
# ● done 初始化对像
# viewport : 视口
#--------------------------------------------------------------------------
def initialize(viewport = nil)
super(viewport)
@use_sprite = true # 活动块使用标记
@animation_duration = 0 # 动画剩余时间
# 基本结构:0.animation, 1.mirror, 2.length, 3.sprites, 4.ox, 5.oy ,
# 6.[bitmap1, bitmap2], 7.[frame_index, quanzhong](权重表),
# 8.all_quanzhong, 9.[hp_damage, sp_damage, string]
@animation_collection = []
@fordispose = [] # 待消除的列表
@damage_string = [] # 与damage有关的列表
@damage_duration = 0 # 如果>0则刷新damage
@battler = nil
end
#--------------------------------------------------------------------------
# ● done 释放
#--------------------------------------------------------------------------
def dispose
super
dispose_all_animation
end
#--------------------------------------------------------------------------
# ● done 刷新画面
#--------------------------------------------------------------------------
def update
super
if @animation_collection != nil
@animation_duration -= 1 if @animation_duration > 0
if @animation_duration == 1
@battler.call_for_effect if @battler != nil
end
for i in 1..@animation_collection.size
ani = @animation_collection[i - 1]
ani[2] -= 1
if ani[2] % $game_system.animation_lag == 0
update_animation(ani, i)
end
end
else
@animation_duration = 0
end
# 把本次播放已经播放完毕的动画删除
if @fordispose != []
for ani in @fordispose
dispose_animation(ani)
end
@fordispose = []
end
update_damage
@@animations.clear
end
#--------------------------------------------------------------------------
# ● done 动画显示中判定 (强判定)
#--------------------------------------------------------------------------
def animation?
return @animation_collection != []
end
#--------------------------------------------------------------------------
# ● done 动画显示中判定 (弱判定)
# 弱判定会和真实情况有一定的出入,为了加快战斗节奏
#--------------------------------------------------------------------------
def animation_ruo?
return @animation_duration != 0
end
#--------------------------------------------------------------------------
# ● done 获取权重列表
#--------------------------------------------------------------------------
def get_damage_list
damage_list = []
all_quanzhong = 0
for timing in @animation.timings
quanzhong = animation_process_timing(timing, true)
all_quanzhong += quanzhong
damage_list.push([timing.frame, quanzhong])
end
return [damage_list, all_quanzhong]
end
#--------------------------------------------------------------------------
# ● done 开始动画
#--------------------------------------------------------------------------
def start_animation(animation, mirror = false, damage = [])
@animation = animation
return if @animation == nil
damage_list = get_damage_list
@animation_mirror = mirror
animation_length = @animation.frame_max * $game_system.animation_lag + 1
#~ @animation_duration += animation_length - 2 * $game_system.animation_lag
had_max = 0
for ani in @animation_collection
had_max = [had_max, ani[2]].max
end
@animation_duration = [had_max, animation_length].max
animbitmap = load_animation_bitmap
@animation_sprites = []
if @animation.position != 3 or not @@animations.include?(animation)
if @use_sprite
for i in 0..15
sprite = ::Sprite.new(viewport)
sprite.visible = false
@animation_sprites.push(sprite)
end
unless @@animations.include?(animation)
@@animations.push(animation)
end
end
end
if @animation.position == 3
if viewport == nil
@animation_ox = 544 / 2
@animation_oy = 416 / 2
else
@animation_ox = viewport.rect.width / 2
@animation_oy = viewport.rect.height / 2
end
else
@animation_ox = width / 2 # x - ox + width / 2
@animation_oy = height / 2 # y - oy + height / 2
if @animation.position == 0
@animation_oy -= height / 2
elsif @animation.position == 2
@animation_oy += height / 2
end
end
@animation_collection.push([@animation, @animation_mirror, animation_length,
@animation_sprites, @animation_ox, @animation_oy,
animbitmap, damage_list[0], damage_list[1], damage])
end
#--------------------------------------------------------------------------
# ● 伤害字符串喷射
#--------------------------------------------------------------------------
def damage(quanzhong, all_quanzhong, damage_all)
for i in 0..2
next if damage_all[i] == nil or damage_all[i] == 0
bitmap = Bitmap.new(200, 80)
bitmap.font.name = (["Arial Black","Arial","黑体","宋体"])
bitmap.font.size = 32
if damage_all[i].is_a?(Numeric)
rect_y = damage_all[i] > 0 ? 32 : 0
begin
this_number = (1.0 * quanzhong * damage_all[i] / all_quanzhong ).to_i
rescue
return
end
next if this_number == 0 and damage_all[i] != 0
@battler.hp += this_number if i == 0 and @battler != nil
@battler.mp += this_number if i == 1 and @battler != nil
$scene.add_total_damage(this_number.abs) if $game_temp.in_battle and @battler != nil
$scene.add_hits(@battler) if $game_temp.in_battle and @battler != nil and $game_system.partyLevel >= 2
$scene.status_window.refresh if $game_temp.in_battle and @battler.is_a?(Game_Actor)
temp_damage_all = this_number.abs.to_s
damage_array = temp_damage_all.scan(/./)
damage_x = 81 - temp_damage_all.size * 9
for char in damage_array
number = char.to_i
bmp_name = i == 1 ? "Damagesp" : "Damage"
bitmap.blt(damage_x, 32, Cache.system(bmp_name),
Rect.new(number * 18, rect_y, 18, 32))
damage_x += 18
end
else
# 系统默认描画字符串
unless damage_all[i] == "Miss"
bitmap.font.color.set(0, 0, 0)
temp_damage_all = damage_all[i].to_s.clone
bitmap.draw_text(-1, 27, 162, 36, temp_damage_all, 1)
bitmap.draw_text(+1, 27, 162, 36, temp_damage_all, 1)
bitmap.draw_text(-1, 29, 162, 36, temp_damage_all, 1)
bitmap.draw_text(+1, 29, 162, 36, temp_damage_all, 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 28, 162, 36, temp_damage_all, 1)
# Miss 的情况下
else
# 显示未击中图画
bitmap.blt(36, 28, Cache.system("Damage"), Rect.new(90, 64, 90, 32))
end
end
damage_sprite = ::Sprite.new(self.viewport)
damage_sprite.bitmap = bitmap
damage_sprite.ox = 80
damage_sprite.oy = 20
damage_sprite.x = self.x - 20 + rand(40)
damage_sprite.y = self.y - self.oy / 2 - 20 + rand(40)
damage_sprite.z = 3000
@damage_duration = 40
@damage_string.push([damage_sprite,@damage_duration - 5, 0, rand(30) - 15, rand(3)])
make_total_damage
end
end
#--------------------------------------------------------------------------
# ● 制作彩虹神劍總傷害,待書寫
#--------------------------------------------------------------------------
def make_total_damage
return
end
#--------------------------------------------------------------------------
# ● 刷新总伤害动画
#--------------------------------------------------------------------------
def update_damage
if @damage_duration > 0
@damage_duration -= 1
for damage in @damage_string
damage[0].x = self.x + self.viewport.rect.x -
self.ox + self.src_rect.width / 2 +
(40 - damage[1]) * damage[3] / 10
damage[0].y -= damage[4]+damage[1]/10
damage[0].opacity = damage[1]*20
damage[1] -= 1
if damage[1]==0
damage[0].bitmap.dispose
damage[0].dispose
@damage_string.delete(damage)
next
end
end
end
end
#--------------------------------------------------------------------------
# ● done 读取动画的类变量
#--------------------------------------------------------------------------
def load_animation_bitmap
animation1_name = @animation.animation1_name
animation1_hue = @animation.animation1_hue
animation2_name = @animation.animation2_name
animation2_hue = @animation.animation2_hue
@animation_bitmap1 = Cache.animation(animation1_name, animation1_hue)
@animation_bitmap2 = Cache.animation(animation2_name, animation2_hue)
if @@_reference_count.include?(@animation_bitmap1)
@@_reference_count[@animation_bitmap1] += 1
else
@@_reference_count[@animation_bitmap1] = 1
end
if @@_reference_count.include?(@animation_bitmap2)
@@_reference_count[@animation_bitmap2] += 1
else
@@_reference_count[@animation_bitmap2] = 1
end
Graphics.frame_reset
return [@animation_bitmap1, @animation_bitmap2]
end
#--------------------------------------------------------------------------
# ● done 释放全部动画
#--------------------------------------------------------------------------
def dispose_all_animation
return nil if @animation_collection == nil
for ani in @animation_collection
dispose_animation(ani)
next
end
return @animation_collection
end
#--------------------------------------------------------------------------
# ● done 释放动画
#--------------------------------------------------------------------------
def dispose_animation(ani)
if ani[6][0] != nil
@@_reference_count[ani[6][0]] -= 1
if @@_reference_count[ani[6][0]] == 0
ani[6][0].dispose
ani[6][0] = nil
end
end
if ani[6][1] != nil
@@_reference_count[ani[6][1]] -= 1
if @@_reference_count[ani[6][1]] == 0
ani[6][1].dispose
ani[6][1] = nil
end
end
if ani[3] != nil
for sprite in ani[3]
sprite.dispose
end
ani[3] = nil
ani[0] = nil
end
@animation_collection.delete(ani)
end
#--------------------------------------------------------------------------
# ● done 刷新动画
# number_of_collection, 用来记录是这个动画是系列的第几个,制造减法
#--------------------------------------------------------------------------
def update_animation(ani, number_of_collection = 1)
if ani[2] > 0
frame_index = ani[0].frame_max - (ani[2] + $game_system.animation_lag - 1) / $game_system.animation_lag
animation_set_sprites(ani[0].frames[frame_index], ani, number_of_collection)
for timing in ani[0].timings
if timing.frame == frame_index
animation_process_timing(timing)
end
end
if $animation_sp[ani[0].id] != nil
for keycont in $animation_sp[ani[0].id]
if keycont[0] == frame_index
animation_process_special(keycont[1] , ani)
end
end
end
for tm in ani[7]
if tm[0] == frame_index
damage(tm[1], ani[8], ani[9])
end
end
else
@fordispose.push(ani)
end
end
#--------------------------------------------------------------------------
# ● done 设置动画活动块
# frame : 帧数据 (RPG::Animation::Frame)
#--------------------------------------------------------------------------
def animation_set_sprites(frame, ani, number_of_collection = 1)
return if frame == nil
cell_data = frame.cell_data
for i in 0..15
sprite = ani[3][i]
next if sprite == nil
pattern = cell_data[i, 0]
if pattern == nil or pattern == -1
sprite.visible = false
next
end
if pattern < 100
sprite.bitmap = ani[6][0]
else
sprite.bitmap = ani[6][1]
end
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192,
pattern % 100 / 5 * 192, 192, 192)
t6Rx = x - ox
t6Ry = y - oy
if ani[0].position == 3
t6Rx = 0
t6Ry = 0
end
if @animation_mirror
sprite.x = t6Rx + ani[4] - cell_data[i, 1]
sprite.y = t6Ry + ani[5] - cell_data[i, 2]
sprite.angle = (360 - cell_data[i, 4])
sprite.mirror = (cell_data[i, 5] == 0)
else
sprite.x = t6Rx + ani[4] + cell_data[i, 1]
sprite.y = t6Ry + ani[5] + cell_data[i, 2]
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
end
sprite.z = self.z + number_of_collection # 300
sprite.z += 300 unless $game_temp.in_battle
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
if number_of_collection < @animation_collection.size
sprite.blend_type = 2
else
sprite.blend_type = cell_data[i, 7]
end
end
end
#--------------------------------------------------------------------------
# ● done SE 与闪烁的时机处理
# timing : Timing数据 (RPG::Animation::Timing)
#--------------------------------------------------------------------------
def animation_process_timing(timing, dontflash = false)
unless dontflash
timing.se.play
end
case timing.flash_scope
when 1
unless dontflash
self.flash(timing.flash_color, timing.flash_duration * $game_system.animation_lag)
$animation_hitpause += (timing.flash_duration / HITPAUSE_KR).to_i
end
return timing.flash_color.alpha * timing.flash_duration
when 2
unless dontflash
if viewport != nil
viewport.flash(timing.flash_color, timing.flash_duration * $game_system.animation_lag)
$animation_hitpause += (timing.flash_duration / HITPAUSE_KR).to_i
end
end
when 3
unless dontflash
self.flash(nil, timing.flash_duration * $game_system.animation_lag)
end
end
return 0
end
#--------------------------------------------------------------------------
# ● done 动画的特殊效果处理
# timing : Timing数据 (RPG::Animation::Timing)
#--------------------------------------------------------------------------
def animation_process_special(keycont, fromani = nil)
colorid = nil
shake = nil
colorreal = nil
helper = nil
startani = nil
eval(keycont)
update_special_colorreal(colorreal) if colorreal != nil
update_special_colorid(colorid) if colorid != nil
update_special_shake(shake) if shake != nil
update_special_helper(helper) if helper != nil
update_special_startani(startani, fromani) if startani != nil
end
#------------------------------------------------------------------------------
# 以下为临时函数,实际游戏中如果不使用请自行重写,留着无害。
#------------------------------------------------------------------------------
#--------------------------------------------------------------------------
# ● 协议函数:动画中改变屏幕色调
#--------------------------------------------------------------------------
def update_special_colorid(colorid)
if $game_temp.in_battle
if colorid[0] == 0
$scene.spriteset.battleback_sprite.start_tone_change($scene.recover_tone, colorid[1])
else
$scene.spriteset.battleback_sprite.start_tone_change(get_pixel_tone(colorid[0].to_i), colorid[1])
end
else
$game_map.screen.start_tone_change(get_pixel_tone(colorid[0].to_i), colorid[1])
end
end
#--------------------------------------------------------------------------
# ● 协议函数:动画中呼叫helper
#--------------------------------------------------------------------------
def update_special_helper(helper)
return if rand(100) < helper[7]
sprite = Sprite_Base.new
if helper[0] == 0
sprite.x = self.x + helper[1]
sprite.y = self.y + helper[2]
sprite.z = self.z + helper[3]
elsif helper[0] == 1
sprite.x = helper[1]
sprite.y = helper[2]
sprite.z = helper[3]
end
$sprite_helper.push([sprite, helper[5] * $game_system.animation_lag, helper[6]])
$sprite_helper[$sprite_helper.size - 1][0].start_animation($data_animations[helper[4]])
end
#--------------------------------------------------------------------------
# ● 协议函数:动画中改变屏幕色调
#--------------------------------------------------------------------------
def update_special_colorreal(colorreal)
if $game_temp.in_battle
$scene.spriteset.battleback_sprite.start_tone_change(Tone.new(colorreal[0],colorreal[1],colorreal[2],colorreal[3]), colorreal[4])
else
$game_map.screen.start_tone_change(Tone.new(colorreal[0],colorreal[1],colorreal[2],colorreal[3]),colorreal[4])
end
end
#--------------------------------------------------------------------------
# ● 协议函数:动画插入连续技
#--------------------------------------------------------------------------
def update_special_startani(startani, fromani)
start_animation($data_animations[startani], mirror = false, fromani[9])
end
#--------------------------------------------------------------------------
# ● 协议函数:动画中振动屏幕
#--------------------------------------------------------------------------
def update_special_shake(shake)
screen.start_shake(shake[0], shake[1], shake[2])
end
#--------------------------------------------------------------------------
# ● 协议函数:获取画面指令对象
#--------------------------------------------------------------------------
def screen
if $game_temp.in_battle
return $game_troop.screen
else
return $game_map.screen
end
end
#--------------------------------------------------------------------------
# ● 协议函数:获取编号n的色调颜色
#--------------------------------------------------------------------------
def get_pixel_tone(n)
return Tone.new(0, 0, 0, 0) if n == 0
x = 64 + (n % 8) * 8
y = 96 + (n / 8) * 8
color = Cache.system("Window").get_pixel(x, y)
return Tone.new([color.red / 4, 64].max, [color.green / 4, 64].max, [color.blue / 4, 64].max, [color.alpha, 256].max)
end
end
复制代码
此彩虹神剑脚本该如何兼容“Zhong RMVX 半即时战斗系统 1.02a版”的战斗系统呢?
作者:
路法
时间:
2009-5-16 23:37
你这个脚本是XP的,战斗系统是VX的,遂不兼容
我掩着我的脸,一副难过的表情。。
:孩子,放弃吧,你重贴了,会被打的
或者建议你真·超大幅度提高悬赏
我在下载你做的那个游戏,打算玩玩再做评论
作者:
PAME
时间:
2009-5-17 01:35
大哥,我是从柳柳的黑暗神剑传说中弄下来的,是VX
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1