• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Warps(Sphere)

Booda Sack

Sphere Master
  • 300
    Posts
    20
    Years
    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:
    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*/
    
    }
     

    Booda Sack

    Sphere Master
  • 300
    Posts
    20
    Years
    Read the title of the topic,warps.
    I don't mean this offensively but if you don't understand this,you should maybe regress and try something easier.
     
  • 38
    Posts
    19
    Years
    • Age 34
    • Seen Feb 11, 2011
    I couldnt get the "FancyWarp" to work how it was so I had to add together the Warp and FancyWarp. If anyones having troubles with this, this is what i changed it to and it worked:
    Code:
     function Warp(x, y, layer, map,retain,person) 
    { 
    
      DetachInput();
      FadeOut(1000);
      if (map) ChangeMap(map); 
      SetPersonLayer(person, layer); 
      SetPersonX(person, x);//Pixel not tile; 
      SetPersonY(person, y);//Pixel not tile; 
      SetPersonDirection(person,retain);
      UpdateMapEngine();
      RenderMap();
      FadeIn(500); 
      AttachInput("Player");
      
    }

    and the usage code was just the Warp one:

    Code:
    Warp(169,375, 1, "Route1.rmp","south","hero");

    Thanks Booda this would've takin me ages to figure out.
     

    Booda Sack

    Sphere Master
  • 300
    Posts
    20
    Years
    What was the error?
    You must have been using it wrong because that's the exact function I've used in my game since the beginning and it works fine for me.
     
  • 38
    Posts
    19
    Years
    • Age 34
    • Seen Feb 11, 2011
    it just continuously looped like the screen would fade but then it would take me back to the same point wher my warp was and then fade again n then bring me back ontop of the warp again . . . . . .. . . . .
     

    Booda Sack

    Sphere Master
  • 300
    Posts
    20
    Years
    Oh ok,you were probably just warping onto the warp trigger on the next map which would then warp onto the warp trigger of the previous map which would then warp onto the warp trigger of the next map which would then warp onto the warp trigger of the previous map which would then warp onto the warp trigger of the next map ....
    etc.
     
  • 38
    Posts
    19
    Years
    • Age 34
    • Seen Feb 11, 2011
    meh i wouldnt have a clue what i was doing . . something stupid no doubt. . . im new to sphere so yeh lol soz my bad
     
    Back
    Top