adiktuzmiko

Auto-Untint Events v1.0

Nov 8th, 2013
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.08 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # Duplicate and Auto-Untint Events v1.00
  4. # by AdiktuzMiko
  5. # --- Date Created: 11/08/2013
  6. # --- Last Date Updated: 11/08/2013
  7. # --- Level: Easy
  8. #
  9. # Allows you to have events that doesn't get affected by screen tint commands
  10. # and allows you to duplicate events from any map to another, and to also place
  11. # these duplicate events on top of one another (useful for things like making
  12. # 3+ layers of decorative events)
  13. #
  14. # Allows you to disable tinting of the character types (player,events,vehicles)
  15. # automatically via regions
  16. #
  17. #==============================================================================
  18. #   ++ How to use ++
  19. #==============================================================================
  20. #
  21. # For making events unaffected by screen tints, simply make sure that it's name
  22. # includes the string set below in the configuration (default: lights)
  23. #
  24. # To duplicate events, simply use this script call
  25. #
  26. # dup_event(mapid,eventid,x,y,view,z)
  27. #
  28. # where:
  29. #
  30. # mapid = Map ID of the map from which the event will be copied from
  31. # eventid = ID of the event to be copied
  32. # x = X tile position on where to put the duplicated event
  33. # y = Y tile position on where to put the duplicated event
  34. # view = Viewport in which to spawn the duplicate event
  35. #        (Set it to 2 or 3 if you want the events to be untinted without
  36. #         having to need to use the untint string on it's name)
  37. # z = Priority of the event
  38. #     0 => Below Characters
  39. #     1 => Same as characters
  40. #     2 => Above characters
  41. #     You can also use any arbitrary number to arrange your events in case
  42. #     you will duplicate more than one event in a single tile
  43. #
  44. # Example:
  45. #
  46. # dup_event(1,2,1,1,1,2.1)
  47. # dup_event(1,1,1,1,1,2)
  48. #
  49. # Since event 2's z is 2.1 and event 1's z is 2: Event 2 will be placed above
  50. # Event 1 in-game
  51. #
  52. # To set-up the character types untint:
  53. #
  54. # Go to the configuration below and set hte untint region and delay
  55. # then start setting your tiles to the right region
  56. #
  57. #==============================================================================
  58. #   ++ Installation ++
  59. #==============================================================================
  60. # Install this script in the Materials section in your project's
  61. # script editor and configure what should be in the name of event's that
  62. # should be untinted (default: lights) and start using it
  63. #
  64. #==============================================================================
  65. #   ++ Compatibility ++
  66. #==============================================================================
  67. # This script overwrites the following default VXA methods:
  68. #
  69. #     Spriteset_Map: create_characters
  70. #     Game_CharacterBase: initialize
  71. #
  72. # and aliases the following methods:
  73. #
  74. #    Game_Event: initialize
  75. #    Game_CharacterBase: update
  76. #
  77. #==============================================================================
  78. #   ++ Terms and Conditions ++
  79. #==============================================================================
  80. #
  81. # Read this: http://lescripts.wordpress.com/terms-and-conditions/
  82. #
  83. #==============================================================================
  84. #   ++ Notes ++
  85. #==============================================================================
  86. #
  87. # 1) Right now, I don't advise using the Duplicate function for events that
  88. # interact with the player
  89. #
  90. # 2) As far as my tests go, the passability of the event in the lowest
  91. #    layer is the one used for the passability of that tile
  92. #
  93. # 3) The auto-untinting via regions doesn't work for duplicated events
  94. #
  95. #==============================================================================
  96. $imported = {} if $imported.nil?
  97. $imported["DupUntint-Adik"] = true
  98.  
  99.  
  100. #======================================================================#
  101. # CONFIGURATION
  102. #======================================================================#
  103. module ADIK
  104.   module EVENTS
  105.     #This sets what string your events' name should have if you want them
  106.     #to be not affected by screen tints
  107.     UNTINT = "lights"
  108.     #Region ID in which all character classes will be untinted
  109.     #Player,Follower,Events and vehicles
  110.     UNTINT_REGION = 1
  111.     #Frame delay between each untint check
  112.     #Lower value = less delay = higher chance of lag
  113.     FRAME_DELAY = 15
  114.   end
  115. end
  116.  
  117. =begin
  118. #======================================================================#
  119. DO NOT EDIT BELOW THIS LINE
  120. #======================================================================#
  121. =end
  122.  
  123. class Game_Event
  124.  
  125.   attr_accessor :event
  126.   attr_accessor :doodad
  127.   attr_accessor :view
  128.   attr_accessor :priority_type
  129.  
  130.   alias adik_init initialize
  131.   def initialize(map_id, event)
  132.     adik_init(map_id,event)
  133.     @view = 1
  134.   end
  135.  
  136.   def get_name
  137.     return @event.name
  138.   end
  139.  
  140. end
  141.  
  142. class Spriteset_Map
  143.  
  144.   def viewport(index)
  145.     case index
  146.       when 1
  147.         return @viewport1
  148.       when 2
  149.         return @viewport2
  150.       when 3
  151.         return @viewport3
  152.       end
  153.   end
  154.  
  155.   def character_sprites
  156.     return @character_sprites
  157.   end
  158.  
  159.   def create_characters
  160.     @character_sprites = []
  161.     $game_map.events.values.each do |event|
  162.       if event.get_name.include?(ADIK::EVENTS::UNTINT)
  163.         @character_sprites.push(Sprite_Character.new(@viewport3, event))
  164.       elsif event.doodad
  165.         @character_sprites.push(Sprite_Character.new(viewport(event.view), event))
  166.       elsif event.region_id == ADIK::EVENTS::UNTINT_REGION
  167.         if event.view > 1
  168.           @character_sprites.push(Sprite_Character.new(viewport(event.view), event))
  169.         else
  170.           @character_sprites.push(Sprite_Character.new(viewport(2), event))
  171.         end
  172.       else
  173.         @character_sprites.push(Sprite_Character.new(@viewport1, event))
  174.       end
  175.     end
  176.     $game_map.vehicles.each do |vehicle|
  177.       if vehicle.region_id == ADIK::EVENTS::UNTINT_REGION
  178.         @character_sprites.push(Sprite_Character.new(@viewport2, vehicle))
  179.       else
  180.         @character_sprites.push(Sprite_Character.new(@viewport1, vehicle))
  181.       end
  182.     end
  183.     $game_player.followers.reverse_each do |follower|
  184.       if follower.region_id == ADIK::EVENTS::UNTINT_REGION
  185.         @character_sprites.push(Sprite_Character.new(@viewport2, follower))
  186.       else
  187.         @character_sprites.push(Sprite_Character.new(@viewport1, follower))
  188.       end
  189.     end
  190.     if $game_player.region_id == ADIK::EVENTS::UNTINT_REGION
  191.       @character_sprites.push(Sprite_Character.new(@viewport2, $game_player))
  192.     else
  193.       @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
  194.     end
  195.     @map_id = $game_map.map_id
  196.   end
  197. end
  198.  
  199. class Game_Interpreter
  200.  
  201.   def dup_event(mapid,eventid,x,y,view,z)
  202.     $game_map.dup_event(mapid,eventid,x,y,view,z)
  203.   end
  204.  
  205. end
  206.  
  207. class Game_Map
  208.   def dup_event(mapid,eventid,x,y,view,z)
  209.     @mapx = load_data(sprintf("Data/Map%03d.rvdata2", mapid))
  210.     event = get_event(@mapx, eventid)
  211.     key = @events.keys.max + 1
  212.     @events[key] = Game_Event.new(@map_id, event)
  213.     @events[key].view = view
  214.     @events[key].priority_type = z
  215.     @events[key].doodad = true
  216.     @events[key].moveto(x,y)
  217.     @events[key].update
  218.     SceneManager.scene.spriteset.refresh_characters
  219.     refresh
  220.     update
  221.   end
  222.  
  223.   def get_event(map, event_id)
  224.     for events in map.events
  225.       event = events[1]
  226.       next if event.nil?
  227.       return event if event.id == event_id
  228.     end
  229.     return nil
  230.   end
  231. end
  232.  
  233. class Scene_Map
  234.   def spriteset
  235.     return @spriteset
  236.   end
  237. end
  238.  
  239. class Game_CharacterBase
  240.  
  241.   attr_accessor :regionid
  242.   attr_accessor :reg_count
  243.  
  244.   def initialize
  245.     init_public_members
  246.     init_private_members
  247.     @regionid = 0
  248.     @reg_count = 0
  249.   end
  250.  
  251.   alias adik_update update
  252.   def update
  253.     adik_update
  254.     @reg_count += 1
  255.     if @reg_count == ADIK::EVENTS::FRAME_DELAY
  256.       @reg_count = 0
  257.     else
  258.       return
  259.     end
  260.     if region_id != @regionid and self.character_name != ""
  261.       @regionid = region_id
  262.       SceneManager.scene.spriteset.refresh_characters
  263.     end
  264.   end
  265. end
Advertisement
Add Comment
Please, Sign In to add comment