x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

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

etc.

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.

I rather:

1) Buy sniper ---> access "cost value" in sniper from BP ---> subtract cost from balance

instead of

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?

Product Version: UE 4.16
Tags:
more ▼

asked Jul 30 '17 at 04:05 PM in Blueprint Scripting

avatar image

SyedAman
13 4 5

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Jul 30 '17 at 09:56 PM

avatar image

ScottSpadea
9.6k 318 205 449

avatar image SyedAman Jul 31 '17 at 12:47 AM

WOW I had no idea about GetClassDefaults, this makes everything so much simpler. Using data tables is very tedious, but agreed there are some cases where separating the prices can be useful.

You're awesome buddy. People like you make the community so great :)

Regarding an RTS, you could potentially just create a 2nd class default variable for each faction no?

avatar image Mingah Sep 11 '17 at 01:16 PM

You could have a prices data table where each column specifies the faction and each row specify the item. Currently I am doing this from CSV to datatable.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question