|
|
|
|
Reply From: |
SnapCracklins |
Arrays are your friend, as are dictionaries. After you learn how to put all that data you need into these structures, it’s just how you program afterwards.
Godot Docs - Array
So it could be something like this:
var _FirebirdDictionary = {
"Max health" : 100
"Max skill points" : 20
"Element" : "Fire"
"Flying" : true
"Health Level Up" : (randi()10)+3
"Skill Level Up" : (randi()3)+2)
"Level" : 1
So that holds your data. Then you tuck that into a dictionary:
var _Bestiary = [_FirebirdDictionary, _WaterTurtleDictionary....]
And pull that for fights. If it were me, hold the base stats and then have stats for how much each stat increases per level. So compare the level data with the dictionary, and after that it’s a bunch of math. But hopefully that is good source material?
Thanks for your answer, SnapCracklins!
I tried your approach before, but found a caveat that didn’t really look solvable with arrays or dictionaries for me.
So I opted for creating classes for a base monster, that gets initialized with base values (in the _init() method from tres reference files). The reason also was that I want to define functions for attacking, getting damage, levelling up etc, right inside one specific monster instance and having the ability to change that aswell.
That did not seem possible with just base values like in dictionaries (or is there a way to save instances of custom classes in dictionaries)?
e.g. I currently save my monster party of 6 monsters in an array of Monster classes and initialize them based on the inst2dict() values in my savegame when loading the game.
That way I have differing values from the base class and can override stuff inside there.
Thats seems to be a plausible and extendable way for me, but let’s see when I see a downside of this approach as well
LucaJunge | 2022-09-12 13:56
Yeah i have seen the resource method in a lot of tutorials. For the record, you can save objects and data structures in dictionaries. But glad you got it worked out. That’s the great thing about programming - there’s always more than one way to build something.
SnapCracklins | 2022-09-12 20:16