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
local hasAI = ai ~= nil and 1 or 0
local hasKnockback = kb ~= nil and 1 or 0
local hasRigid = rb ~= nil and 1 or 0
log_warning(string.format("hasAI: %d hasKnockback: %d hasRigid: %d", hasAI, hasKnockback, hasRigid))
return
end
    local target = _UserService.LocalPlayer
    local nextAction = 0
    local inputX = nil
    local inputY = nil
    local mobPos = mob.TransformComponent.WorldPosition
    local mobX = boundLt.x + 0.1
    local mobY = boundRb.x - 0.1
    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
    ---@param destX number
    ---@param destY number
    ---@param floating boolean
    ---@return number
    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 targetPos = target.TransformComponent.WorldPosition:ToVector2()
        local targetX = targetPos.x
        local targetY = targetPos.y
        local dirVecX, dirVecY = targetX - mobPos.x, targetY - mobPos.y
        dirVecX = dirVecX * 1
        dirVecY = dirVecY * 1
        targetX = mobPos.x + dirVecX - -0.8 
        targetY = mobPos.y + dirVecY - -0.2 
        --local userLayer = _UserService.LocalPlayer.AvatarRendererComponent.SortingLayer
        makeCommand(_MobActionPartType.Fly, targetX, targetY, math.abs(targetY - mobPos.y) < 0.6, "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.Fly, 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.Fly, platform.right.x, destY, true, "Npc")
                    inputX = -1
                else
                    elapse = elapse + makeCommand(_MobActionPartType.Fly, platform.left.x, destY, true, "Npc")
                    inputX = 1
                end
            end| 제목 | 작성자 | 작성일 | 조회 | |
|---|---|---|---|---|
| 9315 | 02-17 | 290 | ||
| 9314 | 02-17 | 280 | ||
| 9313 | 02-17 | 675 | ||
| 9312 | 02-17 | 261 | ||
| 9311 | 02-17 | 471 | ||
| 9310 | 02-17 | 341 | ||
| 9309 | 02-17 | 565 | ||
| 9308 | 02-17 | 688 | ||
| 9307 | 02-17 | 413 | ||
| 9306 | 02-17 | 399 | ||
| 9305 | 02-17 | 508 | ||
| 9304 | 02-17 | 506 | ||
| 9303 | 02-17 | 500 | ||
| 9302 | 02-17 | 578 | ||
| 9301 | 02-17 | 421 | ||
| 9300 | 02-17 | 485 | ||
| 9299 | 02-17 | 292 | ||
| 9298 | 02-17 | 300 | ||
| 9297 | 02-17 | 401 | ||
| 9296 | 02-17 | 336 | 
댓글1
뭐허냐