标题: 脚本使用问题请教大神 [打印本页] 作者: 够爱 时间: 2018-3-24 02:01 标题: 脚本使用问题请教大神 我下载了些范例 里面的脚本在范例中可以使用 可是弄到自己的游戏中却不能实现 有没有大神帮忙看下怎么回事作者: 够爱 时间: 2018-3-24 02:02
#==============================================================================
#
# �� Yanfly Engine Ace - State Animations v1.01
# -- Last Updated: 2014.03.22
# -- Level: Normal 在状态栏里备注显示的动画: <state ani: X>
# -- Requires: n/a
# -- Special Thanks:
# SoulPour777 for the Bug Fix for V1.01
#==============================================================================
$imported = {} if $imported.nil?
$imported["YEA-StateAnimations"] = true
#==============================================================================
# �� Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2014.03.22 - Some of the animations have been using the same reference count,
# which results to cancelling the animation.
# 2011.12.23 - Started Script and Finished.
#
#==============================================================================
# �� Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# A missing feature from RPG Maker XP. Status effects had animations replaying
# on them constantly to indicate that a user was affected by a state. Only the
# state with the highest priority and possesses an animation will be played.
#
#==============================================================================
# �� Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below �� Materials/�f�� but above �� Main. Remember to save.
#
# -----------------------------------------------------------------------------
# State Notetags - These notetags go in the states notebox in the database.
# -----------------------------------------------------------------------------
#
# Causes the status effect to play battle animation x repeatedly on the battler
# if the battler is affected by this state and if this state is the highest
# priority state with an animation.
#
#==============================================================================
# �� Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================
module YEA
module STATE_ANIMATION
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Adjust the state animation settings here. -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# These settings decide whether or not state animations will cause the
# screen to flash, play sound effects, and what kinds of zoom levels will
# be used on actors affected by states with animations.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
PLAY_SOUND = true # 播放状态动画的声音?
PLAY_FLASH = false # 使用屏幕闪光的状态动画?
#==============================================================================
# �� Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================
#--------------------------------------------------------------------------
# alias method: load_database
#--------------------------------------------------------------------------
class <<self; alias load_database_sani load_database; end
def self.load_database
load_database_sani
load_notetags_sani
end
#--------------------------------------------------------------------------
# new method: load_notetags_sani
#--------------------------------------------------------------------------
def self.load_notetags_sani
for state in $data_states
next if state.nil?
state.load_notetags_sani
end
end
end
# DataManager
#--------------------------------------------------------------------------
# alias method: initialize
#--------------------------------------------------------------------------
alias sprite_battler_initialize_sani initialize
def initialize(viewport, battler = nil)
sprite_battler_initialize_sani(viewport, battler)
@state_ani_duration = 0
end
#--------------------------------------------------------------------------
# alias method: dispose
#--------------------------------------------------------------------------
alias sprite_battler_dispose_sani dispose
def dispose
dispose_state_animation
sprite_battler_dispose_sani
end
#==============================================================================
#
# alias method: setup_new_effect
#==============================================================================
alias sprite_battler_setup_new_effect_sani setup_new_effect
def setup_new_effect
sprite_battler_setup_new_effect_sani
setup_state_ani_effect
end
#=====
# new method: setup_state_ani_effect
#=====
def setup_state_ani_effect
return if @battler.state_animation_id.nil?
if @battler.state_animation_id == 0
dispose_state_animation
else
animation = $data_animations[@battler.state_animation_id]
start_state_animation(animation)
end
end
#--------------------------------------------------------------------------
# alias method: update
#--------------------------
alias sprite_battler_update_sani update
def update
sprite_battler_update_sani
update_state_animations
end
#=======
# new method: update_state_animations
#===============
def update_state_animations
update_state_animation
@@state_ani_checker.clear
@@state_ani_spr_checker.clear
end
#---------------------
#new method: state_animation?
#----------------------
def state_animation?
return !@state_animation.nil?
end
#------------------
# new method: start_state_animation
#---------------------
def start_state_animation(animation, mirror = false)
return if !@state_animation.nil? && @state_animation.id == animation.id
dispose_state_animation
@state_animation = animation
return if @state_animation.nil?
@state_ani_mirror = mirror
set_animation_rate
@state_ani_duration = @state_animation.frame_max * @ani_rate + 1
load_state_animation_bitmap
make_state_animation_sprites
set_state_animation_origin
end
#---------------------------
# new method: load_state_animation_bitmap
#------------------------
def load_state_animation_bitmap
animation1_name = @state_animation.animation1_name
animation1_hue = @state_animation.animation1_hue
animation2_name = @state_animation.animation2_name
animation2_hue = @state_animation.animation2_hue
@state_ani_bitmap1 = Cache.animation(animation1_name, animation1_hue)
@state_ani_bitmap2 = Cache.animation(animation2_name, animation2_hue)
if @@_reference_count.include?(@state_ani_bitmap1)
@@_reference_count[@state_ani_bitmap1] += 1
else
@@_reference_count[@state_ani_bitmap1] = 1
end
if @@_reference_count.include?(@ani_bitmap2)
@@_reference_count[@state_ani_bitmap2] += 1
else
@@_reference_count[@state_ani_bitmap2] = 1
end
Graphics.frame_reset
end
#-------------------
# new method: make_state_animation_sprites
#----------------------
def make_state_animation_sprites
@state_ani_sprites = []
if @use_sprite && !@@state_ani_spr_checker.include?(@state_animation)
16.times do
sprite = ::Sprite.new(viewport)
sprite.visible = false
@state_ani_sprites.push(sprite)
end
if @state_animation.position == 3
@@state_ani_spr_checker.push(@animation)
end
end
@state_ani_duplicated = @@state_ani_checker.include?(@state_animation)
if !@state_ani_duplicated && @state_animation.position == 3
@@state_ani_checker.push(@state_animation)
end
end
#-----------------
# new method: set_state_animation_origin
#-------------------
def set_state_animation_origin
if @state_animation.position == 3
if viewport == nil
@state_ani_ox = Graphics.width / 2
@state_ani_oy = Graphics.height / 2
else
@state_ani_ox = viewport.rect.width / 2
@state_ani_oy = viewport.rect.height / 2
end
else
@state_ani_ox = x - ox + width / 2
@state_ani_oy = y - oy + height / 2
if @state_animation.position == 0
@state_ani_oy -= height / 2
elsif @state_animation.position == 2
@state_ani_oy += height / 2
end
end
end
#--------------
# new method: dispose_state_animation
#-------------
def dispose_state_animation
if @state_ani_bitmap1
@@_reference_count[@state_ani_bitmap1] -= 1
if @@_reference_count[@state_ani_bitmap1] == 0
@state_ani_bitmap1.dispose
end
end
if @state_ani_bitmap2
@@_reference_count[@state_ani_bitmap2] -= 1
if @@_reference_count[@state_ani_bitmap2] == 0
@state_ani_bitmap2.dispose
end
end
if @state_ani_sprites
@state_ani_sprites.each {|sprite| sprite.dispose }
@state_ani_sprites = nil
@state_animation = nil
end
@state_ani_bitmap1 = nil
@state_ani_bitmap2 = nil
end
#--------------
# new method: update_state_animation
#--------------
def update_state_animation
return unless state_animation?
@state_ani_duration -= 1
if @state_ani_duration % @ani_rate == 0
if @state_ani_duration > 0
@state_frame_index = @state_animation.frame_max
change = (@state_ani_duration + @ani_rate - 1) / @ani_rate
@state_frame_index -= change
@state_animation.timings.each do |timing|
next unless timing.frame == @state_frame_index
state_animation_process_timing(timing)
end
else
@state_ani_duration = @state_animation.frame_max * @ani_rate + 1
end
end
return if @state_frame_index.nil?
state_animation_set_sprites(@state_animation.frames[@state_frame_index])
set_state_animation_origin
end
#~~~~~~~~~~~~~~~~
# new method: end_state_animation
#~~~~~~~~~~~~~~~~
def end_state_animation
dispose_state_animation
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~
# new method: state_animation_process_timing
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def state_animation_process_timing(timing)
timing.se.play if YEA::STATE_ANIMATION::PLAY_SOUND
case timing.flash_scope
when 1
self.flash(timing.flash_color, timing.flash_duration * @ani_rate)
when 2
return unless YEA::STATE_ANIMATION::PLAY_FLASH
if viewport && !@state_ani_duplicated
flash_amount = timing.flash_duration * @ani_rate
viewport.flash(timing.flash_color, flash_amount)
end
when 3
self.flash(nil, timing.flash_duration * @ani_rate)
end
end
end # Sprite_Battler
# ~~~~~~~~~~
# �� Game_BattlerBase
# ~~~~~~~~~~
class Game_BattlerBase
#
# public instance variables
#
attr_accessor :state_animation_id
#
# alias method: refresh
#
alias game_battlerbase_refresh_sani refresh
def refresh
game_battlerbase_refresh_sani
reload_state_animation
end
#
# new method: reload_state_animation
#
def reload_state_animation
@state_animation_id = 0
return if actor? && !YEA::STATE_ANIMATION::PLAY_ACTOR
for state in states
next unless state.state_animation > 0
@state_animation_id = state.state_animation
break
end
end
end # Game_BattlerBase
#
# �� End of File
#
#
#作者: 刹那铃音 时间: 2018-3-24 11:52
1.学会使用这个代码框
2.你其实可以用汉化版
3.把脚本复制到main以上
4.按照注释填写备注并测试
5.确定是否有冲突的脚本或脚本位置出现问题