[XP] Teleportation

Started by shdwlink1993, February 01, 2009, 04:12:53 pm

Previous topic - Next topic

shdwlink1993

February 01, 2009, 04:12:53 pm Last Edit: February 21, 2009, 05:54:08 am by shdwlink1993
Teleportation
Authors: shdwlink1993
Version: 1.1
Type: Game Addon
Key Term: Movement Add-on



Introduction

You guys remember RPG Maker 2003, right? I didn't think so. :^_^': There was an event command in RM2k3 called "Manage Teleport Locations" (or something to that effect). Using this allowed you to add and remove locations from a list. A skill called Teleport allowed you to go to any of these locations. This script is my conversion of my variation of this functionality.



Features


  • Easy control of teleportable locations.
  • Automatic duplicate control.
  • Backup and restore the list of locations.
  • Scene made that allows for easy player selection.
  • Temporarily disable and enable different locations.



Screenshots

None, really. The Teleport Menu isn't really shiny enough to need it's own screen.


Demo

See here for the VX Demo.


Script

Spoiler: ShowHide

#==============================================================================
# Teleportation
# Author: Shdwlink1993
# Version: 1.1
# Type: Game Addon
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Teleport Date 1.0: 2/1/2009
# Teleport Date 1.1: 2/5/2009
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# #  This work is protected by the following license:
# #----------------------------------------------------------------------------
# # 
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# # 
# #  You are free:
# # 
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# # 
# #  Under the following conditions:
# # 
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# # 
# #  Noncommercial. You may not use this work for commercial purposes.
# # 
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# # 
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# # 
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# # 
# #  - Nothing in this license impairs or restricts the author's moral rights.
# # 
# #----------------------------------------------------------------------------
# #
# # Note that if you share this file, even after editing it, you must still
# # give proper credit to shdwlink1993.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#                                ~= Functions =~
#
# This script allows you to teleport to predefined locations, not unlike RPG
# Maker 2003's similar function.
#
# $game_player.add_location(name, map, x, y, face, description)
#   Adds a location to the list of teleportable locations. You cannot add a
# location if it's name is already in use (limit duplicates). Face refers to
# the direction the player will be facing. If you don't know, look at a number
# pad. 2 is down, 4 left, etc.
#
# $game_player.add_here(name, description)
#   Adds a location to the list where you are with the designated name and
# description.
#
# $game_player.remove_location(name)
#   Removes a location with the name from the list of teleportable locations.
#
# $game_player.disable_location(name)
#   Disallows you to teleport to the location with the name. This should be
#  used only in instances where the teleport is to be temporarily disabled. If
#  it should be permanently disabled, use the remove_location command to free
#  space.
#
# $game_player.enable_location(name)
#   Allows you to teleport to the disabled location with the name.
#
# $game_player.toggle_location(name)
#   Changes if the location with the name can be teleported to or not.
#
# $game_player.backup_locations
#   Makes a backup of all known locations and deletes them.
#
# $game_player.restore_locations
#   Restores the locations from the backup. All locations learned in the backup
#  are added to the list.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#                               ~= Version History =~
#
# Version 1.0 ------------------------------------------------------ [2/1/2009]
# Version 1.1 ------------------------------------------------------ [2/5/2009]
#  - Added in ability to disable individual teleports.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#                               ~= Compatability =~
#
# - Should work perfectly with just about anything.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

class Game_System
 
  attr_accessor :teleport_disabled
 
  alias teleinit initialize
  def initialize
    teleinit
    @teleport_disabled = false
  end
 
end

class Game_Player
 
  attr_reader :known_locs
 
  alias teleinit initialize
  def initialize
    teleinit
    @known_locs = []
    @backup_locs = []
  end
 
  def add_here(name, desc = '')
    return add_location(name, $game_map.map_id, @x, @y, @direction, desc)
  end
 
  def add_location(name, map, x, y, face, desc = '')
    unless @known_locs == []
      @known_locs.each_index {|i| return if name == @known_locs[i][0] }
    end
    @known_locs.push([name, map, x, y, face, desc, true])
  end
 
  def remove_location(name)
    @known_locs.each_index {|i|
      if name == @known_locs[i][0]
        @known_locs.delete(@known_locs[i])
        return
      end}
  end
 
  def disable_location(name)
    @known_locs.each_index {|i|
      if name == @known_locs[i][0]
        @known_locs[i][6] = false
        return
      end}
  end
 
  def enable_location(name)
    @known_locs.each_index {|i|
      if name == @known_locs[i][0]
        @known_locs[i][6] = true
        return
      end}
  end
 
  def toggle_location(name)
    @known_locs.each_index {|i|
      if name == @known_locs[i][0]
        @known_locs[i][6] = !@known_locs[i][6]
        return
      end}
  end
   
  def backup_locations
    @backup_locs = @known_locs
    @known_locs = []
  end
 
  def restore_locations
    @known_locs & @backup_locs
    @backup_locs = []
  end
 
