Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Supervision
- # Version 1.0
- # By Szyu
- #
- # About:
- # Lets events have a stealth mode, so nobody can see them unless special
- # tags are set or you activate supervision. Supervision can also be activated
- # by wearing an item.
- #
- # Instructions:
- # - Place below "▼ Materials" but above "▼ Main Process".
- #
- # How to Use:
- # - See comments in Configuration Area
- #
- # Requires:
- # - RPG Maker VX Ace
- #
- # Terms of Use:
- # - Free for commercal and non-commercial use. Please list me
- # in the credits to support my work.
- #
- # Pastebin:
- # http://adf.ly/UteAh
- #
- #==============================================================
- # * Configuration
- #==============================================================
- #
- # This comment lets an event go to stealth mode
- STEALTH_COMMAND = "Stealth"
- # A stealth event draws a semi-transparent shade on the map
- LIGHTSEER_COMMAND = "Lightseer"
- # You can interact with stealth events without supervision
- ST_INTERACT_COMMAND = "Interact"
- # "Through"-property is always false while stealth
- ST_NO_THROUGH_COMMAND = "No_Through"
- # Event can detected stealthed characters
- DETECT_STEALTH_COMMAND = "Detect_Stealth"
- # Player stealths when such an item is equipped
- EQ_STEALTH_NOTE = "<stealth>"
- # Player switches to supervision mode when such an item is equipped
- EQ_SUPER_VISION_NOTE = "<super_vision>"
- # Opacity of Lightseer Stalth Events
- LIGHTSEER_GRADE = 40
- # Colors the player while supervision
- COLOR_SV_PLAYER = false
- # Sets the "Through"-property for stealth events while not in supervision mode
- THROUGH_STEALTH_EVENT = true
- # Color of supervision
- SUPER_VISION_FIELD_COLOR = Tone.new(255,0,255,255)
- #=====================================================================
- # Don't edit below this line
- #=====================================================================
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #==============================================================
- # * Super_Vision
- #==============================================================
- class Super_Vision
- attr_accessor :toggled
- def initialize
- @toggled = false
- end
- def toggle
- @old_tone = $game_map.screen.tone
- case @toggled
- when true;@toggled = false
- $game_map.screen.start_tone_change(Tone.new(0,0,0,0),1)
- if COLOR_SV_PLAYER
- $game_player.blend_type = 0
- end
- when false;@toggled = true
- $game_map.screen.start_tone_change(SUPER_VISION_FIELD_COLOR,1)
- if COLOR_SV_PLAYER
- $game_player.blend_type = 1
- end
- end
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #==============================================================
- # * DataManager alias
- #==============================================================
- module DataManager
- class << self
- alias cgo_infrarot create_game_objects
- end
- def self.create_game_objects
- cgo_infrarot
- $super_vision = Super_Vision.new
- end
- end
- #==============================================================
- # * Game_Event Properties
- #==============================================================
- class Game_Event < Game_Character
- alias infrarot_init initialize
- alias infrared_update update
- attr_reader :id
- def initialize(map_id, event)
- @lightseer = lightseer
- @stealth = stealth
- @interact = interact
- infrarot_init(map_id, event)
- @stealth = check_comment(STEALTH_COMMAND)
- @lightseer = check_comment(LIGHTSEER_COMMAND)
- @interact = check_comment(ST_INTERACT_COMMAND)
- @no_through = check_comment(ST_NO_THROUGH_COMMAND)
- @through = false if @no_through
- @detect_stealth = check_comment(DETECT_STEALTH_COMMAND)
- toggle_super_vision
- end
- def update
- infrared_update
- toggle_super_vision
- end
- def toggle_super_vision
- if @stealth
- case $super_vision.toggled
- when false
- if @lightseer
- @opacity = LIGHTSEER_GRADE if not @opacity == LIGHTSEER_GRADE
- else
- @opacity = 0 if not @opacity == 0
- end
- @through = true if THROUGH_STEALTH_EVENT && !@no_through
- when true
- @opacity = 255
- @blend_type = 1 if not @blend_type== 1
- @through = false if THROUGH_STEALTH_EVENT && @through == true
- end
- else
- case $super_vision.toggled
- when true;@blend_type = 1 if not @blend_type== 1
- when false;@blend_type = 0 if not @blend_type == 0
- end
- end
- end
- def check_comment(comment)
- com = comment.downcase
- return false if @list.nil? or @list.size <= 0
- for item in @list
- if item.code == 108 or item.code == 408
- if item.parameters[0].include?(com)
- return true
- end
- end
- end
- return false
- end
- alias szsv_start start
- def start
- return if @stealth && !$super_vision.toggled && !@interact
- return if $game_player.stealth && !@detect_stealth && @trigger == 2
- szsv_start
- end
- end
- #==============================================================
- # * Game_Character proprties
- #==============================================================
- class Game_Character < Game_CharacterBase
- attr_accessor :opacity
- attr_accessor :blend_type
- attr_accessor :interact
- attr_accessor :lightseer
- attr_accessor :stealth
- attr_accessor :no_through
- attr_accessor :detect_stealth
- def toggle_stealth
- case @stealth
- when true
- @stealth = false
- @opacity = 255
- @blend_type = 0
- @through = false if THROUGH_STEALTH_EVENT && @through == true
- when false
- @stealth = true
- @opacity = (@lightseer || self.is_a?(Game_Player)) ? LIGHTSEER_GRADE : 0
- @blendtype = 1
- @through = (THROUGH_STEALTH_EVENT && !@no_through) ? true : false
- @through = false if self.is_a?(Game_Player)
- end
- end
- end
- #==============================================================
- # * Game_Actor change equip
- #==============================================================
- class Game_Actor < Game_Battler
- alias szsv_change_e change_equip
- def change_equip(slot_id, item)
- szsv_change_e(slot_id, item)
- $game_player.toggle_stealth_sv
- end
- end
- #==============================================================
- # * Game_Player self stealth
- #==============================================================
- class Game_Player < Game_Character
- def toggle_stealth_sv
- st = false
- sv = false
- actor.equips.each do |eq|
- next if !eq
- st = true if eq.stealth?
- sv = true if eq.super_vision?
- end
- @stealth = !st
- toggle_stealth
- $super_vision.toggle if sv != $super_vision.toggled
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #==============================================================
- # * Content of Crafting Items
- #==============================================================
- class RPG::BaseItem
- def super_vision?
- return self.note.downcase.include?(EQ_SUPER_VISION_NOTE.downcase)
- end
- def stealth?
- return self.note.downcase.include?(EQ_STEALTH_NOTE.downcase)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement