Using Crew to Move Items

Hey Folks! Some pretty cool progress today, as I focused on some tools to allow crew to move larger items and uninstall/reinstall them.

The first thing I did was more of a warm-up. I finished the dragging/pulling code I started yesterday afternoon, and formalized it into a simple component I could add to any object. Once added, and told who to follow, that object drags around behind the target at a set distance. Not much more to it yet, but it should come in handy once I'm ready for AI to start using it.

Once that was done, I started adding more directly useful code: the ability to select an item, put a placeholder object for it somewhere, and have the AI move the original to the new space.

I started out with a simple hotkey to take whatever item was selected, and add a ship-editing cursor to the UI with a copy. This was why I merged the old ship editor scene into the crew sim scene, as doing this was a simple few commands to initialize the editor cursor.

Once that item was placed, I needed to intercept the normal ship editor click to put a placeholder copy there instead. This was also fairly easy to setup. I just created a special sprite to use for this purpose, which is an additive shader using whatever the original item's image was. The item stats for it are the same, so it can reuse the tile placement rules. But the game stats portion of it is a complete blank, so it does nothing to the ship, except block pathfinding appropriately.

Finally, I needed to start integrating the AI with this process. So at the moment this placeholder is put onto the ship, I queue up several commands on the player's AI to get things rolling. The AI is told to pick up the target item, and then pickup the placeholder.

When the AI gets these commands, it automatically inserts pathfinding commands to reach each goal before initiating the command. And it uses the pickup code I added earlier to remove the item officially from the ship to the AI's inventory.

The result is today's screenshot, which is almost like a mini comic:

  1. AI is doing something else at the beginning.
  2. User chooses the N2 canister to be moved, and uses the grid placement rules to position it in its new home.
  3. A placeholder N2 canister copy is placed in the new home.
  4. The AI walks to the real N2 canister, picks it up, and begins walking to the placeholder with it in inventory.
  5. The AI removes the placeholder, making room for the real N2 canister.

So far, so good. At this point, we have both a real and fake N2 canister in our possession. So the next step is to make sure the fake is removed from the game when no longer needed, and the real one is installed where it's supposed to be.

Probably, this means a new interaction for AIs to use exclusively on placeholder. Something like "remove placeholder," so it doesn't go into inventory. I already have code to remove items from AI in an interaction, so this should be straightforward.

The placement of the original item might be trickier. I might need to store the final destination somewhere so the AI can drop it in a specific spot. Right now, I have an item drop system, but it doesn't care where the item goes. So I might be able to borrow or bend that system to do this.

Overall, though, not bad! Once this is running, players should be able to install items and/or move them around on the ship, which seems like a big step towards being able to live on a ship long-term.

Tags: Ostranauts