Group Spawning, Interactions Clean-up

Hey Folks! Worked a bit on group spawning rules today, and a lot of general clean-up of interactions and null pointers.

As mentioned yesterday, the game's spawning rules prevented almost anyone except the first person on each station from appearing. I needed to change the spawning such that it:

a) didn't care if a similar NPC was already spawned, and
b) didn't require a separate spawn zone per NPC

The first change was trivial. I just omitted the code I added to prevent spawning if a similar NPC already existed. This might bite me down the line (namely performance), but for now, it gets things moving again.

The second one was a bit more involved, as it required both a data change and a UI change.

The data change was to add a new field to zone info for "count." In zones that allow it, like spawn zones, the user can add a "count" amount to control how many NPCs spawn in that zone. This was just a matter of adding the new field to the data type, and adjusting load/save code accordingly.

The UI, predictably, was more involved. I needed a new widget in the UI to accept input for this data. I needed to show/hide it depending on the zone being edited. I needed to save whatever setting the user applied to said zone. And I needed to load the previous user setting into that widget when the user chooses a zone that supports it.

Like I said, predictably complex, as with almost any UI :)

Anyway, that works now. And I spawn one bartender/shopkeep on OKLG station now, as well as 5 random people.

And immediately upon doing that, I noticed they had some weird interactions. Like, they all pile into the same tile and start chatting.

Part of this is due to the data, since the talk range is 1 tile, and the talking spot is 1 tile in front of an NPC. That means that NPCs facing furniture, like a toilet, have their talk point inside the toilet. And the NPC approaching them tries to get 1 tile away from that, which if they're approaching from behind, is the same hex as their target.

Ideally, they'd be smarter. But I'd have to be smarter (or more developers) to fix that. So for now, I changed the talking point to be dead-center of the NPC, and allowed a range of 2. This means NPCs approach their target, and pretty much stop 2 hexes away, regardless of which way anyone is facing.

The result is slightly better visuals, and less overlapping due to interactions. However, they'll still need more fixing some day, since it's possible for NPCs to share a space and overlap for other reasons (which become more common when a trio or more NPCs switch between chatting partners).

So chatting looks a bit better now.

I also had to hide certain interactions from AI so it wouldn't open things like the trade, hiring or other UIs. A small data change, but not hard.

All of this was to solve problems I noticed when I last tried to fly to OKLG and hire some crew, and found nobody there but the shopkeep. This time, I arrived to find 6 people milling around the station, which is more like it. I started approaching some and hiring them, and then bought all the food packets I could from the shopkeep.

However, I ran into trouble corralling my hired NPCs back onto my ship. Finding them was one thing, I had to keep opening my Roster UI to look up their names, and find them to select them. And then, they wouldn't cross the threshold back to my ship unless I hand-guided them in small steps there.

At first, I thought this might be due to their roster settings forbidding "shore leave," but even changing that didn't help. So tomorrow, that's on my to-do list.

I also think I should add some creature comforts to the game to make recalling my crew to my ship easier. Either a "recall all" button, or ways to select crew from the Roster UI, or maybe just force them to return when "shore leave" is revoked on each.

Once that's done, I can try this test again, and hopefully get a small crew onto my ship for a real-time flip-and-burn maneuver to the closest derelict. It'll give me time to try out intra-crew drama, as well as some salvaging. And hopefully, give me a clearer idea of what I need to work on next to make this more interesting to play.

Tags: Ostranauts