XGM Forum
Сайт - Статьи - Проекты - Ресурсы - Блоги

Форуме в режиме ТОЛЬКО ЧТЕНИЕ. Вы можете задать вопросы в Q/A на сайте, либо создать свой проект или ресурс.
Вернуться   XGM Forum > Warcraft> Академия: форум для вопросов> Jass
Ник
Пароль
Войти через VK в один клик
Сайт использует только имя.

Закрытая тема
 
Anubizz

offline
Опыт: 1,260
Активность:
Спелл
Есть ли в спелле утечки или что то лишнее?
Код:
function Trig_Wave_Slam_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A00T' ) ) then
        return false
    endif
    return true
endfunction
function Trig_Wave_Slam_Actions takes nothing returns nothing
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 60
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call CreateNUnitsAtLoc( 1, 'n009', GetOwningPlayer(GetTriggerUnit()), GetUnitLoc(GetTriggerUnit()), bj_UNIT_FACING )
        call SetUnitAbilityLevelSwapped( 'A00S', GetLastCreatedUnit(), GetUnitAbilityLevelSwapped('A00T', GetSpellAbilityUnit()) )
        call IssuePointOrderLocBJ( GetLastCreatedUnit(), "breathoffrost", PolarProjectionBJ(GetUnitLoc(GetTriggerUnit()), 256, ( 6.00 * I2R(GetForLoopIndexA()) )) )
        call UnitApplyTimedLifeBJ( 0.50, 'BTLF', GetLastCreatedUnit() )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction
function InitTrig_Wave_Slam takes nothing returns nothing
    set gg_trg_Wave_Slam = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Wave_Slam, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Wave_Slam, Condition( function Trig_Wave_Slam_Conditions ) )
    call TriggerAddAction( gg_trg_Wave_Slam, function Trig_Wave_Slam_Actions )
endfunction
Старый 14.08.2009, 15:06
Daemonik

offline
Опыт: 5,084
Активность:
Пользуйся тегами. Ничерта не понятно, а глаза ломать неохота.
Могу сразу сказать, утечек много. Читай статьи по оптимизации и JPNG тебе в помощь.
Старый 14.08.2009, 15:08
Anubizz

offline
Опыт: 1,260
Активность:
Daemonik, исправил.
Старый 14.08.2009, 15:09
DragonSpirit
у - уходи
offline
Опыт: 22,625
Активность:
function Trig_Wave_Slam_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A00T' ) ) then
return false
endif
return true
endfunction
достаточно
function Trig_Wave_Slam_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00T' 
endfunction
цикл можно легче сделать через
local integer i = 1
loop
exitwhen i >60
call CreateNUnitsAtLoc( 1, 'n009', GetOwningPlayer(GetTriggerUnit()), GetUnitLoc(GetTriggerUnit()), bj_UNIT_FACING )
call SetUnitAbilityLevelSwapped( 'A00S', GetLastCreatedUnit(), GetUnitAbilityLevelSwapped('A00T', GetSpellAbilityUnit()) )
call IssuePointOrderLocBJ( GetLastCreatedUnit(), "breathoffrost", PolarProjectionBJ(GetUnitLoc(GetTriggerUnit()), 256, ( 6.00 * I2R(GetForLoopIndexA()) )) )
call UnitApplyTimedLifeBJ( 0.50, 'BTLF', GetLastCreatedUnit() )
set i = i + 1
endloop 
так же раскрой BJ функции
Старый 14.08.2009, 15:09
Anubizz

offline
Опыт: 1,260
Активность:
Спасибо.
Старый 14.08.2009, 15:20
Hellfim
Новичок
offline
Опыт: 79,707
Активность:
» code
function waveSlamConditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00T'
endfunction

