back to Creeper World
# Util-AltitudeMultiplier.crpl
# Created by: nathanaelps
# Created on: 9/18/2020 12:56:49 PM
# ------------------------------------------


# If we're doing a sub-map section, we can use these. Probably not real useful, unless we're wanting a really big map with just a small area sized up? Idk.
$endX:-1 # -1 means "full map width"
$endY:-1 # -1 means "full map height"
$ChunkSize:30 # Cells per chunk side.

  # set visible details
  "Each altitude counts as " <-Multiplier Concat SetPopupText
  Self "main" "Custom0" SetImage # this is usually empty in my maps, so it's invisible.
  self CONST_CREATEPZ 0 SetUnitAttribute
  self CONST_COUNTSFORVICTORY 0 SetUnitAttribute
  self CONST_NULLIFIERDAMAGES 0 SetUnitAttribute

  # sanitize input. Not perfect, I don't think, but... Yeah.
  <-endX 0 lt if MapWidth ->endX endif
  <-endY 0 lt if MapHeight ->endY endif
  <-endX MapWidth gt if MapWidth ->endX endif
  <-endY MapHeight gt if MapHeight ->endY endif
  <-endX <-startX sub ->width
  <-endY <-startY sub ->height
  <-width <-ChunkSize div 1 add ->ChunkWidth
  <-height <-ChunkSize div 1 add ->ChunkHeight
  <-ChunkWidth <-ChunkHeight mul ->ChunkCount
  <-ChunkCount 1 add ->currentChunk

@stepFilter # This fires each tick, it's the heartbeat of the machine.

  <-currentChunk <-ChunkHeight mod ->iChunkX
  <-currentChunk <-ChunkHeight div ->iChunkY
  <-iChunkX <-ChunkSize mul <-startX add ->chunkStartX
  <-iChunkY <-ChunkSize mul <-startY add ->chunkStartY
  <-chunkStartX <-ChunkSize add ->chunkEndX
  <-chunkStartY <-ChunkSize add ->chunkEndY
  <-chunkEndX <-endX gt if <-endX ->chunkEndX endif
  <-chunkEndY <-endY gt if <-endY ->chunkEndY endif
  <-chunkEndX <-chunkStartX do
    <-chunkEndY <-chunkStartY do
      I J @filter
  <-currentChunk 1 add <-ChunkCount mod ->currentChunk

  ->y ->x
  <-x <-y GetTerrain ->t
  <-t -1 neq if
    <-x <-y <-t <-Multiplier mul SetTerrainOverride
    <-x <-y <-VoidDepth SetTerrainOverride