TheoAllen 830 Posted May 15, 2014 (edited) Theo - Fog Screen Type : Graphical Utility Version : 2.0 Original Post : Fog ScreenIntroductions :This is just another fog script which allow you to set multiple fogs in screen. And as SGITC requested, here is the translation (Not really a request, I just voluntary offer a translation) Features : Displays fog at battle scene Multiple fogs Simple script call (Because I don't really like longer script call such as "fog(filename, opacity, ox,oy, etc ...)" ) Support switch id for each fog. This area has been cleared. I want to disable fog as well Support map notetag Screenshot : Downloads :DemoScript Terms of Use :Credit me, TheoAllen. You are free to edit this script by your own. As long as you don't claim it yours. For commercial purpose, don't forget to give me a free copy of the game. Note : If you found any glitches or bugs, please tell me Edited May 15, 2014 by TheoAllen 3 ShidoLionheart, Plague Docteur and kawaii reacted to this Share this post Link to post Share on other sites
Faye V. 52 Posted May 15, 2014 (edited) Holy damn. Definitively going to try this! thanks dude! Edit: oh my god. Multiple fogs, not scrolling with player, in-battle fogs and many features. You, sir, rock. This is an awesome script. Do you mind if i translate it to Spanish and share it with other people from other forums? obviously giving you all the credits. This script is awesome ^^ Edited May 15, 2014 by SGITC Share this post Link to post Share on other sites
TheoAllen 830 Posted May 15, 2014 Sure, do as you wish. And spread it to the world :3 1 Faye V. reacted to this Share this post Link to post Share on other sites
Faye V. 52 Posted May 15, 2014 (edited) Just in case someone is interested/speaks spanish or something, and if it is not illegal, i'll let the Spanish version of this awesome script here: # ============================================================================= # TheoAllen - Fog Screen # Version : 2.0 # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com # (Original: Tailandés, Traducción al Inglés: Theo, al Español: SGITC) # ============================================================================= ($imported ||={})[:Theo_FogScreen] = true # ============================================================================= # Notas de la versión: # ----------------------------------------------------------------------------- # 2013.08.24 - Script reescrito con diferentes funciones # - Soporte para multiples fogs # - Ahora soporta movimiento muy lento (0.01 por ejemplo) # - La fog ya no scrollea con el jugador # - Ahora soporta fog en batalla # - Ahora se puede cambiar la fog mediante notas de mapa # - Removida la varianza de la opacidad # 2013.06.13 - Añadidas las fog globales # - Añadido interruptor global de desactivación # - Añadido interruptor de desactivación especÃfico # 2013.06.12 - Bug arreglado. La fog no estaba siendo borrada cuando pasaba de mapa. # 2013.05.15 - Añadida la función de tipo de mezclado # - Añadida la función de zoom # - Added opacity variance # 2013.05.09 - Finalizado el script # ============================================================================= =begin ----------------------------------------------------------------------------- Apertura: Éste es un script diferente a mi anterior script de fog. Funciona de manera distinta, asà que si tienes una versión anterior, lo recomendable serÃa que la removieses y pusieses ésta en cambio. ----------------------------------------------------------------------------- Introducción: Éste script emula la función de "Fog" (o "Neblina") que tenÃa el RMXP por defecto. ----------------------------------------------------------------------------- Cómo usar: 1.- Coloca éste script encima de "Main" y debajo de "Materiales" Edita la base de datos de éste script para configurar tus fogs Para mostrar las fogs, ejecuta un comando de "Script" Para mostrar: add_fog(key) add_fog(key,fadein) Para remover: delete_fog(key) delete_fog(key,fadeout) Nota: - "Key" es una palabra clave de la base de datos de éste script. Similar a un "ID" pero en vez de números, palabras o letras. - "Fade in" y "Fade Out" son los tiempos de aparición y desaparición de cada fog. El valor va colocado en frames. Si omites éste paso, la aparición/des- aparición será inmediata. - No puedes llamar dos o más fogs que tengan el mismo nombre. Utiliza el comando: clear_fogs si quieres remover todas las fogs actuales. ----------------------------------------------------------------------------- Uso de notas: Éste sistema es bastante simple. Todo lo que debes de hacer es colocar el siguiente código en las notas del mapa. Donde "Key" va el nombre de la fog que customizaste en la base de datos de éste script. <add fog: key> ----------------------------------------------------------------------------- Términos de uso: Todos los créditos van para Theo Allen. Puedes editar éste script como gustes pero nunca debes reclamar que es de tu propiedad. Para uso comercial, no olvides darme una copia gratis del juego =end # ============================================================================= # Configuración # ============================================================================= module THEO module Fog # ------------------------------------------------------------------------- # ¿Será incluida en las batallas? # ------------------------------------------------------------------------- BattleFog = true # True para sÃ, False para no. # ------------------------------------------------------------------------- # Base de Datos de Fogs # Nivel: fácil # ------------------------------------------------------------------------- # GuÃa de configuración: # # key => Nombre o ID de la fog. # name => Nombre exacto de la imagen de fog. Debe estar en "Pictures" # opacity => Opacidad de la fog (0 - 255) # speed_x => Velocidad de movimiento horizontal # speed_y => Velocidad de movimiento vertical # zoom_x => Escala de zoom horizontal (valor normal: 1.0 acepta decimales) # zoom_y => Escala de zoom vertical (valor normal: 1.0 acepta decimales) # ------------------------------------------------------------------------- List = { # "key" => ["name", opacity, speed_x, speed_y, zoom_x, zoom_y] "fog" => ["fog", 128, 0.2, 0.2, 1.0, 1.0], "cloud" => ["cloud", 90, -0.2, -0.2, 2.0, 2.0], "storm" => ["storm", 90, -2.0, 2.0, 1.0, 1.0], "leaf" => ["leaf", 90, 0, 0, 2.0, 2.0], # ¡Añade tus propias fogs! } # <-- ¡No lo elimines! # ------------------------------------------------------------------------- # Base de datos de fog extendida (Para usuarios avanzados) # Level : Dificil # ------------------------------------------------------------------------- # Hay más configuraciones que las de arriba, pero es puramente opcional. # Por razones de organización, prefiero dividirlas. # # GuÃa de Configuración # Empieza escribiendo ésto: # fog = fog_data["key"] # # Luego cambia sus atributos: # fog = fog_data["fog"] # fog.name = "something" # fog.opacity = 100 # # Ésta es la lista de configuraciones adicionales no incluidas normalmente: # # fog.switch >> ID del interruptor. Si está activa, será invisible. # fog.blend_type >> Tipo de mezclado. 0 = Normal 1 = Añadir 2 = Inverso # fog.tone >> Tono de la fog en valor RGB como los tonos de pantalla. # fog.z >> Coordenada Z. Z = profundidad. # # # Para movimiento de escala: # fog.scroll_scale_x >> Escala horizontal # fog.scroll_scale_y >> Escala vertical # # Son para movimiento de escala. Si el valor es 0.0 la fog se moverá junto al # jugador. El valor predeterminado es 1.0 (no se moverá con el jugador) # ------------------------------------------------------------------------- def self.custom_fogs fog = fog_data["leaf"] fog.scroll_scale_x = 0.4 fog.scroll_scale_y = 0.4 fog = fog_data["rain1"] fog.blend_type = 1 fog = fog_data["rain2"] fog.blend_type = 2 end end end # ============================================================================= # Fin de la configuración. Ediciones a partir de aquà podrÃan causar cáncer. # ============================================================================= module THEO module Fog def self.load_fogs List.each do |key,data| fog = fog_data[key] fog.name = data[0] fog.opacity = data[1] fog.speed_x = data[2] fog.speed_y = data[3] fog.zoom_x = data[4] fog.zoom_y = data[5] end end def self.fog_data $game_temp.fogs end end end # ============================================================================= # â–¼ DataManager # ============================================================================= class << DataManager alias theo_fog_create_obj create_game_objects def create_game_objects theo_fog_create_obj THEO::Fog.load_fogs THEO::Fog.custom_fogs end end # ============================================================================= # â–¼ DataFogs # ============================================================================= class DataFogs def initialize @data = {} end def [](key) @data[key] ||= Fog.new(key) end end # ============================================================================= # â–¼ Fogs # ============================================================================= class Fog attr_accessor :key attr_accessor :name attr_accessor :opacity attr_accessor :speed_x attr_accessor :speed_y attr_accessor :zoom_x attr_accessor :zoom_y attr_accessor :scroll_scale_x attr_accessor :scroll_scale_y attr_accessor :blend_type attr_accessor :tone attr_accessor :switch attr_accessor :z def initialize(key) @key = key @name = "" @opacity = 255 @speed_x = 0.0 @speed_y = 0.0 @zoom_x = 1.0 @zoom_y = 1.0 @scroll_scale_x = 1.0 @scroll_scale_y = 1.0 @blend_type = 0 @tone = Tone.new @switch = 0 @z = 250 end def visible !$game_switches[@switch] end end # ============================================================================= # â–¼ Game_Temp # ============================================================================= class Game_Temp attr_accessor :clear_fog attr_reader :fogs # -------------------------------------------------------------------------- # They said that too much global variables isn't good. So, I used an # instance variable to store my fogs database =P # -------------------------------------------------------------------------- alias theo_fog_init initialize def initialize theo_fog_init @fogs = DataFogs.new @clear_fog = false end end # ============================================================================= # â–¼ Game_System # ============================================================================= class Game_System attr_reader :used_fog alias theo_fog_init initialize def initialize theo_fog_init @used_fog = [] end end # ============================================================================= # â–¼ Game_Interpreter # ============================================================================= class Game_Interpreter def clear_fogs $game_system.used_fog.clear $game_temp.clear_fog = true Fiber.yield end def get_fog(key) plane = planefogs return nil unless plane plane.get_fog(key) end def planefogs scene = SceneManager.scene spriteset = scene.instance_variable_get("@spriteset") return spriteset.instance_variable_get("@fogs") end def delete_fog(key,speed = 255) fog = get_fog(key) return unless fog $game_system.used_fog.delete(key) fog.fadeout(speed) fog.fade_delete = true end def add_fog(key,speed = 255) return if $game_system.used_fog.include?(key) $game_system.used_fog.push(key) fog = planefogs[key] fog.fadein(speed) end end # ============================================================================= # â–¼ Game_Map # ============================================================================= class Game_Map attr_accessor :used_fogs alias theo_fog_init initialize def initialize theo_fog_init @used_fogs = [] end alias theo_fog_setup setup def setup(map_id) theo_fog_setup(map_id) setup_fogs end def setup_fogs @used_fogs = [] @map.note.split(/[\r\n]+/).each do |line| case line when /<(?:ADD_FOG|add fog): (.*)>/i key = $1.to_s next if @used_fogs.include?(key) @used_fogs.push(key) end end end end # ============================================================================= # â–¼ PlaneFog # ============================================================================= class PlaneFog < Plane attr_accessor :fade_delete attr_accessor :key def initialize(key, viewport) super(viewport) @real_ox = self.ox.to_f + rand(Graphics.width) @real_oy = self.oy.to_f + rand(Graphics.height) load_data(key) update_oxoy @fade = 0 @fade_delete = false end def load_data(key) @data = THEO::Fog.fog_data[key] self.bitmap = Cache.picture(@data.name) @data.instance_variables.each do |varsymb| ivar_name = varsymb.to_s.gsub(/@/){""} eval(" if self.respond_to?(\"#{ivar_name}\") self.#{ivar_name} = @data.#{ivar_name} end ") end end def fadeout(speed) @fade = -speed end def fadein(speed) @fade = speed self.opacity = 0 end def spd_x @data.speed_x end def spd_y @data.speed_y end def update update_real_oxoy update_oxoy update_visible update_fade end def update_real_oxoy @real_ox += spd_x @real_oy += spd_y end def update_oxoy self.ox = fog_display_x + @real_ox self.oy = fog_display_y + @real_oy end def update_fade self.opacity = [[opacity + @fade,0].max,max_opacity].min end def max_opacity @data.opacity end def fog_display_x $game_map.display_x * (32.0 * @data.scroll_scale_x) end def fog_display_y $game_map.display_y * (32.0 * @data.scroll_scale_y) end def update_visible self.visible = @data.visible end end # ============================================================================= # â–¼ PlaneFogs # ============================================================================= class PlaneFogs def initialize(viewport) @data = {} @viewport = viewport init_used_fog end def init_used_fog $game_system.used_fog.each do |fogname| self[fogname] end end def get_fog(key) @data[key] end def delete(key) fog = @data[key] return unless fog fog.dispose @data.delete(key) end def [](key) @data[key] ||= PlaneFog.new(key, @viewport) end def update update_basic @data.values.each {|fog| fog.update unless fog.disposed?} end def update_basic update_delete update_clear end def update_delete @data.values.each do |fog| next unless fog.fade_delete && fog.opacity == 0 delete(fog.key) $game_system.used_fog.delete(fog.key) end end def update_clear if $game_temp.clear_fog @data.keys.each do |key| delete(key) end $game_temp.clear_fog = false end end def dispose @data.values.each {|fog| fog.dispose} end end # ============================================================================= # â–¼ MapFogs # ============================================================================= class Mapfogs < PlaneFogs def init_used_fogs @used_fogs = $game_map.used_fogs.dup @used_fogs.each do |fogname| self[fogname] end end def update_basic update_used_fog end def update_used_fog if @used_fogs != $game_map.used_fogs delete_all init_used_fogs end end def delete_all @data.values.each do |fog| delete(fog.key) end end end # ============================================================================= # â–¼ Spriteset_Map # ============================================================================= class Spriteset_Map alias theo_fog_viewports create_viewports def create_viewports theo_fog_viewports create_mapfogs create_global_fogs end def create_mapfogs @mapfogs = Mapfogs.new(@viewport1) end def create_global_fogs @fogs = PlaneFogs.new(@viewport1) end alias theo_fog_update update def update theo_fog_update update_global_fogs update_mapfogs end def update_global_fogs @fogs.update end def update_mapfogs @mapfogs.update end alias theo_fog_dispose dispose def dispose theo_fog_dispose dispose_global_fogs dispose_mapfogs end def dispose_global_fogs @fogs.dispose end def dispose_mapfogs @mapfogs.dispose end end # ============================================================================= # â–¼ Spriteset_Battle # ============================================================================= class Spriteset_Battle def use_fog? THEO::Fog::BattleFog end alias theo_fog_viewports create_viewports def create_viewports theo_fog_viewports return unless use_fog? create_mapfogs create_global_fogs end def create_mapfogs @mapfogs = Mapfogs.new(@viewport1) end def create_global_fogs @fogs = PlaneFogs.new(@viewport1) end alias theo_fog_update update def update theo_fog_update return unless use_fog? update_global_fogs update_mapfogs end def update_global_fogs @fogs.update end def update_mapfogs @mapfogs.update end alias theo_fog_dispose dispose def dispose theo_fog_dispose return unless use_fog? dispose_global_fogs dispose_mapfogs end def dispose_global_fogs @fogs.dispose end def dispose_mapfogs @mapfogs.dispose end end All credits goes to TheoAllen. Edited May 15, 2014 by SGITC 1 TheoAllen reacted to this Share this post Link to post Share on other sites
TheoAllen 830 Posted May 15, 2014 That's awesome for sure. Thanks for translation. It feels like I'm looking other scripter's work ahahaha.... Share this post Link to post Share on other sites
Faye V. 52 Posted May 15, 2014 (edited) That's awesome for sure. Thanks for translation. It feels like I'm looking other scripter's work ahahaha.... The thanks goes to you for this script Btw, i noted something interesting. Normally, the Y valor in the RPG Maker is inverted, so if you show a picture with -200 Y coordinate it will show up in the top, not in the bottom. The interesting part is that this occurs in your script, but with the X coordinate! and the Y coordinate is as it should be. So if you put -1.0 in the X move speed, it will move to the right, not the left. You should put a note in your script or the main post of it. Also, the fade in is not showing correctly. I mean, i put 200 frames in the fadein field, but it shows instantly o.o and i'm sure that this occurs as well with the fadeout field, but i haven't tested that yet. Edited May 15, 2014 by SGITC Share this post Link to post Share on other sites
TheoAllen 830 Posted May 15, 2014 (edited) Well, that is actually how "class Plane" works (The terms graphics object in scripting which display image in loop). Edit : Also, the fade in is not showing correctly. I mean, i put 200 frames in the fadein field, but it shows instantly o.o and i'm sure that this occurs as well with the fadeout field, but i haven't tested that yet. It's speed, not duration. By adding 200, it means that you tells the machine to add 200 opacity per frame. Edited May 15, 2014 by TheoAllen 1 Faye V. reacted to this Share this post Link to post Share on other sites
Faye V. 52 Posted May 15, 2014 Well, that is actually how "class Plane" works (The terms graphics object in scripting which display image in loop). Edit : Also, the fade in is not showing correctly. I mean, i put 200 frames in the fadein field, but it shows instantly o.o and i'm sure that this occurs as well with the fadeout field, but i haven't tested that yet. It's speed, not duration. By adding 200, it means that you tells the machine to add 200 opacity per frame. That's... an interesting system. Why you didn't made it traditional way? and with that i mean with frames xD Share this post Link to post Share on other sites
TheoAllen 830 Posted May 15, 2014 The script is already complicated. In that moment, I finished the script and I gave all I have. But suddenly, the wild idea came. And that was fade feature. Due to laziness, I added it in simple way. The script core itself already took all of my powers xD I will consider it for the next version. 2 kawaii and Faye V. reacted to this Share this post Link to post Share on other sites
trogador2005 0 Posted June 16, 2014 Love this script thank you!!! I know you've done it in other scripts, but how could I make it so the fog is disabled by map ID like in your realistic light? -T Share this post Link to post Share on other sites
TheoAllen 830 Posted June 16, 2014 There are "global fogs" and "map fogs" Slightly different with my realistic light (hey, did you use the Indonesian instruction anyway? or are u Indonesian?). Global fogs called by script call. And it will always visible no matter what whenever you're. Unless you manually delete the fog or turn ON the switch (set it up on "extended database" configuration). Meanwhile, map fogs only visible when you give the map notetag such as <add fog: key> It's not about how to disable only in certain maps. But it's about how to make it only visible in certain maps. Such a reverse setup xD Share this post Link to post Share on other sites
Plague Docteur 189 Posted June 16, 2014 Amazing script. And so far I haven't run into the slew of compatibility issues that I tend to see with other fog related scripts. Awesome contribution. 1 TheoAllen reacted to this Share this post Link to post Share on other sites
trogador2005 0 Posted June 16, 2014 (edited) Ok I gotcha. I used the english script! The reason I want to add a way to disable by map ID is cause I have a common event triggering different fogs at random times to simulate weather with the script calls, and I would like to make them not happen when I'm in "inside" maps like houses and caves and such. That way i have one common event for all outside maps for random fog and they don't happen on any inside maps. If there is another way of doing this please shed some light! I've been scratching my head for a while with this one haha. Thanks again! -T Edited June 16, 2014 by trogador2005 Share this post Link to post Share on other sites
TheoAllen 830 Posted June 16, 2014 There is a trick though. But you have to use external script to do it http://forums.rpgmakerweb.com/index.php?/topic/20349-linked-switches/ Yp, the trick is to play with the switches. And I believe the one that you mean is "tileset id" Okay, at first... set the switch for each fog using "Fog Extended Database List" config def self.custom_fogs fog = fog_data["leaf"] fog.switch = 1 fog = fog_data["rain1"] fog.switch = 1 fog = fog_data["rain2"] fog.switch = 1 end When the switch 1 is ON, then the fogs which has same switch ID will be invisible. You could do it by event. Or use Linked Switch script above. If you plan to use linked switch script, then the configuration would be like this @links[1] = '[3,4].any? { |id| $game_map.tileset.id == id }' It means that when you enters any map which has tileset id 3 or 4, the fogs will be invisible Share this post Link to post Share on other sites
trogador2005 0 Posted June 16, 2014 Yes that makes perfect sense! and yes i did mean tileset ID. just like this line in you realistic light. DISABLE_AT_TILESET_ID = [11,] The problem its giving me is an "undefined method 'tileset' for nil:NilClass" This is what I put in the linked switches script. @links = [@links[202] = [11,12].any? { |id| $game_map.tileset.id == id }] Share this post Link to post Share on other sites
TheoAllen 830 Posted June 16, 2014 Hmm.... scratch that linked switch script. I could make my own. Try to insert this snippet class Game_Switches alias :theo_switch :[] def [](id) if id == 1 # <-- Switch ID you want to use # Change the tileset id inside [] return [3,4].any? {|id| $game_map.tileset.id == id } rescue false else return theo_switch(id) end end end The switch will be automatically turned ON when you enters the map with tileset ID 3 and 4 Share this post Link to post Share on other sites
trogador2005 0 Posted June 16, 2014 (edited) That's perfect and makes more sense to me than the linked switches haha. So in the fogs script I have this under the extended database: fog = fog_data["cloud"] fog.switch = 202 And then in the switch snippet you just made I have this: class Game_Switches alias :theo_switch :[] def [](id) if id == 202 # <-- Switch ID you want to use # Change the tileset id inside [] return [11,12].any? {|id| $game_map.tileset.id == id } rescue false else return theo_switch(id) end end end But when I enter maps 11 and 12 the fog is still showing. Did I set that up correctly? Edited June 16, 2014 by trogador2005 Share this post Link to post Share on other sites
TheoAllen 830 Posted June 16, 2014 Lol, lemme test that out in my script demo. It could me something wrong with code itself or such. But I believe I wrote the script correctly Stay tune ~ Share this post Link to post Share on other sites
trogador2005 0 Posted June 16, 2014 Thanks for all your help! Share this post Link to post Share on other sites
TheoAllen 830 Posted June 16, 2014 Okay, quick test done and switch works perfectly.I suspect in this part But when I enter maps 11 and 12 the fog is still showing. Did I set that up correctly? What do you mean by maps 11 and 12? Is that map ID or map's tileset ID? To make a simple test, try in a new map, call the fog. According to your setup, "cloud" should be called Then make event which turned the switch 202 on. And expect "cloud" will be gone. Share this post Link to post Share on other sites
trogador2005 0 Posted June 16, 2014 It works perfectly! lol. I was getting map and tilset ID confused. Now I have random fog when I'm on any outside tilesets!!! You're a genius thank you very much! -T Share this post Link to post Share on other sites
TheoAllen 830 Posted June 16, 2014 No prob, have fun! And good luck for your project Share this post Link to post Share on other sites
trogador2005 0 Posted June 16, 2014 (edited) Sorry another question.... How could I make the scripts call "clear_fogs" fade the fogs out like "delete_fog(key,fadeout)"? Because i'm using several fogs at once. After this I'll leave you alone haha. Edited June 16, 2014 by trogador2005 Share this post Link to post Share on other sites
TheoAllen 830 Posted June 16, 2014 Can't be done in this version ._. But you could try a longer script call tho $game_system.used_fog.each do |key| fog = get_fog(key) next unless fog fog.fadeout(speed) # <-- set speed here fog.fade_delete = true end $game_system.used_fog.clear Btw, nice input Share this post Link to post Share on other sites
trogador2005 0 Posted June 16, 2014 Perfect! Thank you again! Share this post Link to post Share on other sites