Sign in to follow this  

How is tagging achieved?

This topic is 1051 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

 

New to game design, I have basic knowledge of C++ and Java and am working towards making a game. I have an awesome concept (well I think so) and want to bring it into existence. Currently I'm just working on the "Systems" that the game with need and from there will get them talking to each other as I become more comfortable with them.

 

The design of the game is that of a RPG/Survival/Sandbox. As far as features I know roughly what I want to achieve and have been stumbling my way through resources until I find the gold nugget of information that allows me to progress.

 

Right now I need to be pointed towards the right direction with "Tagging". It may not be the right term... Fallout comes to mind where you pick a trait that is assigned to your character... Another example would be Dwarf fortress, If you drop wood and obsidian into lava, the wood will combust as it is tagged as flammable, the obsidian would not as it is missing the flammable tag. Actually even this post allows me to set a tag for easier searching as another example.

 

How would these interactions be achieved? I was thinking of the character object having a boolean "Insane" or "wealthy" and as it becomes relevant the code can check if it's true or false, I know that could work. I ask if there would be a better method of achieving this on a large scale or If the "tag" is unknown to begin with? I just don't know what terminology I'd need to search to find relevant information.

 

Thanks in advance.

Share this post


Link to post
Share on other sites

I ask if there would be a better method of achieving this on a large scale or If the "tag" is unknown to begin with?


This would usually be implemented with system-specific approaches. A component-based design (not necessarily just an ECS) is a great solution for some uses but certainly not all. A hard-coded bit set works for other cases. A flexible user-defined bit set of arbitrary size (with an external mapping of string names to bit indices) works well for yet other cases. No one of them is a best fit for all situations.

Player attributes like in Fallout are entirely different things than an object behavior like "ignites in lava" (which may well be different than general flammability). They are used for completely different things, used by completely different pieces of code, attached to different kinds of objects, and are reflective of different types of state.

Big general one-solution-for-everything designs are a novice mistake. Don't over abstract and over generalize.

There can be some use to generalized tagging for your content tools, but this can be implemented in all sorts of ways that don't make sense in the game itself, and there's no reason to stress about it too much. A SQL database that auto-populates with string tags generated by the tools code works perfectly well for content management purposes.

Share this post


Link to post
Share on other sites

I would probably call those things "attributes" rather than "tags".

 

 

Your idea of storing flags would work, but you're right that it may not be ideal if you want a non-trivial amount of attributes.

You probably want to look into "entity component system" or "ECS". A full ECS setup may be more than you need, but the basic idea is at least what you're after. Searching for the term should give you some decent starting points.  You might start with "Understanding Component Entity Systems" and "Implementing Component Entity Systems".


Hope that helps! smile.png

 

do you have some advanced ECS material?

my problem is when using it with complicated  games it seems to me each system has to call too many of other systems/entities and i dont get how to get around this

 

ie: a uni moving should only use movement component but lets assume it is wearing boots so should check for equip component and then there is a enemy snaring it so should check debuffs or enemies but then movement is dependant on terrain so in the end it seems to me you cant reallly make a system work with its own component only

Share this post


Link to post
Share on other sites


[...] in the end it seems to me you cant reallly make a system work with its own component only

That is true for sure. As with every concept, going into extreme is never a good idea. It was so for omnipotent scene graphs, and it is so for ECS. When looking at game mechanics, things are not isolated, and hence they cannot be simulated in isolation.

 

Remember that components were used before the invention of ECS. Composing an ECS entity by components means to practice duck-typecasting, because the entity's meaning is defined by the entirety of attached entity components. On the other hand composition by aggregation/linking, i.e. object relations in the sense of OOP textbooks, is done with a more or less strict typecasting. IMHO one should use both, together with inheritance where needed, to get the job done. That means that an ECS component may be composed by linking classic OOP components. It is a way to express relations explicitly, like in "this action has this pre-condtion and causes this list of effects on stats", instead of having all effects separate as own entity components.

Share this post


Link to post
Share on other sites


ie: a uni moving should only use movement component but lets assume it is wearing boots so should check for equip component and then there is a enemy snaring it so should check debuffs or enemies but then movement is dependant on terrain so in the end it seems to me you cant reallly make a system work with its own component only

 

FWIW, in that case, when you put on the boots, it modifies the speed data in the movement component, and when the enemy cast a snare, that also modifies the speed data in the movement component.  When the player takes off the boots, it un-modifies the speed data (basically just subtracts the speed it had added before).  At least, that's how I'd use it.

Share this post


Link to post
Share on other sites
Sign in to follow this