Page 2 of 2

Re: Code efficiency with regard to computing resources

Posted: Tue Jan 26, 2010 11:33 pm
by Fledermaus

Code: Select all

native AddSpecialEffect takes string modelName, real x, real y returns effect
You need to clean up that effect though. Depending on the model, you may be able to do this

Code: Select all

call DestroyEffect(AddSpecialEffect(somemodelname, x, y))
in your case this should work:

Code: Select all

call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", GetUnitX(GetEnumUnit()), GetUnitY(GetEnumUnit())))
You should probably make a local unit to store GetEnumUnit() in (remember to null it at the end of the function) so you only have to call it once. Depending on what else you are doing, you may also want to make the x and y local reals.

Re: Code efficiency with regard to computing resources

Posted: Wed Jan 27, 2010 2:32 am
by Greenspawn
Cool. What about when creating units at a target location?

Re: Code efficiency with regard to computing resources

Posted: Wed Jan 27, 2010 3:15 am
by Rising_Dusk
The location leaks. It always leaks if you don't call RemoveLocation() on it.

Re: Code efficiency with regard to computing resources

Posted: Wed Jan 27, 2010 6:31 am
by Fledermaus
There is only 1 time you should ever use a location, when you need to use GetLocationZ. Otherwise you can always use coordinates instead.

Re: Code efficiency with regard to computing resources

Posted: Fri Jan 29, 2010 11:02 pm
by Greenspawn
Ok cool :)

CreateUnit returns a unit, but all i have to do is remove it from the game right?

Re: Code efficiency with regard to computing resources

Posted: Sat Jan 30, 2010 1:45 am
by Rising_Dusk
If a unit dies, the game naturally removes it after its decay time. (So you don't have to)

Re: Code efficiency with regard to computing resources

Posted: Sat Jan 30, 2010 1:54 am
by Greenspawn
Ok. I just stumbled across another issue: what if you need to know where a certain ability was targeted (i.e. GetSpellTargetLoc()). Is there a way to do this in X,Y without using the location?

Re: Code efficiency with regard to computing resources

Posted: Sat Jan 30, 2010 2:10 pm
by 2-P
Not sure, but I think GetSpellTargetX/Y was added in the 1.24 patch.

Re: Code efficiency with regard to computing resources

Posted: Sat Jan 30, 2010 2:59 pm
by Rising_Dusk
They were.

Re: Code efficiency with regard to computing resources

Posted: Wed Feb 24, 2010 11:12 pm
by Greenspawn
Thanks!