Rada,
JASS:
/*
* We null the data in the struct.
* This is completely optional. It doesn't really make a difference
* at all. (Unless you're casting the spell some hundreds of times.)
* If you have some real memory intense systems in your map,
* you might want to do this, especially if your struct has a lot of data.
*
* These are global variables, so they will be recycled eventually.
* It's all up to you, my friend.
*/
set this.caster = null
set this.target = null
// Code.
Over here, you were supposed to null all the handles, not just the caster and the target.
A handle is anything that is not a:
- String
- Integer
- Real
- Boolean
- Code
Another thing: In vJASS, we prefer to use pure coordinates instead of locations.
Use GetUnitX/GetUnitY instead of GetUnitLoc.
Tip: Hold ctrl and click a function highlighted in red to see what it actually does. Then do that.
I see that you're using the locations only to get the angle. You don't need the locations for that because you can do this:
bj_RADTODEG * Atan2(targetY - casterY, targetX - casterX)
^This returns the angle from the caster to the target in degrees.
As for distance:
SquareRoot((targetX - casterX)*(targetX - casterX) + (targetY - casterY)*(targetY - casterY))
^This returns the distance between the caster and the target.
But, you can optimize this. In your case, since you're only using the distance for a comparison, you can omit the SquareRoot function call and instead compare the distance with 10000 instead of 100. (As if you squared both sides.)
edit
Also, I specifically stated in that tutorial that these models should not be used in public resources if you're not going to wrap all the code inside a library or a scope.
You need proper documentation, explicit requirements and proper importing instructions with a version number/name/author tag and possibly a section for credits.
Just put all your code inside a library:
JASS:
library SpellNameHere requires Requirement1, Requirement2, etc...
// All the code.
endlibrary
And on top of the library, put documentation.
Check out some of my resources for some nice documentation models
If you want something that's absolutely brilliant in terms of configuration,
check this one out.
No, this is not an excuse for me to advertise my own resources, I'm just not aware of any well-documented spells and even if I was, on such short notice, I wouldn't remember them :V
edit
Most of the variables in the struct are being initialized when they don't need to be.
Why are you initializing the special effect string for each instance? It should be a configurable constant in a globals block or a constant function. (Preferably, a globals block).
The same applies to all the other values that are up for configuration.