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.

Fog in Battle?

Hey people. Relatively simple question, is it possible to use Fog in a battle? I've tried various event commands during battle, but nothing seems to work in this case.
 
Gimme a minute...

Here you go:
Code:
#==============================================================================
# ** Fog in Battle
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1.0
# 2008-07-26
#==============================================================================

#==============================================================================
# ** Spriteset_Battle
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_battlefogs_ssbtl_init, :initialize
  alias_method :seph_battlefogs_ssbtl_disp, :dispose
  alias_method :seph_battlefogs_ssbtl_updt, :update
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Original Initialization
    seph_battlefogs_ssbtl_init
    # Create Fog
    @fog = Plane.new(@viewport1)
    @fog.z = 1
    update_fog
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    # Original Initialization
    seph_battlefogs_ssbtl_disp
    # Dispose of fog plane
    @fog.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update: Fog
  #--------------------------------------------------------------------------
  def update_fog
    # If fog is different than current fog
    return if @fog == nil
    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 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
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Original Update
    seph_battlefogs_ssbtl_updt
    # Update Fog
    update_fog
  end
end
 
that worked Nicely O_o quick response. Thanks a lot SS, good job as always.

edit: though I suppose there's no way around not being able to test battle via the database?

Also, is there a way to make random encounters have their own custom fog? Per map would work perfectly I think. If not, this is perfect. Thanks a ton~
 
Try this for test battles:
Code:
#==============================================================================
# ** Fog in Battle
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1.0
# 2008-07-26
#==============================================================================

#==============================================================================
# ** Spriteset_Battle
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_battlefogs_ssbtl_init, :initialize
  alias_method :seph_battlefogs_ssbtl_disp, :dispose
  alias_method :seph_battlefogs_ssbtl_updt, :update
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Original Initialization
    seph_battlefogs_ssbtl_init
    # Create Fog
    @fog = Plane.new(@viewport1)
    @fog.z = 1
    update_fog
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    # Original Initialization
    seph_battlefogs_ssbtl_disp
    # Dispose of fog plane
    @fog.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update: Fog
  #--------------------------------------------------------------------------
  def update_fog
    # If fog is different than current fog
    return if @fog == nil
    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 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
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Original Update
    seph_battlefogs_ssbtl_updt
    # Update Fog
    update_fog
  end
end

# If Battle testing
if $BTEST

#==============================================================================
# ** Scene_Title
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_battlefogs_scnbtl_sbtm, :setup_battle_test_members
  #--------------------------------------------------------------------------
  # * Battle Test
  #--------------------------------------------------------------------------
  def setup_battle_test_members
    # Original Setup Battle Test
    seph_battlefogs_scnbtl_sbtm
    # Setup Game_Map
    $game_map.setup(1)
  end
end

end

There is a way. Something like this:
Code:
class Game_Troop
  #fog_name                 # fog file name
  #fog_hue                  # fog hue
  #fog_opacity              # fog opacity level
  #fog_blend_type           # fog blending method
  #fog_zoom                 # fog zoom rate
  #fog_sx                   # fog sx
  #fog_sy                   # fog sy
  Specific_Fog_Effects = {}
  alias_method :seph_specifictroopfogeffects_gmtroop_setup, :setup
  def setup(troop_id)
    if Specific_Fog_Effects.has_key?(troop_id)
      Specific_Fog_Effects[troop_id].each do |key, value|
        eval "$game_map.#{key} = #{value}"
      end
    end
    seph_specifictroopfogeffects_gmtroop_setup
  end
end

Now lets say for troop 1, you want the fog to turn to "001-Fog01". You would add:
Code:
  Specific_Fog_Effects[1] = {'fog_name' => "001-Fog01"}
Below
Code:
  Specific_Fog_Effects= {}

You can do that for each of those keywords listed above the Specific_Fog_Effects = {} lines.
 
I see, so if you wanted to be more specific, it would be like so:

Code:
Specific_Fog_Effects[1] = {'fog_name' => "001-Fog01", 'fog_opacity' => "100"}
right after
Code:
Specific_Fog_Effects= {}
and so forth?
 

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