Project1
标题:
ARPG彩虹神剑(涂鸦版本)-大家一起来找碴
[打印本页]
作者:
冰蓝的马甲
时间:
2008-4-19 22:32
标题:
ARPG彩虹神剑(涂鸦版本)-大家一起来找碴
玩个脚本排错哈...
首先说一句,本脚本是在我隔着窗户监督CIS狂人而成。(我两个住对门)
大家一起来找碴...
构思:神话V冰蓝
脚本:(参考柳大的)神话V狂人 神话V冰蓝
# 核心的说明:
# damage_pop 不再附带damage()的功能,这个放到animation里面去了
module RPG
class Sprite < ::Sprite
@@_animations = []
@@_reference_count = {}
#==========================================
# 修改说明:
# @flash_shake用来制作挨打时候跳跃
# @_damage 用来记录每次打击之后弹出数字
#==========================================
def initialize(viewport = nil)
super(viewport)
@flash_shake = 0
@_whiten_duration = 0
@_appear_duration = 0
@_escape_duration = 0
@_collapse_duration = 0
@_damage_duration = 0
@_animation_duration = 0
@_blink = false
@_damage = [] #~66RPG~#
@py_y = 0
end
def damage(value, critical)
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 = 32
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, 55, 55)
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 / 2
@_damage_sprite.z = 3000
@_damage_duration = 40
#=======================================
# 修改:推入新的伤害
#=======================================
@_damage.push([@_damage_sprite,@_damage_duration-10,0, rand(30) - 15, rand(3)])
end
def animation(animation, hit, battler_damage="", battler_critical=false)
dispose_animation
#=======================================
# 修改:记录伤害和critical
#=======================================
@character.damage = battler_damage
@character.critical = battler_critical
@_animation = animation
return if @_animation == nil
@_animation_hit = hit
@_animation_duration = @_animation.frame_max
animation_name = @_animation.animation_name
animation_hue = @_animation.animation_hue
bitmap = RPG::Cache.animation(animation_name, animation_hue)
#=======================================
# 修改:计算总闪光权限值
#=======================================
for timing in @_animation.timings
@all_quanzhong += animation_process_timing(timing, @_animation_hit)
end
if @@_reference_count.include?(bitmap)
@@_reference_count[bitmap] += 1
else
@@_reference_count[bitmap] = 1
end
@_animation_sprites = []
if @_animation.position != 3 or not @@_animations.include?(animation)
for i in 0..15
sprite = ::Sprite.new(self.viewport)
sprite.bitmap = bitmap
sprite.visible = false
@_animation_sprites.push(sprite)
end
unless @@_animations.include?(animation)
@@_animations.push(animation)
end
end
update_animation
end
#=======================================
# 修改:更换清除伤害的算法,以防万一
# 本内容在脚本中没有使用过
#=======================================
def dispose_damage
for damage in @_damage.reverse
damage[0].bitmap.dispose
damage[0].dispose
@_damage.delete(damage)
end
end
def dispose_animation
#=======================================
# 修改:清除记录的伤害,清除权重记录
#=======================================
#@character.damage = nil
#@character.critical = false
@all_quanzhong = 1
if @_animation_sprites != nil
sprite = @_animation_sprites[0]
if sprite != nil
@@_reference_count[sprite.bitmap] -= 1
if @@_reference_count[sprite.bitmap] == 0
sprite.bitmap.dispose
end
end
for sprite in @_animation_sprites
sprite.dispose
end
@_animation_sprites = nil
@_animation = nil
end
end
def update
super
if @_whiten_duration > 0
@_whiten_duration -= 1
self.color.alpha = 128 - (16 - @_whiten_duration) * 10
end
if @_appear_duration > 0
@_appear_duration -= 1
self.opacity = (16 - @_appear_duration) * 16
end
if @_escape_duration > 0
@_escape_duration -= 1
self.opacity = 256 - (32 - @_escape_duration) * 10
end
if @_collapse_duration > 0
@_collapse_duration -= 1
self.opacity = 256 - (48 - @_collapse_duration) * 6
end
#=======================================
# 修改:更新算法,更新弹出
#=======================================
if @_damage_duration > 0
@_damage_duration -= 1
for damage in @_damage
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.delete(damage)
next
end
end
end
if @_animation != nil and (Graphics.frame_count % 2 == 0)
@_animation_duration -= 1
update_animation
end
if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
update_loop_animation
@_loop_animation_index += 1
@_loop_animation_index %= @_loop_animation.frame_max
end
if @_blink
@_blink_count = (@_blink_count + 1) % 32
if @_blink_count < 16
alpha = (16 - @_blink_count) * 6
else
alpha = (@_blink_count - 16) * 6
end
self.color.set(255, 255, 255, alpha)
end
@@_animations.clear
end
def update_animation
if @_animation_duration > 0
frame_index = @_animation.frame_max - @_animation_duration
cell_data = @_animation.frames[frame_index].cell_data
position = @_animation.position
animation_set_sprites(@_animation_sprites, cell_data, position)
#=======================================
# 修改:弹出伤害,权重计算
#=======================================
for timing in @_animation.timings
if timing.frame == frame_index
$t = 1.0 * animation_process_timing(timing, @_animation_hit)
#p t,"当前权重", @all_quanzhong,"总权重"
if @character.damage.is_a?(Numeric) and t != 0
$t *= @character.damage
$t /= @all_quanzhong
#p t,"当前伤害",@character.damage,"总伤害"
$t = $t.to_i
#p t,@character.damage,@all_quanzhong
damage($t,@character.critical)
elsif
[email protected]
_a?(Numeric)
damage(@character.damage,@character.critical)
end
end
end
else
dispose_animation
end
end
#=======================================
# 修改:敌人跳跃的功能 + 添加返回数值
#=======================================
def animation_process_timing(timing, hit)
if (timing.condition == 0) or
(timing.condition == 1 and hit == true) or
(timing.condition == 2 and hit == false)
if timing.se.name != ""
se = timing.se
Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
end
case timing.flash_scope
when 1
self.flash(timing.flash_color, timing.flash_duration * 2)
@flash_shake_switch = true
@flash_shake = 10
return timing.flash_color.alpha * timing.flash_duration
when 2
if self.viewport != nil
self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
return timing.flash_color.alpha * timing.flash_duration
end
when 3
self.flash(nil, timing.flash_duration * 2)
return timing.flash_color.alpha * timing.flash_duration
end
end
return 0
end
end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < RPG::Sprite
#--------------------------------------------------------------------------
# ● 初始化对像
# 添加跳跃记录
#--------------------------------------------------------------------------
def initialize(viewport, battler = nil)
super(viewport)
@battler = battler
@character.visible = false
@flash_shake_switch = true
end
#--------------------------------------------------------------------------
# ● 刷新画面
# 增添跳跃功能
#--------------------------------------------------------------------------
def update
super
# 战斗者为 nil 的情况下
if @battler == nil
self.bitmap = nil
loop_animation(nil)
return
end
# 文件名和色相与当前情况有差异的情况下
if @battler.battler_name != @character.name or
@battler.battler_hue != @character.hue
# 获取、设置位图
@character.name = @battler.battler_name
@character.hue = @battler.battler_hue
self.bitmap = RPG::Cache.battler(@character.name, @character.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
# 动画 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
# 应该被显示的角色的情况下
if @battler.is_a?(Game_Actor) and @character.visible
# 不是主状态的时候稍稍降低点透明度
if $game_temp.battle_main_phase
self.opacity += 3 if self.opacity < 255
else
self.opacity -= 3 if self.opacity > 207
end
end
# 明灭
if @battler.blink
blink_on
else
blink_off
end
# 不可见的情况下
unless @character.visible
# 出现
if not @battler.hidden and not @battler.dead? and
(@battler.damage == nil or @battler.damage_pop)
appear
@character.visible = true
end
end
# 可见的情况下
if @character.visible
# 逃跑
if @battler.hidden
$game_system.se_play($data_system.escape_se)
escape
@character.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.damage, @battler.critical)
@battler.animation_id = 0
end
# 伤害
if @battler.damage_pop
@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)
else
$game_system.se_play($data_system.actor_collapse_se)
end
collapse
@character.visible = false
end
end
# 设置活动块的坐标
if @flash_shake_switch == true
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
@flash_shake_switch = false
end
if @flash_shake != 0 and @battler.damage != nil
case @flash_shake
when 9..10
self.x = @battler.screen_x
self.y -=4
self.z = @battler.screen_z
when 6..8
self.x = @battler.screen_x
self.y -=2
self.z = @battler.screen_z
when 3..5
self.x = @battler.screen_x
self.y +=2
self.z = @battler.screen_z
when 2
self.x = @battler.screen_x
self.y += 4
self.z = @battler.screen_z
when 1
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
end
@flash_shake -= 1
end
end
end
class Sprite_Character < RPG::Sprite
alias damage_pop_update update
def update
damage_pop_update
if @character.damage_pop and $t != 0
damage_disp
end
if @da != $t and $t != 0
@da = $t.to_i
damage_disp
end
end
def damage_disp
@da = $t.to_i
damage(da, @character.critical)
$t = 0
@character.critical = false
@character.damage_pop = false
end
end
class Game_Character
attr_accessor :damage_pop
attr_accessor :damage
attr_accessor :critical
alias damage_pop_initialize initialize
def initialize
@damage_pop = false
@damage = 0
@critical = false
damage_pop_initialize
end
end
复制代码
差不多了吧...闪人。88。
作者:
冰蓝的马甲
时间:
2008-4-19 22:35
另外感谢一下Iselia雪同学...批了狂人一顿...使他猛下苦工夫学习...今天上午他一直在写作业...都是我给他挂着来着...(希望他数学不要再打75了!)
作者:
越前リョーマ
时间:
2008-4-19 23:17
介绍也没有……
什么东西啊……
作者:
shanely
时间:
2008-4-20 01:27
给个范例吧……这样什么人都不清楚……= =
作者:
ONEWateR
时间:
2008-4-20 20:56
BUG
作者:
水迭澜
时间:
2008-4-22 02:45
脚本419行发现NameError
其实我一直觉得这个脚本背后要一个完善系统……orz
作者:
CIS狂人
时间:
2008-4-26 02:51
匹夫世界啊..(发牢骚中,别管)
其实想出这个点子的就有我一个人而已..
作者:
水迭澜
时间:
2008-4-26 02:53
其实LZ是LS的MJ吧。
这年头都流行披着MJ自言自语么?
作者:
CIS狂人
时间:
2008-4-26 05:21
是好主义..但是其实是错误的......这个点子就是我想出来的..盗窃LZ的号发出来..(不要怪我.他竟然密码用跟我一样)我打错了名字以后..
作者:
CIS狂人
时间:
2008-4-26 05:22
难道没有看到我两个的IP那么近么?
作者:
yubinhuei
时间:
2008-4-26 12:50
废话.前面2个IP一致.不是马甲才怪.
作者:
CIS狂人
时间:
2008-4-26 19:50
....是我不小心看到他的号了..我们两个真的住对门......不信的话就拉倒吧..谁让他和我设定的密码一致呢.
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1