Author Topic: Saving / Loading  (Read 2669 times)

Offline USS Frontier

  • Posts: 176
  • Cookies: 562
Saving / Loading
« on: April 14, 2008, 10:48:25 PM »
Hey there,

Just wanted to know, is there any way to "easily" save/load the mission/game state in BC?  More precisely, in Quickbattle. We save in moment X for example, and upon loading, everything is back to that moment: ships in their position, their damage, etc.
Just like the normal saving/loading we did on the single player campaign.

I need that to help me out with something i'm making now, and besides needing to save/load BC objects status, I also need to save/load some custom script status (variables values and so). Dunno if the BC save/load system could do that, but at least if it could do what it did on the SP, that's already a BIG help.
Otherwise I would need to write my own routine to save/load the game status, and that is just too much work.


Anyway, I tried using some methods from App.g_kUtopiaModule that I found in App, and in some other scripts to save/load the game in the console: like .SaveToFile(filename)  and .LoadFromFile(filename),  .SaveMissionState(string) and .LoadMissionState(string)
but they just didn't work... only thing that ever appeared in the console was "cPickle.PicklingError: Cannot pickle <type 'ellipsis'> objects."   after my first try to call .SaveToFile("saves\\savetest.BCS")

Also tried using the quickload/quicksave shortcuts, but they didn't worked as well.  I remember in old stock BC they didn't worked in QB, but there's got to be a way to let us save the game im QB  lol...
"Revenge is a dish best served cold"
                    -Old Klingon Proverb
GravityFX Download
Galaxy Charts Download

Sandtrooper

  • Guest
Re: Saving / Loading
« Reply #1 on: April 14, 2008, 11:14:55 PM »
Don't think that would be possible, as BC might get pissy if you even change one aspect of the hardpoint or whatever projectile it calls and it happens to be different.

Offline FekLeyr Targ

  • DS9FX Team
  • Posts: 492
  • Cookies: 538
Re: Saving / Loading
« Reply #2 on: April 15, 2008, 09:36:33 AM »
Yes, a mod which you've descriped above is featured in Kobayashi Maru.
TaH pagh, Tah be.

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Saving / Loading
« Reply #3 on: April 15, 2008, 12:18:22 PM »
There are keybindings you can "activate".

If you look at the default keybindings (scripts/DefaultKeyboardBindings.py) and scroll all the way to the bottom, you see 2 disabled lines (they have been commented out).
If you uncomment them and delete your KeyBindings.py, or put the uncommented lines in your KeyboardBindings.py.
And start BC in -TestMode, then it's possible you can "quick" save/load in QB by respectivly pressing F7 and F8.

But I can't guarantee anything will work.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline USS Frontier

  • Posts: 176
  • Cookies: 562
Re: Saving / Loading
« Reply #4 on: April 16, 2008, 07:37:50 PM »
Hmmm

Tried the keybindings, they still didn't work....

About that mod in KM1, I had completely forgot about it. I checked it out and it's a "simple" coding job (from Defiant I think). It doesn't really use BC's save system.

Anyway, I'll probably start writing my own saving system now, since BC seems to not want to help us with that lol.
Still, any "news" on my previous question would still be helpful as always.
"Revenge is a dish best served cold"
                    -Old Klingon Proverb
GravityFX Download
Galaxy Charts Download

Offline Rob Archer

  • Posts: 163
  • Cookies: 545
  • New Frontier MKVI
Re: Saving / Loading
« Reply #5 on: April 17, 2008, 02:11:44 AM »
Hmmm

Tried the keybindings, they still didn't work....

About that mod in KM1, I had completely forgot about it. I checked it out and it's a "simple" coding job (from Defiant I think). It doesn't really use BC's save system.

Anyway, I'll probably start writing my own saving system now, since BC seems to not want to help us with that lol.
Still, any "news" on my previous question would still be helpful as always.

Saving System You Say.... My New Frontier senses are tingling

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Saving / Loading
« Reply #6 on: April 17, 2008, 01:22:37 PM »
Try Ctrl+F7 for save, and Ctrl+F8 for load.

This ought to work in Bridge, Tactical, Map and Cinematic mode (according to the scripts) and without the need for editting your keyboard bindings (also according to the scripts).
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline USS Frontier

  • Posts: 176
  • Cookies: 562
