Missile lag, local trigger

Status
Not open for further replies.
Level 3
Joined
Feb 14, 2013
Messages
26
Hi, i love to write all code with jass and i have some problem as title, hope someone can help me solved, thank in advance.

- First i have 20 or 30 tower shot at same time, huge damage and fast, it make some lag, can i solved this by change the missile model ?

- When do i use local trigger ?
JASS:
globals
    trigger trg_Mytrigger = CreateTrigger()
endglobals
JASS:
function ...
    local trigger trg_Mytrigger = CreateTrigger()
endfunction

- Should i use this:
JASS:
call ForGroup(GetUnitsOfPlayerAll(p), function RemoveEnumUnit)
or
JASS:
set group = GetUnitsOfPlayerAll(p)
call ForGroup(group, function RemoveEnumUnit)
call DestrouGroup(group)

- Should i use only 1 trigger for all ability or each trigger for each ability
JASS:
    function MyAbilityActions takes nothing returns nothing
        if GetSpellAbilityId() == 'A000' then
            //Do action
        endif
        if GetSpellAbilityId() == 'A001' then
            //Do action
        endif
    endfunction
    set trg_MyAbility = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trg_MyAbility, EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddAction(trg_MyAbility, function MyAbilityActions)
 
Level 16
Joined
Mar 25, 2016
Messages
1,327
Groups:
Use the second one. You should destroy the unit groups. You should also null local handles when you no longer need them. Instead of the BJ GetUnitsOfPlayerAll(p) you should use natives.

Abilitiy:
I would use for each ability a trigger. It's way more comfortable to edit the abilities if they are seperated (you can disable single abilities, you find the ability you want to edit faster).
 
Level 3
Joined
Feb 14, 2013
Messages
26
Groups:
Use the second one. You should destroy the unit groups. You should also null local handles when you no longer need them. Instead of the BJ GetUnitsOfPlayerAll(p) you should use natives.

Abilitiy:
I would use for each ability a trigger. It's way more comfortable to edit the abilities if they are seperated (you can disable single abilities, you find the ability you want to edit faster).
Thank for your help, which function i should use to replace with GetUnitsOfPlayerAll() and when do i can use local trigger ?
 
Level 16
Joined
Mar 25, 2016
Messages
1,327
You should use Jass NewGen Pack [Official] if you code in JASS. It contains a systax highlighter and a function list. It shows you which functions are native (purple) and which are BJs (red). As you can see in the code you posted GetUnitsOfPlayerAll is red.
Using Ctrl + left mouse click on a function shows the parameters and the return type. If it's a BJ you can see which functions it consists of.

JASS:
    local group g = CreateGroup()
    local player p = Player(0)
   
    call GroupEnumUnitsOfPlayer(g,p,null)
    call ForGroup(g, function RemoveEnumUnit)
    call DestroyGroup(g)
   
    set g = null
    set p = null
This would be the code only using natives and no leaks.

I don't know when you can use local triggers. I never did it myself, so I can't help you with that one.
 
Status
Not open for further replies.
Top