Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #~ Map Edge Transfer (VX-Ace) v2.3 by Lain (formerly Jester)
- #~ Version History:
- #~ 06.FEB.2013 -> 1.0 -> Initial Release
- #~ 08.FEB.2013 -> 1.1 -> Bugfixes, Syntax Overhaul, 8-dir compatibility
- #~ 18.FEB.2013 -> 2.0 -> More Customization and compatibility with Slide-Effect
- #~ 05.MAR.2013 -> 2.1 -> Compatibility improvement
- #~ 12.MAR.2013 -> 2.1a-> Minor optimizations
- #~ 15.MAR.2013 -> 2.2 -> A Script call to manually choose the transfer coordinates (Take a look at line 72 and below)
- #~ 15.MAR.2013 -> 2.2a -> Hotfix
- #~ 21.SEP.2013 -> 2.3 -> Added "Offset" Script call (Take a look at line ~100 and below)
- #~ Features:
- #~ Automatic Map-Edge-Transfer system
- #~ More realistic looking transfer
- #~ This Script allows the player to automatically transfer to the next
- #~ map when hitting the edge of the current map, using in-game variables.
- #~ It also adds a small feature to make it look like the player actually
- #~ WALKS out of the current map into the new map instead of teleporting.
- #~ This Script is NOT PLUG'N'PLAY, but relatively easy to use.
- #~ Take a look at the Customization section.
- #~ If you still have problems, try out the recent Demo before asking for help!
- #~ Bugs:
- #~ (no known issues)
- #~ Conflicts:
- #~ Place this Script below any movement scripts, like 8-dir-movement
- #~ I am fine with Compatibility fix requests if you say "PLEEAASEEEE!!!"
- #~ Feel free to report any Bugs and Conflicts that are not listed above.
- #~ I am available for feedback at rmrk.net and rpgmakervxace.net.
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
- $jimported ||= {} #<- DON'T TOUCH ME!!!
- $jimported[:jms_met] = 2.3 #<- DON'T TOUCH ME!!!
- module JMSC # Jester Mini-Script Customization
- module MET # Map Edge Transfer
- #~~~~~~~~~~~~~~~~~~~~~~~~~Customization~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
- # Autotransfer Options:
- # In-Game Variables that define the Map-ID you will transfer to, when
- # hitting the Map Edge on the respective cardinal direction.
- # Setting them to 0 will disable transfer for the specific Edge:
- MapID_North_Variable = 21 #North
- MapID_East_Variable = 22 #East
- MapID_South_Variable = 23 #South
- MapID_West_Variable = 24 #West
- # In-Game Switch to temporarely disable Map Edge Transfer:
- Disable_AutoEdgeTransfer_Switch = 21
- # The default Transfer-Effect for Map Edge Transfer:
- # 0 = Black
- # 1 = White
- # 2 = None
- Fade_Type = 2
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
- # Compatibility Options:
- # Set to true, if you use Scripts like Pixel Movement:
- New_Move_Straight = false
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
- # END OF CUSTOMIZATION!
- #~ OPTIONAL script calls:
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
- #~ You can specifically change the transfer information with this Script call
- #~ (The informations will reset after transferring):
- #~ $game_player.jms_met_transferinfo(card, x, y, d)
- #~ card = The cardinal direction you want to change the transfer info of
- #~ (8, 6, 4 or 2) or ("North", "East", "South" or "West")
- #~ x = The x coordinates the player will transfer to
- #~ Can be a Integer or false (false = no change)
- #~ y = The y coordinates the player will transfer to
- #~ Can be a Integer of false (false = no change)
- #~ d = The direction (8/6/4/2) the player will face after transfer
- #~ (8, 6, 4 or 2) or false (false = no change)
- #~ Example:
- #~ $game_player.jms_met_transferinfo(8, 5, false, 4)
- #~ Changes transfer informations for if you travel through the north
- #~ It will force the player to transfer to x coordinate "5"
- #~ The y coordinate the player will transfer to doesn't change
- #~ The player will face into direction "4" (which is West)
- #~ You can also add an Offset to the x or y coordinates with these script calls
- #~ (The informations will reset after transferring):
- #~ $game_player.jms_met_addoffset(card, axis, offset)
- #~ card = The cardinal direction you want to add a offset to
- #~ (8, 6, 4 or 2) or ("North", "East", "South" or "West")
- #~ axis = "x" or "y"
- #~ offset = The amount of offset you want to add (can be negative)
- #~ Example:
- #~ $game_player.jms_met_addoffset("North", "x", -3)
- #~ Adds offset if you travel through the north
- #~ 3 will be subtracted from the x-axis
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
- #~~~~~~~~~~~~~~~~~~~~~~~Main Script~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
- # Don't edit anything below, unless you know what you are doing:
- end #module MET
- end #module JMSC
- #==============================================================================
- # ** Game_Player
- #==============================================================================
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # * [Alias] initialize
- # * Adding new variables
- #--------------------------------------------------------------------------
- alias jms_MapEdgeTransfer_GameCharacterBase_init initialize
- def initialize
- jms_MapEdgeTransfer_GameCharacterBase_init
- @jms_met_through = false
- @jms_met_xnorth = @jms_met_ynorth = @jms_met_dnorth = false
- @jms_met_xeast = @jms_met_yeast = @jms_met_deast = false
- @jms_met_xsouth = @jms_met_ysouth = @jms_met_dsouth = false
- @jms_met_xwest = @jms_met_ywest = @jms_met_dwest = false
- @jms_met_xoffnorth = @jms_met_yoffnorth = @jms_met_xoffeast = 0
- @jms_met_yoffeast = @jms_met_xoffsouth = @jms_met_yoffsouth = 0
- @jms_met_xoffwest = @jms_met_yoffwest = 0
- end
- #--------------------------------------------------------------------------
- # * [Alias] passable?
- # * If the new variable is on, everything will be passable!
- #--------------------------------------------------------------------------
- alias jms_MapEdgeTransfer_GameCharacterBase_passable? passable?
- def passable?(x, y, d)
- return true if @jms_met_through
- jms_MapEdgeTransfer_GameCharacterBase_passable?(x, y, d)
- end
- #--------------------------------------------------------------------------
- # * [Alias] update
- # * Makes autotransfer possible
- #--------------------------------------------------------------------------
- alias jms_MapEdgeTransfer_GamePlayer_update update
- def update
- jms_met_autotransfer
- jms_MapEdgeTransfer_GamePlayer_update
- end
- #--------------------------------------------------------------------------
- # * [Alias] move_by_input
- # * Makes passing through map edges possible
- #--------------------------------------------------------------------------
- alias jms_MapEdgeTransfer_GamePlayer_movebyinput move_by_input
- def move_by_input
- if jms_met_edgeblock? && jms_met_edgepassable? > 0
- jms_met_executeedgepassing
- else
- jms_MapEdgeTransfer_GamePlayer_movebyinput
- end
- end
- #--------------------------------------------------------------------------
- # * [Alias] reserve_transfer
- # * Resets variables of the scriptcall(s)
- #--------------------------------------------------------------------------
- alias jms_MapEdgeTransfer_gameplayer_reservetransfer reserve_transfer
- def reserve_transfer(*args)
- @jms_met_xnorth = @jms_met_ynorth = @jms_met_dnorth = false
- @jms_met_xeast = @jms_met_yeast = @jms_met_deast = false
- @jms_met_xsouth = @jms_met_ysouth = @jms_met_dsouth = false
- @jms_met_xwest = @jms_met_ywest = @jms_met_dwest = false
- @jms_met_xoffnorth = @jms_met_yoffnorth = @jms_met_xoffeast = 0
- @jms_met_yoffeast = @jms_met_xoffsouth = @jms_met_yoffsouth = 0
- @jms_met_xoffwest = @jms_met_yoffwest = 0
- jms_MapEdgeTransfer_gameplayer_reservetransfer(*args)
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
- # Method-chain: Map Edge Passing
- # Relevant Methods:
- # jms_met_edgeblock? <- Player movement blocked by edge?
- # jms_met_edgepassable? <- Is the edge passable and which edge is it?
- # jms_met_executeedgepassing <- Actually pass through the edge
- # Useful methods
- # jms_met_corner? <- Which Corner is the Player in? (diagonal number)
- # jms_met_movethrough(d) <- Move through everything, even edges (dir4 only)
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
- #--------------------------------------------------------------------------
- # * [New Method] jms_met_edgeblock?
- # * Return true if input will be blocked by a potentially passable edge
- #--------------------------------------------------------------------------
- def jms_met_edgeblock?
- return false if $game_switches[JMSC::MET::Disable_AutoEdgeTransfer_Switch]
- return true if jms_met_edgex? == jms_met_dirconvx?
- return true if jms_met_edgey? == jms_met_dirconvy?
- return false
- end
- #--------------------------------------------------------------------------
- # * [New Method] jms_met_edgepassable?
- # * Return dir number if edge that blocks the Player is passable variable-wise
- #--------------------------------------------------------------------------
- def jms_met_edgepassable?
- return 8 if jms_met_dirconvy? == 8 && jms_met_edgey? == 8 && $game_variables[JMSC::MET::MapID_North_Variable] > 0
- return 6 if jms_met_dirconvx? == 6 && jms_met_edgex? == 6 && $game_variables[JMSC::MET::MapID_East_Variable] > 0
- return 2 if jms_met_dirconvy? == 2 && jms_met_edgey? == 2 && $game_variables[JMSC::MET::MapID_South_Variable] > 0
- return 4 if jms_met_dirconvx? == 4 && jms_met_edgex? == 4 && $game_variables[JMSC::MET::MapID_West_Variable] > 0
- return 0
- end
- #--------------------------------------------------------------------------
- # * [New Method] jms_met_executeedgepassing
- # * Move the player through the edge
- #--------------------------------------------------------------------------
- def jms_met_executeedgepassing
- d = jms_met_edgepassable?
- jms_met_movethrough(d) unless jms_met_edgepassable? == 0
- end
- #--------------------------------------------------------------------------
- # * [New Method] jms_met_movethrough(d)
- # * Forces the player to move_straight through everything in direction "d"
- #--------------------------------------------------------------------------
- def jms_met_movethrough(d)
- return if !movable? || $game_map.interpreter.running?
- @jms_met_through = true
- jms_met_move_straight(d) if JMSC::MET::New_Move_Straight
- move_straight(d) if !JMSC::MET::New_Move_Straight
- @jms_met_through = false
- end
- #--------------------------------------------------------------------------
- # * [New Method] jms_met_dir8convx?
- # * Converts a dir8 input into a dir4 NUMBER (x axis)
- #--------------------------------------------------------------------------
- def jms_met_dirconvx?
- return 4 if Input.dir8 == 7 || Input.dir8 == 1 || Input.dir4 == 4 #west
- return 6 if Input.dir8 == 9 || Input.dir8 == 3 || Input.dir4 == 6 #east
- end
- #--------------------------------------------------------------------------
- # * [New Method] jms_met_dir8convy?
- # * Converts a dir8 input into a dir4 NUMBER (y axis)
- #--------------------------------------------------------------------------
- def jms_met_dirconvy?
- return 8 if Input.dir8 == 7 || Input.dir8 == 9 || Input.dir4 == 8 #north
- return 2 if Input.dir8 == 1 || Input.dir8 == 3 || Input.dir4 == 2 #south
- end
- #--------------------------------------------------------------------------
- # * [New Method] jms_met_corner?
- # * Return (diagonal) direction number if Player is on a map corner
- #--------------------------------------------------------------------------
- def jms_met_corner?
- return 9 if jms_met_edgex? == 8 && jms_met_edgey? == 6 #north-east
- return 3 if jms_met_edgex? == 2 && jms_met_edgey? == 6 #south-east
- return 1 if jms_met_edgex? == 2 && jms_met_edgey? == 4 #south-west
- return 7 if jms_met_edgex? == 8 && jms_met_edgey? == 4 #north-west
- return 0
- end
- #--------------------------------------------------------------------------
- # * [New Method] jms_met_edgex?
- # * Return direction number if Player is on on a map edge (x axis)
- #--------------------------------------------------------------------------
- def jms_met_edgex?
- return 4 if @real_x == 0 #west
- return 6 if @real_x + 1 == $game_map.width #east
- return 0
- end
- #--------------------------------------------------------------------------
- # * [New Method] jms_met_edgey?
- # * Return direction number if Player is on on a map edge (y axis)
- #--------------------------------------------------------------------------
- def jms_met_edgey?
- return 8 if @real_y == 0 #north
- return 2 if @real_y + 1 == $game_map.height #south
- return 0
- end
- #End of Method-Chain: Map Edge Passing
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
- # Method-chain: Automatic Transfer
- # Relevant Methods:
- # jms_met_autotransfer <- Checks if Conditions for automatic transfer are met
- # Useful Methods:
- # jms_met_overedge? <- Return number if Player is directly behind an edge
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
- #--------------------------------------------------------------------------
- # * [New Method] jms_met_autotransfer
- # * Go on with autotransfer, if player passed through an edge
- #--------------------------------------------------------------------------
- def jms_met_autotransfer
- jms_met_transfer(8) if jms_met_overedge? == 8 && $game_variables[JMSC::MET::MapID_North_Variable] > 0
- jms_met_transfer(6) if jms_met_overedge? == 6 && $game_variables[JMSC::MET::MapID_East_Variable] > 0
- jms_met_transfer(2) if jms_met_overedge? == 2 && $game_variables[JMSC::MET::MapID_South_Variable] > 0
- jms_met_transfer(4) if jms_met_overedge? == 4 && $game_variables[JMSC::MET::MapID_West_Variable] > 0
- end
- #--------------------------------------------------------------------------
- # * [New Method] jms_met_tranfer(d)
- # * Executing the automatic transfer to cardinal direction map "d"
- #--------------------------------------------------------------------------
- def jms_met_transfer(d)
- $game_temp.fade_type = JMSC::MET::Fade_Type
- dtrans = d
- if d == 8 #north
- new_map = $game_variables[JMSC::MET::MapID_North_Variable]
- load_map = load_data(sprintf("Data/Map%03d.rvdata2", new_map))
- new_x = @real_x unless @jms_met_xnorth
- new_x = @jms_met_xnorth if @jms_met_xnorth
- new_x += @jms_met_xoffnorth
- new_y = load_map.height - 1 unless @jms_met_ynorth
- new_y = @jms_met_ynorth if @jms_met_ynorth
- new_y += @jms_met_yoffnorth
- dtrans = @jms_met_dnorth if @jms_met_dnorth
- end
- if d == 6 #east
- new_x = 0 unless @jms_met_xeast
- new_x = @jms_met_xeast if @jms_met_xeast
- new_x += @jms_met_xoffeast
- new_y = @real_y unless @jms_met_yeast
- new_y = @jms_met_yeast if @jms_met_yeast
- new_y += @jms_met_yoffeast
- new_map = $game_variables[JMSC::MET::MapID_East_Variable]
- dtrans = @jms_met_deast if @jms_met_deast
- end
- if d == 2 #south
- new_x = @real_x unless @jms_met_xsouth
- new_x = @jms_met_xsouth if @jms_met_xsouth
- new_x += @jms_met_xoffsouth
- new_y = 0 unless @jms_met_ysouth
- new_y = @jms_met_ysouth if @jms_met_ysouth
- new_y += @jms_met_yoffsouth
- new_map = $game_variables[JMSC::MET::MapID_South_Variable]
- dtrans = @jms_met_dsouth if @jms_met_dsouth
- end
- if d == 4 #west
- new_map = $game_variables[JMSC::MET::MapID_West_Variable]
- load_map = load_data(sprintf("Data/Map%03d.rvdata2", new_map))
- new_x = load_map.width - 1 unless @jms_met_xwest
- new_x = @jms_met_xwest if @jms_met_xwest
- new_x += @jms_met_xoffwest
- new_y = @real_y unless @jms_met_ywest
- new_y = @jms_met_ywest if @jms_met_ywest
- new_y += @jms_met_yoffwest
- dtrans = @jms_met_dwest if @jms_met_dwest
- end
- if $jimported[:jms_sef] != nil
- $game_temp.jms_met_sliding = true unless $game_switches[JMSC::SEF::Disable_Sliding_Switch]
- end
- reserve_transfer(new_map, new_x, new_y, dtrans)
- end
- #--------------------------------------------------------------------------
- # * [New Method] jms_met_transferinfo(card, x, y, d)
- # * Changes transfer details
- #--------------------------------------------------------------------------
- def jms_met_transferinfo(card, x = false, y = false, d = false)
- if card == "North" || card == 8
- @jms_met_xnorth = x
- @jms_met_ynorth = y
- @jms_met_dnorth = d
- end
- if card == "East" || card == 6
- @jms_met_xeast = x
- @jms_met_yeast = y
- @jms_met_deast = d
- end
- if card == "South" || card == 2
- @jms_met_xsouth = x
- @jms_met_ysouth = y
- @jms_met_dsouth = d
- end
- if card == "West" || card == 4
- @jms_met_xwest = x
- @jms_met_ywest = y
- @jms_met_dwest = d
- end
- end
- def jms_met_addoffset(card, axis, offset)
- if card == "North" || card == 8
- @jms_met_xoffnorth = offset if axis == "x"
- @jms_met_yoffnorth = offset if axis == "y"
- end
- if card == "East" || card == 6
- @jms_met_xoffeast = offset if axis == "x"
- @jms_met_yoffeast = offset if axis == "y"
- end
- if card == "South" || card == 2
- @jms_met_xoffsouth = offset if axis == "x"
- @jms_met_yoffsouth = offset if axis == "y"
- end
- if card == "West" || card == 4
- @jms_met_xoffwest = offset if axis == "x"
- @jms_met_yoffwest = offset if axis == "y"
- end
- end
- #--------------------------------------------------------------------------
- # * [New Method] jms_met_overedge?
- # * Return direction number if Player passed one of the map edges
- #--------------------------------------------------------------------------
- def jms_met_overedge?
- return 8 if @real_y + 1 == 0 #north
- return 6 if $game_map.width == @real_x #east
- return 2 if $game_map.height == @real_y #south
- return 4 if @real_x + 1 == 0 #west
- return 0
- end
- #End of Method-Chain: Automatic Transfer
- #Compatibility fix: Pixel Movement
- #--------------------------------------------------------------------------
- # * [New Method] jms_met_move_straight
- # * Copy of move_straight
- #--------------------------------------------------------------------------
- def jms_met_move_straight(d, turn_ok = true)
- @move_succeed = passable?(@x, @y, d)
- if @move_succeed
- set_direction(d)
- @x = $game_map.round_x_with_direction(@x, d)
- @y = $game_map.round_y_with_direction(@y, d)
- @real_x = $game_map.x_with_direction(@x, reverse_dir(d))
- @real_y = $game_map.y_with_direction(@y, reverse_dir(d))
- increase_steps
- elsif turn_ok
- set_direction(d)
- check_event_trigger_touch_front
- end
- end
- #End of Compatibility fix: Pixel Movement
- end #Game_Player
- # END OF SCRIPT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement