Mike Portnoy
Member
I Pmed Trickster for this but maybe he's a bit... busy or anything.
So i post here aswell.
I have two problems with the display animation script of trickster
1 - It's activated by a call script. This call script works if the event is activated with "action". It doesn't work if it's a parallel event or autostart.
2 - I don't know the command to stop infinite loops of animations.
Basically the script can activate an animation on a event or on a tile with a call script.
Here's the script.
I can't use the command described in the script cause i can't get them to work, but i have a demo released from trickster and i copied the commands from that. It was something like animation_push or something similar, i'll write if somebody can or wants to help.
So i post here aswell.
I have two problems with the display animation script of trickster
1 - It's activated by a call script. This call script works if the event is activated with "action". It doesn't work if it's a parallel event or autostart.
2 - I don't know the command to stop infinite loops of animations.
Basically the script can activate an animation on a event or on a tile with a call script.
Here's the script.
I can't use the command described in the script cause i can't get them to work, but i have a demo released from trickster and i copied the commands from that. It was something like animation_push or something similar, i'll write if somebody can or wants to help.
Code:
=begin
┌──────────────────────────────────────â”
│◠Display Animations 1.0 │
│ │
│ Created By │
│ │
│ Trickster (tricksterguy@hotmail.com)│
│ │
│ │
└──────────────────────────────────────┘
â–ºIntro
This script will allow you to display an animation at any (x,y) position or
any tile so you will not have to use blank events to display an animation at
that tile
â–ºInstructions
Add this above main.
To call just do
$animations.push(Animation.new(type,x,y,id[,loop,sound,viewport])
anything within the [] is optional
type is the type of animation use either 1,2,3 or 'screen','tile','map'
1 or 'screen' follows the player it stays on the screen
2 or 'tile' stays at a particular tile (x,y)
3 or 'map' stays at a particular position (x,y) on the map
4 or 'player' follows the player (x,y) defines the offset
5 or 'event' follows an event (use x parameter for id and [x,y] for offset)
id is the animation id to play
Optional
loop is the number of times to play the animation
set this to nil an the animation plays forever
the default value is 1
sound set to true and you will hear the animation's sounds
set this to false and the sounds will not play
the default value is true
viewport is the animations viewport the default is the whole screen
=end
class Animation
@@animations = []
@@reference_count = {}
def initialize(type,x,y,id,loop = 1,sound = true,viewport = Viewport.new(0,0,640,480))
@type = type
@off_x = 0
@off_y = 0
case type
when 'screen','map',1,3
@x = x
@y = y
when 'tile',2
@x = (x % $game_map.width) * 128
@y = (y % $game_map.height) * 128
when 'player',4
@battler = $game_player
@off_x = x
@off_y = y
when 'event',5
event_id = x
x = y[0]
y = y[1]
@battler = $game_map.events[event_id]
@off_x = x
@off_y = y
end
@animation = $data_animations[id]
return if @animation.nil?
@loop = loop
@sound = sound
@viewport = viewport
animation
end
def animation
dispose_animation
@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(@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 update
if @animation != nil and (Graphics.frame_count % 2 == 0)
@animation_duration -= 1
update_animation
end
@@animations.clear
end
def update_animation
if @animation_duration > 0 or @loop.nil? or @loop > 1
if @animation_duration == 0
@animation_duration = @animation.frame_max
@loop -= 1 if !@loop.nil?
end
frame_index = @animation.frame_max - @animation_duration
cell_data = @animation.frames[frame_index].cell_data
position = @animation.position
animation_set_sprites(@animation_sprites, cell_data, position)
for timing in @animation.timings
if timing.frame == frame_index
animation_process_timing(timing)
end
end
else
dispose_animation
end
end
def dispose
dispose_animation
end
def dispose_animation
if @animation_sprites != nil
sprite = @animation_sprites[0]
if sprite != nil
@@reference_count[sprite.bitmap] -= 1
if @@reference_count[sprite.bitmap] == 0
sprite.bitmap.dispose
end
end
for sprite in @animation_sprites
sprite.dispose
end
@animation_sprites = nil
@animation = nil
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)
case @type
when 'tile','map',2,3
sprite.x = (@x - $game_map.display_x + 3) / 4 + 16
sprite.y = (@y - $game_map.display_y + 3) / 4 + 32
when 'screen',1
sprite.x = @x
sprite.y = @y
when 'player','event',4,5
sprite.x = @battler.screen_x + @off_x
sprite.y = @battler.screen_y + @off_y
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)
sprite.opacity = cell_data[i, 6]
sprite.blend_type = cell_data[i, 7]
end
end
def animation_process_timing(timing)
if @sound
if timing.se.name != ""
se = timing.se
Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
end
end
end
def x=(x)
sx = x
if sx != 0
if @animation_sprites != nil
for i in 0..15
@animation_sprites[i].x += sx
end
end
end
end
def y=(y)
sy = y
if sy != 0
if @animation_sprites != nil
for i in 0..15
@animation_sprites[i].y += sy
end
end
end
end
end