end

class Window_Teleport < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 640, 416)
    @column_max = 2
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    $game_player.known_locs.each {|t| @data.push(t) }
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      @item_max.times {|i| draw_item(i) }
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    if item[6]
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(x + 4, y, 212, 32, item[0], 0)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? '' : self.item[5])
  end
end

class Scene_Teleport
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make help window, item window
    @help_window = Window_Help.new
    @teleport_window = Window_Teleport.new
    # Associate help window
    @teleport_window.help_window = @help_window
    # Execute transition
    Graphics.transition
    # Main loop
    loop {
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      break if $scene != self
    }
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @teleport_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @help_window.update
    @teleport_window.update
    update_tele
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when item window is active)
  #--------------------------------------------------------------------------
  def update_tele
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Menu.new(0)
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Get currently selected data on the item window
      @item = @teleport_window.item
      # If you can't teleport, then you don't!
      unless @item[6]
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      $game_temp.player_transferring = true
      # Set player move destination
      $game_temp.player_new_map_id = @item[1]
      $game_temp.player_new_x = @item[2]
      $game_temp.player_new_y = @item[3]
      $game_temp.player_new_direction = @item[4]
      $scene = Scene_Map.new
      return
    end
  end
 
end



Instructions

Read the script for this.


Compatibility

Should be compatible with just about everything.


Credits and Thanks


  • Shdwlink1993 for making the script.



Author's Notes

One little thing that might be new to some of you is that you need to change the scene to view the Teleport Menu. To do this, use the script( call) '$scene = Scene_Teleport.new'.
Stuff I've made:




"Never think you're perfect or else you'll stop improving yourself."

"Some people say the glass is half full... some half empty... I just wanna know who's been drinking my beer."

Calintz

So this is the XP version of your VX teleportation script?

shdwlink1993

Yep. It's the XP conversion of the VX script.
Stuff I've made:




"Never think you're perfect or else you'll stop improving yourself."

"Some people say the glass is half full... some half empty... I just wanna know who's been drinking my beer."

Calintz


Blizzard

*gives <3 to shdw*

... NO WAIT! >.<
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

This would've been helpful before I converted it >.>

Anyways great job shdwlink

Landith

This is great, I really wanted this for my game and I put it in with the ring menu so it looks great, thanks shwdlink1993 :)

*Powers Up*

Calintz

This would be very useful for many games, and I may even you it myself.
- Can you configure this script to only be unavailable from the world map?

Landith

Quote from: Calintz16438 on February 03, 2009, 09:34:09 pm
This would be very useful for many games, and I may even you it myself.
- Can you configure this script to only be unavailable from the world map?

Don't you mean available?
And yea you can I think it's $game_system.tele_disabled = true or something like that.
Send me your Worldmap script and I'll do it for you :)

Calintz

Alright, and I will also upload the world map into the scripts section...
First, I will send the code to you in a PM though.

Blizzard

And CP has been stripped of yet another part of its originality. ._.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

shdwlink1993

@Blizz: LOL. The Message System by the end of the week unless you release the beta within three days! Cheer up, Blizz. I could have made a variation of your Pre-Battle Window that's just 40 lines of code...

Wait a second...  :>.<:
Stuff I've made:




"Never think you're perfect or else you'll stop improving yourself."

"Some people say the glass is half full... some half empty... I just wanna know who's been drinking my beer."

Blizzard

The window itself is, but the subsystem that lets you avoid battles isn't. ;)
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Calintz

Quote from: Blizzard on February 04, 2009, 06:24:03 am
And CP has been stripped of yet another part of its originality. ._.


What do you mean?

Starrodkirby86

Quote from: Calintz16438 on February 04, 2009, 06:40:42 pm
Quote from: Blizzard on February 04, 2009, 06:24:03 am
And CP has been stripped of yet another part of its originality. ._.


What do you mean?

