HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Weird Lag Problem when Replacing Unit

06-18-2008, 11:49 PM#1
deathdrivex
In the older and more messy version of my map, the character creation system had exactly no lag. After remaking everything so it uses less triggers and is more efficient and testing the thing itself in the game, it starts to produce a large amount of lag ONLY when it replaces the unit. Not sure why its doing this, and I just fixed 90% of all memory leaks in my current triggers too. (All leaks except player group ones which I cant fix)

Heres what I have now (Its GUI, deal with it):

Making Menus at near start of game:
Trigger:
Initialize Menus
Collapse Events
Time - Elapsed game time is 0.50 seconds
Conditions
Collapse Actions
Dialog - Change the title of ADProfession to Would you like to c...
Dialog - Create a dialog button for ADProfession labelled Yes
Set ADP1 = (Last created dialog Button)
Dialog - Create a dialog button for ADProfession labelled No
Set ADP2 = (Last created dialog Button)

This is simply moving unit near the event area:
Trigger:
Meeting the Melee Master
Collapse Events
Unit - A unit comes within 250.00 of Melee Combat Master 0034 <gen>
Collapse Conditions
((Unit-type of (Entering unit)) Equal to Apprentice) or ((Unit-type of (Entering unit)) Equal to Apprentice)
(Entering unit) Equal to Apprentice[(Player number of (Owner of (Entering unit)))]
Collapse Actions
Cinematic - Send transmission to (Player group((Owner of (Entering unit)))) from Melee Combat Master 0034 <gen> named Captain Killicks: Play No sound and display You seem to be look.... Modify duration: Set to 5.00 seconds and Wait
Dialog - Show ADProfession for (Owner of (Entering unit))

The actual replacing of unit:
Trigger:
AD Melee
Collapse Events
Dialog - A dialog button is clicked for ADProfession
Conditions
Collapse Actions
Set Temp_Group = (Units in (Playable map area) owned by (Triggering player))
Collapse Unit Group - Pick every unit in Temp_Group and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to ADP1
(Unit-type of (Picked unit)) Equal to Apprentice
Collapse Then - Actions
Unit - Replace Apprentice[(Player number of (Triggering player))] with a Melee using The new unit's max life and mana
Hero - Create Iron Sword and give it to (Last replaced unit)
Unit Group - Add (Last replaced unit) to Hunger
Set Hero[(Player number of (Owner of (Last replaced unit)))] = (Last replaced unit)
Set Apprentice[(Player number of (Triggering player))] = No unit
Cinematic - Send transmission to (Player group((Owner of (Last replaced unit)))) from Melee Combat Master 0034 <gen> named Captain Killicks: Play No sound and display Not bad if I do say.... Modify duration: Set to 2.00 seconds and Wait
Collapse Else - Actions
Do nothing
Collapse Unit Group - Pick every unit in Temp_Group and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to ADP1
(Unit-type of (Picked unit)) Equal to Apprentice
Collapse Then - Actions
Unit - Replace Apprentice[(Player number of (Triggering player))] with a Melee using The new unit's max life and mana
Hero - Create Iron Sword and give it to (Last replaced unit)
Unit Group - Add (Last replaced unit) to Hunger
Set Hero[(Player number of (Owner of (Last replaced unit)))] = (Last replaced unit)
Set Apprentice[(Player number of (Triggering player))] = No unit
Cinematic - Send transmission to (Player group((Owner of (Last replaced unit)))) from Melee Combat Master 0034 <gen> named Captain Killicks: Play No sound and display Not bad if I do say.... Modify duration: Set to 2.00 seconds and Wait
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to ADP2
Collapse Then - Actions
Cinematic - Send transmission to (Player group((Triggering player))) from Melee Combat Master 0034 <gen> named Captain Killicks: Play No sound and display I see... please do .... Modify duration: Set to 3.00 seconds and Wait
Collapse Else - Actions
Do nothing
Custom script: call DestroyGroup (udg_Temp_Group)
06-19-2008, 10:59 AM#2
Anitarf
The lag may be associated with loading the new unit. Try preplacing all your units somewhere on the map for a neutral player so they get loaded when the map starts and then remove them.
06-19-2008, 04:17 PM#3
deathdrivex
Forgot to add, it only happens when you select to be a Rangetype,Magictype,Meleetype.

So far, this is what happened:

First, I selected to be either Male/Female character.
The character created is registered to "Apprentice[#]"
After selecting the "Accept" button on dialog menu to change, it lags.

^So somewhere within that causes it and I remade the whole thing, still got a problem. My best guess is the "replacing". Should I change it to "Remove+Create new one"?

EDIT: Both methods failed to remove lag. I think it has to do with the spawning of the custom unit. Testing it right now.
EDIT2: Just checked. It DOES NOT LAG when I spawn an original/normal unit. May be something with the Custom Unit? if so, what? I spawned the custom unit many times before without lag but now its causing it for some awkward reason? And yes, the neutral player already has the units in the map, not sure why would it lag if a unit exactly the same is already there.