Godot Version
4.6 stable
Question
This might be a silly question. But I’m wondering if you can save a .tres file from a custom Resource and then… instantiate it(?) in multiple places to serve as a template for creating variations. Or something like that. Let me explain what I’m trying to do. Maybe my question isn’t even the right direction and I need to do something totally different.
I’m creating items. I have made an ItemData resource that looks like this so far:
ModifierData is another Resource. My question has to do with that. Here are the export variables it has:
Let’s just focus on target and operation. These are used for telling a Modifier (a RefCounted) what attribute to apply to and how to modify it.
When making a new ItemData, the idea is that I can export an array of ModifierData as seen above, which gets turned into an Item (RefCounted) with an array of Modifier. For example, when equipping an item, a Character can just do:
func equip(item: Item):
for mod in item.modifiers:
attributes[mod.target].apply_modifier(mod)
Now here’s where my question comes in. In ItemData above, you can see a WeaponData component. If I’m making a weapon, I’ll fill that in (it’s optional).
I want my game to have a rule: all weapons have a few predetermined modifiers. For example, they all modify attack and range when equipped.
So, one option is to just… trust myself to do that for every weapon. For every weapon, I could manually add an attack and range modifier, set their attribute targets and operations (and all the other fields) the same way every time while only varying the value field… and this game is going to basically completely revolve around items, meaning I’m hoping for a very large amount of them.
That feels like a lot of unnecessary work and easy to mess up. Or is that just how it goes? Can I give myself a template inside WeaponData using some premade ModifierData somehow, or could I force it to be correct programmatically in a totally different way? Or if you’ve ever done something like this, what did you do? Maybe I just need to rethink everything here.



