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.

Re: Code efficiency with regard to computing resources

Postby Fledermaus on Tue Jan 26, 2010 10: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.
Image
==================================================================================
Image Image Image Image Image Image
User avatar
Fledermaus
Wielder of the Ctrl-Alt-Delete
 
Posts: 238
Joined: Fri Feb 01, 2008 8:55 am
Location: New Zealand

Re: Code efficiency with regard to computing resources

Postby Greenspawn on Wed Jan 27, 2010 1: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
Greenspawn
Keeper of the Keys
 
Posts: 430
Joined: Fri Jan 18, 2008 3:50 pm
Location: Massachusetts

Re: Code efficiency with regard to computing resources

Postby Rising_Dusk on Wed Jan 27, 2010 2:15 am

The location leaks. It always leaks if you don't call RemoveLocation() on it.
Image Image Image
Ingram
"I'll come to Florida one day and make you look like a damn princess." ~Hep
(®Î§Îπg_¶)µ§Ï<)
User avatar
Rising_Dusk
Chosen of the Intargweeb
 
Posts: 3926
Joined: Sat Dec 15, 2007 12:50 pm

Re: Code efficiency with regard to computing resources

Postby Fledermaus on Wed Jan 27, 2010 5: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.
Image
==================================================================================
Image Image Image Image Image Image
User avatar
Fledermaus
Wielder of the Ctrl-Alt-Delete
 
Posts: 238
Joined: Fri Feb 01, 2008 8:55 am
Location: New Zealand

Re: Code efficiency with regard to computing resources

Postby Greenspawn on Fri Jan 29, 2010 10: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
Greenspawn
Keeper of the Keys
 
Posts: 430
Joined: Fri Jan 18, 2008 3:50 pm
Location: Massachusetts

Re: Code efficiency with regard to computing resources

Postby Rising_Dusk on Sat Jan 30, 2010 12:45 am

If a unit dies, the game naturally removes it after its decay time. (So you don't have to)
Image Image Image
Ingram
"I'll come to Florida one day and make you look like a damn princess." ~Hep
(®Î§Îπg_¶)µ§Ï<)
User avatar
Rising_Dusk
Chosen of the Intargweeb
 
Posts: 3926
Joined: Sat Dec 15, 2007 12:50 pm

Re: Code efficiency with regard to computing resources

Postby Greenspawn on Sat Jan 30, 2010 12: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
Greenspawn
Keeper of the Keys
 
Posts: 430
Joined: Fri Jan 18, 2008 3:50 pm
Location: Massachusetts

Re: Code efficiency with regard to computing resources

Postby 2-P on Sat Jan 30, 2010 1: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
2-P
Revenent of the Replies
 
Posts: 287
Joined: Wed Feb 13, 2008 10:18 am

Re: Code efficiency with regard to computing resources

Postby Rising_Dusk on Sat Jan 30, 2010 1:59 pm

They were.
Image Image Image
Ingram
"I'll come to Florida one day and make you look like a damn princess." ~Hep
(®Î§Îπg_¶)µ§Ï<)
User avatar
Rising_Dusk
Chosen of the Intargweeb
 
Posts: 3926
Joined: Sat Dec 15, 2007 12:50 pm

Re: Code efficiency with regard to computing resources

Postby Greenspawn on Wed Feb 24, 2010 10: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.
User avatar
Greenspawn
Keeper of the Keys
 
Posts: 430
Joined: Fri Jan 18, 2008 3:50 pm
Location: Massachusetts

Previous

Return to Custom Map Creation

Who is online

Users browsing this forum: No registered users and 1 guest