Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: General Battuta on March 27, 2012, 10:06:46 am

Title: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: General Battuta on March 27, 2012, 10:06:46 am
At some point someone will do an awesome Wiki article like Axem's guide to tactical jumps. (http://www.hard-light.net/wiki/index.php/Tutorial_-_In-Mission_Jumps) It'll have pictures and it won't be dry, rambling, and boring as ****.

In the meantime, here's the Blue Planet guide to rigging up mid-mission checkpoints in FreeSpace Open. It's hastily written and bad! Sorry.

This is a guide for those already fluent in FRED. It's not going to hold your hand. It's a low-quality guide compared to Karajorma's FREDDOCS or Axem's jump guide; it doesn't have any pictures of the events editor, or a sample mission to build and help you along. Here's the general outline:


Here's a really simple diagram of how the checkpoint logic works:

badttuta's bad diagram

Normal playthrough:

MISSION START - INTERIM 1 - SAVE EVENT WRITES TO CHECKPOINT VARS - INTERIM 2 - MISSION END

Checkpoint playthrough:

MISSION START - CHECKPOINT LOAD WINDOW - CHECKPOINT LOAD CALL - INTERIM 1 BREAKS - FADEOUT - LOAD EVENT LOADS FROM CHECKPOINT VARS - INTERIM 2 BEGINS - MISSION END


STEP ONE
make a fred

Make sure to design your mission with what I like to call 'mission phase space bottlenecks'. People who aren't assholes call these 'calm spots'. You need to make sure that the mission contains at least one moment during which there will be no active combat and as many ships as possible are at known, predictable locations. Here is a useful checklist:


These criteria aren't all completely necessary, but they'll help you avoid going over your variable budget.

Now we'll start on the checkpoint.

STEP ZERO
office of player persistent variable budget control

The key element in the checkpoint system is the Player Persistent Variable, or PPV. Unlike other variable types (campaign persistent, for example) this type of variable is not set at mission end - it's set immediately and stored in the player file.

Unfortunately, you're only given 100* of them per campaign. This means you need to be economical in their use.

Now that you've identified WHEN in the mission your checkpoint is going to happen, you're going to use PPVs to store the location, hull state, and dead/alive status of key ships in the mission. There are two steps to a checkpoint: the SAVE and the LOAD. We're going to rig up the SAVE first, because it's a lot easier.

Keep in mind there are some factors you can't currently save: mission clock time, countermeasures fired, and player kills among them.

STEP TWO
every morning i wake up and open palm slam a vhs into the slot

Create two events - we'll call them CHECKPOINT LOAD and CHECKPOINT SAVE. Set them up to trigger at the calm spot you've selected.

Use the FRED events editor to create a series of Player Persistent Variables. You need one for the hull state of each ship you're going to save. (Bear in mind it's often safe to ignore the hull state of smaller ships like fighters and bombers -- though you should probably save the player's hull.) If you're going to save the position of a ship, you'll need three additional variables for its X, Y and Z coordinates. (With new improvements in the SCP, it may be possible to save these as a single number, then break it into three values when you want to load the checkpoint.)

Make sure to give these variables consistent names like alpha1hullstate, alpha1x, alpha1y, alpha1z.

Now, expand CHECKPOINT SAVE. Make sure you've got the trigger condition where you want it. Make sure this trigger condition is not based on the mission clock - you may want the SAVE to work properly even if the player has loaded a checkpoint, or you might want to disable it if the player has loaded a checkpoint. (You can use 'or' to good effect here: six minutes have elapsed in mission time, OR checkpoint 1 has been loaded.) Rig up events for each ship you're saving to read the necessary information (hull state at minimum, possibly coordinates) and write it to the variables in question.

You'll probably want to test the mission right about now. Rig up some messages to print these variables and make sure they were stored correctly. I've had some trouble with ships destroyed as of CHECKPOINT SAVE not saving their hull state as 0, so you may need to mix in additional variables to indicate whether a ship's been destroyed.

Sometimes you don't want to waste three PPVs to save a ship's position. You just want to set it to the same place every time the checkpoint's loaded. To get a good idea of where a ship is at any point in the mission, rig an event that prints the target ship's X, Y and Z coordinates to the training message box in your HUD, and have this event update every second. You can monitor a ship's coordinates and figure out where it is at the point when your checkpoint should be firing. You can just write the numbers down.

Another way to save PPVs is to use relative coordinates. Say you know three fighters will be escorting a freighter - you can save the freighter's position, and then just assume the fighters will be positioned in a triangle relative to it. This is a good way to put the player's fighter near a ship he's guarding.

