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

Project1

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

[已经解决] 请教一个“状态图标化”(图标显示状态)脚本的问题

[复制链接]

Lv4.逐梦者

梦石
0
星屑
9128
在线时间
463 小时
注册时间
2015-5-8
帖子
865
跳转到指定楼层
1
发表于 2022-8-11 05:13:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 taeckle 于 2022-8-14 10:54 编辑

刚才那个帖子过期了,那咱就重开一个帖子来描述这个问题。

我找到了一个“状态图标化”脚本还有一个“脚下显示HPSP”脚本, 可以把状态用图标显示在敌人身上, 但是我把这两个脚本移植到新开的默认工程里就会出现了一个问题:

敌人使用普通攻击后, 自身实际已经消失的状态(比如第1号状态)对应的状态图标却不消失

更神奇的是, 用了这个状态图标化脚本还有脚下显示HPSP脚本后敌人使用技能后自身消失的状态(比如第1号状态)对应的图标却能正常消失,

此外我方队员使用普通攻击后, 自身消失的状态(比如第1号状态)对应的状态图标也能正常消失。。


这是什么原因呢?

这是“脚下显示HPSP”脚本:

RUBY 代码复制
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #==============================================================================
  4. # ■ エネミーHP&SP(ver 0.98)
  5. # □ カスタマイズポイント
  6. #==============================================================================
  7. module PLAN_HPSP_DRAW
  8. FONT_NAME         = ["黑体", "楷体", "宋体"]    # フォント
  9. FONT_SIZE         =  14                               # フォントサイズ
  10. FONT_BOLD         = true                              # 太字
  11. FONT_ITALIC       = false                              # 斜体
  12. DRAW_NAME         = true                              # 名前の描画
  13. DRAW_HP           = true                              # HP の描画
  14. DRAW_SP           = true                              # SP の描画
  15. DRAW_WIDTH        =  240                              # 描画幅
  16. DRAW_HEIGHT       = 5 * 32                          # 描画高さ
  17. DRAW_SPACE        =  4                                # 行間
  18. DRAW_Y            =  36                               # Y 座標修正値
  19. end
  20. #==============================================================================
  21. # ■ Sprite_Battler
  22. #==============================================================================
  23. class Sprite_Battler < RPG::Sprite
  24. #--------------------------------------------------------------------------
  25. # ● オブジェクト初期化
  26. #--------------------------------------------------------------------------
  27. alias plan_enemy_hpsp_draw_initialize initialize
  28. def initialize(viewport, battler = nil)
  29.    # 元のメソッドに戻す
  30.    plan_enemy_hpsp_draw_initialize(viewport, battler)
  31.    # エネミーの場合
  32.    if @battler.is_a?(Game_Enemy)
  33.      width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
  34.      height = PLAN_HPSP_DRAW::DRAW_HEIGHT + 32
  35.      x = @battler.screen_x - width / 2
  36.      y = @battler.screen_y - height + 32 + PLAN_HPSP_DRAW::DRAW_Y
  37.      @enemy_hpsp_window = Window_Base.new(x, y, width, height)
  38.      @enemy_hpsp_window.contents = Bitmap.new(width - 32, height - 32)
  39.      @enemy_hpsp_window.contents.font.name = PLAN_HPSP_DRAW::FONT_NAME
  40.      @enemy_hpsp_window.contents.font.size = PLAN_HPSP_DRAW::FONT_SIZE
  41.      @enemy_hpsp_window.contents.font.bold = PLAN_HPSP_DRAW::FONT_BOLD
  42.      @enemy_hpsp_window.contents.font.italic = PLAN_HPSP_DRAW::FONT_ITALIC
  43.      y = 0
  44.      @old_enemy_hpsp = []
  45.      one_line = ((PLAN_HPSP_DRAW::FONT_SIZE * 100 / 28) * 32) / 100
  46.      if PLAN_HPSP_DRAW::DRAW_NAME
  47.        @enemy_hpsp_window.draw_actor_name(@battler, 0+64, y-8, 100)
  48.        y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  49.        @old_enemy_hpsp.push(@battler.name)
  50.      end
  51.      if PLAN_HPSP_DRAW::DRAW_HP
  52.        @enemy_hpsp_window.draw_actor_hp2222(@battler, 0+64, y, 100,4)
  53.        y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  54.        @old_enemy_hpsp.push(@battler.hp)
  55.      end
  56.      if PLAN_HPSP_DRAW::DRAW_SP
  57.        @enemy_hpsp_window.draw_actor_sp2222(@battler, 0+64, y, 100,4)
  58.        @old_enemy_hpsp.push(@battler.sp)
  59.      end
  60.      @enemy_hpsp_window.opacity = 0
  61.      @enemy_hpsp_window.contents_opacity = 0
  62.      @enemy_hpsp_window.z = -2
  63.  
  64.    end
  65. end
  66. #--------------------------------------------------------------------------
  67. # ● 解放
  68. #--------------------------------------------------------------------------
  69. alias plan_enemy_hpsp_draw_dispose dispose
  70. def dispose
  71.    # エネミーの場合
  72.    if @battler.is_a?(Game_Enemy)
  73.      @enemy_hpsp_window.dispose
  74.    end
  75.    # 元のメソッドに戻す
  76.    plan_enemy_hpsp_draw_dispose
  77. end
  78. #--------------------------------------------------------------------------
  79. # ● フレーム更新
  80. #--------------------------------------------------------------------------
  81. alias plan_enemy_hpsp_draw_update update
  82. def update
  83.    # 元のメソッドに戻す
  84.    plan_enemy_hpsp_draw_update
  85.    # エネミーの場合
  86.    if @battler.is_a?(Game_Enemy)
  87.      @enemy_hpsp_window.visible = @battler_visible
  88.    # スプライトの座標を設定
  89.      width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
  90.      @enemy_hpsp_window.x = self.x - width / 2
  91.      @now_enemy_hpsp = []
  92.      if PLAN_HPSP_DRAW::DRAW_NAME
  93.        @now_enemy_hpsp.push(@battler.name)
  94.      end
  95.      if PLAN_HPSP_DRAW::DRAW_HP
  96.        @now_enemy_hpsp.push(@battler.hp)
  97.      end
  98.      if PLAN_HPSP_DRAW::DRAW_SP
  99.        @now_enemy_hpsp.push(@battler.sp)
  100.      end
  101.      if @old_enemy_hpsp != @now_enemy_hpsp and $game_temp.enemy_hpsp_refresh
  102.        @old_enemy_hpsp = @now_enemy_hpsp
  103.        @enemy_hpsp_window.contents.clear
  104.        y = 0
  105.        #width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
  106.        width = 132 #常量代入,脚本融合
  107.        one_line = ((PLAN_HPSP_DRAW::FONT_SIZE * 100 / 28) * 32) / 100
  108.        if PLAN_HPSP_DRAW::DRAW_NAME
  109.          @enemy_hpsp_window.draw_actor_name(@battler, 0+64, y-8, width - 32)
  110.          y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  111.        end
  112.        if PLAN_HPSP_DRAW::DRAW_HP
  113.          @enemy_hpsp_window.draw_actor_hp2222(@battler, 0+64, y, width - 32,4)
  114.          y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  115.        end
  116.        if PLAN_HPSP_DRAW::DRAW_SP
  117.          @enemy_hpsp_window.draw_actor_sp2222(@battler, 0+64, y, width - 32,4)
  118.        end
  119.  
  120.        Graphics.frame_reset
  121.      end
  122.    end
  123. end
  124. #--------------------------------------------------------------------------
  125. # ● visible の設定
  126. #--------------------------------------------------------------------------
  127. if !method_defined?("plan_enemy_hpsp_draw_visible=")
  128.    alias plan_enemy_hpsp_draw_visible= visible=
  129. end
  130. def visible=(bool)
  131.    # エネミーの場合
  132.    if @battler.is_a?(Game_Enemy)
  133.      @enemy_hpsp_window.visible = bool
  134.    end
  135.    # 元のメソッドに戻す
  136.    self.plan_enemy_hpsp_draw_visible=(bool)
  137. end
  138. #--------------------------------------------------------------------------
  139. # ● 不透明度の設定
  140. #--------------------------------------------------------------------------
  141. if !method_defined?("plan_enemy_hpsp_draw_opacity=")
  142.    alias plan_enemy_hpsp_draw_opacity= opacity=
  143. end
  144. def opacity=(n)
  145.    # 元のメソッドに戻す
  146.    self.plan_enemy_hpsp_draw_opacity=(n)
  147.    # エネミーの場合
  148.    if @battler.is_a?(Game_Enemy)
  149.      @enemy_hpsp_window.contents_opacity = n
  150.    end
  151. end
  152. #--------------------------------------------------------------------------
  153. # ● ダメージ
  154. #--------------------------------------------------------------------------
  155. def damage(value, critical)
  156.    super(value, critical)
  157.    bitmap = @_damage_sprite.bitmap
  158.    @_damage_sprite.dispose
  159.    @_damage_sprite = ::Sprite.new(Viewport.new(0, 0, 640, 480))
  160.    @_damage_sprite.bitmap = bitmap
  161.    @_damage_sprite.ox = 80
  162.    @_damage_sprite.oy = 20
  163.    @_damage_sprite.x = self.x
  164.    @_damage_sprite.y = self.y - self.oy / 2
  165.    @_damage_sprite.viewport.z = self.viewport.z + 1
  166.    @_damage_sprite.z = 3000
  167.    @_damage_duration = 40
  168. end
  169. #--------------------------------------------------------------------------
  170. # ● ダメージ解放
  171. #--------------------------------------------------------------------------
  172. def dispose_damage
  173.    if @_damage_sprite != nil
  174.      @_damage_sprite.viewport.dispose
  175.    end
  176.    super
  177. end
  178. end
  179. #==============================================================================
  180. # ■ Game_Temp
  181. #==============================================================================
  182. class Game_Temp
  183. #--------------------------------------------------------------------------
  184. # ● 公開インスタンス変数
  185. #--------------------------------------------------------------------------
  186. attr_accessor :enemy_hpsp_refresh
  187. #--------------------------------------------------------------------------
  188. # ● オブジェクト初期化
  189. #--------------------------------------------------------------------------
  190. alias plan_enemy_hpsp_draw_initialize initialize
  191. def initialize
  192.    # 元のメソッドに戻す
  193.    plan_enemy_hpsp_draw_initialize
  194.    @enemy_hpsp_refresh = false
  195. end
  196. end
  197. #==============================================================================
  198. # ■ Scene_Battle
  199. #==============================================================================
  200. class Scene_Battle
  201. #--------------------------------------------------------------------------
  202. # ● プレバトルフェーズ開始 (エネミー名+アルファベット用)
  203. #--------------------------------------------------------------------------
  204. alias plan_enemy_hpsp_draw_start_phase1 start_phase1
  205. def start_phase1
  206.    $game_temp.enemy_hpsp_refresh = true
  207.    # 元のメソッドに戻す
  208.    plan_enemy_hpsp_draw_start_phase1
  209. end
  210. #--------------------------------------------------------------------------
  211. # ● パーティコマンドフェーズ開始 (エネミー名+アルファベット用)
  212. #--------------------------------------------------------------------------
  213. alias plan_enemy_hpsp_draw_start_phase2 start_phase2
  214. def start_phase2
  215.    $game_temp.enemy_hpsp_refresh = false
  216.    # 元のメソッドに戻す
  217.    plan_enemy_hpsp_draw_start_phase2
  218. end
  219. #--------------------------------------------------------------------------
  220. # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
  221. #--------------------------------------------------------------------------
  222. alias plan_enemy_hpsp_draw_update_phase4_step5 update_phase4_step5
  223. def update_phase4_step5
  224.    # 元のメソッドに戻す
  225.    plan_enemy_hpsp_draw_update_phase4_step5
  226.    $game_temp.enemy_hpsp_refresh = true
  227. end
  228. #--------------------------------------------------------------------------
  229.  
  230. #--------------------------------------------------------------------------
  231. alias plan_enemy_hpsp_draw_update_phase4_step6 update_phase4_step6
  232. def update_phase4_step6
  233.    # 元のメソッドに戻す
  234.    plan_enemy_hpsp_draw_update_phase4_step6
  235.    $game_temp.enemy_hpsp_refresh = true
  236. end
  237. #--------------------------------------------------------------------------
  238.  
  239. #--------------------------------------------------------------------------
  240. alias plan_enemy_hpsp_draw_update_phase4_step1 update_phase4_step1
  241. def update_phase4_step1
  242.    # 元のメソッドに戻す
  243.    plan_enemy_hpsp_draw_update_phase4_step1
  244.    $game_temp.enemy_hpsp_refresh = true
  245. end
  246. alias plan_enemy_hpsp_draw_update_phase4_step2 update_phase4_step2
  247. def update_phase4_step2
  248.    # 元のメソッドに戻す
  249.    plan_enemy_hpsp_draw_update_phase4_step2
  250.    $game_temp.enemy_hpsp_refresh = false
  251. end  
  252. alias plan_enemy_hpsp_draw_update_phase4_step4 update_phase4_step4
  253. def update_phase4_step4
  254.    # 元のメソッドに戻す
  255.    plan_enemy_hpsp_draw_update_phase4_step4
  256.    $game_temp.enemy_hpsp_refresh = false
  257. end  
  258. #--------------------------------------------------------------------------
  259. #原理: step1:T;step2,F,3,F,4:F;step5:T;step6:T
  260. #--------------------------------------------------------------------------
  261. end
  262. #==============================================================================
  263. # ■ Window_Base
  264. #==============================================================================
  265. class Window_Base < Window
  266. #--------------------------------------------------------------------------
  267. # ● 名前の描画
  268. #--------------------------------------------------------------------------
  269. def draw_actor_name(actor, x, y, width = 120, align = 0)
  270.    self.contents.font.color = Color.new(30,255,0)
  271.    self.contents.font.name = ["黑体", "楷体", "宋体"]
  272.    self.contents.font.italic = false
  273.    self.contents.font.bold = true
  274.    #self.contents.font.size = 22
  275.    align = 1 if $scene.is_a?(Scene_Battle)
  276.    if actor.is_a?(Game_Enemy)
  277.    self.contents.draw_text(x-64, y, width+120, 32, actor.name, align)
  278.    elsif $scene.is_a?(Scene_Battle)
  279.    self.contents.draw_text(x-64, y, width+120, 32, actor.name, align)
  280.    else
  281.    self.contents.draw_text(x, y, width, 32, actor.name, align)
  282.    end
  283.  
  284.    if actor.is_a?(Game_Enemy)
  285.    state_size = 0
  286.    #debuff_idx = 0
  287.    #buff_idx = 0
  288.     for state in actor.states
  289.       # 图标数量超出宽度就中断循环
  290.       if state_size >=  12
  291.         break
  292.       end
  293.       # 此状态不带图标就跳过
  294.       if !ICON_STATE_IDS.include?(state)
  295.         next
  296.       end
  297.       bitmap = RPG::Cache.icon($data_states[state].animation_id.to_s)
  298.       if actor.states_turn[state] >= $data_states[state].hold_turn/2
  299.         opacity = 255
  300.       else
  301.         opacity = 100
  302.       end
  303.       #if $data_states[state].name.include?"☆"
  304.        # if debuff_idx <= 5
  305.         # self.contents.blt(x + 24 * debuff_idx, y + 64 - 108, bitmap, Rect.new(0, 0, 24, 24), opacity)
  306.         #else
  307.          #self.contents.blt(x + 24 * (debuff_idx-5), y + 64 - 86, bitmap, Rect.new(0, 0, 24, 24), opacity)
  308.         #end
  309.         #debuff_idx += 1
  310.       #else
  311.        # if  buff_idx <= 5
  312.         # self.contents.blt(x + 24 * buff_idx, y + 64, bitmap, Rect.new(0, 0, 24, 24), opacity)
  313.         #else
  314.          #self.contents.blt(x + 24 * (buff_idx-5), y + 64+32, bitmap, Rect.new(0, 0, 24, 24), opacity)
  315.         #end
  316.         #buff_idx += 1
  317.       #end
  318.  
  319.       if state_size <= 5
  320.        self.contents.blt(64+24 * state_size, 64, bitmap, Rect.new(0, 0, 24, 24), opacity)
  321.       else
  322.        self.contents.blt(64+24 * (state_size-5), 64+30, bitmap, Rect.new(0, 0, 24, 24), opacity)
  323.       end
  324.       state_size += 1
  325.     end
  326.    end
  327. #========================================================================
  328. end
  329. #--------------------------------------------------------------------------
  330. # ● ステートの描画
  331. #--------------------------------------------------------------------------
  332. def draw_actor_state(actor, x, y, width = 120)
  333.    # 元のメソッドに戻す
  334.    text = make_battler_state_text(actor, width, true)
  335.    self.contents.draw_text(x, y, width, 32, text, 1)
  336. end
  337. end
  338. #==============================================================================
  339. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  340. #==============================================================================
  341. class Window_Base < Window
  342.   def draw_actor_hp2222(actor, x, y, width = 100, height=8)
  343.     y+=3
  344.     olx = x
  345.     oly = y
  346.     #w = width * actor.hp / [actor.maxhp,1].max
  347.     w = 100 * actor.hp / [actor.maxhp,1].max  
  348.     hp_color_1 = Color.new(255, 0, 0, 192)  
  349.     hp_color_2 = Color.new(255, 255, 0, 192)  
  350.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))  
  351.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)  
  352.     x -= 1  
  353.     y += (height/4).floor  
  354.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))  
  355.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)  
  356.     x -= 1  
  357.     y += (height/4).ceil  
  358.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))  
  359.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)  
  360.     x -= 1  
  361.     y += (height/4).ceil  
  362.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))  
  363.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)  
  364.     x = olx
  365.     y = oly-14   
  366.     # 描绘字符串 "HP"
  367.     self.contents.font.color = system_color
  368.     self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
  369.     # 计算描绘 MaxHP 所需的空间  
  370.     if width - 32 >= 108
  371.       hp_x = x + width - 108
  372.       flag = true
  373.     elsif width - 32 >= 48
  374.       hp_x = x + width - 48
  375.       flag = false
  376.     end
  377.     # 描绘 HP
  378.     self.contents.font.color = actor.hp == 0 ? knockout_color :
  379.       actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
  380.     self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
  381.     # 描绘 MaxHP
  382.     if flag
  383.       self.contents.font.color = normal_color
  384.       self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
  385.       self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
  386.     end     
  387.   end
  388.   def draw_actor_sp2222(actor, x, y, width = 100, height = 8)
  389.     y+=3
  390.     olx = x
  391.     oly = y
  392.     #w = width * actor.sp / [actor.maxsp,1].max  
  393.     w = 100 * actor.sp / [actor.maxsp,1].max  
  394.     hp_color_1 = Color.new( 0, 0, 255, 192)  
  395.     hp_color_2 = Color.new( 0, 255, 255, 192)  
  396.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))  
  397.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)  
  398.     x -= 1  
  399.     y += (height/4).floor  
  400.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))  
  401.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)  
  402.     x -= 1  
  403.     y += (height/4).ceil  
  404.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))  
  405.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)  
  406.     x -= 1  
  407.     y += (height/4).ceil  
  408.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))  
  409.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)  
  410.     x = olx
  411.     y = oly-14
  412.     # 描绘字符串 "SP"  
  413.     self.contents.font.color = system_color
  414.     self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
  415.     # 计算描绘 MaxSP 所需的空间
  416.     if width - 32 >= 108
  417.       sp_x = x + width - 108
  418.       flag = true
  419.     elsif width - 32 >= 48
  420.       sp_x = x + width - 48
  421.       flag = false
  422.     end
  423.     # 描绘 SP
  424.     self.contents.font.color = actor.sp == 0 ? knockout_color :
  425.       actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
  426.     self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
  427.     # 描绘 MaxSP
  428.     if flag
  429.       self.contents.font.color = normal_color
  430.       self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
  431.       self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
  432.     end     
  433.   end
  434.   #--------------------------------------------------------------------------  
  435.   # ● ライン描画 by 桜雅 在土  
  436.   #--------------------------------------------------------------------------  
  437.   def draw_line(start_x, start_y, end_x, end_y, start_color, width = 1, end_color = start_color)  
  438.     # 描写距離の計算。大きめに直角時の長さ。  
  439.     distance = (start_x - end_x).abs + (start_y - end_y).abs  
  440.     # 描写開始  
  441.     if end_color == start_color  
  442.       for i in 1..distance  
  443.         x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i  
  444.         y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i  
  445.         if width == 1  
  446.           self.contents.set_pixel(x, y, start_color)  
  447.         else  
  448.           self.contents.fill_rect(x, y, width, width, start_color)  
  449.         end  
  450.       end  
  451.     else  
  452.       for i in 1..distance  
  453.         x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i  
  454.         y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i  
  455.         r = start_color.red * (distance-i)/distance + end_color.red * i/distance  
  456.         g = start_color.green * (distance-i)/distance + end_color.green * i/distance  
  457.         b = start_color.blue * (distance-i)/distance + end_color.blue * i/distance  
  458.         a = start_color.alpha * (distance-i)/distance + end_color.alpha * i/distance  
  459.         if width == 1  
  460.           self.contents.set_pixel(x, y, Color.new(r, g, b, a))  
  461.         else  
  462.           self.contents.fill_rect(x, y, width, width, Color.new(r, g, b, a))  
  463.         end  
  464.       end  
  465.     end  
  466.   end  
  467. end
  468. #==============================================================================
  469. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  470. #==============================================================================




