Guest Access
Go to page : 1, 2
C.O.R.N.
C.O.R.N.
C.O.R.N.
profile
BluE
profile
It's probably easier for me to put it right in front of you instead of me trying to explain where it was.
It was in the first spoiler. :D
- Code:
################################################################################
# Script Drawn & Picture Particles v2.0 by gameface101 8/21/2011
# Original 'Particuleur Script' 1.5d XP by fabien_35@hotmail.com
################################################################################
#
#=============================== INSTRUCTIONS:
#
# use the following in a call script:
# pfx("X",Y)
# X = type *see list below
# Y = target *where the effect will appear 0 = actor / or event ID number
#
# example #1: pfx("navi",0)
# *this will call the navi effect to follow the actor
#
# example #2: pfx("feu",13)
# *this will call the fire effect to appear on the event with an ID of 13
#
#============================== TYPE OF EFFECTS:
# script drawn:
#
# orbite = orbit
# feu = fire
# saupoudrage = dust
# navi = fairy light
# brume = mist
# fumee = smoke
# feu = fire trail
# explosion = small fire blast facing
#
################################################################################
#
#liste des types d'effets :
#["orbite","fumee","feu","explosion","aura","orbite2","orbite3",
#"lance_flamme","projectile","saupoudrage","brume","coup_sword","navi"]
# indication divers
# brume possède un réglage aleas_rho
# les effets HOR (soleil, halos et reflets) doivent être effacer via le nom de la fct, ex : "soleil"
#================================= INTERFACE:
def pfx(type,target,*params)
$pfx[target]=EffetP.new(target,type,target,params,true,false,[],1,0,0,31,0.1)
end
def pfx2(nom,type,target,*params)
$pfx[nom]=EffetP.new(nom,type,target,params,true,false,[],1,0,0,31,0.1)
end
def stop_pfx(nom)
$pfx[nom].fin=true
end
#================================== CODE:
$pfx=Hash.new
EffetP = Struct.new(
"EffetP", :nom, :type, :target, :params, :ini, :fin, :particules,
:carte, :intensite, :compteur, :dsprite_z, :dtzoom, :stock, :bitmap,
:dx, :dy, :aleas_x, :aleas_y, :aleas_rho, :longueur, :vx0, :vy0, :tone,
:opacity, :blend_type, :angle, :flou, :altitude)
Particule = Struct.new(
"Particule", :x, :y, :z, :vx, :vy, :vz, :sprite, :aleas, :dsprite_z,
:stock, :source, :zoom_final)
#===============================================================================
# Spriteset Map
#===============================================================================
class Spriteset_Map
alias dispose_pfx dispose
alias update_pfx update
def dispose
dispose_pfx
$pfx.each_value{|effet|
effet.particules.each{|particule|
if not particule.is_a?(Array)
particule.sprite.dispose
else # certain particles are arrays of particles
particule.each{|elt|elt.sprite.dispose if elt.is_a?(Sprite)}
end}}
$pfx=Hash.new
end
def update
update_pfx
$pfx.each_pair{|nom,effet| # INI = start for each effect if needed
if effet.ini
effet.particules.each{|particule|particule.sprite.dispose} if not effet.particules.empty?
effet.particules = []
end
#shift effect
eval effet.type+"_maj(effet)"
effet.compteur+=effet.intensite
while effet.compteur >1
eval(effet.type+"_nouvelle_particule(effet)")
effet.compteur -= 1
end
effet.ini=false
#supress effect
$pfx.delete nom if effet.fin and effet.particules.empty? }
end
#tools for the following effect
def ev(id=0)
return (id==0 ? $game_player : $game_map.events[id] )
end
def coords(target)
target=target[0] if target.is_a?(Array)
target=target.sprite if target.is_a?(Particule)
if target.is_a?(Sprite)
return [target.x,target.y]
elsif target.is_a?(String)
return [0,0]
else
return [ev(target).screen_x,ev(target).screen_y] if ev(target)!= nil
end
end
def sgn(x)
return 0 if x==0
return x/x.abs
end
def pix_visible_aleatoire(target) #returns the visible pixels to an image
target = target[0] if target.is_a?(Array)
target = @character_sprites[target-1] if target.is_a?(Integer)
target = target.sprite if target.is_a?(Particule)
loop do #random pixel checked if non-transparent
x = rand(target.src_rect.width)
y = rand(target.src_rect.height)
return [x,y] if target.bitmap.get_pixel(x,y).alpha != 0
end
end
def pix_visible?(target,x,y)
target = target[0] if target.is_a?(Array)
target = @character_sprites[target] if not target.is_a?(Sprite)
p "Erreur. Probable qu'il y ait un trou dans les id des évts." if target==nil
x += target.ox
y += target.oy
return false if x<0 or y<0
return false if x>target.src_rect.width or y>target.src_rect.height
return (target.bitmap.get_pixel(x,y).alpha != 0)
end
def colisions_evt?(id,particule)
return false if particule.z > 48 or id==particule.source
ev = (id==0 ? $game_player : $game_map.events[id])
dx,dy=particule.x-ev.screen_x,particule.y-ev.screen_y
dx-=$game_map.display_x/4
dy-=$game_map.display_y/4
if (dx.abs<16 and dy.abs<16)
if pix_visible?(id,dx,dy-particule.z*2)
particule.vx=particule.vy=particule.vz=0
return true
end
end
return false
end
def ini_classique(effet,bitmap) #standard manufacture of a particle
particule = Particule.new
particule.sprite = Sprite.new(@viewport1)
if effet.bitmap.is_a?(String)
particule.sprite.bitmap=RPG::Cache.load_bitmap(
"Graphics/Pictures/Particules/", effet.bitmap)
elsif bitmap.is_a?(String)
particule.sprite.bitmap=RPG::Cache.load_bitmap(
"Graphics/Pictures/Particules/", bitmap)
else
particule.sprite.bitmap=bitmap
end
particule.vx, particule.vy, particule.vz = 0, 0, 0
x,y=coords(effet.target) #returns the coordinates of the event or other
x+=effet.dx if effet.dx != nil #dx horizontal pixel offset
y+=effet.dy if effet.dy != nil #dy vertical pixel offset
x+=(rand-0.5)*effet.aleas_x if effet.aleas_x != nil # random offset
y+=(rand-0.5)*effet.aleas_y if effet.aleas_y != nil # random offset
if effet.aleas_rho != nil
rho=Math.sqrt(rand)*effet.aleas_rho
theta=rand*2*Math::PI
x += rho*Math.cos(theta)
y += rho*Math.sin(theta)
end
particule.sprite.zoom_x = particule.sprite.zoom_y = (effet.dtzoom==nil ? 1 : 0 )
particule.zoom_final = 1
particule.vx=effet.vx0 if effet.vx0 != nil
particule.vy=effet.vy0 if effet.vy0 != nil
particule.dsprite_z=effet.dsprite_z
particule.x, particule.y, particule.z = x, y, 0
particule.sprite.blend_type=1
particule.sprite.origine 5
particule.sprite.zoom_x=particule.sprite.zoom_y=0
if effet.carte != nil
particule.x+=$game_map.display_x/(4*effet.carte)
particule.y+=$game_map.display_y/(4*effet.carte)
end
particule.sprite.tone= effet.tone if effet.tone.is_a?(Tone)
return particule
end
def maj_classique(effet,particule,ax=0,ay=0,az=0) #standard update
particule.x += particule.vx
particule.y += particule.vy
particule.z += particule.vz
particule.vx += ax
particule.vy += ay
particule.vz += az
particule.sprite.x = particule.x
particule.sprite.y = particule.y
particule.sprite.z = (particule.sprite.y*4 - $game_map.display_y + 3) / 4 + particule.dsprite_z
if effet.carte != nil
particule.sprite.x-=$game_map.display_x/(4*effet.carte)
particule.sprite.y-=$game_map.display_y/(4*effet.carte)
end
particule.sprite.zoom_x+=effet.dtzoom if particule.sprite.zoom_x < particule.zoom_final
particule.sprite.zoom_y+=effet.dtzoom if particule.sprite.zoom_y < particule.zoom_final
end
def dispose_brutale(effet)
effet.particules.each{|particule|particule.sprite.dispose}
effet.particules=[]
end
# From now on the different effects are stored
def orbite_maj(effet)
n=0
for particule in effet.particules
angle=360*n/(effet.particules.size+1)+Graphics.frame_count/particule.aleas
n+=1
particule.x = ev(effet.target).screen_x + 30*Math.cos(angle)
particule.y = ev(effet.target).screen_y - 25 + 20*Math.sin(angle)
particule.sprite.angle = 90-angle*180/Math::PI
end
dispose_brutale(effet) if effet.fin
end
def orbite_nouvelle_particule(effet,n=10)
n.times {
gen_particule("flamme2","boule",40,40,255,0,0,2,1)
particule=ini_classique(effet,"flamme2")
particule.aleas = 10+rand(360)*Math::PI/180
particule.sprite.blend_type = 1
particule.sprite.origine 5
particule.sprite.zoom_y=0.6
effet.particules.push particule}
end
def fumee_maj(effet)
if effet.ini
effet.aleas_x=effet.aleas_y=8
effet.dy=-24
effet.intensite=2
effet.dsprite_z=0
end
for particule in effet.particules
maj_classique(effet,particule,(rand-0.5)**9,-(0.5+particule.vy)/20.0)
longueur=(effet.longueur != nil ? effet.longueur: 1)
particule.sprite.opacity-=(Math.hypot(particule.vx.to_f,particule.vy)*longueur)
particule.vx/=1.02
particule.vy/=1.02
particule.sprite.tone.red+=1
particule.sprite.tone.blue+=1
particule.sprite.tone.green+=1
particule.dsprite_z+=-particule.vy
end
effet.particules.delete_if{|particule|particule.sprite.opacity<=0}
dispose_brutale(effet) if effet.fin
end
def fumee_nouvelle_particule(effet)
gen_particule("Blanc","boule",32,32,255,255,255,3/4.0)
particule = ini_classique(effet,"Blanc")
particule.sprite.blend_type = 0
particule.zoom_final=1/3+rand*2/3
particule.sprite.tone=Tone.new(-250,-250,-250)
particule.sprite.angle=rand(360)
effet.particules.push particule
end
def feu_maj(effet)
if effet.ini
effet.aleas_x,effet.aleas_y=15,10
effet.dx,effet.dy=0,-5
effet.intensite = 3
end
for particule in effet.particules
maj_classique(effet,particule, (rand-0.5)**5, -(0.5+particule.vy)/10.0)
particule.sprite.opacity-=particule.vy.abs/2+Math.sqrt((particule.source-particule.x).abs)
end
effet.particules.delete_if{|particule|particule.sprite.opacity<=0}
dispose_brutale(effet) if effet.fin
end
def feu_nouvelle_particule(effet)
gen_particule("fl","boule",32,32,255,60,30,1)
particule = ini_classique(effet,"fl")
particule.sprite.opacity=100
particule.zoom_final=rand/2
particule.source=ev(effet.target).screen_x+effet.dx
particule.source+= (effet.carte ==nil ? $game_map.display_x/4 : $game_map.display_x/(4*effet.carte) )
effet.particules.push particule
end
def explosion_maj(effet)
if effet.ini
effet.aleas_x,effet.aleas_y=8,10
effet.dx,effet.dy=0,-2
effet.intensite=0
end
effet.params[0]=0 if effet.params[0]==nil
effet.params[0]+=1
50.times {explosion_nouvelle_particule(effet)} if effet.params[0]<10
for particule in effet.particules
maj_classique(effet,particule)
particule.sprite.opacity-=Math.hypot(particule.vx,particule.vy)*3
end
effet.particules.delete_if{|particule|particule.sprite.opacity<=0}
ev=ev(0)
effet.particules.delete_if{|particule|Math.hypot(ev.screen_x-particule.sprite.x,ev.screen_y-particule.sprite.y-16)<16 }
dispose_brutale(effet) if effet.fin
end
def explosion_nouvelle_particule(effet)
gen_particule("fla","boule",40,40,255,0,0,1)
particule=ini_classique(effet,"fla")
particule.sprite.z=300
particule.sprite.tone=Tone.new(255,50,30)
angle=rand
particule.vx= 3*Math.cos(angle*2*Math::PI)
particule.vy= 3*Math.sin(angle*2*Math::PI)
particule.sprite.angle=rand*360
effet.particules.push particule
end
def aura_maj(effet)
if effet.ini
effet.aleas_x,effet.aleas_y=20,-32
effet.dx,effet.dy=0,16
effet.intensite=2
effet.dsprite_z = rand(500)
end
for particule in effet.particules
maj_classique(effet,particule,(rand-0.5)**5,(-0.5-particule.vy)/20.0)
particule.sprite.x=ev(effet.target).screen_x+particule.x#-$game_map.display_x/4
particule.sprite.y=ev(effet.target).screen_y+particule.y#-$game_map.display_y/4
#particule.sprite.tone.green+=10 if particule.sprite.tone.green<50
particule.sprite.opacity-=Math.hypot(particule.vx,particule.vy)*7
end
effet.particules.delete_if{|particule|particule.sprite.opacity<=0}
dispose_brutale(effet) if effet.fin
end
def aura_nouvelle_particule(effet)
gen_particule("flam","boule",40,40,255,0,0,0.5)
particule=ini_classique(effet,"flam")
particule.sprite.tone=Tone.new(-255,0,255)
particule.sprite.opacity=250
particule.zoom_final = rand/4
particule.x=+rand(20)-10
particule.y=-rand(32)
effet.particules.push particule
end
def orbite2_maj(effet)
orbite2_nouvelle_particule(effet,1) if Graphics.frame_count%4==0
for particule in effet.particules
particule.x+=particule.aleas/6.0
particule.z+=particule.aleas*((particule.z-50)/50.0)**2+0.05
x = particule.z*Math.cos(particule.y)*Math.cos(particule.x)
y = particule.z*Math.cos(particule.y)*Math.sin(particule.x)
z = particule.z*Math.sin(particule.y)
particule.sprite.x = x + ev(effet.target).screen_x
particule.sprite.y = (y-z)/2 + ev(effet.target).screen_y - 20
particule.sprite.z = (y < 0 ? 10 : 1000)
particule.sprite.opacity=63*(3+y/particule.z)
end
effet.particules.delete_if{|particule|particule.z>640}
dispose_brutale(effet) if effet.fin
end
def orbite2_nouvelle_particule(effet,n=100)
n.times {
particule = Particule.new
particule.sprite = Sprite.new(@viewport1)
particule.sprite.bitmap=gen_particule("blanc","boule",20,20,100,50,255,2)
particule.sprite.blend_type = 1
particule.sprite.origine 5
particule.sprite.zoom_x=particule.sprite.zoom_y=0
particule.aleas = 0.5+rand/2
particule.x = 2*Math::PI*rand # angle phi
particule.y = (rand-0.5)*Math::PI #angle theta
particule.z = 0# rayon
effet.particules.push particule}
end
def orbite3_maj(effet)
20.to_i.times {orbite3_nouvelle_particule(effet)} if effet.particules.size<200
for particule in effet.particules
particule.x+=particule.vx
particule.y+=particule.vy
particule.vx/=1.03
particule.vy/=1.03
particule.vx=10*sgn(particule.vx) if particule.vx.abs>10
particule.vy=10*sgn(particule.vy) if particule.vy.abs>10
particule.sprite.x=particule.x-$game_map.display_x/4
particule.sprite.y=particule.y-$game_map.display_y/4
particule.sprite.z=(particule.sprite.y*4 + 3) / 4 + 32
for target in effet.target
dx=particule.sprite.x-ev(target).screen_x
dy=particule.sprite.y-ev(target).screen_y+20
dy*=1.3
distance=((dx*dx+dy*dy)/6000.0)**2-0.1
distance=distance/(1+distance/200.0)**4
particule.vx+= dy/300.0 - sgn(dx)*distance +(rand-0.5)/10.0
particule.vy+= - dx/300.0 - sgn(dy)*distance +(rand-0.5)/10.0
end
if particule.sprite.zoom_x<1
particule.sprite.zoom_x+=0.05
particule.sprite.zoom_y+=0.05
end
end
# effet.particules.delete_if{|particule|particule.sprite.opacity<=0}
# ev=ev(0)
# effet.particules.delete_if{|particule|Math.hypot(ev.screen_x-particule.sprite.x,ev.screen_y-particule.sprite.y-16)<16 }
dispose_brutale(effet) if effet.fin
end
def orbite3_nouvelle_particule(effet)
gen_particule("flamm","boule",40,40,255,0,0,1)
particule=ini_classique(effet,"flamm")
particule.sprite.z=300
particule.sprite.tone=Tone.new(255,40,5)
effet.target=[effet.target] if not effet.target.is_a?(Array)
particule.x=ev(effet.target[0]).screen_x+$game_map.display_x/4
particule.y=ev(effet.target[0]).screen_y+$game_map.display_y/4-20
particule.aleas=[Math.cos(particule.aleas),Math.sin(particule.aleas)]
particule.vx= particule.aleas[0]
particule.vy= particule.aleas[1]
particule.sprite.angle=rand*360
effet.particules.push particule
end
def lance_flamme_maj(effet)
if effet.ini
effet.aleas_x,effet.aleas_y=8,10
effet.dx,effet.dy=0,-20
effet.intensite=5
end
for particule in effet.particules
maj_classique(effet,particule)
particule.sprite.tone.red+=30 if particule.sprite.tone.green<255
particule.sprite.tone.green+=8 if particule.sprite.tone.green<70
particule.sprite.tone.blue-=20 if particule.sprite.tone.green>20
particule.sprite.opacity-=Math.hypot(particule.vx,particule.vy)*3
end
effet.particules.delete_if{|particule|particule.sprite.opacity<=0}
ev=ev(1)
effet.particules.delete_if{|particule|Math.hypot(ev.screen_x-particule.sprite.x,ev.screen_y-particule.sprite.y-16)<16 }
dispose_brutale(effet) if effet.fin
end
def lance_flamme_nouvelle_particule(effet)
gen_particule("flamme","boule",20,20,255,0,0,1)
particule=ini_classique(effet,"flamme")
particule.sprite.tone=Tone.new(-255,0,255)
particule.zoom_final=0.3+rand
angle=[135,90,45,180,0,0,-135,-90,-45][ev(effet.target).direction-1]*Math::PI/180
angle+=(rand-0.5)/8.0
particule.vx= 5*Math.cos(angle)
particule.vy= 5*Math.sin(angle)
effet.particules.push particule
end
def brume_maj(effet)
if effet.ini
effet.aleas_rho=100 if effet.aleas_rho==nil
effet.intensite=0
effet.dsprite_z=24
densite =0.002 #number of sprite pixels
surface=2*Math::PI*effet.aleas_rho*effet.aleas_rho
nbr=(densite*surface).to_i
while effet.particules.size < nbr
brume_nouvelle_particule(effet)
end
end
for particule in effet.particules
maj_classique(effet,particule,(rand-0.5)**5,(rand-0.5)**5)
particule.vx/=1.07
particule.vy/=1.07
effet.target=[effet.target] if not effet.target.is_a?(Array)
for target in effet.target
next if not ev(target).moving?
dx=particule.sprite.x-ev(target).screen_x
dy=particule.sprite.y-ev(target).screen_y+20
next if dx.abs+dy.abs>100
dy*=1.3
distance=0.2*Math.hypot(dx,dy)**2+1
vx,vy=ev(target).vitesse_event
particule.vx+= sgn(dx)/distance + vx/distance
particule.vy+= sgn(dy)/distance + vy/distance
end
end
#effet.particules.delete_if{|particule|particule.sprite.opacity<=0}
dispose_brutale(effet) if effet.fin
end
def brume_nouvelle_particule(effet)
gen_particule("brume","boule",48,48,255,255,255,1)
particule = ini_classique(effet,"brume")
particule.sprite.tone=Tone.new(0,255,250)
particule.sprite.opacity=rand*200+55
particule.zoom_final = rand/4+0.75
particule.sprite.blend_type=0
effet.particules.push particule
end
def saupoudrage_maj(effet)
if effet.ini
effet.dx,effet.dy = 0,0
effet.intensite=1
end
for particule in effet.particules
particule.sprite.opacity-=2
maj_classique(effet,particule,(rand-0.5)**5,0,-0.1)
particule.vx/=1.2
particule.vy/=1.2
particule.vz/=1.2
particule.z=0 if particule.z<0
particule.vz=particule.vx=particule.vy=0 if particule.z==0
particule.sprite.y-= particule.z
particule.sprite.z = (particule.sprite.y*4 + 3) / 4 + 48
end
effet.particules.delete_if{|particule|particule.sprite.opacity<=0}
dispose_brutale(effet) if effet.fin
end
def saupoudrage_nouvelle_particule(effet)
#creating the sprite
gen_particule("blue","boule",16,16,40,100,250,1)
particule = ini_classique(effet,"blue")
# calculate various coordinates
if effet.target.is_a?(Particule)
particule.x = effet.target.x+rand(8)-4
particule.y = effet.target.y+rand(8)-4
particule.z = effet.target.z+rand(8)-4
particule.vx,particule.vy=effet.target.vx,effet.target.vy
else
# if source is an event
sprite_target=@character_sprites[effet.target-1]
#calculate inital rate
particule.vx,particule.vy=ev(effet.target).vitesse_event
#calculate position for event
x,yz=pix_visible_aleatoire(effet.target)
y = rand(sprite_target.src_rect.width) - sprite_target.src_rect.width/2 + 4
#attribution
particule.x = sprite_target.x+$game_map.display_x/4 + x - sprite_target.src_rect.width/2
particule.y = sprite_target.y+$game_map.display_y/4 - y
particule.z = yz - y
end
#various
particule.zoom_final=rand/2
particule.vz=0
effet.particules.push particule
end
end
#===============================================================================
# Sprite
#===============================================================================
class Sprite
def origine(direction=5)
self.ox = self.oy = 0
self.ox = self.bitmap.width if direction %3==0
self.ox = self.bitmap.width/2 if direction %3==2
self.oy = self.bitmap.height if direction < 7
self.oy /=2 if direction > 3
end
end
#===============================================================================
# Game Character
#===============================================================================
class Game_Character
def vitesse_event
v = (2 ** @move_speed)/4
v = 0 if not moving?
vx = [0, -v, 0, v, -v, 0, v, -v, 0, v][@direction]
vy = [0, v, v, v, 0, 0, 0, -v ,-v, -v][@direction]
return [vx,vy]
end
end
#===============================================================================
# Spriteset Map
#===============================================================================
class Spriteset_Map
def onde_nouvelle_particule(effet)
#gen_particule("navi","boule",16,16,255,250,250,2)
particule=ini_classique(effet,"onde")
particule.sprite.z=1000
particule.sprite.zoom_x=particule.sprite.zoom_y=particule.aleas=0
particule.sprite.blend_type=1
particule.z=32
effet.particules.push particule
end
def onde_maj(effet)
effet.carte=0 if effet.ini
onde_nouvelle_particule(effet) if effet.particules.empty?
particule= effet.particules[0]
particule.sprite.x=particule.x-$game_map.display_x/4
particule.sprite.y=particule.y-$game_map.display_y/4
particule.sprite.zoom_x=particule.sprite.zoom_x*1.05+0.01
particule.sprite.zoom_y=particule.sprite.zoom_x
# particule.sprite.z=(particule.sprite.y*4 + 3) / 4 + 32
dispose_brutale if effet.fin
end
def coup_sword_nouvelle_particule(effet)
particule=ini_classique(effet,"Sword")
particule.sprite.origine(3)
particule.sprite.z=1000
particule.sprite.zoom_x=particule.sprite.zoom_y=1
particule.sprite.blend_type=0
angle=100-90-[135,90,45,180,0,0,-135,-90,-45][ev(effet.target).direction-1]
particule.sprite.angle=angle
particule.sprite.z = 0 if particule.sprite.angle >= 215
particule.sprite.z = 0 if particule.sprite.angle < 45
particule.sprite.visible=false
vx,vy=ev(effet.target).vitesse_event
particule.vx = vx
particule.vy = vy
particule.stock=0
effet.particules.push particule
pfx("traine_sprite",particule.sprite)
end
def coup_sword_maj(effet)
if effet.ini
effet.dy= -16
effet.intensite=0
end
return if effet.fin
coup_sword_nouvelle_particule(effet) if effet.particules.empty?
particule=effet.particules[0]
particule.sprite.angle+=35
particule.sprite.zoom_x=particule.sprite.zoom_y=1-0.4*(particule.stock-3).abs/3.0
particule.stock+=1
particule.sprite.x = ev(effet.target).screen_x
particule.sprite.y = ev(effet.target).screen_y-16
particule.sprite.z = (particule.sprite.y*4 + 3) / 4 + 32
particule.sprite.z +=40
particule.sprite.z -= 40 if particule.sprite.angle >= 250
particule.sprite.z -= 40 if particule.sprite.angle < 90
if particule.stock>=7
particule.sprite.dispose
effet.fin=true
end
end
def navi_nouvelle_particule(effet)
gen_particule("navi","boule",16,16,255,250,250,2)
particule=ini_classique(effet,"navi")
particule.sprite.z=1000
particule.sprite.zoom_x=particule.sprite.zoom_y=1
particule.sprite.blend_type=0
particule.z=32
particule.vx,particule.vy = ev(effet.target).vitesse_event
maj_classique(effet,particule)
pfx2("navi_saupoudrage",'saupoudrage', particule)
effet.particules.push particule
end
def navi_maj(effet)
if effet.ini
effet.dy= -16
effet.intensite=0
end
navi_nouvelle_particule(effet) if effet.particules.empty?
particule= effet.particules[0]
particule.x+=particule.vx
particule.y+=particule.vy
particule.vx/=1.03
particule.vy/=1.03
particule.vx=10*sgn(particule.vx) if particule.vx.abs>10
particule.vy=10*sgn(particule.vy) if particule.vy.abs>10
particule.sprite.x=particule.x-$game_map.display_x/4
particule.sprite.y=particule.y-$game_map.display_y/4
particule.sprite.z=(particule.sprite.y*4 + 3) / 4 + 32
effet.target=[effet.target] if not effet.target.is_a?(Array)
for target in effet.target
dx=particule.sprite.x-ev(target).screen_x
dy=particule.sprite.y-ev(target).screen_y+20
distance=((dx*dx+dy*dy)/6000.0)**3-0.01
distance=distance/(1+distance/200.0)**4
particule.vx+= + dy/1000.0 - sgn(dx)*distance +(rand-0.5)
particule.vy+= - dx/1000.0 - sgn(dy)*distance +(rand-0.5)
end
particule.sprite.angle=-57.3*Math.atan2(particule.vy,particule.vx)-90
v=Math.hypot(particule.vx,particule.vy)/2
particule.sprite.zoom_x=1.1**-v
particule.sprite.y-= particule.z
dispose_brutale(effet) if effet.fin
end
end
def projectile_maj(effet)
effet.intensite=0 if effet.ini
while not effet.stock.empty? #contains the projectiles to launch
projectile_nouvelle_particule(effet)
end
for doublet in effet.particules
particule,ombre=doublet
maj_classique effet,particule
particule.vz-=0.3
if particule.z<=0
particule.z = 0
particule.vx=particule.vy=particule.vz=0
elsif particule.stock != nil
particule.vx,particule.vy = 0,0
particule.vz=0
particule.stock=nil if ev(particule.stock).mort
else
particule.sprite.angle=57.3*Math.atan2(-particule.vy+particule.vz*2,particule.vx)
ombre.sprite.angle=57.3*Math.atan2(-particule.vy,particule.vx)
if particule.z < 48
for id in $pfx[effet.nom].target
if colisions_evt?(id,particule)
particule.stock=id
(id==0 ? $game_player : $game_map.events[id]).pv-=1
end
end
end
end
ombre.sprite.x=particule.sprite.x
ombre.sprite.y=particule.sprite.y
ombre.sprite.zoom_x=1.0/(particule.vz.abs/2+1)
particule.sprite.y-=particule.z*2
ombre.sprite.opacity=particule.sprite.opacity/Math.sqrt(2+particule.z.abs/3)
end
effet.particules.delete_if{|particule|
particule[0].sprite.opacity-=effet.particules.size/20 if particule[0].z<=0 or particule[0].stock != nil
particule[0].sprite.opacity<=0 }
dispose_brutale(effet) if effet.fin
end
def projectile_nouvelle_particule(effet)
id_tireur,vx,vy,vz = effet.stock.shift
particule=ini_classique(effet,"Arrow")
particule.source=id_tireur
particule.sprite.origine(6)
particule.sprite.zoom_x=particule.sprite.zoom_y=1
particule.sprite.blend_type=0
particule.x = ev(id_tireur).screen_x+$game_map.display_x/4
particule.y = ev(id_tireur).screen_y+$game_map.display_y/4
angle=[135,90,45,180,0,0,-135,-90,-45][ev(id_tireur).direction-1]*Math::PI/180
angle+=(rand-0.5)/30.0
particule.vx = vx
particule.vy = vy
particule.vz = vz
particule.z=10
particule.sprite.angle = 57.3*Math.atan2(-particule.vy+particule.vz*2,particule.vx)
ombre = ini_classique(effet,"Arrow")
ombre.sprite.origine(6)
ombre.sprite.zoom_x=ombre.sprite.zoom_y=ombre.aleas=1
ombre.sprite.blend_type=2
effet.particules.push [particule,ombre]
end
def traine_sprite_maj(effet)
effet.intensite=0if effet.ini
if effet.target==nil or effet.target.disposed?
effet.fin=true if effet.particules.empty?
else
traine_sprite_nouvelle_particule(effet) if effet.params==1
end
effet.params=1
for particule in effet.particules
particule.sprite.opacity/=1.5+effet.particules.size/10.0
particule.sprite.x=particule.x-$game_map.display_x/4
particule.sprite.y=particule.y-$game_map.display_y/4
end
effet.particules.delete_if{|particule|particule.sprite.opacity<=0}
dispose_brutale(effet) if effet.fin
end
def traine_sprite_nouvelle_particule(effet)
if effet.particules.empty?
particule = Particule.new
particule.sprite=Sprite.new(effet.target.viewport)
particule.sprite.bitmap = effet.target.bitmap
for truc in ["x","y","z","ox","oy","angle","opacity","blend_type","zoom_x","zoom_y"]
eval("particule.sprite."<<truc<<" = effet.target."<<truc)
end
particule.x= particule.sprite.x + $game_map.display_x/4
particule.y= particule.sprite.y + $game_map.display_y/4
effet.particules.push particule
return
end
antecedent = effet.particules[-1].sprite
n=16
for i in 1..n
particule = Particule.new
particule.sprite=Sprite.new(effet.target.viewport)
particule.sprite.bitmap = effet.target.bitmap
j=n-i
for truc in ["x","y","z","ox","oy","angle","opacity","blend_type","zoom_x","zoom_y"]
eval("particule.sprite."<<truc<<" = (effet.target."<<truc<<"*i + antecedent."<<truc<<"*j)/n.to_f")
end
particule.x= particule.sprite.x + $game_map.display_x/4
particule.y= particule.sprite.y + $game_map.display_y/4
effet.particules.push particule
end
end
def calcul_ballistique(id_tireur,id_target,portee_tireur=15,g=0.3)
portee_tireur*=32.0
v0 = Math.sqrt(g*portee_tireur.to_f)
tireur = (id_tireur==0 ? $game_player : $game_map.events[id_tireur])
target = (id_target==0 ? $game_player : $game_map.events[id_target])
dx = target.screen_x-tireur.screen_x
dy = target.screen_y-tireur.screen_y
distance = Math.hypot(dx,dy)
argument = distance / portee_tireur
if argument.abs>1
angle=3.1415/4
else
angle=0.5*Math.asin(argument)
end
tau = (Math.cos(angle) != 0 ? tau=distance/(v0*Math.cos(angle)) : 999)
if target.moving?
vx,vy=target.vitesse_event
dx += vx*tau
dy += vy*tau
distance = Math.hypot(dx,dy)
argument = distance / portee_tireur
if argument.abs>1
angle=3.1415/4
else
angle=0.5*Math.asin(argument)
end
tau = (Math.cos(angle) != 0 ? tau=distance/(v0*Math.cos(angle)) : 999)
end
vx=dx/tau
vy=dy/tau
vz=v0*Math.sin(angle)
return [vx,vy,vz]
end
def tirer(id_tireur,id_target,portee_tireur=15,targets=[])
vx,vy,vz = calcul_ballistique(id_tireur,id_target,portee_tireur,0.3)
if not $pfx.has_key?("Projectiles")
pfx2("Projectiles","projectile",id_tireur)
end
$pfx["Projectiles"].stock= [] if $pfx["Projectiles"].stock==nil
$pfx["Projectiles"].stock.push([id_tireur,vx,vy,vz])
if not $pfx["Projectiles"].target.is_a? (Array)
$pfx["Projectiles"].target=[$pfx["Projectiles"].target]
end
$pfx["Projectiles"].target.concat(targets)
$pfx["Projectiles"].target.uniq!
end
def arroser(id_tireur,id_target,portee_tireur=15)
vx,vy,vz = calcul_ballistique(id_tireur,id_target,portee_tireur,0.3)
if not $pfx.has_key?("Projectiles")
pfx2("Projectiles","projectile",id_tireur)
end
$pfx["Projectiles"][2].push([id_tireur,vx+rand-0.5,vy+rand-0.5,vz+rand-0.5])
end
def gen_bmp(w,h,r,v,b,a="255")
bmp=Bitmap.new(w,h)
r,v,b=r.to_s,v.to_s,b.to_s
(0...h).each{|y| Graphics.update ; (0...w).each{|x|
bmp.set_pixel(x,y,Color.new(eval(r), eval(v),eval(b),eval(a)))
}}
return bmp
end
def gen_boule(w=20,h=20,r="255",v="255",b="255",puissance=1.0,n=0,m=0)
return gen_bmp(w,h,r,v,b,"d=Math.hypot(x-w/2,y-h/2);theta=Math.atan2(x-w/2,y-h/2);f=(1+Math.cos("<<m.to_s<<"*theta+"<<n.to_s<<"*4*Math::PI*d/w.to_f))/2;f*(255-255*(2.0*d/w)**"<<puissance.to_s<<")")
end
def gen_onde(w=20,h=20,r="255",v="255",b="255",puissance=1.0,k=0,rot=0,loc="d/20.0-4")
return gen_bmp(w,h,r,v,b,
"d=Math.hypot(x-w/2,y-h/2);theta=Math.atan2(x-w/2,y-h/2);g=Math.exp(-("<<loc<<")**2);f=(1+Math.cos("<<k.to_s<<"*theta+"<<rot.to_s<<"*4*Math::PI*d/w.to_f))/2;f*g*255")
end
def gen_particule(nom,type,w,h,r,v,b,a="255")
path="Graphics/Pictures/Particules/"<<nom #load or create bmp
if not RPG::Cache.a?(path) and not FileTest.exist?(path)
commande="gen_"<<type<<"("<<w.to_s<<","<<h.to_s<<","<<r.to_s<<","<<v.to_s<<","<<b.to_s<<","<<a.to_s<<")"
RPG::Cache.ajouter(eval(commande),path)
end
return RPG::Cache.load_bitmap("",path)
end
#==========================
module RPG
module Cache
def self.ajouter(bmp,path)
@cache[path] = bmp
return bmp
end
def self.a?(path)
if @cache.include?(path)
return true if not @cache[path].disposed?
end
return false
end
end
end
#==========================
def soleil(*ids)
pfx("hor","soleil")
$pfx["soleil"].stock=ids
$pfx["soleil"].tone=Tone.new(255,255,255)
$pfx["soleil"].angle= 45
$pfx["soleil"].opacity = 128
$pfx["soleil"].blend_type= 2
$pfx["soleil"].flou= 1
$pfx["soleil"].dy=-8
$pfx["soleil"].dsprite_z= -1
$pfx["soleil"].longueur= 2
end
def lum_ponctuelle(id,*ids)
nom="hor"+id.to_s
pfx2(nom,"hor",id)
$pfx[nom].stock=ids
$pfx[nom].tone=Tone.new(255,255,255)
$pfx[nom].altitude=256
$pfx[nom].angle= "angle(effet.target,particule.source)*180/Math::PI-180"
$pfx[nom].opacity = "200-distance(effet.target,particule.source)*20/100.0"
$pfx[nom].longueur= "distance(effet.target,particule.source)/(1+(effet.altitude-32).abs)"
$pfx[nom].blend_type= 2
$pfx[nom].flou= 1
$pfx[nom].dy=-8
$pfx[nom].dsprite_z= -1
end
def halos(*ids)
pfx("hor","halos")
$pfx["halos"].stock=ids
$pfx["halos"].tone=Tone.new(255,255,255)
$pfx["halos"].opacity = 128
$pfx["halos"].blend_type= 1
$pfx["halos"].flou= 3
$pfx["halos"].dsprite_z= -1
end
def reflets(*ids)
pfx("hor","reflets")
$pfx["reflets"].stock=ids
$pfx["reflets"].opacity = 200
$pfx["reflets"].dsprite_z= -1000
$pfx["reflets"].angle=180
$pfx["reflets"].flou= 3
end
def angle(id1,id2)
ev1 = (id1==0 ? $game_player: $game_map.events[id1])
ev2 = (id2==0 ? $game_player: $game_map.events[id2])
dx=ev2.real_x-ev1.real_x
dy=ev2.real_y-ev1.real_y
return Math.atan2(dx,dy)
end
def distance(id1,id2)
ev1 = (id1==0 ? $game_player: $game_map.events[id1])
ev2 = (id2==0 ? $game_player: $game_map.events[id2])
dx=ev2.real_x-ev1.real_x
dy=ev2.real_y-ev1.real_y
return Math.hypot(dx,dy)
end
#===============================================================================
# Spriteset Map
#===============================================================================
class Spriteset_Map
#----------------------------------------
def hor_maj(effet)
if effet.ini #initial setting of the effect
effet.intensite = 0
effet.dsprite_z = -1 if effet.dsprite_z == nil
end
while not effet.stock.empty?
hor_nouvelle_particule(effet)
end
for particule in effet.particules
original = @character_sprites[particule.source-1]
particule.sprite.character=original.character
particule.sprite.character.character_name = original.character.character_name+"hor"+effet.flou.to_s
particule.sprite.update
original.character.character_name=original.character.character_name[0...-4]
particule.sprite.z += effet.dsprite_z
particule.sprite.x +=effet.dx if effet.dx != nil
particule.sprite.y +=effet.dy if effet.dy != nil
particule.sprite.opacity = eval effet.opacity.to_s if effet.opacity != nil
next if particule.sprite.opacity < 2
particule.sprite.angle = eval effet.angle.to_s if effet.angle != nil
particule.sprite.tone = effet.tone if effet.tone.is_a?(Tone)
particule.sprite.zoom_y= eval effet.longueur.to_s if effet.longueur != nil
particule.sprite.zoom_y =10 if particule.sprite.zoom_y>10
particule.sprite.blend_type = effet.blend_type if effet.blend_type != nil
if effet.nom == "halos"
particule.sprite.oy=particule.sprite.src_rect.height/2
particule.sprite.y-=original.src_rect.height/2
elsif effet.nom == "reflets"
particule.sprite.mirror = true
end
end
dispose_brutale(effet) if effet.fin
end
def hor_nouvelle_particule(effet)
id = effet.stock.shift
original=@character_sprites[id-1]
particule=ini_classique(effet,chara_flou(original.bitmap,effet.flou))
particule.sprite = Sprite_Character.new(original.viewport,original.character)
particule.source=id
RPG::Cache.stocker_bitmap("Graphics/Characters/",
original.character.character_name+"hor"+effet.flou.to_s,
chara_flou(original,effet.flou))
effet.particules.push particule
end
end
def chara_flou(original,intensite=1)
nbr_poses_x,nbr_poses_y=1,1
original=RPG::Cache.picture(original) if original.is_a?(String)
if original.is_a?(Numeric)
original=0 ? original=$game_player : original=$game_map.events[original]
original=original.character_name
nbr_poses_x,nbr_poses_y=12,8
sign = original[/^[\!\$]./]
nbr_poses_x,nbr_poses_y=3,4 if sign != nil and sign.include?('$')
original=RPG::Cache.character(original,0)
elsif original.is_a?(Sprite_Character)
nbr_poses_x,nbr_poses_y=12,8
sign = original.character.character_name[/^[\!\$]./]
nbr_poses_x,nbr_poses_y=3,4 if sign != nil and sign.include?('$')
original=original.bitmap
end
nbr_poses_x,nbr_poses_y=4,4
return original if intensite==0
#flow horizontal
bitmap1=Bitmap.new(original.width+nbr_poses_x*2*intensite,original.height)
for n in 0..2*intensite
for x in 0...nbr_poses_x
bitmap1.blt(x*bitmap1.width/nbr_poses_x+n,0,
original,Rect.new(x*original.width/nbr_poses_x,0,original.width/nbr_poses_x,original.height),
255/(2*intensite) )
end
end
#flow vertical
bitmap2=Bitmap.new(bitmap1.width,original.height+nbr_poses_y*2*intensite)
for n in 0..2*intensite
for y in 0...nbr_poses_y
bitmap2.blt(0,y*bitmap2.height/nbr_poses_y+n,
bitmap1,Rect.new(0,y*bitmap1.height/nbr_poses_y,bitmap1.width,bitmap1.height/nbr_poses_y),
255/(2*intensite) )
end
end
bitmapf=Bitmap.new(original.width+nbr_poses_x*2*intensite,original.height+nbr_poses_y*2*intensite)
2*intensite.times do
bitmapf.blt(0,0,bitmap2,bitmap2.rect)
end
bitmap1.dispose
bitmap2.dispose
return bitmapf
end
#=====================
module RPG
module Cache
def self.stocker_bitmap(folder_name, filename,bitmap)
path = folder_name + filename
@cache[path] = bitmap if filename != ""
end
end
end
#=====================
#===============================================================================
# Game Character class
#===============================================================================
class Game_Character
attr_accessor :character_name
end
def erase_me
$game_map.delete_event(@id)
end
#===============================================================================
# Game Event under Game Character class
#===============================================================================
class Game_Event < Game_Character
alias pfx_erase_me erase_me
def erase_me
if $pfx[@id] != nil
#for i in 0..30
#print $pfx[@id]
#end
effet = $pfx[@id]
effet.particules.each{|particule|
if not particule.is_a?(Array)
particule.sprite.dispose
else # certain "particules" are arrays of particles...
particule.each{|elt|elt.sprite.dispose if elt.is_a?(Sprite)}
end}
$pfx.delete(@id)#[@id] = nil
end
pfx_erase_me
end
end
It was in the first spoiler. :D
C.O.R.N.
Show Signature
ACTIVATED
ACTIVATED
The only one
The only one
The only one
profile
NuKa_BuBble
profile
Next time, ask me, I'll translate.
The only one
Show Signature
ACTIVATED
ACTIVATED
ACTIVATED
profile
NinjaGM
profile
PERFECT SCRIPT, THANKS A LOT, IS THE BEST SCRIPT I HAVE EVER SEEN!
ACTIVATED
Show Signature
ACTIVATED
Administrator
Administrator
Administrator
profile
G@MeF@Ce
profile
yeah I really like this one too, the fact that effects are script drawn and the script uses some calculus math to do it. I used this for the afterburner effect on the spaceship (S.S.XEGA)
"Into the Nexas" project.
it was tricky stuff to get the "flame lance" effect to go from flame thrower to rocket thrusters.
Who knows, with a little "modulation" this script could become easier to use with more effects in a future version.
"Into the Nexas" project.
it was tricky stuff to get the "flame lance" effect to go from flame thrower to rocket thrusters.
Who knows, with a little "modulation" this script could become easier to use with more effects in a future version.
Administrator
Show Signature
CyberSpace Pirate
CyberSpace Pirate
CyberSpace Pirate
profile
BliZZvET
profile
i try to understand this type of script but i usually use action-script and as soon as i saw a dollar sign i decided that the script would be out of my grasp , but i am just wondering if "def" is the beginning of a function and "end" is the end of it . also does it use variables because i was looking at it and i could not find any will comparing it with action-script.
CyberSpace Pirate
Show Signature
CyberSpace Pirate
Go to page : 1, 2