(
    ----------------------------------------------------------------
    -- 1. シーン設定とヘルパー配置（A1からC5まで拡張）
    ----------------------------------------------------------------
    delete objects

    -- パラメータ（元の値を保持しつつ、拡張に対応）
    global g_spacing   = 20.0  -- ヘルパー間の間隔（同系列内）
    global g_zHeight   = 0.0
    global g_size      = 10.0
    global g_targetDist = 20.0  -- 系列間の固定距離

    -- ヘルパー生成（A1からC5まで15個）とグローバル変数への割り当て
    -- Helper_A系列 (Y=+g_spacing)
    global g_hpA1 = Point name:"Helper_A1" pos:[0,           g_spacing, g_zHeight] size:g_size wirecolor:red cross:true box:false
    global g_hpA2 = Point name:"Helper_A2" pos:[g_spacing,   g_spacing, g_zHeight] size:g_size wirecolor:green cross:true box:false
    global g_hpA3 = Point name:"Helper_A3" pos:[g_spacing*2, g_spacing, g_zHeight] size:g_size wirecolor:blue cross:true box:false
    global g_hpA4 = Point name:"Helper_A4" pos:[g_spacing*3, g_spacing, g_zHeight] size:g_size wirecolor:yellow cross:true box:false
    global g_hpA5 = Point name:"Helper_A5" pos:[g_spacing*4, g_spacing, g_zHeight] size:g_size wirecolor:orange cross:true box:false

    -- Helper_B系列 (Y=0)
    global g_hpB1 = Point name:"Helper_B1" pos:[0,           0, g_zHeight] size:g_size wirecolor:white cross:true box:false
    global g_hpB2 = Point name:"Helper_B2" pos:[g_spacing,   0, g_zHeight] size:g_size wirecolor:gray cross:true box:false
    global g_hpB3 = Point name:"Helper_B3" pos:[g_spacing*2, 0, g_zHeight] size:g_size wirecolor:(color 255 0 255) cross:true box:false
    global g_hpB4 = Point name:"Helper_B4" pos:[g_spacing*3, 0, g_zHeight] size:g_size wirecolor:(color 0 255 255) cross:true box:false
    global g_hpB5 = Point name:"Helper_B5" pos:[g_spacing*4, 0, g_zHeight] size:g_size wirecolor:(color 255 255 0) cross:true box:false

    -- Helper_C系列 (Y=-g_spacing)
    global g_hpC1 = Point name:"Helper_C1" pos:[0,           -g_spacing, g_zHeight] size:g_size wirecolor:(color 128 0 0) cross:true box:false
    global g_hpC2 = Point name:"Helper_C2" pos:[g_spacing,   -g_spacing, g_zHeight] size:g_size wirecolor:(color 0 128 0) cross:true box:false
    global g_hpC3 = Point name:"Helper_C3" pos:[g_spacing*2, -g_spacing, g_zHeight] size:g_size wirecolor:(color 0 0 128) cross:true box:false
    global g_hpC4 = Point name:"Helper_C4" pos:[g_spacing*3, -g_spacing, g_zHeight] size:g_size wirecolor:(color 128 128 0) cross:true box:false
    global g_hpC5 = Point name:"Helper_C5" pos:[g_spacing*4, -g_spacing, g_zHeight] size:g_size wirecolor:(color 128 0 128) cross:true box:false

    -- リンク設定（チェーン構造）
    g_hpA2.parent = g_hpA1; g_hpA3.parent = g_hpA2; g_hpA4.parent = g_hpA3; g_hpA5.parent = g_hpA4
    g_hpB2.parent = g_hpB1; g_hpB3.parent = g_hpB2; g_hpB4.parent = g_hpB3; g_hpB5.parent = g_hpB4
    g_hpC2.parent = g_hpC1; g_hpC3.parent = g_hpC2; g_hpC4.parent = g_hpC3; g_hpC5.parent = g_hpC4

    -- 親をフリーズ（各系列の1番目）
    g_hpA1.isFrozen = true
    g_hpB1.isFrozen = true
    g_hpC1.isFrozen = true

    format "Helpers created and linked (A1-C5).\n"

    ----------------------------------------------------------------
    -- 2. キー修復システム（ティーポット方式）
    ----------------------------------------------------------------
    global g_isAdjusting = false
    global g_expectedKeyValues = #() -- 構造: #( #(Helper, Time, LocalPos), ... )

    -- 期待値データベース初期化関数 (内容は変更なし)
    fn initExpectedValues helpersList =
    (
        g_expectedKeyValues = #()
        for h_obj in helpersList do
        (
            local currentCtrl = h_obj.pos.controller
            if classof currentCtrl == Position_XYZ then
            (
                local allTimes = #()
                join allTimes (for k_item in currentCtrl.X_Position.controller.keys collect k_item.time)
                join allTimes (for k_item in currentCtrl.Y_Position.controller.keys collect k_item.time)
                join allTimes (for k_item in currentCtrl.Z_Position.controller.keys collect k_item.time)
                makeUniqueArray allTimes
                for t_val in allTimes do
                (
                    local currentLocalPos = at time t_val (in coordsys parent h_obj.pos)
                    append g_expectedKeyValues #(h_obj, t_val, currentLocalPos)
                )
            )
        )
    )

    -- キー修復関数 (内容は変更なし)
    fn repairKeys =
    (
        suspendEditing()
        try
        (
            for data_entry in g_expectedKeyValues do
            (
                local h_obj = data_entry[1]
                local time_val = data_entry[2]
                local local_pos = data_entry[3]
                local currentCtrl = h_obj.pos.controller
                if classof currentCtrl == Position_XYZ then
                (
                    local axisControllers = #(currentCtrl.X_Position.controller, currentCtrl.Y_Position.controller, currentCtrl.Z_Position.controller)
                    local axisValues = #(local_pos.x, local_pos.y, local_pos.z)
                    
                    for i_idx = 1 to 3 do
                    (
                        local currentAxisCtrl = axisControllers[i_idx]
                        local currentVal = axisValues[i_idx]
                        local foundKeyIdx = getKeyIndex currentAxisCtrl time_val
                        if foundKeyIdx > 0 then
                            currentAxisCtrl.keys[foundKeyIdx].value = currentVal
                        else
                        (
                            addNewKey currentAxisCtrl time_val
                            currentAxisCtrl.keys[(getKeyIndex currentAxisCtrl time_val)].value = currentVal
                        )
                    )
                )
            )
            format "キー修復完了 (Frame %)\n" sliderTime
        )
        catch
        (
            format "修復エラー: %\n" (getCurrentException())
        )
        resumeEditing()
    )

    -- 期待値更新関数 (内容は変更なし)
    fn updateExpectedValues helpersList currentFrame =
    (
        for h_obj in helpersList do
        (
            local currentLocalPos = in coordsys parent h_obj.pos
            local entryFound = false
            for i_idx = 1 to g_expectedKeyValues.count do
            (
                if g_expectedKeyValues[i_idx][1] == h_obj and g_expectedKeyValues[i_idx][2] == currentFrame then
                (
                    g_expectedKeyValues[i_idx][3] = currentLocalPos
                    entryFound = true
                    exit
                )
            )
            if not entryFound do
                append g_expectedKeyValues #(h_obj, currentFrame, currentLocalPos)
        )
    )

    ----------------------------------------------------------------
    -- 3. 移動イベントハンドラ（ロジック修正箇所）
    ----------------------------------------------------------------
    
    -- 安全なnormalize関数 (内容は変更なし)
    fn safeNormalize inputVec =
    (
        local vecLength = length inputVec
        if vecLength < 0.001 then [1,0,0] else inputVec / vecLength
    )

    -- A系列のヘルパーが動いた時の処理
    fn onASeriesMoved movedHelper =
    (
        if not g_isAdjusting then
        (
            g_isAdjusting = true
            local currentFrame = sliderTime
            local affectedHelpers = #()
            
            local aHelpers = #(g_hpA1, g_hpA2, g_hpA3, g_hpA4, g_hpA5)
            local bHelpers = #(g_hpB1, g_hpB2, g_hpB3, g_hpB4, g_hpB5)
            local cHelpers = #(g_hpC1, g_hpC2, g_hpC3, g_hpC4, g_hpC5)
            
            local movedIndex = findItem aHelpers movedHelper
            
            case movedIndex of
            (
                2: ( -- A2が動いた場合 (変更なし)
                    -- A1は不動なので、A2の位置をA1から固定距離に制限
                    local offsetVec = g_hpA2.pos - g_hpA1.pos
                    local expectedOffsetVec = safeNormalize(offsetVec) * g_spacing
                    if length offsetVec != g_spacing then
                        g_hpA2.pos = g_hpA1.pos + expectedOffsetVec
                    
                    -- A3以降を調整
                    for i = 3 to 5 do
                    (
                        local parentHelper = aHelpers[i-1]
                        local childHelper = aHelpers[i]
                        local currentOffset = childHelper.pos - parentHelper.pos
                        local fixedOffset = safeNormalize(currentOffset) * g_spacing
                        childHelper.pos = parentHelper.pos + fixedOffset
                    )
                    
                    -- B系列を調整（B2の位置をA2に合わせる）
                    local dirB = safeNormalize(g_hpB2.pos - g_hpA2.pos)
                    g_hpB2.pos = g_hpA2.pos + dirB * g_targetDist
                    -- B系列のB3以降も調整
                    for i = 3 to 5 do
                    (
                        local parentHelper = bHelpers[i-1]
                        local childHelper = bHelpers[i]
                        local currentOffset = childHelper.pos - parentHelper.pos
                        local fixedOffset = safeNormalize(currentOffset) * g_spacing
                        childHelper.pos = parentHelper.pos + fixedOffset
                    )

                    -- C系列を調整（C2の位置をA2に合わせる）
                    local dirC = safeNormalize(g_hpC2.pos - g_hpA2.pos)
                    g_hpC2.pos = g_hpA2.pos + dirC * g_targetDist * 2
                    -- C系列のC3以降も調整
                    for i = 3 to 5 do
                    (
                        local parentHelper = cHelpers[i-1]
                        local childHelper = cHelpers[i]
                        local currentOffset = childHelper.pos - parentHelper.pos
                        local fixedOffset = safeNormalize(currentOffset) * g_spacing
                        childHelper.pos = parentHelper.pos + fixedOffset
                    )
                )
                
                default: ( -- A3, A4, A5が動いた場合
                    -- 【修正箇所】移動したヘルパーの親を調整するループ
                    for i = movedIndex to 2 by -1 do
                    (
                        local childHelper = aHelpers[i]
                        local parentHelper = aHelpers[i-1]
                        
                        local offsetVec = childHelper.pos - parentHelper.pos
                        local expectedOffsetVec = safeNormalize(offsetVec) * g_spacing
                        
                        if length offsetVec != g_spacing then
                        (
                            if parentHelper.isFrozen then
                            (
                                -- 親(A1)がフリーズされている場合：親は動かさず、子(A2)を親基準で再配置
                                childHelper.pos = parentHelper.pos + expectedOffsetVec
                                
                                -- 子(i=2)が動いたので、それ以降の子(i+1から5)も連鎖的に再調整
                                for j = i+1 to 5 do
                                (
                                    local subsequentChild = aHelpers[j]
                                    local subsequentParent = aHelpers[j-1]
                                    local subsequentOffset = subsequentChild.pos - subsequentParent.pos
                                    local fixedSubsequentOffset = safeNormalize(subsequentOffset) * g_spacing
                                    subsequentChild.pos = subsequentParent.pos + fixedSubsequentOffset
                                )
                                -- フリーズされた親に到達したら、それ以上遡らない
                                exit
                            )
                            else
                            (
                                -- 親がフリーズされていない場合：親を子に合わせて動かす
                                parentHelper.pos = childHelper.pos - expectedOffsetVec
                            )
                        )
                    )
                    
                    -- 移動したヘルパーより後の子を調整 (変更なし)
                    for i = movedIndex+1 to 5 do
                    (
                        local childHelper = aHelpers[i]
                        local parentHelper = aHelpers[i-1]
                        local offsetVec = childHelper.pos - parentHelper.pos
                        if length offsetVec != g_spacing then
                            childHelper.pos = parentHelper.pos + safeNormalize(offsetVec) * g_spacing
                    )
                    
                    -- 他の系列を調整 (変更なし)
                    for i = 2 to 5 do
                    (
                        -- B系列
                        local dirB = safeNormalize(bHelpers[i].pos - aHelpers[i].pos)
                        bHelpers[i].pos = aHelpers[i].pos + dirB * g_targetDist
                        -- C系列
                        local dirC = safeNormalize(cHelpers[i].pos - aHelpers[i].pos)
                        cHelpers[i].pos = aHelpers[i].pos + dirC * g_targetDist * 2
                    )

                    -- B系列内の距離を再調整 (変更なし)
                    for i = 3 to 5 do
                    (
                        local parentHelper = bHelpers[i-1]
                        local childHelper = bHelpers[i]
                        local currentOffset = childHelper.pos - parentHelper.pos
                        local fixedOffset = safeNormalize(currentOffset) * g_spacing
                        childHelper.pos = parentHelper.pos + fixedOffset
                    )

                    -- C系列内の距離を再調整 (変更なし)
                    for i = 3 to 5 do
                    (
                        local parentHelper = cHelpers[i-1]
                        local childHelper = cHelpers[i]
                        local currentOffset = childHelper.pos - parentHelper.pos
                        local fixedOffset = safeNormalize(currentOffset) * g_spacing
                        childHelper.pos = parentHelper.pos + fixedOffset
                    )
                )
            )
            
            join affectedHelpers aHelpers
            join affectedHelpers bHelpers
            join affectedHelpers cHelpers
            
            updateExpectedValues affectedHelpers currentFrame
            repairKeys()
            g_isAdjusting = false
        )
    )

    -- B系列のヘルパーが動いた時の処理
    fn onBSeriesMoved movedHelper =
    (
        if not g_isAdjusting then
        (
            g_isAdjusting = true
            local currentFrame = sliderTime
            local affectedHelpers = #()
            
            local aHelpers = #(g_hpA1, g_hpA2, g_hpA3, g_hpA4, g_hpA5)
            local bHelpers = #(g_hpB1, g_hpB2, g_hpB3, g_hpB4, g_hpB5)
            local cHelpers = #(g_hpC1, g_hpC2, g_hpC3, g_hpC4, g_hpC5)
            
            local movedIndex = findItem bHelpers movedHelper
            
            case movedIndex of
            (
                2: ( -- B2が動いた場合 (変更なし)
                    local offsetVec = g_hpB2.pos - g_hpB1.pos
                    local expectedOffsetVec = safeNormalize(offsetVec) * g_spacing
                    if length offsetVec != g_spacing then
                        g_hpB2.pos = g_hpB1.pos + expectedOffsetVec
                    
                    for i = 3 to 5 do
                    (
                        local parentHelper = bHelpers[i-1]
                        local childHelper = bHelpers[i]
                        local currentOffset = childHelper.pos - parentHelper.pos
                        local fixedOffset = safeNormalize(currentOffset) * g_spacing
                        childHelper.pos = parentHelper.pos + fixedOffset
                    )
                    
                    -- A系列を調整（A2の位置をB2に合わせる）
                    local dirA = safeNormalize(g_hpA2.pos - g_hpB2.pos)
                    g_hpA2.pos = g_hpB2.pos + dirA * g_targetDist
                    for i = 3 to 5 do
                    (
                        local parentHelper = aHelpers[i-1]
                        local childHelper = aHelpers[i]
                        local currentOffset = childHelper.pos - parentHelper.pos
                        local fixedOffset = safeNormalize(currentOffset) * g_spacing
                        childHelper.pos = parentHelper.pos + fixedOffset
                    )
                    
                    -- C系列を調整
                    local dirC = safeNormalize(g_hpC2.pos - g_hpB2.pos)
                    g_hpC2.pos = g_hpB2.pos + dirC * g_targetDist
                    for i = 3 to 5 do
                    (
                        local parentHelper = cHelpers[i-1]
                        local childHelper = cHelpers[i]
                        local currentOffset = childHelper.pos - parentHelper.pos
                        local fixedOffset = safeNormalize(currentOffset) * g_spacing
                        childHelper.pos = parentHelper.pos + fixedOffset
                    )
                )
                
                default: ( -- B3, B4, B5が動いた場合
                    -- 【修正箇所】移動したヘルパーの親を調整するループ
                    for i = movedIndex to 2 by -1 do
                    (
                        local childHelper = bHelpers[i]
                        local parentHelper = bHelpers[i-1]

                        local offsetVec = childHelper.pos - parentHelper.pos
                        local expectedOffsetVec = safeNormalize(offsetVec) * g_spacing

                        if length offsetVec != g_spacing then
                        (
                            if parentHelper.isFrozen then
                            (
                                -- 親(B1)がフリーズされている場合：親は動かさず、子(B2)を親基準で再配置
                                childHelper.pos = parentHelper.pos + expectedOffsetVec
                                
                                -- 子(i=2)が動いたので、それ以降の子(i+1から5)も連鎖的に再調整
                                for j = i+1 to 5 do
                                (
                                    local subsequentChild = bHelpers[j]
                                    local subsequentParent = bHelpers[j-1]
                                    local subsequentOffset = subsequentChild.pos - subsequentParent.pos
                                    local fixedSubsequentOffset = safeNormalize(subsequentOffset) * g_spacing
                                    subsequentChild.pos = subsequentParent.pos + fixedSubsequentOffset
                                )
                                -- フリーズされた親に到達したら、それ以上遡らない
                                exit
                            )
                            else
                            (
                                -- 親がフリーズされていない場合：親を子に合わせて動かす
                                parentHelper.pos = childHelper.pos - expectedOffsetVec
                            )
                        )
                    )
                    
                    -- (変更なし)
                    for i = movedIndex+1 to 5 do
                    (
                        local childHelper = bHelpers[i]
                        local parentHelper = bHelpers[i-1]
                        local offsetVec = childHelper.pos - parentHelper.pos
                        if length offsetVec != g_spacing then
                            childHelper.pos = parentHelper.pos + safeNormalize(offsetVec) * g_spacing
                    )
                    
                    -- (変更なし)
                    for i = 2 to 5 do
                    (
                        local dirA = safeNormalize(aHelpers[i].pos - bHelpers[i].pos)
                        aHelpers[i].pos = bHelpers[i].pos + dirA * g_targetDist
                        
                        local dirC = safeNormalize(cHelpers[i].pos - bHelpers[i].pos)
                        cHelpers[i].pos = bHelpers[i].pos + dirC * g_targetDist
                    )

                    -- (変更なし)
                    for i = 3 to 5 do
                    (
                        local parentHelper = aHelpers[i-1]
                        local childHelper = aHelpers[i]
                        local currentOffset = childHelper.pos - parentHelper.pos
                        local fixedOffset = safeNormalize(currentOffset) * g_spacing
                        childHelper.pos = parentHelper.pos + fixedOffset
                    )

                    -- (変更なし)
                    for i = 3 to 5 do
                    (
                        local parentHelper = cHelpers[i-1]
                        local childHelper = cHelpers[i]
                        local currentOffset = childHelper.pos - parentHelper.pos
                        local fixedOffset = safeNormalize(currentOffset) * g_spacing
                        childHelper.pos = parentHelper.pos + fixedOffset
                    )
                )
            )
            
            join affectedHelpers aHelpers
            join affectedHelpers bHelpers
            join affectedHelpers cHelpers
            
            updateExpectedValues affectedHelpers currentFrame
            repairKeys()
            g_isAdjusting = false
        )
    )

    -- C系列のヘルパーが動いた時の処理
    fn onCSeriesMoved movedHelper =
    (
        if not g_isAdjusting then
        (
            g_isAdjusting = true
            local currentFrame = sliderTime
            local affectedHelpers = #()
            
            local aHelpers = #(g_hpA1, g_hpA2, g_hpA3, g_hpA4, g_hpA5)
            local bHelpers = #(g_hpB1, g_hpB2, g_hpB3, g_hpB4, g_hpB5)
            local cHelpers = #(g_hpC1, g_hpC2, g_hpC3, g_hpC4, g_hpC5)
            
            local movedIndex = findItem cHelpers movedHelper
            
            case movedIndex of
            (
                2: ( -- C2が動いた場合 (変更なし)
                    local offsetVec = g_hpC2.pos - g_hpC1.pos
                    local expectedOffsetVec = safeNormalize(offsetVec) * g_spacing
                    if length offsetVec != g_spacing then
                        g_hpC2.pos = g_hpC1.pos + expectedOffsetVec
                    
                    for i = 3 to 5 do
                    (
                        local parentHelper = cHelpers[i-1]
                        local childHelper = cHelpers[i]
                        local currentOffset = childHelper.pos - parentHelper.pos
                        local fixedOffset = safeNormalize(currentOffset) * g_spacing
                        childHelper.pos = parentHelper.pos + fixedOffset
                    )
                    
                    -- B系列を調整（B2の位置をC2に合わせる）
                    local dirB = safeNormalize(g_hpB2.pos - g_hpC2.pos)
                    g_hpB2.pos = g_hpC2.pos + dirB * g_targetDist
                    for i = 3 to 5 do
                    (
                        local parentHelper = bHelpers[i-1]
                        local childHelper = bHelpers[i]
                        local currentOffset = childHelper.pos - parentHelper.pos
                        local fixedOffset = safeNormalize(currentOffset) * g_spacing
                        childHelper.pos = parentHelper.pos + fixedOffset
                    )
                    
                    -- A系列を調整（A2の位置をC2に合わせる）
                    local dirA = safeNormalize(g_hpA2.pos - g_hpC2.pos)
                    g_hpA2.pos = g_hpC2.pos + dirA * g_targetDist * 2
                    for i = 3 to 5 do
                    (
                        local parentHelper = aHelpers[i-1]
                        local childHelper = aHelpers[i]
                        local currentOffset = childHelper.pos - parentHelper.pos
                        local fixedOffset = safeNormalize(currentOffset) * g_spacing
                        childHelper.pos = parentHelper.pos + fixedOffset
                    )
                )
                
                default: ( -- C3, C4, C5が動いた場合
                    -- 【修正箇所】移動したヘルパーの親を調整するループ
                    for i = movedIndex to 2 by -1 do
                    (
                        local childHelper = cHelpers[i]
                        local parentHelper = cHelpers[i-1]

                        local offsetVec = childHelper.pos - parentHelper.pos
                        local expectedOffsetVec = safeNormalize(offsetVec) * g_spacing

                        if length offsetVec != g_spacing then
                        (
                            if parentHelper.isFrozen then
                            (
                                -- 親(C1)がフリーズされている場合：親は動かさず、子(C2)を親基準で再配置
                                childHelper.pos = parentHelper.pos + expectedOffsetVec
                                
                                -- 子(i=2)が動いたので、それ以降の子(i+1から5)も連鎖的に再調整
                                for j = i+1 to 5 do
                                (
                                    local subsequentChild = cHelpers[j]
                                    local subsequentParent = cHelpers[j-1]
                                    local subsequentOffset = subsequentChild.pos - subsequentParent.pos
                                    local fixedSubsequentOffset = safeNormalize(subsequentOffset) * g_spacing
                                    subsequentChild.pos = subsequentParent.pos + fixedSubsequentOffset
                                )
                                -- フリーズされた親に到達したら、それ以上遡らない
                                exit
                            )
                            else
                            (
                                -- 親がフリーズされていない場合：親を子に合わせて動かす
                                parentHelper.pos = childHelper.pos - expectedOffsetVec
                            )
                        )
                    )
                    
                    -- (変更なし)
                    for i = movedIndex+1 to 5 do
                    (
                        local childHelper = cHelpers[i]
                        local parentHelper = cHelpers[i-1]
                        local offsetVec = childHelper.pos - parentHelper.pos
                        if length offsetVec != g_spacing then
                            childHelper.pos = parentHelper.pos + safeNormalize(offsetVec) * g_spacing
                    )
                    
                    -- (変更なし)
                    for i = 2 to 5 do
                    (
                        local dirB = safeNormalize(bHelpers[i].pos - cHelpers[i].pos)
                        bHelpers[i].pos = cHelpers[i].pos + dirB * g_targetDist
                        
                        local dirA = safeNormalize(aHelpers[i].pos - cHelpers[i].pos)
                        aHelpers[i].pos = cHelpers[i].pos + dirA * g_targetDist * 2
                    )

                    -- (変更なし)
                    for i = 3 to 5 do
                    (
                        local parentHelper = bHelpers[i-1]
                        local childHelper = bHelpers[i]
                        local currentOffset = childHelper.pos - parentHelper.pos
                        local fixedOffset = safeNormalize(currentOffset) * g_spacing
                        childHelper.pos = parentHelper.pos + fixedOffset
                    )

                    -- (変更なし)
                    for i = 3 to 5 do
                    (
                        local parentHelper = aHelpers[i-1]
                        local childHelper = aHelpers[i]
                        local currentOffset = childHelper.pos - parentHelper.pos
                        local fixedOffset = safeNormalize(currentOffset) * g_spacing
                        childHelper.pos = parentHelper.pos + fixedOffset
                    )
                )
            )
            
            join affectedHelpers aHelpers
            join affectedHelpers bHelpers
            join affectedHelpers cHelpers
            
            updateExpectedValues affectedHelpers currentFrame
            repairKeys()
            g_isAdjusting = false
        )
    )

    ----------------------------------------------------------------
    -- 4. 初期化とハンドラ登録 (変更なし)
    ----------------------------------------------------------------
    
    -- 全てのヘルパーをリスト化
    local allManagedHelpers = #(
        g_hpA1, g_hpA2, g_hpA3, g_hpA4, g_hpA5,
        g_hpB1, g_hpB2, g_hpB3, g_hpB4, g_hpB5,
        g_hpC1, g_hpC2, g_hpC3, g_hpC4, g_hpC5
    )

    initExpectedValues allManagedHelpers
    deleteAllChangeHandlers id:#HelperMoveMonitor
    
    -- ハンドラ登録（子ヘルパーのみ）
    -- A系列
    when transform g_hpA2 changes id:#HelperMoveMonitor do onASeriesMoved g_hpA2
    when transform g_hpA3 changes id:#HelperMoveMonitor do onASeriesMoved g_hpA3
    when transform g_hpA4 changes id:#HelperMoveMonitor do onASeriesMoved g_hpA4
    when transform g_hpA5 changes id:#HelperMoveMonitor do onASeriesMoved g_hpA5
    
    -- B系列
    when transform g_hpB2 changes id:#HelperMoveMonitor do onBSeriesMoved g_hpB2
    when transform g_hpB3 changes id:#HelperMoveMonitor do onBSeriesMoved g_hpB3
    when transform g_hpB4 changes id:#HelperMoveMonitor do onBSeriesMoved g_hpB4
    when transform g_hpB5 changes id:#HelperMoveMonitor do onBSeriesMoved g_hpB5
    
    -- C系列
    when transform g_hpC2 changes id:#HelperMoveMonitor do onCSeriesMoved g_hpC2
    when transform g_hpC3 changes id:#HelperMoveMonitor do onCSeriesMoved g_hpC3
    when transform g_hpC4 changes id:#HelperMoveMonitor do onCSeriesMoved g_hpC4
    when transform g_hpC5 changes id:#HelperMoveMonitor do onCSeriesMoved g_hpC5

    format "\nSetup complete (Fixed Frozen Parent Logic).\n"
    format "Extended to 3 series x 5 helpers (A1-C5).\n"
)
距離を動的に計算して維持する修正版を考えて
変数名はかえないで