Freyr Posted October 18, 2015 Group: Members Topic Count: 10 Topics Per Day: 0.00 Content Count: 38 Reputation: 7 Joined: 01/11/13 Last Seen: March 5, 2021 Share Posted October 18, 2015 (edited) How do I make an NPC to calculate a logarithm? for example: set @tax,log10(Zeny) * 10; Edited October 18, 2015 by Freyr Quote Link to comment Share on other sites More sharing options...
Haziel Posted October 18, 2015 Group: Content Moderator Topic Count: 22 Topics Per Day: 0.00 Content Count: 639 Reputation: 609 Joined: 11/25/11 Last Seen: March 7 Share Posted October 18, 2015 (edited) If I recall correctly, a logarithm is the calculation about which exponent a base must be raised to reach a value.If I also recall correctly, there is not a in-built function which calculates that, so, you need a Custom Function.I made this one: prontera,150,150,3 script Test#log 420,{ mes "" + callfunc("Logarithim",10,10000) + ""; close; } function script Logarithim { set @basis, getarg(0); set @value, getarg(1); set @m, @basis; for (set @n, 2; @m < @value; set @n, @n + 1){ for (set @o, 1; @o < @n; set @o, @o + 1){ set @m, @m * @basis; } if (@m == @value) return @n; else if (@m > @value) return (@n - 1); else set @m, @basis; } return 0; } It's just a scratch and I don't know if it works perfectly.By the way, you can enter an basis and a target value, it will returns either the correct Logarithim or the closest one. Edited October 18, 2015 by Haziel Quote Link to comment Share on other sites More sharing options...
Ninja Posted October 18, 2015 Group: Members Topic Count: 54 Topics Per Day: 0.01 Content Count: 513 Reputation: 84 Joined: 08/11/12 Last Seen: July 4, 2024 Share Posted October 18, 2015 (edited) set @tax,log10(Zeny) * 10; Function script logarthm { Set .@base, getarg(0); Set .@targetnum, getarg(1); Set .@x1, 1; For(set .@x,0:.@x<=.@targetnum;set .@x, .@x +1) { Set .@x1, .@x1 * .@base; } Return .@x*10; } Usage: set @tax, callfunc("logarthm",basenum,targetnum);Sample simulation: Log2(8).@x 0 1 2 3.@x1 1 2 4 8Returns 3Check:2 ^ 3 = 8You can do it this way since, in my knowledge, everything ingame works with an integer. Edited October 19, 2015 by jezznar Quote Link to comment Share on other sites More sharing options...
Question
Freyr
How do I make an NPC to calculate a logarithm?
for example:
set @tax,log10(Zeny) * 10;
Edited by FreyrLink to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.