Booda Sack
Sphere Master
- 300
- Posts
- 21
- Years
- Age 38
- Ireland
- Seen Jul 30, 2007
Hey everyone here are some more sphere scripts for you.
Theese are essential for any rpg and indeed most games.
First include some system scripts:
Then your basic warp:
Usage:
More usefull warp:
Usage:
Here is an extra function that is handy when you want test maps,and dont want keep turning off the game and reseting your start position.
Text function:
Theese are essential for any rpg and indeed most games.
First include some system scripts:
Code:
EvaluateSystemScript("time.js");
EvaluateSystemScript("screen.js");
Then your basic warp:
Code:
function Warp(x, y, layer, map,retain,person) {
//note layer is the layer number not name,eg 0 is first layer,1 is second etc
if (map) ChangeMap(map);
SetPersonLayer(person, layer);
SetPersonX(person, x);//Pixel not tile;
SetPersonY(person, y);//Pixel not tile;
SetPersonDirection(person,retain);
/*To warp to a tile you would enter the tile x and y and then multiply that by your tile size ,you might have to add or take away a few pixels depending on your sprites obstruction base*/
}
Usage:
Code:
Warp(169,375, 1, "Route1.rmp","south","hero");
More usefull warp:
Code:
function FancyWarp(x, y, layer, map,retain,person) {
//Detach input so the person doesn't walk while you are warping
DetachInput();
FadeOut(1000);//Fade screen to black
// 1000 milliseconds = 1 second.
Warp(x, y, layer, map,retain,person); // use the original warp function
UpdateMapEngine();
RenderMap();
FadeIn(1000);
AttachInput("hero");
}
Usage:
Code:
FancyWarp(169,375, 1, "Route1.rmp","south","hero");
Here is an extra function that is handy when you want test maps,and dont want keep turning off the game and reseting your start position.
Code:
BindKey (KEY_M, "typemap()", "t()"); //Bind the M key to this function
function typemap()
{
var gotomap;
if (IsMapEngineRunning()) // Check if the map engine is running
RenderMap(); //If yes then display the map
//Different text function to the one I posted yesterday check below
NText("Which Map : ",16,214);
//Type the map filename name,it is case sensitive
//This is getting the filename so remember to type the map file extension
// for sphere which is .rmp
gotomap = GetString(16,214,LoadFont("epokefont.rfn"));
if (IsMapEngineRunning())
RenderMap();
NText("X value : ",16,214)
//Type the x value
var x = GetString(16,214,LoadFont("epokefont.rfn"));
if (IsMapEngineRunning())
RenderMap();
NText("Y value : ",16,214)
//Type the Y value
var y = GetString(16,214,LoadFont("epokefont.rfn"));
//Warp to the map
FancyWarp(x, y, 1, gotomap,"north","hero")
//You could mod this to get the direction too.
//Also you may want to change the x and y in each of the GetStrings()
//To suit where your text box is displayed.
}
Text function:
Code:
function NText(str,x,y)
{
/*Similar to the text function the previous tutorial but adapted so it displays right when getting input*/
var myfont = LoadFont("epokefont.rfn");
var windowstyle = LoadWindowStyle("grey2.rws");
var width = GetScreenWidth() - 32;
var height = myfont.getStringHeight(str, width);
windowstyle.drawWindow(x, y, width, height);
myfont.drawTextBox(x, y, width, height, 0, str);
/*not ther is no FlipScreen() wait for Ctrl key like the last one because this is taken care of by the GetString() function*/
}