[ad_1]
Game Development Stack Exchange is a query and reply web site for skilled and impartial sport builders. It solely takes a minute to enroll.
Anybody can ask a query
Anybody can reply
The finest solutions are voted up and rise to the highest
Asked
Viewed
15 instances
I’m engaged on an astroid mining sport the place there’s the participant managed ship that may break up astroids into smaller ore chunks to then acquire and produce again to a base station for processing. I’d wish to have a % composition for these astroids that gives a weighted loot drop desk for what ores every astroid drops when break up by the participant. In addition to this, I’d like to have the ability to shift the weights of the drops within the desk primarily based on the gap the participant is from the bottom station. For instance:
Near to Base Station
IRON - 0.80
SILVER - 0.15
GOLD - 0.05
Far from Base Station
IRON - 0.50
SILVER = 0.30
GOLD - 0.20
It’d be easy to create a number of drop tables with these values preset, nevertheless I’d wish to interpolate the values and alter them relative to the gap the participant is from the bottom station. What could be strategy to reaching this conduct?
andrewwx10 is a brand new contributor to this web site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
Sounds like you are able to do precisely what you mentioned: dynamically make a brand new desk by interpolating between the min & max tables.
Example:
double[] close toTable = new double[] { 0.80, 0.15, 0.05 };
double[] farTable = new double[] { 0.50, 0.30, 0.20 };
double minDist = 10;
double maxDist = 110;
double currDist = 60;
if (currDist < minDist)
currDist = minDist;
if (currDist > maxDist)
currDist = maxDist;
double share = (currDist - minDist) / (maxDist - minDist);
double[] desk = new double[nearTable.Length];
for (int a = 0; a < desk.Length; a++)
desk[a] = close toTable[a] + (farTable[a] - close toTable[a]) * share;
$endgroup$
2
You should log in to reply this query.
Not the reply you are searching for? Browse different questions tagged .
default
[ad_2]