- Joined
- Nov 30, 2014
- Messages
- 240
- Reaction score
- 167
- First Language
- Engrish
- Primarily Uses
Yay, another script in the works! :naughty: Im hoping this forum is a bit more active...
What I want this script to do is to Loop the Map like is possible in VX / Ace, but I dont have copies of either, which doesnt help. So far, the Map does loop, Passable works, Fogs and Panoramas (mostly) seem to work, but I dont think Im doing that quite right either. Where Im stuck is getting Events that are close to Map Edges do not display at all times because the Player is repositioned. Im not sure how they pulled it off in VX / Ace. I could be going about this totally wrong as well and correcting positions at the wrong time. Events need to be able to display consistently, so Im thinking maybe some sort of adjustment either to Sprites, or screen_x and screen_y?
Oh, and to add to the complexity, Im also hoping to have this script compatible with ANY form of Anti Lag script where Sprites dont get updated if they are not close to the screen. I havent even touched the Anti Lag part of it yet. Some assistance here is requested... Im fine with a collaboration script where any who put any effort into this are also titled as Authors.
Anyway, here is the script:
Feel free to replace the existing code in here if you'd like!
What I want this script to do is to Loop the Map like is possible in VX / Ace, but I dont have copies of either, which doesnt help. So far, the Map does loop, Passable works, Fogs and Panoramas (mostly) seem to work, but I dont think Im doing that quite right either. Where Im stuck is getting Events that are close to Map Edges do not display at all times because the Player is repositioned. Im not sure how they pulled it off in VX / Ace. I could be going about this totally wrong as well and correcting positions at the wrong time. Events need to be able to display consistently, so Im thinking maybe some sort of adjustment either to Sprites, or screen_x and screen_y?
Oh, and to add to the complexity, Im also hoping to have this script compatible with ANY form of Anti Lag script where Sprites dont get updated if they are not close to the screen. I havent even touched the Anti Lag part of it yet. Some assistance here is requested... Im fine with a collaboration script where any who put any effort into this are also titled as Authors.
Anyway, here is the script:
# This script is NOT intended for use or distribution. It has BUGS and will# not work in its present form as expected. This is what I need a bit# of assistance with! Panoramas and Fogs dont work quite right, and# Events close to Map Edges are not always displayed when Map is Looped.## - Heretic# Map ID - Obvious# Loop Type:# 0 - No Looping (Normal Maps and Collisions# 1 - Vertical Loop, no Horizontal# 2 - Horizontal Loop, no Vertical# 3 - Loop Horizontal and Vertical# ConfigLOOP_MAPS = [ [map_id = 1, loop_type = 3] ]# End Configclass Game_Map #-------------------------------------------------------------------------- # * Public Instance Variables - Game_Map #-------------------------------------------------------------------------- attr_accessor :loop_type # 0: Off, 1: Vertical, 2: Horizontal, 3: Both attr_accessor :fog_ox # Fog Origin X attr_accessor :fog_oy # Fog Origin Y attr_accessor :loop_pan_x # Panorama Adjustment when Looping Horizontal attr_accessor :loop_pan_y # Panorama Adjustment when Looping Vertical #-------------------------------------------------------------------------- # * Setup - Game_Map # map_id : Map ID #-------------------------------------------------------------------------- alias loop_map_setup setup unless $@ def setup(map_id) # Set the Default Loop Type @loop_type = 0 # Panorama Adjustments for Looping @loop_pan_x = 0 @loop_pan_y = 0 # If Config has Looping Map for loops in LOOP_MAPS # Set Loop Type based on Config @loop_type = loops[1] if loops[0] == map_id end # Call Original or other Aliases of Setup loop_map_setup(map_id) end #-------------------------------------------------------------------------- # * Loop Horizontally? - Game_Map #-------------------------------------------------------------------------- def loop_horizontal? @loop_type > 1 end #-------------------------------------------------------------------------- # * Loop Vertically? - Game_Map #-------------------------------------------------------------------------- def loop_vertical? @loop_type == 1 or @loop_type == 3 end #-------------------------------------------------------------------------- # * Valid? - Game_Map # - Adjusts X and Y values for Looping Maps #-------------------------------------------------------------------------- alias map_loop_valid? valid? unless $@ def valid?(x, y) # Fix X Value to Map Range if Map Loops Horizontally x %= @map.width if loop_horizontal? # Fix Y Value to Map Range if Map Loops Vertically y %= @map.height if loop_vertical? # Call Original or other Aliases map_loop_valid?(x, y) end #-------------------------------------------------------------------------- # * Passable? - Game_Map # - Adjusts X and Y values for Looping Maps #-------------------------------------------------------------------------- alias map_loop_passable? passable? unless $@ def passable?(x, y, d, self_event = nil) # Fix X Value to Map Range if Map Loops Horizontally x %= @map.width if loop_horizontal? # Fix Y Value to Map Range if Map Loops Vertically y %= @map.height if loop_vertical? # Call Original or other Aliases with updated X and Y map_loop_passable?(x, y, d, self_event) end #-------------------------------------------------------------------------- # * Scroll Down # distance : scroll distance #-------------------------------------------------------------------------- alias map_loop_scroll_down scroll_down unless $@ def scroll_down(distance) # If Map Loops Vertically if loop_vertical? # Update Display with no Limiters @display_y += distance else # Call Original or other Aliases map_loop_scroll_down(distance) end end #-------------------------------------------------------------------------- # * Scroll Left # distance : scroll distance #-------------------------------------------------------------------------- alias map_loop_scroll_left scroll_left unless $@ def scroll_left(distance) # If Map Loops Horizontal if loop_horizontal? # Update Display with no Limiters @display_x -= distance else # Call Original or other Aliases map_loop_scroll_left(distance) end end #-------------------------------------------------------------------------- # * Scroll Right # distance : scroll distance #-------------------------------------------------------------------------- alias map_loop_scroll_right scroll_right unless $@ def scroll_right(distance) # If Map Loops Horizontal if loop_horizontal? @display_x += distance else # Call Original or other Aliases map_loop_scroll_right(distance) end end #-------------------------------------------------------------------------- # * Scroll Up # distance : scroll distance #-------------------------------------------------------------------------- alias map_loop_scroll_up scroll_up unless $@ def scroll_up(distance) # If Map Loops Vertically if loop_vertical? @display_y -= distance else # Call Original or other Aliases map_loop_scroll_up(distance) end endendclass Spriteset_Map #-------------------------------------------------------------------------- # * Update - Spriteset_Map # - Adjusts Panorama Position on Looping Maps #-------------------------------------------------------------------------- alias loop_map_update update unless $@ def update # Call Original or other Aliases loop_map_update # Clear Fog Looping Flags @panorama.ox += $game_map.loop_pan_x @panorama.oy += $game_map.loop_pan_y endendclass Game_Event #-------------------------------------------------------------------------- # * Determine if Near Visible Area of Screen - VXA # dx: A certain number of tiles left/right of screen's center # dy: A certain number of tiles above/below screen's center #-------------------------------------------------------------------------- def near_the_screen?(dx = 12, dy = 8) ax = $game_map.adjust_x(@real_x) - Graphics.width / 2 / 32 ay = $game_map.adjust_y(@real_y) - Graphics.height / 2 / 32 ax >= -dx && ax <= dx && ay >= -dy && ay <= dy end #-------------------------------------------------------------------------- # * Map Loop Position - Game_Player # - Calls for Corrections when Player triggers a Map Loop #-------------------------------------------------------------------------- def event_map_loop_position return unless $game_map.loop_type > 0 and (moving? or jumping?) # If Horizontal Map Loop if $game_map.loop_horizontal? # Correct Positions if outside Map Boundaries if @real_x < 0 or @real_x > $game_map.width * 128 # Fix Event's Position @x %= $game_map.width @real_x %= $game_map.width * 128 end end # If Horizontal Map Loop if $game_map.loop_vertical? # Correct Positions if outside Map Boundaries if @real_y < 0 or @real_y > $game_map.height * 128 # Fix Event's Position @y %= $game_map.height @real_y %= $game_map.height * 128 end end end #-------------------------------------------------------------------------- # * Update - Game_Event #-------------------------------------------------------------------------- alias map_loop_update update unless $@ def update # Call Original or other Aliases map_loop_update # Update Map Loop Positions event_map_loop_position end endclass Game_Player #-------------------------------------------------------------------------- # * Set Map Display Position to Center of Screen - Game_Player #-------------------------------------------------------------------------- alias loop_map_center center unless $@ def center(x, y) # Call Original or other Aliases loop_map_center(x, y) # Recenter Display Horizontally if Map Loops Horizontal $game_map.display_x = x * 128 - CENTER_X if $game_map.loop_horizontal? # Recenter Display Vertically if Map Loops Vertical $game_map.display_y = y * 128 - CENTER_Y if $game_map.loop_vertical? end #-------------------------------------------------------------------------- # * Correct Loop Left - Game_Player # - Corrects Player Coordinates, Fogs, and Panoramas on a Map Loop #-------------------------------------------------------------------------- def correct_loop_left fog_ox = $game_map.fog_ox # Fix Player's Position @x %= $game_map.width @real_x %= $game_map.width * 128 # Correct Map Display $game_map.display_x %= $game_map.width * 128 # Correct Fog Display $game_map.fog_ox -= $game_map.width * 32 $game_map.fog_ox %= $game_map.width * 128 # Correct Panorama Display $game_map.loop_pan_x -= $game_map.width * 16 end #-------------------------------------------------------------------------- # * Correct Loop Right - Game_Player # - Corrects Player Coordinates, Fogs, and Panoramas on a Map Loop #-------------------------------------------------------------------------- def correct_loop_right # Fix Player's Position @x %= $game_map.width @real_x %= $game_map.width * 128 # Correct Map Display $game_map.display_x %= @real_x - $game_map.width * 128 - 2 ** @move_speed # Correct Fog Display $game_map.fog_ox += $game_map.width * 32 $game_map.fog_ox %= $game_map.width * 128 # Correct Panorama Display $game_map.loop_pan_x += $game_map.width * 16 end #-------------------------------------------------------------------------- # * Correct Loop Up - Game_Player # - Corrects Player Coordinates, Fogs, and Panoramas on a Map Loop #-------------------------------------------------------------------------- def correct_loop_up # Fix Player's Position @y %= $game_map.height @real_y %= $game_map.height * 128 # Correct Map Display $game_map.display_y %= $game_map.height * 128 # Correct Fog Display $game_map.fog_oy -= $game_map.height * 32 # Correct Panorama Display $game_map.loop_pan_y -= $game_map.height * 16 end #-------------------------------------------------------------------------- # * Correct Loop Down - Game_Player # - Corrects Player Coordinates, Fogs, and Panoramas on a Map Loop #-------------------------------------------------------------------------- def correct_loop_down # Fix Player's Position @y %= $game_map.height @real_y %= $game_map.height * 128 # Correct Map Display $game_map.display_y %= @real_y - $game_map.height * 128 - 2 ** @move_speed # Correct Fog Display $game_map.fog_oy += $game_map.height * 32 # Correct Panorama Display $game_map.loop_pan_y += $game_map.height * 16 end #-------------------------------------------------------------------------- # * Map Loop Position - Game_Player # - Calls for Corrections when Player triggers a Map Loop #-------------------------------------------------------------------------- def map_loop_position return unless $game_map.loop_type > 0 and (moving? or jumping?) # If Horizontal Map Loop if $game_map.loop_horizontal? # Correct Positions if outside Map Boundaries correct_loop_left if @real_x < 0 correct_loop_right if @real_x > $game_map.width * 128 end # If Horizontal Map Loop if $game_map.loop_vertical? # Correct Positions if outside Map Boundaries correct_loop_up if @real_y < 0 correct_loop_down if @real_y > $game_map.height * 128 end end #-------------------------------------------------------------------------- # * Update - Game_Player #-------------------------------------------------------------------------- alias map_loop_update update unless $@ def update # Call Original or other Aliases map_loop_update # Update Map Loop Positions map_loop_position endend
