HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Why Would This Lag?

01-08-2007, 06:57 PM#1
Rising_Dusk
Collapse JASS:
function Withdraw_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A02U'
endfunction

function Withdraw_Check takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(bj_lastLoadedUnit)) and GetWidgetLife(GetFilterUnit()) > 0.405 and not IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) and GetUnitAbilityLevel(GetFilterUnit(), 'Avul') <= 0
endfunction

function Withdraw_Actions takes nothing returns nothing
    local unit u = GetSpellAbilityUnit()
    local unit s
    local group g = CreateGroup()
    local boolexpr b = Condition(function Withdraw_Check)
    local integer lvl = GetUnitAbilityLevel(u, 'A02U')
    local integer m = 3
    local integer i = 1
    local real life
    local real stea
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    
    if lvl == 3 or lvl == 4 then
        set m = 4
    elseif lvl == 5 then
        set m = 5
    endif
    
    set bj_lastLoadedUnit = u
    call GroupEnumUnitsInRange(g, x, y, 400, b)
    loop
        set s = FirstOfGroup(g)
        exitwhen i > m or s == null
        set life = GetWidgetLife(s)
        set stea = 10+(10*lvl)
        if life < stea then
            set stea = life
        endif
        call DestroyEffect(AddSpecialEffect("MDX\\HealTargetNew.mdx", x, y))
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl", GetUnitX(s), GetUnitY(s)))
        call UnitDamageTarget(u, s, stea, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null)
        call SetWidgetLife(u, GetWidgetLife(u)+stea)
        call GroupRemoveUnit(g, s)
        set i = i + 1
    endloop
    
    call GroupClear(g)
    call DestroyGroup(g)
    call DestroyBoolExpr(b)
    set g = null
    set b = null
    set u = null
    set s = null
endfunction

function InitTrig_Withdraw takes nothing returns nothing
    set gg_trg_Withdraw = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Withdraw, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Withdraw, Condition(function Withdraw_Conditions))
    call TriggerAddAction(gg_trg_Withdraw, function Withdraw_Actions)
endfunction
I can't figure out why, but every single casting of this the game lags for roughly 2 seconds.
Also, both effects that are used are used elsewhere in the map and aren't very visually demanding.
01-08-2007, 07:04 PM#2
Vexorian
nothing there justifies that kind of lag. I would bruteforce it by disabling each line until I find the one that bugs
01-08-2007, 07:13 PM#3
iNfraNe
"MDX\\HealTargetNew.mdx"

perhaps its lagging cus the game needs to turn this to mdl each time cus you tell it to use an mdx file? (I dont know if the game does that, I just know it turns all mdx to mdl and from there on you use the mdl)
01-08-2007, 07:24 PM#4
Rising_Dusk
Doesn't it do that during the load screen though?
And i just commented out the entire SFX lines and it still lags.
It's weird.

I'll probably figure it out Vex's way.
Thanks though.
01-08-2007, 08:23 PM#5
Daelin
Collapse JASS:
not IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL)
Isn't IsUnitType bugged and works only in comparisions?

~Daelin
01-08-2007, 08:37 PM#6
Vexorian
It is not the last function called in the if
01-09-2007, 10:08 AM#7
BertTheJasser
First step is, to check if it still lags without the boolexpr for the enum stuff...
01-09-2007, 10:47 AM#8
iNfraNe
Quote:
Originally Posted by Rising_Dusk
Doesn't it do that during the load screen though?
And i just commented out the entire SFX lines and it still lags.
Yes, but you still give the effect the .mdx extention.

But ohwell, wasnt the cause. 2bad :)
01-09-2007, 04:38 PM#9
DioD
you have to use group enum counted to your cap, this will decrease group size to minimum and will not take integer check every time
01-09-2007, 04:44 PM#10
Daelin
I don't get why would you clear the group if you are removing it anyway. I'm not pointing necessarily lag problems, just certain things that look confusing to me.

~Daelin
01-09-2007, 05:18 PM#11
Vexorian
Quote:
Originally Posted by DioD
you have to use group enum counted to your cap, this will decrease group size to minimum and will not take integer check every time
GroupEnumCounted natives didn't seem to have any effect.
01-09-2007, 06:42 PM#12
Rising_Dusk
Quote:
I don't get why would you clear the group if you are removing it anyway. I'm not pointing necessarily lag problems, just certain things that look confusing to me.
It's a safety measure in case the group wasn't clear beforehand.
Force of habit, if anything.
01-09-2007, 10:34 PM#13
Heaven
I had a similar problem with character selection in one of my maps. Every time a character was selected it would lag for like 2+ seconds.

When I copied the triggers to a new map with default units, etc., the lag went away.

Still working on the why. Heh.

Take care.
01-10-2007, 01:02 AM#14
Rising_Dusk
Quote:
I had a similar problem with character selection in one of my maps. Every time a character was selected it would lag for like 2+ seconds.
You didn't preload the heroes, that's why it lagged when you created them for the first time.

This, on the other hand, doesn't create any units and uses already preloaded FX.
So... Yeah. xD
01-10-2007, 02:14 AM#15
Heaven
Quote:
Originally Posted by Rising_Dusk
You didn't preload the heroes, that's why it lagged when you created them for the first time.
So... no.

I did say 'every time' right? Heh. Seriously. Even if you picked the same hero over and over it would lag every time right when it got to the unit - create 1 BLAH for player BLAH. I think I finally found a way around it by creating all the hero types in advance for each player in a big array for neutral passive and then transferring the unit to the selecting player upon selection.

Anyway, my point was maybe he should try duplicating the trigger in a blank map and see if that does anything. If not, sorry I wasted your time. If it does...maybe we can try and figure out what things in the object editor are causing our maps to lag.

Take care.