New Event Methods

This is a fun little script I made for spicing up events
Try the demo, it's fun
:D

screenshots:
screenshots Spoiler
spawn bunnies:
Image
shooting fireballs
Image
replace bunnies with blood stains :
Image

demo Spoiler

code Spoiler
You'll need to place this dll in the project folder: uabm.dll
Place each script in a new page, my script goes below Additional bitmap methods.
Advanced event commands :
  1. #----------------------------------------------------#
  2. #      Advanced event commands                       #
  3. #                                                    #
  4. #  made by: Silver Wind                              #
  5. #  v1.1                                              #
  6. #----------------------------------------------------#
  7. #     Instructions:                                  #
  8. # -Use one of the following lines inside a           #
  9. #  Conditional Branch (in the script box).           #
  10. #                                                    #
  11. #   event_is_at?(x,y)                                #
  12. #   taken_tile?(x,y)                                 #
  13. #                                                    #
  14. # - To check if 2 events touch, use:                 #
  15. #   event_touch?(event1,event2)                      #
  16. #                                                    #
  17. # -To create a new event, put this code in a         #
  18. #   script box. It can be used for bullets, etc.     #
  19. #                                                    #
  20. #   method 1 :                                       #
  21. #   clone_event(event, x, y, name)                   #
  22. #    - event: name or id of an existing event.       #
  23. #    - name: optional. can be left out.              #
  24. #                                                    #
  25. #   method 2 :                                       #
  26. #   spawn_event(sprite, x, y, name, through) *       #
  27. #   move_route_copy(from,to) **                      #
  28. #                                                    #
  29. #   * name, through, x ,y are all optional.          #
  30. #     by deafult, through=false and name=EV00X       #
  31. #  ** Set the move route of your event.              #
  32. #     from & to can be the event name or the id.     #
  33. #----------------------------------------------------#
  34. class Game_Character
  35.  
  36.   # flag: has a collision occured?
  37.   def collision( flag, x, y )
  38.     return if (self == $game_player)
  39.     @last_collision = @collision
  40.     if not flag
  41.       @collision = nil
  42.     else
  43.       # collision: true
  44.       @collision = [x,y]
  45.     end
  46.   end
  47.  
  48.   def collision?(x,y)
  49.     return (@collision == [x,y] or @last_collision == [x,y] )
  50.   end
  51.  
  52.   def any_collision?
  53.     # @last_collision gives RMXP more time
  54.     # to detect the collision: (the time it takes the event to move 2 tiles.)
  55.     return (@collision != nil or @last_collision != nil )
  56.   end
  57.  
  58.   def passable?(x, y, d)
  59.     if self.is_a?(Game_Event) and self.erased
  60.       return false
  61.     end
  62.     # Get new coordinates
  63.     new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  64.     new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  65.     # If coordinates are outside of map
  66.     unless $game_map.valid?(new_x, new_y)
  67.       # impassable
  68.       # edit: collision with map borders
  69.       collision(true, new_x, new_y)
  70.       return false
  71.     end
  72.     # If through is ON
  73.     if @through
  74.      
  75.       # edit: event is on Through. check collision.
  76.       # collistion with tiles
  77.       tile_colide = ! $game_map.passable?(new_x, new_y, 10 - d)
  78.       # collistion with events
  79.       for event in $game_map.events.values
  80.         if event.x == new_x and event.y == new_y
  81.           event_colide = true
  82.         end
  83.         break if event_colide
  84.       end
  85.       colide = (event_colide or tile_colide)
  86.       collision(colide, new_x, new_y)
  87.      
  88.       # passable
  89.       return true
  90.     end
  91.     # If unable to leave first move tile in designated direction
  92.     unless $game_map.passable?(x, y, d, self)
  93.       # edit: NOT a collision. the event is on a non-passable tile
  94.       # impassable
  95.       return false
  96.     end
  97.     # If unable to enter move tile in designated direction
  98.     unless $game_map.passable?(new_x, new_y, 10 - d)
  99.       # impassable
  100.       # edit: collision with something
  101.       collision(true, new_x, new_y)
  102.       return false
  103.     end
  104.     # Loop all events
  105.     for event in $game_map.events.values
  106.       # If event coordinates are consistent with move destination
  107.       if event.x == new_x and event.y == new_y
  108.         # new - collision will ignore events Through flag
  109.         # need testing
  110.         collision(true, new_x, new_y)  
  111.         # If through is OFF
  112.         unless event.through
  113.           # If self is event
  114.           if self != $game_player
  115.             # impassable
  116.             return false
  117.           end
  118.           # With self as the player and partner graphic as character
  119.           if event.character_name != ""
  120.             # impassable
  121.             return false
  122.           end
  123.         end
  124.       end
  125.     end
  126.     # If player coordinates are consistent with move destination
  127.     if $game_player.x == new_x and $game_player.y == new_y
  128.       # If through is OFF
  129.       unless $game_player.through
  130.         # If your own graphic is the character
  131.         if @character_name != ""
  132.           # impassable
  133.           return false
  134.         end
  135.       end
  136.     end
  137.     # passable
  138.     collision(false, new_x, new_y)
  139.     return true
  140.   end
  141.  
  142. end
  143.  
  144. class Game_Event < Game_Character
  145.   attr_reader   :erased
  146.   attr_reader   :character_name
  147.   attr_reader   :event
  148.   attr_reader   :direction
  149.   attr_reader   :move_frequency
  150.  
  151.   # un used. doesn't seem to work
  152.   def moving_to?(x, y)
  153.     d = @direction
  154.     # Get new coordinates
  155.     new_x = @x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  156.     new_y = @y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  157.     return (new_x == x and new_y == y and not moving?)
  158.   end
  159.  
  160. end
  161.  
  162. class Game_Temp
  163.   attr_accessor  :new_events
  164. end
  165.  
  166. class Game_Character
  167.   attr_reader   :move_route
  168. end
  169.  
  170. class Game_Event
  171.  
  172.   def name
  173.     return @event.name
  174.   end
  175.  
  176.   def get_speed
  177.     return @move_speed
  178.   end
  179.  
  180.   def set_speed(s)
  181.     @move_speed = s
  182.     update
  183.   end
  184.  
  185.   def set_frequency(f)
  186.     @move_frequency = f
  187.     update
  188.   end
  189.  
  190. end
  191.  
  192.  
  193. class Spriteset_Map
  194.  
  195.   def add_sprite(event_id)
  196.     if event_id.is_a?(Array)
  197.       event_id.each {|id| add_sprite(id) }
  198.       return
  199.     end
  200.     id = event_id
  201.     sprite = Sprite_Character.new(@viewport1, $game_map.events[id])
  202.     @character_sprites.push(sprite)
  203.   end
  204.  
  205.   alias new_event_update update
  206.   def update
  207.     event_ids = $game_temp.new_events
  208.     unless event_ids.nil?
  209.       add_sprite(event_ids)
  210.       $game_temp.new_events = nil
  211.     end
  212.     new_event_update
  213.   end
  214.  
  215. end
  216.  
  217. class Game_Map
  218.   attr_reader   :map
  219.  
  220.   alias eventing_initialize initialize
  221.   def initialize
  222.     eventing_initialize
  223.     @groups = Hash.new
  224.   end
  225.  
  226.   def occupied_tile?(x,y)
  227.     return false if @map.events.keys.size ==0
  228.     for i in @map.events.keys
  229.       e = @events[i]
  230.       if (e.x == x) and (e.y==y)
  231.         return true
  232.       end
  233.     end
  234.     # check tiles
  235.     return !passable?(x, y, 0)
  236.   end
  237.  
  238.   def new_event(sprite, x=0, y=0, name=nil, through=false, group=nil)
  239.     ids = @map.events.keys  
  240.     event_id = events_id_max
  241.     # was event_id = (ids.size==0) ? 1 : ((ids.max) +1)
  242.     newx = x
  243.     newy = y
  244.     # if the tile is taken, select an empty nearby tile.
  245.     while (occupied_tile?(newx,newy))
  246.       # advance non equally, to get tiles like: (1,15)
  247.       (rand(1) ==0) ? newx += 1 : newy += 1
  248.     end
  249.     new_event = RPG::Event.new(newx,newy)
  250.     new_event.id = event_id                  
  251.     new_event.name = name.nil? ? "EV00" + event_id.to_s  : name
  252.     # set the graphic of the event
  253.     new_event.pages[0].graphic.character_name = sprite
  254.     new_event.pages[0].through = through
  255.     l = @map.events.keys.length
  256.     @map.events.keys[l]=event_id
  257.     @map.events[event_id]=new_event
  258.     game_event = Game_Event.new(@map_id, new_event)
  259.    
  260.     @events[event_id] = game_event
  261.     add_to_group(event_id, group) if not group.nil?
  262.     # This data is used in Spriteset_Map to add the new sprite.
  263.     if $game_temp.new_events.nil?
  264.       $game_temp.new_events = [event_id]
  265.     else
  266.       $game_temp.new_events.push(event_id)
  267.     end
  268.     return event_id
  269.   end
  270.   #
  271.   #-------------------------------------------------------#
  272.   #       Event Groups                                    #
  273.   # if you have a bunch of projectiles flying around      #
  274.   # and you need to check if any of them hits an event,   #
  275.   # group them under the same name.                       #
  276.   #-------------------------------------------------------#
  277.   def add_to_group(event_id, group)
  278.     @groups[group] = [] if (@groups[group]).nil?
  279.     @groups[group].push(event_id)
  280.   end
  281.   #
  282.   def get_group(name)
  283.     return @groups[name]
  284.   end
  285.   #
  286.   def group_collison?(event1, group)
  287.     events = get_group(group)
  288.     return false if events.nil?
  289.     for event2 in events
  290.       colis = event_touch?(event1, event2)
  291.       return true if colis
  292.     end
  293.     return false
  294.   end
  295.  
  296.   def clone_event(event, x, y, name=nil, group=nil)
  297.     source_event = get_event(event)
  298.     sprite = source_event.character_name
  299.     # create the event
  300.     id = new_event(sprite, x, y, name)
  301.     # copy values from the sent event
  302.     new_event1 = get_event(id)
  303.     new_event1.moveto(x, y)
  304.     new_event1.event.pages = source_event.event.pages
  305.     new_event1.refresh
  306.     @map.events[id] = new_event1
  307.     add_to_group(id, group) if not group.nil?
  308.     return id # new
  309.   end
  310.  
  311.   def events_id_max
  312.     ids = @map.events.keys
  313.     id = (ids.size==0) ? 1 :((ids.max) +1)
  314.   end
  315.  
  316.   # ----------------------------------------------#
  317.   #  these 3 methods are defined again in         #
  318.   #   Additional bitmap methods                   #
  319.   # ----------------------------------------------#
  320.  
  321.   def get_event(key)
  322.      if key.is_a?(String)
  323.       return get_event_by_name(key)
  324.     else
  325.       return get_event_by_id(key)
  326.     end
  327.   end
  328.  
  329.   def get_event_by_name(name)
  330.     for i in @events.keys
  331.       ev = @events[i]
  332.       return ev if ev.name == name
  333.     end
  334.     #p "Error: No such event #{name}"
  335.     return nil
  336.   end
  337.  
  338.   def get_event_by_id(i)
  339.     for k in @events.keys
  340.       ev = @events[k]
  341.       return ev if ev.id== i
  342.     end
  343.     #p "Error: No such event #{name}"
  344.     return nil
  345.   end
  346.  
  347.   # -------------------------------------------------- #
  348.   #   ** event_touch?                                  #
  349.   #  more like event collide. will only return true    #
  350.   #  if one event is moving towards the other event.   #
  351.   # -------------------------------------------------- #
  352.   def event_touch?(event1, event2)
  353.     e1 = get_event(event1)
  354.     e2 = get_event(event2)
  355.     return false if e1.nil? or e2.nil?  
  356.     # known bug: when creatng an event, erasing it,
  357.     # and creating new one with the same name, event.erased = true
  358.     return false if e1.erased or e2.erased
  359.     return ( collision?(event1, event2) )
  360.   end
  361.  
  362.   #
  363.   def collision?(event1, event2)
  364.     e1 = get_event(event1)
  365.     e2 = get_event(event2)
  366.     return true if e1.collision?(e2.x, e2.y)
  367.     return true if e2.collision?(e1.x, e1.y)
  368.     return false
  369.   end
  370.  
  371. end
  372.  
  373. # ------------------------------------------------------------------ #
  374. class Interpreter
  375.  
  376.   attr_reader  :event_id
  377.  
  378.   def get_character(parameter)
  379.     # Branch by parameter
  380.     case parameter
  381.     when -1  # player
  382.       return $game_player
  383.     when 0  # this event
  384.       events = $game_map.events
  385.       return events == nil ? nil : events[@event_id]
  386.     else  # specific event
  387.       events =  $game_map.events
  388.       return events == nil ? nil : get_event(parameter)   #events[parameter]
  389.     end
  390.   end
  391.  
  392.   def get_event(key)
  393.      if key.is_a?(String)
  394.       return get_event_by_name(key)
  395.     else
  396.       return get_event_by_id(key)
  397.     end
  398.   end
  399.  
  400.   def get_event_by_name(name)
  401.     events = $game_map.events
  402.     for i in events.keys
  403.       ev = events[i]
  404.       return ev if ev.name == name
  405.     end
  406.     # Error: No such event
  407.     return nil
  408.   end
  409.  
  410.   def get_event_by_id(i)
  411.     events = $game_map.events
  412.     for k in events.keys
  413.       ev = events[k]
  414.       return ev if ev.id== i
  415.     end
  416.     # Error: No such event
  417.     return nil
  418.   end
  419.  
  420.   def erase_event(event)
  421.     e = get_character(event)
  422.     e.erase
  423.   end
  424.  
  425.   def collision?(event1, event2)
  426.     e1 = get_character(event1)
  427.     e2 = get_character(event2)
  428.     return true if e1.collision?(e2.x, e2.y)
  429.     return true if e2.collision?(e1.x, e1.y)
  430.     return false
  431.   end
  432.  
  433.   # did the event colide with ANYTHING.
  434.   # including trees, and any map event (through is ignored).
  435.   def colide?
  436.     e1 = get_character(0)
  437.     return e1.any_collision?
  438.   end
  439.  
  440.   # -------------------------------------------------- #
  441.   #   ** event_touch?                                  #
  442.   #  event 1,2 : event name or id                      #
  443.   #  more like event collide. will only return true    #
  444.   #  if one event is moving towards the other event.   #
  445.   # -------------------------------------------------- #
  446.   def event_touch?(event2, event1=nil)
  447.     if event1.nil?
  448.       # use the calling event
  449.       event1 = get_character(0).id
  450.     end
  451.     e1 = get_character(event1)
  452.     e2 = get_character(event2)
  453.     return false if e1.nil? or e2.nil?  
  454.     # known bug: when creatng an event, erasing it,
  455.     # and creating new one with the same name, event.erased = true
  456.     return false if e1.erased or e2.erased
  457.     return ( collision?(event1, event2) )
  458.   end
  459.  
  460.     # from, to   : event name or id
  461.   def move_route_copy(from, to)
  462.     events = $game_map.events
  463.     if from.is_a?(String)
  464.       from = get_event_by_name(from)
  465.       from = from.id
  466.     end
  467.     if to.is_a?(String)
  468.       event = get_event_by_name(to)
  469.     else
  470.       event = events[to]
  471.     end
  472.     move = events[from].move_route
  473.     event.force_move_route(move)
  474.     speed = events[from].get_speed
  475.     event.set_speed(speed)
  476.     freq = events[from].move_frequency
  477.     event.set_frequency(freq)
  478.   end
  479.  
  480.   def taken_tile?(x,y)
  481.     player = get_character(-1)
  482.     return true if (player.x==x) and (player.y==y)
  483.     return $game_map.occupied_tile?(x,y)
  484.   end
  485.  
  486.   def below?(event)
  487.     x = get_character(0).x
  488.     ev = get_character(event)
  489.     return event_at?(x, ev.y+1)
  490.   end
  491.  
  492.   def above?(event)
  493.     x = get_character(0).x
  494.     ev = get_character(event)
  495.     return event_at?(x, ev.y-1)
  496.   end
  497.  
  498.   def left_of?(event)
  499.     y = get_character(0).y
  500.     ev = get_character(event)
  501.     return event_at?(ev.x-1, y)
  502.   end
  503.  
  504.   def right_of?(event)
  505.     y = get_character(0).y
  506.     ev = get_character(event)
  507.     return event_at?(ev.x+1, y)
  508.   end
  509.  
  510.   def spawn_event(sprite, x ,y, name, through)
  511.     $game_map.new_event(sprite, x, y, name, through)
  512.   end
  513.  
  514.   def clone_event(event, x=0, y=0, name=nil, group=nil)
  515.     $game_map.clone_event(event, x, y, name, group)
  516.   end
  517.  
  518.   def event_at?(x,y)
  519.     e = get_character(0)
  520.     return (e.x==x and e.y==y)
  521.   end
  522.  
  523.   def group_collison?(group)
  524.     event1 = get_character(0).id
  525.     return $game_map.group_collison?(event1, group)
  526.   end
  527.  
  528.   def swap(event1,event2)
  529.     e = get_character(event1) #$game_map.events
  530.     d = e.direction
  531.     @parameters = [event1, 2, event2, d]
  532.     # set event location
  533.     command_202
  534.   end
  535.  
  536.   # The 1st event will be erased
  537.   def replace(event1, event2)
  538.     swap(event1,event2)
  539.     erase_event(event1)
  540.   end
  541.  
  542. end
  543.  
  544. # ------------------------------------------------------------------ #
  545. # this part was below Additional bitmap methods, but it seems to work here too.
  546. #==============================================================================
  547. # * Edit by Silver Wind
  548. #==============================================================================
  549. class Game_Event
  550.  
  551.   def name
  552.     return @event.name
  553.   end
  554.  
  555. end
  556. #-------------------------------------------------------------------------#
  557. class Game_Map
  558.   def get_event(key)
  559.      if key.is_a?(String)
  560.       return get_event_by_name(key)
  561.     else
  562.       return get_event_by_id(key)
  563.     end
  564.   end
  565.  
  566.   def get_event_by_name(name)
  567.     for i in @events.keys
  568.       ev = @events[i]
  569.       return ev if ev.name == name
  570.     end
  571.     # Error: No such event
  572.     return nil
  573.   end
  574.  
  575.   def get_event_by_id(i)
  576.     for k in @events.keys
  577.       ev = @events[k]
  578.       return ev if ev.id== i
  579.     end
  580.     # Error: No such event
  581.     return nil
  582.   end
  583. end
  584. #-------------------------------------------------------------------------#
  585. class Scene_Map
  586.  
  587.   def bitmap_effect(event, action, amount=nil)
  588.     ev = $game_map.get_event(event)
  589.     sprite = @spriteset.get_sprite(ev)
  590.     return if ev.nil?
  591.     case (action)
  592.     when 'brighten'
  593.       sprite.brighten_by(amount)
  594.     when 'darken'
  595.       sprite.darken_by(amount)
  596.     else
  597.       eval ("sprite.#{action}")
  598.     end
  599. =begin
  600.     when 'invert'
  601.       sprite.invert
  602.     when 'grayscale'
  603.       sprite.grayscale
  604.     when 'hyper_contrast'
  605.       sprite.hyper_contrast
  606.     when 'monochrome'
  607.       sprite.monochrome
  608.     when 'emboss'
  609.       sprite.emboss
  610.     when 'sepia'
  611.       sprite.sepia
  612.     when 'sharpen'
  613.       sprite.sharpen
  614.     when 'soften'
  615.       sprite.soften
  616.     end
  617. =end
  618.   end
  619.  
  620. end
  621. #-------------------------------------------------------------------------#
  622. class Spriteset_Map
  623.  
  624.   def get_sprite(event)
  625.     for sprite in @character_sprites
  626.       ev = sprite.character
  627.       # if it's the same Game_Event object.
  628.       if ev.object_id == event.object_id  
  629.         target_sprite = sprite
  630.       end
  631.     end
  632.     return target_sprite
  633.   end
  634.  
  635. end
  636. #-------------------------------------------------------------------------#
  637. class Sprite_Character < RPG::Sprite
  638.   def brighten_by(x)
  639.     self.bitmap.brighten(x)
  640.   end
  641.  
  642.   def darken_by(x)
  643.     self.bitmap.darken(x)
  644.   end
  645.  
  646.   def invert
  647.     self.bitmap.invert
  648.   end
  649.  
  650.   def grayscale
  651.     self.bitmap.grayscale
  652.   end
  653.  
  654.   def hyper_contrast
  655.     self.bitmap.hyper_contrast
  656.   end
  657.  
  658.   def monochrome
  659.     self.bitmap.monochrome
  660.   end
  661.  
  662.   def emboss
  663.     self.bitmap.emboss
  664.   end  
  665.  
  666.   def sepia
  667.     self.bitmap.sepia
  668.   end
  669.  
  670.   def sharpen
  671.     self.bitmap.sharpen
  672.   end
  673.  
  674.   def soften
  675.     self.bitmap.soften
  676.   end
  677.  
  678.   def update
  679.     super
  680.     # If tile ID, file name, or hue are different from current ones
  681.     if @tile_id != @character.tile_id or
  682.        @character_name != @character.character_name or
  683.        @character_hue != @character.character_hue
  684.       # Remember tile ID, file name, and hue
  685.       @tile_id = @character.tile_id
  686.       @character_name = @character.character_name
  687.       @character_hue = @character.character_hue
  688.       # If tile ID value is valid
  689.       if @tile_id >= 384
  690.         #----------------------------- edit -----------------------------#
  691.         # clone the bitmap before using it for an event.
  692.         bitmap = RPG::Cache.tile($game_map.tileset_name,
  693.           @tile_id, @character.character_hue)
  694.         self.bitmap = bitmap.clone
  695.         #----------------------------------------------------------------#
  696.         self.src_rect.set(0, 0, 32, 32)
  697.         self.ox = 16
  698.         self.oy = 32
  699.       # If tile ID value is invalid
  700.       else
  701.         #----------------------------- edit -----------------------------#
  702.         # clone the bitmap before using it for an event.
  703.         bitmap = RPG::Cache.character(@character.character_name,
  704.           @character.character_hue)
  705.         self.bitmap = bitmap.clone
  706.         #----------------------------------------------------------------#
  707.         @cw = bitmap.width / 4
  708.         @ch = bitmap.height / 4
  709.         self.ox = @cw / 2
  710.         self.oy = @ch
  711.       end
  712.     end
  713.     # Set visible situation
  714.     self.visible = (not @character.transparent)
  715.     # If graphic is character
  716.     if @tile_id == 0
  717.       # Set rectangular transfer
  718.       sx = @character.pattern * @cw
  719.       sy = (@character.direction - 2) / 2 * @ch
  720.       self.src_rect.set(sx, sy, @cw, @ch)
  721.     end
  722.     # Set sprite coordinates
  723.     self.x = @character.screen_x
  724.     self.y = @character.screen_y
  725.     self.z = @character.screen_z(@ch)
  726.     # Set opacity level, blend method, and bush depth
  727.     self.opacity = @character.opacity
  728.     self.blend_type = @character.blend_type
  729.     self.bush_depth = @character.bush_depth
  730.     # Animation
  731.     if @character.animation_id != 0
  732.       animation = $data_animations[@character.animation_id]
  733.       animation(animation, true)
  734.       @character.animation_id = 0
  735.     end
  736.   end
  737.  
  738. end
  739. #-------------------------------------------------------------------------#
  740. class Interpreter
  741.  
  742. def brighten(amount,event=nil)
  743.   #return unless $scene.is_a?(Scene_Map)
  744.    event = get_character(0).id if event.nil?
  745.   $scene.bitmap_effect(event,'brighten',amount)
  746. end
  747.  
  748. def darken(amount,event=nil)
  749.    event = get_character(0).id if event.nil?
  750.   $scene.bitmap_effect(event,'darken',amount)
  751. end
  752.  
  753. def invert(event)
  754.   $scene.bitmap_effect(event,'invert')
  755. end
  756.  
  757. def grayscale(event)
  758.   $scene.bitmap_effect(event,'grayscale')
  759. end
  760.  
  761. def bitmap_effect(action,event=nil,amount=nil)
  762.   event = get_character(0).id if event.nil?
  763.   $scene.bitmap_effect(event,action,amount)
  764. end
  765.  
  766. end
