Advertisement
Szyu

Supervision

Aug 31st, 2013
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.26 KB | None | 0 0
  1. #==============================================================================
  2. # Supervision
  3. # Version 1.0
  4. # By Szyu
  5. #
  6. # About:
  7. # Lets events have a stealth mode, so nobody can see them unless special
  8. # tags are set or you activate supervision. Supervision can also be activated
  9. # by wearing an item.
  10. #
  11. # Instructions:
  12. # - Place below "▼ Materials" but above "▼ Main Process".
  13. #
  14. # How to Use:
  15. # - See comments in Configuration Area
  16. #
  17. # Requires:
  18. # - RPG Maker VX Ace
  19. #
  20. # Terms of Use:
  21. # - Free for commercal and non-commercial use. Please list me
  22. #   in the credits to support my work.
  23. #
  24. # Pastebin:
  25. # http://adf.ly/UteAh
  26. #
  27. #==============================================================
  28. #   * Configuration
  29. #==============================================================
  30. #
  31. # This comment lets an event go to stealth mode
  32. STEALTH_COMMAND = "Stealth"
  33.  
  34. # A stealth event draws a semi-transparent shade on the map
  35. LIGHTSEER_COMMAND = "Lightseer"
  36.  
  37. # You can interact with stealth events without supervision
  38. ST_INTERACT_COMMAND = "Interact"
  39.  
  40. # "Through"-property is always false while stealth
  41. ST_NO_THROUGH_COMMAND = "No_Through"
  42.  
  43. # Event can detected stealthed characters
  44. DETECT_STEALTH_COMMAND = "Detect_Stealth"
  45.  
  46. # Player stealths when such an item is equipped
  47. EQ_STEALTH_NOTE = "<stealth>"
  48.  
  49. # Player switches to supervision mode when such an item is equipped
  50. EQ_SUPER_VISION_NOTE = "<super_vision>"
  51.  
  52. # Opacity of Lightseer Stalth Events
  53. LIGHTSEER_GRADE = 40
  54.  
  55. # Colors the player while supervision
  56. COLOR_SV_PLAYER = false
  57.  
  58. # Sets the "Through"-property for stealth events while not in supervision mode
  59. THROUGH_STEALTH_EVENT = true
  60.  
  61. # Color of supervision
  62. SUPER_VISION_FIELD_COLOR = Tone.new(255,0,255,255)
  63.  
  64. #=====================================================================
  65. # Don't edit below this line
  66. #=====================================================================
  67. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  68. #==============================================================
  69. #   * Super_Vision
  70. #==============================================================
  71. class Super_Vision
  72.  
  73.   attr_accessor :toggled
  74.  
  75.   def initialize
  76.     @toggled = false
  77.   end
  78.  
  79.   def toggle
  80.     @old_tone = $game_map.screen.tone
  81.     case @toggled
  82.     when true;@toggled = false
  83.       $game_map.screen.start_tone_change(Tone.new(0,0,0,0),1)
  84.       if COLOR_SV_PLAYER
  85.         $game_player.blend_type = 0
  86.       end
  87.     when false;@toggled = true
  88.       $game_map.screen.start_tone_change(SUPER_VISION_FIELD_COLOR,1)
  89.       if COLOR_SV_PLAYER
  90.         $game_player.blend_type = 1
  91.       end
  92.     end
  93.   end
  94. end
  95.  
  96. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  97. #==============================================================
  98. #   * DataManager alias
  99. #==============================================================
  100. module DataManager
  101.   class << self
  102.     alias cgo_infrarot create_game_objects
  103.   end
  104.  
  105.   def self.create_game_objects
  106.     cgo_infrarot
  107.     $super_vision = Super_Vision.new
  108.   end
  109. end
  110.  
  111. #==============================================================
  112. #   * Game_Event Properties
  113. #==============================================================
  114. class Game_Event < Game_Character
  115.   alias infrarot_init initialize
  116.   alias infrared_update update
  117.  
  118.   attr_reader :id
  119.  
  120.  
  121.   def initialize(map_id, event)
  122.     @lightseer = lightseer
  123.     @stealth = stealth
  124.     @interact = interact
  125.     infrarot_init(map_id, event)
  126.     @stealth = check_comment(STEALTH_COMMAND)
  127.     @lightseer = check_comment(LIGHTSEER_COMMAND)
  128.     @interact = check_comment(ST_INTERACT_COMMAND)
  129.     @no_through = check_comment(ST_NO_THROUGH_COMMAND)
  130.     @through = false if @no_through
  131.     @detect_stealth = check_comment(DETECT_STEALTH_COMMAND)
  132.     toggle_super_vision
  133.   end
  134.  
  135.   def update
  136.     infrared_update
  137.     toggle_super_vision
  138.   end
  139.  
  140.   def toggle_super_vision
  141.     if @stealth
  142.       case $super_vision.toggled
  143.       when false
  144.         if @lightseer
  145.           @opacity = LIGHTSEER_GRADE if not @opacity == LIGHTSEER_GRADE
  146.         else
  147.           @opacity = 0 if not @opacity == 0
  148.         end
  149.         @through = true if THROUGH_STEALTH_EVENT && !@no_through
  150.       when true
  151.         @opacity = 255
  152.         @blend_type = 1 if not @blend_type== 1
  153.         @through = false if THROUGH_STEALTH_EVENT && @through == true
  154.       end
  155.     else
  156.       case $super_vision.toggled
  157.       when true;@blend_type = 1 if not @blend_type== 1
  158.       when false;@blend_type = 0 if not @blend_type == 0  
  159.       end
  160.     end
  161.   end
  162.  
  163.   def check_comment(comment)
  164.     com = comment.downcase
  165.     return false if @list.nil? or @list.size <= 0
  166.     for item in @list
  167.       if item.code == 108 or item.code == 408
  168.         if item.parameters[0].include?(com)
  169.           return true
  170.         end
  171.       end
  172.     end
  173.     return false
  174.   end
  175.  
  176.   alias szsv_start start
  177.   def start
  178.     return if @stealth && !$super_vision.toggled && !@interact
  179.     return if $game_player.stealth && !@detect_stealth && @trigger == 2
  180.     szsv_start
  181.   end
  182. end
  183.  
  184. #==============================================================
  185. #   * Game_Character proprties
  186. #==============================================================
  187. class Game_Character < Game_CharacterBase
  188.   attr_accessor   :opacity              
  189.   attr_accessor   :blend_type
  190.   attr_accessor :interact
  191.   attr_accessor :lightseer
  192.   attr_accessor :stealth
  193.   attr_accessor :no_through
  194.   attr_accessor :detect_stealth
  195.  
  196.   def toggle_stealth
  197.     case @stealth
  198.     when true
  199.       @stealth = false
  200.       @opacity = 255
  201.       @blend_type = 0
  202.       @through = false if THROUGH_STEALTH_EVENT && @through == true
  203.     when false
  204.       @stealth = true
  205.       @opacity = (@lightseer || self.is_a?(Game_Player)) ? LIGHTSEER_GRADE : 0
  206.       @blendtype = 1
  207.       @through = (THROUGH_STEALTH_EVENT && !@no_through) ? true : false
  208.       @through = false if self.is_a?(Game_Player)
  209.     end
  210.   end
  211. end
  212.  
  213. #==============================================================
  214. #   * Game_Actor change equip
  215. #==============================================================
  216. class Game_Actor < Game_Battler
  217.   alias szsv_change_e change_equip
  218.   def change_equip(slot_id, item)
  219.     szsv_change_e(slot_id, item)
  220.     $game_player.toggle_stealth_sv
  221.   end
  222. end
  223.  
  224. #==============================================================
  225. #   * Game_Player self stealth
  226. #==============================================================
  227. class Game_Player < Game_Character
  228.  
  229.   def toggle_stealth_sv
  230.     st = false
  231.     sv = false
  232.     actor.equips.each do |eq|
  233.       next if !eq
  234.       st = true if eq.stealth?
  235.       sv = true if eq.super_vision?
  236.     end
  237.     @stealth = !st
  238.     toggle_stealth
  239.     $super_vision.toggle if sv != $super_vision.toggled
  240.   end
  241. end  
  242.  
  243. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  244. #==============================================================
  245. #   * Content of Crafting Items
  246. #==============================================================
  247. class RPG::BaseItem
  248.  
  249.   def super_vision?
  250.     return self.note.downcase.include?(EQ_SUPER_VISION_NOTE.downcase)
  251.   end
  252.  
  253.   def stealth?
  254.     return self.note.downcase.include?(EQ_STEALTH_NOTE.downcase)
  255.   end
  256. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement