Author Topic: ship save/load script  (Read 14131 times)

0 Members and 1 Guest are viewing this topic.

Re: ship save/load script
Uploaded a new version allowing saving and loading of SEXP controlled variables. The savefile is the same that is used for ship data.
Here goes scripting and copy paste coding
Freespace RTS Mod
Checkpoint/Shipsaveload script

 

Offline Parias

  • 27
Thought I'd drop a note of appreciation - I'm in the process of porting the FS1 (FSPort) campaign to co-op and was looking for a way to get Red Alert-like functionality working properly in multiplayer (as doing this natively in the code is extremely daunting).

With a couple of minor code tweaks (there are some MP-specific client-side issues with processing ship-vanish / ship-destroy on AI-controlled ships that I've been hacking around), your script actually works PERFECTLY and has saved me a lot of trouble. I have mission handling in place to bypass the script if any player-controlled ships are dead (I give them a fresh default ship to work with in the next mission if they've run out of respawns before the previous mission had ended), but otherwise all player-ship stats for all players transition to the next mission flawlessly, and the "red-alert experience" (for lack of a better term) is completely preserved.

As soon as I wrap some things up, I'll be releasing a beta of the mod soon. Is it OK if I include your script with it? Full credit will be given of course.

 
Damn, nice work Parias (and damn nice work to the original script creator too of course). I read about this and was curious if it worked with multiplayer coop. I imagine you got this to work in multiplayer campaign arcs correct? For example, there is no way to save multiplayer campaign progress, so a work around is to group 2 or 3 missions together so that there is some type of continuity from mission to mission.

 

Offline Parias

  • 27
Essentially correct - I have the campaign split up into multiple smaller multiplayer campaigns, consisting of a few missions each.  This way if there's a problem (someone has to bomb out mid-campaign, or crashes), the group doesn't have to start all over again.

Each mission can also be played as "single" co-op missions of course... and the benefit of using this script is that it'll work regardless on if you're doing campaign mode or not. So long as the previous mission was played (and it had a chance to fire the save function), it'll load the corresponding ship data in the next mission. And if it wasn't played, everyone will still just get default ships.

 
That is amazing. Will the script only affect one mission ahead?

For example, say you have the entire freespace 1 campaign. You are in mission 1 and there is trigger set up that if you don't save that ship, it won't show up in the final mission. Will the save function keep the data handy until you play through all the mission between and then you arrive at mission 30 and depending on your actions the ship is gone. I will try to test it out over the weekend but it opens up many possibilities that have been lacking in multiplayer.

 

Offline Parias

  • 27
Yup - the script is file-based (it writes the ship data to a specific file and reads it afterwards). So long as the file exists on your hard drive, the ship data is maintained, and just needs to be called by an appropriate SEXP. You can set a string variable called "filename" to tell it which file to use for saving and loading - check out the PDF included with the script as Admiral MS explains how that works. He's done a pretty good job with this.

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Anims: 420, Cutscenes: 10, Mainhalls: 7, Logos: 52
    • Steam
    • Twitter
    • Mix-Hai Productions
This script was originally intended as an alternative to FSO's sketchy Red Alert system. In fact, when I built a Red Alert mission set, I used this scrip to transfer all of the ship data from one mission to the next instead of Red Alert. All Red Alert did was show the specialized briefing.

Red Alert may have been fixed and become more reliable by now, I dunno. I just don't trust it to be reliable.
Cutscene Upgrade Project - Mainhall Remakes - MixaelANITools - Between the Ashes - MjnMixael's Render Boutique - Mix-Hai Productions
Youtube Channel - P3D Model Box - Photobucket Albums - Model Releases - Downloads
Between the Ashes is looking for committed testers, PM me for details.
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!

 

Offline Cyborg17

  • 29
  • A-1 Supar
It's wise to use the script since the script is a better way of keeping track of the data and could be adjusted for special cases if desired.

 

Offline Parias

  • 27
