Save/Load Game at a Specific Location (Dark Souls Bonfire-Esque)

metalgearmaycry

Veteran
Veteran
Joined
Sep 12, 2012
Messages
35
Reaction score
1
First Language
English
Primarily Uses
Description:

1) The player is able to save his game anywhere, but upon loading the game, he is returned to the last place/map he marked as a return point (similar to Dark Souls' bonfire system)

2) The player is able to use an item to mark his current location (mapID,mapX,mapY) as the location he will start from when loading a saved game.

Logic:

Player uses item to mark a map/location as a return point (mapID,mapX, and mapY saved to game variables)

An event is created/copied/moved visually marking the location (this is a bugbear*)

Player moves to another map

Player saves the game

Player exits the game

Player loads the game

Game loads to the return point

*Only one location can be marked as a return point. Event from previous return point is destroyed/moved, etc.

Attempts:

I tried a system like this with common events. It didn't work out so well.

1) It turns out you /can't/ actually move events between maps (otherwise this would be a piece of cake-- there's only one Save Point event, move it between maps when the player uses the marking item, etc.)

2) While using the item that saves the game, even with a common event like:

'Player is at current mapID,MapX,MapYFadeout ScreenTeleport player to return point mapID,MapX,MapYOpen the Save ScreenTeleport player to current mapID,MapX,MapYFadein Screenthe game still wants to load the game at the remembered mapID,MapX,MapY, then wait a second, then teleport the player to the 'current' mapID,MapX,MapY, the location the character was in when he saved the game, NOT the location that it should have stayed at.

I'm currently using YEP_SaveEventLocations for the return point event, so that it stays in place if the player leaves the map.

My guess is that something will have to be done with the way the game saves a save file; originally I thought I'd be able to change the saved mapID, etc. from 'current' to game variables in the StorageManager method, but I don't know enough Javascript/RMMV to do that yet.

Thank you guys for your help; I understand if this is a bugbear lol. Let me know if you need any clarification :)
 
Last edited by a moderator:

metalgearmaycry

Veteran
Veteran
Joined
Sep 12, 2012
Messages
35
Reaction score
1
First Language
English
Primarily Uses
Bump. Let me know if this sounds impossible currently, and I'll put it on the backburner. Thanks :)
 

metalgearmaycry

Veteran
Veteran
Joined
Sep 12, 2012
Messages
35
Reaction score
1
First Language
English
Primarily Uses
Bump. Does anyone know how you'd go about altering the map that the game saves itself on (what I'm really after here)? All I see when I look at the storage manager is a variable pointing just to $gameMap.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
My understanding of your request is


1. You can save anywhere


2. Depending on where you save, your location will be changed based on where you currently are


And that's it pretty much it.


What does yanfly's save location plugin do?
 

Zinx10

Veteran
Veteran
Joined
Oct 11, 2012
Messages
30
Reaction score
58
First Language
English
My understanding of your request is

1. You can save anywhere

2. Depending on where you save, your location will be changed based on where you currently are

And that's it pretty much it.

What does yanfly's save location plugin do?
If I remember correctly, Yanfly's save location plugin allows you to save the locations of events in any map.  So you can simply tell either all the events or a specific event to run the save feature and its location will be saved upon exiting.  When you enter the map again, its saved location will be loaded.
 

metalgearmaycry

Veteran
Veteran
Joined
Sep 12, 2012
Messages
35
Reaction score
1
First Language
English
Primarily Uses
My understanding of your request is

1. You can save anywhere

2. Depending on where you save, your location will be changed based on where you currently are

And that's it pretty much it.

What does yanfly's save location plugin do?
Hmmm... let me see if I can be a little more clear :D . The concept is /basically/ user-created save-points. This is the logic/steps behind it:

1)Player is able to save the game anywhere;

2)Player uses an item to mark his current location (mapID, mapX, mapY; the "return point");

2a)An event appears at the player's current location, visually marking the return point

3)Player saves the game wherever, whether at the return point or not;

4)When the player loads the game, his character resumes play at the return point, not where he saved the game.

5)When the player creates a new return point, the old return point is deleted/erased;

6)Henceforth when the player loads the game, his character resumes play at the new return point, etc. etc., thus there is only one return point in play at any given moment.

The problems I have run into while trying to event this:

1)Being able to move a "return point" event between maps (events are unique to maps)

