See-Through Scenery Script
See-Through Scenery ScriptAnother very simple edit I have made so you can see Characters (events in general) behind trees, houses and so on. It just changes a couple of lines in some methods in the SpriteSet_Map and Sprite_Character, so it isn't a big deal, really. But the result is quite useful and looks good
Preview
A GIF I put out showing Aluxes getting behind trees and whatnot, and he's always visible!
How to Use
Once you imported the script, you're seeing through all scenery! If you want to alter the settings during gameplay, all you need to do is call for the following, whenever you want to change the parameters:
[*]$see_thru_actor = true/false -Activates/Deactivates seeing through the scenery above the actor.
[*]$see_thru_events = true/false -Activates/Deactivates seeing through the scenery above events.
[*]$see_thru_opacity = 0-100 - Adjusts the opacity percentage applied to the opacity value of sprites that are behind scenery or behind other sprites
Demo
See-through Scenery.zip
Script (Moderator edit - the contents of this spoiler have become corrupted. Please see post #2 for a clean version.)
Insert this script above Main, and below others:
Code:
#==============================================================================# SEE THROUGH SCENERY#------------------------------------------------------------------------------#This very simple script alters 2 classes of RMXP to make it able to see#characters behind scenery objects or behind other characters. The region of#the sprite covered by other objects can have different opacity, so the sprite#still makes sense behind other stuff.#What it does is basically duplicating the viewport in which the characters#are drawn and draws translucid characters with high priority in it instead.#By overlaying one on top of another, gives the effect of translucid scenery.#Since the character drawing process is doubled, it may lower performance,#depending on the amount of objects in the scene.##All you have to do is managing global variables that define the see-through#parameters in-game via Call Script functions:##$see_thru_actor = true/false -Activate seeing through the scenery# above the actor#$see_thru_events = true/false -Activate seeing through the scenery# above other events#$see_thru_opacity = 0-100 -Adjusts the opacity percentage applied# to the opacity value of sprites that are# behind scenery or behind other sprites##Terms of Use: Feel free to do anything you want with this in any kind of game#by cockroach#==============================================================================#-------------------------------------------------------------# Global Variable that defines whether scenery above the# actor is seen-through#-------------------------------------------------------------$see_thru_actor = true#-------------------------------------------------------------# Global Variable that defines whether scenery above the# events is seen-through#-------------------------------------------------------------$see_thru_events = true#-------------------------------------------------------------# Opacity percentage of characters when behind other stuff#-------------------------------------------------------------$see_thru_opacity = 20#==============================================================================# ** Alterations in Spriteset_Map#------------------------------------------------------------------------------#All methods suffer slight changes, to include another array of characters#to contain each actor/event#==============================================================================class Sprite_Character < RPG::Sprite#--------------------------------------------------------------------------# * Object Initialization# viewport: viewport# character : character (Game_Character)#--------------------------------------------------------------------------def initialize(viewport, character = nil, overlay = false) super(viewport) @character = character @overlaychar = overlay updateend#--------------------------------------------------------------------------# * Frame Update#--------------------------------------------------------------------------def update super # If tile ID, file name, or hue are different from current ones if @tile_id != @character.tile_id or @character_name != @character.character_name or @character_hue != @character.character_hue # Remember tile ID, file name, and hue @tile_id = @character.tile_id @character_name = @character.character_name @character_hue = @character.character_hue # If tile ID value is valid if @tile_id >= 384 self.bitmap = RPG::Cache.tile($game_map.tileset_name, @tile_id, @character.character_hue) self.src_rect.set(0, 0, 32, 32) self.ox = 16 self.oy = 32 # If tile ID value is invalid else self.bitmap = RPG::Cache.character(@character.character_name, @character.character_hue) @cw = bitmap.width / 4 @ch = bitmap.height / 4 self.ox = @cw / 2 self.oy = @ch end end # Set visible situation self.visible = (not @character.transparent) if @overlaychar if @character == $game_player and not($see_thru_actor) self.visible = false elsif @character != $game_player and not($see_thru_events) self.visible = false end end # If graphic is character if @tile_id == 0 # Set rectangular transfer sx = @character.pattern * @cw sy = (@character.direction - 2) / 2 * @ch self.src_rect.set(sx, sy, @cw, @ch) end # Set sprite coordinates self.x = @character.screen_x self.y = @character.screen_y self.z = @character.screen_z(@ch) # Set opacity level, blend method, and bush depth self.opacity = @character.opacity if @overlaychar self.opacity = self.opacity * $see_thru_opacity / 100 end self.blend_type = @character.blend_type self.bush_depth = @character.bush_depth # Animation if @character.animation_id != 0 animation = $data_animations[@character.animation_id] animation(animation, true) @character.animation_id = 0 endendend#==============================================================================# ** Alterations in Spriteset_Map#------------------------------------------------------------------------------#All methods suffer slight changes, to include another array of characters#to contain each actor/event#==============================================================================class Spriteset_Map#--------------------------------------------------------------------------# * Object Initialization#--------------------------------------------------------------------------def initialize # Make viewports @viewport1 = Viewport.new(0, 0, 640, 480) @viewport2 = Viewport.new(0, 0, 640, 480) @viewport3 = Viewport.new(0, 0, 640, 480) @viewport4 = Viewport.new(0, 0, 640, 480) @viewport2.z = 200 @viewport3.z = 5000 @viewport4.z = 4000 # Make tilemap @tilemap = Tilemap.new(@viewport1) @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name) for i in 0..6 autotile_name = $game_map.autotile_names @tilemap.autotiles = RPG::Cache.autotile(autotile_name) end @tilemap.map_data = $game_map.data @tilemap.priorities = $game_map.priorities # Make panorama plane @panorama = Plane.new(@viewport1) @panorama.z = -1000 # Make fog plane @fog = Plane.new(@viewport1) @fog.z = 3000 # Make character sprites @character_sprites = [] @see_thru_sprite = [] @see_thru_sprite.push(Sprite_Character.new(@viewport4, $game_player, true)) for i in $game_map.events.keys.sort event = $game_map.events sprite = Sprite_Character.new(@viewport1, event) @character_sprites.push(sprite) @see_thru_sprite.push(Sprite_Character.new(@viewport4, event, true)) end @character_sprites.push(Sprite_Character.new(@viewport1, $game_player)) # Make weather @weather = RPG::Weather.new(@viewport1) # Make picture sprites @picture_sprites = [] for i in 1..50 @picture_sprites.push(Sprite_Picture.new(@viewport2, $game_screen.pictures)) end # Make timer sprite @timer_sprite = Sprite_Timer.new # Frame update updateend#--------------------------------------------------------------------------# * Dispose#--------------------------------------------------------------------------def dispose # Dispose of tilemap @tilemap.tileset.dispose for i in 0..6 @tilemap.autotiles.dispose end @tilemap.dispose # Dispose of panorama plane @panorama.dispose # Dispose of fog plane @fog.dispose # Dispose of character sprites for sprite in @character_sprites sprite.dispose end for sprite in @see_thru_sprite sprite.dispose end # Dispose of weather @weather.dispose # Dispose of picture sprites for sprite in @picture_sprites sprite.dispose end # Dispose of timer sprite @timer_sprite.dispose # Dispose of viewports @viewport1.dispose @viewport2.dispose @viewport3.dispose @viewport4.disposeend#--------------------------------------------------------------------------# * Frame Update#--------------------------------------------------------------------------def update # If panorama is different from current one if @panorama_name != $game_map.panorama_name or @panorama_hue != $game_map.panorama_hue @panorama_name = $game_map.panorama_name @panorama_hue = $game_map.panorama_hue if @panorama.bitmap != nil @panorama.bitmap.dispose @panorama.bitmap = nil end if @panorama_name != "" @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue) end Graphics.frame_reset end # If fog is different than current fog if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue @fog_name = $game_map.fog_name @fog_hue = $game_map.fog_hue if @fog.bitmap != nil @fog.bitmap.dispose @fog.bitmap = nil end if @fog_name != "" @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue) end Graphics.frame_reset end # Update tilemap @tilemap.ox = $game_map.display_x / 4 @tilemap.oy = $game_map.display_y / 4 @tilemap.update # Update panorama plane @panorama.ox = $game_map.display_x / 8 @panorama.oy = $game_map.display_y / 8 # Update fog plane @fog.zoom_x = $game_map.fog_zoom / 100.0 @fog.zoom_y = $game_map.fog_zoom / 100.0 @fog.opacity = $game_map.fog_opacity @fog.blend_type = $game_map.fog_blend_type @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy @fog.tone = $game_map.fog_tone # Update character sprites for sprite in @character_sprites sprite.update end # Update weather graphic @weather.type = $game_screen.weather_type @weather.max = $game_screen.weather_max @weather.ox = $game_map.display_x / 4 @weather.oy = $game_map.display_y / 4 @weather.update for sprite in @see_thru_sprite sprite.update end # Update picture sprites for sprite in @picture_sprites sprite.update end # Update timer sprite @timer_sprite.update # Set screen color tone and shake position @viewport1.tone = $game_screen.tone @viewport1.ox = $game_screen.shake # Set screen flash color @viewport3.color = $game_screen.flash_color # Update viewports @viewport1.update @viewport4.update @viewport3.updateendend
本贴来自国际rpgmaker官方论坛作者:cockroach处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/see-through-scenery-script.42280/
页:
[1]