Project1

标题: 敌人的状态显示!! [打印本页]

作者: neverstop    时间: 2014-7-30 11:22
标题: 敌人的状态显示!!
最近弄了很多很多的奇葩技能,so 奇葩的状态也很会出现。

但是当状态赋予敌人时,只是出现一会就消失了。。而且窗口上面的提示文字转瞬即逝啊。。。

所以有没有什么方法,能让敌人身上的所有状态显示在其脚底下{:2_282:} (虽然很拥挤)

麻烦啦~{:2_249:}
作者: taroxd    时间: 2014-7-30 11:52
本帖最后由 taroxd 于 2014-7-30 11:55 编辑

https://rpg.blue/forum.php?mod=r ... 971&pid=2506651

给个思路,懒得实现。Window_Variable 的定义在群组的基础设置里面。
区别只在于显示的内容是血条还是状态而已。
作者: neverstop    时间: 2014-8-4 10:26
浮起来~~~~
作者: 3106345123    时间: 2014-8-4 10:49
状态动画脚本
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - State Animations v1.00
  4. # -- Last Updated: 2011.12.23
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================

  9. $imported = {} if $imported.nil?
  10. $imported["YEA-StateAnimations"] = true

  11. #==============================================================================
  12. # ▼ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2011.12.23 - Started Script and Finished.
  15. #
  16. #==============================================================================
  17. # ▼ Introduction
  18. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  19. # A missing feature from RPG Maker XP. Status effects had animations replaying
  20. # on them constantly to indicate that a user was affected by a state. Only the
  21. # state with the highest priority and possesses an animation will be played.
  22. #
  23. #==============================================================================
  24. # ▼ Instructions
  25. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  26. # To install this script, open up your script editor and copy/paste this script
  27. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  28. #
  29. # -----------------------------------------------------------------------------
  30. # State Notetags - These notetags go in the states notebox in the database.
  31. # -----------------------------------------------------------------------------
  32. # <state ani: x>
  33. # Causes the status effect to play battle animation x repeatedly on the battler
  34. # if the battler is affected by this state and if this state is the highest
  35. # priority state with an animation.
  36. #
  37. #==============================================================================
  38. # ▼ Compatibility
  39. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  40. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  41. # it will run with RPG Maker VX without adjusting.
  42. #
  43. #==============================================================================

  44. module YEA
  45.   module STATE_ANIMATION
  46.    
  47.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  48.     # - Adjust the state animation settings here. -
  49.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  50.     # These settings decide whether or not state animations will cause the
  51.     # screen to flash, play sound effects, and what kinds of zoom levels will
  52.     # be used on actors affected by states with animations.
  53.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  54.     PLAY_SOUND = false      # Play sounds for state animations?
  55.     PLAY_FLASH = false      # Use screen flash for state animations?
  56.    
  57.     PLAY_ACTOR = true       # Play animations on the actor?
  58.     ACTOR_ZOOM = 0.25       # Zoom level for animations on actors.
  59.    
  60.   end # STATE_ANIMATION
  61. end # YEA

  62. #==============================================================================
  63. # ▼ Editting anything past this point may potentially result in causing
  64. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  65. # halitosis so edit at your own risk.
  66. #==============================================================================

  67. module YEA
  68.   module REGEXP
  69.   module STATE
  70.    
  71.     STATEANI = /<(?:STATE_ANIMATION|state ani|animation|ani):[ ](\d+)>/i
  72.    
  73.   end # STATE
  74.   end # REGEXP
  75. end # YEA

  76. #==============================================================================
  77. # ■ DataManager
  78. #==============================================================================

  79. module DataManager
  80.   
  81.   #--------------------------------------------------------------------------
  82.   # alias method: load_database
  83.   #--------------------------------------------------------------------------
  84.   class <<self; alias load_database_sani load_database; end
  85.   def self.load_database
  86.     load_database_sani
  87.     load_notetags_sani
  88.   end
  89.   
  90.   #--------------------------------------------------------------------------
  91.   # new method: load_notetags_sani
  92.   #--------------------------------------------------------------------------
  93.   def self.load_notetags_sani
  94.     for state in $data_states
  95.       next if state.nil?
  96.       state.load_notetags_sani
  97.     end
  98.   end
  99.   
  100. end # DataManager

  101. #==============================================================================
  102. # ■ RPG::State
  103. #==============================================================================

  104. class RPG::State < RPG::BaseItem
  105.   
  106.   #--------------------------------------------------------------------------
  107.   # public instance variables
  108.   #--------------------------------------------------------------------------
  109.   attr_accessor :state_animation
  110.   
  111.   #--------------------------------------------------------------------------
  112.   # common cache: load_notetags_sani
  113.   #--------------------------------------------------------------------------
  114.   def load_notetags_sani
  115.     @state_animation = 0
  116.     #---
  117.     self.note.split(/[\r\n]+/).each { |line|
  118.       case line
  119.       #---
  120.       when YEA::REGEXP::STATE::STATEANI
  121.         @state_animation = $1.to_i
  122.       end
  123.     } # self.note.split
  124.     #---
  125.   end
  126.   
  127. end # RPG::State

  128. #==============================================================================
  129. # ■ Sprite_Battler
  130. #==============================================================================

  131. class Sprite_Battler < Sprite_Base
  132.   
  133.   #--------------------------------------------------------------------------
  134.   # class variables
  135.   #--------------------------------------------------------------------------
  136.   @@state_ani_checker = []
  137.   @@state_ani_spr_checker = []
  138.   @@state_ani_reference_count = {}
  139.   
  140.   #--------------------------------------------------------------------------
  141.   # alias method: initialize
  142.   #--------------------------------------------------------------------------
  143.   alias sprite_battler_initialize_sani initialize
  144.   def initialize(viewport, battler = nil)
  145.     sprite_battler_initialize_sani(viewport, battler)
  146.     @state_ani_duration = 0
  147.   end
  148.   
  149.   #--------------------------------------------------------------------------
  150.   # alias method: dispose
  151.   #--------------------------------------------------------------------------
  152.   alias sprite_battler_dispose_sani dispose
  153.   def dispose
  154.     dispose_state_animation
  155.     sprite_battler_dispose_sani
  156.   end
  157.   
  158.   #--------------------------------------------------------------------------
  159.   # alias method: setup_new_effect
  160.   #--------------------------------------------------------------------------
  161.   alias sprite_battler_setup_new_effect_sani setup_new_effect
  162.   def setup_new_effect
  163.     sprite_battler_setup_new_effect_sani
  164.     setup_state_ani_effect
  165.   end
  166.   
  167.   #--------------------------------------------------------------------------
  168.   # new method: setup_state_ani_effect
  169.   #--------------------------------------------------------------------------
  170.   def setup_state_ani_effect
  171.     return if @battler.state_animation_id.nil?
  172.     if @battler.state_animation_id == 0
  173.       dispose_state_animation
  174.     else
  175.       animation = $data_animations[@battler.state_animation_id]
  176.       start_state_animation(animation)
  177.     end
  178.   end
  179.   
  180.   #--------------------------------------------------------------------------
  181.   # alias method: update
  182.   #--------------------------------------------------------------------------
  183.   alias sprite_battler_update_sani update
  184.   def update
  185.     sprite_battler_update_sani
  186.     update_state_animations
  187.   end
  188.   
  189.   #--------------------------------------------------------------------------
  190.   # new method: update_state_animations
  191.   #--------------------------------------------------------------------------
  192.   def update_state_animations
  193.     update_state_animation
  194.     @@state_ani_checker.clear
  195.     @@state_ani_spr_checker.clear
  196.   end
  197.   
  198.   #--------------------------------------------------------------------------
  199.   # new method: state_animation?
  200.   #--------------------------------------------------------------------------
  201.   def state_animation?
  202.     return !@state_animation.nil?
  203.   end
  204.   
  205.   #--------------------------------------------------------------------------
  206.   # new method: start_state_animation
  207.   #--------------------------------------------------------------------------
  208.   def start_state_animation(animation, mirror = false)
  209.     return if !@state_animation.nil? && @state_animation.id == animation.id
  210.     dispose_state_animation
  211.     @state_animation = animation
  212.     return if @state_animation.nil?
  213.     @state_ani_mirror = mirror
  214.     set_animation_rate
  215.     @state_ani_duration = @state_animation.frame_max * @ani_rate + 1
  216.     load_state_animation_bitmap
  217.     make_state_animation_sprites
  218.     set_state_animation_origin
  219.   end
  220.   
  221.   #--------------------------------------------------------------------------
  222.   # new method: load_state_animation_bitmap
  223.   #--------------------------------------------------------------------------
  224.   def load_state_animation_bitmap
  225.     animation1_name = @state_animation.animation1_name
  226.     animation1_hue = @state_animation.animation1_hue
  227.     animation2_name = @state_animation.animation2_name
  228.     animation2_hue = @state_animation.animation2_hue
  229.     @state_ani_bitmap1 = Cache.animation(animation1_name, animation1_hue)
  230.     @state_ani_bitmap2 = Cache.animation(animation2_name, animation2_hue)
  231.     if @@state_ani_reference_count.include?(@state_ani_bitmap1)
  232.       @@state_ani_reference_count[@state_ani_bitmap1] += 1
  233.     else
  234.       @@state_ani_reference_count[@state_ani_bitmap1] = 1
  235.     end
  236.     if @@state_ani_reference_count.include?(@ani_bitmap2)
  237.       @@state_ani_reference_count[@state_ani_bitmap2] += 1
  238.     else
  239.       @@state_ani_reference_count[@state_ani_bitmap2] = 1
  240.     end
  241.     Graphics.frame_reset
  242.   end
  243.   
  244.   #--------------------------------------------------------------------------
  245.   # new method: make_state_animation_sprites
  246.   #--------------------------------------------------------------------------
  247.   def make_state_animation_sprites
  248.     @state_ani_sprites = []
  249.     if @use_sprite && !@@state_ani_spr_checker.include?(@state_animation)
  250.       16.times do
  251.         sprite = ::Sprite.new(viewport)
  252.         sprite.visible = false
  253.         @state_ani_sprites.push(sprite)
  254.       end
  255.       if @state_animation.position == 3
  256.         @@state_ani_spr_checker.push(@animation)
  257.       end
  258.     end
  259.     @state_ani_duplicated = @@state_ani_checker.include?(@state_animation)
  260.     if !@state_ani_duplicated && @state_animation.position == 3
  261.       @@state_ani_checker.push(@state_animation)
  262.     end
  263.   end
  264.   
  265.   #--------------------------------------------------------------------------
  266.   # new method: set_state_animation_origin
  267.   #--------------------------------------------------------------------------
  268.   def set_state_animation_origin
  269.     if @state_animation.position == 3
  270.       if viewport == nil
  271.         @state_ani_ox = Graphics.width / 2
  272.         @state_ani_oy = Graphics.height / 2
  273.       else
  274.         @state_ani_ox = viewport.rect.width / 2
  275.         @state_ani_oy = viewport.rect.height / 2
  276.       end
  277.     else
  278.       @state_ani_ox = x - ox + width / 2
  279.       @state_ani_oy = y - oy + height / 2
  280.       if @state_animation.position == 0
  281.         @state_ani_oy -= height / 2
  282.       elsif @state_animation.position == 2
  283.         @state_ani_oy += height / 2
  284.       end
  285.     end
  286.   end
  287.   
  288.   #--------------------------------------------------------------------------
  289.   # new method: dispose_state_animation
  290.   #--------------------------------------------------------------------------
  291.   def dispose_state_animation
  292.     if @state_ani_bitmap1
  293.       @@state_ani_reference_count[@state_ani_bitmap1] -= 1
  294.       if @@state_ani_reference_count[@state_ani_bitmap1] == 0
  295.         @state_ani_bitmap1.dispose
  296.       end
  297.     end
  298.     if @state_ani_bitmap2
  299.       @@state_ani_reference_count[@state_ani_bitmap2] -= 1
  300.       if @@state_ani_reference_count[@state_ani_bitmap2] == 0
  301.         @state_ani_bitmap2.dispose
  302.       end
  303.     end
  304.     if @state_ani_sprites
  305.       @state_ani_sprites.each {|sprite| sprite.dispose }
  306.       @state_ani_sprites = nil
  307.       @state_animation = nil
  308.     end
  309.     @state_ani_bitmap1 = nil
  310.     @state_ani_bitmap2 = nil
  311.   end
  312.   
  313.   #--------------------------------------------------------------------------
  314.   # new method: update_state_animation
  315.   #--------------------------------------------------------------------------
  316.   def update_state_animation
  317.     return unless state_animation?
  318.     @state_ani_duration -= 1
  319.     if @state_ani_duration % @ani_rate == 0
  320.       if @state_ani_duration > 0
  321.         @state_frame_index = @state_animation.frame_max
  322.         change = (@state_ani_duration + @ani_rate - 1) / @ani_rate
  323.         @state_frame_index -= change
  324.         @state_animation.timings.each do |timing|
  325.           next unless timing.frame == @state_frame_index
  326.           state_animation_process_timing(timing)
  327.         end
  328.       else
  329.         @state_ani_duration = @state_animation.frame_max * @ani_rate + 1
  330.       end
  331.     end
  332.     return if @state_frame_index.nil?
  333.     state_animation_set_sprites(@state_animation.frames[@state_frame_index])
  334.     set_state_animation_origin
  335.   end
  336.   
  337.   #--------------------------------------------------------------------------
  338.   # new method: end_state_animation
  339.   #--------------------------------------------------------------------------
  340.   def end_state_animation
  341.     dispose_state_animation
  342.   end
  343.   
  344.   #--------------------------------------------------------------------------
  345.   # new method: state_animation_set_sprites
  346.   #--------------------------------------------------------------------------
  347.   def state_animation_set_sprites(frame)
  348.     return if @state_animation.nil?
  349.     return if frame.nil?
  350.     cell_data = frame.cell_data
  351.     @state_ani_sprites.each_with_index do |sprite, i|
  352.       next unless sprite
  353.       pattern = cell_data[i, 0]
  354.       if !pattern || pattern < 0
  355.         sprite.visible = false
  356.         next
  357.       end
  358.       sprite.bitmap = pattern < 100 ? @state_ani_bitmap1 : @state_ani_bitmap2
  359.       sprite.visible = true
  360.       sprite.src_rect.set(pattern % 5 * 192,
  361.         pattern % 100 / 5 * 192, 192, 192)
  362.       if @state_ani_mirror
  363.         sprite.x = @state_ani_ox - cell_data[i, 1]
  364.         sprite.y = @state_ani_oy + cell_data[i, 2]
  365.         sprite.angle = (360 - cell_data[i, 4])
  366.         sprite.mirror = (cell_data[i, 5] == 0)
  367.       else
  368.         sprite.x = @state_ani_ox + cell_data[i, 1]
  369.         sprite.y = @state_ani_oy + cell_data[i, 2]
  370.         sprite.angle = cell_data[i, 4]
  371.         sprite.mirror = (cell_data[i, 5] == 1)
  372.       end
  373.       sprite.z = self.z + 250 + i
  374.       sprite.ox = 96
  375.       sprite.oy = 96
  376.       sprite.zoom_x = cell_data[i, 3] / 100.0
  377.       sprite.zoom_y = cell_data[i, 3] / 100.0
  378.       if @battler.actor?
  379.         zoom = YEA::STATE_ANIMATION::ACTOR_ZOOM
  380.         sprite.zoom_x *= zoom
  381.         sprite.zoom_y *= zoom
  382.       end
  383.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  384.       sprite.blend_type = cell_data[i, 7]
  385.     end
  386.   end
  387.   
  388.   #--------------------------------------------------------------------------
  389.   # new method: state_animation_process_timing
  390.   #--------------------------------------------------------------------------
  391.   def state_animation_process_timing(timing)
  392.     timing.se.play if YEA::STATE_ANIMATION::PLAY_SOUND
  393.     case timing.flash_scope
  394.     when 1
  395.       self.flash(timing.flash_color, timing.flash_duration * @ani_rate)
  396.     when 2
  397.       return unless YEA::STATE_ANIMATION::PLAY_FLASH
  398.       if viewport && !@state_ani_duplicated
  399.         flash_amount = timing.flash_duration * @ani_rate
  400.         viewport.flash(timing.flash_color, flash_amount)
  401.       end
  402.     when 3
  403.       self.flash(nil, timing.flash_duration * @ani_rate)
  404.     end
  405.   end
  406.   
  407. end # Sprite_Battler

  408. #==============================================================================
  409. # ■ Game_BattlerBase
  410. #==============================================================================

  411. class Game_BattlerBase
  412.   
  413.   #--------------------------------------------------------------------------
  414.   # public instance variables
  415.   #--------------------------------------------------------------------------
  416.   attr_accessor :state_animation_id
  417.   
  418.   #--------------------------------------------------------------------------
  419.   # alias method: refresh
  420.   #--------------------------------------------------------------------------
  421.   alias game_battlerbase_refresh_sani refresh
  422.   def refresh
  423.     game_battlerbase_refresh_sani
  424.     reload_state_animation
  425.   end
  426.   
  427.   #--------------------------------------------------------------------------
  428.   # new method: reload_state_animation
  429.   #--------------------------------------------------------------------------
  430.   def reload_state_animation
  431.     @state_animation_id = 0
  432.     return if actor? && !YEA::STATE_ANIMATION::PLAY_ACTOR
  433.     for state in states
  434.       next unless state.state_animation > 0
  435.       @state_animation_id = state.state_animation
  436.       break
  437.     end
  438.   end
  439.   
  440. end # Game_BattlerBase

  441. #==============================================================================
  442. #
  443. # ▼ End of File
  444. #
  445. #==============================================================================
复制代码





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1