Alternative to data tables? Static variables, etc?
I'm currently making a RTS game, and as you can imagine, it is very data driven.
Is there a way I can add "stats" for weapons and units (like cost) in their respective BPs instead of having to use external data tables, without object reference? Variables won't work because it requires that the BP is instantiated/spawned before being used. i.e. I wish there were static variables (which can be used in compile time).
And data tables stink because you can't take advantage of inheritance. And it's just much more organized when you can access data FROM THE BP ITSELF instead of some external source.
I know in C++ you can make static variables. I could also store said data in Game Instance or GameMode. Do you guys have a best solution?
For example, lets say I want to purchase a sniper. I look at my data table:
Rifleman Cost: 250
Sniper Cost: 350
I want to subtract 350 from my current "balance" and THEN build the unit. You can't really access that "cost" data until the Sniper is already built. So I made a data table instead to make this work.
1) Buy sniper ---> access "cost value" in sniper from BP ---> subtract cost from balance
2) Buy sniper ---> get display name for sniper ---> find key in data table matching display name ---> get cost in row ---> subtract cost from balance
I guess what I can do is build the unit first and then subtract the cost. But that just seems weird to me.
How do people make "trading" "market" systems in RPG games like Skyrim for example?
you don't have to spawn an object to get its default variables, you can use a class variable, instead of a reference variable. then you can use GetClassDefaults to get its default properties.
but in some games, you may want to separate prices from the items anyway, in case you want to design some variety in the regional economy. you could have a store in a desert town that sells expensive water, but the oil is cheap, while a store in the mountains has cheap water, but expensive oil.
or maybe a store sells some items that they don't understand at all, selling them for cheap with a funny description. in Oracle of Ages, there is a city of underground people who don't know what a heart piece is, so they describe them as a "Rare Peach Stone." https://youtu.be/PZyCBtocLhA?t=53s
each store could have its own prices and item descriptions, even if they reference the same item class, so you might want to make price variables owned by the store object, and maybe multiply them by regional price modifiers, so a traveling salesman changes his prices when he enters a new region.
In an RTS, each faction could have different prices depending on what they are good at producing, and where they are located, and how much of each resource they have. or you could skip all this economy simulation, and give each item a standard price, removing any economic strategy from the game.
Follow this question
Once you sign in you will be able to subscribe for any updates here