RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[XP] Zelda-Like World Map

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 83
As directly Requested by Sasquatch927:

This script allows on a defined Worldmap to teleport at the borders without events or parallel processes.
It's a small script I wrote within some minutes, but maybe some other people will also find it usefull ;)

everything is described as always within the first lines of the script ;)

Spoiler for:
Code: [Select]
################################################################################
#    Zelda like Map-changing v.1.1                                             #
#                                               by Tidloc                      #
#------------------------------------------------------------------------------#
#  As Requested by Sasquatch927 on RMRK.net this script allows on a defined    #
#  Worldmap to teleport at the borders without events or parallel processes.   #
#  Predefined is a Worldmap of 10x10 maps, which means a total of 100 maps.    #
#  These maps should be the first 100 within all map-IDs or you have to change #
#  zelda_maps after the for in the module.                                     #
#------------------------------------------------------------------------------#
#  Description of the modifiable constants:                                    #
#    Zelda_World_Width ..... Defines how many maps will be in X-direction      #
#    Zelda_World_Heigth .... Defines how many maps will be in Y-direction      #
#    zelda_map_width ....... Defines how broad the maps are                    #
#    zelda_map_height ...... Defines how high the maps are                     #
#    Zelda_2nd_World ....... Defines if a second world shall be used parallel  #
#                            to the first one. The other constants will also   #
#                            be used for this second world.                    #
#    Pixel_Movement_Rate ... If you're using a pixel movement script you may   #
#                            have to adjust this. 0 means no pixel movement    #
#                            1 means two moves per tile, 2 means four, 3 means #
#                            8,...                                             #
#==============================================================================#
#  If you need to turn off temporarily the transportation at the edge of the   #
#  map you'll have toused the following command:                               #
#    $game_temp.tidloc_zelda_trans = false                                     #
#  To turn it on again just write true instead of false and everything is      #
#  working again.                                                              #
#==============================================================================#
#  You're free to use this script in any of your games, but please credit me   #
#  for this work. ^^                                                           #
################################################################################

module Tidloc
 
  Zelda_World_Width   = 10
  Zelda_World_Height  = 10
  zelda_map_width     = 100
  zelda_map_height    = 100
  Zelda_2nd_World     = true
  Pixel_Movement_Rate = 1
 
  Zelda_World_MapMax  = Zelda_World_Width * Zelda_World_Height
  zelda_maps          = []
  for i in 0...Zelda_World_MapMax
    zelda_maps.push i
  end
  Zelda_Maps          = zelda_maps
  Pixel_Movement      = 2 ** Pixel_Movement_Rate
  Zelda_Map_Width     = zelda_map_width  * Pixel_Movement
  Zelda_Map_Height    = zelda_map_height * Pixel_Movement
 
end



class Game_Temp
  attr_accessor :tidloc_zelda_trans
  alias _tidloc_zelda_init initialize
  def initialize
    _tidloc_zelda_init
    self.tidloc_zelda_trans = true
  end
end



class Scene_Map
  alias wo_zelda_map_update update
  def update
    wo_zelda_map_update
    map = $game_map.map_id
    mapmax = Tidloc::Zelda_World_Width * Tidloc::Zelda_World_Height
    if map < mapmax+1 && $game_temp.tidloc_zelda_trans
      if $game_player.x == 0
        if map % Tidloc::Zelda_World_Width == 1
          $game_temp.player_new_map_id = map + Tidloc::Zelda_World_Width-1
        else
          $game_temp.player_new_map_id = map - 1
        end
        $game_temp.player_new_x = Tidloc::Zelda_Map_Height-2
        $game_temp.player_new_y = $game_player.y
        $game_temp.player_transferring = true
      elsif $game_player.x == Tidloc::Zelda_Map_Width-1
        if map % Tidloc::Zelda_World_Width == 0
          $game_temp.player_new_map_id = map - (Tidloc::Zelda_World_Width-1)
        else
          $game_temp.player_new_map_id = map + 1
        end
        $game_temp.player_new_x = 1
        $game_temp.player_new_y = $game_player.y
        $game_temp.player_transferring = true
      elsif $game_player.y == 0
        if map <= Tidloc::Zelda_World_Width
          $game_temp.player_new_map_id = map + mapmax - Tidloc::Zelda_World_Width
        else
          $game_temp.player_new_map_id = map - Tidloc::Zelda_World_Width
        end
        $game_temp.player_new_x = $game_player.x
        $game_temp.player_new_y = Tidloc::Zelda_Map_Height - 2
        $game_temp.player_transferring = true
      elsif $game_player.y == Tidloc::Zelda_Map_Height - 1
        if map > mapmax - Tidloc::Zelda_World_Width
          $game_temp.player_new_map_id = map - (mapmax - Tidloc::Zelda_World_Width)
        else
          $game_temp.player_new_map_id = map + Tidloc::Zelda_World_Width
        end
        $game_temp.player_new_x = $game_player.x
        $game_temp.player_new_y = 1
        $game_temp.player_transferring = true
      end
      $game_temp.player_new_x     *= Tidloc::Pixel_Movement
      $game_temp.player_new_y     *= Tidloc::Pixel_Movement
      $game_temp.player_new_map_id = Tidloc::Zelda_Maps[$game_temp.player_new_map_id]
    elsif Tidloc::Zelda_2nd_World && map < mapmax*2+1 && $game_temp.tidloc_zelda_trans
      map -= mapmax
      if $game_player.x == 0
        if map % Tidloc::Zelda_World_Width == 1
          $game_temp.player_new_map_id = map + Tidloc::Zelda_World_Width-1
        else
          $game_temp.player_new_map_id = map - 1
        end
        $game_temp.player_new_x = Tidloc::Zelda_Map_Height-2
        $game_temp.player_new_y = $game_player.y
        $game_temp.player_transferring = true
      elsif $game_player.x == Tidloc::Zelda_Map_Width-1
        if map % Tidloc::Zelda_World_Width == 0
          $game_temp.player_new_map_id = map - (Tidloc::Zelda_World_Width-1)
        else
          $game_temp.player_new_map_id = map + 1
        end
        $game_temp.player_new_x = 1
        $game_temp.player_new_y = $game_player.y
        $game_temp.player_transferring = true
      elsif $game_player.y == 0
        if map <= Tidloc::Zelda_World_Width
          $game_temp.player_new_map_id = map + mapmax - Tidloc::Zelda_World_Width
        else
          $game_temp.player_new_map_id = map - Tidloc::Zelda_World_Width
        end
        $game_temp.player_new_x = $game_player.x
        $game_temp.player_new_y = Tidloc::Zelda_Map_Height - 2
        $game_temp.player_transferring = true
      elsif $game_player.y == Tidloc::Zelda_Map_Height - 1
        if map > mapmax - Tidloc::Zelda_World_Width
          $game_temp.player_new_map_id = map - (mapmax - Tidloc::Zelda_World_Width)
        else
          $game_temp.player_new_map_id = map + Tidloc::Zelda_World_Width
        end
        $game_temp.player_new_x = $game_player.x
        $game_temp.player_new_y = 1
        $game_temp.player_transferring = true
      end
      $game_temp.player_new_x     *= Tidloc::Pixel_Movement
      $game_temp.player_new_y     *= Tidloc::Pixel_Movement
      $game_temp.player_new_map_id = Tidloc::Zelda_Maps[$game_temp.player_new_map_id + mapmax]
    end
  end
