返回列表 发帖

[历史] 生命体AI跳错

情况如图

求解答~

没人知道么-.-

TOP

if object == 0 then
        local actors = GetActors()
        for i,v in ipairs(actors) do
                if (v ~= OwnerID and v ~= MyID) then
                        if (0 == IsMonster(v)) then
                        object = GetEnemyOf(v)
                        if GetV(V_MOTION, object) == MOTION_DEAD then
                                object = 0
                        end
                        if (object ~= 0) then

                if ((GetV (V_HOMUNTYPE, v) < 1) or (GetV (V_HOMUNTYPE, v) > 16)) then                        DoSkill_AAS(AAH, v)
                                break
                        end
                        end
                        end


是这段么

TOP

搜过了 就这段有这个的

TOP

local object = 0


        -- 1: SAFETY FIRSTY! Is the homunculus is under attack?
        local Agressor = GetMyEnemy_AttackingMe(MyID) -- get TactData too
        local AgBehav, AgSkill, AgLevel, AgAlche
        if Agressor ~= 0 then
                if (HomunHPPerc < HP_PERC_DANGER) or (HTact.Behav == BEHA_avoid) or (HTact.Behav == BEHA_coward) then
                        MyState = EVADE_ST -- flee away if HP < secure level
                        MyEnemy = Agressor
                        Evade_ComeBackTime = EVADE_COMEBACK
                        Log(string.format("[ -> EVADE_ST] GetMyNextTarget() attacked by enemy(%d) (avoid/coward mode or while HP < HP_PERC_DANGER)", MyEnemy))
                        return 0
                else -- we are not in danger for now: save these data and let's check for other threats first
         AgBehav = HTact.Behav
         AgSkill = HTact.Skill
         AgLevel = HTact.Level
         AgAlche = HTact.Alche
         if KILL_YOUR_ENEMIES_1ST == true then -- ... unless KILL_YOUR_ENEMIES_1ST is enabled
                                Log(string.format("GetMyNextTarget() <defensive scan + KILL_YOUR_ENEMIES_1ST> attacked by enemy(%d)", Agressor))
                      HTact.Behav = AgBehav
                      HTact.Skill = AgSkill
                      HTact.Level = AgLevel
                      HTact.Alche = AgAlche
                                return Agressor
                        end
                end
        end

        -- 2: if the owner or a friend is under attack, help him/her

        object = GetEnemyOf(OwnerID)
        if object ~= 0 then
                if GetV(V_MOTION, object) == MOTION_DEAD then
                        object = 0
                end
        end
        if object == 0 then
        local actors = GetActors()
        for i,v in ipairs(actors) do
                if (v ~= OwnerID and v ~= MyID) then
                        if (0 == IsMonster(v)) then
                        object = GetEnemyOf(v)
                        if GetV(V_MOTION, object) == MOTION_DEAD then
                                object = 0
                        end
                        if (object ~= 0) then

                if ((GetV (V_HOMUNTYPE, v) < 1) or (GetV (V_HOMUNTYPE, v) > 16)) then                        DoSkill_AAS(AAH, v)
                                break
                        end
                        end
                        end
                end
                end
        end
        if object ~= 0 then
                Log(string.format("GetMyNextTarget() the owner or a friend is attacked by enemy(%d):", object))
                HTact = GetFullTact(GetV(V_HOMUNTYPE, object))
                if (HTact.Behav ~= BEHA_avoid) then
                        return object
                end
        end

        -- 3: if the homunculus is under attack (and his/her life is not in danger, see priority 1)
        if Agressor ~= 0 then
                Log(string.format("GetMyNextTarget() <defensive scan> attacked by enemy(%d)", Agressor))
                HTact.Behav = AgBehav
                HTact.Skill = AgSkill
                  HTact.Level = AgLevel
                    HTact.Alche = AgAlche
                return Agressor
        end

        -- 4: if the owner or a friend is attacking --> cooperate
        local OwnerMotion = GetV(V_MOTION, OwnerID)
        local CooTarget = 0
        object = GetV(V_TARGET, OwnerID)
        if (object ~= 0) and (OwnerMotion == MOTION_ATTACK or OwnerMotion == MOTION_ATTACK2) then
           CooTarget = object
        end
        if CooTarget == 0 then -- Owner is not attacking. Maybe a friend?
                local FriendMotion = 0
                for i,v in Friends do
                if (v ~= OwnerID and v ~= MyID) then
                        if (0 == IsMonster(v)) then
                        object = GetV(V_TARGET, v)
                        FriendMotion = GetV(V_MOTION, v)
                        if (object ~= 0) and (FriendMotion == MOTION_ATTACK or FriendMotion == MOTION_ATTACK2) then
                                CooTarget = object
                                break
                        end
                        end
                end
                end
        end
        if CooTarget ~= 0 then
                Log(string.format("GetMyNextTarget() cooperative target(%d) found:", CooTarget))
                HTact = GetFullTact(GetV(V_HOMUNTYPE, CooTarget))
                if (HTact.Behav ~= BEHA_avoid) then
                        return CooTarget
                end
        end

        -- 5: aggressive, if HPs are OK and a target is near
        if HomunHPPerc > HP_PERC_SAFE2ATK
        then
                object = GetMyEnemy_AnyNoKS(MyID) -- get TactData too
                if (object ~= 0) then
                        Log(string.format("GetMyNextTarget() <aggressive scan> target(%d) found", object))
                        return object
                end
        end

        return 0
end

TOP

-- Log("OnIDLE_ST")

        local cmd = List.popleft(ResCmdList)
        if (cmd ~= nil) then
                ProcessCommand(cmd)
                return
        end

        AtkStartTime = 0
        AtkSkillDoneCount = 0
        HTact.Behav = -1
        HTact.Skill = -1

        local CurrTime = GetTick()

        local HomunHP = GetV(V_HP, MyID)
        local HomunMaxHP = GetV(V_MAXHP, MyID)
        local HomunHPPerc = (HomunHP / HomunMaxHP) * 100
        local HomunSP = GetV(V_SP, MyID)
        local HomunMaxSP = GetV(V_MAXSP, MyID)
        OwnerMotion = GetV(V_MOTION, OwnerID)

        -- Heal wounds

        if GetV(V_HP, OwnerID) < GetV(V_MAXHP, OwnerID) - 560 then
                        DoSkill_AAS(AAH, OwnerID)

        end



就这有一个 其他都没了

TOP

AI。LUA里的都没少 换个AI算了- - 多谢版主。。

TOP

返回列表