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.

Adjust Saturation

Basically, what I need is a script that will adjust the saturation of the screen by a value. However, I would prefer that certain events be taggable as to not be effected by this.
I was looking earlier, and stumbled over a method in the MACL that adjust saturation. However, if anyone can adjust this to fit my one requirement, I'd love it.

If it's too difficult, let me know. This is extremely important to my game though, so I'd hate not to have it. I can work out alternate methods, but that would boost filesize hugely, and I don't really want to do that.

As an added incentive, if you make this for me, I'll do some spriting for you! Charsets or tilesets, your choice.
 

poccil

Sponsor

Setting the "gray" value of the color tone will adjust its saturation, which is probably what you mean:
Code:
# Half saturation=128, desaturated=255
$game_screen.start_tone_change(Tone.new(0,0,0,128), 20)
However, I don't believe it's possible to disable this effect for specific sprites, because the character sprites are interwoven with the tilemap--they have different Z values as well as the tilemap itself.
 

khmp

Sponsor

My thought on this now is placing the tagged sprites into a separate Viewport object which works. But you will get weird z issues that I can't really get around. It seems the viewport has precedence over the z. So I finally decided on moving every sprite into the new viewport. And playing with the update loop by adding a conditional to adjust tone based on whether or not the sprite is tagged. This does work but adds a little extra overhead to the drawing of Spriteset_Map as it includes a conditional check within a for loop but also adjusts the tone of the sprite if it isn't tagged.

Just create an empty section above main and paste in this code. At the top of the Spriteset_Map is a section called Constant Variables. Just below it is "Ignore_Tone_Tag = '_itone'". You can adjust the string to however you want event names to be tagged. Make sure its unique though. An event name like "Woah_itone" works that same as "_itoneyurobbie".

Code:
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
#  This class deals with events. It handles functions including event page 
#  switching via condition determinants, and running parallel process events.
#  It's used within the Game_Map class.
#==============================================================================

class Game_Event < Game_Character
  #--------------------------------------------------------------------------
  # * Event Name
  #--------------------------------------------------------------------------
  def name
    return @event.name
  end
end

#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
#  This sprite is used to display the character.It observes the Game_Character
#  class and automatically changes sprite conditions.
#==============================================================================

class Sprite_Character < RPG::Sprite
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :ignore_tone
end

#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  This class brings together map screen sprites, tilemaps, etc.
#  It's used within the Scene_Map class.
#==============================================================================

class Spriteset_Map
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  Ignore_Tone_Tag = '_itone'
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias_method :grat_ignoretone_spriteset_map_dispose, :dispose
  #--------------------------------------------------------------------------
  # * Object Initialization                                        !OVERRIDE!
  #--------------------------------------------------------------------------
  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 = 200
    
    # 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[i]
      @tilemap.autotiles[i] = 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 = []
    for i in $game_map.events.keys.sort
      sprite = Sprite_Character.new(@viewport4, $game_map.events[i])
      sprite.ignore_tone = $game_map.events[i].name.include?(Ignore_Tone_Tag)
      @character_sprites.push(sprite)
    end
    @character_sprites.push(Sprite_Character.new(@viewport4, $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[i]))
    end
    # Make timer sprite
    @timer_sprite = Sprite_Timer.new
    # Frame update
    update
  end
  #--------------------------------------------------------------------------
  # * Dispose                                                         !ALIAS!
  #--------------------------------------------------------------------------
  def dispose
    grat_ignoretone_spriteset_map_dispose
    @viewport4.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update                                                 !OVERRIDE!
  #--------------------------------------------------------------------------
  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
      sprite.tone = $game_screen.tone unless sprite.ignore_tone
    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
    # 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
    @viewport3.update
    @viewport4.update
  end
end

Good luck with it gratheo! :thumb:
 
THANK YOU SO MUCH, khmp. If you want anything sprited, whenever, just PM me with details. This script is probably the single most important thing to my current mini-project.
 

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