Code efficiency with regard to computing resources

This is where all discussion of WC3 mapmaking should be held. This forum exists particularly for mapmaking needs. If you have a question on how something works or have need for some code review, this is the place to put it.
User avatar
Fledermaus
Keeper of the Keys
Posts: 354
Joined: Fri Feb 01, 2008 9:55 am
Location: New Zealand
Contact:

Re: Code efficiency with regard to computing resources

Post by Fledermaus » Tue Jan 26, 2010 11:33 pm

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.

Greenspawn
Keeper of the Keys
Posts: 434
Joined: Fri Jan 18, 2008 4:50 pm
Location: Massachusetts

Re: Code efficiency with regard to computing resources

Post by Greenspawn » Wed Jan 27, 2010 2:32 am

Cool. What about when creating units at a target location?
Math is # |e^iπ|
"I can't imagine getting hit by a giant rock and not being maimed or crippled or ruined" -Dusk

Logue: Please replace the toilet paper when you use it all. For some reason my 5 year old son believes if it's not there he does not have to wipe.

User avatar
Rising_Dusk
Chosen of the Intargweeb
Posts: 4031
Joined: Sat Dec 15, 2007 1:50 pm
Contact:

Re: Code efficiency with regard to computing resources

Post by Rising_Dusk » Wed Jan 27, 2010 3:15 am

The location leaks. It always leaks if you don't call RemoveLocation() on it.
"I'll come to Florida one day and make you look like a damn princess." ~Hep

User avatar
Fledermaus
Keeper of the Keys
Posts: 354
Joined: Fri Feb 01, 2008 9:55 am
Location: New Zealand
Contact:

Re: Code efficiency with regard to computing resources

Post by Fledermaus » Wed Jan 27, 2010 6:31 am

There is only 1 time you should ever use a location, when you need to use GetLocationZ. Otherwise you can always use coordinates instead.

Greenspawn
Keeper of the Keys
Posts: 434
Joined: Fri Jan 18, 2008 4:50 pm
Location: Massachusetts

Re: Code efficiency with regard to computing resources

Post by Greenspawn » Fri Jan 29, 2010 11:02 pm

Ok cool :)

CreateUnit returns a unit, but all i have to do is remove it from the game right?
Math is # |e^iπ|
"I can't imagine getting hit by a giant rock and not being maimed or crippled or ruined" -Dusk

Logue: Please replace the toilet paper when you use it all. For some reason my 5 year old son believes if it's not there he does not have to wipe.

User avatar
Rising_Dusk
Chosen of the Intargweeb
Posts: 4031
Joined: Sat Dec 15, 2007 1:50 pm
Contact:

Re: Code efficiency with regard to computing resources

Post by Rising_Dusk » Sat Jan 30, 2010 1:45 am

If a unit dies, the game naturally removes it after its decay time. (So you don't have to)
"I'll come to Florida one day and make you look like a damn princess." ~Hep

Greenspawn
Keeper of the Keys
Posts: 434
Joined: Fri Jan 18, 2008 4:50 pm
Location: Massachusetts

Re: Code efficiency with regard to computing resources

Post by Greenspawn » Sat Jan 30, 2010 1:54 am

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?
Math is # |e^iπ|
"I can't imagine getting hit by a giant rock and not being maimed or crippled or ruined" -Dusk

Logue: Please replace the toilet paper when you use it all. For some reason my 5 year old son believes if it's not there he does not have to wipe.

User avatar
2-P
Revenent of the Replies
Posts: 328
Joined: Wed Feb 13, 2008 11:18 am

Re: Code efficiency with regard to computing resources

Post by 2-P » Sat Jan 30, 2010 2:10 pm

Not sure, but I think GetSpellTargetX/Y was added in the 1.24 patch.
Humans don't have the patience to wait even ten minutes for something!

User avatar
Rising_Dusk
Chosen of the Intargweeb
Posts: 4031
Joined: Sat Dec 15, 2007 1:50 pm
Contact:

Re: Code efficiency with regard to computing resources

Post by Rising_Dusk » Sat Jan 30, 2010 2:59 pm

They were.
"I'll come to Florida one day and make you look like a damn princess." ~Hep

Greenspawn
Keeper of the Keys
Posts: 434
Joined: Fri Jan 18, 2008 4:50 pm
Location: Massachusetts

Re: Code efficiency with regard to computing resources

Post by Greenspawn » Wed Feb 24, 2010 11:12 pm

Thanks!
Math is # |e^iπ|
"I can't imagine getting hit by a giant rock and not being maimed or crippled or ruined" -Dusk

Logue: Please replace the toilet paper when you use it all. For some reason my 5 year old son believes if it's not there he does not have to wipe.

Post Reply

Return to “Custom Map Creation”