• 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.

Fixing lag on maps

Status
Not open for further replies.
Level 22
Joined
May 11, 2004
Messages
2,863
Well, I guess it's my turn to ask a question. Time and time again I see mappers resbmitting new verions of their maps claiming that they fixed lag. I'm wondering how they do it. In one paricular map I have, at any given time there are hundreds of units on the map constantly battling, and there is very little lag. But later in the game when many of the unit-producing structures are destroyed, less units and AI commands on the map and fewer triggers running, the map begins to lag pretty badly. That makes no sense to me. Is there a way I can fix this lag?
-VGsatomi
 

c3o

c3o

Level 2
Joined
Feb 17, 2004
Messages
21
This is couse all points refered to by trigger, all special effects, all groups, all triggers etc are like units. A unit don't disappear into the void if you don't remove it. So you have to do this manually after each use if them. You can do this by doing the follwing. It doesn't cover everything that needs to get destroyed. But the mayor factors. If you have already done this the lag is just lag.

Point - After every (yes every) use of a point (Create unit at location, special effect at location, Order move to location) do the following:
(Note, this does not apply to variable points which are used many times in diffrent triggers etc.)
set [A global point variable of your choice, in this case TempPoint]TempPoint = [Your point]
[Do all actions refering to this point, take note that no wait actions can be used.]
Custom Script: call RemoveLocation( udg_TempPoint ) [This is Jass and basicly removes the point after it has been used. The udg_ prefix is couse all global variables (made by clicking ctrl+b) has this infront of the name. Uppercase and lowercase letters are very important. Don't change them! :p]

Trigger - After use of any trigger which only will run once, use:
Custom Script: call DestroyTrigger( GetTriggeringTrigger())
This will destroy the trigger, and thus it will not take up worthfull memory after it has launched. Triggers don't leak much. But you can still do this.

Groups - Before any use of "Unit Group - Pick Every units in group" (Note, this does not apply to variable groups.) paste the following line:
Custom Script: set bj_WantDestroyGroup=true
This will destroy the groups after it has been the following group function has been exectued.

Special Effect - After you have created any special effect do the following. set [Your Variable] = Last Created Special Effect. Then do Special effect - Destroy [Your Variable]. But, since special effect destroyed immideatly usally don't play their birth/stand/death or whatever animations. You need to put a Wait (0.00) seconds after this. But sadly enough another trigger might set the variable to another value, leaving the special effect undestroyed. There is nothing to do about this except to create a massive array or something. Or use Jass which is alot better at cleaning up stuff.
 
Level 22
Joined
May 11, 2004
Messages
2,863
Here's an example of what I got:

Event:
A unit dies
Action:
Set TempPoint=position of triggering unit
Special effect- Create special effect as position of triggering unit using (effect)
Custom script: call RemoveLocation(udg_TempPoint)

I'm a little confused...don't know if I set the variable before or after the use of the point, in this case the creation of the effect on the unit
-and another-

Action
Set TempPoint=center of (regionY)
unit- create unit at center of (regionY)
Custom script: call RemoveLocation(udg_TempPoint)
Unit- order last created unit to (action)

are these good? Does it matter if the variable is array or not?

And with the unit groups, would it look like this?

Action:
Unit- create (unit-type1) at center of (regionX)
Unit- create (unit-type2) at center of (regionX)
Custom script: set bj_WantDestroyGroup=true
Unit Group- Pick every unit in (regionX) and order picked unit to (action)

Another problem: I get errors on my triggers that have custom scripts that start with "set" instead of "call" when I try to save my map in the map editor. What am I missing?
 
Status
Not open for further replies.
Top