Moderator
M
Moderator
12th Dec 2015
IcemanBo: Too long as NeedsFix. Rejected.
06:59, 23rd Jul 2012
Magtheridon96:
IcemanBo: Too long as NeedsFix. Rejected.
06:59, 23rd Jul 2012
Magtheridon96:
- Use static ifs to evaluate the constant booleans on compile time.
- You need some documentation for the spell.
- Using a tree destruction system is totally not worth it.
Check out my spell code.
I'm using a static rect. What I do first is set the rect's bounds, then store the distance
squared into a variable (because I want to pick destructables in a circle, not a square),
then I enumerate over the destructables in the rect. The isTree function I wrote is the most
efficient and compact method ever to detect a tree. (Using a hashtable along with type registry
is the fastest yet least compact methods). I'm taking advantage of how JASS "shortcircuits" boolean
expressions with this function. If the first part returns false, the next won't even run, and the
function would immediately return false. I'm checking if the distance between the destructable and
the center is less than or equal to the radius and if the destructable is tree before I kill it.
It's simple tree detection.
You can totally copy the code if you want. - The global group "TempGroup" should be camelCased. (tempGroup)
- Constant functions are the same as normal functions. Remove the 'constant' keyword and you'll save 9 bytes of file size.
(Including the space that you have to include in between constant and one of the words next to it) - Your GetTargetType function can simply return the boolean expression you have in the if block.
(return not IsUnitType(target, UNIT_TYPE_DEAD) and not ...
) - Since the caster isn't going to be moving anywhere while your function is executing, it would be better to
cache his coordinates OUTSIDE the loop so you don't have to repeat the call over and over again.
You should probably do the same for the Sin and Cos of his facing. - Cos(GetRandomReal(0, 360) * bj_DEGTORAD) is exactly the same as GetRandomReal(-1,1)
- It would be recommended to store the random generated reals so you can use the same ones
when setting the variables x and y inside the loop. (Store GetRandomReal(-1,1) and use that variable,
and do the same for GetRandomReal(0, aoe)).
It wouldn't make a very huge difference, but it just seems better. - You should probably also cache the triggering player outside the loop since he will be constant
for every iteration you make. - You have one useless local unit variable in your Actions function. (local unit du)
- It would be better if you add comments and line breaks inside your code to make things a bit
more readable.