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

Project1

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

[已经解决] VA的状态求助

[复制链接]

Lv1.梦旅人

梦石
0
星屑
107
在线时间
123 小时
注册时间
2010-8-13
帖子
100
跳转到指定楼层
1
发表于 2012-3-10 16:15:37 手机端发表。 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
VA系统默认的状态没有动画,求解怎么显示。

Lv1.梦旅人

梦石
0
星屑
66
在线时间
140 小时
注册时间
2012-2-6
帖子
384
2
发表于 2012-3-10 17:58:34 | 只看该作者
本帖最后由 杂兵天下 于 2012-3-10 22:03 编辑

可以用一个YEA脚本也可以用后知后觉横版
RUBY 代码复制
  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.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-StateAnimations"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2011.12.23 - Started Script and Finished.
  17. #
  18. #==============================================================================
  19. # ▼ Introduction
  20. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  21. # A missing feature from RPG Maker XP. Status effects had animations replaying
  22. # on them constantly to indicate that a user was affected by a state. Only the
  23. # state with the highest priority and possesses an animation will be played.
  24. #
  25. #==============================================================================
  26. # ▼ Instructions
  27. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  28. # To install this script, open up your script editor and copy/paste this script
  29. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  30. #
  31. # -----------------------------------------------------------------------------
  32. # State Notetags - These notetags go in the states notebox in the database.
  33. # -----------------------------------------------------------------------------
  34. # <state ani: x>
  35. # Causes the status effect to play battle animation x repeatedly on the battler
  36. # if the battler is affected by this state and if this state is the highest
  37. # priority state with an animation.
  38. #
  39. #==============================================================================
  40. # ▼ Compatibility
  41. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  42. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  43. # it will run with RPG Maker VX without adjusting.
  44. #
  45. #==============================================================================
  46.  
  47. module YEA
  48.   module STATE_ANIMATION
  49.  
  50.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  51.     # - Adjust the state animation settings here. -
  52.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  53.     # These settings decide whether or not state animations will cause the
  54.     # screen to flash, play sound effects, and what kinds of zoom levels will
  55.     # be used on actors affected by states with animations.
  56.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  57.     PLAY_SOUND = false      # Play sounds for state animations?
  58.     PLAY_FLASH = false      # Use screen flash for state animations?
  59.  
  60.     PLAY_ACTOR = true       # Play animations on the actor?
  61.     ACTOR_ZOOM = 0.25       # Zoom level for animations on actors.
  62.  
  63.   end # STATE_ANIMATION
  64. end # YEA
  65.  
  66. #==============================================================================
  67. # ▼ Editting anything past this point may potentially result in causing
  68. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  69. # halitosis so edit at your own risk.
  70. #==============================================================================
  71.  
  72. module YEA
  73.   module REGEXP
  74.   module STATE
  75.  
  76.     STATEANI = /<(?:STATE_ANIMATION|state ani|animation|ani):[ ](\d+)>/i
  77.  
  78.   end # STATE
  79.   end # REGEXP
  80. end # YEA
  81.  
  82. #==============================================================================
  83. # ■ DataManager
  84. #==============================================================================
  85.  
  86. module DataManager
  87.  
  88.   #--------------------------------------------------------------------------
  89.   # alias method: load_database
  90.   #--------------------------------------------------------------------------
  91.   class <<self; alias load_database_sani load_database; end
  92.   def self.load_database
  93.     load_database_sani
  94.     load_notetags_sani
  95.   end
  96.  
  97.   #--------------------------------------------------------------------------
  98.   # new method: load_notetags_sani
  99.   #--------------------------------------------------------------------------
  100.   def self.load_notetags_sani
  101.     for state in $data_states
  102.       next if state.nil?
  103.       state.load_notetags_sani
  104.     end
  105.   end
  106.  
  107. end # DataManager
  108.  
  109. #==============================================================================
  110. # ■ RPG::State
  111. #==============================================================================
  112.  
  113. class RPG::State < RPG::BaseItem
  114.  
  115.   #--------------------------------------------------------------------------
  116.   # public instance variables
  117.   #--------------------------------------------------------------------------
  118.   attr_accessor :state_animation
  119.  
  120.   #--------------------------------------------------------------------------
  121.   # common cache: load_notetags_sani
  122.   #--------------------------------------------------------------------------
  123.   def load_notetags_sani
  124.     @state_animation = 0
  125.     #---
  126.     self.note.split(/[\r\n]+/).each { |line|
  127.       case line
  128.       #---
  129.       when YEA::REGEXP::STATE::STATEANI
  130.         @state_animation = $1.to_i
  131.       end
  132.     } # self.note.split
  133.     #---
  134.   end
  135.  
  136. end # RPG::State
  137.  
  138. #==============================================================================
  139. # ■ Sprite_Battler
  140. #==============================================================================
  141.  
  142. class Sprite_Battler < Sprite_Base
  143.  
  144.   #--------------------------------------------------------------------------
  145.   # class variables
  146.   #--------------------------------------------------------------------------
  147.   @@state_ani_checker = []
  148.   @@state_ani_spr_checker = []
  149.   @@state_ani_reference_count = {}
  150.  
  151.   #--------------------------------------------------------------------------
  152.   # alias method: initialize
  153.   #--------------------------------------------------------------------------
  154.   alias sprite_battler_initialize_sani initialize
  155.   def initialize(viewport, battler = nil)
  156.     sprite_battler_initialize_sani(viewport, battler)
  157.     @state_ani_duration = 0
  158.   end
  159.  
  160.   #--------------------------------------------------------------------------
  161.   # alias method: dispose
  162.   #--------------------------------------------------------------------------
  163.   alias sprite_battler_dispose_sani dispose
  164.   def dispose
  165.     dispose_state_animation
  166.     sprite_battler_dispose_sani
  167.   end
  168.  
  169.   #--------------------------------------------------------------------------
  170.   # alias method: setup_new_effect
  171.   #--------------------------------------------------------------------------
  172.   alias sprite_battler_setup_new_effect_sani setup_new_effect
  173.   def setup_new_effect
  174.     sprite_battler_setup_new_effect_sani
  175.     setup_state_ani_effect
  176.   end
  177.  
  178.   #--------------------------------------------------------------------------
  179.   # new method: setup_state_ani_effect
  180.   #--------------------------------------------------------------------------
  181.   def setup_state_ani_effect
  182.     return if @battler.state_animation_id.nil?
  183.     if @battler.state_animation_id == 0
  184.       dispose_state_animation
  185.     else
  186.       animation = $data_animations[@battler.state_animation_id]
  187.       start_state_animation(animation)
  188.     end
  189.   end
  190.  
  191.   #--------------------------------------------------------------------------
  192.   # alias method: update
  193.   #--------------------------------------------------------------------------
  194.   alias sprite_battler_update_sani update
  195.   def update
  196.     sprite_battler_update_sani
  197.     update_state_animations
  198.   end
  199.  
  200.   #--------------------------------------------------------------------------
  201.   # new method: update_state_animations
  202.   #--------------------------------------------------------------------------
  203.   def update_state_animations
  204.     update_state_animation
  205.     @@state_ani_checker.clear
  206.     @@state_ani_spr_checker.clear
  207.   end
  208.  
  209.   #--------------------------------------------------------------------------
  210.   # new method: state_animation?
  211.   #--------------------------------------------------------------------------
  212.   def state_animation?
  213.     return !@state_animation.nil?
  214.   end
  215.  
  216.   #--------------------------------------------------------------------------
  217.   # new method: start_state_animation
  218.   #--------------------------------------------------------------------------
  219.   def start_state_animation(animation, mirror = false)
  220.     return if !@state_animation.nil? && @state_animation.id == animation.id
  221.     dispose_state_animation
  222.     @state_animation = animation
  223.     return if @state_animation.nil?
  224.     @state_ani_mirror = mirror
  225.     set_animation_rate
  226.     @state_ani_duration = @state_animation.frame_max * @ani_rate + 1
  227.     load_state_animation_bitmap
  228.     make_state_animation_sprites
  229.     set_state_animation_origin
  230.   end
  231.  
  232.   #--------------------------------------------------------------------------
  233.   # new method: load_state_animation_bitmap
  234.   #--------------------------------------------------------------------------
  235.   def load_state_animation_bitmap
  236.     animation1_name = @state_animation.animation1_name
  237.     animation1_hue = @state_animation.animation1_hue
  238.     animation2_name = @state_animation.animation2_name
  239.     animation2_hue = @state_animation.animation2_hue
  240.     @state_ani_bitmap1 = Cache.animation(animation1_name, animation1_hue)
  241.     @state_ani_bitmap2 = Cache.animation(animation2_name, animation2_hue)
  242.     if @@state_ani_reference_count.include?(@state_ani_bitmap1)
  243.       @@state_ani_reference_count[@state_ani_bitmap1] += 1
  244.     else
  245.       @@state_ani_reference_count[@state_ani_bitmap1] = 1
  246.     end
  247.     if @@state_ani_reference_count.include?(@ani_bitmap2)
  248.       @@state_ani_reference_count[@state_ani_bitmap2] += 1
  249.     else
  250.       @@state_ani_reference_count[@state_ani_bitmap2] = 1
  251.     end
  252.     Graphics.frame_reset
  253.   end
  254.  
  255.   #--------------------------------------------------------------------------
  256.   # new method: make_state_animation_sprites
  257.   #--------------------------------------------------------------------------
  258.   def make_state_animation_sprites
  259.     @state_ani_sprites = []
  260.     if @use_sprite && !@@state_ani_spr_checker.include?(@state_animation)
  261.       16.times do
  262.         sprite = ::Sprite.new(viewport)
  263.         sprite.visible = false
  264.         @state_ani_sprites.push(sprite)
  265.       end
  266.       if @state_animation.position == 3
  267.         @@state_ani_spr_checker.push(@animation)
  268.       end
  269.     end
  270.     @state_ani_duplicated = @@state_ani_checker.include?(@state_animation)
  271.     if !@state_ani_duplicated && @state_animation.position == 3
  272.       @@state_ani_checker.push(@state_animation)
  273.     end
  274.   end
  275.  
  276.   #--------------------------------------------------------------------------
  277.   # new method: set_state_animation_origin
  278.   #--------------------------------------------------------------------------
  279.   def set_state_animation_origin
  280.     if @state_animation.position == 3
  281.       if viewport == nil
  282.         @state_ani_ox = Graphics.width / 2
  283.         @state_ani_oy = Graphics.height / 2
  284.       else
  285.         @state_ani_ox = viewport.rect.width / 2
  286.         @state_ani_oy = viewport.rect.height / 2
  287.       end
  288.     else
  289.       @state_ani_ox = x - ox + width / 2
  290.       @state_ani_oy = y - oy + height / 2
  291.       if @state_animation.position == 0
  292.         @state_ani_oy -= height / 2
  293.       elsif @state_animation.position == 2
  294.         @state_ani_oy += height / 2
  295.       end
  296.     end
  297.   end
  298.  
  299.   #--------------------------------------------------------------------------
  300.   # new method: dispose_state_animation
  301.   #--------------------------------------------------------------------------
  302.   def dispose_state_animation
  303.     if @state_ani_bitmap1
  304.       @@state_ani_reference_count[@state_ani_bitmap1] -= 1
  305.       if @@state_ani_reference_count[@state_ani_bitmap1] == 0
  306.         @state_ani_bitmap1.dispose
  307.       end
  308.     end
  309.     if @state_ani_bitmap2
  310.       @@state_ani_reference_count[@state_ani_bitmap2] -= 1
  311.       if @@state_ani_reference_count[@state_ani_bitmap2] == 0
  312.         @state_ani_bitmap2.dispose
  313.       end
  314.     end
  315.     if @state_ani_sprites
  316.       @state_ani_sprites.each {|sprite| sprite.dispose }
  317.       @state_ani_sprites = nil
  318.       @state_animation = nil
  319.     end
  320.     @state_ani_bitmap1 = nil
  321.     @state_ani_bitmap2 = nil
  322.   end
  323.  
  324.   #--------------------------------------------------------------------------
  325.   # new method: update_state_animation
  326.   #--------------------------------------------------------------------------
  327.   def update_state_animation
  328.     return unless state_animation?
  329.     @state_ani_duration -= 1
  330.     if @state_ani_duration % @ani_rate == 0
  331.       if @state_ani_duration > 0
  332.         @state_frame_index = @state_animation.frame_max
  333.         change = (@state_ani_duration + @ani_rate - 1) / @ani_rate
  334.         @state_frame_index -= change
  335.         @state_animation.timings.each do |timing|
  336.           next unless timing.frame == @state_frame_index
  337.           state_animation_process_timing(timing)
  338.         end
  339.       else
  340.         @state_ani_duration = @state_animation.frame_max * @ani_rate + 1
  341.       end
  342.     end
  343.     return if @state_frame_index.nil?
  344.     state_animation_set_sprites(@state_animation.frames[@state_frame_index])
  345.     set_state_animation_origin
  346.   end
  347.  
  348.   #--------------------------------------------------------------------------
  349.   # new method: end_state_animation
  350.   #--------------------------------------------------------------------------
  351.   def end_state_animation
  352.     dispose_state_animation
  353.   end
  354.  
  355.   #--------------------------------------------------------------------------
  356.   # new method: state_animation_set_sprites
  357.   #--------------------------------------------------------------------------
  358.   def state_animation_set_sprites(frame)
  359.     return if @state_animation.nil?
  360.     return if frame.nil?
  361.     cell_data = frame.cell_data
  362.     @state_ani_sprites.each_with_index do |sprite, i|
  363.       next unless sprite
  364.       pattern = cell_data[i, 0]
  365.       if !pattern || pattern < 0
  366.         sprite.visible = false
  367.         next
  368.       end
  369.       sprite.bitmap = pattern < 100 ? @state_ani_bitmap1 : @state_ani_bitmap2
  370.       sprite.visible = true
  371.       sprite.src_rect.set(pattern % 5 * 192,
  372.         pattern % 100 / 5 * 192, 192, 192)
  373.       if @state_ani_mirror
  374.         sprite.x = @state_ani_ox - cell_data[i, 1]
  375.         sprite.y = @state_ani_oy + cell_data[i, 2]
  376.         sprite.angle = (360 - cell_data[i, 4])
  377.         sprite.mirror = (cell_data[i, 5] == 0)
  378.       else
  379.         sprite.x = @state_ani_ox + cell_data[i, 1]
  380.         sprite.y = @state_ani_oy + cell_data[i, 2]
  381.         sprite.angle = cell_data[i, 4]
  382.         sprite.mirror = (cell_data[i, 5] == 1)
  383.       end
  384.       sprite.z = self.z + 250 + i
  385.       sprite.ox = 96
  386.       sprite.oy = 96
  387.       sprite.zoom_x = cell_data[i, 3] / 100.0
  388.       sprite.zoom_y = cell_data[i, 3] / 100.0
  389.       if @battler.actor?
  390.         zoom = YEA::STATE_ANIMATION::ACTOR_ZOOM
  391.         sprite.zoom_x *= zoom
  392.         sprite.zoom_y *= zoom
  393.       end
  394.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  395.       sprite.blend_type = cell_data[i, 7]
  396.     end
  397.   end
  398.  
  399.   #--------------------------------------------------------------------------
  400.   # new method: state_animation_process_timing
  401.   #--------------------------------------------------------------------------
  402.   def state_animation_process_timing(timing)
  403.     timing.se.play if YEA::STATE_ANIMATION::PLAY_SOUND
  404.     case timing.flash_scope
  405.     when 1
  406.       self.flash(timing.flash_color, timing.flash_duration * @ani_rate)
  407.     when 2
  408.       return unless YEA::STATE_ANIMATION::PLAY_FLASH
  409.       if viewport && !@state_ani_duplicated
  410.         flash_amount = timing.flash_duration * @ani_rate
  411.         viewport.flash(timing.flash_color, flash_amount)
  412.       end
  413.     when 3
  414.       self.flash(nil, timing.flash_duration * @ani_rate)
  415.     end
  416.   end
  417.  
  418. end # Sprite_Battler
  419.  
  420. #==============================================================================
  421. # ■ Game_BattlerBase
  422. #==============================================================================
  423.  
  424. class Game_BattlerBase
  425.  
  426.   #--------------------------------------------------------------------------
  427.   # public instance variables
  428.   #--------------------------------------------------------------------------
  429.   attr_accessor :state_animation_id
  430.  
  431.   #--------------------------------------------------------------------------
  432.   # alias method: refresh
  433.   #--------------------------------------------------------------------------
  434.   alias game_battlerbase_refresh_sani refresh
  435.   def refresh
  436.     game_battlerbase_refresh_sani
  437.     reload_state_animation
  438.   end
  439.  
  440.   #--------------------------------------------------------------------------
  441.   # new method: reload_state_animation
  442.   #--------------------------------------------------------------------------
  443.   def reload_state_animation
  444.     @state_animation_id = 0
  445.     return if actor? && !YEA::STATE_ANIMATION::PLAY_ACTOR
  446.     for state in states
  447.       next unless state.state_animation > 0
  448.       @state_animation_id = state.state_animation
  449.       break
  450.     end
  451.   end
  452.  
  453. end # Game_BattlerBase
  454.  
  455. #==============================================================================
  456. #
  457. # ▼ End of File
  458. #
  459. #==============================================================================
签名是什么?可以吃么?
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-22 16:47

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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