채팅0

    잘알들 와바 이거 가능?

    조회수 490

    return function (self, mob)

    if zz_y7.use_momo then

    local ai = mob.MobAIComponent

    local kb = mob.MobKnockbackComponent

    local rb = mob.MobRigidbodyComponent

        if (not isvalid(rb) or not isvalid(kb) or not isvalid(ai)) then
            log_warning("Invalid components.")
            return
        end
    
        local target = _UserService.LocalPlayer
        local nextAction = 0
        local inputX = nil
        local inputY = nil
        local mobPos = mob.TransformComponent.WorldPosition
        local mobX = mobPos.x
        local mobY = mobPos.y
        local abs = math.abs
        local sqrt = math.sqrt
    
        local platformInfo = mob.CurrentMap.PlatformInfoComponent
        local platforms = platformInfo.Platforms
        local elapse = 0.09
        local state = {
            Position = mobPos:ToVector2(),
            Velocity = ai.LastLocalVelocity
        }
        local timelines = {}
        local timelineIndex = 0
        local lastDuration = 0
        local currentX, currentY = mobX, mobY
    
        local function makeDistance(x1, y1, x2, y2)
            return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
        end
    
        local function makeCommand(cmd, destX, destY, floating, layer)
            local distance = makeDistance(currentX, currentY, destX, destY) 
            currentX = destX
            currentY = destY
            local duration = distance / (rb.FlySpeed * _Physics.FlySpeed / 1)
            
            timelines[timelineIndex + 1] = {cmd, {destX, destY, duration, floating, layer}, lastDuration}
            timelineIndex = timelineIndex + 1
            lastDuration = duration
            return duration
        end
    
        kb:SetShoeAttr(0)
    
        if (isvalid(target)) then
            nextAction = _GlobalRand32:RandomIntegerRange(120, 140) / 1000
            local spawnX = _GlobalRand32:RandomDouble() * 5 + 10  -- 임의의 오른쪽 위치에서 생성
            local spawnY = mobY
            makeCommand(_MobActionPartType.Walk, spawnX, spawnY, false, "Npc")
        else
            nextAction = (_GlobalRand32:RandomIntegerRange(540, 550) / 1000)
            local platformCandidates = {}
            local platformCandidatesNum = 0
            
            local function findTryingPlatformCandidates(range)
                for i=1, #platforms do
                    local checkPlatform = platforms[i]
                    local left = checkPlatform.left
                    local right = checkPlatform.right
                    if (left.x == right.x) then
                        goto continue
                    end
                    local centerX = (left.x + right.x) / 2
                    local centerY = (left.y + right.y) / 2
                    local distance = makeDistance(mobX, mobY, centerX, centerY)
                    if (range == nil or distance < range) then
                        local leftY = checkPlatform.left.y
                        local rightY = checkPlatform.right.y
                        local leftX = checkPlatform.left.x
                        local rightX = checkPlatform.right.x
                        if (abs(leftY - rightY) > 0.5) then
                            goto continue
                        end
                        if (abs(leftX - rightX) < 1) then
                            goto continue
                        end
                        platformCandidates[platformCandidatesNum + 1] = checkPlatform
                        platformCandidatesNum = platformCandidatesNum + 1
                    end
                    ::continue::
                end
            end
    
            local level = {36, 72}
            for i=1,3 do
                findTryingPlatformCandidates(level[i])
                if (platformCandidatesNum > 0) then
                    break
                end
            end
    
            if (platformCandidatesNum > 0) then
                local function makeFloatingYOffset()
                    return _GlobalRand32:RandomIntegerRange(-30, 80) / 100
                end
    
                local platform = platformCandidates[_GlobalRand32:RandomIntegerRange(1, platformCandidatesNum)]
                local destX = platform.left.x + (_GlobalRand32:RandomDouble() * (platform.right.x - platform.left.x))
                local destY = platform.left.y + makeFloatingYOffset()
                local moveToTargetPlatform = true
                
                -- 플랫폼으로 이동
                nextAction = nextAction + makeCommand(_MobActionPartType.Walk, destX, destY, false, "Npc")
                
                -- 배회 시작
                inputX = _GlobalRand32:RandomDouble() < 0.5 and -1 or 1
                while (elapse < nextAction) do
                    if (inputX > 0) then
                        elapse = elapse + makeCommand(_MobActionPartType.Walk, platform.right.x, destY, true, "Npc")
                        inputX = -1
                    else
                        elapse = elapse + makeCommand(_MobActionPartType.Walk, platform.left.x, destY, true, "Npc")
                        inputX = 1
                    end
                end
                
                -- 마지막 Walk 액션
                if (inputX > 0) then
                    makeCommand(_MobActionPartType.Walk, platform.right.x, destY, true, "Npc")
                else
                    makeCommand(_MobActionPartType.Walk, platform.left.x, destY, true, "Npc")
                end
            end
        end
    
        if (timelineIndex > 0) then
            mob.CurrentMap.LifeControllerComponent:RequestControl(mob, timelines, timelineIndex, true)
        end
        ai:EnableNextControlTimer(nextAction)
    end

    end

    댓글3

    회원프로필

    _MobActionPartType.Walk 라는 것 자체가 정의되어있질 않음

    2024.01.27 01:39
    회원프로필

    안되ㅏ는거누

    2024.01.27 01:41
    회원프로필

    z

    2024.01.27 01:42

      게시글 리스트
      제목작성자작성일조회
      1889801-27633
      1889701-27351
      1889601-27557
      1889501-27288
      18894
      +2
      01-27247
      1889301-27457
      1889201-27590
      1889101-27248
      1889001-27174
      1888901-27735
      1888801-27383
      1888701-27648
      1888601-27733
      1888501-27491
      1888401-27292
      1888301-27544
      1888201-27728
      1888101-27196
      1888001-27269
      1887901-27380
      안내 배너 이미지