Решил написать небольшую библиотеку по созданию своих триггерных иллюзий.
раскрыть
library IllusionSystem initializer onInit requires Table


    globals
        private  unit  summoner             =  null
        private  unit  illusion             =  null
        private  unit  tempUnit             =  null
        private  unit  lastCreatedIllusion  =  null

        private  group  illusions           =  null
        private  table  damage              =  table( 0 )
        private  table  defense             =  table( 0 )
    endglobals


    constant function GetLastCreatedIllusion takes nothing returns unit
        return lastCreatedIllusion
    endfunction


    function CreateIllusion takes player whichPlayer, integer unitId, real x, real y, real face, integer percentDamage, integer percentArmor, real duration returns unit
        set  tempUnit  =  CreateUnit( Player( PLAYER_NEUTRAL_PASSIVE ), unitId, x, y, face )

        if ( summoner == null ) then
            call BJDebugMsg( "CreateIllusion( ) :    summoner ещё не создан." )

        elseif ( not IssueTargetOrderById( summoner, 852274, tempUnit ) ) then
            call BJDebugMsg( "CreateIllusion( ) :    не удалось создать иллюзию." )
        endif

        call RemoveUnit( tempUnit )

        set  illusion                            =  GetLastCreatedIllusion( )
        set  damage [ GetHandleId( illusion ) ]  =  percentDamage
        set  defense[ GetHandleId( illusion ) ]  =  percentArmor

        call SetUnitOwner      ( illusion, whichPlayer, true )
        call SetUnitX          ( illusion, x                 )
        call SetUnitX          ( illusion, y                 )
        call SetUnitFacing     ( illusion, face              )
//      call UnitApplyTimedLife( illusion, 'BOmi', duration  )
        call GroupAddUnit      ( illusions, illusion         )

        return illusion
    endfunction


    private function onUnitDamaged takes nothing returns nothing
        local  unit  victim   =  GetTriggerUnit( )
        local  unit  damager  =  GetEventDamageSource( )


        set  victim   =  null
        set  damager  =  null
    endfunction


    function onIllusionSummon takes nothing returns nothing
        set lastCreatedIllusion  =  GetSummoningUnit( )
    endfunction


    public function onInit takes nothing returns nothing
        local  trigger  trig  =  CreateTrigger( )

        set  illusions  =  CreateGroup( )
        set  damage     =  table.create( )
        set  defense    =  table.create( )
        set  summoner   =  CreateUnit( Player( PLAYER_NEUTRAL_PASSIVE ), DUMMY_UNIT_ID, HIDDEN_X, HIDDEN_Y, bj_UNIT_FACING )

        call UnitAddAbility     ( summoner, 'Aloc' )
        call SetUnitInvulnerable( summoner, true   )
        call UnitAddAbility     ( summoner, 'A00A' )
        call SetUnitPathing     ( summoner, false  )
        call UnitRemoveAbility  ( summoner, 'Amov' )

        call TriggerRegisterUnitEvent( trig, summoner, EVENT_UNIT_SUMMON )
        call TriggerAddAction        ( trig, function onIllusionSummon   )

        set  trig  =  null
    endfunction


endlibrary
Но по неизвестной мне причине система работает через раз. А при первом вызове функции CreateIllusion( ) иллюзия не создаётся или же создается за нейтрального игрока.
Вот карта.

Принятый ответ

Всё время выдает один и тот же хендл. Думаю ошибка здесь
    function onIllusionSummon takes nothing returns nothing
        call BJDebugMsg(I2S(GetHandleId(GetSummoningUnit( ))))
        set lastCreatedIllusion  =  GetSummoningUnit( )
    endfunction
