Item Acquisition: Quest Complete


In The Beginning

I'm sitting here typing this out as I wait for another meeting. . . But I won't work on anything during the meeting. Just gonna make some notes to prepare for after the meeting when I'll do the actual work. So, I have a function in my quest manager that is automatically called when a player picks up an item. Right now it doesn't do anything, it's just a placeholder. After the meeting, I was able to really dive in and figure things out. 

What it needs to do is package the appropriate data into a dictionary and pass it along to another function, _process_active_quests, with some other data to actually process. But what does that function do? That's what I need to figure out before I send data to it. I need to know how to structure the data before I send it.

That function expects a quest id, the type of event, and that dictionary I talked about. It seems I had a bit of an issue with consistency it seems, my quest definition has "acquire_item" while my quest manager looks for "collect_item". Which is better. . . I think I'll stick with "acquire", that seems more like me. Now, about that dictionary. It seems it needs to contain a key "item_id" and "amount". You know what? No, "amount" is bad, let's go with "quantity" instead, since that's what I'm using elsewhere.

Wrapping the Dictionary

The next step was building the data into the dictionary I needed. a simple variable declaration with some default values was simple enough. But, next up I gotta figure out how to actually deal with progressing the quest. I have a signal popping a function when an item is acquired (any item). I know a lot about the item, but not how it may relate to active quests. I guess that's where I start then, loop through active quests, look for one with an objective of type "acquire_item" then feed that quest id, along with my dictionary, to the function that actually processes quests. 

But then, we're firing that function every time the player picks up an item. Maybe I need a new function to output quests based on their objective types. Maybe for another day, for now I just want this to work. So, maybe I just feed the function with every active quest id, one at a time, with the rest of the data it needs and see what happens. . . . Actually, I did something similar with the tool level quest stuff, and in that one I only "processed" the quest if it might be okay. 

Let's just see what happens. . . And nothing. . . I should have planned better, I totally forgot to add any debug messages to see what's actually happening. A couple of extra lines of code should help solve the problem. It did, actually. But it turned out the reason it didn't work is because I'm an idiot. I accidentally tried connecting the quest manager to a signal in itself that didn't exist instead of connecting to the inventory manager! With that quick correction, the quest completion on item acquisition worked!

But as it turns out, there's more here than meets the eye. First, I have no way to specify an actual quantity requirement for item acquisition. There appears to be some placeholder functionality built around this, but nothing in the quest definition itself to support it. Luckily, as it turns out, all I needed to do was add a new line to my JSON file for this "goal" and it works! So I can quickly and easily test for specific amounts of items.

Next Time

But, there's more issues still. For some reason, even though it works for all the rest of the quests up to this point, the auto-assignment of the next quest in the series isn't happening. Well, actually maybe that won't be next time. . . Seems I had a typo (an extra word) in my quest id for the follow-up quest. With that slight correction I was able to continue progressing! This is great, things are just working. I still need to add a ton of polish to what is already there, build the world too. And I need to continue the main quest line while also beginning the branch out into side quests.

Today was an amazing day, I got a lot done that will serve me in the future and it really was an easy lift in the end. I've built out so many systems now that there really isn't a ton of development work to do, it mostly boils down to worldbuilding and data. . . so much data. Quests, Items, Dialogue, NPCs, and so much more. One day at a time. Make it work, you can always make it better later.

Course, that doesn't take in account all the systems that are only partially built, like my character menu and inventory, or other planned "upgrades" like conditional talking points in the dialogue system. Those are still going to be really big lifts, but I will need to address the inventory situation soon. I have to give the player the ability to actually use items, like food. Don't need my player's starving when they shouldn't.  I'll get there though, in due time.

Leave a comment

Log in with itch.io to leave a comment.