2)Creating a "return point" event on every map and search for it to delete it (each event is unique; can't search for an event by name)

3)The game loading sequence loading the player on the return point but then teleporting him back to where he saved the game (something to do with saving the game during a common event?)

4)can't delete an event on another map;

5)when programming a common event, the events listed in "set event location", etc. pertain to the current map in the editor and not all events on every map.

Please let me know if I need to further explain; sorry I wasn't more clear earlier :D
 

metalgearmaycry

Veteran
Veteran
Joined
Sep 12, 2012
Messages
35
Reaction score
1
First Language
English
Primarily Uses
I finished a plugin for you.  Here's the link:

http://pastebin.com/h6SWUzTB

I'll put up a formal thread a little later.
This looks like it just might work, for half of this beast anyways. I'd try it out but for some reason I can't load save files (bug?). Once I get that figured out I'll give this a run-- thank you!!

EDIT:

Whatever that was, now I can load savegames again. Your plugin works like a charm! Now, how to move an event through maps, or at least create/destroy/search for one on a different map....
 
Last edited by a moderator:

Maliki79

Veteran
Veteran
Joined
Mar 13, 2012
Messages
797
Reaction score
350
First Language
English
Primarily Uses
N/A
Try setting it up from a new game.

Also, the plugin's file name can't be changed.
 

NoTaku

Villager
Member
Joined
Nov 10, 2015
Messages
6
Reaction score
3
First Language
English
I spent the last two hours jamming out this plugin.

http://pastebin.com/ZyyQr1CD

RestoreLocations are set using the following plugin commands:

* Plugin Command: * RestoreLocation restore # teleport the player to the stored location * RestoreLocation storeLoc mapid x y dir # store the specified location * RestoreLocation storeMap mapid # change the stored map * RestoreLocation storePos x y # change the stored x, y coordinate * RestoreLocation storeDir dir # change the stored direction * RestoreLocation storePlayerLoc # store the player's current location * RestoreLocation storeRelativeLoc evid x_off y_off dir # store a location as an offset from the event with specified id * RestoreLocation storeVariableMap idvar # store a location from a map * RestoreLocation storeVariableLoc idvar xvar yvar dirvar # store a location from four variables * RestoreLocation storeVariablePos xvar yvar # store an x, y coordinate from two variables * RestoreLocation storeVariableDir dirvar # store a direction from variable * RestoreLocation clear # clear the stored locationThe restore location is stored internally in the $gamePlayer object. This plugin hooks the Scene_Load.onLoadSuccess function, and changes it slightly. It will attempt to restore the location of the player on scene load, and if that fails, it'll go about normal loading routines. A scene load will fail when the restore mapid is equal to 0. Clearing the RestoreLocation will set everything back to 0, which will enable normal saving and loading.

You can restore the player's location at any time by calling a "RestoreLocation restore" plugin event.
You can overwrite the stored location at any time by calling one of the store plugin events.

You can use variables to store the RestoreLocation by calling storeVariableLoc (idvar) (xvar) (yvar) (dirvar), or StoreVariableMap (idvar), StoreVariablePos (xvar) (yvar), StoreVariableDir (dirvar). You simply pass the variable numbers as the arguments for the custom events.

If you pass 0 as the map id argument for any of these store functions, it will use the currently loaded map.

You can also set the restore location relative to the current position of a specific event id. If you want to use the currently active event, pass 0 as the event argument. x_off and y_off are relative x/y offsets from the specified event, and dir will use the direction of the event if it's left zero.

This should put you on the right path.

I will warn you. Parts of this are untested. This is my first day messing with RMMV. I'm still getting my feet wet. I've got a pretty good idea of what I'm doing, but I'm still pants-on-head at the moment. Let me know if there are any bugs.
 

NoTaku

Villager
Member
Joined
Nov 10, 2015
Messages
6
Reaction score
3
First Language
English
Just some thoughts on your specific request here:

1)Player is able to save the game anywhere;

> 2)Player uses an item to mark his current location (mapID, mapX, mapY; the "return point");
> 3)Player saves the game wherever, whether at the return point or not;

> 4)When the player loads the game, his character resumes play at the return point, not where he saved the game.
> 6)Henceforth when the player loads the game, his character resumes play at the new return point, etc. etc., thus there is only one return point in play at any given moment.