Expand to see the code.

Additional Bitmap Methods 0.9
(it has its own thread here, posted here for convenience)
  1. #==============================================================================
  2. class Bitmap
  3. #------------------------------------------------------------------------------
  4. #Make sure you have uabm.dll in your project folder.
  5. #You can get it from (assuming link is not dead):
  6. #http://www.box.net/shared/9m54d8hkzu
  7. #------------------------------------------------------------------------------
  8.   Brighten = Win32API.new("uabm.dll", "Brighten", "li", "v")
  9.   Darken = Win32API.new("uabm.dll", "Darken", "li", "v")
  10.   Invert = Win32API.new("uabm.dll", "Invert", "l", "v")
  11.   Grayscale = Win32API.new("uabm.dll", "Grayscale", "l", "v")
  12.   Hcontrast = Win32API.new("uabm.dll", "Hcontrast", "l", "v")
  13.   Monochrome = Win32API.new("uabm.dll", "Monochrome", "l", "v")
  14.   Emboss = Win32API.new("uabm.dll", "Emboss", "l", "v")
  15.   Sepia = Win32API.new("uabm.dll", "Sepia", "l", "v")
  16.   Sharpen = Win32API.new("uabm.dll", "Sharpen", "l", "v")
  17.   Soften = Win32API.new("uabm.dll", "Soften", "l", "v")
  18.   #--------------------------------------------------------------------------
  19.   # * Brighten (0...255)
  20.   #--------------------------------------------------------------------------
  21.   def brighten(amount)
  22.     Brighten.call(self.__id__, amount)
  23.   end
  24.   #--------------------------------------------------------------------------
  25.   # * Darken (0...255)
  26.   #--------------------------------------------------------------------------
  27.   def darken(amount)
  28.     Darken.call(self.__id__, amount)
  29.   end
  30.   #--------------------------------------------------------------------------
  31.   # * Invert
  32.   #--------------------------------------------------------------------------
  33.   def invert
  34.     Invert.call(self.__id__)
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # * Grayscale
  38.   #--------------------------------------------------------------------------
  39.   def grayscale
  40.     Grayscale.call(self.__id__)
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # * Hyper Contrast
  44.   #--------------------------------------------------------------------------
  45.   def hyper_contrast
  46.     Hcontrast.call(self.__id__)
  47.   end
  48.   #--------------------------------------------------------------------------
  49.   # * Monochrome
  50.   #--------------------------------------------------------------------------
  51.   def monochrome
  52.     Monochrome.call(self.__id__)
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # * Emboss {buggy}
  56.   #--------------------------------------------------------------------------
  57.   def emboss
  58.     Emboss.call(self.__id__)
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # * Sepia
  62.   #--------------------------------------------------------------------------
  63.   def sepia
  64.     Sepia.call(self.__id__)
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # * Sharpen {will update with numeric value options}
  68.   #--------------------------------------------------------------------------
  69.   def sharpen
  70.     Sharpen.call(self.__id__)
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # * Soften {will update with numeric value options}
  74.   #--------------------------------------------------------------------------
  75.   def soften
  76.     Soften.call(self.__id__)
  77.   end
  78. end
