• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Basic optimization

Level 5
Joined
Nov 17, 2005
Messages
165
As most of you experienced mappers out there already know, learning how to use JASS is probably the easiest way to optimize your map scripts and to reduce lagg. It's not too hard to learn the very basics, but it probably takes several years to really master. Therefore, I started this thread, where all of you can post some basic tips when it comes to lagg prevention and map script optimization. I'll start.

The first thing I learned was that temporary positions, for instance, are saved in the game memory unless you tell it not to. Let me show you an example. You may want to do this:
  • Item - Create MyItem at Position of (Triggering unit)
As you might have noticed, Position of (Triggering unit) is a temporary position, since the unit most likely will move douring the game. And to make things easy for us, let's say that we don't need Position of (Last created item) later on. Now let's have a look at this:
  • Set MyTempPoint = (Position of (Triggering unit))
  • Item - Create MyItem at MyTempPoint
  • Custom script: call RemoveLocation( udg_MyTempPoint )
Now, the temporary position of the triggering unit is stored in a variable, the variable is used to create the item and then, the variable is "reset" and the position is no longer kept in the game memory. The same method can be applied to unit- and player-groups and other handles, but with a different custom script function.

A second thing has to do with special effects. Instead of using:
  • Special Effect - Create a special effect at MyTempPoint using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
  • Special Effect - Destroy (Last created special effect)
...you can use...
  • Custom script: call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", udg_MyTempPoint))
That's it for this time. Enjoy!
 
Last edited:
Level 7
Joined
Nov 12, 2005
Messages
299
just for the record...
call DestroyEffectBJ( AddSpecialEffectLocBJ( MyTempPoint, "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" ) )
could (and should) be
call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", MyTempPoint))
reason? the functions that end with BJ are slower versions of original engine functions that are initially supposed to give you more options. for example AddSpecialEffectLocBJ leaves a "last created special effect" for you to use later while AddSpecialEffectLoc doesn't. however you don't need it in this case so you can slightly improve your map's performance by removing the "BJ" and modifying the parameters (BJs usually have different parameters than normal functions).
 
Level 6
Joined
May 19, 2004
Messages
267
Custom script: call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", MyTempPoint))

should be

Custom script: call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", udg_MyTempPoint))

>>_udg<<
 
Top