Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[RESOLVED] Restoring Fog/Screen Tone settings

I would like to create a skill that changes the fog layer and screen tone for a short period of time, and when the time expires, restore the fog and screen tone to the previous settings.  Does anyone know how I can retain the fog and screen tone settings before running the skill, and restore them from those settings when the skill is finished?  I want to be able to use this skill on any map, indoor or out, and for whatever fogs were present to return to normal.  Thanks in advance!
 
fog parameters are properties of the Game_Map class
tone is a property of the Game_Screen class

to store the current value, use:

save_tone = $game_screen.tone
save_fog = $game_map.fog_name

To restore after your skill:

$game_screen.start_tone_change(save_tone, 0)
$game_map.fog_name = save_fog

If they will be called from different methods or classes, use global variables
$save_fog
$save_tone

Are you implementing the skill effect (fog & tone change) in a script, or from a common event?

Be Well
 
I made a little something to make this work through a call script. I had some problems with the screen tone memorizing, but it worked, so here you go.

Code:
class Game_Screen
  alias screen_int initialize
  
  def initialize
    screen_int
    @memtone = nil
  end
  
  # Memorize Tone
  def memorize_tone
    @memtone = [@tone.red, @tone.green, @tone.blue, @tone.gray]
  end
  # Old tone
  def restore_tone
    if @memtone[0] != nil
      tone = Tone.new(@memtone[0], @memtone[1], @memtone[2], @memtone[3])
      until @tone.red == @memtone[0] and @tone.green == @memtone[1]
        start_tone_change(tone, 0)
      end
      $game_screen.update
    end
  end
end

class Game_Map
  alias map_int initialize
  
  def initialize
    map_int
    @memtone = nil
  end
  
  def memorize_fog_tone
    @memtone = @fog_tone
  end
  
  def restore_fog_tone
    @fog_tone = @memtone if !@memtone.nil?
    $game_map.refresh
  end
end

Before your skill changes the tones for screen and fog, use the script:
Code:
$game_screen.memorize_tone
$game_map.memorize_fog_tone

When the skill is complete, restore tones by using:
Code:
$game_screen.restore_tone
$game_map.restore_fog_tone

Hope this helps.
 
@Brewmeister:  I tried your method, after establishing those two global variables in Main, but I get a non-specific syntax error.

EDIT:  For Brewmeister's method, I can get it to work for the fog back and forth, and I can get it to store the tone variables, but when I try to restore the tone using:
Code:
$game_screen.start_tone_change($save_tone, 0)
that's when it gives me the generic syntax error.  The error doesn't provide a line or script name, either.

@FireRaven:  How do I add those two scripts into the game?  I tried putting the class definitions at the bottom of Game_Screen & Game_Map respectively, but I got an error.  Do I need to incorporate them into the existing class definition?  Thanks for your help.
 
I just tested what I had above. It works. Although you have to be careful about how you split up long script statements in the event script command.
It works like this:

$save_tone = $game_screen.tone
$save_fog = $game_map.fog_name

To restore after your skill:

$game_screen.start_tone_change\
($save_tone, 0)
$game_map.fog_name = $save_fog

Sorry about the confusion.

Be Well
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top