Skip to main content
This topic has been closed for replies.
Correct answer Nesa Nurani

I was trying to separate fractions because if i use / it works even worse.


Use this:

var x = Number(this.getField("Rating").value);
var x2 = Math.pow(x, 2);
var al = Number(this.getField("AreaLevel").value);
var al2 = Math.pow(al, 2);
var hf = (.1*x)+(.001*x2);
var lf = 10+(.5*al)+(.05*al2);
var f = (hf/lf)+1;
var f1 = (1/f);
event.value = (1-f1)*.8;

 

EDIT: if you want it  to be more precise use this:

var x = Number(this.getField("Rating").value);
var x2 = Math.pow(x, 2);
var al = Number(this.getField("AreaLevel").value);
var al2 = Math.pow(al, 2);
var hf = (.1*x)+(.001*x2);
var lf = 10+(.5*al)+(.05*al2);
var f = (hf/lf)+1;
var f1 = (1/f);
if(al<15){
event.value = (1-f1)*.797;
}else if(al<27){
event.value = (1-f1)*.787;
}else if(al<34){
event.value = (1-f1)*.775;
}else if(al<43){
event.value = (1-f1)*.767;
}else if(al<48){
event.value = (1-f1)*.758;
}else if(al<60){
event.value = (1-f1)*.749;
}

 

2 replies

try67
Community Expert
Community Expert
August 13, 2020

There's nothing special about this formula. The only operator that's a bit different is the square ("power of two") one, which can be done in JS using the pow (power) function of the Math object, like this:

Math.pow(x,y)

With y being 2 in this case.

The rest is just normal math operators ( + - / * ), and possibly parentheses.

MarietaaAuthor
Known Participant
August 24, 2020

Hi, guys I still need help with this one, I was trying to figure it out but I'm stuck how to get this into code.
field1 is dodge rating and field2 is area level
and in field3 should be calculated percentage.
I'v gathered some info on the net so hopefully some1 can help me pls.
this is info i got so far:
calculator: https://www.desmos.com/calculator/b7s5aqep3b
original info: https://lastepoch.gamepedia.com/Dodge
and here are some examples:

Thanks in advance 🙂

MarietaaAuthor
Known Participant
August 24, 2020

That's part of an external JS library. If you install it then you could use that command, but there's really no need to just for this one function. You can divide by using the "/" operator.


Thank you guys for help,I sort of got it to work in example: rating 527 and area level 5 i get 75% instead of 77%, also as area level get higher value  percentage should be lower and mine is getting higher. any advice?

var x = Number(this.getField("Rating").value);
var x2 = Math.pow(x, 2);
var al = Number(this.getField("AreaLevel").value);
var al2 = Math.pow(al, 2);
var lf = (.1*x+.001*x2,10+0.5*al+0.05*al2)+1;
event.value = .8-(.8/lf);

Bernd Alheit
Community Expert
Community Expert
August 13, 2020

Yes it is possible with the Math functions.

https://www.w3schools.com/js/js_math.asp