A
A
Aleksei Podgaev2015-02-02 02:54:43
Data Structures
Aleksei Podgaev, 2015-02-02 02:54:43

How to design a character attribute model?

Actually a subject.
Suppose a character has the strength attribute. There is some basic value - the one with which he was born (or received with the next level - that's not the point). There are various modifiers - enchanted armor, elixirs, etc. Modifiers can be conditionally permanent and temporary. In addition, the same effect can change strength (can it be combined with a similar one?) - for example, the effect of "drinking" the character's strength by a mob. With each successful strike, the strength should decrease.
The question is, what is the best way to store this in memory so that we can most easily control all the effects that affect this attribute - remove some effects without affecting others, etc.
If there is an article where this is written - throw a link, please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
niello, 2015-02-02
@niello

I would store the base value and a list of the effects that affect it. In the effect, you can keep the source, expiration time, additional conditions, all sorts of scripts. The actual indicator would be obtained dynamically, by calculation. Possibly with caching. Implementation details are highly dependent on the rules of the game/role system.
These are ideas offhand. In general, the most interesting is who implements how.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question