Решил сделать подобное воскрешение и в своей карте, но не совсем понимаю, как такое реализовать.
  1. В первую очередь в голову пришла способность торнадо. Слышал, что с помощью них реализованы телепортации в Dota 1. А индикатор воскрешения можно будет сделать с помощью texttag'ов "IIIIIIIIIIIIIIIIII", а полоску прогресса показывать сменой цвета этих полосочек.
  1. Дальше пришла в голову другая идея. Думаю, можно сделать с помощью ремонта зданий Альянса: на месте смерти героя создаётся здание с моделью креста со здоровьем 1/100 ед., а союзные герои ремонтируя крест будут повышать её здоровье, получается некая иллюзия прогресс бара. И если спрятать способность ремонта с помощью функции HideAbilityButton( ) из мемхака, то будет ли она срабатывать при нажатии на ПКМ? Также, как отловить момент полного ремонта здания? С помощью таймера проверять процент здоровья каждые доли секунды?
- Если, кто не видел
На 8:50 умирает герой.

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

Реализовал через второй вариант:
Дальше пришла в голову другая идея. Думаю, можно сделать с помощью ремонта зданий Альянса: на месте смерти героя создаётся здание с моделью креста со здоровьем 1/100 ед., а союзные герои ремонтируя крест будут повышать её здоровье, получается некая иллюзия прогресс бара. И если спрятать способность ремонта с помощью функции HideAbilityButton( ) из мемхака, то будет ли она срабатывать при нажатии на ПКМ? Также, как отловить момент полного ремонта здания? С помощью таймера проверять процент здоровья каждые доли секунды?
раскрыть
scope HeroRevive initializer Initialization


    struct herorevive
        private                    unit           dyingUnit
        private                    unit           reincarnate
        private                    real           life

        private                    thistype       prev
        private                    thistype       next

        public   static  constant  trigger        trig    =  CreateTrigger( )
        public   static  constant  timer          period  =  CreateTimer( )


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

            loop
                exitwhen ( this == 0 )

                if ( GetWidgetLife( this.reincarnate ) > this.life ) then
                    set  this.life  =  GetWidgetLife( this.reincarnate )

                elseif ( GetWidgetLife( this.reincarnate ) >= GetUnitState( this.reincarnate, UNIT_STATE_MAX_LIFE ) ) then
                    call ReviveHero( this.dyingUnit, GetUnitX( this.dyingUnit ), GetUnitY( this.dyingUnit ), true )
                    call RemoveUnit( this.reincarnate )

                    set  this.reincarnate  =  null
                    set  this.life         =  0.0

                    set  this.prev.next    =  this.next
                    set  this.next.prev    =  this.prev

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

                    call thistype.deallocate( this )

                elseif ( GetWidgetLife( this.reincarnate ) <= this.life ) then
                    set  this.life  =  1.0
                    call SetWidgetLife( this.reincarnate, this.life )
                endif

                set this = this.next

            endloop
        endmethod


        public static method actions takes nothing returns nothing
            local  thistype  this  =  thistype.allocate( )

            set  this.next         =  0
            set  this.prev         =  thistype( 0 ).prev
            set  this.next.prev    =  this
            set  this.prev.next    =  this

            set  this.dyingUnit    =  GetDyingUnit( )
            set  this.reincarnate  =  CreateUnit( GetOwningPlayer( this.dyingUnit ), 'h003', GetUnitX( this.dyingUnit ), GetUnitY( this.dyingUnit ), 0.0 )
            set  this.life         =  1.0

            call SetUnitPathing( this.reincarnate, false )
            call SetWidgetLife( this.reincarnate, this.life )

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


        public static constant method conditions takes nothing returns boolean
            return IsUnitType( GetDyingUnit( ), UNIT_TYPE_HERO )
        endmethod


    endstruct


    public function Initialization takes nothing returns nothing
        call TriggerRegisterPlayerUnitEvent( herorevive.trig, Player( 1 ), EVENT_PLAYER_UNIT_DEATH, null )
        call TriggerRegisterPlayerUnitEvent( herorevive.trig, Player( 2 ), EVENT_PLAYER_UNIT_DEATH, null )
        call TriggerRegisterPlayerUnitEvent( herorevive.trig, Player( 3 ), EVENT_PLAYER_UNIT_DEATH, null )
        call TriggerRegisterPlayerUnitEvent( herorevive.trig, Player( 4 ), EVENT_PLAYER_UNIT_DEATH, null )

        call TriggerAddCondition( herorevive.trig, Condition( function herorevive.conditions ) )
        call TriggerAddAction( herorevive.trig, function herorevive.actions )
    endfunction


