XP New Particle Script Edit

Though not sure if this is more of a request or support for this script, But im trying to figure out a way to make the New Particle script to create the particle on self event, like whatever event it is called from the particle will show on its self? Any help would be great!
Add this:
  1. class Interpreter
  2.   attr_reader :event_id
  3. end
Expand to see the code.

Then use $game_map.events[event_id]?
Jaberwoky wrote:
Add this:
  1. class Interpreter
  2.   attr_reader :event_id
  3. end
Expand to see the code.

Then use $game_map.events[event_id]?


Hmm that didnt work out to well.

Tried it out by inserting it into here.
  1. $scene.effect(EVENT_ID, EFFECT, LOCK, X, Y)
  2.  
  3.  
Expand to see the code.


This is the script Im using!
  1. #===============================================================================
  2. # New Particle Engine
  3. #   by arevulopapo
  4. #   Nov 15th 2007
  5. #
  6. # This script lets you create particle effects in your game.
  7. # Particles are integrated into "Spriteset_Map,
  8. # so the can be displayed over/under an event.
  9. # Effects are called from "Script" command like this:
  10. # $scene.effect(EVENT_ID, EFFECT, LOCK, X, Y)
  11. # EVENT_ID  - ID of an event the particles will flow from.
  12. #             (-1) for player, (1) and above for events.
  13. # EFFECT    - name of the effect to call. Names are defined in the Spriteset_Map.
  14. # LOCK      - alignment of the particles. 'event' to align particles
  15. #             with event's map position, 'screen' to align with event's screen position.
  16. #             For static events, like fireplaces, teleports, etc. 'event' alignment is recommended.
  17. #             For moving events use 'screen' mode.
  18. # X, Y      - number of pixels that will be added to the event's position
  19. #             to determine the starting point of particles.
  20. #             That's your most powerful weapon ;) See the demo for examples.
  21. #===============================================================================
  22.  
  23. class Scene_Map
  24.  
  25.   def effect(event=1, effect='', lock='event', x=0, y=0)
  26.     @spriteset.add_effect(event, effect, lock, x, y)
  27.   end
  28.  
  29. end
  30. #===============================================================================
  31. #
  32. #===============================================================================
  33. class Spriteset_Map
  34.  
  35.   attr_reader :particles
  36.  
  37.   alias particle_ssm_init initialize
  38.   alias particle_ssm_update update
  39.   alias particle_ssm_dispose dispose
  40.   #-----------------------------------------------------------------------------
  41.   def initialize
  42.     @particles = []
  43.     particle_ssm_init
  44.   end
  45.   #-----------------------------------------------------------------------------
  46.   def dispose
  47.     @particles.each{ |d| d.dispose }
  48.     particle_ssm_dispose
  49.   end
  50.   #-----------------------------------------------------------------------------
  51.   def update
  52.     @particles.each_with_index{ |p,i|
  53.       @particles[i].update
  54.       if p.opacity == 0
  55.         p.dispose
  56.         @particles.delete_at(i)
  57.       end
  58.       }
  59.     particle_ssm_update
  60.   end
  61.   #-----------------------------------------------------------------------------
  62.   def add_effect(event=1, effect='', lock='event', x=0, y=0)
  63.    
  64.     case event
  65.     when -1
  66.       object = $game_player
  67.     else
  68.       object = $game_map.events[event]
  69.     end
  70.    
  71.     case effect
  72.     # (sprite, acceleration[x,y], gravity[x,y], opacity[base,loss], blending)
  73.     when 'blue'
  74.       sprite='star_blue'
  75.       add_particles(object, x, y, sprite, [1.00*(-15+rand(30))/10, 1.00*(-15+rand(30))/10], [0,0], [160,5+rand(15)], lock, 1)
  76.     when 'red'
  77.       sprite='star_red'
  78.       add_particles(object, x, y, sprite, [1.00*(-15+rand(30))/10, 1.00*(-15+rand(30))/10], [0,0], [160,5+rand(15)], lock, 1)
  79.     when 'green'
  80.       sprite='star_green'
  81.       add_particles(object, x, y, sprite, [1.00*(-15+rand(30))/10, 1.00*(-15+rand(30))/10], [0,0], [160,5+rand(15)], lock, 1)
  82.     when 'yellow'
  83.       sprite='star_yellow'
  84.       add_particles(object, x, y, sprite, [1.00*(-15+rand(30))/10, 1.00*(-15+rand(30))/10], [0,0], [160,5+rand(15)], lock, 1)
  85.     when 'smash'
  86.       sprite='smash'
  87.       add_particles(object, x, y, sprite, [1.00*(-15+rand(30))/10, 1.00*(-15+rand(30))/10], [0,0], [160,5+rand(15)], lock, 1)
  88.     when 'fire'
  89.       sprite='particle_yellow'
  90.       add_particles(object, x, y, sprite, [(rand(7)-3)*0.2, 0], [0,0.15], [255,8+rand(5)], lock, 1)
  91.     when 'fire2'
  92.       sprite='particle_orange'
  93.       add_particles(object, x, y, sprite, [(rand(7)-3)*0.2, 0], [0,0.15], [255,8+rand(5)], lock, 1)
  94.     when 'sparks'
  95.       sprite='particle_red'
  96.       add_particles(object, x, y, sprite, [0.5*(-25+rand(50))/10, -4], [0,-0.5], [255,20], lock, 1)
  97.     when 'smoke'
  98.       sprite='smoke'
  99.       add_particles(object, x, y, sprite, [0.1*(-25+rand(50))/10, 0], [0,0.13], [128,3], lock, 1)
  100.     when 'cells'
  101.       sprite='particle_red'
  102.       dx = 1.00*(-100 + rand(200))/100
  103.       dy = 1.00*(-100 + rand(200))/100
  104.       add_particles(object, x, y, sprite, [5*dx, 5*dy], [0.3*dx,0.3*dy], [255,10], lock, 1)
  105.     end
  106.  
  107.   end
  108.   #-----------------------------------------------------------------------------
  109.   def add_particles(object=$game_player, x=0, y=0, sprite='', acc=[0,0], grav=[0,0], opacity=[255,0], lock='event', blend=0)
  110.     if lock=='event'
  111.       @particles << Particle_Event.new(@viewport1, object, x, y, sprite, acc, grav, opacity, blend)
  112.     elsif lock=='screen'
  113.       @particles << Particle_Screen.new(@viewport1, object, x, y, sprite, acc, grav, opacity, blend)
  114.     end
  115.   end
  116.  
  117. end
  118. #===============================================================================
  119. #
  120. #===============================================================================
  121. class Particle_Screen < Sprite
  122.  
  123.   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)
  124.     super(viewport)
  125.     self.bitmap = RPG::Cache.picture('Particles/' + sprite)
  126.     self.x = object.screen_x + x
  127.     self.y = object.screen_y - 16 + y
  128.     self.ox = self.oy = self.bitmap.width/2
  129.     self.blend_type = blend
  130.     self.opacity = opacity[0]
  131.     @object = object
  132.     @origin = [self.x, self.y]
  133.     @acceleration = acc
  134.     @gravity = grav
  135.     @coords = [0.00, 0.00]
  136.     @opacity = opacity[1]
  137.     update
  138.   end
  139.  
  140.   def update
  141.     @acceleration[0] -= @gravity[0] if @gravity[0] != 0
  142.     @acceleration[1] -= @gravity[1] if @gravity[1] != 0
  143.     @coords[0] += @acceleration[0]
  144.     @coords[1] += @acceleration[1]
  145.     self.opacity -= @opacity
  146.     self.x = @origin[0] + @coords[0]
  147.     self.y = @origin[1] + @coords[1]
  148.     if self.y > (@object.screen_y - 16)
  149.       self.z = @object.screen_z + 32
  150.     else
  151.       self.z = @object.screen_z - 32
  152.     end
  153.   end
  154.  
  155. end
  156.  
  157. class Particle_Event < Sprite
  158.  
  159.   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)
  160.     super(viewport)
  161.     self.bitmap = RPG::Cache.picture('Particles/' + sprite)
  162.     self.x = object.x*32 + 16 - $game_map.display_x / 4 + x
  163.     self.y = object.y*32 + 32 - $game_map.display_y / 4 + y
  164.     self.ox = self.oy = self.bitmap.width/2
  165.     self.blend_type = blend
  166.     self.opacity = opacity[0]
  167.     @object = object
  168.     @origin = [object.x*32 + x + 16, object.y*32 + y + 32]
  169.     @acceleration = acc
  170.     @gravity = grav
  171.     @coords = [0.00, 0.00]
  172.     @opacity = opacity[1]
  173.     update
  174.   end
  175.  
  176.   def update
  177.     @acceleration[0] -= @gravity[0] if @gravity[0] != 0
  178.     @acceleration[1] -= @gravity[1] if @gravity[1] != 0
  179.     @coords[0] += @acceleration[0]
  180.     @coords[1] += @acceleration[1]
  181.     self.opacity -= @opacity
  182.     self.x = @origin[0] + @coords[0] - $game_map.display_x / 4
  183.     self.y = @origin[1] + @coords[1] - $game_map.display_y / 4 - 16
  184.     if self.y > (@object.screen_y - 16)
  185.       self.z = @object.screen_z + 32
  186.     else
  187.       self.z = @object.screen_z - 32
  188.     end
  189.   end
  190.  
  191. end
Expand to see the code.
You can get the ID of "this event" with the following script command:
  1. get_character(0).id
Expand to see the code.


Pass it to EVENT_ID and you're all set.
So I would setup the event like this



  1. get_character(0).id = ID
  2. $scene.effect(ID, smoke, screen, X, Y)
Expand to see the code.


How would i pass it (still a noob scripter)
$scene.effect(get_character(0).id, smoke, screen, X, Y)
Hmm synaxerror occurred...

I think maybe cause when i put in this

$scene.effect(get_character(0).id,'cells','screen')

it turns it into this

$scene.effect(get_character
(0).id,'cells','screen')

but maybe not
Yeah, the script boxes for events are stupidly small.
Try
$scene.effect(
get_character(0).id,
'cells','screen')
Perfect! Thank you much!

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=71136