Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Saving Events during runtime to MAP000.rmxp files

Rob

Member

My goal is to randomely generate some of the events in my game. Ive succeeded, but I cant "Resave" the map after its been generated to the map file. I cant figure out the format of the MAP000.rmxp files so that they load smoothly when you return to the map.

Ive been crawling the forums for days, and picked through the tutorials archive. The closest thing I found that may help is Yeyinde's 'Data Encrypter/Decrypter,' however I cant find it and all links are broken.

I just cant wrap my brain around the format of the MAP000.rmxp map files. If anyone can give me ANY help at all I would be glad to upload my script in the specified RMXP SDK 2.x format which includes easy to use runtime event cloning and random event generation (already finished). Im also working on a pre-defined event system so anyone can just make an event call anywhere in the game and it will be added at random, or specified coordinates. However these functions also require that I understand the MAP000.rmxp map file formats to progress any further.

Thanks guys! I apreciate you taking the time to read this.
 

poccil

Sponsor

I believe you mean "map000.rxdata". If so, then I can say that each file with names like that is simply an RPG::Map object (see the RPG Maker XP help file for details). Here is an example:

Code:
map=load_data("Data/map001.rxdata")
p map.is_a?(RPG::Map) # prints "true"

An alternative approach for saving randomly generated events is to simply add them to Game_Map's events hash. The following "pseudocode" explains what I mean:
Code:
# This function looks for an empty space to put
# a new event in.
def getEmptyEventId
 i=1
 loop do
  if !$game_map.events[i]
   return i
  end
  i+=1
 end
end

def addEventToMap
 # Find an unused event ID for this map
 eventID=getEmptyEventId
 # generateEvent is just an example of a function
 # that generates an event at runtime with a given
 # event ID.  It returns an RPG::Event object.
 rpgEvent=generateEvent(eventID)
 # Convert to Game_Event
 event=Game_Event.new($game_map.map_id,rpgEvent)
 # Add event to map
 $game_map.events[eventID]=event
 # Return event ID
 return eventID
end
 

Rob

Member

Thanks Poccil!

Thats exactly the info I needed to go in the right direction! I just needed to update the $game_map.map.events[] and then use the save_data($game_map.map, "") to save the new info to file. Thanks alot! I cant believe I missed that. Finaly production will shoot forward and Ill keep my promise about uploading my work as soon as I clean up the code a bit and add instructions.
 

Rob

Member

Why not? the MAPxxx.rxdata files are the root of map information. Editing the info at the source is the surest way to guarantee all changes will trickle down to variables and methods they need to. This way I wont have to come up with complicated work arounds. In fact, the script Im using to convert information into MAPxxx.rxdata format is extremely simple, fitting into exactly six lines of code. Eficiancy. And all info that is generated with it when you test run the game is saved and compatible with the editor. which means if I create the needed complicated algorithms, and I intend to, Ill be able to draw random maps, populate them, and put in story lines using events. All of which didnt already exist before the game was started. My ultimate goal is to make these things accesable to people 'DURING' an actual game, so they can define and customize the type of story they want to play, or even create their own using the random generators and tools. Accessing these files is crucial to my design.

As for any legalities... Im modifying these files entirely within the confines of the tools the RMXP editor has provided for me with the information from the help file that came with it. The editing of the files will be one hundred percent contained within the compilation of the game itself and will occur only during actual runtime of the game without any outside influence. The motivation behind this is simply to advance myself as a coder, and to feed my insatiable apetite to be a game designer.

Thanks for the code SephirothSpawn, Ill check it out. Nice site too! You started a busines as a coder... I was wondering if you get jobs through some of the net recruitment sites, or if it's easy to actually find work on the internet. Im looking for some options but right now Im mostly just canvasing the nearest city.
 
Well, saving over the .rxdata is fine. But if you plan to play your game over and over again... every time you hit new game, things won't be as they should at the start. It is better to save the changes, not the rxdata files.

It would be like changing the actors.rxdata file. Once you beat the game with your actors at level 90 instead of their usual start of 1-5, your new game will start with them at 90 (if you modify the actors in the right way).
 

Rob

Member

What if I make a backup of the map file? then reset the map files every time a new game is started? Or am I doing this the hard way...

Anyway, the orginal maps that the game will start out with are just going to be templates. the actual maps the player sees will be generated as he walks through the game. I havnt decided if I want to mess with a map graphic generator yet or not though... but pre-specified templates will get boring quick... Im still in the planning stages. Ill figure it out. If it comes down to it, itll be fun to see if I can actually pull off a random map generator. Though Ive done it before with a 3D map, there wasnt so many variables to consider, or restrictions... in the end, I might abandon the tile aproach all together and do it per pixel like Im used to... but then were talkin taking apart the whole freakin graphics handler and figuring out a template to go on. Its do-able, but itll add another six months onto production at least. Many 'sighs' lay in the persuit of dreams.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top