魔兽地图编辑器吧 关注:65,069贴子:3,836,980
  • 24回复贴,共1

求助:GetAttacker 崩溃问题。

只看楼主收藏回复

一,首先根据百度的情况:
1,没有关闭当前触发。2,当前触发没有等待
二,然后,上图:

三,再然后上代码
function i1lI11 takes nothing returns nothing
local group g
local group g2
local location p=GetUnitLoc(GetTriggerUnit())
local location p2=GetUnitLoc(GetAttacker())
set g=I1lIi(300,p,Condition(function i1liI1))
set g2=I1lIi(300,p2,Condition(function i1liI1))
call GroupAddGroup(g2,g)
call ForGroupBJ(g,function i1lii1)
call DestroyGroup(g)
call DestroyGroup(g2)
call RemoveLocation(p)
call RemoveLocation(p2)
set g=null
set p=null
set g2=null
set p2=null
endfunction
四,最后,拜谢各位能帮忙的大佬,求助
多么简单的几句jass啊,,还是要崩溃,,我能怎么办呢,我也很绝望啊


IP属地:湖南1楼2017-05-27 08:48回复
    然后,这个问题不是每次都崩溃的,这个触发是经常运行的一个被攻击事件,
    有时候打到结束都没事,有时打一段时间后就崩溃了。不是必然崩溃的


    IP属地:湖南2楼2017-05-27 08:50
    回复
      @actboy168 求助


      IP属地:湖南3楼2017-05-27 10:43
      回复
        你的i1lil1也放出来呀


        IP属地:湖南来自Android客户端4楼2017-05-27 10:51
        回复
          function i1liI1 takes nothing returns boolean
          if(IsPlayerInForce(GetOwningPlayer(GetTriggerUnit()),lil1))then
          if((GetOwningPlayer(GetFilterUnit())==Player(0))and(IsUnitAliveBJ(GetFilterUnit())))then
          return true
          endif
          endif
          if(IsPlayerInForce(GetOwningPlayer(GetTriggerUnit()),lii1))then
          if((GetOwningPlayer(GetFilterUnit())==Player(1))and(IsUnitAliveBJ(GetFilterUnit())))then
          return true
          endif
          endif
          return false
          endfunction


          IP属地:湖南5楼2017-05-27 10:59
          回复
            只是一个条件而已,,


            IP属地:湖南6楼2017-05-27 10:59
            回复
              我直接上源码吧


              IP属地:湖南7楼2017-05-27 10:59
              回复
                function PHConditon takes nothing returns boolean
                if ( not ( IsUnitType(GetAttacker(), UNIT_TYPE_STRUCTURE) == false ) ) then
                return false
                endif
                return true
                endfunction
                function atack_timer takes nothing returns nothing
                local timer t=GetExpiredTimer()
                local unit u=GetUnit(H2Tx(t),"PHu")
                local real X=GetReal(H2Tx(u)+"PH","PHX")
                local real Y=GetReal(H2Tx(u)+"PH","PHY")
                call IssuePointOrder( u, "attack", X, Y )
                //call DisplayTextToForce( GetPlayersAll(), "attact point" )
                call DestroyTimer(t)
                set t=null
                endfunction
                function attack_Condition takes nothing returns nothing
                local unit u = GetEnumUnit()
                local timer t = CreateTimer()
                call IssueTargetOrder( u, "attack", GetAttacker() )
                //call DisplayTextToForce( GetPlayersAll(), "attact unit" )
                call TimerStart(t, 3.00, false, function atack_timer)
                call SetUnit(H2Tx(t),"PHu",u)
                set u =null
                endfunction
                function PHCondition_2 takes nothing returns boolean
                if(IsPlayerInForce(GetOwningPlayer(GetTriggerUnit()), udg_PlayerTeamA) == true) then
                if( (GetOwningPlayer(GetFilterUnit())==Player(0)) and (IsUnitAliveBJ(GetFilterUnit()) == true) ) then
                return true
                endif
                endif
                if(IsPlayerInForce(GetOwningPlayer(GetTriggerUnit()), udg_PlayerTeamB) == true) then
                if( (GetOwningPlayer(GetFilterUnit())==Player(1)) and (IsUnitAliveBJ(GetFilterUnit()) == true) ) then
                return true
                endif
                endif
                return false
                endfunction
                function PH_Action takes nothing returns nothing
                local group g
                local group g2
                local location p=GetUnitLoc(GetTriggerUnit())
                local location p2=GetUnitLoc(GetAttacker())
                set g=GetUnitsInRangeOfLocMatching(300,p,Condition(function PHCondition_2))
                set g2=GetUnitsInRangeOfLocMatching(300,p2,Condition(function PHCondition_2))
                call GroupAddGroup(g2,g)
                call ForGroupBJ( g, function attack_Condition )
                call DestroyGroup(g)
                call DestroyGroup(g2)
                call RemoveLocation(p)
                call RemoveLocation(p2)
                set g=null
                set p=null
                set g2=null
                set p2=null
                endfunction
                //===========================================================================
                function InitTrig_ProtectHeroes_t takes nothing returns nothing
                set gg_trg_ProtectHeroes_t = CreateTrigger()
                //ifdef DEBUG
                //call YDWESaveTriggerName(gg_trg_ProtectHeroes_t, "ProtectHeroes_t")
                //endif
                call TriggerRegisterAnyUnitEventBJ( gg_trg_ProtectHeroes_t, EVENT_PLAYER_UNIT_ATTACKED )
                call TriggerAddCondition(gg_trg_ProtectHeroes_t, Condition(function PHConditon))
                call TriggerAddAction(gg_trg_ProtectHeroes_t, function PH_Action)
                endfunction


                IP属地:湖南8楼2017-05-27 11:02
                回复
                  就是一个保护英雄的小兵AI,,不知道DOTA是怎么做的,,难道DOTA不崩吗?


                  IP属地:湖南9楼2017-05-27 11:02
                  收起回复
                    几年前就有人讨论过了,本吧搜索搜 GetAttacker


                    IP属地:北京来自Android客户端10楼2017-05-27 12:05
                    收起回复
                      …喵呜嚼梨


                      IP属地:广东来自Android客户端11楼2017-05-27 12:13
                      回复
                        签到签到啦


                        IP属地:福建12楼2017-05-27 13:26
                        回复