How do I make a Teleport to town item?
Creating a Teleport to town item is actually very simple plotscripting for the most part; it gets more complex if you have multiple towns you want to teleport to, say teleport to the nearest town.
As you could imagine, making a Teleport item is very simple, if all you want is a simple screen fading out and then back in on the destination map. If you have played Chronoboy Adventures, you may have noticed the incredible nice visual effects attached to the Teleport to town items. A glowing portal slowly raises from the ground, and that's it, there is no teleport to map, until the player chooses to step into the portal. This method is rather complex and takes a lot of time to properly implement, as there are many factors to take note of when modifying map tiles anywhere the player is on the map. In order to do this easily, it would be recommended to have a separate map layer dedicated to the portal effects, or try using slices. After the animation, if you want to allow the player to manually step into the portal, then you will need to create a special NPC in plotscript to make sure the destination point is correct.
The fade out/fade in Teleport item[edit]
This is your most basic Teleport item, nothing special here. Create a Textbox, and just write in a place holder, so that you know what the textbox is for to prevent using it for other purposes. Then write and compile this script for the textboxes instead condition:
plotscript, simple item teleport, begin fade screen out teleport to map (map:Town,24,54) wait (1) fade screen in end
Another way of doing this would be to create a Door on each map for this purpose and using the door from the textbox. This method works great for an escape item for example, say a Rope from Final Fantasy.
Assign this textbox to your item, and set Consumed on use if you want the player to use it only once.
The Conditional fade out/fade in Teleport item[edit]
This can be done in either two ways, by using tags with the above textbox and calling different plotscripts for each destination. This can lead to a plotscript overdose, in which your plotscript choosing menu has over 100 plotscripts to choose from. The other method, and my personal favorite, is to control this through the plotscript itself.
You can either use tags, a global variable, or by current map. Lets go through them one by one, first here is an example for a tag-based multi-teleport item:
plotscript, multi teleporter, begin fade screen out if (check tag(tag:Town1)) then (teleport to map (map:Town,24,54)) if (check tag(tag:Town2)) then (teleport to map (map:Town2,24,54)) ... wait (1) fade screen in end
The only issue with this, is that you will see a fade in and out even if your not being teleported anywhere. There are ways around that, such as using local variables to store the map, x, and y for teleportation, or even set a default destination. One can also use the Select/Case plotscript commands.
This example, requires a method to set a global variable depending on the players position and use that to teleport the player. You could use a map autorun, or set it from another trigger on the map.
global variable (1,teleport map) global variable (2,teleport x) global variable (3,teleport y) plotscript, multi teleporter, begin fade screen out teleport to map (teleport map,teleport x,teleport y) wait (1) fade screen in end
You could use a select/case structure and one global variable to choose among destination points, but since we're using globals anyways, why not make it as flexible as possible. You can set your default destination point in a new-game script for example.
My personal favorite method to use for a teleportation item, is to use the current map variable, along with some other variables:
plotscript, multi teleporter, begin variable (dest) if (current map:=map:Cavern) then (dest:=1) if (current map:=map:Plains) then (dest:=2) if (current map:=map:World map) then (dest:=1) if (dest==0) then (get item(item:Teleport),exit script) fade screen out if (dest==1) then (teleport to map (map:Town,16,32)) if (dest==2) then (teleport to map (map:Town2,33,73)) wait (1) fade screen in end
You can set a default destination point by setting dest in the beginning of the script. This script have many advantages over the other scripts above. It will put the item back in the players inventory if the Teleport fails. You can also consolidate all of your destination points, if you only have 2 destination points, but many maps, this does help. The screen will also not fade if you are not being teleported.
The fixed location portal[edit]
I have this example in my Tutorial game for those who would like to see it in action. It also requires no plotscripting and only uses one tag.
Start by deciding what type of item will allow the player access to the portal. Does it she/he have to hold it, or actually weld the item, such as a necklace? Create a tag in Custom called PortalItem, and create your item as you normally would. Attach this tag to the items, inventory or equipped tag.
In the map editor, create your NPC for this portal and set it to display only when this tag is on, also make the NPC activate on step on. Do not set a textbox or script for this NPC or the next step will not work.
Still in the map editor, create a door on the exact position as this portal NPC, and set the door to only activate when PortalItem is on.
Go into game and test out your new fixed location portal, you can create as many portals in your game like this as you need.