Expand to see the code.

method calls Spoiler
- Replacing an event with a blood graphic:
  1. blood_stain = clone_event("blood")
  2. replace( e, blood_stain )
Expand to see the code.

replace 'e' with the event's name or id.
'blood' is a name of an existing event on the map.
if you don't want to have a blood event already on the map,
you can use:
  1. blood_stain = spawn_event(sprite, x ,y, name, through)
  2.   replace( e, blood_stain )
Expand to see the code.

- check collision with any events in the 'fireballs' group:
first, clone a fireball and group your it under 'fireballs':
clone_event("fireball_event",x,y,name,'fireballs')
in a map event, in cond. branch, use
group_collision?("fireballs")
- check if event is above/below another event:
  1. above?(e)
  2.  below?(e)
  3.  left_of?(e)
  4.  right_of?(e)
Expand to see the code.

replace e with event's name / id number.
- Bitmap methods:
  1. brighten(e, x)
  2.  darken(e, x)
  3.  invert(e)
  4.  grayscale(e)
Expand to see the code.

replace x with a number (1-255, I believe)

Features:
- Includes Additional Bitmap Methods by Untra & Glitchfinder
- Invert /grayscale / lighten/ darken a sprite
- Spawn new events
- Clone events
- Detect event touch event (even if set to Through)
- Organize events in groups
- Detect when collision occurs with any event in the group.
- Check event's x,y easily
- Detect if event is above/below/right/left of another event
- Detect when events collide with anything on the map, including tiles.
- Detect when events hit the map borders.
- Handle the spawned events using script:
- erase event
- swap with another event