And the script can actually be made to work properly for multiplayer campaigns too. :D

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Red Alert may have been fixed and become more reliable by now, I dunno. I just don't trust it to be reliable.
Well, quite a few Red Alert bugs have been fixed recently... but ultimately, it still has design problems (can only go back one mission, doesn't work in multiplayer) that make it undesirable.
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

 
Small question:
When implementing the loadship feature for a checkpoint, do you need to have the ship present in the mission at the time to have it loaded correctly when it jumps to the next part.
Currently in my mission when I move to the checkpoint only the ships that were in system at that time load. The others just don't appear.
Too many ideas.....not enough FREDing time!

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Anims: 420, Cutscenes: 10, Mainhalls: 7, Logos: 52
    • Steam
    • Twitter
    • Mix-Hai Productions
There's an option to have the script create-ship.. but here's what I recommend instead.

When you have a ship that arrives later in a mission AND is part of a checkpoint, use SEXPs to change it's arrival info. What I mean is this. During the SEXP sequence where the player chooses to go to the checkpoint (or where the mission starts loading the checkpoint), use set-arrival-info sexp to change that ship's arrival to some trigger that forces it to arrive 'RIGHT NOW' (instead of it's later trigger) with no warp and no delay. Then use the script a frame or second later to load the saved checkpoint data onto that ship.

That way the ship shows up at the right times for both types of playthroughs (checkpoint vs no checkpoint).
Cutscene Upgrade Project - Mainhall Remakes - MixaelANITools - Between the Ashes - MjnMixael's Render Boutique - Mix-Hai Productions
Youtube Channel - P3D Model Box - Photobucket Albums - Model Releases - Downloads
Between the Ashes is looking for committed testers, PM me for details.
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!

 
Thanks mjn, I've set it up but its not working, you suggest using the set-arrival-info sexp right?
Its not making my ship arrive though, what do I particularly have to do to force it to arrive?
Too many ideas.....not enough FREDing time!

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Anims: 420, Cutscenes: 10, Mainhalls: 7, Logos: 52
    • Steam
    • Twitter
    • Mix-Hai Productions
Can I see your SEXP?
Cutscene Upgrade Project - Mainhall Remakes - MixaelANITools - Between the Ashes - MjnMixael's Render Boutique - Mix-Hai Productions
Youtube Channel - P3D Model Box - Photobucket Albums - Model Releases - Downloads
Between the Ashes is looking for committed testers, PM me for details.
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!

 
Code: [Select]
   ( set-arrival-info
      "Yarra"
      "Hyperspace"
      "Yarra"
      0
      0
      0
      ( true )

That is the specific sexp in question
Too many ideas.....not enough FREDing time!

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
It looks like there is currently no way to change an object's arrival or departure cue at runtime; instead, you should change the arrival cue to logically "or" together the normal condition and a check to see if the checkpoint was activated.
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

 
So.....tie it to arrive with the checkpoint trigger just prior to loading the actual checkpoint?
Too many ideas.....not enough FREDing time!

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Anims: 420, Cutscenes: 10, Mainhalls: 7, Logos: 52
    • Steam
    • Twitter
    • Mix-Hai Productions
It looks like there is currently no way to change an object's arrival or departure cue at runtime; instead, you should change the arrival cue to logically "or" together the normal condition and a check to see if the checkpoint was activated.

Oh, whoops. You're right. I forgot that set-arrival-info doesn't handle that.

Yeah, so here's how I'd do this. For the ship that needs to arrive, open it's properties and set it to arrive when 'Ship Arrival Event' becomes true. In the Events editor I would have the Ship Arrival Event to trigger when the mission reaches it's time to arrive OR when the checkpoint is triggered.
Cutscene Upgrade Project - Mainhall Remakes - MixaelANITools - Between the Ashes - MjnMixael's Render Boutique - Mix-Hai Productions
Youtube Channel - P3D Model Box - Photobucket Albums - Model Releases - Downloads
Between the Ashes is looking for committed testers, PM me for details.
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!

 
Okay thanks guys, had a feeling that may have been the way to solve it.
Is there a way to make the Yarra's warp dissapear (does set arrival info do that) or would it be easier to just have it warp in after a fade out and fade back in to start the next part?
Too many ideas.....not enough FREDing time!

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Okay thanks guys, had a feeling that may have been the way to solve it.
Is there a way to make the Yarra's warp dissapear (does set arrival info do that) or would it be easier to just have it warp in after a fade out and fade back in to start the next part?
You see that "( true )" at the bottom of the set-arrival-info SEXP? Set it to "( false )" and there won't be a warp effect.
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.