Yami's Overlay Mapping + Control switches = bug

● ARCHIVED · READ-ONLY
Started by Gui 8 posts View original ↗
  1. I use Yami's Overlay Mapping script (april of 2012 update) to get sun rays and shadows on my maps but I noticed it prevents me from using Control switches: to be more precise, when I do use a Control switch, the game jumps directly to the content of the second Event Page, like if the Control switch was on right at the beginning of the game instead of waiting for the content of the first Event page to perform before setting the Control switch as on.

    For example, I have this intro scene with a short dialogue on map 1 at the end of which the Control switch is turned as on, then player is transfered to another map where a second scene occurs; there is a third scene on a third map, then players is tranferred on map 1 again where a fourth scene happens: the Switch is supposed to make this fourth scene happens at this moment, but for some reason the fourth scene happens at the very beginning of the game, like if the Control switch was on by default...

    I encountered other similar issues in the third map where the player can dialog with some NPCs: every dialog is made of 2 Event pages with a Control switch at the end of the first Event page to go on the second Event page when the payer wants to keep on discussing with the NPC although this one doesn't have anything to add to the conversation – in this case, the NPC just says to the player that it should hurry to his appointment. But the dialog begins at the second Event page instead of the first.

    The only other script I use is Yanfly's Parallax Lock v1.00. If I remove this script from the Script Ed, it doesn't solve anything. But when I put it in again and I remove Yami's Overlay Mapping script instead, the bug disappears.

    Any idea to solve this issue? If I decide to use additional maps instead of switches, how many can I put in a project in total? And if I must envisage to use a different script for overlays, which one would you recommend?

    Thanks in advance for any help  :)
  2. wrong - yami's overlay script needs some switches and variables configured for itself - only if you forget to make that configuration, only then the switches and variables have strange effects.


    Did you enter the configuration area of yanfly's overlay script and set and reserve those required switches correctly?


    That overlay script is NOT plug-n-play, it NEEDS its switches configured correctly.


    If you believe to have them set correctly, then please post the configuration here and we'll see if there is a problem remaining.
  3. Most people tend to forget to check scripts to see if they call for any specific in game switch or variable. Its a good idea to mark it so you don't accidentally use it, change it to 0 (doesn't work with all scripts) or just make it a number your never going to use. I have used yami's overlay script for a while now and  the only bug present is the one where maps do not loop correctly.
  4. Andar said:
    wrong - yami's overlay script needs some switches and variables configured for itself - only if you forget to make that configuration, only then the switches and variables have strange effects.

    Did you enter the configuration area of yanfly's overlay script and set and reserve those required switches correctly?

    [...]
    No, I didn't: I have absolutely no idea where this configuration area you're talking about is located, to begin with, and because my sun beams and my shadows work perfectly, I didn't see any reason to dig deeper...

    Is this the part named Overlay Switches, between lines 47 and 60? If yes, how can I configure this?

    boldpaste2 said:
    Most people tend to forget to check scripts to see if they call for any specific in game switch or variable. Its a good idea to mark it so you don't accidentally use it, change it to 0 (doesn't work with all scripts) or just make it a number your never going to use. [...]
    But mark what exactly? And how can I mark it?

    ---

    Sorry to make this difficult, but I can't prevent myself to think that sometimes custom scripts can be uselessly complicated...
  5. Gui said:
    Is this the part named Overlay Switches, between lines 47 and 60? If yes, how can I configure this?
    Probably yes, I don't have the script to check - but there are two areas, one for switches and one for variables.
    In both cases, the numbers given for the named constants are to be the numbers of the variables and switches that you are reserving for the script's function, and those switches and variables must not be used for anything else - if you use the default switches for anything else (and you probably did), then changing the switch for your intended function will additionally change the assigned function in yami's switch as well - and when yami's script changes those switches, your other events will also react to this.


    If you link to the script we can tell you exactly what and how to set.
  6. Well, it seems I could solve my problem in leaving the 4 first lines of the list of switches as blank: Yami's script does seem to use lines 1 to 4, respectively for light, shadows, parallax and ground. Then, I used the fifth line to command the Control switch I needed and it works: when the player goes back to the first map, the second Event page is activated like it should...

    Anyway, here is the script (sorry to include it entirely but I couldn't find how to implement spoiler tags):

    #==============================================================================
    #
    # ¥ Yami Engine Ace - Overlay Mapping
    # -- Last Updated: 2012.04.16
    # -- Level: Normal
    # -- Requires: n/a
    #
    #==============================================================================

    $imported = {} if $imported.nil?
    $imported["YSE-OverlayMapping"] = true

    #==============================================================================
    # ¥ Updates
    # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # 2012.04.16 - Reworked with Encrypted Game.
    # 2012.04.13 - Ported into Yami Engine.
    #
    #==============================================================================
    # ¥ Introduction
    # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # This script based on Hanzo Kimura's idea. This will automatically load map's
    # overlay by map ID, and a map can have more than one image per layer, so you
    # don't have to create two or more map just for day/night or when an event occur.
    #
    #==============================================================================
    # ¥ Instructions
    # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # Create a folder in Graphics and name it Overlay.
    # Put all of your overlay into Graphics/Overlay.
    # Your overlay file will have the name: "Filename Prefix" + Map-ID + "-" + Number
    # which "Filename Prefix" is the one you will config below
    # Map-ID is your map's ID
    # Number is 1, 2, 3, ... using for Overlay Variables.
    #
    # Example: Graphics/Overlay/ground2-1.png
    # Which means this will be ground layer, for map 2, variable = 1
    #
    # Light/Shadow must be .jpg
    # Parallax/Ground must be .png
    #
    #==============================================================================

    module YSA
      module OVERLAY
        
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        # - Overlay Switches -
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        # These are switches which are enable overlay layers. Turn them on to show
        # them in your maps.
        #--------------------------------------------------------------------------
        # Default: ON
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        LIGHT_SWITCH = 1        # Turn on/off light layer
        SHADOW_SWITCH = 2       # Turn on/off shadow layer
        PARALLAX_SWITCH = 3     # Turn on/off parallax layer
        GROUND_SWITCH = 4       # Turn on/off ground layer

        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        # - Overlay Variables -
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        # A map can have more than one image per layer, that means you can have a
        # different light/shadow for day and night, or have a different ground when
        # an event occured.
        #--------------------------------------------------------------------------
        # Default: 1
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        LIGHT_VARIABLE = 2      # Switch to another light
        SHADOW_VARIABLE = 2     # Switch to another shadow
        PARALLAX_VARIABLE = 1   # Switch to another parallax
        GROUND_VARIABLE = 1     # Switch to another ground
        
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        # - Filename Prefix -
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        # This will make this script automatic, it will check if there are layers in
        # overlay folder
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        LIGHT = "light"         # Light layer's filename prefix
        SHADOW = "shadow"       # Shadow layer's filename prefix
        PARALLAX = "par"        # Parallax layer's filename prefix
        GROUND = "ground"       # Ground layer's filename prefix
        
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        # - Overlay Opacity -
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        # This will make this script automatic, it will check if there are layers in
        # overlay folder
        #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        GROUND_OPACITY = 255
        PARALLAX_OPACITY = 255
        LIGHT_OPACITY = 128
        SHADOW_OPACITY = 96
        
      end #OVERLAY
    end # YSA

    #==============================================================================
    # ¥ Editting anything past this point may potentially result in causing
    # computer damage, incontinence, explosion of user's head, coma, death, and/or
    # halitosis so edit at your own risk.
    #==============================================================================

    #==============================================================================
    # ¡ Cache
    #==============================================================================

    module Cache
     
      #--------------------------------------------------------------------------
      # new method: overlay
      #--------------------------------------------------------------------------
      def self.overlay(filename)
        begin
          self.load_bitmap("Graphics/Overlay/", filename)
        rescue
          self.empty_bitmap
        end
      end
     
    end # Cache

    #==============================================================================
    # ¡ DataManager
    #==============================================================================

    module DataManager
     
      #--------------------------------------------------------------------------
      # alias method: setup_new_game
      #--------------------------------------------------------------------------
      class <<self; alias ovm_setup_new_game setup_new_game; end
      def self.setup_new_game
        ovm_setup_new_game
        setup_overlay_mapping
      end
     
      #--------------------------------------------------------------------------
      # new method: setup_overlay_mapping
      #--------------------------------------------------------------------------
      def self.setup_overlay_mapping
        # Control switches
        $game_switches[YSA::oVERLAY::LIGHT_SWITCH] = true
        $game_switches[YSA::oVERLAY::SHADOW_SWITCH] = true
        $game_switches[YSA::oVERLAY::GROUND_SWITCH] = true
        $game_switches[YSA::oVERLAY::pARALLAX_SWITCH] = true
        
        # Control variables
        $game_variables[YSA::oVERLAY::LIGHT_VARIABLE] = 1
        $game_variables[YSA::oVERLAY::SHADOW_VARIABLE] = 1
        $game_variables[YSA::oVERLAY::GROUND_VARIABLE] = 1
        $game_variables[YSA::oVERLAY::pARALLAX_VARIABLE] = 1
      end
     
    end # DataManager

    #==============================================================================
    # ¡ Spriteset_Map
    #==============================================================================

    class Spriteset_Map
     
      #--------------------------------------------------------------------------
      # alias method: initialize
      #--------------------------------------------------------------------------
      alias overlay_initialize initialize
      def initialize
        overlay_initialize
        create_overlay_map
        update
      end
     
      #--------------------------------------------------------------------------
      # new method: create_overlay_map
      #--------------------------------------------------------------------------
      def create_overlay_map
        @current_light = 0
        @current_shadow = 0
        @current_par = 0
        @current_ground = 0
        # Ground Layer
        @ground = Sprite.new(@viewport1)
        @ground.z = 1
        @ground.opacity = YSA::oVERLAY::GROUND_OPACITY
        # Light Layer
        @light = Sprite.new(@viewport1)
        @light.opacity = YSA::oVERLAY::LIGHT_OPACITY
        @light.blend_type = 1
        @light.z = 299
        # Shadow Layer
        @shadow = Sprite.new(@viewport1)
        @shadow.opacity = YSA::oVERLAY::SHADOW_OPACITY
        @shadow.blend_type = 2
        @shadow.z = 298
        # Parallax Layer
        @par = Sprite.new(@viewport1)
        @par.opacity = YSA::oVERLAY::pARALLAX_OPACITY
        @par.z = 297
      end
     
      #--------------------------------------------------------------------------
      # alias method: dispose_parallax
      #--------------------------------------------------------------------------
      alias overlay_dispose_parallax dispose_parallax
      def dispose_parallax
        overlay_dispose_parallax
        dispose_overlay_map
      end
     
      #--------------------------------------------------------------------------
      # new method: dispose_overlay_map
      #--------------------------------------------------------------------------
      def dispose_overlay_map
        @ground.dispose
        @light.dispose
        @shadow.dispose
        @par.dispose
      end
     
      #--------------------------------------------------------------------------
      # alias method: update_parallax
      #--------------------------------------------------------------------------
      alias overlay_update_parallax update_parallax
      def update_parallax
        overlay_update_parallax
        update_overlay
      end
     
      #--------------------------------------------------------------------------
      # new method: update_overlay
      #--------------------------------------------------------------------------
      def update_overlay
        update_om_ground
        update_om_par
        update_om_light
        update_om_shadow
      end
     
      #--------------------------------------------------------------------------
      # new method: update_om_ground
      #--------------------------------------------------------------------------
      def update_om_ground
        return unless @ground
        @ground.visible = $game_switches[YSA::oVERLAY::GROUND_SWITCH] if @ground.visible != $game_switches[YSA::oVERLAY::GROUND_SWITCH]
        @ground.ox = $game_map.display_x * 32 if @ground.ox != $game_map.display_x * 32
        @ground.oy = $game_map.display_y * 32 if @ground.oy != $game_map.display_y * 32
        if @current_ground != $game_variables[YSA::oVERLAY::GROUND_VARIABLE]
          filename = YSA::oVERLAY::GROUND
          filename += $game_map.map_id.to_s
          filename += "-" + $game_variables[YSA::oVERLAY::GROUND_VARIABLE].to_s
          @ground.bitmap = Cache.overlay(filename)
          @current_ground = $game_variables[YSA::oVERLAY::GROUND_VARIABLE]
        end
      end
     
      #--------------------------------------------------------------------------
      # new method: update_om_par
      #--------------------------------------------------------------------------
      def update_om_par
        return unless @par
        @par.visible = $game_switches[YSA::oVERLAY::pARALLAX_SWITCH] if @par.visible != $game_switches[YSA::oVERLAY::pARALLAX_SWITCH]
        @par.ox = $game_map.display_x * 32 if @par.ox != $game_map.display_x * 32
        @par.oy = $game_map.display_y * 32 if @par.oy != $game_map.display_y * 32
        if @current_par != $game_variables[YSA::oVERLAY::pARALLAX_VARIABLE]
          filename = YSA::oVERLAY::pARALLAX
          filename += $game_map.map_id.to_s
          filename += "-" + $game_variables[YSA::oVERLAY::pARALLAX_VARIABLE].to_s
          @par.bitmap = Cache.overlay(filename)
          @current_par = $game_variables[YSA::oVERLAY::pARALLAX_VARIABLE]
        end
      end
     
      #--------------------------------------------------------------------------
      # new method: update_om_light
      #--------------------------------------------------------------------------
      def update_om_light
        return unless @light
        @light.visible = $game_switches[YSA::oVERLAY::LIGHT_SWITCH] if @light.visible != $game_switches[YSA::oVERLAY::LIGHT_SWITCH]
        @light.ox = $game_map.display_x * 32 if @light.ox != $game_map.display_x * 32
        @light.oy = $game_map.display_y * 32 if @light.oy != $game_map.display_y * 32
        if @current_light != $game_variables[YSA::oVERLAY::LIGHT_VARIABLE]
          filename = YSA::oVERLAY::LIGHT
          filename += $game_map.map_id.to_s
          filename += "-" + $game_variables[YSA::oVERLAY::LIGHT_VARIABLE].to_s
          @light.bitmap = Cache.overlay(filename)
          @current_light = $game_variables[YSA::oVERLAY::LIGHT_VARIABLE]
        end
      end
     
      #--------------------------------------------------------------------------
      # new method: update_om_shadow
      #--------------------------------------------------------------------------
      def update_om_shadow
        return unless @shadow
        @shadow.visible = $game_switches[YSA::oVERLAY::SHADOW_SWITCH] if @shadow.visible != $game_switches[YSA::oVERLAY::SHADOW_SWITCH]
        @shadow.ox = $game_map.display_x * 32 if @shadow.ox != $game_map.display_x * 32
        @shadow.oy = $game_map.display_y * 32 if @shadow.oy != $game_map.display_y * 32
        if @current_shadow != $game_variables[YSA::oVERLAY::SHADOW_VARIABLE]
          filename = YSA::oVERLAY::SHADOW
          filename += $game_map.map_id.to_s
          filename += "-" + $game_variables[YSA::oVERLAY::SHADOW_VARIABLE].to_s
          @shadow.bitmap = Cache.overlay(filename)
          @current_shadow = $game_variables[YSA::oVERLAY::SHADOW_VARIABLE]
        end
      end
     
    end # Spriteset_Map

    #==============================================================================
    # ¡ Scene_Map
    #==============================================================================

    class Scene_Map < Scene_Base
     
      #--------------------------------------------------------------------------
      # alias method: post_transfer
      #--------------------------------------------------------------------------
      alias overlay_post_transfer post_transfer
      def post_transfer
        @spriteset.dispose_overlay_map
        @spriteset.create_overlay_map
        @spriteset.update
        overlay_post_transfer
      end

    end # Scene_Map

    #==============================================================================
    #
    # ¥ End of File
    #
    #==============================================================================
  7. I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


    Please don't post other people's scripts into your post unless you have modified them and are providing the modified version.


    Just provide a link to the original site where you got the script.


    And when you DO post scripts, put code tags around it, and spoiler tags around that if it's a big one - to save taking up so much space AND to keep the formatting intact. A spoiler tag is just spoiler at the start and /spoiler at the end, with [ ] around it.
  8. Shaz said:
    [...]

    And when you DO post scripts, put code tags around it, and spoiler tags around that if it's a big one - to save taking up so much space AND to keep the formatting intact. A spoiler tag is just spoiler at the start and /spoiler at the end, with [ ] around it.
    Yeah, I know I should have put some spoiler tags: this is precisely what I said just before posting the code... Thank for telling me how to implement this tag though, such positive input is very appreciated.