Blizzard scripted a Teleportation system of his own, but now that shdw has made one and released it to the public, many users can now use it to implement it in their game. Bam, now one aspect in Blizzard's game isn't so exclusive because shdw released a similar system to the public and therefore it's one less thing in the innovation department. ;x

What's osu!? It's a rhythm game. Thought I should have a signature with a working rank. ;P It's now clickable!
Still Aqua's biggest fan (Or am I?).




Calintz

Oh, Lol...
I see. Well Blizzard, if it makes you feel any better.

I still love Chaos Project =)

Blizzard

At least CP isn't just as good as the sum of all features. It's better. :D
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Calintz


shdwlink1993

Updated to version 1.1! :D

Now you can disable and enable individual teleports.
Stuff I've made:




"Never think you're perfect or else you'll stop improving yourself."

"Some people say the glass is half full... some half empty... I just wanna know who's been drinking my beer."

Reno-s--Joker

:haha: Muahaha, thanks for converting this, shdwlink! <333
I'll check it out as soon as I can. :)

Calintz


Dragon X

Where were you when I set up teleportation sequences on all my save crystals on my game? >.<
XD I just used the give choices option a lot of times and used transfer player with a sound effect.
Well I'll put something in here eventualy.

Sima Yi

Sorry to bring this topic up again,but I need a new demo,cause filefront is not working for me(I don't know why it just say I'm downloading something) and I am having problems adding the location.

I know it's a noob request,but I need it.

Sacred Nym

# $game_player.add_location(name, map, x, y, face, description)
#   Adds a location to the list of teleportable locations. You cannot add a
# location if it's name is already in use (limit duplicates). Face refers to
# the direction the player will be facing. If you don't know, look at a number
# pad. 2 is down, 4 left, etc.


What's so hard about this? What exactly is the problem?
Quote昨日の自分に「さようなら」
Say "Goodbye" to who you were yesterday.

monkeydash

February 05, 2011, 11:38:38 am #24 Last Edit: February 05, 2011, 11:58:33 am by monkeydash
Is there a way of having the teleportation ability disabled on certain maps?

Looking at the script, at the moment the best way seems to be an event (or two) that backups the locations, then restores them when you leave the area. Is this the only way?

I want to use this as a 'Fast Travel' type thing, so I would likely disable it in interiors. And I'd guess at the moment it also does not include disabling teleporting if enemies are attacking.

EDIT: Testing it, I keep getting a message

---------------------------
SyntaxError occurred while running script.
---------------------------
OK   
---------------------------

Could I be using an incompatible script? If so, is there a better one to work with BlizzABs?

I have a Parallel Process event on the map the actor is trying to enter which says

$game_player.add_location(Rams
Hospital, Rams Hospital, 16, 14,
2, West Cliff Road)

ForeverZer0

When you get the "Syntax Error occured while running script" error, and it means that you have a script call written wrong. The only other time it will do it is when a script is using the "eval" method.

I can see by your example, the script call is all type of wrong.
  • Rams Hospital needs to be written as a string (ex. "Rams Hospital")
  • You can't have a single statement carry across two lines without some type of seperator

    The script call box sucks for how short it is. Try this, coping line for line:


    a = 'Rams Hospital'
    b = 'West Cliff Road'
    $game_player.add_location(a, a, 16, 14, 2, b)


    You need to make sure that if all the arguments don't fit on a single line that you break to the next line right after a comma.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

monkeydash


I tried to do what you suggested and got this error instead. I thought it might be because I was using a save game, so I tried doing it with a New game and still got the same error.


NoMethodError occurred while running script.

undefined method `add_location' for #<Game_Player:0x3cfff50>
---------------------------
OK   
---------------------------

ForeverZer0

That would mean that there is no method called "add_location" to in Game_Player. I have never even looked at this script honestly, I have merely assumed by your previous post that the method existed. Look at the script, check the spelling, and make sure you that the method call is correct.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

monkeydash

I had a look in the script and noticed that it asks for map ID, which was not made clear in the instructions, so I changed that to the map number. I got this error instead.


NoMethodError occurred while running script.

undefined method `add_location' for #<Game_Player:0x3d4e970>
---------------------------
OK   
---------------------------

The instructions don't say anything about editing the script itself, so I havnt done anything to it. It just gives you the script calls to use in events.
Is this something to do with where it is in the scripts? Does it need to be in a certain place? I have it just above the Tons of Add on script.