Rycochet

RPGMaker VX Ace - Zoom Sprites

Sep 15th, 2013
802
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.76 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Rycochet - Zoom Sprites v1.0
  4. # -- Last Updated: 2013.09.15
  5. # -- License: CC BY-NC 3.0 - https://creativecommons.org/licenses/by-nc/3.0/
  6. #
  7. #==============================================================================
  8. # ▼ Updates
  9. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  10. # 2013.09.15 - First Version.
  11. #
  12. #==============================================================================
  13. # ▼ Introduction
  14. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  15. # Allows you to change the zoom level on sprites depending on what they are on
  16. # a per-map basis. This can be used to do things like making the character
  17. # smaller on the main map, or creating a Lilliput village where the character
  18. # is twice the size of the villagers.
  19. #
  20. #==============================================================================
  21. # ▼ Instructions
  22. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  23. # To install this script, open up your script editor and copy/paste this script
  24. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  25. #
  26. # All zoom values are percentages, so 100 is "no change".
  27. #
  28. # You can have multiple tags within single notetag, order is unimportant.
  29. #
  30. # -----------------------------------------------------------------------------
  31. # Map Notetags - These notetags go in the map notebox in a map's properties.
  32. # -----------------------------------------------------------------------------
  33. # <zoom all=x ...>
  34. # Set the zoom level for all sprites.
  35. #
  36. # <zoom player=x ...>
  37. # Set the zoom level for the player *and* followers.
  38. #
  39. # <zoom follower=x ...>
  40. # Set the zoom level for followers only.
  41. #
  42. # <zoom vehicle=x ...>
  43. # Set the zoom level for any vehicles.
  44. #
  45. # <zoom npc=x ...>
  46. # Set the zoom level for npcs, these are classed as any event that can move.
  47. #
  48. # <zoom event=x ...>
  49. # Set the zoom level for any event that has a fixed position.
  50. #
  51. # -----------------------------------------------------------------------------
  52. # Event Comments - These comments must be in the active page and are global.
  53. # -----------------------------------------------------------------------------
  54. # "ZOOM x"
  55. # Set the zoom for this specific event (overrides map notetags).
  56. #
  57. #==============================================================================
  58.  
  59. #==============================================================================
  60. # ▼ Editting anything past this point may potentially result in causing
  61. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  62. # halitosis so edit at your own risk.
  63. #==============================================================================
  64.  
  65. $imported = {} if $imported.nil?
  66. $imported["Rycochet-ZoomSprites"] = true
  67.  
  68. #==============================================================================
  69. # ■ RYCO::REGEXP
  70. #==============================================================================
  71.  
  72. module RYCO
  73.     module REGEXP
  74.         ZOOM_ALL        = /<zoom\s[^>]*all=(\d+)/i
  75.         ZOOM_PLAYER     = /<zoom\s[^>]*player=(\d+)/i
  76.         ZOOM_FOLLOWER   = /<zoom\s[^>]*follower=(\d+)/i
  77.         ZOOM_VEHICLE    = /<zoom\s[^>]*vehicle=(\d+)/i
  78.         ZOOM_EVENT      = /<zoom\s[^>]*event=(\d+)/i
  79.         ZOOM_NPC        = /<zoom\s[^>]*npc=(\d+)/i
  80.         COMMENT_ZOOM    = /ZOOM\s+(\d+)/i
  81.     end # REGEXP
  82. end # RYCO
  83.  
  84. #==============================================================================
  85. # ■ Game_Map
  86. #==============================================================================
  87.  
  88. class Game_Map
  89.     attr_accessor :zoom_event
  90.     attr_accessor :zoom_npc
  91.     attr_accessor :zoom_player
  92.     attr_accessor :zoom_follower
  93.     attr_accessor :zoom_vehicle
  94.  
  95.     #--------------------------------------------------------------------------
  96.     # * Alias method: setup
  97.     #--------------------------------------------------------------------------
  98.     alias game_map_setup_old setup
  99.     def setup(map_id)
  100.         game_map_setup_old(map_id)
  101.  
  102.         @zoom_event = @zoom_npc = @zoom_player = @zoom_follower = @zoom_vehicle = ($1.to_f / 100.0 if @map.note =~ RYCO::REGEXP::ZOOM_ALL) || 1.0
  103.         @zoom_player = @zoom_follower = $1.to_f / 100.0 if @map.note =~ RYCO::REGEXP::ZOOM_PLAYER
  104.         @zoom_follower = $1.to_f / 100.0 if @map.note =~ RYCO::REGEXP::ZOOM_FOLLOWER
  105.         @zoom_vehicle = $1.to_f / 100.0 if @map.note =~ RYCO::REGEXP::ZOOM_VEHICLE
  106.         @zoom_event = $1.to_f / 100.0 if @map.note =~ RYCO::REGEXP::ZOOM_EVENT
  107.         @zoom_npc = $1.to_f / 100.0 if @map.note =~ RYCO::REGEXP::ZOOM_NPC
  108.     end # setup
  109. end # Game_Map
  110.  
  111. #==============================================================================
  112. # ■ Game_Event < Game_Character
  113. #==============================================================================
  114.  
  115. class Game_Event < Game_Character
  116.     attr_accessor :zoom_value
  117.  
  118.     #--------------------------------------------------------------------------
  119.     # * Alias method: clear_starting_flag
  120.     #--------------------------------------------------------------------------
  121.     alias clear_starting_flag_old clear_starting_flag
  122.     def clear_starting_flag
  123.         clear_starting_flag_old
  124.         @zoom_value = nil
  125.         return if empty?
  126.         for item in @list
  127.             if item.code == 108 or item.code == 408
  128.                 if item.parameters[0] =~ RYCO::REGEXP::COMMENT_ZOOM
  129.                     @zoom_value = $1.to_f / 100.0
  130.                     return
  131.                 end
  132.             end
  133.         end
  134.     end
  135.  
  136.     #--------------------------------------------------------------------------
  137.     # * New method: is_moving?
  138.     #--------------------------------------------------------------------------
  139.     def is_moving?
  140.         return @move_type != 0
  141.     end
  142. end
  143.  
  144. #==============================================================================
  145. # ■ Sprite_Character < Sprite_Base
  146. #==============================================================================
  147.  
  148. class Sprite_Character < Sprite_Base
  149.  
  150.     #--------------------------------------------------------------------------
  151.     # * Alias method: update
  152.     #--------------------------------------------------------------------------
  153.     alias sprite_character_update_old update
  154.     def update
  155.         sprite_character_update_old
  156.         zoom = 1.0
  157.         if @character.is_a?(Game_Player)
  158.             zoom = $game_map.zoom_player
  159.         elsif @character.is_a?(Game_Follower)
  160.             zoom = $game_map.zoom_follower
  161.         elsif @character.is_a?(Game_Event)
  162.             if @character.zoom_value.nil?
  163.                 zoom = @character.is_moving? ? $game_map.zoom_npc : $game_map.zoom_event
  164.             elsif
  165.                 zoom = @character.zoom_value
  166.             end
  167.         elsif @character.is_a?(Game_Vehicle)
  168.             zoom = $game_map.zoom_vehicle
  169.         else
  170.             return
  171.         end
  172.         # Backup the old zoom values in case other scripts change them
  173.         @ryco_zoom_x = @ryco_zoom_x || self.zoom_x
  174.         @ryco_zoom_y = @ryco_zoom_y || self.zoom_y
  175.         self.zoom_x = @ryco_zoom_x * zoom
  176.         self.zoom_y = @ryco_zoom_y * zoom
  177.     end
  178. end
Advertisement
Add Comment
Please, Sign In to add comment