# Using qarp to calculate RPG stat curves

0 favourites
• 6 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
• I am terrible with advanced math, and while I can mostly get by, I would appreciate some help with understanding how to use qarp to calculate stat curves in an action RPG.

The scenario is that I have spells that need to exist for a certain duration dependent on the players Wisdom. Currently I just spawn the spell, then start a timer for it based on the casters Wisdom stat. Currently this looks like "Set timer to: Player.Wisdom*0.05 Seconds".

This is not great game design as it means spells stick on the screen for minutes at a time if you cast with a high wisdom stat, so I want to implement a curve to this so that the higher your Wisdom stat is, the less of an effect it has on the timer. The stat range is anywhere from 1 to 9999.

So I believe that would start looking like:

qarp(1, 9999, c, Player.Wisdom)

And I think that the "c" value is the rate of the curve, but I don't quite understand that part, or what the value should look like there, is it a decimal value as well or something else? And if anyone can explain this in a way that makes sense to me it would be appreciated. Thank you!

#### Tagged:

• I would be tempted to just calculate the percentage of the player's stat against the max for that stat and multiply that by the max duration.

so, set Timer to: Player.Wisdom / MaxWisdom * MaxDuration

if MaxDuration is 30 seconds, MaxWisdom is 9999, and Player.Wisdom is 500 then Timer = 1.5 seconds

Player.Wisdom = 2000, then Timer = 6 seconds

Player.Wisdom = 5000, then Timer = 15 seconds...

that is very linear, if you want a curve with diminishing returns then you need some kind of an inverse exponential function, such as duration = 1/(x^2). (and mess with the exponent to adjust the steepness of the curve.

• If you want to use qarp, I believe the correct expression will be this:

qarp(min_time, max_time, max_time, Player.Wisdom/9999)

• that makes a nice curve...

I made a quick test to see what a graph of it would look like:

https://www.rieperts.com/games/forum/QarpGraph.c3p

• There is also cubic() for even curvier curve.

Here is a nice demo:

construct.net/en/forum/construct-2/general-discussion-17/new-interpolations-79318

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Thanks guys! I haven't had a chance to try implementing this but I should have enough advice to go off of now.

• 6 posts