*** Selected sectors must consist of three walls and have different with opposite to first wall sector z's.

// Parameter list begins
mov r98 1 // Process floors
mov r99 1 // Process ceilings
// Parameter list ends
~~~ Default parameters:
~~~ mov r98 1 // Process floors
~~~ mov r99 0 // Process ceilings
mov r00 -1
for each selected sector r00
  getsector r00 floorz r05
  getsector r00 ceilingz r07
  getsector r00 wallptr r01
  getwall r01 nextsector r04
  if r04 > -1
    getsector r04 floorz r06
    getsector r04 ceilingz r08
    sub r05 r06 // Z delta
    sub r07 r08
    if r98 != 0  setsector r00 floorz r06  endif
    if r99 != 0  setsector r00 ceilingz r08  endif
    
    getwall r01 x r10  getwall r01 y r11
    getwall r01 point2 r02
    getwall r02 x r12  getwall r02 y r13
    getwall r02 point2 r03
    getwall r03 x r14  getwall r03 y r15
    
    mov r16 r13  mov r17 r10
    sub r16 r11 // FW X
    sub r17 r12 // FW Y
    hypot r18 r16 r17 // First wall length
    if r18 != 0
      mul r16 4096  mul r17
      div r16 r18  div r17
      sub r14 r10  sub r15 r11
      mul r14 r16  mul r15 r17
      add r14 r15 // X delta
      if r14 != 0
        div r14 1024
        if r98 != 0
          mul r05 -1024
          div r05 r14 // Target heinum
          setsector r00 floorheinum r05
        endif
        if r99 != 0
          mul r07 -1024
          div r07 r14 // Target heinum
          setsector r00 ceilingheinum r07
        endif
        updatesectorslope r00
      endif
    endif
  endif
continue