Congrats: you're now saving coordinate and health information on the ships you've selected. There's one more key thing you need to do: set up a player persistent variable called 'checkpoint1unlocked' or something like that. Arrange for it to be set from 0 to 1 to indicate that the player has unlocked this first checkpoint.

 Time to move on to the hard bit, the LOAD.

STEP THREE
it's chronicles of riddick and right then and there i start doing the moves alongside the main character, riddick

Expand your LOAD event. Don't worry about the trigger for now. We're going to work backward: set up the back end of the LOAD event first.

Imagine for a moment what this event is going to do. It's going to take the mission's initial state and rearrange it to resemble the saved state. In order to do this, it needs to achieve the following:


You need this event to accomplish everything, at least in abstract, that should've happened in the part of the mission you're skipping over.

The first thing you should do is use set-object-position to grab every ship from mission start and slap it in its slaved spot.

Next, delete ships that should be destroyed. You may want to use vanish instead of self-destruct, but bear in mind this won't trigger is-destroyed-delay conditions.

Sabotage hull subsystems to get ships to their correct hull state. If you want to save key subsystems on capships, here's the time to take care of that as well.

Do anything else you want to do, like alter player missile capacity or loadout based on saved info.

You may need to do some other kung fu as well. There's no way to save orientation state, so you may need to do some set-object-facing-object. Clear AI goals and set them to what they need to be. Make sure ships don't do anything dumb with their waypoint paths, like starting the whole thing over from the beginning. Make sure subsystem and ship guardians have been properly applied to ships that need them.

Here's a tricky bit: there may be ships that we need to cue to warp in, then quickly move to a new location. Set up their arrival triggers to include an OR condition which triggers at checkpoint load. Immediately kill the ship's entry momentum with a SEXP (this is glitchy and requires some work), then teleport them to where they want them, and apply any necessary hull and subsystem damage AFTER they arrive.

Bear in mind we still haven't told this LOAD event when, exactly, to fire. We're going to move forward a little further before you do that. You need to look at your mission logic going forward, and make sure that the flow of the script can continue based off either a normal mission play or from this checkpoint LOAD event. This should be easy as long as your mission logic is pretty linear, but it may take some finesse. I'll leave that as an exercise for the FREDder.

Time for the next step: arranging for the player's ability to fire the checkpoint, and actually triggering the LOAD event.

STEP FOUR
i do every move and i do every move hard, makin whooshin sounds when i slam down some necros

Let's look at what we have right now:

Mission start (the mission starts)
A LOAD event which sets the mission up the way we want it once the checkpoint loads
A SAVE event which stores the mission state. (You may want to alter the trigger for this event so it won't fire if the checkpoint has been loaded - this can lead to weird behavior.)

Since the SAVE event sets our checkpoint1available var from 0 to 1, the player will have access to this checkpoint after they've played through the mission once. (You may want to have a training message or HUD gauge indicate when the checkpoint's unlocked.) For testing and dev purposes, just set this var to 1 at mission start.

What do we want to happen if the checkpoint is available? Well, to keep things convenient, I usually give the player a 10 second window at mission start to select the checkpoint - if they don't do it right then, they're committed to a normal playthrough. If you let the player load the checkpoint at any time, you can cause all sorts of mess.

Let's set up an event which checks whether the checkpoint1var equals 0 or 1. If it's 1, we want to show the player a message. You can use a training message or a new HUD gauge.

Now, figure out how the player will tell the mission to load the checkpoint. In BP, we allowed the player to call in a com buoy from the reinforcement menu named 'Load Checkpoint 1'. Another approach is just to tell the player to press Alt-X or Alt-A, or 1 or 2 on a menu if you have more than one checkpoint. Remember, make sure the player can only take this option for the first 10 seconds or so of the mission.

No matter what happens, you should have a single flag which goes from 0 to 1 to indicate that the player has asked for a checkpoint load. We'll call this LOAD CALL. But you don't want the LOAD event to fire right away, or the player will see everything teleporting around. So once LOAD CALL fires, the first step is to fade out to white and lock the player's controls.

Once the fadeout to white is complete, fire your LOAD event. Give it another second, then fade back in and unlock the player's controls. Congrats! You've loaded your checkpoint.

But there's a problem: your mission start logic is probably still running.

STEP FIVE
not many can say they escaped the galaxy's most dangerous prison

