Script for change the "self.z" of specific events.

Discussion in 'RGSS Script Requests' started by Andrea87Sky, Apr 17, 2019.

  1. Andrea87Sky

    Andrea87Sky Ah sh*t, here we go again. Veteran

    Messages:
    30
    Likes Received:
    1
    Location:
    Sicily
    First Language:
    Italian
    Primarily Uses:
    RMXP
    #1
  2. Andrea87Sky

    Andrea87Sky Ah sh*t, here we go again. Veteran

    Messages:
    30
    Likes Received:
    1
    Location:
    Sicily
    First Language:
    Italian
    Primarily Uses:
    RMXP
    re-up
     
    #2
  3. callmedan

    callmedan Friendly Stranger Veteran

    Messages:
    538
    Likes Received:
    861
    Location:
    i'm behind you . . .
    First Language:
    Vietnamese
    Primarily Uses:
    RMXP
    #3
  4. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,396
    Likes Received:
    2,812
    Location:
    Philippines
    First Language:
    Tagalog
    You can try $game_map.events[id].z = value

    but afaik, the event viewport itself is below the image viewport so it might not work. And this is for Ace..

    Also what RM are you using? You posted on RGSS script support so it could be XP, VX or VX Ace..
     
    #4
  5. slimmmeiske2

    slimmmeiske2 Little Red Riding Hood Moderator

    Messages:
    5,172
    Likes Received:
    3,924
    Location:
    Belgium
    First Language:
    Dutch
    Primarily Uses:
    RMXP
    It's posted in RGSS Script Requests, so that's XP.
     
    #5
  6. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,396
    Likes Received:
    2,812
    Location:
    Philippines
    First Language:
    Tagalog
    I misread.. I thought it was RGSSX xD
     
    #6
  7. Andrea87Sky

    Andrea87Sky Ah sh*t, here we go again. Veteran

    Messages:
    30
    Likes Received:
    1
    Location:
    Sicily
    First Language:
    Italian
    Primarily Uses:
    RMXP
    Exactly

    Really? I'll try then.
     
    #7
  8. Andrea87Sky

    Andrea87Sky Ah sh*t, here we go again. Veteran

    Messages:
    30
    Likes Received:
    1
    Location:
    Sicily
    First Language:
    Italian
    Primarily Uses:
    RMXP
    It don't affect pictures, it affect tiles. I need an event to stay above a picture.
     
    #8
  9. Tillymander

    Tillymander Warper Member

    Messages:
    2
    Likes Received:
    0
    First Language:
    English
    Primarily Uses:
    Other
    I'm 90% sure you asked this a few weeks ago, and you could accomplish this, in turn you'd break half of the other systems in place.
    Are you asking someone to rewrite half the standard scripts to move an even above a picture...?
     
    #9
  10. DerVVulfman

    DerVVulfman Resident Werewolf Veteran

    Messages:
    217
    Likes Received:
    110
    First Language:
    English
    Primarily Uses:
    RMXP
    It's not pretty. I literally just slapped this together:

    Almost nothing is impossible. Just sometimes... plain freakin' stubborn.
    Code:
    #==============================================================================
    # ** Sprites in the Sky
    #    by DerVVulfman (May 16, 2019)
    #    for Andrea87Sky (hence the name)
    #------------------------------------------------------------------------------
    #  This script takes the 'pictures' out of the 2nd viewport (Viewport2) and
    #  reintroduces them into Viewport 1 at a projected z-Depth of 3001-3050, so
    #  they are above the fog effect.
    
    #  It also adds a new value to the Game and Sprite Character system so the
    #  z-Depth of any sprite can be altered.
    #
    #  You can use a command of $game_player.z_adjustment = 3000
    #  or make a call like $game_map.events[3].z_adjustment = 4000
    #  A z_adjustment setting of 0 is considered normal
    #==============================================================================
    
    
    #==============================================================================
    # ** Game_Character
    #------------------------------------------------------------------------------
    #  This class deals with characters. It's used as a superclass for the
    #  Game_Player and Game_Event classes.
    #==============================================================================
    
    class Game_Character
      #--------------------------------------------------------------------------
      # * Public Instance Variables
      #--------------------------------------------------------------------------
      attr_accessor :z_adjustment             # Change to Z-Depth
      #--------------------------------------------------------------------------
      # * Alias Listings
      #--------------------------------------------------------------------------
      alias change_pics_sprites_initialize initialize
      #--------------------------------------------------------------------------
      # * Public Instance Variables
      #--------------------------------------------------------------------------
      def initialize
        # The original call
        change_pics_sprites_initialize
        # Set our default
        @z_adjustment = 0
      end
    end
    
    
    
    #==============================================================================
    # ** 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
      #--------------------------------------------------------------------------
      # * Public Instance Variables
      #--------------------------------------------------------------------------
      attr_accessor :z_adjustment             # Change to Z-Depth
      #--------------------------------------------------------------------------
      # * Clear Starting Flag
      #--------------------------------------------------------------------------
      def z_adjustment
        @z_adjustment
      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 :character                # character
      #--------------------------------------------------------------------------
      # * Frame Update
      #--------------------------------------------------------------------------
      alias change_pics_sprites_update update
      #--------------------------------------------------------------------------
      # * Frame Update
      #--------------------------------------------------------------------------
      def update
        change_pics_sprites_update
        self.z += @character.z_adjustment
      end
    end
    
    
    
    #==============================================================================
    # ** Sprite_Picture
    #------------------------------------------------------------------------------
    #  This sprite is used to display the picture.It observes the Game_Character
    #  class and automatically changes sprite conditions.
    #==============================================================================
    
    class Sprite_Picture < Sprite
      #--------------------------------------------------------------------------
      # * Dispose
      #--------------------------------------------------------------------------
      alias change_sprite_pictures_update update
      #--------------------------------------------------------------------------
      # * Frame Update
      #--------------------------------------------------------------------------
      def update
        # Original call
        change_sprite_pictures_update
        # Increase Z to make it above fogs
        self.z += 3000
      end
    end
    
    
    
    #==============================================================================
    # ** Spriteset_Map
    #------------------------------------------------------------------------------
    #  This class brings together map screen sprites, tilemaps, etc.
    #  It's used within the Scene_Map class.
    #==============================================================================
    
    class Spriteset_Map
      #--------------------------------------------------------------------------
      # * Alias Listings
      #--------------------------------------------------------------------------
      alias change_pics_spriteset_initialize initialize
      #--------------------------------------------------------------------------
      # * Object Initialization
      #--------------------------------------------------------------------------
      def initialize
        change_pics_spriteset_initialize
        # Re-Make picture sprites
        @picture_sprites = []
        for i in 1..50
          @picture_sprites.push(Sprite_Picture.new(@viewport1,
            $game_screen.pictures[i]))
        end
      end
    end
     
    #10
  11. Andrea87Sky

    Andrea87Sky Ah sh*t, here we go again. Veteran

    Messages:
    30
    Likes Received:
    1
    Location:
    Sicily
    First Language:
    Italian
    Primarily Uses:
    RMXP
    OH MY GOD, THANK YOU! THAT'S WHAT I WAS SEARCHING!

    But sadly it gives me this error: https://cdn.discordapp.com/attachme...05355264/bandicam_2019-05-29_21-09-49-707.png
     
    #11
  12. DerVVulfman

    DerVVulfman Resident Werewolf Veteran

    Messages:
    217
    Likes Received:
    110
    First Language:
    English
    Primarily Uses:
    RMXP
    Heh... you don't need to quote the WHOLE post... just a little bit to get my attention. ;) If it's a big post, you certainly wouldn't wanna. :D

    So what I'm thinking, is that you have something that 'stalls' the creation of the character, so it's trying to make the sprite before the game character is readied.... so.....................

    I added some tests so it won't try to alter the sprite if..
    1) Self (the sprite itself) is nil .... the sprite hasn't been generated
    2) @character is nil ....the character data hasn't been generated
    --or--
    3) @character.z_adjustment is nil .... nothing set.

    So here goes:
    Code:
    #==============================================================================
    # ** Sprites in the Sky
    #    by DerVVulfman (May 29, 2019)
    #    for Andrea87Sky (hence the name)
    #    Version 1.1
    #------------------------------------------------------------------------------
    #  This script takes the 'pictures' out of the 2nd viewport (Viewport2) and
    #  reintroduces them into Viewport 1 at a projected z-Depth of 3001-3050, so
    #  they are above the fog effect.
    #
    #  It also adds a new value to the Game and Sprite Character system so the
    #  z-Depth of any sprite can be altered.
    #
    #  You can use a command of $game_player.z_adjustment = 3000
    #  or make a call like $game_map.events[3].z_adjustment = 4000
    #  A z_adjustment setting of 0 is considered normal
    #==============================================================================
    
    
    #==============================================================================
    # ** Game_Character
    #------------------------------------------------------------------------------
    #  This class deals with characters. It's used as a superclass for the
    #  Game_Player and Game_Event classes.
    #==============================================================================
    
    class Game_Character
      #--------------------------------------------------------------------------
      # * Public Instance Variables
      #--------------------------------------------------------------------------
      attr_accessor :z_adjustment             # Change to Z-Depth
      #--------------------------------------------------------------------------
      # * Alias Listings
      #--------------------------------------------------------------------------
      alias change_pics_sprites_initialize initialize
      #--------------------------------------------------------------------------
      # * Public Instance Variables
      #--------------------------------------------------------------------------
      def initialize
        # The original call
        change_pics_sprites_initialize
        # Set our default
        @z_adjustment = 0
      end
    end
    
    
    
    #==============================================================================
    # ** 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
      #--------------------------------------------------------------------------
      # * Public Instance Variables
      #--------------------------------------------------------------------------
      attr_accessor :z_adjustment             # Change to Z-Depth
      #--------------------------------------------------------------------------
      # * Clear Starting Flag
      #--------------------------------------------------------------------------
      def z_adjustment
        @z_adjustment
      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 :character                # character
      #--------------------------------------------------------------------------
      # * Frame Update
      #--------------------------------------------------------------------------
      alias change_pics_sprites_update update
      #--------------------------------------------------------------------------
      # * Frame Update
      #--------------------------------------------------------------------------
      def update
        # Original call
        change_pics_sprites_update
        # Ensure that neither self nor @character is nil...
        return if self.nil?
        return if @character.nil?
        return if @character.z_adjustment.nil?
        # Adjust
        self.z += @character.z_adjustment
      end
    end
    
    
    
    #==============================================================================
    # ** Sprite_Picture
    #------------------------------------------------------------------------------
    #  This sprite is used to display the picture.It observes the Game_Character
    #  class and automatically changes sprite conditions.
    #==============================================================================
    
    class Sprite_Picture < Sprite
      #--------------------------------------------------------------------------
      # * Dispose
      #--------------------------------------------------------------------------
      alias change_sprite_pictures_update update
      #--------------------------------------------------------------------------
      # * Frame Update
      #--------------------------------------------------------------------------
      def update
        # Original call
        change_sprite_pictures_update
        # Increase Z to make it above fogs
        self.z += 3000
      end
    end
    
    
    
    #==============================================================================
    # ** Spriteset_Map
    #------------------------------------------------------------------------------
    #  This class brings together map screen sprites, tilemaps, etc.
    #  It's used within the Scene_Map class.
    #==============================================================================
    
    class Spriteset_Map
      #--------------------------------------------------------------------------
      # * Alias Listings
      #--------------------------------------------------------------------------
      alias change_pics_spriteset_initialize initialize
      #--------------------------------------------------------------------------
      # * Object Initialization
      #--------------------------------------------------------------------------
      def initialize
        change_pics_spriteset_initialize
        # Re-Make picture sprites
        @picture_sprites = []
        for i in 1..50
          @picture_sprites.push(Sprite_Picture.new(@viewport1,
            $game_screen.pictures[i]))
        end
      end
    end
     
    #12
  13. Andrea87Sky

    Andrea87Sky Ah sh*t, here we go again. Veteran

    Messages:
    30
    Likes Received:
    1
    Location:
    Sicily
    First Language:
    Italian
    Primarily Uses:
    RMXP
    Uh now it works, but without doing anything the color screen tone affects now the pictures, that wasn't the exactly thing i wanted to do, at least maybe made a specific picture to be affected to color screen tone.. Or maybe a switch for change the viewpoint of a picture

    Anyway I've just clicked on "reply" on your comments, I didn't quoted it manually.
     
    #13
  14. KK20

    KK20 Just some XP Scripter Veteran

    Messages:
    62
    Likes Received:
    29
    Location:
    Orange County, California
    First Language:
    English
    Primarily Uses:
    RMXP
    Code:
    #  This script takes the 'pictures' out of the 2nd viewport (Viewport2) and
    #  reintroduces them into Viewport 1 at a projected z-Depth of 3001-3050, so
    #  they are above the fog effect.
     
    #14
  15. Andrea87Sky

    Andrea87Sky Ah sh*t, here we go again. Veteran

    Messages:
    30
    Likes Received:
    1
    Location:
    Sicily
    First Language:
    Italian
    Primarily Uses:
    RMXP
    Daamn, ok then, so what about making like a new character type? For example the "player" is tecnically another type of character, idk if it's possible, but I'll ask anyway.

    Maybe a new character type called "Bullets" that has like viewport 3, so I can make that daamn bullet hell system, and maybe to ensure that the game identifies it, make a comment on an events that says like "bullet" or something.
     
    Last edited: Jun 2, 2019
    #15

Share This Page