So i feel like i'm clone to understsnding some concepts, but falling short after some progress.. so to explain where I am stuck, here is what I want to achieve: i'm working on a small prove of concept project of a Manager style game. I want a party of characters, each with some basic stats and different skills based on their profession (classic warrior/mage/rogue.. basic stuff)
everything is numbers, strings and ways to manipulate those numbers (an attack for example would be damage = strength * 2 for example..)
where I am now:
I have a resource "Entity" with the basic stats, then I create the professions from them (warrior more strength, rogue more dex, etc.). I can create new partymembers, no problem.
now I want to add the skills to assign to these resources.. here is where I get stuck every time.. I just cannot grasp how i would combine the individual base resources with a script containing the functions to manipulate stats and calculate the damage for the skills..
could somebody try and walk me through the steps to accomplish what i'm trying to do or point me to a specific tutorial? the documentation often confuse me quite a bit, because they often deal with 2Dbodies or other stuff I don't need right now...
if you need me to clarify stuff, I will try..
#using resources for character creation/composition without graphics
14 messages · Page 1 of 1 (latest)
I just want to make sure I understand your question and gauge your skill level before I answer.
Are you familiar with inheritance? Do you know how to reference one Resource in another Resource?
sure! So if I understand the concept correctly I can can inherit from another resource if I use the extends keyword at the top.. so if I want to inherit from the Entity resource I use "extends Entity" for my new resource.. not totally sure though..
but I might confuse something, I think that only works if I give it a class_name to be able to inherit from? (e.g. class_name Entity)
That's right, you need to give your basic entity a class_name. Then your Rogue/Fighter/Mage/etc can extend from that script. That's the inheritance based method.
The component based method is to create a Rogue/Fighter/etc, and have a variable called stats that reference a resource containing hp/str/dex/etc.
I recommend going with the first one if you're just starting out
right, I think I got that and using inheritance to start out seems fine, as I can understand that concept quite well (I guess)
So if I would want to add skills, do I put the functions in the inherited Rogue resource?
Exactly. You can keep functions that all classes share in your Entity class, such as attack, take_damage, rest, etc. And then specialized functions in the subclasses, like sneak_attack for rogues, use_magic for wizards. Also, any functions in the Entity class can be overridden in a subclass. Because maybe your Warewolf character attacks differently than the rest of your characters (look into polymorphism).
And just for interest sake, if in the future you're wondering, "how do I get my Rogue to use magic the way my Wizard does?" the answer is by going component based (the second option I gave you). But don't worry about that for now.
thank you, that was helpful! I'll try it out and maybe come back with followup questions if you don't mind
Of course ✌️
ok, maybe a even more fundamental question. Given that i want my characters "just" to be data containers, without a physical representation in the game, besides the numbers. does the "basic" entity inherit from resource or node?
followup question. if i have a variable called health in the base class and i want to declare "health" again in the inheriting class, it says the variable is used by the parent class entity, but it does not suggest to auto-fill when i type heal (for example).. how do i access the parent's variables?...
answering my second question, it appears, that the auto-fill functionality is active in a function body..
Resources are primarily for holding data, but they're restrictive when providing behavior. In your case, you may not run into these restrictions in a management style game. The restrictions come from Resources not being in the scene tree, which means you can't attach nodes such as raycasts or timers to them. They don't have _ready or _process functions so if you want them to update you have to do it manually. I personally favor Nodes, but others here can give you strong arguments for using Resources. You can try using Resources if you like, and if you find them restricting, switch to Nodes
Make sure you don't redeclare health (var health) in the sub class. It's already there, so all you have to do is set it (health = 10)
Also, auto complete should work with parent functions/variables, but it will only work with outside functions if Godot knows the type.
Type your variables by saying var my_rogue: Rogue
thank you so much! we´ll see, if i get the resources to work... if not, be prepared for some noob-questions about custom nodes 😉