赞 | 671 |
VIP | 62 |
好人卡 | 144 |
积分 | 335 |
经验 | 110435 |
最后登录 | 2024-11-1 |
在线时间 | 5108 小时 |
Lv5.捕梦者
- 梦石
- 0
- 星屑
- 33479
- 在线时间
- 5108 小时
- 注册时间
- 2012-11-19
- 帖子
- 4878
|
邪月长啸 发表于 2014-5-24 19:02
@芯☆淡茹水 大大的芯式战斗系统就有这个效果,可以的话,点芯大的ID找下就有了 ...
话说您也太热心了嘛~!没有必要 @ 我啊!
可能我年纪大了,都记不得自己写过什么了,还是您有心,都还记得。
下面这个,未测试:- #==============================================================================
- module RPG
- class Sprite < ::Sprite
- alias add_initialize_xdrs initialize
- def initialize(viewport = nil)
- add_initialize_xdrs(viewport)
- @_sp_damage_duration = 0
- end
- alias add_dispose_xdrs dispose
- def dispose
- dispose_sp_damage
- add_dispose_xdrs
- end
- def sp_damage(value)
- dispose_damage
- damage_string = value.abs.to_s
- 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(0, 0, 255)
- else
- bitmap.font.color.set(0, 255, 255)
- end
- bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
- @_sp_damage_sprite = ::Sprite.new(self.viewport)
- @_sp_damage_sprite.bitmap = sp_bitmap
- @_sp_damage_sprite.ox = 80
- @_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 = 40
- 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 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
- 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 38..39
- @_sp_damage_sprite.y -= 4
- when 36..37
- @_sp_damage_sprite.y -= 2
- when 34..35
- @_sp_damage_sprite.y += 2
- when 28..33
- @_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 @_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
- end
- end
- #=============================================================================
- class Game_Battler
- attr_accessor :sp_damage_pop
- attr_accessor :sp_damage
- #--------------------------------------------------------------------------
- alias add_initialize_xdrs initialize
- def initialize
- add_initialize_xdrs
- @sp_damage_pop = false
- @sp_damage = nil
- 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
- self.sp_damage = -recover_sp
- # 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
- if item.recover_sp_rate == 0 and item.recover_sp == 0
- self.sp_damage = nil
- end
- # Miss 的情况下
- else
- # 伤害设置为 "Miss"
- self.damage = "Miss"
- end
- # 不在战斗中的情况下
- unless $game_temp.in_battle
- # 伤害设置为 nil
- self.damage = nil
- self.sp_damage = nil
- end
- # 过程结束
- return effective
- end
- end
- #=============================================================================
- class Sprite_Battler < RPG::Sprite
- #--------------------------------------------------------------------------
- def update
- super
- # 战斗者为 nil 的情况下
- if [url=home.php?mod=space&uid=133701]@battler[/url] == nil
- self.bitmap = nil
- loop_animation(nil)
- return
- end
- # 文件名和色相与当前情况有差异的情况下
- if @battler.battler_name != @battler_name or
- @battler.battler_hue != @battler_hue
- # 获取、设置位图
- @battler_name = @battler.battler_name
- @battler_hue = @battler.battler_hue
- self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
- @width = bitmap.width
- [url=home.php?mod=space&uid=291977]@height[/url] = 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 @battler_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 @battler_visible
- # 出现
- if not @battler.hidden and not @battler.dead? and
- (@battler.damage == nil or @battler.damage_pop)
- appear
- @battler_visible = true
- end
- end
- # 可见的情况下
- if @battler_visible
- # 逃跑
- if @battler.hidden
- $game_system.se_play($data_system.escape_se)
- escape
- @battler_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.animation_id = 0
- end
- # 伤害
- if @battler.damage_pop
- damage(@battler.damage, @battler.critical)
- @battler.damage = nil
- @battler.critical = false
- @battler.damage_pop = false
- end
- if @battler.sp_damage_pop
- sp_damage(@battler.sp_damage)
- @battler.sp_damage = nil
- @battler.sp_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
- @battler_visible = false
- end
- end
- # 设置活动块的坐标
- self.x = @battler.screen_x
- self.y = @battler.screen_y
- self.z = @battler.screen_z
- end
- end
- #==============================================================================
- class Scene_Battle
- #--------------------------------------------------------------------------
- def update_phase4_step5
- # 隐藏帮助窗口
- @help_window.visible = false
- # 刷新状态窗口
- @status_window.refresh
- # 显示伤害
- for target in @target_battlers
- if target.damage != nil
- target.damage_pop = true
- end
- if target.sp_damage != nil
- target.sp_damage_pop = true
- end
- end
- # 移至步骤 6
- @phase4_step = 6
- end
- end
- #==============================================================================
复制代码 |
|