Quote:
Originally Posted by littlechris95
What is the difference in the calculations, a Melee attack for a ranged attack? I have this doubt ... use the same calculations as used in Melee attacks to Ranged attacks.
|
The damage algorithm shouldn't be the problem, unless you have some ungodly calculation.
Im willing to bet the problem is in your kill method.
What you should do is test scatter where it doesn't kill a mob, and test where it does kill the mobs.
If the lag spikes only when you kill a mob, then the problem is inside your kill functions.
If it spikes regardless, then the problem is somewhere in the attack section.
Or it could be in both and you have double the problems.
One way to narrow it down would be to add some timing mechanism in several locations recording the time it takes to perform that function.
Stopwatches would likely work for this as you don't need nano seconds.
Place a bunch of stop watches and time different methods and output it the console or to your character.
See where the time is rather large, my guess is you will have 100+ ms intervals.
If your code is efficient, the entire process should be 0ms, or darn close depending on server load.