Group: Revolutionary
Posts: 168
Type: Artist
RM Skill: Advanced
Rei Limited Vision v.1.2 (June 21th 2009) by reijubv
This script can be evented, but I'm too lazy for that, so I made this script. It'll limit player's visibility using a picture, the range of player's visibility can be modified easily, when player is dashing, visibility will be reduced, and with a flashlight button, visibility can be increased (will looks better with Player Plus script), even if you use KTS, visibility range will be adjusted depends on the time phase.
Now you can also use as many picture as you want, or even changing it's tone color, so you don't need to create a many same pictures with different colors.
Changelog:
CODE
V.1.0 (12-06-09) = Initial release V.1.1 (15-06-09) = > Fixed a bug that this script can't be turned off.... > Deleted some unused lines in the script > Can use as many visibility picture that can be changed easily > Can change color tone of the picture V.1.2 (21-06-09) = > Now visibility range can be affected by a party member's states > Compatible with KGC's DayNight
#=============================================================================== # †[VX] †Rei Limited Vision ††# †Limit player's visibility with a picture †#------------------------------------------------------------------------------- # †by reijubv [aruyasoft@comic.com] # †Rpgrevolution.com # †Released on: 12/06/2009 # †Version: 1.2 (June 21th 2009) #------------------------------------------------------------------------------- # > Changelog: # V.1.0 (12-06-09) = Initial release # V.1.1 (15-06-09) = > Fixed a bug that this script can't be turned off.... # > Deleted some unused lines in the script # > Can use as many visibility picture that can be changed # easily # > Can change color tone of the picture # V.1.2 (21-06-09) = > Now visibility range can be affected by a party member's # states # > Compatible with KGC's DayNight #------------------------------------------------------------------------------- # This script can limit player's visibility range using a picture, when player # is running around, this range will be reduced, and with KTS, player can have # different visibility range depends on the time phase. # Even that this kind of script can be easily evented, this script won't give you # any lag problems (hopefully) like using parallel processes... #------------------------------------------------------------------------------- # You might really need a VERY LARGE picture for the visibility! # About 2000x2000 pixels or more might needed (if you reduce visibility range # a lot) # This demo uses 2048x2048 pixels. # Sorry for the bad samples ^^; #------------------------------------------------------------------------------- # How to use : # Turn on the switches defined below, setup the variables, test the game. #------------------------------------------------------------------------------- # To make a state that affect your visibility range, simply write this line # in state's note box : # %mod (num) # Change (num) with a number you want to sub/add the visibility range. # Example : # %mod -70 = > Will reduces visibility range by 70% # %mod 120 = > Will increases visibility range by 120% # or see demo's Database on States tab, see Blind and True Sight states... #------------------------------------------------------------------------------- # Credits: # Reijubv # Thanks to : # Woratana for his picture under character script #------------------------------------------------------------------------------- # Installation: # Place above Main, setup below.. #===============================================================================
$imported = {} if $imported == nil $imported["ReiLimitedVision"] = true
#--------------------------------------------------------------------------- # ** Rei Module #--------------------------------------------------------------------------- module Rei module LimitedVision TOG = 11 # Switch Id to activate this script HFR = 72 # How far is the picture's placement from the player # 0 is on the player , negative is behind, positive is in front IZX = 130 # Initial horizontal zoom % of the visibility IZY = 130 # Initial vertical zoom % of the visibility # negative = reduce, positive = add RUN = -30 # When player's running, visibility will be added/reduced to this % STD = 50 # When player's didn't running, visibility will be added/reduced to # this % LGT = 15 # Switch Id to activate "player has a flashlight" that can increase # or reduce visibility when flashlight is active BUT = Input::F5 # Player must press this button to activate the flashlight RWL = 20 # When player's running (flashlight on), visibility will be # added/reduced to this % SWL = 80 # When player's didn't running (flashlight on), visibility will be # added/reduced to this % DLY = 20 # Delay to change visibility in frames (60frames=1sec) # Higher values are smoother, but may looks weird when running..
KTS = false # true = Using KTS, false = not using KTS KGC = false # true = Using KGC's DayNight, false = no (V.1.2)
# Below is only usable if KTS = true or KGC = true
# Above percentage will be added with these..
# -- For Indoor Maps (Maps without [KTS] OR maps WITH [DN_VOID]) -- INT = -50 # At the night, visibility will be added/reduced to this % IMN = 50 # At the morning, visibility will be added/reduced to this % IDY = 75 # At the day, visibility will be added/reduced to this % IEN = -25 # At the evening, visibility will be added/reduced to this %
# -- For Outdoor Maps (Maps with [KTS] OR maps WITHOUT [DN_VOID] ) -- ONT = -30 # At the night, visibility will be added/reduced to this % OMN = 75 # At the morning, visibility will be added/reduced to this % ODY = 100 # At the day, visibility will be added/reduced to this % OEN = -10 # At the evening, visibility will be added/reduced to this %
# V.1.1 #---- VSP = [] # < Don't edit or remove this #----
USV = 1 # Variable Id used to change visibility. # To change it, just set variable value to one of the number below
SET = 1 # Set this switch Id on if you want the visibility picture's # tone to be changed with the one below.
TON = Tone.new(255,255,255,255) # To change TON variable in game, # use REI::LIMITEDVISION::TON = Tone.new(r,g,b,a) # Example : REI::LIMITEDVISION::TON = Tone.new(255,0,0,255) # r = red, g = green, b = blue, a = alpha/grey end end
#------------------------------------------------------------------------------ # Module RPG #------------------------------------------------------------------------------ module RPG class State def mod_vis self.note.each_line {|line| return line.gsub!('%mod ', '').chomp.to_i if line.include?('%mod ') } return 0 end end end #============================================================================== # ** Scene_Map #------------------------------------------------------------------------------ # This class performs the map screen processing. #============================================================================== class Scene_Map < Scene_Base # Alias things alias reilimitedvisioninit initialize unless method_defined?('reilimitedvisioninit') alias reilimitedvisionstart start unless method_defined?('reilimitedvisionstart') alias reilimitedvisionupdate update unless method_defined?('reilimitedvisionupdate') alias reilimitedvisionterminate terminate unless method_defined?('reilimitedvisionterminate') #-------------------------------------------------------------------------- # * Initialize #-------------------------------------------------------------------------- def initialize $reivisibility_sprite = Game_Picture.new(21) reilimitedvisioninit end #-------------------------------------------------------------------------- # * Start processing #-------------------------------------------------------------------------- def start if $game_switches[Rei::LimitedVision::TOG] index = $game_variables[Rei::LimitedVision::USV] @pic = Rei::LimitedVision::VSP[index] $reivisibility_sprite.show(@pic,1,getvis[0],getvis[1], Rei::LimitedVision::IZX+Rei::LimitedVision::STD+mod_state_range[0], Rei::LimitedVision::IZY+Rei::LimitedVision::STD+mod_state_range[1],255, 0) dovisibilitythingy(1) @showed = true end reilimitedvisionstart end #-------------------------------------------------------------------------- # * Get modified range by states #-------------------------------------------------------------------------- def mod_state_range result = [0,0] for actor in $game_party.members next if actor.states.empty? for state in actor.states next if state.nil? or state.mod_vis == 0 zoomx = state.mod_vis zoomy = state.mod_vis result = [zoomx,zoomy] end end return result end #-------------------------------------------------------------------------- # * Setup visibility coordinate #-------------------------------------------------------------------------- def getvis result = [] case $game_player.direction when 2 x = $game_player.screen_x y = $game_player.screen_y + Rei::LimitedVision::HFR when 4 x = $game_player.screen_x - Rei::LimitedVision::HFR y = $game_player.screen_y when 6 x = $game_player.screen_x + Rei::LimitedVision::HFR y = $game_player.screen_y when 8 x = $game_player.screen_x y = $game_player.screen_y - Rei::LimitedVision::HFR end result = [x,y] return result end #-------------------------------------------------------------------------- # * Setup visibility #-------------------------------------------------------------------------- def dovisibilitythingy(dur = Rei::LimitedVision::DLY) zoomx = Rei::LimitedVision::IZX + mod_state_range[0] zoomy = Rei::LimitedVision::IZY + mod_state_range[1] opa = 255 if Rei::LimitedVision::KTS == true if $kts_map_data[$game_map.map_id].outside_tint? zoomx += Rei::LimitedVision::ONT if $game_switches[KTS::NIGHT] zoomy += Rei::LimitedVision::ONT if $game_switches[KTS::NIGHT] zoomx += Rei::LimitedVision::OMN if $game_switches[KTS::DAWN] zoomy += Rei::LimitedVision::OMN if $game_switches[KTS::DAWN] zoomx += Rei::LimitedVision::ODY if $game_switches[KTS::DAY] zoomy += Rei::LimitedVision::ODY if $game_switches[KTS::DAY] zoomx += Rei::LimitedVision::OEN if $game_switches[KTS::SUNSET] zoomy += Rei::LimitedVision::OEN if $game_switches[KTS::SUNSET] else zoomx += Rei::LimitedVision::INT if $game_switches[KTS::NIGHT] zoomy += Rei::LimitedVision::INT if $game_switches[KTS::NIGHT] zoomx += Rei::LimitedVision::IMN if $game_switches[KTS::DAWN] zoomy += Rei::LimitedVision::IMN if $game_switches[KTS::DAWN] zoomx += Rei::LimitedVision::IDY if $game_switches[KTS::DAY] zoomy += Rei::LimitedVision::IDY if $game_switches[KTS::DAY] zoomx += Rei::LimitedVision::IEN if $game_switches[KTS::SUNSET] zoomy += Rei::LimitedVision::IEN if $game_switches[KTS::SUNSET] end elsif Rei::LimitedVision::KGC == true if $game_map.daynight_void? phase = KGC::DayNight::PHASE_VARIABLE zoomx += Rei::LimitedVision::ODY if phase == 0 zoomy += Rei::LimitedVision::ODY if phase == 0 zoomx += Rei::LimitedVision::OEN if phase == 1 zoomy += Rei::LimitedVision::OEN if phase == 1 zoomx += Rei::LimitedVision::ONT if phase == 2 zoomy += Rei::LimitedVision::ONT if phase == 2 zoomx += Rei::LimitedVision::OMN if phase == 3 zoomy += Rei::LimitedVision::OMN if phase == 3 else phase = KGC::DayNight::PHASE_VARIABLE zoomx += Rei::LimitedVision::IDY if phase == 0 zoomy += Rei::LimitedVision::IDY if phase == 0 zoomx += Rei::LimitedVision::IEN if phase == 1 zoomy += Rei::LimitedVision::IEN if phase == 1 zoomx += Rei::LimitedVision::INT if phase == 2 zoomy += Rei::LimitedVision::INT if phase == 2 zoomx += Rei::LimitedVision::IMN if phase == 3 zoomy += Rei::LimitedVision::IMN if phase == 3 end end if $game_player.moving? and $game_player.dash? zoomx += Rei::LimitedVision::RUN zoomy += Rei::LimitedVision::RUN else zoomx += Rei::LimitedVision::STD zoomy += Rei::LimitedVision::STD end if Input.press?(Rei::LimitedVision::BUT) and $game_switches[Rei::LimitedVision::LGT] if $game_player.moving? and $game_player.dash? zoomx += Rei::LimitedVision::RWL zoomy += Rei::LimitedVision::RWL else zoomx += Rei::LimitedVision::SWL zoomy += Rei::LimitedVision::SWL end end if $game_switches[Rei::LimitedVision::SET] $reivisibility_sprite.start_tone_change(Rei::LimitedVision::TON,0) else $reivisibility_sprite.start_tone_change(Tone.new(0,0,0,0),0) end $reivisibility_sprite.move(1, getvis[0], getvis[1], zoomx,zoomy,opa, 0, dur) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update reilimitedvisionupdate if $game_switches[Rei::LimitedVision::TOG] if @showed == true if @pic != Rei::LimitedVision::VSP[$game_variables[Rei::LimitedVision::USV]] @pic = Rei::LimitedVision::VSP[$game_variables[Rei::LimitedVision::USV]] @showed = false end dovisibilitythingy $reivisibility_sprite.update else if @pic != Rei::LimitedVision::VSP[$game_variables[Rei::LimitedVision::USV]] @pic = Rei::LimitedVision::VSP[$game_variables[Rei::LimitedVision::USV]] end $reivisibility_sprite.show(@pic,1,getvis[0],getvis[1], Rei::LimitedVision::IZX+Rei::LimitedVision::STD+mod_state_range[0], Rei::LimitedVision::IZY+Rei::LimitedVision::STD+mod_state_range[1],255, 0) @showed = true dovisibilitythingy(1) end else if $reivisibility_sprite.name != "" $reivisibility_sprite.erase @showed = false end end end #-------------------------------------------------------------------------- # * Termination Processing #-------------------------------------------------------------------------- def terminate $reivisibility_sprite.erase @showed = false reilimitedvisionterminate end end #============================================================================== #------------------------------------------------------------------------------ # Woratana script, my version #------------------------------------------------------------------------------ class Spriteset_Map alias reicreatepic create_pictures unless method_defined?('reicreatepic') #-------------------------------------------------------------------------- # * Create Picture Sprite #-------------------------------------------------------------------------- def create_pictures(*args);reicreatepic(*args) @picture_sprites.push(Sprite_Picture.new(@viewport1,$reivisibility_sprite)) end end class Sprite_Picture < Sprite alias reipic_upd update unless method_defined?('reipic_upd') #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update(*args);reipic_upd(*args) self.z = $game_player.screen_z + 125 if @picture.number == 21;end end #------------------------------------------------------------------------------ #------------------------------------------------------------------------------
To use the script : Just edit the configuration settings in the script
Installation : Put this script above main
Thanks to : Woratana for his picture under character script Credits : reijubv for making this script.
Hey Reijubv. I was just wondering, is it possible to have difference types of visibility limiting issues. For example, a bacl one like you have already, and a white one for fog, and be able to change between them?
__________________________
To avoid confusion... I'm a guy! xD Current demo officially rated 8.5/10 by RRR's Reviewer; nighthawk282
NICE! This is what I have been looking for... And I know you can do it with events, but I am too lazy for that too. Thank you for this, and I can't wait for the updated versions.
Group: Member
Posts: 28
Type: Writer
RM Skill: Intermediate
Would it work for an ABS script? (any really, when I get to the actual suggestion it'll be apparent)
Because I think it'd be a nice touch if when a Blind state is set on the actor, the "light circle" as I'm going to refer to it as, gets smaller, to hinder the player's view as far as avoiding projectile attacks and successfully hitting an enemy with projectiles as well.
Group: Revolutionary
Posts: 168
Type: Artist
RM Skill: Advanced
whew, sorry for my LATE update, I've got a very serious trouble yesterday ^^ but anyway, I've fixed some bugs and added some more feature as well a demo, please download the demo to see the new feature...
edit::
@jameba Hmm... It is compatible, but the day and night system won't affect your visibility range, I can tweak the script a bit to make a KGC day and night mode..
@thefuneralpyre666 well, what this script does is just limiting visibility with a picture, to do that kind of things, you may need to edit the script (or the abs script!)
Is it a wonder why you're one of my favorites? You, Yanfly, and Originalwij... Three awesome scripters, two of which who are under appreciated. This update is a MAJOR boost to my project. Thank you very much!
Group: Revolutionary
Posts: 168
Type: Artist
RM Skill: Advanced
@evenangels and @Octople_Threat Well, thanks a lot ^^
off topic : Hmm, is there's a particle engine script for VX? Xp has one that was made by arevulopapo, if there's nothing like that in VX, I'll post mine...
@evenangels and @Octople_Threat Well, thanks a lot ^^
off topic : Hmm, is there's a particle engine script for VX? Xp has one that was made by arevulopapo, if there's nothing like that in VX, I'll post mine...
I'm not sure, but I would still like to see it. Please post it?