Unclear on how each battler knows about their stats


I am a bit new to programming and game developments in general. But I spent a lot of time to dig through the codes in the finished game and never understood how the Battlers, with only the Battler.gd attached, be able to know what value of the battlerstats they should have.

In the FileSystem, i noticed that separate resources were created for each battler and assigned different value there. But I never saw you reference the resource path. In the Battler.gd script, all i see is that you duplicated a BattlerStats resource and reinitialized it(setting only health to max), but how would it know that e.g. the bear should have 42 health, 10 attack while the level 1 cat has 14 health and 8 attack?

Apologies if my question is dumb but I am really scratching my head here when trying to implement similar thing in Godot 4.1.1. 

1 love
  • Anthony SOLER(AnthonyS) replied

    Hello DDrHusky,

    I do not own the Godot 2D Secrets (yet!) but I will try to guess based on the information you gave.

    Select one of the Battlers in the node hierarchy. Then, in the inspector panel, you will probably see a "Stats" variable. The resource may have been linked directly here.

    In this case, it is the scene file (.tscn) that holds the information and that's why you do not see it in any .gd file.

    Have a good day,

    2 loves
  • D
    DrHusky replied
    That's it! Thanks Anthony!
    2 loves
  • Nathan Lovato replied

    Thanks for taking the time to help Anthony, much appreciated!

    2 loves