storing multiple values 1 skill

Posted By: Reconnoiter

storing multiple values 1 skill - 10/19/15 19:30

Hi again,

What would be the best way to store as many values with up to 2 digits (e.g. 3 or 22 or 99) in a skill?

I thought something on the line of 4 values per skill by using integer/fraction and multiplying/dividing. I managed to get 4 numbers out of one skill, but the problem is losing precision when saving into the skills (e.g. values get lower etc. with each save/restore).

Here is the general idea (/divided in 4 parts):
112233,44

But its currently faulty cause of precision loss.
Posted By: Wjbender

Re: storing multiple values 1 skill - 10/19/15 19:59

you could fit them into a string like "23,24,66,22,55,67"
then typecast into the skill something like skill1=(char*)this_string or skill1=(string*)this string ..

or put them in an array and cast it into the skill.

or put them in a struct - pointer and cast them in to the skill.
Posted By: slacer

Re: storing multiple values 1 skill - 10/19/15 20:01

Hi,

what is the problem you want to solve?
You want to store many values per entity - but why?
Posted By: Dico

Re: storing multiple values 1 skill - 10/19/15 20:10

Originally Posted By: Wjbender
you could fit them into a string like "23,24,66,22,55,67"
then typecast into the skill something like skill1=(char*)this_string or skill1=(string*)this string ..

or put them in an array and cast it into the skill.

or put them in a struct - pointer and cast them in to the skill.


well , i think its good answer laugh
Posted By: Reconnoiter

Re: storing multiple values 1 skill - 10/20/15 10:43

Thanks for your replies:

Originally Posted By: Wjbender
you could fit them into a string like "23,24,66,22,55,67"
then typecast into the skill something like skill1=(char*)this_string or skill1=(string*)this string ..

or put them in an array and cast it into the skill.

or put them in a struct - pointer and cast them in to the skill.
, I forgot to mention it needs to be able to saved in a wmb file too.

Anyway I think I have a reliable system up running now. I dropped the fraction so it now looks like this: 112233.
And to keep precision: before saving values into the skill, I do ...skill = 0.05. This seems to negate precision loss.
Also I reduced the range from 1-99 to 1-89 cause otherwise when a number reached 99 the previous number jumped up by 1 point (and for me 1-89 is still far enough options).
© 2024 lite-C Forums