site banner

Tinker Tuesday

This was really popular last week, I was really impressed with how many hardworking hobbyist type people we have here. It got me motivated to do some of my own things.

As a reminder, this thread is for anyone working on personal projects to share their progress, and hold themselves somewhat accountable to a group of peers. We can coordinate weekly standup type meetings if their is interest.

Post your project, your progress from last week, and what you hope to accomplish this week.

Also naming the thread. Tinker Tuesday or taskmaster Tuesday, or something else? I switched the thread to Tuesday instead of Monday because the culture war thread refreshes on Monday.

7
Jump in the discussion.

No email address required.

HighSpace

Last week:

It went pretty well, I did all the tasks I was planning to, and even got an early start on this week. Issues I managed to close are:

  • Spawning of enemy ships

The idea for the prologue scenario is that the player jumps into a system where allies were ambushed, and chose to scatter their squadron by making random short-range jumps throughout the system. Subspace jumps can be tracked, albeit imperfectly, so the enemy is hot on their heels, but outside their field of view. The screenshot for the monthly thread included a part of that - ships spawning in random orbits throughout the system. Currently there's no sensor mechanics therefore there's no "field of view" to speak of, so the goal here was to have the ability to spawn in a random spot within a given range. At first glance the ships might look like they're on top of each other, but these are astronomical distances we're talking about, so it ain't all that bad when you zoom in. I'm pretty happy with it so far.

  • Load New Game state from data files instead of hardcoding it in LUA

I did a bunch of hardcording at the beginning, since it was just a proof of concept, but even the scenario with one friendly group and 2 enemy ships ended up taking up a whole bunch of space in the script file, and wasn't all that friendly to read. Moving it to a json file doesn't help all that much with the readability, but at least the game state lua file is reserved for logic, and I don't dread opening it anymore.

  • CTD on start of campaign under some circumstances.

Not a very helpful title, but originally this bug felt pretty mysterious. It ended up being a result of an allied ship spawning on top of an enemy, and thus triggering a mission. There's a known problem where a mission currently needs a ship designated as "Alpha 1" or the game will crash, and this bug was (most likely) a result of that. In any case the scenario of an allied ship meeting an enemy was outside the scope of what I was planning to do, so all I did here was throw a more descriptive error, and closed the issue.

  • Add Find group by name functionality.

Star systems are a kind of a tree structure, where a star has it's satellites, which can have their satellites, etc., this helps with calculating the orbits. Aside from that, there's a "flat" map that allows me to get an object by name, except a group is also a valid object, and their construction is somewhat dynamic, so you can't rely on them having a particular name/ID

This ended up being an issue in 2 cases:

  1. Finding the player's battle group, so the camera can lock on it
  2. Removing individual fighters from their wing in the global game state, if you shoot them down in a mission.

Grouped ships now have their own flat map. Quick and dirty, but it works.

  • Crash on win/lose of the game.

Somewhat easier to reproduce before I spammed the map with enemy ships, but the name is self-explanatory. Turned out to be a case of overzealous refactoring, where I renamed a call to a function necessary for the win/lose dialog to show up.

  • Neutral ships join player on rendezvous.

Freespace lets you define "teams" and I put the allies in the "unknown" team so the player has no direct control of them. The goal was to have them switch the team to "friendly" when you encounter them. Quick and easy.

This week:

  • Document code with annotations.

I may have gotten an early start, but I think I also nerd-sniped me self here...

One of the pain-points in working on this project was lack of auto-complete. It wasn't a big deal at the start, but it gets more annoying as complexity grows. Still, there didn't seem much I could do about it, since even annotated code I lifted from other mods didn't seem to do anything for me... until I decided to update the plugins for my IDE - lo and behold, turns out that EmmyLua supports annotations, and I must have been using some bugged out version that didn't do anything with them.

So naturally now I want to Annotate All The Things, except EmmyLua is pretty good at figuring out of the autocompletions all on it's own, so the immediate need for that also went down. However one place where it would be really helpful is the Freespace scripting API, until now I was just looking up their HTML docs. The problem here is that the API us pretty massive, so annotating it by hand, and maintaining it would b a pain in the ass. Luckily the Freespace exec has a switch that let's you dump the scripting docs, but currently it only supports HTML (for the website, I'm guessing) and JSON (for autocomplete in typescript, which can later be transpiled to LUA, which I find a bit galaxy-brained).

So now I'm extending it to support a LUA annotation format. Still a few kinks to iron out, but I'm pretty happy with the results so far, and if I clean up the code this might even be useful enough for others to get merged into the main FS2 repository.

Later on I will want to annotate at some of the mod code itself, because there's a few common data structures that a bunch of classes use, that currently just get parsed as table, but I'll probably split that into a separate issue.

  • Map AI: Aggro and chasing

I want the enemies to have some basic AI. For the moment I'll go with a simple "chase the ship with the highest aggro", algorithm, but even that has it's implication (ships having AI, the existence of different AI profiles, the existence of aggro) so it might be a bit more complex than it looks at first sight.

  • Distinct icon for bomber wings

Something nice and easy after the other two tasks. Currently bomber wings are indistinguishable from fighter wings on the system map, which could lead to some terrible tactical decisions.


I might get to other issues, but right now it's looking like this will be enough for this week.