Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #------------------------------------------------------------------------------#
- # Galv's Encounter Pointer
- #------------------------------------------------------------------------------#
- # For: RPGMAKER VX ACE
- # Version 1.1
- #------------------------------------------------------------------------------#
- # 2013-02-18 - Version 1.1 - fixed bug with changing number of frames
- # 2013-02-18 - Version 1.0 - release
- #------------------------------------------------------------------------------#
- # This script displays a pointer above the player's head that changes
- # depending on how many steps until the next random encounter will happen.
- # This is based off of the feature in the psone game 'Legend of Dragoon'.
- #------------------------------------------------------------------------------#
- # INSTRUCTIONS
- #------------------------------------------------------------------------------#
- # Get image from demo.
- # Put script under Materials and above Main
- # Check settings to see if you want to change anything.
- # Start a new game.
- #------------------------------------------------------------------------------#
- ($imported ||= {})["Galv_Encounter_Pointer"] = true
- module Galv_Enc
- #------------------------------------------------------------------------------#
- # SETUP OPTIONS
- #------------------------------------------------------------------------------#
- #---------------------#
- # Gameplay Options: #
- #---------------------#
- DISABLE_BUTTON = :Y # Button for player to turn it on and off :Y is "s" key
- DISABLE_SWITCH = 1 # Turn ON to turn pointer OFF.
- WARNING_LEVEL = 0.5 # When pointer turns yellow
- DANGER_LEVEL = 0.2 # When pointer turns red
- # The above levels are based on how many steps until encounter and the
- # encounter rate of the area. 0.5 means when steps until encounter has reached
- # 50% of the encounter rate. (So 15 steps in a 30 step zone).
- #---------------------#
- # Graphic Options: #
- #---------------------#
- IMAGE = "encounter_pointer" # The image to use in /Graphics/System/
- FRAMES = 5 # Amount of frames the pointer animation uses
- SPEED = 5 # Speed of animation (higher is slower)
- Z_LEVEL = 100 # Make higher to display above things if it doesn't.
- Y_POSITION = -50 # Y position relevant to the player.
- #------------------------------------------------------------------------------#
- # END SETUP OPTIONS
- #------------------------------------------------------------------------------#
- end
- class Spriteset_Map
- alias galv_enc_point_smap_initialize initialize
- def initialize
- create_enc_symbol
- galv_enc_point_smap_initialize
- end
- def create_enc_symbol
- @enc_symbol = Sprite_EncSymbol.new(@viewport1, $game_player)
- end
- alias galv_enc_point_smap_update update
- def update
- galv_enc_point_smap_update
- @enc_symbol.update
- end
- alias galv_enc_point_smap_dispose dispose
- def dispose
- galv_enc_point_smap_dispose
- dispose_enc_symbol
- end
- def dispose_enc_symbol
- @enc_symbol.dispose if @enc_symbol
- end
- end # Spriteset_Map
- class Sprite_EncSymbol < Sprite_Character
- def initialize(viewport, character = nil)
- super(viewport, character)
- @character = character
- update
- end
- def defaults
- @speed_timer = 0
- @enc_pattern = 1
- @enc_rate = $game_map.encounter_step
- @enc_status = $game_player.encounter_count
- end
- def update
- update_enc_status
- set_enc_bitmap if @enc_pattern.nil?
- update_src_rect
- update_position
- update_other
- end
- def update_enc_status
- steps_left = $game_player.encounter_count.to_f / $game_map.encounter_step.to_f
- if steps_left <= Galv_Enc::DANGER_LEVEL
- @enc_status = 2
- elsif steps_left <= Galv_Enc::WARNING_LEVEL
- @enc_status = 1
- else
- @enc_status = 0
- end
- end
- def set_enc_bitmap
- @enc_pattern ||= 1
- @speed_timer ||= 0
- self.bitmap = Cache.system(Galv_Enc::IMAGE)
- @cw = bitmap.width / Galv_Enc::FRAMES
- @ch = bitmap.height / 3
- self.ox = @cw / 2
- self.oy = @ch
- end
- def update_src_rect
- if @enc_pattern < Galv_Enc::FRAMES
- pattern = @enc_pattern
- else
- @enc_pattern = 1
- pattern = 1
- end
- sx = pattern * @cw
- sy = @enc_status * @ch
- self.src_rect.set(sx, sy, @cw, @ch)
- end
- def update_position
- self.x = @character.screen_x
- self.y = @character.screen_y + Galv_Enc::Y_POSITION
- self.z = Galv_Enc::Z_LEVEL
- end
- def update_other
- @speed_timer += 1
- if @speed_timer > Galv_Enc::SPEED
- @enc_pattern += 1
- @speed_timer = 0
- end
- if !$game_switches[Galv_Enc::DISABLE_SWITCH]
- self.opacity = 255
- else
- self.opacity = 0
- end
- self.visible = !@character.transparent
- end
- end # Sprite_EncSymbol < Sprite_Character
- class Game_Player < Game_Character
- attr_reader :encounter_count
- alias galv_enc_point_player_move_by_input move_by_input
- def move_by_input
- if Input.trigger?(Galv_Enc::DISABLE_BUTTON)
- $game_switches[1] ^= true
- end
- galv_enc_point_player_move_by_input
- end
- end # Game_Player < Game_Character
Advertisement
Add Comment
Please, Sign In to add comment