My plugin sorts this part very nicely. Simply link an item up with a common event which calls out to RestoreLocation storePlayerLoc.

> 2a)An event appears at the player's current location, visually marking the return point
> 5)When the player creates a new return point, the old return point is deleted/erased;

This bit's gonna need another plugin. 

I'm thinking maybe the best way to do this would be instead of having one event per map managed by a common event, I could perhaps write a plugin that can register something called "event prototypes". When the plugin loads, you can specify a list of files to load into memory, which would contain the JSON data of an event dictionary. You can scum this from MapXXX.JSON. These "event prototypes" would be identified by name and global ID. The prototype itself isn't actually an event on the map, but rather sits in temporary memory.

This bit's easy. Loading a dictionary of JSON data into a global dictionary identified by ID and name should be trivial as all getout. There's already code in the map loading foo that shows us how to do that.

The next step would be constructing a way to clone these event prototypes into "event instances". I'm pretty sure a javascript deep clone would do the job. Once the object is cloned, we forcibly insert it into the Mapdata for the currently loaded map. Now, the Mapdata for the currently loaded map is not saved after you leave the map and go to another one, so these instances would be destroyed the minute that you left. That's actually a good thing, not a bad thing. It makes our work so much easier.

I think a third plugin would be best for this.

This third plugin would modify the way that maps are unloaded and loaded. Marking an event persistent would put the event's id, x, y, direction, and self flags into an object that would then be stored in $gameSystem in an array indexed by Mapid. When events are initialized on the map, each event checks the map's index to see if its event Id is stored in the persistent data list, and if it is, it replaces the default values with the new ones. When an event is unloaded, it checks to see if the event is marked persistent, and socks that persistent data away into said list.

Last, we'd need to write a shim for the third plugin, which makes it so that when maps are loaded, event instances are re-created with their persistent data and a proper eventId matching the load order.


I'll sit down in the morning to write out those two plugins if time allows. I need to learn how to mess around with events and maps in RMMV, so I think both of these will be good projects for me.

Your common event could potentially be as simple as:
 

: PluginCommand RestoreLocation storePlayerLoc: Script: var instance = PersistentEvent("SaveMarker");: if(instance) { instance.clearPersistent(); }: Prototype_Instance("SaveMarker",$gameMap.mapId,$gamePlayer.x,$gamePlayer.y).makePersistent("SaveMarker");Provided of course, that this all works.
 

metalgearmaycry

Veteran
Veteran
Joined
Sep 12, 2012
Messages
35
Reaction score
1
First Language
English
Primarily Uses
Notaku a lot of that went over my head (at least at the moment, as my experience programming isn't that great and I haven't had my coffee yet), but it looks like you're the man with the plan! :D I'll check your script as soon as I get off of work this evening. Thank you so much for your help and expertise :D -- I'm glad that my request is giving you good experience!
 

NoTaku

Villager
Member
Joined
Nov 10, 2015
Messages
6
Reaction score
3
First Language
English
Been up a few hours. Plugging away at the EventPrototypes plugin. Got it about 80% finished, but there are a lot of unknowns in the parts that aren't done yet. Creating copies of events from JSON data took a matter of minutes. It was really no sweat at all. I stole about half the code out of the DataManager and adapted it to what I wanted it to do.

Right now, I'm figuring out how to do a few things:

1) I need to work out how to add my cloned events to the loaded datamap.
2) I need to figure out how to keep the game from reporting that it's done loading before the PrototypeManager has loaded all of its JSON data.
3) I need to figure out how to create actors for my cloned events.

Once that's done, though, we're sitting pretty on the second plugin. The third plugin will be much harder, I think.
 

metalgearmaycry

Veteran
Veteran
Joined
Sep 12, 2012
Messages
35
Reaction score
1
First Language
English
Primarily Uses
I've tested out your system so far, and it works perfectly :) .
 

dragon1up

Veteran
Veteran
Joined
Sep 24, 2013
Messages
130
Reaction score
41
First Language
English
Primarily Uses
RMMV
I got a failed to execute dispatchevent on eventtarget. For the event sadly, using a common event with the plugin command.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:
attack on titan final season is airing tomorrow, I'm excited and scared at the same time!

Forum statistics

Threads
105,883
Messages
1,017,232
Members
137,607
Latest member
Maddo
Top