Minor script conflict between Napoleon's Minimap and Galv's Character Effects

Discussion in 'RGSS3 Script Requests' started by KingHazeel, Jul 26, 2019.

Thread Status:
Not open for further replies.
  1. KingHazeel

    KingHazeel Veteran Veteran

    Messages:
    125
    Likes Received:
    5
    First Language:
    English
    Primarily Uses:
    RMVXA
    Basically there's this bug where, if the mirror effect in Galv's Chracter Effects is active, the character sprite on Napoleon's Minimap will still move in the correct position but will sort of be moonwalking backwards. I was wondering if anyone could kindly provide a fix for this? Thanks!

    Napoleon Mini Map:

    https://forums.rpgmakerweb.com/index.php?threads/napoleons-minimap.13801/

    Galv's Character Effects:

    https://www.rpgmakercentral.com/topic/12803-character-effects/

    EDIT: I think it has something to do with this in Napeleon's Mini Map:

    Code:
    def update_player_cursor
        player_character = $game_player.sprite
        return if !player_character || player_character.disposed?
       
        @player_sprite.bitmap.clear
        @player_sprite.bitmap.stretch_blt(Rect.new(0,0,@player_sprite.bitmap.width, @player_sprite.bitmap.height),
                                          player_character.bitmap,
                                          player_character.src_rect,
                                          255)
      end
    The player_character.src_rect is probably the culprit due to influence here in Galv's

    Code:
    def update_src_rect
        if @character.reflect_sprite
          index = @character.reflect_sprite[1]
        else
          index = @character.character_index
        end
        pattern = @character.pattern < 3 ? @character.pattern : 1
        sx = (index % 4 * 3 + pattern) * @cw
        sy = (index / 4 * 4 + (10 - @character.direction - 2) / 2) * @ch
        self.src_rect.set(sx, sy, @cw, @ch)
      end
    I'm just not sure how to fix it. ^^;

    EDIT 2: OK, I managed to create a fix, so I'll request for this thread to be closed.
     
    Last edited: Jul 27, 2019
    #1
  2. hiddenone

    hiddenone Lurker Extraordinaire Moderator

    Messages:
    1,985
    Likes Received:
    4,698
    First Language:
    english
    Primarily Uses:
    RMMV
    @KingHazeel Are you willing to share the fix you made? It may help someone else out in the future.
     
    #2
  3. KingHazeel

    KingHazeel Veteran Veteran

    Messages:
    125
    Likes Received:
    5
    First Language:
    English
    Primarily Uses:
    RMVXA
    Well...it's less of an added patch and more of a change to the script itself. And I wasn't sure if posting the script itself was allowed. If it is, then I can share it...though I should warn anyone using it that I have little knowledge of Ruby and this is less an optimal patch and more of a band-aid fixed that simply "works".
     
    #3
  4. hiddenone

    hiddenone Lurker Extraordinaire Moderator

    Messages:
    1,985
    Likes Received:
    4,698
    First Language:
    english
    Primarily Uses:
    RMMV
    Well, posting it would depend on the terms of the scripts, but just explaining what you changed and where without posting the scripts themselves should be fine.
     
    #4
  5. KingHazeel

    KingHazeel Veteran Veteran

    Messages:
    125
    Likes Received:
    5
    First Language:
    English
    Primarily Uses:
    RMVXA
    Very well. In Galv's script, I made a class "Sprite_Mirror_Fix" and the only function inside it is the standard update_src_rect

    Code:
    class Sprite_Mirror_Fix < Sprite_Character
      def update_src_rect
        if @character.reflect_sprite
          index = @character.reflect_sprite[1]
        else
          index = @character.character_index
        end
        pattern = @character.pattern < 3 ? @character.pattern : 1
        sx = (index % 4 * 3 + pattern) * @cw
        sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
        self.src_rect.set(sx, sy, @cw, @ch)
      end
    end 
    I put this below the Sprite_Mirror class. And under the "create effects" function, around like 445 or so, the mirror effects are created. I add a call to Sprite_Mirror_Fix every time Sprite_Mirror is called. i.e. replacing this...

    @mirror_sprites.push(Sprite_Mirror.new(@viewport1, e)) if e.reflect

    with this:

    @mirror_sprites.push(Sprite_Mirror.new(@viewport1, e)) && @mirror_sprites.push(Sprite_Mirror_Fix.new(@viewport1, e)) if e.reflect

    If I'm understanding this correctly, this means the most recent update for src_rect is the standard one, not a mirrored one. And since the map uses the most recent one, this issue is fixed. Now I'm sure someone with a better understanding of Ruby and the code itself could provide a more....elegant...solution, but this worked for me.
     
    #5
  6. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,932
    Likes Received:
    10,645
    First Language:
    English
    Primarily Uses:
    RMVXA

    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

     
    #6
Thread Status:
Not open for further replies.

Share This Page