Protobound Day 4: Party time.

Protobound Day 4: Party time.

Today's focus is the Party system and recruitment. Party members for now will just be NPCs that follow you around.

First step is to create the recruit to party function. Then add a switch for Party mode/NPC mode.

Next I need to set the party member to the party child of the player character.

Then I need to write the follow code for the party member to follow whoever is in front of them. There are 2 ways I can think of doing this, first is adding a script to the Party node that keeps track of the player's path, then moves each party member along the path X steps behind. This would result in the party members taking a snake-like path behind the player.
The other way is having the party members always walk toward the player but each member in line has a wider target area to approach to so they would form a less straight line. This approach would have more potential issues I think.

I will try the former, if it starts taking too long, I will switch to the later and have to fix the problems later.

Let's get this party started. (Ow. I hate myself for that. I will have to self-flagellate later.)

The question is... should I have nodes to act as containers for the party members built on to the party node? It would require some rewrites on how the animations are triggered but it would be maybe 10 minutes of work. It would make it easier to test. Let's give it a shot, I guess.

While I work I have HexChat opened and hang around some channels on Freenode. C, C++, Godot, Arduino, PostgreSQL and some others. It can be distracting at times but I do learn a lot. If I find I am getting too distracted I will minimize it and focus. It's weird seeing how active IRC channels still are and the conversations manage to stay on topic. It was a while since the last time I poked my head in... I prefer it to Discord, seems like all the immature people are on the discord servers for the same subject. Anyway, back to work.

So, I think I have a pretty good idea how this will work. I got the nodes set up and I will write the code to make them follow behind the player at a set distance in the player's history. I need to write the function to store the player's movement history up to maybe 150 positions? It's probably a good idea to look up what the positional coords are modeled as (if not pixels) and convert them to pixels somehow.

Meanwhile I am printing some parts for a macro keyboard I hope to be working on over the weekend, if I have time.

Go faster, dammit.

Hang on a moment! What's this PathFollow2D node? From the look of it I could have the player generate a Path2D wherever it goes. But would it be worth it to do it this way? It would probably be better for my cutscene system than this, really but hey... I have something for that now. Gonna put that up on the whiteboard.

I think I got a little ahead of myself with writing the code. I hadn't had my tea yet and just wanted to get it done. This was foolish. This is how we make mistakes that take hours or days to fix. I have stepped back and went to the whiteboard. I am starting to get everything in order now.

The following nodes will have a destination which will be X frames behind the player, the player's history will be tracked by the party node for Y frames. Depending on which follow node we are, our destination is X frames behind the player. We do not want to record frames if the player is not moving(walking into walls, etc). If we are not at our destination we are moving, thus animating, else we are idle.

How do we know which animation to play? Two ways I can think of:

A matrix tracking the movement and direction of the player per frame.

Compare current position to last position. Animate based on changes.

Which is better, though? With the matrix approach it's basically just playing back frames the player has gone through like a video. It would take more memory but have a lower impact per loop(let's assume there are 4 party members). There would be a lot of comparisons having to happen each frame for each party member, instead of reading from the matrix and setting direction, then if position ! destination, play walk for direction.

So on paper, we'd want the matrix.

And it does seem to work.

This is a distance of 20 frames. I will make it shorter though.

There is one bug I can imagine currently and that's something I will solve by resetting the frame matrix on map change.

Lunch. I got some Seafood ramen from Japan... I am not sure how this will go for me. I've never been big on seafood in general but I do need to find a way to eat more fish so I figured I would attempt to acclimate myself in whatever ways I can. Do I dare to it today though? Nah. I will have less work tomorrow and if my body does what it usually does with fish I will probably need to lay down for a while. Tomorrow it is.

Gonna eat my lunch, take my dog out and finish up this following code so I can make the first party member and get the bugger recruited and animating properly.

I have a bug where the frames still record while the player is colliding, I could fix this with some checks but the party members will have no collision and this isn't exactly gameplay breaking. Gotta remember, this is a protoype. I will make notes of low priority bugs for my future self if I come back to this but I will leave them for now.

Created issues for a few of the bugs. I'll come back and fix them some day, maybe. Back to work on the following logic.

All seems well so far.

I'll certainly need to space them out better, but it's working.

Next up, need to create the first party member. I can just copy the NPC template I made yesterday and build onto it.

I need to implement a switch that changes the NPC into Party member mode. Then from the NPC call the add party member function from the player's party node which will handle the rest... once I write that too. First, though... the party member NPC.

Managed to get most of the logic working, did find a bug, though. The page counter does not reset on ending conversations. Easy enough to fix, just set it back to one on goodbye().

Here's our boyo now.

Next step is to animate the bastard based on if moving or not. Hmm...

So we know what direction to face, we just need to modify the code so the party member will face that direction and animate if their global position is not equal to their last global position.

Now to make it work for more than one party member.

Out with the lads.

Welp. Time for a short break according to the pomodoro timer, then I will make 2 seperate party members.

Now each one needs their own script. Otherwise they will all behave exactly alike.

I guess I could write code that checks each npc's name and loads the correct bahaviors based on that, but that will allow me to make more mistakes later on. Having repetative code is also a bad thing because if I change something in one place I have to change it in all of them. I guess I will go for the halfway point.

There were a slight rewrite, I basically implemented the conversation from JSON system I had envisioned yesterday. It basically looks like:

{
  "page_one": {
    "text": "You look bored.",
    "button": "What?"
  },
  "page_two": {
    "text": "Come on, let's go get into some shit!",
    "button": "Uhhh?"
  },
  "page_three": {
    "text": "You and me are gonna run this town, let's go!",
    "button": "Recruit to party"
  }
}

This wasn't too hard to implement, though I had hoped not to need it. Oh well, good thing I thought of it, eh?

Godot does not allow internal editing of JSON files, though. Gotta use an external editor, which is fine, I guess. Feel bad for my poor laptop having to run all this.

Issue Closed, Milestone Closed.

I tried to edit and encode this to webm and it looked uglier than the gif. The laptop screamed the whole time and I feel like this is good enough, crappy gif it is.

I managed to finish a day and 2 hours early for this milestone, which ain't bad. Next week is combat and stats though, so... who knows how that'll go. I do get tomorrow to work on any project I want though.

Probably spend it adding some features to Mantilogs, maybe take a shot at printing a gecko hide. Need to get some water-based polyurethane to seal it though. Welp, gonna take a shower and do some laundry with the rest of my workday, then make some dinner.

Cheers.