I plan on adding new features like a case statement using comments, and an option to use items on a map event.
Tell me if have an idea for other cool features.

Enjoy.
If you use this, credit Untra & Glitchfinder.
😀          😀
😀          😀

😀 😀 😀 😀 😀
😀          😀
😀 😀 😀
Haha, glad you like it untra :thumb:
Oh, don't play in map 002,
That's where I dumped all the non-working events
silver wind wrote:
Oh, don't play in map 002,
That's where I dumped all the non-working events
That's what I call a complementive demo game! XD

Either way, sounds like a cool thing you got there... reminds me a bit of my Map Object Manager concept... ^^

As you were too scared to share the code with us, would you mind at least sharing some basic information about how stuff's set up with those of us who don't like to download demos all the time? :huh:
Thanks :)
and sorry, I'll add the code too + some method calls.
I like what I see... as far as the coding goes, you have a few inconsistencies in style there, but other than that, it looks clean... as for the actual operations on the map, it's amazingly simple to set stuff up there... I can see this being easily turned into an ABS, however, I'm afraid that'll end up as event system clutter XD But yeah, very interesting methods you got in that script!

Keep up the good work. :thumb:
* new demo, uses Additional Bitmap Methods 0.9*

Thanks for the nice comment ^^
I wanted to keep this simple to use,
as my main goal is to provide 'eventers' more possibilities.
You know, those people who avoid scripts and prefer controlling everything from events- at times making complete battle systems with them. This gives them more power.
(a case statement will greatly help too, I should get to that)

