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

[JASS] picking units in range causes heavy lags?

Status
Not open for further replies.
Level 14
Joined
Jul 1, 2008
Messages
1,314
hey guys, its me again :)

This time, i got an ability, that should be used by dummies created in a pick loop.
Its seems that either the ability itself or the trigger causes heavy lags...

I tested the ability, and it laged, as i used it without this trigger, but i never heard, that an ability can cause so much traffic.

Its based on shadow strike, and here is the trigger:

JASS:
//Conditions for picking units
function Plants_Check takes nothing returns boolean
local unit U = GetFilterUnit()
if IsUnitType(U, UNIT_TYPE_MECHANICAL) == false then
   set U = null
   return false
endif
if GetUnitState(U, UNIT_STATE_LIFE) <= 0 then
   set U = null
   return false
endif
if GetUnitAbilityLevel(U, 'Avul') > 0 then
   set U = null
   return false
endif
   set U = null
   return true
endfunction
 
//Condition, if the start ability is the right one  
function Trig_Duengen_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == 'A02V' then
        return true
    endif
    return false 
endfunction

function Trig_Duengen_Actions takes nothing returns nothing
local unit Picked
local group Plants = CreateGroup()
local location Center = GetSpellTargetLoc()
local integer Count = 10
local unit dummy

// Pick every Unit in Range 350, when Cond == true
call GroupEnumUnitsInRangeOfLoc( Plants, Center, 350.00, Condition(function Plants_Check))
   
   // loop to manage the group
   loop
        set Picked = FirstOfGroup(Plants) 
        exitwhen Picked == null or Count == 0
                set dummy = CreateUnitAtLoc(Player(0), 'hspt', Center, bj_UNIT_FACING )
                [COLOR="Red"]call UnitAddAbility(dummy, 'A02U')[/COLOR]
                call UnitApplyTimedLife(dummy, 'BTLF', 5.00)
                call IssueTargetOrder( dummy, "shadowstrike", Picked)
                //next Unit
                call GroupRemoveUnit(Plants,Picked)
                set dummy=null 
    endloop
    //reset
    set Picked = null
    call RemoveLocation(Center)
    set Center = null
    call DestroyGroup(Plants)
    set Plants = null
endfunction

//==== Init Trigger Duengen ===================================================
function InitTrig_Duengen takes nothing returns nothing
    set gg_trg_Duengen = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Duengen,EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddCondition(gg_trg_Duengen, Condition(function Trig_Duengen_Conditions))
    call TriggerAddAction(gg_trg_Duengen, function Trig_Duengen_Actions)
endfunction

I dont know what to do....any suggestions? The ability added above, which i marked red, is the lag source

Thanks in advance :)

Greetings
 
Level 5
Joined
Dec 18, 2007
Messages
205
little question:
JASS:
function InitTrig_Duengen takes nothing returns nothing
    set gg_trg_Duengen = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Duengen,EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddCondition(gg_trg_Due[color="Red"][/color]ngen, Condition(function Trig_Duengen_Conditions))
    call TriggerAddAction(gg_trg_Duengen, function Trig_Duengen_Actions)
endfunction

What is the color? Oo
JASS:
call TriggerAddCondition(gg_trg_Due[color="Red"][/color]ngen, Condition(function Trig_Duengen_Conditions))

Edit: Stupid question, i think you made a little mistake with adding the code to hive (used color?:p )
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
exactyl ;)

Well i still have no idea, why this thing would cause lags...there are only 2 units in range, when i test it, and my laptop nearly crashes (2 times 2.5 GHZ and 2 GB DDR 3 SSD).

Maybe there is an infinite loop?
Someone knows, what i made wrong?

Greets
 
Level 5
Joined
Dec 18, 2007
Messages
205
and by the way: 'count' is never going to be null.
but i don't see why this should lag. how often is the function called in what time etc.?

edit: well here i give u some tips to improve your code, maybe this is already the solution, but your code shouldn't lag:

JASS:
function Trig_Duengen_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A02V'
endfunction

instead of

JASS:
function Trig_Duengen_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == 'A02V' then
        return true
    endif
    return false
endfunction

JASS:
function InitTrig_Duengen takes nothing returns nothing
    local trigger Duengen = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(Duengen,EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddCondition(Duengen, Condition(function Trig_Duengen_Conditions))
    call TriggerAddAction(Duengen, function Trig_Duengen_Actions)
    set Duengen = null
endfunction

instead of

JASS:
function InitTrig_Duengen takes nothing returns nothing
    set gg_trg_Duengen = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Duengen,EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddCondition(gg_trg_Duengen, Condition(function Trig_Duengen_Conditions))
    call TriggerAddAction(gg_trg_Duengen, function Trig_Duengen_Actions)
endfunction

JASS:
function Plants_Check takes nothing returns boolean
if IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) == true and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 and GetUnitAbilityLevel(GetFilterUnit(), 'Avul') <= 0 then
   return true
endif
return false
endfunction

instead of

JASS:
function Plants_Check takes nothing returns boolean
local unit U = GetFilterUnit()
if IsUnitType(U, UNIT_TYPE_MECHANICAL) == false then
   set U = null
   return false
endif
if GetUnitState(U, UNIT_STATE_LIFE) <= 0 then
   set U = null
   return false
endif
if GetUnitAbilityLevel(U, 'Avul') > 0 then
   set U = null
   return false
endif
   set U = null
   return true
endfunction


Just some things that i've changed, but as i already said, i dont see why your code should lag.

greetz
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
It might be initial cast lag. It is caused by WC3 pausing while it loads a model from the hard disk. Normally this never happens as the units are loaded as they become available to build or before they are displayed, however trigger creation is spontanious so there is no time before the recource is needed and fetching the recource. This means it has to put the entire game on hold until the model is loaded into the game engine and is capable of being used. This is the most common form of lag in multiplayer maps that are well made as the pause is local so will start to give a waiting on player once the model loads for your PC (I think).
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
oh thanks guys!

I recognized, that i uploaded an older trigger, but thanks for the help. I changed the things, that were not already in the new code...

I realldy have no idea, the changes dont change anything. But i tested another thing. I let the dummies cast their abilities without this trigger, and it seems, that the usage of shadow strike in this map causes laggs...

Im not sure, but this seems to be an infinite loop...but i have no clue, where this should be.

Anyways, guys thanks alot for helping!

Greets


Edit: oh hey thank you Dr Super Good, i didnt think of this thing ! I will test preloading and telling you guys the result after this

Edit2: nope unluckily it doesnt work neither....:( I preloaded it at map initialisation like the other abilities, but the "shadow strike" still causes laggs. I guess i better search another ability to base it on. Thank you anyways :) The dummy was preloaded before, and its really the ability, and my computer is 3 days old and very powerfull^^...
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Shadow strike is well known to lag. It is caused by it dealing 0 damage 1000s of times a second. Simply avoid setting it's settings (damage can be 0 thou) to 0. Rather go with numbers like 0.01.

Also appon casting any spell as econd time, there should no longer be load lag.
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
oh thanks, i didnt know that.

Anyways it lags...i set all the 0 to 0.1, and actually it shouldnt do any damage, because its only to add a buff to the target unit.

edit: Ill search another ability, its only a dummy ability to add a buff, so it doesn have to be Shadow strike...

then funny thing is just, im using the same thing as a dummy ability already in the same map the same kind, but this does work...

Thanks for helping me ! :)
 
Status
Not open for further replies.
Top