This is actually pretty good!
Critique:
Firstly; don't care about Anachron's negative comments, there's a lot of people like him
Secondly; you should, as a system-designer, consider the fact that your audience would like to have that onLoop method.
Thirdly; but since many users who would have used that onLoop method to something probably would have scripted their own plug-in; I think you are fine without it
Fourthly; you should be rewarded with a mountain of cookies for those comments
In your onDestroy method you do the following, among other things:
I'd suggest that you use the
However, it's nothing seriously, just a minor suggestion.
------------------------------------------------------
Another thing is the projectilegroup enumeration method.
I'm not a fan of doing several o(n) searches every second. I can understand it if your system only handles locusted units, but since your
Instead of having one major group with all projectiles in (which is what you have atm I believe), get two. One will be used to store ALL projectiles, while the other one will be used to store locusted units.
eg: ProjectilesAll, ProjectilesAloc
When you allocate the projectile instance, you check if the passed unit has locust. If it has you add it to the ProjectilesAloc group, but if it doesn't has the ability, you'll add a unit-type to it - which should be a global constant btw.
Then you could rewrite the
This is just a suggestion and I have no clue if it would improve overall performance, because it would only improve performance if you had a lot of unit-projectiles flying about.
Still, doing that o(n) search multiple times a second shouldn't be an all too big performance-hit, since many computers have more than enough computing power and because of the fact that n won't exceed 300 in most cases.
Edit: With 6 spheres (Time Slow) up simultaneously i got these values:

Worth noting that this test was run on a computer with the CPU: i7 920, OC'd to 3,2GHz from 2,66 GHz
Graphics card was an ATI Radeon HD 4890.
Critique:
Firstly; don't care about Anachron's negative comments, there's a lot of people like him
Secondly; you should, as a system-designer, consider the fact that your audience would like to have that onLoop method.
Thirdly; but since many users who would have used that onLoop method to something probably would have scripted their own plug-in; I think you are fine without it

Fourthly; you should be rewarded with a mountain of cookies for those comments

In your onDestroy method you do the following, among other things:
JASS:
....
if (.toRemove) then // If .toRemove is flagged, then remove the unit associated with
call RemoveUnit(.toUnit) // the projectile.
endif
ShowUnit(.toUnit,false)
+ KillUnit(.toUnit)
trick. Mainly because AutoIndex hooks the RemoveUnit()
function, which isn't all too efficient.However, it's nothing seriously, just a minor suggestion.
------------------------------------------------------
Another thing is the projectilegroup enumeration method.
JASS:
...
static method enumNearby takes projectilegroup g, real x, real y, real z, real radius returns nothing
local integer i=0
local real x2
local real y2
local real z2
loop
exitwhen (i==.priv_stackDex)
set x2 = .priv_stack[i].posVec.x
set y2 = .priv_stack[i].posVec.y
set z2 = .priv_stack[i].posVec.z
if ((x2-x)*(x2-x)+(y2-y)*(y2-y)+(z2-z)*(z2-z)) <= (radius*radius) then
call g.add(.priv_stack[i])
endif
set i=i+1
endloop
endmethod
projectile.create(unit u)
method requires a specified unit, I would organize it a bit differently.Instead of having one major group with all projectiles in (which is what you have atm I believe), get two. One will be used to store ALL projectiles, while the other one will be used to store locusted units.
eg: ProjectilesAll, ProjectilesAloc
When you allocate the projectile instance, you check if the passed unit has locust. If it has you add it to the ProjectilesAloc group, but if it doesn't has the ability, you'll add a unit-type to it - which should be a global constant btw.
Then you could rewrite the
enumNearby
method to only do the position-search for projectiles in the ProjectilesAloc group. But since you'd lose the non-locusted units, a normal GroupEnumUnitsInRange
would be needed with a filter that adds unit-projectiles to the projectilegroup if they have the unique unit-type.This is just a suggestion and I have no clue if it would improve overall performance, because it would only improve performance if you had a lot of unit-projectiles flying about.
Still, doing that o(n) search multiple times a second shouldn't be an all too big performance-hit, since many computers have more than enough computing power and because of the fact that n won't exceed 300 in most cases.
Edit: With 6 spheres (Time Slow) up simultaneously i got these values:
@ 900 missiles fps was: 3,4
@ 600 missiles fps was: ~10-13
@ 400 missiles fps was: 30-31
@ 300 missiles fps was: 51
so I think you'll be fine with your current o(n) method. @ 600 missiles fps was: ~10-13
@ 400 missiles fps was: 30-31
@ 300 missiles fps was: 51
Worth noting that this test was run on a computer with the CPU: i7 920, OC'd to 3,2GHz from 2,66 GHz
Graphics card was an ATI Radeon HD 4890.
Last edited: