Ding! Trading Operational

<Drawing in long breath and exhaling.> Ok. I think we've got trade working now. It was a heck of a day, fraught with niggling, annoying details. But I believe the trade system now works as intended!

The first order of business was a bug in the ship zone tiles when ships rotated for docking. They needed special treatment since their tile indices became invalid when the ship's tiles rotated. Not too hard to fix, just hard to remember, hence why it wasn't already doing it :)

But that wasn't it. Not by a long shot.

Items being traded were often hidden due to being in a container (e.g. the seller, or a fridge). So the item needed to be revealed again when moved to the buyer's barter zone. Not only that, they needed their transforms fixed, since they were often thrown out of whack as the container walked around the ship. (Or scaled according to the container's dimensions.)

Then, there was a bug in the way item tallies were calculated during a sale. I was incrementing and decrementing the same value each trade. Similarly, the trade was operating on the same item over and over (the one used to populate trade UI rows), instead of copies belonging to the seller. Oops.

And it turns out there was also a bug in the way item bounds were calculated when checking if it would fit on a tile. This just never showed up before since it only happens when fitting an item from a container or other distant position. (When the item was a floating cursor, the calculation wasn't wrong, so ship editing worked.)

When all of these issues were finally corrected (and some of those position ones needed multiple fix attempts), we had the trade you see in today's image! Two food packets in our barter zone, we buy one from Tope, and upon completion, it appears in an empty space of our barter zone. Nice!

Along the way, I also solved a few unrelated issues that were annoying me (mostly due to slowing my testing).

Pathfinding was incorrectly weighing the cost of diagonal movement, causing some weird, wide arcs when walking around. Door walkable tiles were trimmed a bit to avoid clipping when NPCs walked through them. There was a null pointer bug when AI was interacting with certain doors that were manually opened by the player.

And a few finance/cash features were added or cleaned-up. Character generation now bestows life savings to the starting character, and there is a hotkey to give the player $100.

Overall, this was a good day. Some hard work yielding some useful and important features.

I think what this means now is that I am almost able to play the game. If I have stuff to sell, I can do so, get money in exchange, and then use that money to buy supplies like fuel or food. The missing piece now might just be more data/content.

The first (and simplest) example I can think of here is something like breaking down a wall, floor, or other ship piece to get parts that you can sell. Sprinkle some ships around the system, arbitrarily damage them to make them derelicts, then let the player approach them, dock, board, and interact with parts to get pieces for sale.

There's a lot wrapped up in that simple loop. Damaged states for things (which I kind of have for basic parts already), components that can be salvaged from said parts, interactions that produce salvage parts, tools(?) needed to do those interactions. Probably also some breathing apparatus for boarding the derelict, and some means of detecting which ships on the nav console are derelicts vs. friendlies.

That's a lot. But the cool thing is that it's a lot of stuff that seems like it directly adds fun to the game. Instead of building foundation systems, these seem a bit more like adding new crafting recipes to NEO Scavenger, or items to be used in situations, or, dare I say it, goals for the player?

Anyway, I'm feeling a bit better about things after this. Maybe I could be having fun in the game soon?

Tags: Ostranauts