[RMMV] New Game Script Call

● ARCHIVED · READ-ONLY
Started by EmmaB 12 posts View original ↗
  1. Hi everyone,

    I was wondering if there is a new game script call that exists, as I am needing it for a game I am working on. I am wanting to use it for a custom title screen. Any help would really be appreciated.:)
  2. DataManager.setupNewGame();

    That's the base you'll need, but odds are you'll need other things. The base code in the Scene_Title for a new game looks like this:

    Scene_Title.prototype.commandNewGame = function() {
    DataManager.setupNewGame();
    this._commandWindow.close();
    this.fadeOutAll();
    SceneManager.goto(Scene_Map);
    };

    This video should offer some insight as well:

    [embedded media]
  3. So, what I do is just transfer them to a new map where the game starts. Depending on the way you've evented your title screen, it might just take them back to the title screen if they start a new game, since the default command of starting a new game will take you to the map your character is set to start on.
  4. Thanks for the quick replies.

    @shockra I tried it and an error came up.

    In my game, when I start the game, bring up the menu and quit back to the main menu (I have made the quit button transfer the player back to the title screen map), and then press new game, the game transfers the player to the starting map. The problem is, that I have made an event on the starting map that copies events from a different map and pastes them randomly on the starting map. So when the player starts a second game, it spawns the events on the map a second time (if you get what I'm saying) so that, in this case, the starting map will have two sets of the events when it was only meant to have one.

    Sorry, this is very complex. If you don't understand, just let me know and I'll try to explain it better.

    So the reason that I need a New Game script command, is that it will reset the whole game (except for the saves) and start at the title screen.
  5. If you have a skip title screen script, you can still use the default menu command for returning to the title because it is the equivalent of refreshing the game, not actually returning to the title. If you teleport to the title screen, then you're still running the same instance of the game.
  6. Hi @Prescott,
    I tried using the default return to title screen command but it just went to a blank title screen with the different options (Not the first map). I am using Yami's Skip Title plugin. Is it the wrong skip title plugin to be using maybe? I'm not sure.
  7. Not much of an answer to provide. Gave this a try myself, got errors from it and gave up (almost) immediately.

    As a workaround (and in case the OP still needs an alternative) I'm gonna risk necroposting and provide an idea of my own that I was debating for just this reason. What I ended up doing is to settle on a slideshow advanced by the player with the first slide set as the title itself. Then, using Hime's pre-title events I made my alternative menu screen (which should NOT be set as the title so leave that set to false and just put in the map ID you're using). Set the start game command as a goto for the normal title scene (the procedure is listed in the pre-title plugin help system if you need a reference point), set load game to push the load scene, exit command to close etc. The rest is particularly technical so make a backup and change only what I mention as the next part involves the source code (so you'd better know what you're doing beforehand... or else). From rpg_scenes.js change Scene_GameEnd.prototype.commandToTitle to call location.reload() instead of the default - this will hard reset immediately but I have not found a way to mitigate this for the sake of presentation so make what you will of it. However, this will also prevent you from going back to the opening slides that you're setting up for this. Finally, on the map where you set the player to start you can build out the rest of your opening sequence and then comment out the addCommand calls for continue and options from rpg_windows.js to finish the process. (Additionally, you should comment out anything and everything that also adds to the title menu in its source, plugin etc. or at least turn off its display from the plugin manager if you're allowed to do so.) You can also change the start game definition to read next page (or just next) and create show choices calls in the rest of the sequence to read likewise for an extra touch of professionalism.
  8. Thanks @BreakerZero. I think I've fixed the problem already :).
  9. In that case (and in the event you can provide some insight of your own for improvements and such) then perhaps an idea of how you did it may be of use, either here or in MV tutorials (preferably the latter or subjective equivalent depending on method of resolution). Beyond that, you can elevate this to resolved and notify the mods via the report function if you're done with this.

    EDIT: My issue is that tilesetNames is being reported null. That is to say, it "cannot read property 'tilesetNames' of null".
  10. I didn't exactly fix this problem, actually. I just found that I didn't need to use the New Game script call after all. :)
    Thanks for the help anyway.
    (If anyone knows how to fix this problem, you can still post it if you want to, as it may help someone else. :))
  11. For future reference: wanted to share a solution that worked for me. I also have a custom title screen and setupNewGame threw some errors in my case.

    So basically, I'm resetting the party, switches, variables and self switches in a script call:

    JavaScript:
    // Clear Party
    $gameParty._actors = [];
    $gameParty._gold = 0;
    $gameParty.initAllItems();
    
    // Clear Variables & Switches
    $gameSwitches.clear();
    $gameVariables.clear();
    $gameSelfSwitches.clear();

    Note that setupNewGame does a lot of this, but it also does other things that can cause some plugins to crash (which is what happened in my case). Not using setupNewGame also means the player won't automatically transfer to the start location, and instead you can transfer them wherever you want.

    It's generally not recommended to mess with ._actors directly, but right after this I am re-adding my main character (initialized).

    By the way: Gold is clamped between 0 and 99999999, so instead of ._gold = 0 you can just use the "change gold" event button and reduce 99999999 gold.




    If you want to know what else is being reset in a new game, here's the Party initialization code:

    JavaScript:
    Game_Party.prototype.initialize = function() {
        Game_Unit.prototype.initialize.call(this);
        this._gold = 0;
        this._steps = 0;
        this._lastItem = new Game_Item();
        this._menuActorId = 0;
        this._targetActorId = 0;
        this._actors = [];
        this.initAllItems();
    };
    
    Game_Party.prototype.initAllItems = function() {
        this._items = {};
        this._weapons = {};
        this._armors = {};
    };


    And here's the setupNewGame code:

    JavaScript:
    DataManager.setupNewGame = function() {
        this.createGameObjects();
        this.selectSavefileForNewGame();
        $gameParty.setupStartingMembers();
        $gamePlayer.reserveTransfer($dataSystem.startMapId,
            $dataSystem.startX, $dataSystem.startY);
        Graphics.frameCount = 0;
    };
    
    DataManager.createGameObjects = function() {
        $gameTemp          = new Game_Temp();
        $gameSystem        = new Game_System();
        $gameScreen        = new Game_Screen();
        $gameTimer         = new Game_Timer();
        $gameMessage       = new Game_Message();
        $gameSwitches      = new Game_Switches();
        $gameVariables     = new Game_Variables();
        $gameSelfSwitches  = new Game_SelfSwitches();
        $gameActors        = new Game_Actors();
        $gameParty         = new Game_Party();
        $gameTroop         = new Game_Troop();
        $gameMap           = new Game_Map();
        $gamePlayer        = new Game_Player();
    };
  12. Oatilis, please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.