ezmash

Large Event Collision (VX Ace)

Jul 14th, 2016
814
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.13 KB | None | 0 0
  1. # Use a comment with <collide: a b>
  2. # to specify an event that takes up a tiles horizontally and b tiles vertically,
  3. # going to the right and up from the event location
  4. #
  5. # <collide: 2 3>
  6. # represents an event that takes up its own tile and the one to the right, as well
  7. # as the two tiles above each of those
  8.  
  9.  
  10. class Game_Event < Game_Character
  11.   alias shaz_large_event_collision_clear_page_settings clear_page_settings
  12.   alias shaz_large_event_collision_setup_page_settings setup_page_settings
  13.  
  14.   def clear_page_settings
  15.     shaz_large_event_collision_clear_page_settings
  16.     @collide_width = 0
  17.     @collide_height = 0
  18.   end
  19.  
  20.   def setup_page_settings
  21.     shaz_large_event_collision_setup_page_settings
  22.     @collide_width = 0
  23.     @collide_height = 0
  24.     return if empty?
  25.     @list.select{|cmd|
  26.       [108,408].include?(cmd.code) &&
  27.       cmd.parameters[0].to_s =~ /<collide: (\d+)\s*(\d+)>/}.each {|cmd|
  28.         @collide_width = $1.nil? ? 0 : ($1.to_i)
  29.         @collide_height = $2.nil? ? 0 : ($2.to_i)
  30.     }
  31.   end
  32.  
  33.   def pos?(x,y)
  34.     x.between?(@x, @x + @collide_width) && y.between?(@y - @collide_height, @y)
  35.   end
  36. end
Advertisement
Add Comment
Please, Sign In to add comment