end

And as always: If you encounte problems, bugs, or got any ideas to make this better, feel free to contact me ^^
« Last Edit: May 05, 2010, 10:34:52 PM by tidloc »
[...]And they feared him.
He understands that cruelty arises from opportunity![...]

**
Rep: +0/-0Level 81
Wow man. Really nice job implementing all of that. Now all the other people that get on here can benefit from this script, and I can probably get rid of my event systems and use this script instead lol. Great job dude. I'll let ya know if there's any errors. Thanks for your work on this =D

**
Rep: +0/-0Level 81
Hey man. The script is working pretty well. There's a couple problems though...

I don't think the transitions are set up in the right place. FIrst of all, I'm not sure how it does this, but with my maps 100x100 it transitions at the coordinates (25, 25) It's really hard to explain it it's like on the map, all the squares from (25, 0) to (25, 99) are considered the edge of the map. same goes for the Y axis. From (0, 25) to (99, 25) considered to be the edge of the map also. Here's the freaky thing. I kinda fixed it by modifying my numbers a little bit. I can kinda understand why it did this also...

It's my understanding that this script would work for someone that uses no pixel movement. But for me, I use a pixel movement of 2. If you think about it, thats 4 moves per square, and the points (25, 25) are actually 4 times less than the actual size of the map 100x100. so I experimented and found that, when I use a pixel movement of 2, if I change the dimensions specified in the script for the map size from 100x100 to 400x400 it fixed it. It kinda fixed it, but it didn't because The part of the character that the x and y coordinates is tracked by can't be on the coordinate at the right and bottom of the map, so I made the dimensions 397x397. This gave me the ability to transition actually at the edge of the map, where it was supposed to be. I don't think it's supposed to be like that though. I think it's supposed to be where if you have a pixel movement rate of 2, it should still transition at the edges of the map when I specify the dimensions at 100x100. It might just be a minor adjustment. I hope that makes sense, reading it to myself, I have a hard time understanding it. It's hard for me to explain it lol sorry...

The second error. For now, I kept the dimensions at 397x397 just so I could test out if the teleportations were working out perfectly. The area it teleports me to is correct, but the position inside the area is wierd. When I exit the map to the right, I should end up on the left of the next map, still retaining my Y-coordinate. The same goes to all the other directions. Not only that, but the screen isn't on the player. It's in the middle of nowhere not centered over me. Somehow, I think pixel movement has effected how the transfer system works also. Hope you can fix this. In the meantime, I'll make a dummy project without pixel movement and just regular, and see if it works perfectly, that way we will know that the pixel movement is what we need to look at. Thanks dude. Hope the errors can be fixed. =D

**
Rep:
Level 83
ok, because I don't use Pixel-Movement, I didn't think about that...
But the first error is done ;)

The second one is - as I think - because you played with the script ;) if it still appears contact me :D
[...]And they feared him.
He understands that cruelty arises from opportunity![...]

**
Rep: +0/-0Level 81
I didn't actually modify the actual script, I modified the configurations like the world size and stuff. lol I'll leave the scripting part to you. I wouldn't dare to mess with it...

The second error, is that the one where when I do teleport, that I end up in a funky place on the map?

**
Rep:
Level 83
If the second error still appears, send me a PM what you do to have it appear, so I may find a clue what's the problem ;)
[...]And they feared him.
He understands that cruelty arises from opportunity![...]