赞 | 153 |
VIP | 10 |
好人卡 | 39 |
积分 | 93 |
经验 | 146191 |
最后登录 | 2024-5-6 |
在线时间 | 2504 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 9280
- 在线时间
- 2504 小时
- 注册时间
- 2011-5-20
- 帖子
- 15389
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 fux2 于 2013-12-31 13:07 编辑
- #==============================================================================
- # ■ Game_Battler (分割定义 3)
- #------------------------------------------------------------------------------
- # 处理战斗者的类。这个类作为 Game_Actor 类与 Game_Enemy 类的
- # 超级类来使用。
- #==============================================================================
- class Game_Battler
- #--------------------------------------------------------------------------
- # ● 可以使用特技的判定
- # skill_id : 特技 ID
- #--------------------------------------------------------------------------
- def skill_can_use?(skill_id)
- # SP 不足的情况下不能使用
- if $data_skills[skill_id].sp_cost > self.sp
- return false
- end
- # 战斗不能的情况下不能使用
- if dead?
- return false
- end
- # 沉默状态的情况下、物理特技以外的特技不能使用
- if $data_skills[skill_id].atk_f == 0 and self.restriction == 1
- return false
- end
- if states.include?(4) or states.include?(7)#眩晕、沉默状态禁用技能
- return false
- end
- # 获取可以使用的时机
- occasion = $data_skills[skill_id].occasion
- # 战斗中的情况下
- if $game_temp.in_battle
- # [平时] 或者是 [战斗中] 可以使用
- return (occasion == 0 or occasion == 1)
- # 不是战斗中的情况下
- else
- # [平时] 或者是 [菜单中] 可以使用
- return (occasion == 0 or occasion == 2)
- end
- end
- #--------------------------------------------------------------------------
- # ● 应用通常攻击效果
- # attacker : 攻击者 (battler)
- #--------------------------------------------------------------------------
- def attack_effect(attacker)
- # 清除会心一击标志
- self.critical = false
- damage = 0#敌人受到伤害
- edamage = 0#敌人受到实际伤害
- self.damage = 0#输出伤害
- mdamage = 0#魔法盾伤害
- amdamage = 0#魔法盾伤害
- rdamage = 0#反弹伤害
- # $game_variables[1]=0#显示HP、SP的伤害(恢复)颜色编号
- if $attackercombo==0 or $attackercombo==nil
- combos = attacker.as%100#概率连击
- combo = (attacker.as-combos)/100#连击
- mz = rand(100)
- if mz <combos
- combo+=1
- end
- $attackercombo=combo
- end
- mz=rand(100)
- if mz > self.pdod
- mz=rand(100)
- if mz < attacker.phit
- damage = (attacker.patk - self.pdef)*(100+attacker.pog)/100
- mz=rand(100)
- if mz < attacker.pcr
- damage *= (100+attacker.pcrc)/100
- self.critical = true
- end
- if damage < 0
- damage = 0
- end
- # 状态冲击解除
- remove_states_shock
- edamage = damage*(100-self.pdr)/100#敌人受到实际伤害
- #判断是否开启魔法盾
- if states.include?(2)
- mdamage = damage*self.sdr/100#计算开启魔法盾的魔力伤害
- if self.sp < mdamage/self.sdd#魔力不足以支持完整的魔法盾
- $game_variables[1]=1
- self.damage = edamage-self.sp*self.sdd
- self.damage_pop = true
- self.hp -= edamage-self.sp*self.sdd
- $game_variables[2]=6
- self.sp_damage = self.sp
- self.sp_damage_pop = true
- self.sp = 0
- rdamage=(edamage-self.sp*self.sdd)*self.preb/100*(100-attacker.pdr)/100#受到反弹
- remove_state(2)
- else
- $game_variables[1]=1
- self.damage = edamage - mdamage
- self.damage_pop = true
- self.hp -= edamage - mdamage
- $game_variables[2]=6
- self.sp_damage = mdamage / self.sdd
- self.sp_damage_pop = true
- self.sp -= mdamage / self.sdd
- rdamage=(edamage-mdamage)*self.preb/100*(100-attacker.pdr)/100#受到反弹
- end
- else
- $game_variables[1]=1
- self.damage = edamage
- #self.damage_pop = true#这句注释取消后颜色显示会混乱
- self.hp -= edamage
- rdamage=edamage*self.preb/100*(100-attacker.pdr)/100
- end
-
- if rdamage>0
- if attacker.state?(2)#判断是否开启魔法盾抵抗反弹伤害
- amdamage = rdamage*attacker.sdr/100#计算开启魔法盾的魔力伤害
- if attacker.sp < amdamage/attacker.sdd#魔力不足以支持完整的魔法盾
- $game_variables[1]=1
- attacker.damage = rdamage-attacker.sp*attacker.sdd
- attacker.damage_pop = true
- attacker.hp -= rdamage-attacker.sp*attacker.sdd
- $game_variables[2]=6
- attacker.sp_damage = attacker.sp
- attacker.sp_damage_pop = true
- attacker.sp = 0
- remove_state(2)
- else
- $game_variables[1]=1
- attacker.damage = rdamage - amdamage
- attacker.damage_pop = true
- attacker.hp -= rdamage - amdamage
- $game_variables[2]=6
- attacker.sp_damage = amdamage / attacker.sdd
- attacker.sp_damage_pop = true
- attacker.sp -= amdamage / attacker.sdd
- end
- else
- $game_variables[1]=1
- attacker.damage = rdamage
- attacker.damage_pop = true
- attacker.hp -= rdamage#受到反弹
- end
- end
- $game_variables[1]=2
- attacker.damage = damage * attacker.pvam / 100
- attacker.damage_pop = true
- attacker.hp += damage * attacker.pvam / 100#攻击吸血
-
- # 清除会心一击标志
- self.critical = false
- # 状态变化
- @state_changed = false
- states_plus(attacker.plus_state_set)
- states_minus(attacker.minus_state_set)
- else#MISS
- # 伤害设置为 "Miss"
- self.damage = "Miss"
- # 清除会心一击标志
- self.critical = false
- end
-
- else#MISS
- # 伤害设置为 "Lost"
- self.damage = "Miss"
- # 清除会心一击标志
- self.critical = false
- end
- # 过程结束
- return true
- end
- #--------------------------------------------------------------------------
- # ● 应用特技效果
- # user : 特技的使用者 (battler)
- # skill : 特技
- #--------------------------------------------------------------------------
- def skill_effect(user, skill)
- # 清除会心一击标志
- self.critical = false
- # 特技的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
- # 或者特技的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
- if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
- ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
- bdmz=true
- # 过程结束
- return false
- end
- # 清除有效标志
- effective = false
- # 公共事件 ID 是有效的情况下,设置为有效标志
- effective |= skill.common_event_id > 0
- # 第一命中判定
- if $skills_dt[skill.id]==0#物理类型技能
- mz=rand(100)
- if mz > self.pdod
- mz=rand(100)
- if mz < user.phit
- hit_result = true
- else
- hit_result = false
- mz=0
- end
- else
- hit_result = false
- mz=0
- end
- elsif $skills_dt[skill.id]==1#魔法类型技能
- mz=rand(100)
- if mz > self.mdod
- mz=rand(100)
- if mz < user.mhit
- hit_result = true
- else
- hit_result = false
- mz=0
- end
- else
- hit_result = false
- mz=0
- end
- else#纯粹类型技能
- mz = skill.hit
- end
- hit_result = (rand(100) < mz)
- # 不确定的特技的情况下设置为有效标志
- effective |= mz < 100
- # 命中的情况下
- if hit_result == true or bdmz==true
- # 计算威力
- if $skills_dt[skill.id]==0#物理类型技能
- power = [user.patk - self.pdef, 0].max
- elsif $skills_dt[skill.id]==1#魔法类型技能
- power = [user.matk - self.mdef, 0].max
- else#纯粹类型技能
- power = skill.power
- end
- if power > 0
- power = [power, 0].max
- end
- # 计算倍率
- rate = 20
- # 计算基本伤害
- self.damage = power * rate / 20
- if $skills_dt[skill.id]==0#物理类型技能
- self.damage*=(100+self.pog)/100
- elsif $skills_dt[skill.id]==1#魔法类型技能
- self.damage*=(100+self.mog)/100
- end
- # 属性修正
- self.damage *= elements_correct(skill.element_set)
- self.damage /= 100
- # 伤害符号正确的情况下
- if self.damage > 0
- # 暴击修正
- if $skills_dt[skill.id]==0#物理类型技能
- if rand(100) < user.pcr
- self.damage *= (100+user.pcrc)/100
- self.critical = true
- end
- elsif $skills_dt[skill.id]==1#魔法类型技能
- if rand(100) < user.mcr
- self.damage *= (100+user.mcrc)/100
- self.critical = true
- end
- end
- # 防御修正
- if self.guarding?
- self.damage /= 2
- end
- end
- # 分散
- if skill.variance > 0 and self.damage.abs > 0
- amp = [self.damage.abs * skill.variance / 100, 1].max
- self.damage += rand(amp+1) + rand(amp+1) - amp
- end
- # 第二命中判定
- if $skills_dt[skill.id]==0#物理类型技能
- mz=rand(100)
- if mz > self.pdod
- mz=rand(100)
- if mz < user.phit
- hit_result = true
- else
- hit_result = false
- mz=0
- end
- else
- hit_result = false
- mz=0
- end
- elsif $skills_dt[skill.id]==1#魔法类型技能
- mz=rand(100)
- if mz > self.mdod
- mz=rand(100)
- if mz < user.mhit
- hit_result = true
- else
- hit_result = false
- mz=0
- end
- else
- hit_result = false
- mz=0
- end
- else#纯粹类型技能
- mz = skill.hit
- end
- hit_result = (rand(100) < mz)
- # 不确定的特技的情况下设置为有效标志
- effective |= mz < 100
- end
- # 命中的情况下
- if hit_result == true or bdmz==true
- # 威力 0 以外的物理攻击的情况下
- if skill.power != 0 and skill.atk_f > 0
- # 状态冲击解除
- remove_states_shock
- # 设置有效标志
- effective = true
- end
- if bdmz==true
- # 状态冲击解除
- remove_states_shock
- # 设置有效标志
- effective = true
- end
- # HP 的伤害减法运算
- last_hp = self.hp
- if $skills_dt[skill.id]==0#物理类型技能
- self.damage*=(100-self.pdr)/100
- elsif $skills_dt[skill.id]==1#魔法类型技能
- self.damage*=(100-self.mdr)/100
- end
- #法术吸蓝
- if skill.id == 10
- if self.sp == 0
- self.damage = 0
- self.hp -= self.damage
- else
- self.sp -= self.damage
- user.sp += self.damage * 50 / 100
- end
- else
- #魔法盾
- if states.include?(17)
- if self.sp == 0
- self.hp -= self.damage
- remove_state(17)
- else
- self.hp -= self.damage * (100-self.sdd) / 100
- self.sp -= self.damage * self.sdd / 100
- end
- else
- self.hp -= self.damage
- end
- end
- effective |= self.hp != last_hp
- # 状态变化
- @state_changed = false
- effective |= states_plus(skill.plus_state_set)
- effective |= states_minus(skill.minus_state_set)
-
- if $skills_dt[skill.id]==0#物理类型技能
- user.hp -= self.damage * self.preb / 100#受到反弹
- user.hp += self.damage * user.pvam / 100#攻击吸血
- elsif $skills_dt[skill.id]==1#魔法类型技能
- user.hp -= self.damage * self.mreb / 100#法术反弹
- user.hp += self.damage * user.mvam / 100#法术吸血
- end
-
- # 威力为 0 的场合
- if skill.power == 0
- # 伤害设置为空的字串
- self.damage = ""
- # 状态没有变化的情况下
- unless @state_changed
- # 伤害设置为 "Miss"
- self.damage = "Miss"
- end
- end
- # Miss 的情况下
- else
- # 伤害设置为 "Miss"
- self.damage = "Miss"
- # 清除会心一击标志
- self.critical = false
- bdmz=false
- end
- # 不在战斗中的情况下
- unless $game_temp.in_battle
- # 伤害设置为 nil
- self.damage = nil
- end
- # 过程结束
- return effective
- end
- #--------------------------------------------------------------------------
- # ● 应用物品效果
- # item : 物品
- #--------------------------------------------------------------------------
- def item_effect(item)
- # 清除会心一击标志
- self.critical = false
- # 物品的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
- # 或者物品的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
- if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
- ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
- # 过程结束
- return false
- end
- # 清除有效标志
- effective = false
- # 公共事件 ID 是有效的情况下,设置为有效标志
- effective |= item.common_event_id > 0
- # 命中判定
- hit_result = (rand(100) < item.hit)
- # 不确定的特技的情况下设置为有效标志
- effective |= item.hit < 100
- # 命中的情况
- if hit_result == true
- # 计算回复量
- recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
- recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
- if recover_hp < 0
- recover_hp += self.pdef * item.pdef_f / 20
- recover_hp += self.mdef * item.mdef_f / 20
- recover_hp = [recover_hp, 0].min
- end
- # 属性修正
- recover_hp *= elements_correct(item.element_set)
- recover_hp /= 100
- recover_sp *= elements_correct(item.element_set)
- recover_sp /= 100
- # 分散
- if item.variance > 0 and recover_hp.abs > 0
- amp = [recover_hp.abs * item.variance / 100, 1].max
- recover_hp += rand(amp+1) + rand(amp+1) - amp
- end
- if item.variance > 0 and recover_sp.abs > 0
- amp = [recover_sp.abs * item.variance / 100, 1].max
- recover_sp += rand(amp+1) + rand(amp+1) - amp
- end
- # 回复量符号为负的情况下
- if recover_hp < 0
- # 防御修正
- if self.guarding?
- recover_hp /= 2
- end
- end
- # HP 回复量符号的反转、设置伤害值
- self.damage = -recover_hp
- # HP 以及 SP 的回复
- last_hp = self.hp
- last_sp = self.sp
- self.hp += recover_hp
- self.sp += recover_sp
- effective |= self.hp != last_hp
- effective |= self.sp != last_sp
- # 状态变化
- @state_changed = false
- effective |= states_plus(item.plus_state_set)
- effective |= states_minus(item.minus_state_set)
- # 能力上升值有效的情况下
- if item.parameter_type > 0 and item.parameter_points != 0
- # 能力值的分支
- case item.parameter_type
- when 1 # MaxHP
- @maxhp_plus += item.parameter_points
- when 2 # MaxSP
- @maxsp_plus += item.parameter_points
- when 3 # 力量
- @str_plus += item.parameter_points
- when 4 # 灵巧
- @dex_plus += item.parameter_points
- when 5 # 速度
- @agi_plus += item.parameter_points
- when 6 # 魔力
- @int_plus += item.parameter_points
- end
- # 设置有效标志
- effective = true
- end
- # HP 回复率与回复量为 0 的情况下
- if item.recover_hp_rate == 0 and item.recover_hp == 0
- # 设置伤害为空的字符串
- self.damage = ""
- # SP 回复率与回复量为 0、能力上升值无效的情况下
- if item.recover_sp_rate == 0 and item.recover_sp == 0 and
- (item.parameter_type == 0 or item.parameter_points == 0)
- # 状态没有变化的情况下
- unless @state_changed
- # 伤害设置为 "Miss"
- self.damage = "Miss"
- end
- end
- end
- # Miss 的情况下
- else
- # 伤害设置为 "Miss"
- self.damage = "Miss"
- end
- # 不在战斗中的情况下
- unless $game_temp.in_battle
- # 伤害设置为 nil
- self.damage = nil
- end
- # 过程结束
- return effective
- end
- #--------------------------------------------------------------------------
- # ● 应用连续伤害效果
- #--------------------------------------------------------------------------
- def slip_damage_effect
- # 设置伤害
- self.damage = self.maxhp / 10
- # 分散
- if self.damage.abs > 0
- amp = [self.damage.abs * 15 / 100, 1].max
- self.damage += rand(amp+1) + rand(amp+1) - amp
- end
- # HP 的伤害减法运算
- self.hp -= self.damage
- # 过程结束
- return true
- end
- #--------------------------------------------------------------------------
- # ● 属性修正计算
- # element_set : 属性
- #--------------------------------------------------------------------------
- def elements_correct(element_set)
- # 无属性的情况
- if element_set == []
- # 返回 100
- return 100
- end
- # 在被赋予的属性中返回最弱的
- # ※过程 element_rate 是、本类以及继承的 Game_Actor
- # 和 Game_Enemy 类的定义
- weakest = -100
- for i in element_set
- weakest = [weakest, self.element_rate(i)].max
- end
- return weakest
- end
- end[code/]
- [code]=begin
- 伤害效果美化 v1.0 by SailCat
- 脚本使用说明:
- 1.使用时需要将Damage.png复制到你的游戏的Graphics/Pictures目录下
- 2.Damage.png文件的格式:
- 大小为180 x 96
- (0, 0) - (179, 31)为伤害值的数字表,其中每个数字宽18,高32
- (0, 32) - (179, 63)为回复值(伤害负值)的数字表,其中每个数字宽18,高32
- (0, 64) - (89, 95)为会心一击标记的图画,长宽为90 x 32
- (90, 64) - (179, 95)为未命中标记的图画,长宽为90 x 32
- 3.number.png文件的格式:
- 大小为270 x 270
- (0, 0) - (179, 33+i)为伤害值的数字表,其中每个数字宽27,高33
- (0, 233) - (89, 95)为会心一击标记的图画,长宽为90 x 32
- (90, 233) - (179, 95)为未命中标记的图画,长宽为90 x 32
- =end
- module RPG
- class Sprite < ::Sprite
- #--------------------------------------------------------------------------
- # ● 伤害值描画
- #--------------------------------------------------------------------------
- def 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(270, 231)
- bitmap.font.name = "Arial Black"
- bitmap.font.size = 32
- # 伤害值是数值的情况下
- if value.is_a?(Numeric)
- # 分割伤害值字符串
- damage_array = damage_string.scan(/./)
- damage_x = 81 - damage_string.size * 9
- # 伤害值为负的情况下
- x = damage_x- 20
- # 循环伤害值字符串
- for char in damage_array
- number = char.to_i
- # 显示伤害数字
- if $game_variables[1]==0
- bitmap.blt(damage_x, 32, RPG::Cache.picture("numbers"),
- Rect.new(number * 27, 0, 27, 33))
- elsif $game_variables[1]==1
- bitmap.blt(damage_x, 32, RPG::Cache.picture("numbers"),
- Rect.new(number * 27, 33, 27, 33))
- elsif $game_variables[1]==2
- bitmap.blt(damage_x, 32, RPG::Cache.picture("numbers"),
- Rect.new(number * 27, 66, 27, 33))
- elsif $game_variables[1]==3
- bitmap.blt(damage_x, 32, RPG::Cache.picture("numbers"),
- Rect.new(number * 27, 99, 27, 33))
- elsif $game_variables[1]==4
- bitmap.blt(damage_x, 32, RPG::Cache.picture("numbers"),
- Rect.new(number * 27, 132, 27, 33))
- elsif $game_variables[1]==5
- bitmap.blt(damage_x, 32, RPG::Cache.picture("numbers"),
- Rect.new(number * 27, 165, 27, 33))
- elsif $game_variables[1]==6
- bitmap.blt(damage_x, 32, RPG::Cache.picture("numbers"),
- Rect.new(number * 27, 198, 27, 33))
- elsif $game_variables[1]==7
- bitmap.blt(damage_x, 32, RPG::Cache.picture("numbers"),
- Rect.new(number * 27, 231, 27, 33))
- end
- # 后移一位
- damage_x += 27
- end
- # 伤害值不是数值的情况
- else
- # 如果伤害值不是 Miss
- unless value == "Miss"
- # 系统默认描画字符串
- bitmap.font.color.set(255, 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)
- # Miss 的情况下
- else
- # 显示未击中图画
- bitmap.blt(36, 28, RPG::Cache.picture("numbers"), Rect.new(108, 233, 108, 32))
- end
- end
- # 会心一击标志打开的情况
- if critical
- # 显示会心一击图画
- bitmap.blt(36, 0, RPG::Cache.picture("numbers"), Rect.new(32, 233, 90, 32))
- end
- # 伤害值定位
- @_damage_sprite = ::Sprite.new(self.viewport)
- @_damage_sprite.bitmap = bitmap
- @_damage_sprite.ox = 81
- @_damage_sprite.oy = 70
- @_damage_sprite.x = self.battler.screen_x
- @_damage_sprite.y = self.y - self.oy / 2
- @_damage_sprite.z = 3000
- @_damage_duration = 50
- $game_variables[1]=0
- end
- end
- end
- #==============================================================================
- # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
- #==============================================================================[code/]
- [code]#=============================================================================
- # 仿 伤害显示 ,在 Sprite 里又添加了个伤害显示,来显示 SP伤害。
- # 添加了第二个动画显示。(可同时两重动画) <- 芯☆淡如水
- #=============================================================================
- module RPG
- class Sprite < ::Sprite
- @@_animations = []
- @@_reference_count = {}
- def initialize(viewport = nil)
- super(viewport)
- @_whiten_duration = 0
- @_appear_duration = 0
- @_escape_duration = 0
- @_collapse_duration = 0
- @_damage_duration = 0
- @_sp_damage_duration = 0
- @_animation_duration = 0
- @_animation_duration2 = 0
- @_blink = false
- end
- def dispose
- dispose_damage
- dispose_sp_damage
- dispose_animation
- dispose_animation2
- dispose_loop_animation
- super
- end
- def sp_damage(value)
- dispose_sp_damage
- if value.is_a?(Numeric)
- sp_damage_string = value.abs.to_s
- end
- sp_bitmap = Bitmap.new(270, 231)
- sp_bitmap.font.name = "Arial Black"
- sp_bitmap.font.size = 32
- if value.is_a?(Numeric)
- sp_damage_array = sp_damage_string.scan(/./)
- sp_damage_x = 81 - sp_damage_string.size * 9
- x = sp_damage_x - 20
- for n in sp_damage_array
- number = n.to_i
- if $game_variables[2]==0
- sp_bitmap.blt(sp_damage_x, 33, RPG::Cache.picture("numbers"),
- Rect.new(number * 27, 0, 27, 33))
- elsif $game_variables[2]==1
- sp_bitmap.blt(sp_damage_x, 33, RPG::Cache.picture("numbers"),
- Rect.new(number * 27, 33, 27, 33))
- elsif $game_variables[2]==2
- sp_bitmap.blt(sp_damage_x, 33, RPG::Cache.picture("numbers"),
- Rect.new(number * 27, 66, 27, 33))
- elsif $game_variables[2]==3
- sp_bitmap.blt(sp_damage_x, 33, RPG::Cache.picture("numbers"),
- Rect.new(number * 27, 99, 27, 33))
- elsif $game_variables[2]==4
- sp_bitmap.blt(sp_damage_x, 33, RPG::Cache.picture("numbers"),
- Rect.new(number * 27, 132, 27, 33))
- elsif $game_variables[2]==5
- sp_bitmap.blt(sp_damage_x, 33, RPG::Cache.picture("numbers"),
- Rect.new(number * 27, 165, 27, 33))
- elsif $game_variables[2]==6
- sp_bitmap.blt(sp_damage_x, 33, RPG::Cache.picture("numbers"),
- Rect.new(number * 27, 198, 27, 33))
- elsif $game_variables[2]==7
- sp_bitmap.blt(sp_damage_x, 33, RPG::Cache.picture("numbers"),
- Rect.new(number * 27, 231, 27, 33))
- end
- sp_damage_x += 27
- end
- else
- sp_bitmap.blt(36, 28, RPG::Cache.picture("numbers"), Rect.new(126, 233, 90, 33))
- end
- @_sp_damage_sprite = ::Sprite.new(self.viewport)
- @_sp_damage_sprite.bitmap = sp_bitmap
- @_sp_damage_sprite.ox = 81
- @_sp_damage_sprite.oy = 40
- @_sp_damage_sprite.x = self.battler.screen_x
- @_sp_damage_sprite.y = self.y - self.oy / 2
- @_sp_damage_sprite.z = 3001
- @_sp_damage_duration = 50
- $game_variables[2]=0
- end
- def animation2(animation2, hit2)
- dispose_animation2
- @_animation2 = animation2
- return if @_animation2 == nil
- @_animation_hit2 = hit2
- @_animation_duration2 = @_animation2.frame_max
- animation_name = @_animation2.animation_name
- animation_hue = @_animation2.animation_hue
- bitmap = RPG::Cache.animation(animation_name, animation_hue)
- if @@_reference_count.include?(bitmap)
- @@_reference_count[bitmap] += 1
- else
- @@_reference_count[bitmap] = 1
- end
- @_animation2_sprites = []
- if @_animation2.position != 3 or not @@_animations.include?(animation2)
- for i in 0..15
- sprite = ::Sprite.new(self.viewport)
- sprite.bitmap = bitmap
- sprite.visible = false
- @_animation2_sprites.push(sprite)
- end
- unless @@_animations.include?(animation2)
- @@_animations.push(animation2)
- end
- end
- update_animation2
- end
- def dispose_sp_damage
- if @_sp_damage_sprite != nil
- @_sp_damage_sprite.bitmap.dispose
- @_sp_damage_sprite.dispose
- @_sp_damage_sprite = nil
- @_sp_damage_duration = 0
- end
- end
- def dispose_animation2
- if @_animation2_sprites != nil
- sprite = @_animation2_sprites[0]
- if sprite != nil
- @@_reference_count[sprite.bitmap] -= 1
- if @@_reference_count[sprite.bitmap] == 0
- sprite.bitmap.dispose
- end
- end
- for sprite in @_animation2_sprites
- sprite.dispose
- end
- @_animation2_sprites = nil
- @_animation2 = nil
- end
- end
- def effect?
- @_whiten_duration > 0 or
- @_appear_duration > 0 or
- @_escape_duration > 0 or
- @_collapse_duration > 0 or
- @_damage_duration > 0 or
- @_sp_damage_duration > 0 or
- @_animation_duration > 0 or
- @_animation_duration2 > 0
- 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 @_sp_damage_duration > 0
- @_sp_damage_duration -= 1
- case @_sp_damage_duration
- when 48..49
- @_sp_damage_sprite.y -= 4
- when 46..47
- @_sp_damage_sprite.y -= 2
- when 44..45
- @_sp_damage_sprite.y += 2
- when 38..43
- @_sp_damage_sprite.y += 4
- end
- @_sp_damage_sprite.opacity = 256 - (12 - @_sp_damage_duration) * 32
- if @_sp_damage_duration == 0
- dispose_sp_damage
- end
- end
- if @_damage_duration > 0
- @_damage_duration -= 1
- case @_damage_duration
- when 48..49
- @_damage_sprite.y -= 4
- when 46..47
- @_damage_sprite.y -= 2
- when 44..45
- @_damage_sprite.y += 2
- when 38..43
- @_damage_sprite.y += 4
- end
- @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
- if @_damage_duration == 0
- dispose_damage
- end
- end
- if @_animation != nil and (Graphics.frame_count % 2 == 0)
- @_animation_duration -= 1
- update_animation
- end
- if @_animation2 != nil and (Graphics.frame_count % 2 == 0)
- @_animation_duration2 -= 1
- update_animation2
- 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
- animation_process_timing(timing, @_animation_hit)
- end
- end
- else
- dispose_animation
- end
- end
- def update_animation2
- if @_animation_duration2 > 0
- frame_index = @_animation2.frame_max - @_animation_duration2
- cell_data = @_animation2.frames[frame_index].cell_data
- position = @_animation2.position
- animation_set_sprites(@_animation2_sprites, cell_data, position)
- for timing in @_animation2.timings
- if timing.frame == frame_index
- animation_process_timing(timing, @_animation_hit2)
- end
- end
- else
- dispose_animation2
- end
- end
- def update_loop_animation
- frame_index = @_loop_animation_index
- cell_data = @_loop_animation.frames[frame_index].cell_data
- position = @_loop_animation.position
- animation_set_sprites(@_loop_animation_sprites, cell_data, position)
- for timing in @_loop_animation.timings
- if timing.frame == frame_index
- animation_process_timing(timing, true)
- end
- end
- end
- def animation_set_sprites(sprites, cell_data, position)
- for i in 0..15
- sprite = sprites[i]
- pattern = cell_data[i, 0]
- if sprite == nil or pattern == nil or pattern == -1
- sprite.visible = false if sprite != nil
- next
- end
- sprite.visible = true
- sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
- if position == 3
- if self.viewport != nil
- sprite.x = self.viewport.rect.width / 2
- sprite.y = self.viewport.rect.height - 160
- else
- sprite.x = 320
- sprite.y = 240
- end
- else
- sprite.x = self.x - self.ox + self.src_rect.width / 2
- sprite.y = self.y - self.oy + self.src_rect.height / 2
- sprite.y -= self.src_rect.height / 4 if position == 0
- sprite.y += self.src_rect.height / 4 if position == 2
- end
- sprite.x += cell_data[i, 1]
- sprite.y += cell_data[i, 2]
- sprite.z = 2000
- 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.angle = cell_data[i, 4]
- sprite.mirror = (cell_data[i, 5] == 1)
- sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
- sprite.blend_type = cell_data[i, 7]
- 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)
- when 2
- if self.viewport != nil
- self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
- end
- when 3
- self.flash(nil, timing.flash_duration * 2)
- end
- end
- end
- def x=(x)
- sx = x - self.x
- if sx != 0
- if @_animation_sprites != nil
- for i in 0..15
- @_animation_sprites[i].x += sx
- end
- end
- if @_loop_animation_sprites != nil
- for i in 0..15
- @_loop_animation_sprites[i].x += sx
- end
- end
- end
- super
- end
- def y=(y)
- sy = y - self.y
- if sy != 0
- if @_animation_sprites != nil
- for i in 0..15
- @_animation_sprites[i].y += sy
- end
- end
- if @_loop_animation_sprites != nil
- for i in 0..15
- @_loop_animation_sprites[i].y += sy
- end
- end
- end
- super
- end
- end
- end
- #=============================================================================
复制代码 因为本人在战斗里面用到了伤害显示的脚本,而且战斗系统里有各种各样的伤害类型(中毒、魔法、普通攻击、反弹伤害、吸血效果等等···),所以本来是按照SP显示的那部分脚本做了反弹和吸血的对应脚本···但是后来发现做出来的反弹和吸血的显示无法消除,所以想了一个折衷的方法,用变量来决定显示伤害的颜色(缺陷是不能和普通攻击伤害的数值一起显示了),但是现在仍然出了很奇怪的BUG——只有1号变量为0,2号变量为6时显示的才是对应颜色(红、蓝),其他都会显示黄色,更讨厌的是,如果把第108行#self.damage_pop = true#这句注释取消后颜色显示会混乱的注释去掉就会彻底混乱,变成只显示红色数字的局面···用p的结果显示却是变量已经改变,所以···找不出问题了···
|
|