Still waiting to hear ideas for new features !
Hey, were working on things as best we can :grin: . The RGSS bitmap processing is fairly unintuitive and hard to code with, which is why things are taking awhile.

If you could help with one thing, could you figure out how to apply the bitmap effects to entire viewports as well? For some of the more advanced effects such as the pixelate, having it work with the entire screen could do some neat things. If you can figure that out, we'll include your script and method calls with the v.1 demo, so people can get a better feel for the neat things that can be done.

Keep up the great work Silver Wind!
Do you mean applying the effect on each bitmap separately?
I can do that.
Monotone, grayscale or pixelate on the entire screen will be cool :D
Edit: seems like sharpen, soften, hyper contrast and emboss create a line around the bitmap, so when used on the tileset they make a grid appear on the map.
I mostly want the pixelate to work, as its seen in most modern videogames (and as far back as the super nintendo even. Which bugs me it took us this long to figure it out 🤔. Having all the effects capable of working on the screen or individually is my goal.

I knew hyper contrast made a white line around the bitmap, but I didn't know the others did too. Can you show a screenshot of each doing that? Mostly for amusement purposes. The new methods have way too many bugs, and pixelate is the most frustrating effect to work with right now.
The good news are, it only seems to effect tiles that cover 32x32 area, not auto tiles or trees, for example.
Content Hidden Spoiler
sharpen:Image
soften:Image
emboss: Image
Um... so making the grass an autotile will actually fix this?
This seems strange to me, as the only reason I can imagine that is by how files are handled, meaning it would have the very same effects at the edges of the autotile file, meaning you'd still get a 'grid' appearance between autotiles, for example.
That is strange, especially considering the individual grass and tree tiles are seperate bitmaps as well. Why the trees aren't recieving the same grid effect as the grass tiles is strange.

Ultimately, the problem should be stemming from the actual design of the grass tile. Its possible some other tilesets with different ground tiles (such as the desert or snowfield tilesets) won't experience this problem, which would confirm this. Does the problem disappear on other tilesets?

Also, when taking screenshots, can you save them as .pngs instead of .jpgs? jpgs kinda "blur" the pixels when saved, and its harder to accurately judge the look of the image. Thanks for beta testing this!
Interesting. When I use the same grass tile, but its located somewhere else on the tileset (other than the top-left most tile), the grid is less apparent, or doesn't show up at all:
Content Hidden Spoiler
using grass tile on other location:
Image
here the 2 ground tiles are identical, but only the one on top-left gets a grid:
Image

some other 32x32 tiles don't get grid.
It's simple, really. It's because it's modifying the tileset itself, meaning that the grid you see is spillover from the tiles next to the ones you actually see on the map. In other words, there isn't really a way to fix it, in some cases.
Ahh... Thats why.
Yeah, there really isn't a fix for that in those cases. The hyper contrast, soften, sharpen and emboss methods are influenced by the surrounding pixels, so they can't work overtop entire tilesets. They can really only work with event graphics or other things. This does mean that frost can't work with the tileset as well, and pixelate will be limited to blocks of 32, 16, 8, 4, and 2 on the tileset.

Can you get some of the effects to work on other viewports, such as the panorama or fog layers?
As for what Glitch said, that's perfectly reasonable and I have no clue how I didnt think of that ^^ Now, to solve this...

Obviously, making tilesets containing 9 of each tiles would work out fine (just using the middle tile), however, that'd be insanely unfriendly to every non-robot. However, to fix this, it needs a few additional pixels to the side of the tile, so if you could get that to work in a virtual graphic instance (as in cutting out a tile, placing it on a 96x96 raster, then draw the map from there using only the central 32x32), that'd be perfectly operational. I've been too much into Gosu lately to remember RMXP's exact functions, so I can't give any details... however, this should work some way or the other, however would require storing all (now 96x96px-sized) tiles in the cache seperately and calling them by a cropping function.
This assumes tiles that are 32x32 by themselves with no adjacent colors will be blurred at the sides, causing transparency. I don't know if that actually happens the way you process them, however, if you found a way around that, storing the 32x32 tile will do. Bottom line is, though: You have to store individual tiles instead of applying the effects to the entire tileset.
@Bluescope: yeah no.
Thats a lot of scripting I don't think I'm ready for, or even know how to do ( in C or RGSS). Maybe once I have everything on the checklist checked off I'll attempt it.
It's a lot of pointless scripting, is what it is. You would have to either create the tiles by hand, or script them together. The first option is insanely time-consuming and mind-numbingly dull. The second one takes a lot of resources and has the potential to lag RM* so much that it crashes with a script is hanging error.
Don't forget there are 6 effects that DO work on tilesets: Brighten/Darken/Grayscale/Invert/Sepia/Monochrome.
Those do not move pixels so they should work will all tilesets. When you think about it, few users will actually need to emboss a tileset. These 6 effects will see much more use.
No need to be so harsh :<

All I'm trying to do is giving a nudge on how to go about this. As RGSS(2) doesn't support tileable cropping of a sprite, that's the next best I've been trying to come up with. I'm not saying it's worth it, easy or necessary at all... just trying to help a fellow scripter out :x

...and I really can imagine this to work fluently, done in C...

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