Guest User

Untitled

a guest
Oct 24th, 2015
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.68 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. #  ▼ Self-Switch Reset
  3. #  Author: Kread-EX
  4. #  Version 1.0
  5. #  Release date: 03/02/2012
  6. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  7.  
  8. #-------------------------------------------------------------------------------------------------
  9. #  ▼ TERMS OF USAGE
  10. #-------------------------------------------------------------------------------------------------
  11. # #  You are free to adapt this work to suit your needs.
  12. # #  You can use this work for commercial purposes if you like it.
  13. # #  Credit is appreciated.
  14. # #
  15. # # For support:
  16. # # grimoirecastle.wordpress.com
  17. # # OR
  18. # # rpgmakervxace.net
  19. # # OR
  20. # # rpgrevolution.com
  21. #-------------------------------------------------------------------------------------------------
  22. #  ▼ INTRODUCTION
  23. #-------------------------------------------------------------------------------------------------
  24. # # Automatically reset self-switches upon transferring to another map.
  25. #-------------------------------------------------------------------------------------------------
  26. #  ▼ INSTRUCTIONS
  27. #-------------------------------------------------------------------------------------------------
  28. # # You'll have to put a flag in the event's name:
  29. # # /SSR[letter]
  30. # # The letter can be A, B, C or D. It will reset the self-switch from D to that
  31. # # letter. Basically, if you put C, D and C will be reset. If you put D, only D.
  32. # # If you put A, then all letters will be.
  33. #-------------------------------------------------------------------------------------------------
  34. #  ▼ COMPATIBILITY
  35. #-------------------------------------------------------------------------------------------------
  36. # # List of aliases and overwrites:
  37. # # Game_Event
  38. # # ssr (new method)
  39. # # name (new method)
  40. # #
  41. # # Scene_Map
  42. # # perform_transfer (alias)
  43. #-------------------------------------------------------------------------------------------------
  44.  
  45. $imported = {} if $imported.nil?
  46. $imported['KRX-SelfSwitchReset'] = true
  47.  
  48. puts 'Load: Self-Switch Reset v1.0 by Kread-EX'
  49.  
  50. module KRX
  51.  
  52.   module REGEXP
  53.     SSR = /\/SSR\[(\w+)\]/i
  54.   end
  55.  
  56. end
  57.  
  58. #===========================================================================
  59. # ■ Game_Event
  60. #===========================================================================
  61.  
  62. class Game_Event < Game_Character
  63.     #--------------------------------------------------------------------------
  64.     # ● Determine if the event's self-switches will be resetted
  65.     #--------------------------------------------------------------------------
  66.     def ssr
  67.     result = KRX::REGEXP::SSR.match(name)
  68.     result.nil? ? nil : $1
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # ● Returns the event's name
  72.   #--------------------------------------------------------------------------
  73.   def name
  74.     @event.name
  75.   end
  76. end
  77.  
  78. #===========================================================================
  79. # ■ Scene_Map
  80. #===========================================================================
  81.  
  82. class Scene_Map < Scene_Base
  83.   #--------------------------------------------------------------------------
  84.   # ● Map transfer
  85.   #--------------------------------------------------------------------------
  86.   alias_method(:krx_ssr_sm_pt, :perform_transfer)
  87.   def perform_transfer
  88.     values = ['D', 'C', 'B', 'A']
  89.     $game_map.events.values.each do |event|
  90.       letter = event.ssr
  91.       next if letter.nil?
  92.       index = values.index(letter)
  93.       (0..index).each do |i|
  94.         $game_self_switches[[$game_map.map_id, event.id, values[i]]] = false
  95.       end
  96.     end
  97.     krx_ssr_sm_pt
  98.   end
  99. end
Advertisement
Add Comment
Please, Sign In to add comment