The Duck Pond
By Saturday night the duck was a warrior, with a trainer menu built into the game. I loaded my save to play it and asked a simple question: when does the demo end?
1Where the shareware stops
There's no time limit. The free shareware version of Diablo is the town plus the first two levels of the dungeon. Take the stairs down from level 2 and the warrior says "Not a chance," and a message says that part isn't in the shareware. You can only play a warrior, a few townspeople won't talk to you, and most quests are switched off.
In DevilutionX, the open-source rebuild I'm playing on, every one of those limits is a single check in the code against one flag, gbIsSpawn. The stairs are one line in levels/trigs.cpp. Since I build the game from source now, every one of those limits is mine to lift.
2The fork
That's where the idea forked. I could buy the full game and reskin it piece by piece, or I could treat the shareware as a small, complete core and replace everything in it until none of it is Blizzard's.
I went with the core. Town and two dungeon levels is a whole game loop. Everything I replace there moves it toward being mine, instead of chipping away at a full game I'd never finish replacing. It also matters for sharing: the shareware was made to be passed around, and a game made entirely of my own art could be handed to anyone. The full game, when I get a copy, is reference: something to look at, not something the mod needs.
3A pond, a rabbit, a hole
If the hero is a duck, the town is a pond. Keep it as small as it can be: one person to talk to and one way down. A duck doesn't go into a cathedral. It goes down a rabbit hole, after meeting the rabbit, because the snake is down there.
The original town already has that shape hiding in it. The cathedral entrance has a townsperson right beside it, the wounded townsman who tells you about the Butcher. He doesn't appear in the shareware, because he only shows up when the Butcher quest is active, and the shareware turns quests off. That spot is where the rabbit will go.
4How a town is built
Tristram is three layers:
| Layer | What it is |
|---|---|
| Layout | Four "sector" files, grids of tile numbers stitched into one map, plus a few tiles the code places by hand (the boarded-up shortcuts the shareware keeps closed). |
| People | A table in the code: who stands where, facing which way, and what happens when you click them. |
| Art | The town tile set: thousands of small isometric pieces that fit together into walls, roofs, grass and water. |
The plan is to go in that order: layout first, using the old art, then the rabbit, then new art one piece at a time. A new map with old tiles is playable right away. And if the pond is built around the spots the code fixes (the dungeon entrance and where you arrive coming back up), the first version needs no code changes at all: DevilutionX reads loose files from an override folder before its archive, so the new map is just new files.
5Seeing the map first
The rule from part 1 holds: see it before you build it. Before editing a map, I wanted a picture of the one we have. So the first tool reads the game's own files and draws the town the way the game does: the sector files become a grid of pieces, each piece is a stack of 32-pixel tiles, and each tile is stored in one of six shapes (squares, triangles, trapezoids) chosen to waste as few bytes as possible in 1996. The decoding was ported straight from DevilutionX's renderer. It drew the town correctly on the first run.
The second view is the one for editing: top-down, one square per piece, with coordinates. It's the town laid out the way the code stores it.
One thing it showed right away: the creek through town is drawn with water tiles. The pond can start with art the game already has.
6A catalog of tiles
A map file is just numbers, so before drawing a new one I needed to know what the numbers mean. The second tool draws every tile the town uses, with its number, how many times Tristram uses it, and how much of it you can walk on (green: all of it, red: none). Boulders are 63, the most-used tile in town. Plain grass is 1, 2, 5, 6 and 8. The creek is a dozen numbers in the 70s and 80s, each a piece of bank or bend.
7The clearing
The pond town is a short script rather than a hand-drawn file: fill the whole map with boulders, carve an oval clearing around the dungeon entrance, scatter grass and a few trees, soften the edge with small rocks, and keep Tristram's creek wherever it crosses the clearing. A dirt patch marks the hole until it has its own art. The first oval only clipped the creek, so it moved two tiles west.
Two things the map couldn't fix on its own. A new game starts you in the middle of old Tristram, which is now solid rock, and a save made in town would put you back inside the boulders. And the "Down to dungeon" label only appears over the cathedral's stair tiles, which are gone. Three small changes to the game's code: start at the pond, move a town save to the pond, and show the label over the hole's spot. Then a rebuild, 32 seconds.
8A walk to the hole
Then I started a new game and the duck was standing in the boulders, out where the healer used to live. Loading a save had worked; starting fresh hadn't. A new character's spot doesn't come from the town code at all. It comes from a small table in the multiplayer code, nine squares around 75, 68 so that players joining together don't stack on one tile, and single player uses the first one. One more line to change.
While I was looking at it, I changed my mind about where the duck should start. Appearing right next to the hole skips the best part. So now he starts in a little nook in the rocks east of the clearing, and a dirt path with one bend leads him to the hole. Coming back up from the dungeon still puts you beside the hole, where you'd climb out.
The hole works: click the dirt patch at the end of the path, "Down to dungeon," and the duck is in level 1.
9One townsperson
Tristram has nine people (plus cows). The pond has one. A single function in the game sets who appears, so the change is two lines: nobody is present except the town elder, Cain, and his spot moves from the town square to just beside the hole. Cain's job is the right one for a rabbit: he's the one who knows things, and he identifies the magic items you bring back up. He's renamed "The Rabbit" in his menu and when you point at him. He still looks like Cain until his sprite gets made, the same way the duck got made.
Removing eight people turned up one place that depended on them being there: the code that puts you back in town after certain quest levels looks up the drunk's position. The shareware never reaches it, but it would crash if it did, so it gets a fallback.
That's the town: a clearing, a path, a hole, and one neighbor who doesn't look like himself yet. Giving him his own look is part 3.
土曜の夜には、アヒルは戦士になっていて、ゲームにはトレーナーメニューが組み込まれていました。セーブデータをロードして遊ぼうとしたとき、単純な疑問がわきました。体験版はいつ終わるんだろう?
1シェアウェアの終わるところ
時間制限はありません。Diablo の無料のシェアウェア版は、町とダンジョンの最初の二階層だけです。2階から階段を降りようとすると、戦士が「Not a chance」(とても無理だ)と言い、その先はシェアウェアには入っていないというメッセージが出ます。遊べるのは戦士だけで、話してくれない町の人が何人かいて、クエストのほとんどはオフになっています。
私が遊んでいるオープンソースの再実装 DevilutionX では、こうした制限はどれも、コードの中で gbIsSpawn という一つのフラグを見るチェック一つです。階段は levels/trigs.cpp の一行です。いまは私がソースからゲームをビルドしているので、どの制限も自分で外せます。
2分かれ道
ここで考えが二つに分かれました。製品版を買って、少しずつ見た目を差し替えていくか。それとも、シェアウェアを小さくて完結したコアとして扱い、Blizzard のものが何も残らなくなるまで中身を全部置き換えるか。
私はコアのほうを選びました。町とダンジョン二階層で、ゲームのループが一通りそろっています。そこで何かを置き換えるたびに、ゲームは自分のものに近づきます。製品版を少しずつ削っていっても、置き換えが終わる日は来ないでしょう。共有するうえでも意味があります。シェアウェアは人に配るために作られたもので、全部が自分の絵でできたゲームなら、誰にでも渡せます。製品版は、手に入れたら参考資料にします。見るためのもので、この改造に必要なものではありません。
3池と、ウサギと、穴
主人公がアヒルなら、町は池です。できるだけ小さくします。話す相手は一人、降りる道は一つ。アヒルは大聖堂には入りません。ウサギに会ってから、ウサギの穴に降りていきます。下にヘビがいるからです。
元の町には、その形がすでに隠れています。大聖堂の入口のすぐ横に、町の人が一人いるのです。Butcher のことを教えてくれる、傷を負った町人です。彼はシェアウェアには出てきません。Butcher のクエストが有効なときにしか現れず、シェアウェアではクエストがオフだからです。その場所に、ウサギを置くことにします。
4町のつくり
Tristram は三つの層でできています。
| 層 | 中身 |
|---|---|
| レイアウト | 四つの「セクター」ファイル。タイル番号の格子で、つなぎ合わせると一枚の地図になります。それに加えて、コードが手で置くタイルがいくつか(シェアウェアでは閉じたままの、板でふさがれた近道)。 |
| 人 | コードの中の表。誰がどこに立ち、どちらを向き、クリックすると何が起きるか。 |
| 絵 | 町のタイルセット。何千もの小さなアイソメトリックの部品で、組み合わせると壁、屋根、草、水になります。 |
計画は、この順番で進めることです。まず古い絵のままでレイアウト、次にウサギ、そして新しい絵を一つずつ。古いタイルで描いた新しい地図なら、すぐに遊べます。しかも、コードが固定している場所(ダンジョンの入口と、上に戻ってきたときに出てくる場所)を基準に池を作れば、最初の版はコードを一切変えずにすみます。DevilutionX はアーカイブより先に、上書き用のフォルダにあるばらのファイルを読むので、新しい地図は新しいファイルを置くだけです。
5まず地図を見る
パート1のルールはここでも同じです。作る前に見る。地図を編集する前に、いまある地図の絵がほしかった。そこで最初のツールは、ゲーム自身のファイルを読み、ゲームと同じやり方で町を描きます。セクターファイルが部品の格子になり、各部品は32ピクセルのタイルの積み重ねで、各タイルは六つの形(正方形、三角形、台形)のどれかで保存されています。1996年当時、できるだけバイトを無駄にしないように選ばれた形です。デコードの処理は DevilutionX のレンダラーからそのまま移植しました。最初の実行で、町が正しく描けました。
二つ目の表示は編集用です。真上から見て、一つの部品が一マス、座標付き。コードが保存しているとおりの並びで表した町です。
すぐにわかったことが一つあります。町を流れる小川は、水のタイルで描かれています。池は、ゲームにすでにある絵で始められます。
6タイルのカタログ
地図のファイルはただの数字の並びなので、新しい地図を描く前に、その数字の意味を知る必要がありました。二つ目のツールは、町で使われているタイルを全部描き、それぞれに番号と、Tristram で何回使われているかと、どれだけ歩けるか(緑は全部、赤はまったく歩けない)を添えます。岩は63で、町でいちばん多く使われているタイルです。ただの草は1、2、5、6、8。小川は70番台と80番台の十数個の番号で、それぞれが岸や曲がり角の一片です。
7空き地
池の町は、手で描いたファイルではなく、短いスクリプトで作ります。地図全体を岩で埋め、ダンジョンの入口のまわりに楕円の空き地をくり抜き、草と木を何本か散らし、小さな岩で縁をやわらげ、空き地を横切るところでは Tristram の小川を残す。穴の場所には、専用の絵ができるまで、土の地面を置いて目印にします。最初の楕円は小川の端をかすめただけだったので、西に2タイル動かしました。
地図だけでは直せないことが二つありました。新しいゲームを始めると、昔の Tristram の真ん中から始まりますが、そこはいまは固い岩です。町でセーブすると、ロードしたときに岩の中に戻されてしまいます。そして「Down to dungeon」のラベルは、大聖堂の階段のタイルの上にしか出ませんが、そのタイルはもうありません。そこで、ゲームのコードに小さな変更を三つ。池から始める、町でのセーブを池に移す、穴の場所の上にラベルを出す。それからリビルド、32秒。
8穴までの散歩
それから新しいゲームを始めると、アヒルは岩の中、昔ヒーラーが住んでいたあたりに立っていました。セーブのロードはうまくいったのに、新しく始めるとだめでした。新しいキャラクターの位置は、町のコードからはまったく来ていません。マルチプレイのコードにある小さな表から来ています。75, 68 のまわりの九マスで、一緒に参加したプレイヤーが一つのタイルに重ならないためのもので、シングルプレイでは最初の一つが使われます。変える行がもう一行。
そこを見ているうちに、アヒルの出発点について考えが変わりました。穴のすぐ横に現れると、いちばんいいところを飛ばしてしまいます。そこでいまは、空き地の東の岩の間の小さなくぼみから始まり、一度曲がる土の道が穴まで導きます。ダンジョンから上がってきたときは、これまでどおり穴の横、這い出してくる場所に出ます。
穴はちゃんと使えます。道の終わりの土の地面をクリックすると「Down to dungeon」、アヒルは1階にいます。
9町の人は一人
Tristram には九人の人がいます(それと牛)。池には一人。誰が現れるかはゲームの一つの関数で設定されているので、変更は二行です。町の長老 Cain 以外は誰もいなくし、Cain の場所を町の広場から穴のすぐ横に移します。Cain の役目はウサギにぴったりです。物知りで、持ち帰った魔法のアイテムを鑑定してくれる人です。メニューでも、カーソルを合わせたときも、名前は「The Rabbit」に変わっています。スプライトができるまでは、見た目はまだ Cain のままです。スプライトは、アヒルを作ったのと同じやり方で作ります。
八人を消したら、彼らがいないと動かない場所が一つ見つかりました。特定のクエストの階層のあとで町に戻すコードが、酔っぱらいの位置を参照していたのです。シェアウェアではそこに到達しませんが、到達したらクラッシュするので、代わりの値を用意しました。
これで町ができました。空き地と、道と、穴と、まだ自分らしい姿をしていない隣人が一人。彼に自分の姿を与えるのがパート3です。
Want the next one?
New posts by email, now and then. Nothing else.