endscope
Вот только если спрятать кнопку через HideAbilityButton( ), то способность ремонта зданий исчезает и не работает через ПКМ.
0
21
6 лет назад
0
Реализовал через второй вариант:
Дальше пришла в голову другая идея. Думаю, можно сделать с помощью ремонта зданий Альянса: на месте смерти героя создаётся здание с моделью креста со здоровьем 1/100 ед., а союзные герои ремонтируя крест будут повышать её здоровье, получается некая иллюзия прогресс бара. И если спрятать способность ремонта с помощью функции HideAbilityButton( ) из мемхака, то будет ли она срабатывать при нажатии на ПКМ? Также, как отловить момент полного ремонта здания? С помощью таймера проверять процент здоровья каждые доли секунды?
раскрыть
scope HeroRevive initializer Initialization


    struct herorevive
        private                    unit           dyingUnit
        private                    unit           reincarnate
        private                    real           life

        private                    thistype       prev
        private                    thistype       next

        public   static  constant  trigger        trig    =  CreateTrigger( )
        public   static  constant  timer          period  =  CreateTimer( )


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

            loop
                exitwhen ( this == 0 )

                if ( GetWidgetLife( this.reincarnate ) > this.life ) then
                    set  this.life  =  GetWidgetLife( this.reincarnate )

                elseif ( GetWidgetLife( this.reincarnate ) >= GetUnitState( this.reincarnate, UNIT_STATE_MAX_LIFE ) ) then
                    call ReviveHero( this.dyingUnit, GetUnitX( this.dyingUnit ), GetUnitY( this.dyingUnit ), true )
                    call RemoveUnit( this.reincarnate )

                    set  this.reincarnate  =  null
                    set  this.life         =  0.0

                    set  this.prev.next    =  this.next
                    set  this.next.prev    =  this.prev

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

                    call thistype.deallocate( this )

                elseif ( GetWidgetLife( this.reincarnate ) <= this.life ) then
                    set  this.life  =  1.0
                    call SetWidgetLife( this.reincarnate, this.life )
                endif

                set this = this.next

            endloop
        endmethod


        public static method actions takes nothing returns nothing
            local  thistype  this  =  thistype.allocate( )

            set  this.next         =  0
            set  this.prev         =  thistype( 0 ).prev
            set  this.next.prev    =  this
            set  this.prev.next    =  this

            set  this.dyingUnit    =  GetDyingUnit( )
            set  this.reincarnate  =  CreateUnit( GetOwningPlayer( this.dyingUnit ), 'h003', GetUnitX( this.dyingUnit ), GetUnitY( this.dyingUnit ), 0.0 )
            set  this.life         =  1.0

            call SetUnitPathing( this.reincarnate, false )
            call SetWidgetLife( this.reincarnate, this.life )

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


        public static constant method conditions takes nothing returns boolean
            return IsUnitType( GetDyingUnit( ), UNIT_TYPE_HERO )
        endmethod


    endstruct


    public function Initialization takes nothing returns nothing
        call TriggerRegisterPlayerUnitEvent( herorevive.trig, Player( 1 ), EVENT_PLAYER_UNIT_DEATH, null )
        call TriggerRegisterPlayerUnitEvent( herorevive.trig, Player( 2 ), EVENT_PLAYER_UNIT_DEATH, null )
        call TriggerRegisterPlayerUnitEvent( herorevive.trig, Player( 3 ), EVENT_PLAYER_UNIT_DEATH, null )
        call TriggerRegisterPlayerUnitEvent( herorevive.trig, Player( 4 ), EVENT_PLAYER_UNIT_DEATH, null )

        call TriggerAddCondition( herorevive.trig, Condition( function herorevive.conditions ) )
        call TriggerAddAction( herorevive.trig, function herorevive.actions )
    endfunction


endscope
Вот только если спрятать кнопку через HideAbilityButton( ), то способность ремонта зданий исчезает и не работает через ПКМ.
Принятый ответ
Чтобы оставить комментарий, пожалуйста, войдите на сайт.