So, nachdem das nun doch mehr Arbeit war als geplant - aber durch meine Internetabstinenz und vielen Bahnfahrten hatte ich viel Zeit das zu erledigen - hab ich dein Script nun fertig. Waren doch 2 von mir dumm verursachte Endlosschleifen -.-
Es macht: Charaktere während einer Animation (ausser white flash) unsichtbar, spielt animation auf dem Battler und dem Target gleichzeitig ab.
Du solltest diesen Teil
Code:
#----------------------------------------------------#
#-------------------RPG::Sprite----------------------#
#----------------------------------------------------#
#RPG-Sprite# #Updated to support two animations at once,
#callable via using RPG::SPrite.animation while an
#Animation is still running.
#Using it again while 2 Animations are running will stop animation1
#an replace it.
class RPG::Sprite
@@_animations2 =[]
@@_reference_count2={}
def update
super
if @_whiten_duration > 0
@_whiten_duration -= 1
self.color.alpha = 128 - (16 - @_whiten_duration) * 10
end
if @_appear_duration > 0
@_appear_duration -= 1
self.opacity = (16 - @_appear_duration) * 16
end
if @_escape_duration > 0
@_escape_duration -= 1
self.opacity = 256 - (32 - @_escape_duration) * 10
end
if @_collapse_duration > 0
@_collapse_duration -= 1
self.opacity = 256 - (48 - @_collapse_duration) * 6
end
if @_damage_duration > 0
@_damage_duration -= 1
case @_damage_duration
when 38..39
@_damage_sprite.y -= 4
when 36..37
@_damage_sprite.y -= 2
when 34..35
@_damage_sprite.y += 2
when 28..33
@_damage_sprite.y += 4
end
@_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
if @_damage_duration == 0
dispose_damage
end
end
if @_animation != nil and (Graphics.frame_count % 2 == 0)
@_animation_duration -= 1
update_animation
end
if @_animation2 != nil and (Graphics.frame_count % 2 == 0)
@_animation2_duration -= 1
update_animation2
end
if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
update_loop_animation
@_loop_animation_index += 1
@_loop_animation_index %= @_loop_animation.frame_max
end
if @_blink
@_blink_count = (@_blink_count + 1) % 32
if @_blink_count < 16
alpha = (16 - @_blink_count) * 6
else
alpha = (@_blink_count - 16) * 6
end
self.color.set(255, 255, 255, alpha)
end
@@_animations.clear
@@_animations2.clear
end
#alias double_animation_update update
#def update
# if @_animation2 != nil and (Graphics.frame_count % 2 == 0)
# @_animation2_duration -= 1
# update_animation2
# end
# double_animation_update
# @@_animations2.clear
#end
alias double_animation_init initialize
def initialize (vp=nil)
double_animation_init(vp)
@_animation2_duration = 0
end
alias double_animation_dispose dispose
def dispose
double_animation_dispose
dispose_animation2
end
def animation(animation,hit)
if @_animation_duration > 0
if @_animation2_duration > 0
dispose_animation
else
animation2(animation,hit)
return
end
end
@_animation = animation
return if @_animation == nil
@_animation_hit = hit
@_animation_duration = @_animation.frame_max
animation_name = @_animation.animation_name
animation_hue = @_animation.animation_hue
bitmap = RPG::Cache.animation(animation_name, animation_hue)
if @@_reference_count.include?(bitmap)
@@_reference_count[bitmap] += 1
else
@@_reference_count[bitmap] = 1
end
@_animation_sprites = []
if @_animation.position != 3 or not @@_animations.include?(animation)
for i in 0..15
sprite = ::Sprite.new(self.viewport)
sprite.bitmap = bitmap
sprite.visible = false
@_animation_sprites.push(sprite)
end
unless @@_animations.include?(animation)
@@_animations.push(animation)
end
end
update_animation
end
def animation2 (animation, hit)
dispose_animation2
@_animation2 = animation
return if @_animation == nil
@_animation2_hit = hit
@_animation2_duration = @_animation2.frame_max
animation_name = @_animation2.animation_name
animation_hue = @_animation2.animation_hue
bitmap = RPG::Cache.animation(animation_name, animation_hue)
if @@_reference_count2.include?(bitmap)
@@_reference_count2[bitmap] += 1
else
@@_reference_count2[bitmap] = 1
end
@_animation2_sprites = []
if @_animation2.position != 3 or not @@_animations2.include?(animation)
for i in 0..15
sprite = ::Sprite.new(self.viewport)
sprite.bitmap = bitmap
sprite.visible = false
@_animation2_sprites.push(sprite)
end
unless @@_animations2.include?(animation)
@@_animations2.push(animation)
end
end
update_animation2
end
def dispose_animation2
if @_animation2_sprites != nil
sprite = @_animation2_sprites[0]
if sprite != nil
@@_reference_count2[sprite.bitmap] -= 1
if @@_reference_count2[sprite.bitmap] == 0
sprite.bitmap.dispose
end
end
for sprite in @_animation2_sprites
sprite.dispose
end
@_animation2_sprites = nil
@_animation2 = nil
end
end
alias double_animation_effect effect?
def effect?
double_animation_effect or
@_animation2_duration > 0
end
def update_animation2
if @_animation2_duration > 0
frame_index = @_animation2.frame_max - @_animation2_duration
cell_data = @_animation2.frames[frame_index].cell_data
position = @_animation2.position
animation_set_sprites(@_animation2_sprites, cell_data, position)
for timing in @_animation2.timings
if timing.frame == frame_index
animation2_process_timing(timing, @_animation2_hit)
end
end
else
dispose_animation2
end
end
def animation_set_sprites(sprites, cell_data, position)
for i in 0..15
sprite = sprites[i]
pattern = cell_data[i, 0]
if sprite == nil or pattern == nil or pattern == -1
sprite.visible = false if sprite != nil
next
end
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
if position == 3
if self.viewport != nil
sprite.x = self.viewport.rect.width / 2
sprite.y = self.viewport.rect.height - 160
else
sprite.x = 320
sprite.y = 240
end
else
sprite.x = self.x - self.ox + self.src_rect.width / 2
sprite.y = self.y - self.oy + self.src_rect.height / 2
sprite.y -= self.src_rect.height / 4 if position == 0
sprite.y += self.src_rect.height / 4 if position == 2
end
sprite.x += cell_data[i, 1]
sprite.y += cell_data[i, 2]
sprite.z = 2000
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
if self.opacity == 0
sprite.opacity = cell_data[i, 6] * 255.0
else
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
end
sprite.blend_type = cell_data[i, 7]
end
end
def animation2_process_timing(timing, hit)
if (timing.condition == 0) or
(timing.condition == 1 and hit == true) or
(timing.condition == 2 and hit == false)
if timing.se.name != ""
se = timing.se
Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
end
case timing.flash_scope
when 1
self.flash(timing.flash_color, timing.flash_duration * 2)
when 2
if self.viewport != nil
self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
end
when 3
self.flash(nil, timing.flash_duration * 2)
end
end
end
alias double_animation_x x=
def x=(x)
sx = x - self.x
if @_animation2_sprites != nil
for i in 0..15
@_animation2_sprites[i].x += sx
end
end
double_animation_x(x)
end
alias double_animation_y y=
def y=(y)
sy = y - self.y
if @_animation2_sprites != nil
for i in 0..15
@_animation2_sprites[i].y += sy
end
end
double_animation_y(y)
end
end
vor allem anderen einfügen, folgenden
Code:
#----------------------------------------------------#
#-----------------Game_Battler-----------------------#
#----------------------------------------------------#
class Game_Battler
attr_accessor :opacity0
attr_accessor :opacity255
attr_accessor :animation_hit2
attr_accessor :animation_id2
alias double_animation_init_gb initialize
def initialize
double_animation_init_gb
@opacity0=false
@opacity255=false
@animation_hit2 = false
@animation_id2=0
@last_done=1
end
def animation_id=(id)
if @animation_id ==0
@animation_id=id
@last_done=1
return
elsif @animation_id2 == 0
@animation_id2=id
@last_done=2
return
end
@animation_id = id
@last_done=1
end
def animation_hit=(hit)
if @last_done==1
@animation_hit=hit
return
else
@animation_hit2=hit
return
end
end
def FIXanimation_id=(id)
@animation_id=id
end
end
#----------------------------------------------------#
#-----------------Sprite_Battler---------------------#
#----------------------------------------------------#
class Sprite_Battler
alias double_animation_upd update
def update
#Animation
if @battler.animation_id != 0
animation = $data_animations[@battler.animation_id]
animation(animation, @battler.animation_hit)
@battler.FIXanimation_id = 0
end
double_animation_upd
# Animation2
if @battler.animation_id2 != 0
animation = $data_animations[@battler.animation_id2]
animation(animation, @battler.animation_hit2)
@battler.animation_id2 = 0
end
if @battler.opacity0
self.opacity = 0
#@battler.opacity0=false
end
if @battler.opacity255
self.opacity = 255
@battler.opacity0=false
@battler.opacity255=false
end
end
end
#----------------------------------------------------#
#-----------------Scene_Battle-----------------------#
#----------------------------------------------------#
class Scene_Battle
alias double_animation_up4s2 update_phase4_step2
def update_phase4_step2
double_animation_up4s2
if @phase4_step == 3
@phase4_step = 4
end
end
alias double_animation_up4s3 update_phase4_step3
alias double_animation_up4s4 update_phase4_step4
def update_phase4_step4
unless @animation1_id == 0
@active_battler.opacity0=true
end
double_animation_up4s3
double_animation_up4s4
end
alias double_animation_up4s5 update_phase4_step5
def update_phase4_step5
@active_battler.opacity255=true
double_animation_up4s5
end
end
am besten unter deinen anderen System - wobei es vermutlich egal ist.
Das Script funktioniert in meinem Testprojekt einwandfrei, allerdings ist es nicht ideal geschrieben, also es könnte durchaus Kompatibilitätsprobleme mit anderen Scripten geben, da kann ich für nichts garantieren.
Wenn du Probleme mit dem Script hast, u.a. eben wegen Kompatibilität, post einfach nochmal hier oder schreib ne PN
@KD:
Ich bin übrigens gerne für Verbesserungsvorschläge offen, wenn du sie geben möchtest. Grade bei RPG::Sprite weiss ich nicht, ob ich mir einige der Variablen (u.a. reference_count) hätte sparen können zu verdoppeln.