Добавлен Sergant1000
Внимание вопрос)
Какую конструкцию лучше использовать, конструкцию:
function Trig_SomeFunction_Conditions takes nothing returns boolean
return ( GetSpellAbilityId() == 'SomeSpell' )
endfunction
unction Trig_SomeFunction_Actions takes nothing returns nothing
call SomeAction
endfunction
//=========
function InitTrig_SomeFunction takes nothing returns nothing
set gg_trg_SomeFunction = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SomeFunction, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_SomeFunction, Condition( function Trig_SomeFunction_Conditions ) )
call TriggerAddAction( gg_trg_SomeFunction, function Trig_SomeFunction_Actions )
endfunction
Или конструкцию:
unction Trig_SomeFunction_Actions takes nothing returns nothing
if (GetSpellAbilityId() == 'SomeSpell') then
call SomeAction
endif
endfunction
//=========
function InitTrig_SomeFunction takes nothing returns nothing
set gg_trg_SomeFunction = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SomeFunction, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddAction( gg_trg_SomeFunction, function Trig_SomeFunction_Actions )
endfunction
Какае плюсы и минусы у них.
Принятый ответ
Сделай тогда так:
code
function Trig_SomeFunction_Conditions takes nothing returns boolean
if GetSpellAbilityId() == 'SomeSpell' then
call SomeAction
endif
return false
endfunction
//=========
function InitTrig_SomeFunction takes nothing returns nothing
set gg_trg_SomeFunction = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SomeFunction, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_SomeFunction, Condition( function Trig_SomeFunction_Conditions ) )
endfunction
Ты сделаешь проверку в условии и там же запустишь функцию, без лишнего вызова Trig_SomeFunction_Actions . Но это почти одно и то же, что и второй вариант.
Что-то я не понял, что ты подразумеваешь под "порядком" Несколько условий?
Что-то я не понял, что ты подразумеваешь под "порядком" Несколько условий?
Если у тебя несколько условий, то делай градацию, начиная с самого распространенного
code
function Trig_SomeFunction_Conditions takes nothing returns boolean
if GetSpellAbilityId() == 'SomeSpell' then // Самое распространенное
if GetUnitState(GetTriggerUnit()) > 100.0 then // Менее распространенное
if ... then // И т.д. в порядке уменьшения вероятности несрабатывания
call SomeAction
endif
endif
....
return false
endfunction
//=========
function InitTrig_SomeFunction takes nothing returns nothing
set gg_trg_SomeFunction = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SomeFunction, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_SomeFunction, Condition( function Trig_SomeFunction_Conditions ) )
endfunction
Чтобы оставить комментарий, пожалуйста, войдите на сайт.
Отредактирован DaeDR
Что-то я не понял, что ты подразумеваешь под "порядком" Несколько условий?