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

Project1

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

[有事请教] 用图片显示了hits但是没有消失

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1237
在线时间
163 小时
注册时间
2019-10-4
帖子
217
跳转到指定楼层
1
发表于 2023-11-15 22:43:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
RUBY 代码复制
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #==============================================================================
  4.  
  5. # 作者:桜雅 在土
  6.  
  7. #==============================================================================
  8. # □ 根据打击次数显示HITS
  9. #==============================================================================
  10. class XRXS_BP19
  11. #
  12. # 两次连击最大时间差(单位:帧)
  13. #
  14. COMBOHIT_DURATION = 150
  15. end
  16. class Game_Battler
  17. #
  18. # 连击攻击力增大[単位:%]
  19. #
  20. DAMAGE_INCREASE_PER_HIT = -15
  21. end
  22. class Window_ComboHit < Window_Base
  23. #
  24. # 连技显示的字体和颜色 (255,140,0, 255)
  25. #
  26. COMBOHIT_FONTNAME  = "Arial Black"  
  27. COMBOHIT_FONTCOLOR = Color.new(255,140,0, 255)
  28. end
  29.  
  30. #==============================================================================
  31. # □ Window_ComboHit
  32. #------------------------------------------------------------------------------
  33. #     是战斗中显示连击数的透明窗口。  
  34. #==============================================================================
  35. class Window_ComboHit < Window_Base
  36. #--------------------------------------------------------------------------
  37. # ○ 对象初始化
  38. #--------------------------------------------------------------------------
  39. def initialize
  40.    super(500+50, 64, 130+50, 512)
  41.    self.contents = Bitmap.new(width - 32, height - 32)
  42.    self.opacity = 0
  43.    self.visible = false
  44.    @active = false
  45.    @show_duration = 0
  46.    @sliding_duration = 0
  47.    self.contents.clear
  48. end
  49. #--------------------------------------------------------------------------
  50. # ○ 透明
  51. #--------------------------------------------------------------------------
  52. def clear
  53.    self.contents.clear
  54.    self.visible = false
  55. end
  56. #--------------------------------------------------------------------------
  57. # ○ リフレッシュ
  58. #--------------------------------------------------------------------------
  59. def refresh(hit_combo, duration)
  60.    # 可視化
  61.    self.contents_opacity = 250
  62.    self.visible = true
  63.    # 設定
  64.    @show_duration    = duration
  65.    @sliding_duration = 0
  66.    # 描写(縁取り仕様)
  67.    self.contents.clear
  68.    self.contents.font.name = "Arial Black"
  69.    self.contents.font.italic = false #斜体
  70.    self.contents.font.bold = false
  71.    text = hit_combo.to_s + " " #最主要的一句話
  72.  
  73.      hits_string = hit_combo.to_s
  74.      bitmap = Bitmap.new(320, 64)
  75.      bitmap.font.name = "Arial Black"
  76.      bitmap.font.size = 32
  77.      # 分割伤害值字符串
  78.      hits_array =   hits_string.scan(/./)
  79.      hits_x = - 36.2#hits_string.size * 18.1 # 81 - hits_string.size * 18.1
  80.      rect_y = 0
  81.      # 循环伤害值字符串
  82.      for char in hits_array
  83.        # 后移一位
  84.        hits_x += 36.2
  85.        number = char.to_i
  86.        # 显示伤害数字
  87.        bitmap.blt(hits_x, 0, RPG::Cache.picture("String/" + "Number"),
  88.        Rect.new(number * 36.2, rect_y, 36.2, 50))
  89.      end
  90.      hits_x += 18.1
  91.      bitmap.blt(hits_x, 0, RPG::Cache.picture("String/" + "HITS"),
  92.                 Rect.new(0, -21, 90, 50))
  93.      # 伤害值定位
  94.      @_hits_sprite = ::Sprite.new(self.viewport)
  95.      @_hits_sprite.bitmap = bitmap
  96.      @_hits_sprite.x =  self.x#560 - hits_string.size * 36.2
  97.      @_hits_sprite.y = self.y - self.oy / 2
  98.      @_hits_sprite.z = 3000
  99.      @_hits_duration = 40
  100.  
  101. end
  102.  
  103. #--------------------------------------------------------------------------
  104. # ○帧更新
  105. #--------------------------------------------------------------------------
  106. def update
  107.    if @sliding_duration > 0
  108.      @sliding_duration -= 1
  109.      self.contents_opacity -= 32
  110.      self.x += 1
  111.      if @sliding_duration == 0
  112.        self.visible = false
  113.      end
  114.    elsif @show_duration > 0
  115.      @show_duration -= 1
  116.      if @show_duration == 0
  117.         @sliding_duration = 8
  118.      end
  119.    end
  120. end
  121. end
  122.  
  123. #==============================================================================
  124. # ■ Game_Battler
  125. #==============================================================================
  126. class Game_Battler
  127. #--------------------------------------------------------------------------
  128. # ● 公开实例变量
  129. #--------------------------------------------------------------------------
  130. def combohit
  131.    @combohit = 0 if @combohit.nil?
  132.    return @combohit
  133. end
  134. def combohit_duration
  135.    @combohit_duration = 0 if @combohit_duration.nil?
  136.    return @combohit_duration
  137. end
  138. #--------------------------------------------------------------------------
  139. # ○ 更新组合安打
  140. #--------------------------------------------------------------------------  
  141. def combohit_update
  142.    # 例外補正
  143.    @combohit_duration = 0 if @combohit_duration.nil?
  144.    # 计数,
  145.    if @combohit_duration > 0
  146.      @combohit_duration -= 1
  147.      # 后仰时间结束时,重置连击数
  148.  
  149.      @combohit = 0 if @combohit_duration == 0
  150.  
  151.  
  152.    end
  153. end
  154. #--------------------------------------------------------------------------
  155. # ○ コンボヒットをカウント
  156. #--------------------------------------------------------------------------  
  157. def combohit_count
  158.    # 例外補正
  159.    @combohit = 0 if @combohit.nil?
  160.    # カウント
  161.    @combohit += 1
  162.    @combohit_duration = XRXS_BP19::COMBOHIT_DURATION
  163.    #unless @motion.nil?
  164.    #  # ちとFMBS仕様
  165.    #  @combohit_duration = @motion.knock_back_duration
  166.    #end
  167. end
  168. #--------------------------------------------------------------------------
  169. # ○ コンボヒットをクリア
  170. #--------------------------------------------------------------------------  
  171. def combohit_clear
  172.    @combohit = nil
  173.    @combohit_duration = nil
  174. end
  175. #--------------------------------------------------------------------------
  176. # ● 通常攻撃の効果適用
  177. #--------------------------------------------------------------------------
  178. alias xrxs_bp19_attack_effect attack_effect
  179. def attack_effect(attacker)
  180.    # 呼び戻す
  181.    bool = xrxs_bp19_attack_effect(attacker)
  182.    # 攻撃成功時( 行動有効 & ダメージあり )
  183.    if bool and self.damage.to_i > 0
  184.      # ヒット補正
  185.      add_damage   = self.damage * ([self.combohit * DAMAGE_INCREASE_PER_HIT,-100].max)/100
  186.      self.hp     -= add_damage
  187.      self.damage += add_damage
  188.      # コンボヒット+1
  189.      self.combohit_count
  190.    end
  191.    return bool
  192. end
  193. #--------------------------------------------------------------------------
  194. # ● スキルの効果適用
  195. #--------------------------------------------------------------------------
  196. alias xrxs_bp19_skill_effect skill_effect
  197. def skill_effect(user, skill)
  198.    # ダメージスキルではない場合
  199.    if skill.power <= 0
  200.      # 呼び戻す
  201.      return xrxs_bp19_skill_effect(user, skill)
  202.    end
  203.    # ヒット補正( ダメージスキルのみ )
  204.    skill = skill.dup
  205.    skill.power = skill.power * (100 + [self.combohit * DAMAGE_INCREASE_PER_HIT,-100].max)/100
  206.    # 呼び戻す
  207.    bool = xrxs_bp19_skill_effect(user, skill)
  208.    # 攻撃成功時( 行動有効 & ダメージあり )
  209.    #if bool and self.damage.to_i > 0
  210.    if self.damage.to_i > 0
  211.      # コンボヒット+1
  212.      self.combohit_count
  213.    end
  214.    return bool
  215. end
  216. #--------------------------------------------------------------------------
  217. # ● アイテムの効果適用 项目的效果应用
  218. #--------------------------------------------------------------------------
  219. alias xrxs_bp19_item_effect item_effect
  220. def item_effect(item)
  221.    # ダメージアイテムではない場合 不是损害条款的情况
  222.    unless (item.recover_hp < 0 or item.recover_hp_rate  < 0)
  223.      # 呼び戻す
  224.      return xrxs_bp19_item_effect(item)
  225.    end
  226.    # 複製
  227.    item = item.dup
  228.    # ヒット補正
  229.    rate = (100 + [self.combohit * DAMAGE_INCREASE_PER_HIT,-100].max)
  230.    item.recover_hp      = item.recover_hp      * rate / 100
  231.    item.recover_hp_rate = item.recover_hp_rate * rate / 100
  232.    # 呼び戻す
  233.    bool = xrxs_bp19_item_effect(item)
  234.    # 攻撃成功時( 行動有効 & ダメージあり )
  235.    if bool and self.damage.to_i > 0
  236.      # コンボヒット+1
  237.      self.combohit_count
  238.    end
  239.    return bool
  240. end
  241. end
  242. #==============================================================================
  243. # ■ Scene_Battle
  244. #==============================================================================
  245. class Scene_Battle
  246. #--------------------------------------------------------------------------
  247. # ● 主处理
  248. #--------------------------------------------------------------------------
  249. alias xrxs_bp19_main main
  250. def main
  251.    # 创建组合热窗口
  252.    @combohit_window = Window_ComboHit.new
  253.    # 唤回
  254.    xrxs_bp19_main
  255.    # 打开窗口
  256.    @combohit_window.dispose
  257.    #组合通关
  258.    $game_party.actors.each {|actor| actor.combohit_clear}
  259. end
  260. #--------------------------------------------------------------------------
  261. # ● フレーム更新 帧更新
  262. #--------------------------------------------------------------------------
  263. alias xrxs_bp19_update update
  264. def update
  265.    # フレーム更新
  266.    @combohit_window.update
  267.    $game_party.actors.each {|actor| actor.combohit_update}
  268.    $game_troop.enemies.each{|enemy| enemy.combohit_update}
  269.    # 呼び戻す
  270.    xrxs_bp19_update
  271. end
  272. #--------------------------------------------------------------------------
  273. # ●帧更新(主阶段步骤5:伤害表示)  
  274. #--------------------------------------------------------------------------
  275. alias xrxs_bp19_update_phase4_step5 update_phase4_step5
  276. def update_phase4_step5
  277.    # 呼び戻す
  278.    xrxs_bp19_update_phase4_step5
  279.    # 寻找组合数最高的目标
  280.    max = 0
  281.    hit_target = nil
  282.    for target in @target_battlers
  283.      if target.combohit > max
  284.        max = target.combohit
  285.        hit_target = target
  286.      end
  287.    end
  288.    # 组合数2以上的目标存在时,表示  
  289.    if max >= 2 and !hit_target.nil?
  290.       @combohit_window.x = hit_target.is_a?(Game_Enemy) ? 512 : 0
  291.       #目标是敌人位置512 如果不是敌人0
  292.       @combohit_window.refresh(max, hit_target.combohit_duration)
  293.    end
  294. end
  295. end

我做到了用图片显示hits,但是不知道在,脚本那个位置加入消失。我觉得也因为没整合成模块吧。求大佬帮忙
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-4-30 11:15

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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