Because you read this tutorial all the way through before starting your mission, you're going to know from the start that your pre-checkpoint mission logic needs a break point. After your 10 second starting window, check whether the LOAD CALL has fired. If it hasn't, mission proceeds as normal. If it has, break your mission logic and then resume from the point of the LOAD.

You'll also need to suppress any messages or events that would've fired before the checkpoint when, say, a loaded ship took damage or exploded. You don't want your checkpoint loading and immediately firing 15 messages about how ships have taken damage.

Okay I'm probably forgetting a bunch of important **** but congrats, off the top of my head I think you've got the rough outline of a working checkpoint! Time to check it a billion times. Ask me questions and point out my dumb mistakes here in this thread.

I'm skipping over a lot of finesse here. You need to build the whole mission with the checkpoint in mind, using clean, easily broken chains of mission logic. But if you're a good FREDder you'll have no trouble, and if you're not, it'll be a great way to touch up your skills. Good luck, and happy loading!

next time on battuta writes words: the easy business of dialogue skips
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: General Battuta on March 27, 2012, 10:54:12 am
i want to emphasize that this guide is in fact pretty bad and needs some sweet pictures
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Cyborg17 on March 27, 2012, 11:26:22 am
You're being way too hard on yourself.  I understood it all, and the tutorial fulfilled it's purpose.

