DQB Forever / Hermit's Heresy

Tutorial: Mottled Mountainsideđź”—

This tutorial demonstrates the "find and replace" pattern. If you want to follow along exactly, use Buildertopia code 3c0mmifdh3 to generate the large Blossom Bay used in this tutorial. But you can use any island with a large chalky mountain.

Here is the default mountain generated by the game:

We will replace the Chalk with Light Dolomite, and replace the Chunky Chalk with a randomized mixture of Dark Dolomite and Gold Vein blocks. Here is the result our script will produce:

There’s gold in them thar hills.

The script starts with the usual setup. Change these values as needed:
#lang racket
(require hermits-heresy)
(save-dir "C:/Users/kramer/Documents/My Games/DRAGON QUEST BUILDERS II/Steam/76561198073553084/SD/")
(define source-slot 'B02) ; slot 3
(define dest-slot 'B00) ; slot 1, my ephemeral slot
(define stage-id 'BT1) ; Buildertopia 1

Next we use build-mottler to create a procedure which will be used to replace the Chunky Chalk. In general, a mottler returns a random block each time it is called from a list of blocks with relative weights. This particular mottler returns Dark Dolomite and Gold Vein blocks in a 5/3 ratio, so if you called it 800 times you would expect approximately 500 Dark Dolomite and 300 Gold Vein blocks:
(define gold-mottler
  (build-mottler '[Dark-Dolomite 5]
                 '[Gold-Vein 3]))

Next we define a simple traversal. When this traversal sees Chalk it will replace it with Light Dolomite. When this traversal sees Chunky Chalk it will replace it with a block from the gold-mottler we defined earlier:
(define trav
  (traversal
   (cond
     [(block-matches? 'Chalk)
      (set-block! 'Light-Dolomite)]
     [(block-matches? 'Chunky-Chalk)
      (set-block! (gold-mottler))])))

And now we just have to execute the traversal. As usual, I first copy from my source save slot to my ephemeral save slot. Then I make the modifications to the ephemeral slot. Doing it this way means if I don’t like the result, I can easily adjust the script and rerun it because my source save slot has not changed.
(copy-all-save-files! #:from source-slot #:to dest-slot)
(define stage (load-stage stage-id dest-slot))
(traverse stage trav)
(save-stage! stage)

And that’s it! Note that this script will perform the replacement on the entire island. A future tutorial will show you how to limit the replacement to a smaller area.

Run the complete script, load the destination slot, and examine the results. If you don’t like the results, adjust the script and run it again. If you do like the results, you could manually copy the relevant STGDAT file from your ephemeral slot back to your working slot to "make it official". Here is the complete script:
#lang racket
(require hermits-heresy)
(save-dir "C:/Users/kramer/Documents/My Games/DRAGON QUEST BUILDERS II/Steam/76561198073553084/SD/")
(define source-slot 'B02) ; slot 3
(define dest-slot 'B00) ; slot 1, my ephemeral slot
(define stage-id 'BT1) ; Buildertopia 1
 
(define gold-mottler
  (build-mottler '[Dark-Dolomite 5]
                 '[Gold-Vein 3]))
 
(define trav
  (traversal
   (cond
     [(block-matches? 'Chalk)
      (set-block! 'Light-Dolomite)]
     [(block-matches? 'Chunky-Chalk)
      (set-block! (gold-mottler))])))
 
(copy-all-save-files! #:from source-slot #:to dest-slot)
(define stage (load-stage stage-id dest-slot))
(traverse stage trav)
(save-stage! stage)