Re: Saving / Loading
« Reply #7 on: April 17, 2008, 10:24:08 PM »
LMAO  Rob. If you want it, just ask :P
Tho it will require some changes to save up all of NFs different attributes and classes, and then changes to load them. I'm making it to save all ships stats (position, velocity, acceleration, target, subsystems conditions, etc) and set stats (which objs are where);  and GC's classes: the War Simulator(encompasses 3 different classes), Regions, System/Set Plugins, Race Plugins, Random Defence Force, some global values from some scripts, and i'm still thinking if saving the Traveler system condition is really necessary.
For now i'm still finishing writing the save routine (it's missing the race plugins, traveler system and ship's torpedo loads), and then i'll start on the loading, which will most likely be much more difficult (and system resource intensive lol).

Actually saving these different classes isn't really dificult: looping thru pObj.__dict__ REALLY helps  :lol:  Problem was with App.ShipClass, I had to write down to get each value manually... The save file can probably be a mess with so many things and all lol, but at least that will make cheating tougher! lol
Then loading it up can be done pratically the same way: recreating the objs, and looping thru the __dict__s and updating their attributes.

k MLeo, will try that later.
"Revenge is a dish best served cold"
                    -Old Klingon Proverb
GravityFX Download
Galaxy Charts Download

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Saving / Loading
« Reply #8 on: April 18, 2008, 05:56:35 AM »
I suggest you look at the ATP: D source, I believe you also have that.
Apollo already had this type of save/loading done.


Good luck with trying to load ships correctly. ;)
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline USS Frontier

  • Posts: 176
  • Cookies: 562
Re: Saving / Loading
« Reply #9 on: April 18, 2008, 10:00:17 AM »
SMBW, technically, saving the AI state would be necessary yes. But since i'm mainly directing this saving system for use with GC and the war simulator, so that people can close BC and continue the war later, i'm not doing that. Because the ships in the war are basically using "combat" AIs, which I can easily reset it later by code, and the ships will pretty much do whatever they were doing.


And nope, I don't have the ATP:D source MLeo =P Funny thing, you're not the first person to believe that I have it...
lol thanks  :D
"Revenge is a dish best served cold"
                    -Old Klingon Proverb
GravityFX Download
Galaxy Charts Download

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Saving / Loading
« Reply #10 on: April 18, 2008, 11:03:33 AM »
There have been so many changes to that team, that I haven't been able to keep up.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline USS Frontier

  • Posts: 176
  • Cookies: 562
Re: Saving / Loading
« Reply #11 on: April 25, 2008, 08:31:38 PM »
Ok I did a little test with the saving routine:  opened the game, opened QB mode (not starting a QB game tho), and saved the game.  The saved file was 400 Kb in size lol  (tho that's nothing compared to the 1.3 Mb save file which came in a previous test, which had a lot of useless things from 1 class that had a LOT of objs to be saved).
However there was still some BC Objs to save properly, like waypoints and projectiles.
And the file was also loaded sucesfully as a python script, meaning it is working.  :D
So the save files should probably be around 400-1000 Kb in size, depending on the amounts of BC Objs loaded pratically.

And the saving routine is pretty much done (beta testing will give me the correct info about this - if something is missing from being saved), except for one info which I couldn't find a way to get: 
-how can I check if a obj (BaseObjectClass) is attached to another obj?
"Revenge is a dish best served cold"
                    -Old Klingon Proverb
GravityFX Download
Galaxy Charts Download

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Saving / Loading
« Reply #12 on: April 26, 2008, 06:11:01 AM »
I suspect not directly.

But I believe you can get it's coordinates, and if it doesn't match the world coordinates, then it's attached to the ship at position world coordinates - "local" coordinates.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline USS Frontier

  • Posts: 176
  • Cookies: 562
Re: Saving / Loading
« Reply #13 on: April 27, 2008, 06:13:13 PM »
Hmmm attached ships return their World Location as their parent's world location? (or something like that? sorry, I didn't quite understanded...)    Didn't know that. I'll give it a try later.

Also I just tested the Loading routine, and it is working  :D
Just gotta add some values to the save file which I forgot to put before, and apply them in the loading.

EDIT:  just had an idea about getting the attached ship:  overwrite the Attach/Detach Object methods of the App.BaseObjectClass with another one that will store which objs are attached to which objs, and call the original method so the obj is indeed attached/detached.
"Revenge is a dish best served cold"
                    -Old Klingon Proverb
GravityFX Download
Galaxy Charts Download

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Saving / Loading
« Reply #14 on: April 27, 2008, 06:29:24 PM »
It's possible (not sure where, but it is) that they are called from the exe side, so you still wouldn't know exactly.

Well, say that the parent ship is at location (3,1)
And you have a child ship which is at (1,2)

Then effectively, the position in real world coordinates for the child ship would be (4,3)

Just attach a friendly ship (or a planet!) to your ship and move around, and you will notice the effect.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.