I don't know how i passed math classes

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

jaylawl

Active Member
Jan 29, 2017
173
31
0
This is more of a math question, rather than how to write my scripts - i hope somebody is up for the task. :emoji_slight_smile:

I'm working on a game where i'm using the EXP bar as chargebar. Goes something like this:
code_language.skript:
set {_charge} to (level progress of event-player + 1)

Then, i'm using that value in later calculations to get stuff like power, accuracy, etc.
code_language.skript:
set {_strength} to {_item_strength} * {_charge}
set {_inaccuracy} to min({_inaccuracy},( {_charge} - 1))

And all of that works fine, i'm making real good progress and it's a happy thing. :emoji_slight_smile:

However, all of these calculations are linear. Instead, i would i prefer to apply an exponential function relative to the level of the {_charge}. But i don't how that would work at all.

Let's assume for example that "{_inaccuracy} = 50 %". How would i achieve that {_inaccuracy} grows exponentially between 0% and 50%, relative to the {_charge}, which is always a number between 0 and 1? Obivously somehow using the exp() functions, but ... well

Thanks for your time!

Nevermind, i solved it by messing around long enough:
code_language.skript:
{_charge}  = sqrt(level progress of event-player)

Or let's at least say that's a step into the right direction, because that number im getting is growing too quickly! How would one go about making the growth smaller in the beginning and higher towards approaching 1?
 
Last edited:
This is more of a math question, rather than how to write my scripts - i hope somebody is up for the task. :emoji_slight_smile:

I'm working on a game where i'm using the EXP bar as chargebar. Goes something like this:
code_language.skript:
set {_charge} to (level progress of event-player + 1)

Then, i'm using that value in later calculations to get stuff like power, accuracy, etc.
code_language.skript:
set {_strength} to {_item_strength} * {_charge}
set {_inaccuracy} to min({_inaccuracy},( {_charge} - 1))

And all of that works fine, i'm making real good progress and it's a happy thing. :emoji_slight_smile:

However, all of these calculations are linear. Instead, i would i prefer to apply an exponential function relative to the level of the {_charge}. But i don't how that would work at all.

Let's assume for example that "{_inaccuracy} = 50 %". How would i achieve that {_inaccuracy} grows exponentially between 0% and 50%, relative to the {_charge}, which is always a number between 0 and 1? Obivously somehow using the exp() functions, but ... well

Thanks for your time!

Nevermind, i solved it by messing around long enough:
code_language.skript:
{_charge}  = sqrt(level progress of event-player)

Or let's at least say that's a step into the right direction, because that number im getting is growing too quickly! How would one go about making the growth smaller in the beginning and higher towards approaching 1?

code_language.skript:
{_charge}  = sqrt(level progress of event-player/2)
 
code_language.skript:
{_charge}  = sqrt(level progress of event-player/2)
Thanks for your reply. That one unfortunately wouldn't work, because it would fail to reach a full "1" on 100% charge. :emoji_frowning: The output range must be between 0 and 1
 
Status
Not open for further replies.