![]() |
[share] small tool to change AI constants
hey all!
everybody knows, that NC uses some "source code" to compile ai.obj and not a secret, that they use some variables (multipliers) to tune it before production release. in compilied ai it's looks like: myself.AddTimerEx(1001, 10 * 60 * 1000); or if (myself.sm.hp < myself.sm.max_hp * 2.000000 / 4.000000) { } The result of 10*60*1000 is always same. And result of 2/4 is always same. So, why we need to do this calculations every time handler called? Here is some tool to check your AI for things like that: http://dev.blacksun.com.ua/download/bsaic.exe In my AI, I found more than 9k of this "things to optimize". This is alpha version of tool, so check your AI before sending to production. Source file must be saved in ascii. Sorry for "bad english" :) |
>myself.AddTimerEx(1001, 10 * 60 * 1000);
I have feeling that those 10, 60 are smething not just constans but decompiler decompiled them as constants or my feeling wrong? |
Quote:
|
Quote:
|
Quote:
push_const 10 push_const 60 mul push_const 1000 mul and we can do just push_const 60000 the result will be same |
Will it give any noticeble permformance change? Its not like those calculations takes for ever :P
|
Well i tryied on my server, everything works fine, the changes have the same effect, maybe some small performance in calculation improve. (free de ALU from calculating some useless mul, add and sub operations)
|
Quote:
|
Quote:
|
In noticed those things too, I was like 'why?'. Never took the liberty to change them all. Good thing you did it :)
|
[quote=zcold;87882]hey all!
myself.AddTimerEx(1001, 10 * 60 * 1000); If you are still curious… Try to measure how much “processor time” it will cost to execute push_const one million times and to execute “9 thousands of add/sub/mul/div” one million times… divide the difference by one million back and post results here =)2nd thing… for example, usually, I edit ai.obj file directly and when I’m finished to create of to fix something, I decompile full version of a file… or when I modified the decompiler, I also need to re-decompile full version of ai.obj. In some time I try to see some_class.txt and see thee optimized version AddTimerEx(1001, 7800000) or not optimizer AddTimerEx(1001, 130 * 60 * 1000). How much time will it take for a human to de-calculate 7800000 into 130 seconds.. and I’ll be forced to by myself to do it each time I read any of 3k+ file of classes.I preferred to optimize my work and leave for server CPU “more work”…p.s. don’t beat me, it’s only my point of view by now) |
you can do both, use a source version with 10 * 60 * 1000 which is very easy to understand the time and the optimized version in the compiled one. anyway doing 10 * 10 a millon times doesn't affect the performance. remember the cpu is most of the time at 4% usage
|
| All times are GMT. The time now is 21:47. |