这是那个“图标显示状态”脚本:

RUBY 代码复制
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. # 欢迎访问[url]www.66RPG.com[/url]
  4. # 梦想世界,在你手中
  5. #==============================================================================
  6. #==============================================================================
  7. # 图标显示状态 v1.1
  8. # By 叶子
  9. # 9-30-2007 v1.1
  10. # 修正了描绘状态的一个致命BUG
  11. # 12-31-2005 v1.0
  12. # 重定义类:Window_Base, Window_Help
  13. #==============================================================================
  14. # 脚本功能:
  15. # 实现战斗中和菜单中用图标显示状态,代替原来的文字显示。
  16. # 默认最多同时显示5个状态 108行定义,已改为8
  17. #------------------------------------------------------------------------------
  18. # 设置方法:
  19. # 一个状态对应的图标文件名为“状态的动画ID”
  20. # 例如某状态的动画ID为50,那么它的图标就是“Icons\50.png”或“Icons\50.jpg”
  21. # 如果找不到对应的文件,会报错 ◎_◎
  22. #==============================================================================
  23. # 注意,在ICON_STATE_IDS中写上需要带图标的状态ID
  24. # ICON_STATE_IDS是一个数组,数组的方法请参考帮助文件
  25. # 例如:
  26. # 只要1,5,8号状态带图标,就这样:ICON_STATE_IDS = [1,5,8]
  27. # 要20到50号状态带图标:ICON_STATE_IDS = 20..50
  28. ICON_STATE_IDS = 1..999
  29. #==============================================================================
  30. # ■ Window_Base
  31. #------------------------------------------------------------------------------
  32. #  游戏中全部窗口的超级类。
  33. #==============================================================================
  34. class Window_Base < Window
  35.   #--------------------------------------------------------------------------
  36.   # ● 描绘状态
  37.   #     actor : 角色
  38.   #     x     : 描画目标 X 坐标
  39.   #     y     : 描画目标 Y 坐标
  40.   #     width : 描画目标的宽
  41.   #--------------------------------------------------------------------------
  42.   def draw_actor_state(actor, x, y, width = 120)  #改动了一下
  43.     text = make_battler_state_text(actor, width, true)
  44.     text.gsub!(/\[/) { "" }
  45.     text.gsub!(/\]/) { "" }
  46.     s = text.split("/")
  47.     sp = 0
  48.     s.each do |i|
  49.       bitmap = RPG::Cache.icon("#{i}")     
  50.       cw = bitmap.width
  51.       ch = bitmap.height
  52.       src_rect = Rect.new(0, 0, cw, ch)
  53.       self.contents.blt(x + sp, y, bitmap, src_rect)
  54.       sp += cw + 10
  55.     end
  56.   end
  57. end
  58. class Window_Base < Window
  59.   #--------------------------------------------------------------------------
  60.   # ● 描绘状态
  61.   #     actor : 角色
  62.   #     x     : 描画目标 X 坐标
  63.   #     y     : 描画目标 Y 坐标
  64.   #     width : 描画目标的宽
  65.   #--------------------------------------------------------------------------
  66.   def draw_actor_state(actor, x, y, width = 240)
  67.     state_size = 0
  68.     #buff_idx = 0
  69.     #debuff_idx = 0
  70.     for state in actor.states
  71.       # 图标数量超出宽度就中断循环
  72.       if state_size >= 24
  73.         break
  74.       end
  75.       # 此状态不带图标就跳过
  76.       if !ICON_STATE_IDS.include?(state)
  77.         next
  78.       end
  79.       bitmap = RPG::Cache.icon($data_states[state].animation_id.to_s)
  80.       if actor.states_turn[state] >= $data_states[state].hold_turn/2
  81.         opacity = 255
  82.       else
  83.         opacity = 100
  84.       end
  85.      #这里的图标大小默认是24x24,要改就改下面那个Rect.new(0, 0, 24, 24)
  86.      #if $data_states[state].name.include?"☆"
  87.      # if debuff_idx <= 5
  88.      #  self.contents.blt(x + 24 * debuff_idx, y + 56, bitmap, Rect.new(0, 0, 24, 24), opacity)
  89.      # else
  90.      #  self.contents.blt(x + 24 * (debuff_idx-5), y +88, bitmap, Rect.new(0, 0, 24, 24), opacity)
  91.      # end
  92.      # debuff_idx += 1
  93.      #else
  94.      # if  buff_idx <= 5
  95.      # self.contents.blt(x + 24 * buff_idx, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  96.      # else
  97.      # self.contents.blt(x + 24 * (buff_idx-5), y + 30, bitmap, Rect.new(0, 0, 24, 24), opacity)
  98.      #end
  99.      # buff_idx += 1
  100.      #end
  101.       if state_size <= 5
  102.        self.contents.blt(x+24 * state_size, y+4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  103.       else
  104.        self.contents.blt(x+24 * (state_size-5), y+4+30, bitmap, Rect.new(0, 0, 24, 24), opacity)
  105.       end
  106.       state_size += 1
  107.     end
  108.   end
  109. end
  110. #==============================================================================
  111. # ■ Window_Help
  112. #------------------------------------------------------------------------------
  113. #  特技及物品的说明、角色的状态显示的窗口。
  114. #==============================================================================
  115. class Window_Help < Window_Base
  116.  
  117.   #--------------------------------------------------------------------------
  118.   # ● 设置敌人
  119.   #     enemy : 要显示名字和状态的敌人
  120.   #--------------------------------------------------------------------------
  121.   def set_enemy(enemy)
  122.     @text = ""
  123.     # 描绘敌人名字
  124.     set_text(enemy.name, 1)
  125.     # 描绘状态图标
  126.     state_size = 0
  127.     for state in enemy.states
  128.       # 图标数量超出宽度就中断循环
  129.       if state_size >= 10
  130.       break
  131.       end
  132.       #此状态不带图标就跳过
  133.       #if !ICON_STATE_IDS.include?(state)
  134.       #next
  135.       #end
  136.       #bitmap = RPG::Cache.icon($data_states[state].animation_id.to_s)
  137.       #if enemy.states_turn[state] >= $data_states[state].hold_turn/2
  138.       #opacity = 255
  139.       #else        
  140.       #opacity = 100
  141.       #end
  142.       #if state_size <= 5
  143.       # self.contents.blt(64+24 * state_size, 64, bitmap, Rect.new(0, 0, 24, 24), opacity)
  144.       #else
  145.       # self.contents.blt(64+24 * (state_size-5), 64+30, bitmap, Rect.new(0, 0, 24, 24), opacity)
  146.       #end
  147.       #state_size += 1
  148.  
  149.       @text +=" "
  150.       if $data_states[state].id < 400 or ($data_states[state].id > 800 && $data_states[state].id < 900)
  151.       @text += $data_states[state].name.to_s
  152.       end
  153.       @text +=" "
  154.      end  # of for
  155.    set_text(@text, 0)
  156.  
  157.  
  158. #========================================================================
  159.  
  160.   end
  161. end
  162. class Game_Battler
  163.   attr_reader :states_turn       # 声明状态剩余回合
  164. end
  165. #==============================================================================
  166. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  167. # 欢迎访问[url]www.66RPG.com[/url]
  168. # 梦想世界,在你手中
  169. #==============================================================================



我把这个问题整合到新开的一个默认工程里了,脚本编辑器里面main上面的“脚下显示HPSP”、“图标显示状态”就是那个状态图标代码,
大家用数据库队伍里的“测试战斗_火狼”测试一下就清楚啦,敌人火狼设定的是只会普通攻击,然后其被附加的状态图标就一直不会消失了,但是敌人火狼被设定为技能攻击时期被附加的状态图标则会正常消失:

还请大家指点一二,多谢了!


敌人普通攻击后状态图标不消失.rar

238.49 KB, 下载次数: 10

Lv5.捕梦者

梦石
24
星屑
7017
在线时间
247 小时
注册时间
2020-12-4
帖子
306

极短24获奖极短23获奖极短22获奖

2
发表于 2022-8-11 16:35:53 | 只看该作者
hmmmmm......看这描述,那种神奇的现象已经把问题关键引出了:
应该是 基本行动 与 特技行动 的差异,导致了状态显示出现了不同的结果
而这种问题只是显示问题,而不会影响怪物的正常行动(状态实际已经消失了)
所以盲猜,特技行动能够引起状态显示刷新,而基本行动不行

Scene Battle4 中 对普攻行动和技能行动采用的是不同的方法
-- 生成基本行动结果:make_basic_action_result
-- 生成特技行动结果:make_skill_action_result

会发现特技行动比基本行动多一个     
    # 刷新状态窗口
    @status_window.refresh

把普攻对应步骤也加上一个@status_window.refresh 或许能够解决这个问题?


另外,会喷水的火狼真的很可爱有木有!


回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
9128
在线时间
463 小时
注册时间
2015-5-8
帖子
865
3
 楼主| 发表于 2022-8-12 11:14:32 | 只看该作者
纯属小虫 发表于 2022-8-11 16:35
hmmmmm......看这描述,那种神奇的现象已经把问题关键引出了:
应该是 基本行动 与 特技行动 的差异,导致 ...

亲测加个@status_window.refresh也没用。。。

点评

emmmm......那可能是Sprite类里面的问题...啊,最不熟悉的类,我再研究研究 QAQ  发表于 2022-8-12 12:31
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
6483
在线时间
119 小时
注册时间
2020-1-8
帖子
234
4
发表于 2022-8-12 12:47:42 | 只看该作者
问题如图所示
你把敌人的状态挂在描绘名字的里面……害我看了半天的描绘状态也没看出问题
描绘敌人HPSP是有条件刷新(HP或SP 不同)
你工程测试附加眩晕状态后(其他状态附加无图片……),
可能就一直防御消耗回合,对敌人没伤害,导致敌人HPSP精灵位图没有“刷新”,状态图标就一直在。
敌人使用技能消耗了SP,符合了“刷新”条件

监测 敌人的状态数组 是否发生变化,然后描绘状态。
或者改为 玩家 那样实时刷新。

temp.jpg (82.02 KB, 下载次数: 10)

temp.jpg

点评

就是不设条件……不考虑效率的话,你可以把图上的 if 语句(以及对应end) 注释掉  发表于 2022-8-17 10:25
大神请问下哪里可以改为像玩家那样实时刷新呢?  发表于 2022-8-14 03:23

评分

参与人数 2星屑 +50 +1 收起 理由
RyanBern + 50 认可答案
taeckle + 1 多谢大神指点!

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-25 00:51

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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