I was a little disappointed, though, since I guess I imagined your system was a little more complex than this. (not that it needs to be: it's an excellent system. I just imagined that there would be more manipulation of numbers or something like that so that you could save more data.)

Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Darius on March 27, 2012, 11:45:08 am
Radttuta is being silly. This is an excellent addition to my ongoing FREDucation.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Colonol Dekker on March 27, 2012, 11:47:57 am
My head hurts..
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: General Battuta on March 27, 2012, 12:02:15 pm
You're being way too hard on yourself.  I understood it all, and the tutorial fulfilled it's purpose.

I was a little disappointed, though, since I guess I imagined your system was a little more complex than this. (not that it needs to be: it's an excellent system. I just imagined that there would be more manipulation of numbers or something like that so that you could save more data.)

What more data do you want to save? I left most of that implied because I thought it was the easy part. I requested some string-related SEXPs recently that should allow much more dense data storage; Goob implemented them swiftly and they're available now.

You can if you're creative even store and recreate mission clock time and kill count - it's just sort of dumb and pointless.

Sorry to disappoint, though, guess I should've just left it a mystery so everyone could think it was impressive

e: I really don't understand your complaint here. You think it's as simple as it needs to be but what you want it to be more complicated so that...it can be more complicated?  :blah:
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Cyborg17 on March 27, 2012, 04:19:55 pm
I guess I imagined that you might be saving x,y,z coordinates in one variable, or something along those lines.  It must have just gotten it into my head at some point that there was too much information to store and so there was some masterful trick at work.

But thanks for showing us how to do it.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: General Battuta on March 27, 2012, 04:23:38 pm
I guess I imagined that you might be saving x,y,z coordinates in one variable, or something along those lines.  It must have just gotten it into my head at some point that there was too much information to store and so there was some masterful trick at work.

You can do that now (thanks to a feature request I put in and Goob implemented), but it was impossible at the time the system was devised, and it's still much more work for relatively little benefit.

The 'masterful trick' lies in being smart about what you need to store rather than brute-forcing everything and wasting a bunch of your time and resources.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Meneldil on March 27, 2012, 07:41:50 pm
Wow, great work. The whole checkpoint idea was brilliant. It may be ugly as hell, but it definitely made playing WiH more enjoyable.

@Cyborg17: Things like cramping several integers into one variable probably wouldn't be worth the effort, but I guess set-bit and is-bit-set could be quite indispensable for storing binary states in a longer campaign.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Cyborg17 on March 27, 2012, 09:15:36 pm
Well, it doesn't matter now, apparently.

FSO moves quickly.

Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: General Battuta on March 27, 2012, 10:12:22 pm
I intended to use this new string functionality to manage big sets of persistent data. The plan was to track the status of the pilots in a 24-man squadron using a single 24-symbol string, with the value of each string digit or letter representing a code (dead, alive, experience level if alive) and each individual digit in the string modified separately and called when necessary.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: karajorma on March 27, 2012, 11:48:15 pm
I really should just bite the bullet and work on my full collection classes idea.

Gah! Another one for the "When Diaspora is out" pile.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Admiral MS on March 31, 2012, 01:08:30 pm
What more data do you want to save? I left most of that implied because I thought it was the easy part. I requested some string-related SEXPs recently that should allow much more dense data storage; Goob implemented them swiftly and they're available now.
Which SEXPs were added for that purpose? Couldn't find anything related to better data storage.

I intended to use this new string functionality to manage big sets of persistent data. The plan was to track the status of the pilots in a 24-man squadron using a single 24-symbol string, with the value of each string digit or letter representing a code (dead, alive, experience level if alive) and each individual digit in the string modified separately and called when necessary.
That feels like one should write a script for that purpose...

And while you are talking about saving and loading shipdata, I created a script to do this and save things like hp (including subsystems), coordinates, weapons (and whatever else useful is in the ships array) into a file and load them again into the game. I posted it over a year ago - but as usual the scripting forum is ignored by most people. It might need some fine tuning if someone wants to use it but it should help reducing the amount of variables needed.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: General Battuta on March 31, 2012, 01:21:12 pm
I wouldn't say the scripting forum is ignored - BP uses a ton of scripting in the same release that introduced these checkpoints. It just happened that someone with FRED knowhow and no LUA skill did these checkpoints (me)
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: mjn.mixael on March 31, 2012, 01:38:21 pm
I personally would be interested in a script that simplifies the process. Using less variables is handy because I do tend to use a lot of variables already..
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: General Battuta on March 31, 2012, 01:56:08 pm
I personally would be interested in a script that simplifies the process. Using less variables is handy because I do tend to use a lot of variables already..

I also use lots of variables! Pre-bump (I think the limit was bumped...) the problem is not total variables per mission but PPVs per campaign.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Admiral MS on March 31, 2012, 01:57:15 pm
Maybe, at least in bigger teams there are people who have LUA skills or take a look into the scripting forum. There is a number scripts usable without any LUA skills.  The script I made should be easy to use as well and could help at checkpoints or getting a lot of shipdata easy from one mission to another but despite a lot of possible uses no one bothered testing it. Probably because they don't know that it even exists.

There may be bugs I can't find myself during testing or people don't like the way it works (which can be changed). Still that needs people actually trying to use it somewhere.

I personally would be interested in a script that simplifies the process. Using less variables is handy because I do tend to use a lot of variables already..

I can upload it again somewhere together with the sample mission if you want.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: General Battuta on March 31, 2012, 03:33:41 pm
Again, the reason your script wasn't used here, in spite of all the LUA-fluent people on the BP team, was because I did the entire checkpoint system myself one afternoon when it seemed like it'd help with a mission and I'm completely useless at LUA. For all I know your script could be a 50000% better way to do it, please feel free to post/link it and the sample mission

It will definitely help with a checkpoint setup, though you'll still need to make sure your mission logic is set up right.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Admiral MS on March 31, 2012, 05:18:44 pm
I think you made your checkpoint system long before I even had the idea for that script, so it wasn't directed at anyone specific ;)

So here is the script: http://www.mediafire.com/?az06q1gd3j4b95k

Contains two really short sample missions just showing what the script can do. I tested it on 3.6.14 RC5 and everything worked fine.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Cyborg17 on March 31, 2012, 11:43:40 pm
Sounds like an excellent reason learn LUA.  *runs off to tinker*
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: mjn.mixael on April 01, 2012, 09:49:15 pm
Admiral MS, why are optional Stat 3 and 4 not recommended currently? (Just curious)
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: General Battuta on April 01, 2012, 10:12:00 pm
This tutorial thread has taught me a lot, my technique is disappointing and would be better handled by LUA (http://fi.somethingawful.com/images/smilies/emot-v.gif)
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: mjn.mixael on April 01, 2012, 10:20:04 pm
Wut, no. Your technique is still quite valid. Just instead of using like 50 PPVs we can just do script-evals. The rest of the 'how-to' is still very relevant.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Admiral MS on April 02, 2012, 02:38:07 am
Admiral MS, why are optional Stat 3 and 4 not recommended currently? (Just curious)

I'm not exactly sure why, I made the script over a year ago. But as far as I remember Freespace had the habit of crashing randomly when using these and I couldn't figure out why. If I think about it the reason could be as well that the engine was unhappy about all the manipulation work going on at the same time  :rolleyes:
I guess it's as safe to use them as is the whole script. The sample missions are using both stat 3 & 4 without problems anyway.

This tutorial thread has taught me a lot, my technique is disappointing and would be better handled by LUA (http://fi.somethingawful.com/images/smilies/emot-v.gif)

Actually I thought about extending the script to cover some more stuff like recreating SEXP states but I have absolutely no idea how that should work  :D
So you still need proper fredding as described in your tutorial to make anything like a checkpoint work. The script helps going around the PPV cap and simplyfies the process of saving and loading to one SEXP for each.

The reason for creating the script wasn't checkpoints at first but getting rid of buggy red-alert and still transport shipdata to the next mission and if possible even in the mission simulator.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Goober5000 on April 02, 2012, 03:04:35 am
Wut, no. Your technique is still quite valid. Just instead of using like 50 PPVs we can just do script-evals. The rest of the 'how-to' is still very relevant.

The new sexps Battuta mentioned should significantly reduce the number of variables you need.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Admiral MS on April 02, 2012, 09:19:07 am
Admiral MS, why are optional Stat 3 and 4 not recommended currently? (Just curious)

I'm not exactly sure why, I made the script over a year ago. But as far as I remember Freespace had the habit of crashing randomly when using these and I couldn't figure out why.

Took a look at it again. There are two reasons: Depending on the mod and mission you may need to change entries directly in the script. Stat 3 & 4 need a shiptype and coordinates to place it before destroying it or sending it into subspace.
Second reason is that the Fredder needs to be really careful to prevent any unwanted influence on other SEXPs. I'm not sure if the script can get something wrong as a consequence. It uses SEXPs itself to determine whether a ship has departed or is destroyed.

Wut, no. Your technique is still quite valid. Just instead of using like 50 PPVs we can just do script-evals. The rest of the 'how-to' is still very relevant.

The new sexps Battuta mentioned should significantly reduce the number of variables you need.

I already asked this but no one answered. Which SEXPs were added and what can they do older ones can't?
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: General Battuta on April 02, 2012, 09:29:26 am
You can alter individual characters in a string.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Goober5000 on April 03, 2012, 02:02:22 am
I already asked this but no one answered. Which SEXPs were added and what can they do older ones can't?
Sorry, missed it.

What Battuta said.  Take a look at all the uncategorized sexps in the latest FRED build.  The int-to-string, string-to-int, string-get-substring, string-set-substring, string-concatenate, and string-get-length sexps will all help here.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: karajorma on April 03, 2012, 02:30:30 am
They really should be categorised.

int-to-string
string-to-int
string-get-substring
string-set-substring
string-concatenate
string-get-length

It's not like figuring out what to call the category should be an issue. :p
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Admiral MS on April 03, 2012, 03:23:32 am
These sexps are really interesting. Still they sort of belong together with the other variable sexps like variable-array-set. My suggestion is putting them into a variables category  :drevil:

Am I right that with variable arrays and these new sexps you can get as much variables as you need?
So the main difference using a script like the one I made is that there won't be tons of sexps confusing fredders (instead a short ( script-eval "saveship('Alpha 1')" ) or ( script-eval "loadship('Alpha 1')" )) and the ability to save and change some data sexps can't access at the moment?
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Snail on April 03, 2012, 04:15:42 am
string to int and int to string sound like awesome awesome sexps
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Goober5000 on April 03, 2012, 01:19:15 pm
These sexps are really interesting. Still they sort of belong together with the other variable sexps like variable-array-set. My suggestion is putting them into a variables category  :drevil:
Indeed... good suggestion.  This will also allow us to categorize the modify-variable sexp. :nod:

Quote
Am I right that with variable arrays and these new sexps you can get as much variables as you need?
No, you are still limited to 200 (or whatever) variables total.  But these sexps let you pack a lot more information into each string variable.

The funny thing is, you can only store 7905 bits of information in a string variable (31 * (2^8 - 1)), compared with 4294967296 bits of information in a numeric variable (2^32).  But most people will find character combinations much more intuitive to work with than numbers.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: karajorma on April 03, 2012, 07:39:09 pm
Problem is that String-to-int has bugger all to do with Variables. In fact I've never once used it with a variable even though I've used it multiple times.

In addition, if someone ever adds a String return type they'll all be in the wrong place.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Goober5000 on April 03, 2012, 11:27:18 pm
Problem is that String-to-int has bugger all to do with Variables. In fact I've never once used it with a variable even though I've used it multiple times.
Except that this is the only sexp that works with strings that doesn't put something in a string variable.  For the sake of grouping all the string sexps together, it should be in the same place.

And if someone adds a string return type we'll have to make new sexps for all the others anyway, so that would be an excuse to recategorize them.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: karajorma on April 04, 2012, 02:08:26 am
Or we could do it right in the first place.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Admiral MS on April 04, 2012, 02:38:32 am
Whatever you do, please put all of them somewhere together!  :nod:
string-to-int is located in status category, int-to-string in change category and it's the same with the script-eval sexps (script-eval in change and script-eval-string/num in status). In case a sort of variable transformation like string-to-int feels too far away from variables, then create a string category, a variables category and a scripts category inside change or whatever. Just give it some organisation.

And if someone adds a string return type we'll have to make new sexps for all the others anyway, so that would be an excuse to recategorize them.
Script-eval-string returns a string, though it's not something like standard sexp. I can't see why you have to make new sexps in case someone adds a string return type?
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Goober5000 on April 05, 2012, 01:03:11 am
Whatever you do, please put all of them somewhere together!  :nod:
string-to-int is located in status category, int-to-string in change category and it's the same with the script-eval sexps (script-eval in change and script-eval-string/num in status).

That part can't be helped because the Change category is for sexps that perform actions as opposed to returning values.  You'll find many other sexps split up that way where one is a "set" and one is a "get".


Quote
Script-eval-string returns a string, though it's not something like standard sexp. I can't see why you have to make new sexps in case someone adds a string return type?

The string return capability doesn't work.  Take a look at this excerpt from the code:

Code: [Select]
case OPR_STRING:
Error(LOCATION, "SEXP system does not support string return type; Goober must fix this before script-eval-string will work");

It appears WMC (the author of the above) is trying to blackmail me. :p  He does have a bit of a point; I can think of a rather clever way to return string values (as well as decimals and whatever else) without rewriting the whole sexp system.  I just haven't gotten around to actually coding it.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Admiral MS on April 05, 2012, 03:22:29 am
That part can't be helped because the Change category is for sexps that perform actions as opposed to returning values.  You'll find many other sexps split up that way where one is a "set" and one is a "get".
Feels like I'm at a loss here with my somewhat basic programming knowledge but oh well, it can't be changed anyway. :rolleyes:

Quote
The string return capability doesn't work.  Take a look at this excerpt from the code:

Code: [Select]
case OPR_STRING:
Error(LOCATION, "SEXP system does not support string return type; Goober must fix this before script-eval-string will work");

It appears WMC (the author of the above) is trying to blackmail me. :p  He does have a bit of a point; I can think of a rather clever way to return string values (as well as decimals and whatever else) without rewriting the whole sexp system.  I just haven't gotten around to actually coding it.
Someone should have changed the description in FRED to something like: doesn't work at the moment...
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: mjn.mixael on April 28, 2012, 12:36:49 am
So I finally got around to this. I injected checkpoints into previously made missions... (which was not an easy task for missions that weren't designed with checkpoints in mind)... But it works! Admiral MS's script is totally win. I made the checkpoint with only 4 variables. I highly recommend others checkout this powerful script tool.

Admiral MS, why are optional Stat 3 and 4 not recommended currently? (Just curious)

Question answered. FSO may not mind this so much with 1 or 2 ships at a time, but doing it for 5 or more definitely screws some things up. I'd recommend saving Stat types 3 and 4 for ships that absolutely need to show as destroyed or departed.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Admiral MS on May 12, 2012, 09:37:18 am
After getting some suggestions from mjn.mixael I modified the script to include filemanagement. Now it's possible to have a different savefile for every mission. Another function was added to check whether a certain file does exist or not. That way the script works fine with multiple checkpoints or checkpoints used for playing missions in the simulator.
I fixed a few other things and made a easier to understand readme ;)

Download here:
http://www.mediafire.com/?ekf69ed865skpf3
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: mjn.mixael on May 12, 2012, 09:57:31 am
The script is so much win. We've already used it to easily setup checkpoints in BtA.
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: Talon 1024 on July 31, 2012, 07:07:33 pm
So...  I have a question.  Do I have to modify EVERY event that occurs prior to the checkpoint to allow it to load and not break mission logic?
Title: Re: Badttuta's Bad Guide to Mid-mission Checkpoints
Post by: mjn.mixael on July 31, 2012, 07:21:45 pm
well, sorta. Any event that you don't want to trigger after the checkpoint, just do AND with NOT -> IS EVENT TRUE (checkpoint). But you only have to do this with "trigger" events. What I mean is that you probably have events that only trigger after other events and so on.. making a long series of events occur. If you FRED'd properly, then you  only need to modify the first event in the series.

Similarly for events that should trigger after the checkpoint, you may need to check for that too.