Tutorial - Fun with Simulated Hull

From FreeSpace Wiki
Jump to: navigation, search

Let us suppose we have a daring mission idea here. You, a pirate, needs some cash. Well there's this mostly abandoned container depot that might have credits. To make things nice and random, let's have each container have a random amount of credits. When we send a transport to dock with the container, it'll take those credits from the container and add them to a stockpile. And maybe after docking with like 4 containers, the GTVA notices us and sends some goons out to take care of us.

So how would we do this? There's a few ways we could do this. One is make variables for each container and link them to containers by careful use of arguments and *-variable-by-index sexps. Or we could just set the cargo of each container to be a value and just grab that info with things like string-to-int sexps. But I think we should stick with something a little more simpler, sim-hits.

Just what is sim-hits? It’s a special, mostly invisible subsystem that all ships have. Way back in semi-ancient history, simulated hull was added so you could have a mock dogfight outside of a simulator setting. Weapons with a "training" flag wouldn't do real damage, just damage to your sim-hits subsystem. Though the oddest part about the simulated hull subsystem is that it starts at 0%, unlike anything else sane at 100%.

Since its invisible to the player and isn't affected by 99.9% of all weapons, I find it a great ship-specific variable to use for fun and profit.

Invisible Variable

So here is how we will use sim-hits in our scenario:

When the mission starts, we give each container a random amount of sim-hits integrity, from 1 to 100. Since sim-hits is a subsystem and is limited to 0 - 100, we set the cargo for each container to be (sim-hits-left * 10) to give a nice healthy amount of credits. Using string concatenate we'll add on CR as well to make it look nice. When we order a freighter to dock, we'll take that sim-hits total, multiply it by 10 and add it to our stock of credits. Then we set the sim-hits of the container to zero and mark its cargo as empty. This way we can go something like "2350/891200 credits stolen" at the end to help the player know how well he did.

Okay, let's get to it!

Here's our mission space. Just the player, a Posedion-class freighter, and a bunch of containers.

Simhits1.jpg

Here's the setup to making the containers get the sim-hits value and setting the cargo with a properly scaled number. All of the containers are in that in-sequence sexp, I make the event repeat 15 times so I can hit each one with a unique sim-hits (Though if you have this game settings flag on, you could do it in just one pass).

Simhits2.png

The dummyNumber variable is a string variable that gets the scaled amount from us doing sim-hits-left * 10. Then dummyNumber gets concatenated with " CR" and is set as the cargo for the player to scan.

And now for the event where our freighter docks with a container. Again we'll need to make this one trigger 15 times, once for each container.

Simhits3.png

It's similar to setting that first event up. When Cohort docks, add (sim-hits-left * 10) to the total number of credits, use that to generate a new cargo string and then set the container as empty with no sim-hits left. And we also send a message so we've got an update on our scavenging right there too. That collapsed modify-variable near the bottom just increments a variable called numDocked by 1 so we know when to send in the GTVA.

And that's it! Just 2 events that generates a number specific to each container and then accesses it for us to use elsewhere.

Of course there's so much more you can use sim-hits for.

Flag Variables

If you're making a complex conversation with the prompt box, you might want to ask a question or two to a ship and also have that question you asked exhaust itself so you don't ask the same thing twice. Here in a future mission for JAD, you can see how I used it. When I select an option with the Prompt Box, proBoxValue returns the line number that I selected. So when its 1, I selected line 1, and it sets that bit within the sim-hits of my target. Since sim-hits only goes up to 100, I only have room for 5 bits, but that’s still good enough for me.

In the event that decides what lines to draw, it checks to see if those bits are active within that target.

Simhits4.png

You could also use it for other things like to decide which fighters go renegade, or if a ship likes you or anything else you might need to store simple yes/no information in.

State Variables

In JAD:XA, the gauntlet has a boss trio, Trinitiel, that has a teamwork system built into them. To kill all three, you need to destroy each one's weakpoint core. When you destroy the core on one of them, that one goes to sleep for a bit, and one of other two goes into a heal mode to restore their sleeping brother. Then when he's healed, they go back to attacking you.

Sounds sort of simple when you just plan it out like that, but to make sure everyone is doing what they are supposed to, we need to keep track of their state. We could do that with a normal variable, but by embedding it into their sim-hits subsystem, we can just go "whoever has sim-hits 50 and this happens to them, do this then".

Simhits6.png Simhits5.png

You can see in this pic the different "Modes" the boss has. Everything from attacking the player, to healing a brother, to playing dead or self-destructing. (Keen players who see this may notice that they never teleported or tried to avoid the player, that is what we in the business call, cut content.)

Hopefully this will help assist you in any weird missions you might be planning, or maybe even inspire you!