Some things end up doing a lot in games, but just from your screen shot I think you could break out stats into their own class, like StatBlock
You don't even need it to be generic, just throw all the stats you care about in there. And you can even have StatBlock handle the buffs too.
Any behavior driving the NPC could be separated too. Not actions like "jump" or "walk", but the code that makes them decide what to do. Often times I'll make game objects with some sort of control generic. You call functions on them to tell them to do their simple actions. Then I can have a class that drives that with input (for the player) or an AI class that makes decisions and uses the same interface as the input class does to control the object. Doing it this way would let you plug in different AI into the NPC too if you wanted.
#Is there a "Smarter" way to approach having a lot of Variables other than PirateSoftwaring it at top
1 messages · Page 1 of 1 (latest)
You could use something like npc_stats.gd
class_name NpcStats
@export var npc_name: String = "Bob"
@export var max_life: float = 100.0
and then in your npc_base you could do
@export var stats: NpcStats
For other variables you can strongly type and create a class?
I'll keep that Idea of StatBlock thank you. I've tried to keep the behavior out of the NPC's. I assign them tasks, and the Tasks Manager's check the NPC's info. Max I keep in the NPC is the place it want to go. My brother taught me about Object-Oriented Programming for his work and I try to learn more about it