设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2627|回复: 3
打印 上一主题 下一主题

[已经过期] 关于伤害美化脚本

[复制链接]

Lv1.梦旅人

梦石
0
星屑
15
在线时间
0 小时
注册时间
2018-5-18
帖子
1
跳转到指定楼层
1
发表于 2018-5-18 19:01:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================


  4. # ============================================================================
  5. # 伤害效果美化 v1.0 by SailCat
  6. # ============================================================================

  7. # 脚本使用说明:

  8. # 1.使用时需要将Damage.png复制到你的游戏的Graphics/Pictures目录下

  9. # 2.Damage.png文件的格式:

  10. #   大小为180 x 96

  11. #   (0, 0) - (179, 31)为伤害值的数字表,其中每个数字宽18,高32

  12. #   (0, 32) - (179, 63)为回复值(伤害负值)的数字表,其中每个数字宽18,高32

  13. #   (0, 64) - (89, 95)为会心一击标记的图画,长宽为90 x 32

  14. #   (90, 64) - (179, 95)为未命中标记的图画,长宽为90 x 32

  15. # 3.sp使用方式与其相同,不插入图片也可以使用。
  16. # ============================================================================
  17. class Game_Battler
  18.   attr_accessor :sp_damage_pop            # 显示SP标志
  19.   alias new_initialize initialize
  20.   def initialize
  21.     @sp_damage_pop = false
  22.     new_initialize
  23.   end
  24.   #--------------------------------------------------------------------------
  25.   # ● 应用物品效果
  26.   #     item : 物品
  27.   #--------------------------------------------------------------------------
  28.   def item_effect(item)
  29.     # 清除会心一击标志
  30.     self.critical = false
  31.     # 物品的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
  32.     # 或者物品的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
  33.     if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
  34.        ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
  35.       # 过程结束
  36.       return false
  37.     end
  38.     # 清除有效标志
  39.     effective = false
  40.     # 公共事件 ID 是有效的情况下,设置为有效标志
  41.     effective |= item.common_event_id > 0
  42.     # 命中判定
  43.     hit_result = (rand(100) < item.hit)
  44.     # 不确定的特技的情况下设置为有效标志
  45.     effective |= item.hit < 100
  46.     # 命中的情况
  47.     if hit_result == true
  48.       # 计算回复量
  49.       recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
  50.       recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
  51.       if recover_hp < 0
  52.         recover_hp += self.pdef * item.pdef_f / 20
  53.         recover_hp += self.mdef * item.mdef_f / 20
  54.         recover_hp = [recover_hp, 0].min
  55.       end
  56.       # 属性修正
  57.       recover_hp *= elements_correct(item.element_set)
  58.       recover_hp /= 100
  59.       recover_sp *= elements_correct(item.element_set)
  60.       recover_sp /= 100
  61.       # 分散
  62.       if item.variance > 0 and recover_hp.abs > 0
  63.         amp = [recover_hp.abs * item.variance / 100, 1].max
  64.         recover_hp += rand(amp+1) + rand(amp+1) - amp
  65.       end
  66.       if item.variance > 0 and recover_sp.abs > 0
  67.         amp = [recover_sp.abs * item.variance / 100, 1].max
  68.         recover_sp += rand(amp+1) + rand(amp+1) - amp
  69.       end
  70.       # 回复量符号为负的情况下
  71.       if recover_hp < 0
  72.         # 防御修正
  73.         if self.guarding?
  74.           recover_hp /= 2
  75.         end
  76.       end
  77.       # HP 回复量符号的反转、设置伤害值
  78.       self.damage = -recover_hp
  79.       # ========================================================
  80.       # SP变动
  81.       # =======================================================
  82.       self.sp_damage = -recover_sp
  83.       # ========================================================
  84.       # SP变动
  85.       # =======================================================
  86.       # HP 以及 SP 的回复
  87.       last_hp = self.hp
  88.       last_sp = self.sp
  89.       self.hp += recover_hp
  90.       self.sp += recover_sp
  91.       effective |= self.hp != last_hp
  92.       effective |= self.sp != last_sp
  93.       # 状态变化
  94.       @state_changed = false
  95.       effective |= states_plus(item.plus_state_set)
  96.       effective |= states_minus(item.minus_state_set)
  97.       # 能力上升值有效的情况下
  98.       if item.parameter_type > 0 and item.parameter_points != 0
  99.         # 能力值的分支
  100.         case item.parameter_type
  101.         when 1  # MaxHP
  102.           @maxhp_plus += item.parameter_points
  103.         when 2  # MaxSP
  104.           @maxsp_plus += item.parameter_points
  105.         when 3  # 力量
  106.           @str_plus += item.parameter_points
  107.         when 4  # 灵巧
  108.           @dex_plus += item.parameter_points
  109.         when 5  # 速度
  110.           @agi_plus += item.parameter_points
  111.         when 6  # 魔力
  112.           @int_plus += item.parameter_points
  113.         end
  114.         # 设置有效标志
  115.         effective = true
  116.       end
  117.       # HP 回复率与回复量为 0 的情况下
  118.       if item.recover_hp_rate == 0 and item.recover_hp == 0
  119.         # 设置伤害为空的字符串
  120.         self.damage = ""
  121.         # SP 回复率与回复量为 0、能力上升值无效的情况下
  122.         if item.recover_sp_rate == 0 and item.recover_sp == 0 and
  123.            (item.parameter_type == 0 or item.parameter_points == 0)
  124.           # 状态没有变化的情况下
  125.           unless @state_changed
  126.             # 伤害设置为 "Miss"
  127.             self.damage = "Miss"
  128.           end
  129.         end
  130.       end
  131.     # Miss 的情况下
  132.     else
  133.       # 伤害设置为 "Miss"
  134.       self.damage = "Miss"
  135.     end
  136.     # 不在战斗中的情况下
  137.     unless $game_temp.in_battle
  138.       # 伤害设置为 nil
  139.       self.damage = nil
  140.     end
  141.     # 过程结束
  142.     return effective
  143.   end
  144. end
  145. #==============================================================================
  146. # ■ Sprite_Battler
  147. #==============================================================================
  148. class Sprite_Battler < RPG::Sprite
  149.   #--------------------------------------------------------------------------
  150.   # ● 刷新画面
  151.   #--------------------------------------------------------------------------
  152.   def update
  153.     super
  154.     # 战斗者为 nil 的情况下
  155.     if [url=home.php?mod=space&uid=133701]@battler[/url] == nil
  156.       self.bitmap = nil
  157.       loop_animation(nil)
  158.       return
  159.     end
  160.     # 文件名和色相与当前情况有差异的情况下
  161.     if @battler.battler_name != @battler_name or
  162.        @battler.battler_hue != @battler_hue
  163.       # 获取、设置位图
  164.       @battler_name = @battler.battler_name
  165.       @battler_hue = @battler.battler_hue
  166.       self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  167.       @width = bitmap.width
  168.       [url=home.php?mod=space&uid=291977]@height[/url] = bitmap.height
  169.       self.ox = @width / 2
  170.       self.oy = @height
  171.       # 如果是战斗不能或者是隐藏状态就把透明度设置成 0
  172.       if @battler.dead? or @battler.hidden
  173.         self.opacity = 0
  174.       end
  175.     end
  176.     # 动画 ID 与当前的情况有差异的情况下
  177.     if @battler.damage == nil and
  178.        @battler.state_animation_id != @state_animation_id
  179.       @state_animation_id = @battler.state_animation_id
  180.       loop_animation($data_animations[@state_animation_id])
  181.     end
  182.     # 应该被显示的角色的情况下
  183.     if @battler.is_a?(Game_Actor) and @battler_visible
  184.       # 不是主状态的时候稍稍降低点透明度
  185.       if $game_temp.battle_main_phase
  186.         self.opacity += 3 if self.opacity < 255
  187.       else
  188.         self.opacity -= 3 if self.opacity > 207
  189.       end
  190.     end
  191.     # 明灭
  192.     if @battler.blink
  193.       blink_on
  194.     else
  195.       blink_off
  196.     end
  197.     # 不可见的情况下
  198.     unless @battler_visible
  199.       # 出现
  200.       if not @battler.hidden and not @battler.dead? and
  201.          (@battler.damage == nil or @battler.damage_pop)
  202.         appear
  203.         @battler_visible = true
  204.       end
  205.     end
  206.     # 可见的情况下
  207.     if @battler_visible
  208.       # 逃跑
  209.       if @battler.hidden
  210.         $game_system.se_play($data_system.escape_se)
  211.         escape
  212.         @battler_visible = false
  213.       end
  214.       # 白色闪烁
  215.       if @battler.white_flash
  216.         whiten
  217.         @battler.white_flash = false
  218.       end
  219.       # 动画
  220.       if @battler.animation_id != 0
  221.         animation = $data_animations[@battler.animation_id]
  222.         animation(animation, @battler.animation_hit)
  223.         @battler.animation_id = 0
  224.       end
  225.       # 伤害
  226.       if @battler.damage_pop
  227.         damage(@battler.damage, @battler.critical)
  228.         @battler.damage = nil
  229.         @battler.critical = false
  230.         @battler.damage_pop = false
  231.       end
  232.       # ====================================================================
  233.       # SP变动
  234.       # ====================================================================
  235.       if @battler.sp_damage_pop
  236.         sp_damage(@battler.sp_damage)
  237.         @battler.sp_damage = nil
  238.         @battler.sp_damage_pop = false
  239.       end
  240.       # ====================================================================
  241.       # SP变动
  242.       # ====================================================================
  243.       # korapusu
  244.       if @battler.damage == nil and @battler.dead?
  245.         if @battler.is_a?(Game_Enemy)
  246.           $game_system.se_play($data_system.enemy_collapse_se)
  247.         else
  248.           $game_system.se_play($data_system.actor_collapse_se)
  249.         end
  250.         collapse
  251.         @battler_visible = false
  252.       end
  253.     end
  254.     # 设置活动块的坐标
  255.     self.x = @battler.screen_x
  256.     self.y = @battler.screen_y
  257.     self.z = @battler.screen_z
  258.   end
  259. end
  260. #==============================================================================
  261. # ■ Scene_Battle (分割定义 4)
  262. #==============================================================================
  263. class Scene_Battle
  264.   #--------------------------------------------------------------------------
  265.   # ● 刷新画面 (主回合步骤 5 : 显示伤害)
  266.   #--------------------------------------------------------------------------
  267.   def update_phase4_step5
  268.     # 隐藏帮助窗口
  269.     @help_window.visible = false
  270.     # 刷新状态窗口
  271.     @status_window.refresh
  272.     # 显示伤害
  273.     for target in @target_battlers
  274.       if target.damage != nil
  275.         target.damage_pop = true
  276.       end
  277.     end
  278.     # =========================================================
  279.     # SP变动
  280.     # =========================================================
  281.     for target in @target_battlers
  282.       if target.sp_damage != nil
  283.         target.sp_damage_pop = true
  284.       end
  285.     end
  286.     # =========================================================
  287.     # SP变动
  288.     # =========================================================
  289.     # 移至步骤 6
  290.     @phase4_step = 6
  291.   end
  292. end
  293. # =========================================================
  294. # 脚本核心
  295. # =========================================================
  296. module RPG
  297.   class Sprite < ::Sprite
  298.     def initialize(viewport = nil)
  299.       super(viewport)
  300.       @_whiten_duration = 0
  301.       @_appear_duration = 0
  302.       @_escape_duration = 0
  303.       @_collapse_duration = 0
  304.       @_damage_duration = 0
  305.       @_sp_damage_duration = 0
  306.       @_animation_duration = 0
  307.       @_blink = false
  308.     end
  309.     def dispose
  310.       dispose_damage
  311.       dispose_sp_damage
  312.       dispose_animation
  313.       dispose_loop_animation  
  314.       super
  315.     end
  316.     #--------------------------------------------------------------------------
  317.     # ● 伤害值描画
  318.     #--------------------------------------------------------------------------
  319.     def damage(value, critical)
  320.       # 释放伤害
  321.       dispose_damage
  322.       # 如果伤害值是数值
  323.       if value.is_a?(Numeric)
  324.         # 绝对值转为字符串
  325.         damage_string = value.abs.to_s
  326.       else
  327.         # 转为字符串
  328.         damage_string = value.to_s
  329.       end
  330.       # 初始化位图
  331.       bitmap = Bitmap.new(162, 64)
  332.       bitmap.font.name = "Arial Black"
  333.       bitmap.font.size = 28
  334.       # 伤害值是数值的情况下
  335.       if value.is_a?(Numeric)
  336.         # 分割伤害值字符串
  337.         damage_array = damage_string.scan(/./)
  338.         damage_x = 81 - damage_string.size * 9
  339.         # 伤害值为负的情况下
  340.         if value < 0
  341.           # 调用回复数字表
  342.           rect_y = 32
  343.         else
  344.           # 调用伤害数字表
  345.           rect_y = 0
  346.         end
  347.         # 循环伤害值字符串
  348.         for char in damage_array
  349.           number = char.to_i
  350.           # 显示伤害数字
  351.           bitmap.blt(damage_x, 32, RPG::Cache.picture("Damage"),
  352.             Rect.new(number * 18, rect_y, 18, 32))
  353.           # 后移一位
  354.           damage_x += 18
  355.         end
  356.       # 伤害值不是数值的情况
  357.       else
  358.         # 如果伤害值不是 Miss
  359.         unless value == "Miss"
  360.           # 系统默认描画字符串
  361.           bitmap.font.color.set(0, 0, 0)
  362.           bitmap.draw_text(-1, 27, 162, 36, damage_string, 1)
  363.           bitmap.draw_text(+1, 27, 162, 36, damage_string, 1)
  364.           bitmap.draw_text(-1, 29, 162, 36, damage_string, 1)
  365.           bitmap.draw_text(+1, 29, 162, 36, damage_string, 1)
  366.           bitmap.font.color.set(255, 255, 255)
  367.           bitmap.draw_text(0, 28, 162, 36, damage_string, 1)
  368.         # Miss 的情况下
  369.         else
  370.           # 显示未击中图画
  371.           bitmap.blt(36, 28, RPG::Cache.picture("Damage"), Rect.new(90, 64, 90, 32))
  372.         end
  373.       end
  374.       # 会心一击标志打开的情况
  375.       if critical
  376.         # 显示会心一击图画
  377.         bitmap.blt(36, 0, RPG::Cache.picture("Damage"), Rect.new(0, 64, 90, 32))
  378.       end
  379.       # 伤害值定位
  380.       @_damage_sprite = ::Sprite.new(self.viewport)
  381.       @_damage_sprite.bitmap = bitmap
  382.       @_damage_sprite.ox = 81
  383.       @_damage_sprite.oy = 20
  384.       @_damage_sprite.x = self.x
  385.       @_damage_sprite.y = self.y - self.oy / 2
  386.       @_damage_sprite.z = 3000
  387.       @_damage_duration = 40
  388.     end
  389.     #--------------------------------------------------------------------------
  390.     # ● SP变动
  391.     #--------------------------------------------------------------------------
  392.     def sp_damage(value)
  393.       # 释放伤害
  394.       dispose_sp_damage
  395.       # 如果伤害值是数值
  396.       if value.is_a?(Numeric)
  397.         # 绝对值转为字符串
  398.         sp_damage_string = value.abs.to_s
  399.       else
  400.         # 转为字符串
  401.         sp_damage_string = value.to_s
  402.       end
  403.       # 初始化位图
  404.       bitmap = Bitmap.new(162, 64)
  405.       bitmap.font.name = "Arial Black"
  406.       bitmap.font.size = 28
  407.       # 伤害值是数值的情况下
  408.       if value.is_a?(Numeric)
  409.         # 分割伤害值字符串
  410.         sp_damage_array = sp_damage_string.scan(/./)
  411.         sp_damage_x = 81 - sp_damage_string.size * 9
  412.         # 伤害值为负的情况下
  413.         if value < 0
  414.           # 调用回复数字表
  415.           rect_y = 32
  416.         else
  417.           # 调用伤害数字表
  418.           rect_y = 0
  419.         end
  420.         # 循环伤害值字符串
  421.         for char in sp_damage_array
  422.           number = char.to_i
  423.           # 显示伤害数字
  424.           bitmap.blt(sp_damage_x, 32, RPG::Cache.picture("Damagesp"),
  425.             Rect.new(number * 18, rect_y, 18, 32))
  426.           # 后移一位
  427.           sp_damage_x += 18
  428.         end
  429.       # 伤害值不是数值的情况
  430.       else
  431.         # 系统默认描画字符串
  432.         bitmap.font.color.set(0, 0, 0)
  433.         bitmap.draw_text(-1, 27, 162, 36, sp_damage_string, 1)
  434.         bitmap.draw_text(+1, 27, 162, 36, sp_damage_string, 1)
  435.         bitmap.draw_text(-1, 29, 162, 36, sp_damage_string, 1)
  436.         bitmap.draw_text(+1, 29, 162, 36, sp_damage_string, 1)
  437.         bitmap.font.color.set(255, 255, 255)
  438.         bitmap.draw_text(0, 28, 162, 36, sp_damage_string, 1)
  439.       end
  440.       # 伤害值定位
  441.       @_sp_damage_sprite = ::Sprite.new(Viewport.new(0, 0, 640, 480))
  442.       @_sp_damage_sprite.bitmap = bitmap
  443.       @_sp_damage_sprite.ox = 81
  444.       @_sp_damage_sprite.oy = 40
  445.       @_sp_damage_sprite.x = self.x
  446.       @_sp_damage_sprite.y = self.y - self.oy / 2
  447.       @_sp_damage_sprite.z = 3000
  448.       @_sp_damage_sprite.viewport.z = self.viewport.z + 1
  449.       @_sp_damage_duration = 40
  450.     end
  451.     def dispose_sp_damage
  452.       if @_sp_damage_sprite != nil
  453.         @_sp_damage_sprite.viewport.dispose
  454.         @_sp_damage_sprite.bitmap.dispose
  455.         @_sp_damage_sprite.dispose
  456.         @_sp_damage_sprite = nil
  457.         @_sp_damage_duration = 0
  458.       end
  459.     end
  460. # ============================================================================
  461. #
  462. # ============================================================================
  463.     def effect?
  464.       @_whiten_duration > 0 or
  465.       @_appear_duration > 0 or
  466.       @_escape_duration > 0 or
  467.       @_collapse_duration > 0 or
  468.       @_damage_duration > 0 or
  469.       @_sp_damage_duration > 0 or
  470.       @_animation_duration > 0
  471.     end
  472.     def update
  473.      super
  474.      if @_whiten_duration > 0
  475.        @_whiten_duration -= 1
  476.        self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  477.      end
  478.      if @_appear_duration > 0
  479.        @_appear_duration -= 1
  480.        self.opacity = (16 - @_appear_duration) * 16
  481.      end
  482.      if @_escape_duration > 0
  483.        @_escape_duration -= 1
  484.        self.opacity = 256 - (32 - @_escape_duration) * 10
  485.      end
  486.      if @_collapse_duration > 0
  487.        @_collapse_duration -= 1
  488.        self.opacity = 256 - (48 - @_collapse_duration) * 6
  489.      end
  490.      if @_damage_duration > 0
  491.        @_damage_duration -= 1
  492.        case @_damage_duration
  493.        when 38..39
  494.          @_damage_sprite.y -= 4
  495.        when 36..37
  496.          @_damage_sprite.y -= 2
  497.        when 34..35
  498.          @_damage_sprite.y += 2
  499.        when 28..33
  500.          @_damage_sprite.y += 4
  501.        end
  502.        @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
  503.        if @_damage_duration == 0
  504.          dispose_damage
  505.        end
  506.      end
  507.      if @_sp_damage_duration > 0
  508.        @_sp_damage_duration -= 1
  509.        case @_sp_damage_duration
  510.        # 这里把SP伤害数值的显示设成往上飘了
  511.        # 如要往下飘,把@_sp_damage_sprite.y后的-换成+
  512.        when 0..30
  513.          @_sp_damage_sprite.y -= 1
  514.        end
  515.        @_sp_damage_sprite.opacity = 255 - (10 - @_sp_damage_duration) * 7
  516.        if @_sp_damage_duration == 0
  517.          dispose_sp_damage
  518.        end
  519.      end
  520.      if @_animation != nil and (Graphics.frame_count % 2 == 0)
  521.        @_animation_duration -= 1
  522.        update_animation
  523.      end
  524.      if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  525.        update_loop_animation
  526.        @_loop_animation_index += 1
  527.        @_loop_animation_index %= @_loop_animation.frame_max
  528.      end
  529.      if @_blink
  530.        @_blink_count = (@_blink_count + 1) % 32
  531.        if @_blink_count < 16
  532.          alpha = (16 - @_blink_count) * 6
  533.        else
  534.          alpha = (@_blink_count - 16) * 6
  535.        end
  536.        self.color.set(255, 255, 255, alpha)
  537.      end
  538.      @@_animations.clear
  539.     end
  540.   end
  541. end

  542. #==============================================================================
  543. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  544. #==============================================================================
复制代码

使用物品时如果不回复sp,也会显示sp,怎么让它不显示
工程

project1.rar

247.19 KB, 下载次数: 100

Lv3.寻梦者

梦石
0
星屑
1438
在线时间
328 小时
注册时间
2016-4-4
帖子
168

开拓者

2
发表于 2018-5-19 09:20:12 | 只看该作者
把135行上面修改成
  1. # SP 回复率与回复量为 0、能力上升值无效的情况下
  2.         if item.recover_sp_rate == 0 and item.recover_sp == 0 and
  3.            (item.parameter_type == 0 or item.parameter_points == 0)
  4.              @sp_damage_pop = false
复制代码

试试?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
180
在线时间
211 小时
注册时间
2011-10-29
帖子
30
3
发表于 2018-5-19 09:54:39 | 只看该作者
怎么改都会错.脚本执行事件从叠了
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
6245
在线时间
558 小时
注册时间
2018-6-5
帖子
129
4
发表于 2018-6-8 01:11:26 | 只看该作者
那个,这脚本在魔塔样板7630里适用吗
俄罗斯帝国末代沙皇尼古拉二世
#俄文转写 = Царь Николай II
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-26 06:57

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表