Короче, поменяй GetSummoningUnit( ) на GetSummonedUnit( )
`
ОЖИДАНИЕ РЕКЛАМЫ...
0
19
6 лет назад
0
Похожие вопросы:

ответ
О, спасибо, столько накидали)
Разобрался кстати, почему не захватывало на суммонед - иллюзия не сразу создается, нужен вейт ~0.2 сек.
Melissa:
Вызывает боевую единицу.
Тип вызванной = тип вызывающего
^ отлов иллюзии, если цель сам воин
А не легче, Target unit of ability being cast равно Casting unit в условиях?
Melissa:

Триггерно иллюзию ведь не создать (для Last created unit)
дать руну со способностью жезла иллюзий ему
Я имел ввиду триггерно создать иллюзию через CreateUnit, т.е. полностью триггером, без любых способностей.
quq_CCCP:
Почему это нет, Event_Unit_Summon и Summoned unit (событие именно конкретный юнит вызвал), так же EventUnitInRect (входит в область) и условие IsUnitIllusion И проверяем на бафф от жезла иллюзий у иллюзии (GetUnitAbilityLevel( u, 'B000') > 0)
А как в первом и втором способе исключить жезл иллюзий? Вторичные действия способности подразумевают именно иллюзию от использования способности.
Т.е. все способы окольные, печально.
ответ
Где-то я видел наработку с этими хр барами.
Найдётся в ресурсах пользователя JesusHipster.

0
23
6 лет назад
0
Этого мы уже разжевали 1000 раз лучше используй предметный для создание клона из него ловите
0
21
6 лет назад
0
pro100master, почему используй предметный на создание клон, тогда есть способность использует напрямую.
0
20
6 лет назад
0
Имхо с созданием иллюзии через руну меньше гемора.
0
16
6 лет назад
0
Diaboliko, после руны остаётся модель. Руну нужно удалять.
2
18
6 лет назад
2
Мне кажется здесь ошибка
        call SetUnitX          ( illusion, x                 )
        call SetUnitX          ( illusion, y                 )
0
21
6 лет назад
0
UrsaBoss, спасибо, не заметил.) Но проблема с созданием иллюзий с этим не связана.
4
32
6 лет назад
4
Где UnitShareVision - если что даммик нихрена не видит после того как создан, он либо должен иметь точно такие же координаты как и цель либо у него должна быть расшарена видимость над целью.
0
21
6 лет назад
0
quq_CCCP, а почему у первой иллюзии владелец - Player( PLAYER_NEUTRAL_PASSIVE )? Несмотря на то что, в функции есть SetUnitOwner( ).
quq_CCCP:
Где UnitShareVision - если что даммик нихрена не видит после того как создан, он либо должен иметь точно такие же координаты как и цель либо у него должна быть расшарена видимость над целью.
Это да, но в карте открыта видимость, так что проблема была не в этом.
4
18
6 лет назад
Отредактирован Hodor
4
Всё время выдает один и тот же хендл. Думаю ошибка здесь
    function onIllusionSummon takes nothing returns nothing
        call BJDebugMsg(I2S(GetHandleId(GetSummoningUnit( ))))
        set lastCreatedIllusion  =  GetSummoningUnit( )
    endfunction
Короче, поменяй GetSummoningUnit( ) на GetSummonedUnit( )
Принятый ответ
0
21
6 лет назад
Отредактирован scopterectus
0
UrsaBoss, да, действительно. Только что сам это выяснил и хотел написать, а Вы уже написали ответ. )

Cобсна, конечный код:
раскрыть
library IllusionSystem requires Table


    struct illusion
        private  static  timer     period               =  null
        private          thistype  prev
        private          thistype  next
        
        private  static  trigger   trig                 =  null
        private  static  unit      summoner             =  null
        private  static  unit      tempUnit             =  null
        private  static  unit      lastCreatedIllusion  =  null
        private  static  group     illusions            =  null
        private  static  table     data                 =  table( 0 )

        readonly         unit      unit
        readonly         real      damage
        readonly         real      defense
        readonly         real      duration


        private static method iterate takes nothing returns nothing
            local  thistype  this  =  thistype( 0 ).next

            loop
                exitwhen ( this == 0 )

                set  this.duration  =  this.duration - 0.03125

                if ( this.duration <= 0.0 ) then
                    call KillUnit( this.unit )
                endif

                set  this  =  this.next
            endloop
        endmethod


        static method create takes player whichPlayer, integer unitId, real x, real y, real face, real damage, real defense, real duration returns thistype
            local  thistype  this  =  illusion( 0 )

            set  thistype.tempUnit  =  CreateUnit( Player( PLAYER_NEUTRAL_PASSIVE ), unitId, x, y, face )

            call SetUnitPathing     ( thistype.tempUnit, false )
            call SetUnitInvulnerable( thistype.tempUnit, true   )
            call UnitRemoveAbility  ( thistype.tempUnit, 'Amov' )
            call UnitShareVision    ( thistype.tempUnit, whichPlayer, true )

            call SetUnitX           ( thistype.summoner, x )
            call SetUnitY           ( thistype.summoner, y )

            if ( thistype.tempUnit == null ) then
                debug call BJDebugMsg( "CreateIllusion( ) :    не удалось cоздать временного воина." )

            elseif IssueTargetOrderById( thistype.summoner, 852274, thistype.tempUnit ) then
                set  this                                       =  thistype.allocate( )
                set  this.next                                  =  thistype( 0 )
                set  this.prev                                  =  thistype( 0 ).prev
                set  this.next.prev                             =  this
                set  this.prev.next                             =  this

                set  this.unit                                  =  thistype.lastCreatedIllusion
                set  this.damage                                =  damage
                set  this.defense                               =  defense
                set  this.duration                              =  duration
                set  thistype.data[ GetHandleId( this.unit ) ]  =  integer( this )

                if IsUnitType( this.unit, UNIT_TYPE_STRUCTURE ) then
                    call SetUnitPosition( this.unit, x, y )

                else
                    call SetUnitX( this.unit, x )
                    call SetUnitX( this.unit, y )
                endif

                call SetUnitFacing     ( this.unit, face               )
                call SetUnitOwner      ( this.unit, whichPlayer, true  )
                call GroupAddUnit      ( thistype.illusions, this.unit )

                if ( this.prev == 0 ) then
                    call TimerStart( thistype.period, 0.03125, true, function thistype.iterate )
                endif

            else
                debug call BJDebugMsg( "CreateIllusion( ) :    не удалось применить способность, создающую иллюзию." )
            endif

            call UnitShareVision( thistype.tempUnit, whichPlayer, false )
            call RemoveUnit     ( thistype.tempUnit )
            set  thistype.tempUnit  =  null

            call SetUnitX       ( thistype.summoner, HIDDEN_X )
            call SetUnitY       ( thistype.summoner, HIDDEN_Y )
            call SetUnitOwner   ( thistype.summoner, Player( PLAYER_NEUTRAL_PASSIVE ), false )

            return this
        endmethod


        private static method onIllusionSummon takes nothing returns nothing
            set thistype.lastCreatedIllusion  =  GetSummonedUnit( )
        endmethod


        private static method onUnitDamaged takes nothing returns nothing
            if IsUnitInGroup( GetEventDamageSource( ), thistype.illusions ) then
                call SetEventDamage( GetEventDamage( ) * thistype( data[ GetHandleId( GetEventDamageSource( ) ) ] ).damage )
            endif

            if IsUnitInGroup( GetTriggerUnit( ), thistype.illusions ) then
                call SetEventDamage( GetEventDamage( ) * thistype( data[ GetHandleId( GetTriggerUnit( ) ) ] ).defense )
            endif
        endmethod


        private static method onIllusionDeath takes nothing returns nothing
            if IsUnitInGroup( GetDyingUnit( ), thistype.illusions ) then
                call GroupRemoveUnit( thistype.illusions, GetDyingUnit( ) )

                set  thistype( data[ GetHandleId( GetDyingUnit( ) ) ] ).prev.next  =  thistype( data[ GetHandleId( GetDyingUnit( ) ) ] ).next
                set  thistype( data[ GetHandleId( GetDyingUnit( ) ) ] ).next.prev  =  thistype( data[ GetHandleId( GetDyingUnit( ) ) ] ).prev

                if ( thistype( 0 ).next == 0 ) then
                    call PauseTimer( thistype.period )
                endif

                call thistype.deallocate( thistype( data[ GetHandleId( GetDyingUnit( ) ) ] ) )
            endif
        endmethod


        private static method onInit takes nothing returns nothing
            set  thistype.data       =  table.create( )
            set  thistype.period     =  CreateTimer( )
            set  thistype.trig       =  CreateTrigger( )
            set  thistype.illusions  =  CreateGroup( )
            set  thistype.summoner   =  CreateUnit( Player( PLAYER_NEUTRAL_PASSIVE ), DUMMY_UNIT_ID, HIDDEN_X, HIDDEN_Y, bj_UNIT_FACING )

            call UnitAddAbility     ( thistype.summoner, 'Aloc' )
            call SetUnitInvulnerable( thistype.summoner, true   )
            call UnitAddAbility     ( thistype.summoner, 'A00A' )
            call SetUnitPathing     ( thistype.summoner, false  )
            call UnitRemoveAbility  ( thistype.summoner, 'Amov' )

            call TriggerRegisterUnitEvent( thistype.trig, thistype.summoner, EVENT_UNIT_SUMMON )
            call TriggerAddAction        ( thistype.trig, function thistype.onIllusionSummon   )
        endmethod


    endstruct


endlibrary
Чтобы оставить комментарий, пожалуйста, войдите на сайт.