function waveSlamActions takes nothing returns nothing
    local integer loopIndex=0
    local unit caster=GetTriggerUnit()
    local real casterX=GetUnitX(caster)
    local real casterY=GetUnitY(caster)
    local unit dummy=null
    local real targetX=0.00
    local real targetY=0.00
    loop
        exitwhen loopIndex>59
        set dummy=CreateUnit(GetOwningPlayer(caster),'n009',casterX,casterY,0)
        call SetUnitAbilityLevel(dummy,'A00S',GetUnitAbilityLevel(caster,'A00T')
        set targetX=casterX+256*Cos(6.00*loopIndex)
        set targetY=casterY+256*Sin(6.00*loopIndex)
        call IssuePointOrder(dummy,"breathoffrost",targetX,targetY)
        call UnitApplyTimedLife(dummy,'BTLF',1.50)
        set loopIndex=loopIndex+1
    endloop
    set caster=null
    set dummy=null
endfunction

function InitTrig_Wave_Slam takes nothing returns nothing
    local trigger waveSlam=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(waveSlam,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(waveSlam,Condition(function waveSlamConditions))
    call TriggerAddAction(waveSlam,function waveSlamActions)
    set waveSlam=null
endfunction
Старый 14.08.2009, 15:20
Anubizz

offline
Опыт: 1,260
Активность:
Hellfim, и тебе спасибо.
Старый 14.08.2009, 15:26
Линкольн
Barg Ent.
offline
Опыт: 4,812
Активность:
Я бы сделал так. Проверь.
Код:
globals
    constant integer dummy_id = 'n009'
    constant integer caster_ability_id = 'A00T'
    constant integer dummy_ability_id = 'A00S'
endglobals

function Trig_Wave_Slam_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == caster_ability_id
endfunction

function Trig_Wave_Slam_Actions takes nothing returns nothing
    local unit u1 = GetSpellAbilityUnit()
    local unit u2 = null
    local real x1 = GetUnitX(u1)
    local real y1 = GetUnitY(u1)
    local real x2 = 0.00
    local real y2 = 0.00
    local real f = GetUnitFacing(u1)
    local integer i = 1
    loop
        set x2 = x1 + 256 * Cos(6 * i)
        set y2 = y1 + 256 * Sin(6 * i)
        set u2 = CreateUnit(GetOwningPlayer(u1), dummy_id, x1, y1, f)
        call UnitApplyTimedLife(u2, 'BTLF', 0.50)
        call SetUnitAbilityLevel(u2, dummy_ability_id, GetUnitAbilityLevel(u1, caster_ability_id))
        call IssuePointOrderById(u2, 852560, x2, y2)
        exitwhen (i == 60)
        set i = i + 1
    endloop
endfunction

function InitTrig_Wave_Slam takes nothing returns nothing
    local trigger WaveSlam = CreateTrigger()
    local integer i = 0
    loop
        call TriggerRegisterPlayerUnitEvent(WaveSlam, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
        set i = i + 1
        exitwhen (i == 11)
    endloop
    call TriggerAddCondition(WaveSlam, Condition(function Trig_Wave_Slam_Conditions))
    call TriggerAddAction(WaveSlam, function Trig_Wave_Slam_Actions)
endfunction
Старый 14.08.2009, 15:41
Anubizz

offline
Опыт: 1,260
Активность:
Щас проверю.
Старый 14.08.2009, 15:43
Линкольн
Barg Ent.
offline
Опыт: 4,812
Активность:
Anubizz. Работать они будут одинаково, дело в удобстве. Я привык делать именно так. Удобнее, особенно если код большой. Допустим тебе нужно изменить id способностей или б/е, не нужно перебирать весть код, а просто выставляешь нужные id в глобальных переменных.
Старый 14.08.2009, 16:11
Hellfim
Новичок
offline
Опыт: 79,707
Активность:
Линкольн, CTRL+H (автозамена)...
Старый 14.08.2009, 17:55
Закрытая тема

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы можете скачивать файлы

BB-коды Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход



Часовой пояс GMT +3, время: 13:08.