Effects: Underwhelming
Getting Started
It was a rough day at work today. I had to scrap a good hour's worth of work because of someone else's mistake. That was after fighting with performance issues due to their bloated Excel spreadsheet (I don't know how she was able to get it up to nearly 70MB in size). Then, there wasn't enough information to finish the second task for this same person. So it's left me feeling a little deflated.
Even with that said, I'm still here pushing ahead with Xenodochium! The first thing I need to do is add these new effects. I think I may be lucky enough that I can just copy an existing effect and kinda "smudge" it a little bit. See, I've already got my "Well Fed" buff, which adds health every in-game minute. I could just copy that with some modifications to make the instant health effect. Though, I'm not sure that's the best approach. If I were to do that, it could cause player frustration by forcing them to wait up to a whole second before the health is added.
Nah, instead I'll just make this new thing happen. Of course, doing this means I'll have to change the way my effects work. Right now I don't have any "instant" effects. Everything is time based. So, I'll need to figure out a way to assign an instant effect. Luckily, I already have "duration" on my effects. There's currently two different sets of effects, those with a positive duration and those with a negative duration. So, now I can just add ones with zero duration and trigger instant effects on that!
So, the first thing I need to do is build out three new effects in my JSON file, each with a duration of zero. I took my "well fed" effect and duplicated it three times, modifying each instance to account for one of my new effects, effect_restore_health_flat_10, effect_restore_energy_flat_10, & effect_restore_satiety_flat_10. Of course, this means more data in my localization files! The next step is figuring out exactly how I want to define the actual effect. My first thought was to directly define the function call in the data, using an expression to accomplish my goal.
But, that's probably a bad idea. If I do it that way, a simple typo may cause crashes, or a refactor will require updating data instead of just code. So, instead I'm sticking with a very clear assignment, which will then be read and affected by my playerstats manager. After updating the effects and my localization data, I did a quick test to make sure I didn't break anything.
Applying Effects
This next part is a bit tricky. At the moment my playerstats manager has a function to apply effects, but all it does is add them to a pool of active effects which are then "processed" during signals from my time manager. These new instant effects don't really fit into that execution method, so I had to rebuild the function slightly. At the beginning of the function, I now do a check for a zero duration, and if so I execute a new block of code and then return. This prevents the rest of the function from firing, and doesn't force me to make a bunch of extraneous indents.
Then, I created a whole new function to actually deal with these effects. This means minimal changes to an existing, working function. Of course, this is all still a work in progress, my "consume" function doesn't actually fire the "apply effect" function. Let's see, how do I do that? Oh no, this is bad. I just realized that my playerstats manager is loading it's own JSON file instead of processing it through my data manager!
Next Time
This is getting out of hand, and I'm definitely not in the mood to completely refactor my playerstats manager and data manager today. So, as a note for tomorrow, here's what needs to happen. I need to move my effect definition loading out of the playerstats manager and into the data manager. This means not only adding the JSON loading, but also a new function to get the EffectDefinition based on the effect_id. Then I need to update all the effect related stuff in my playerstats manager to use the data manager.
Once that is done, I can jump back into the playerstats manager to finish my consume_item function, along with the _process_instant_effect function. The worst part is, I'm pretty sure I won't feel like doing that tomorrow because I still have to continue the work I was doing at my day job! Oh well, at least I've done something today, even if it isn't nearly as much as I was hoping.
And, when I do actually get to work on refactoring the playerstats manager in conjunction with the data manager, I'll need to spin up a whole new chat with Gemini to work through it. The one I've been using for most of this work has way too much information that will probably cause issues in the refactor. Of course, there are other things related to this that I can still work on that aren't a refactor, like the quick action buttons themselves still don't do anything, and they don't update based on item assignments.
Xenodochium
The future is what you make of it!
| Status | In development |
| Author | Munchmo |
| Genre | Role Playing |
| Tags | 2D, Cozy, Godot, Indie, Life Simulation, Pixel Art, Sci-fi, Singleplayer |
| Languages | English |
More posts
- Quick Action Buttons: Displaying13 hours ago
- Consumables and Controller Safety1 day ago
- Quick Actions: Preparations2 days ago
- Quick Actions: Assigned!3 days ago
- Road Trip!4 days ago
- Playerstats: Refactored!5 days ago
- Data Manager: Effects and Thresholds6 days ago
- Inventory Manager: Quick Actions10 days ago
- Inventory: Updates11 days ago
Leave a comment
Log in with itch.io to leave a comment.