QUOTE (breadlord @ Aug 14 2009, 01:02 AM)

Wich particle engine? Please post it so I can see if I can fix the compatibility issues.
Oh, it's not really neccessary, but thank you. =) And the problem is with Particle Engine in fact, not in yours. They just can't work together, cause I get error every time when I'm leaving mixing window(s), when the particle effect should be created. Anyway, it's not really important. =)
But if you want to check this, here's the script:
CODE
#===============================================================================
# † [VX] † Rei Particle Engine † †
# † This script lets you create particle effects in your game †
#-------------------------------------------------------------------------------
# † XP version by arevulopapo on RMXP.org
# † VX version by reijubv [aruyasoft@comic.com]
# † RPGRevolution.com
# † Released on: 16/06/2009
# † Version: 1.0 (June 16th 2009)
#-------------------------------------------------------------------------------
# > Changelog:
# V.1.0 (16-06-09) = Initial release
#-------------------------------------------------------------------------------
# Particles are integrated into "Spriteset_Map, so they can be displayed
# over/under an event.
# To automatically give particle effect to an event, just write :
# [rpee#]
# to the event's comment.
# Change # with a preset Id specified in Rei Module
# Effects are also can be called from "Script" command like this:
# $scene.effect(EVENT_ID, EFFECT, LOCK, X, Y, Z)
#
# Explanation :
#
# EVENT_ID - ID of the source the particles will flow from.
# -1, player. Otherwise, that event ID.
# EFFECT - Id of the effect to call. This can be set up in Rei module below.
# LOCK - alignment of the particles. 'stay' to align particles
# with event's map position, 'move' to align with event's screen
# position.
# For static events, like fireplaces, teleports, etc. 'stay' align
# ment is recommended.
# For moving events use 'move' mode.
# X, Y - number of pixels that will be added to the event's position
# to determine the starting point of particles.
# Z - base Z coordinate of the particles, it'll be automatically added
# or reduced based on particle's Y coordinate.
#-------------------------------------------------------------------------------
# To add your own particle effects, edit Rei module below...
#-------------------------------------------------------------------------------
# VX version is far more easier to configure!! ^.^
# See the demo for examples.
#-------------------------------------------------------------------------------
# Credits:
# arevulopapo for making this script in XP
# reijubv for porting this script to VX
#-------------------------------------------------------------------------------
# ? Installation:
# Put this script above main, setup in Rei module below
#==============================================================================
$imported = {} if $imported == nil
$imported["Rei_"+"ParticleEffect"] = true
#---------------------------------------------------------------------------
# ** Rei Module
#---------------------------------------------------------------------------
module Rei
module Particle_Effect
#-------------------------
# don't remove or modify below lines!
EFFECT = {}
PRESET = {}
# don't remove or modify above lines!
#--------------------------
PATH = "Pictures/" # Where you put the particle pictures inside
# Graphics folder
#-------------------------
# don't remove or modify below lines!
def self.update
# don't remove or modify above lines!
#--------------------------
#-----------------------------------------------------------------------
# To setup particle effects :
#-----------------------------------------------------------------------
# First setup the variables, then just place them like this
# EFFECT[id] = [pic,acc,grv,opa,bld]
# pic = Picture name of the particle
# acc = Acceleration of the particle in x and y coordinate
# acc determine how far the particles will go it's source
# grv = Gravity/weight of the particle in x and y coordinate
# acc will be reduced by grv at the end
# opa = Opacity of the particle, starting opacity and it's reduction
# bld = Blend type, 0 = normal, 1 = add, 2 = reduce
# hue = hue of the picture, from 0 to 360
#----------------------------------------------------------------------
# Effect 1 ( blue stars )
pic = 'star_blue'
acc = [1.00*(-15+rand(30))/10, 1.00*(-15+rand(30))/10]
grv = [0,0]
opa = [160,5+rand(15)]
bld = 1
hue = 0
EFFECT[1] = [pic,acc,grv,opa,bld,hue]
# Effect 2 ( red stars )
pic = 'star_red'
acc = [1.00*(-15+rand(30))/10, 1.00*(-15+rand(30))/10]
grv = [0,0]
opa = [160,5+rand(15)]
bld = 1
hue = 0
EFFECT[2] = [pic,acc,grv,opa,bld,hue]
# Effect 3 ( green stars )
pic = 'star_green'
acc = [1.00*(-15+rand(30))/10, 1.00*(-15+rand(30))/10]
grv = [0,0]
opa = [160,5+rand(15)]
bld = 1
hue = 0
EFFECT[3] = [pic,acc,grv,opa,bld,hue]
# Effect 4 ( yellow stars )
pic = 'star_yellow'
acc = [1.00*(-15+rand(30))/10, 1.00*(-15+rand(30))/10]
grv = [0,0]
opa = [160,5+rand(15)]
bld = 1
hue = 0
EFFECT[4] = [pic,acc,grv,opa,bld,hue]
# Effect 5 ( "smash" particle )
pic = 'smash'
acc = [1.00*(-15+rand(30))/10, 1.00*(-15+rand(30))/10]
grv = [0,0]
opa = [160,5+rand(15)]
bld = 1
hue = 0
EFFECT[5] = [pic,acc,grv,opa,bld,hue]
# Effect 6 ( fire 1 )
pic = 'particle_yellow'
acc = [(rand(7)-3)*0.2, 0]
grv = [0,0.15]
opa = [255,8+rand(5)]
bld = 1
hue = 0
EFFECT[6] = [pic,acc,grv,opa,bld,hue]
# Effect 7 ( fire 2 )
pic = 'particle_orange'
acc = [(rand(7)-3)*0.2, 0]
grv = [0,0.15]
opa = [255,8+rand(5)]
bld = 1
hue = 0
EFFECT[7] = [pic,acc,grv,opa,bld,hue]
# Effect 8 ( red sparks )
pic = 'particle_red'
acc = [0.5*(-25+rand(50))/10, -4]
grv = [0,-0.5]
opa = [255,20]
bld = 1
hue = 0
EFFECT[8] = [pic,acc,grv,opa,bld,hue]
# Effect 9 ( smoke )
pic = 'smoke'
acc = [0.1*(-25+rand(50))/10, 0]
grv = [0,0.13]
opa = [128,3]
bld = 1
hue = 0
EFFECT[9] = [pic,acc,grv,opa,bld,hue]
# Effect 10 ( "cells" particle )
pic = 'particle_red'
dx = 1.00*(-100 + rand(200))/100 # Just to make calculation easier
dy = 1.00*(-100 + rand(200))/100 # Just to make calculation easier
acc = [5*dx, 5*dy]
grv = [0.3*dx,0.3*dy]
opa = [255,10]
bld = 1
hue = 0
EFFECT[10] = [pic,acc,grv,opa,bld,hue]
# Effect 11 ( skull )
pic = 'skull'
acc = [(rand(7)-3)*0.2, 0]
grv = [0,0.25]
opa = [255,10]
bld = 2
hue = 0
EFFECT[11] = [pic,acc,grv,opa,bld,hue]
# Add more with similiar format as those above
end
#-----------------------------------------------------------------------
# To setup preset settings that can be used to automatically add effects
# to event
#-----------------------------------------------------------------------
# Effect id, Lock type, X, Y , Z coordinate)
# Effect id is those EFFECT[id] above,
# Lock Type is either "stay" or "move"
# X , Y , Z is coordinate
PRESET[1] = [ 6, "stay", 0, 0, 0 ] # > Fireplace effect
PRESET[2] = [ 9, "stay", 0, 0, 0 ] # > Smoke for a fireplace effect
PRESET[3] = [ 11, "stay", 0, -24, 1 ]
# Add more with similiar format as those above
end
end
#==============================================================================
# ** Cache
#------------------------------------------------------------------------------
# This module loads each of graphics, creates a Bitmap object, and retains it.
# To speed up load times and conserve memory, this module holds the created
# Bitmap object in the internal hash, allowing the program to return
# preexisting objects when the same bitmap is requested again.
#==============================================================================
module Cache
#--------------------------------------------------------------------------
# * Get Animation Graphic
# filename : Filename
# hue : Hue change value
#--------------------------------------------------------------------------
def self.particle_engine(filename, hue)
load_bitmap("Graphics/"+Rei::Particle_Effect::PATH, filename, hue)
end
end
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
# This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
# * Object Initialization
# map_id : map ID
# event : event (RPG::Event)
#--------------------------------------------------------------------------
alias reipegemint initialize unless method_defined?('reipegemint')
def initialize(map_id, event)
reipegemint(map_id, event)
@delay = 0
end
#---------------------------------------------------------------------------
# * get particle effect preset
#---------------------------------------------------------------------------
def getparticleeffect
if !@list.nil?
for i in 0...@list.size - 1
next if @list[i].code != 108
if @list[i].parameters[0].include?("[rpee")
list = @list[i].parameters[0].scan(/\[rpee([0-9]+)\]/)
pe = $1.to_i
end
end
return pe
end
end
#---------------------------------------------------------------------------
# * check if event has a specified comment
#---------------------------------------------------------------------------
def has_comment?(comment, return_comment = false )
if !@list.nil?
for i in 0...@list.size - 1
next if @list[i].code != 108
if @list[i].parameters[0].include?(comment)
return @list[i].parameters[0] if return_comment
return true
end
end
return '' if return_comment
return false
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias reipegemupd update unless method_defined?('reipegemupd')
def update
reipegemupd
if self.has_comment?("[rpee")
if @delay >1
ef = Rei::Particle_Effect::PRESET[getparticleeffect][0]
lc = Rei::Particle_Effect::PRESET[getparticleeffect][1]
x = Rei::Particle_Effect::PRESET[getparticleeffect][2]
y = Rei::Particle_Effect::PRESET[getparticleeffect][3]
z = Rei::Particle_Effect::PRESET[getparticleeffect][4]
id = @event.id
$scene.eveffect(id, ef, lc, x, y, z)
@delay = 0
end
@delay +=1
end
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs the map screen processing.
#==============================================================================
class Scene_Map
def effect(event=1, effect=1, lock='stay', x=0, y=0 ,z=0)
@spriteset.add_effect(event, effect, lock, x, y, z)
end
def eveffect(event=1,effect=1, lock='stay', x=0, y=0 ,z=0)
@spriteset.add_eveffect(event, effect, lock, x, y, z)
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================
class Spriteset_Map
attr_reader :particles
alias particle_ssm_init initialize
alias particle_ssm_update update
alias particle_ssm_dispose dispose
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@particles = []
particle_ssm_init
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
@particles.each{ |d| d.dispose }
particle_ssm_dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
Rei::Particle_Effect.update
@particles.each_with_index{ |p,i|
@particles[i].update
if p.opacity == 0
p.dispose
@particles.delete_at(i)
end
}
particle_ssm_update
end
#--------------------------------------------------------------------------
# * Get Character
# param : if -1, player. Otherwise, that event ID.
#--------------------------------------------------------------------------
def get_character(param)
case param
when -1
object = $game_player
else
object = $game_map.events[param]
end
return object
end
#--------------------------------------------------------------------------
# * Add particle effect
#--------------------------------------------------------------------------
def add_effect(event=1, effect=1, lock='stay', x=0, y=0 ,z=0)
object = get_character(event)
add_particles(object, x, y, Rei::Particle_Effect::EFFECT[effect][0],
Rei::Particle_Effect::EFFECT[effect][1],Rei::Particle_Effect::EFFECT[effect][2],
Rei::Particle_Effect::EFFECT[effect][3],
lock,Rei::Particle_Effect::EFFECT[effect][4],z,
Rei::Particle_Effect::EFFECT[effect][5])
end
def add_eveffect(event=1, effect=1, lock='stay', x=0, y=0 ,z=0)
object = $game_map.events[event]
add_particles(object, x, y, Rei::Particle_Effect::EFFECT[effect][0],
Rei::Particle_Effect::EFFECT[effect][1],Rei::Particle_Effect::EFFECT[effect][2],
Rei::Particle_Effect::EFFECT[effect][3],
lock,Rei::Particle_Effect::EFFECT[effect][4],z,
Rei::Particle_Effect::EFFECT[effect][5])
end
#--------------------------------------------------------------------------
# * Add the particles
#--------------------------------------------------------------------------
def add_particles(object=$game_player, x=0, y=0, sprite='', acc=[0,0],
grav=[0,0], opacity=[255,0], lock='stay', blend=0 ,z=0,hue=0)
if lock=='stay'
@particles << Particle_Event.new(@viewport1, object, x, y, sprite, acc,
grav, opacity, blend,z,hue)
elsif lock=='move'
@particles << Particle_Screen.new(@viewport1, object, x, y, sprite, acc,
grav, opacity, blend,z,hue)
end
end
end
#==============================================================================
# ** Particle_Screen
#------------------------------------------------------------------------------
# This class is to handle particle effect that will stay on a non movable object.
#==============================================================================
class Particle_Screen < Sprite
def initialize(viewport=Viewport.new(0,0,800,600), object=$game_player, x=0,
y=0, sprite='', acc=[0,0], grav=[0,0], opacity=[255,3], blend=0,z=0,hue=0)
super(viewport)
self.bitmap = Cache.particle_engine(sprite,hue)
self.x = object.screen_x + x
self.y = object.screen_y - 16 + y
self.ox = self.bitmap.width/2
self.oy = self.bitmap.height/2
self.blend_type = blend
self.opacity = opacity[0]
@baseZ = z
@object = object
@origin = [self.x, self.y]
@acceleration = acc
@gravity = grav
@coords = [0.00, 0.00]
@opacity = opacity[1]
update
end
def update
@acceleration[0] -= @gravity[0] if @gravity[0] != 0
@acceleration[1] -= @gravity[1] if @gravity[1] != 0
@coords[0] += @acceleration[0]
@coords[1] += @acceleration[1]
self.opacity -= @opacity
self.x = @origin[0] + @coords[0]
self.y = @origin[1] + @coords[1]
if self.y > (@object.screen_y - 16)
self.z = @baseZ + @object.screen_z + 32
else
self.z = @baseZ + @object.screen_z - 32
end
end
end
#==============================================================================
# ** Particle_Event
#------------------------------------------------------------------------------
# This class is to handle particle effect that is placed on a movable object.
#==============================================================================
class Particle_Event < Sprite
def initialize(viewport=Viewport.new(0,0,800,600), object=$game_player, x=0,
y=0, sprite='', acc=[0,0], grav=[0,0], opacity=[255,3], blend=0,z=0,hue=0)
super(viewport)
self.bitmap = Cache.particle_engine(sprite,hue)
self.x = object.x*32 + 16 - $game_map.display_x / 2 + x
self.y = object.y*32 + 32 - $game_map.display_y / 2 + y
self.ox = self.bitmap.width/2
self.oy = self.bitmap.height/2
self.blend_type = blend
self.opacity = opacity[0]
@baseZ = z
@object = object
@origin = [object.x*32 + x + 16, object.y*32 + y + 32]
@acceleration = acc
@gravity = grav
@coords = [0.00, 0.00]
@opacity = opacity[1]
update
end
def update
@acceleration[0] -= @gravity[0] if @gravity[0] != 0
@acceleration[1] -= @gravity[1] if @gravity[1] != 0
@coords[0] += @acceleration[0]
@coords[1] += @acceleration[1]
self.opacity -= @opacity
self.x = @origin[0] + @coords[0] - $game_map.display_x / 8
self.y = @origin[1] + @coords[1] - $game_map.display_y / 8 - 16
if self.y > (@object.screen_y - 16)
self.z = @baseZ + @object.screen_z + 32
else
self.z = @baseZ + @object.screen_z - 32
end
end
end
#--------------------------------------------------------------------------
# * END OF SCRIPT
#--------------------------------------------------------------------------
To launch particle effect, for example: [rpee1] as a comment in event.
Oh, and by the way... Are you taking requests? =P I really love yours scripts, and I wanted to change a little this "mix items" script, but I've done a mess....I'm suck at scripting ^^; I just need to add some windows with texts to this script. If you could help, I'll be honored. ^_~