BT1 clone in Python

Any developer realated stuff
Desmet Irkm
Posts: 35
Joined: Fri Nov 11, 2011 2:50 pm
Location: .de
Contact:

BT1 clone in Python

Post by Desmet Irkm »

EDIT: Newest version (0.2): http://www.file-upload.net/download-389 ... t.zip.html

Hi all,

I've played BT1 on the Amiga long ago and liked the graphics and feeling there very much. When I wanted to replay it, however, I found disk loading times so awfully slow that I gave it up pretty soon. Then I tried the msdos version, where the loading time are very fast, however, the graphics look so awful that I dumped that too.

So I planned to write a clone of BT1 and here you can see the first step. So far, you cannot do much: walk around in Skara Brae (with the amiga look), enter the buildings (with graphics, except for the towers and the castle), get the street names. However, it's fast and quite nice, since you can go everywhere in town without any monster beating you up. The code for loading the levels from the 'levs' file is also there, but the graphics and logic is not implemented yet. However, I'm planning to do that soon. If you want to take a look: download
btdist.zip (see link at the beginning), then do

Code: Select all

unzip btdist
cd btdist/src
python bard.py
It's developed under linux with python 2.7 and pygame 1.9.1, but I guess it'll also run with python 2.6 and maybe also under windows, but I'm not sure about that. In the res folder are images that were extracted from the Amiga version by screen capturing, and also files from the msdos version for the levels, city map and game strings.

What is also included is the code for the Huffman decoding, loading of indexed files and conversion for some of the msdos graphics files (see the file src/testing.py for which files can be decoded right now). At this point I need to say thanks to some of the people here (Maven, Darendor, Horpner, Caracas, hope I didn't forget anybody whose input I used). It would have taken me months to decipher all that stuff on my own. Really great work, I'm still wondering how you figured out the Huffman decoding scheme.

Currently most of this information is spread over some threads in this forum; I think it would be great to gather all that information in one place. So I started a project on github (https://github.com/btdevel/bt), with the source for the algorithms I've implemented and also a doc directory where I plan to put all information on file formats used in the different BT versions. The docs are generated automatically and put on readthedocs.org, see http://bt.readthedocs.org. As you can see, it's not much yet.

So, I would appreciate any input on this, or contributions to the code or docs, or if anybody wants to join that project... feel free.[/url][/b]
Last edited by Desmet Irkm on Tue Nov 22, 2011 1:12 am, edited 1 time in total.
Maven
Posts: 138
Joined: Sat Apr 16, 2011 9:39 pm

Post by Maven »

Wow. Pretty impressive.

Works fine under Windows XP, with Python 2.7.2 and pygame 1.9.2a0.

I also played originally on the Amiga, and really liked the graphics and sound. I prefer the PC over the Amiga for the same reason as you -- response time.

So how far do you intend to take this project?

Is there a place on GitHub to discuss specifics of the project? I didn't see a forum of any type, but then I didn't create an account over there, either.

I probably won't be contributing any coding, at least for the forseeable future, but I would love to help figure out more specifics of how the game works on PC. I have been working on more of the game mechanics, and plan to post more of my findings on this forum. If it is easy enough, I could cross-post in the GitHub area as well.
Caracas
Posts: 89
Joined: Thu Jan 20, 2011 9:16 am
Location: Belgium

Post by Caracas »

Forgive a complete noob, but how do I run this?
I downloaded python-2.7.msi and pygame 1.9.1release
I installed python. Do I also have to install pygame?
How do I run bard.py?
Maven
Posts: 138
Joined: Sat Apr 16, 2011 9:39 pm

Post by Maven »

I had to install pygame, and I had to make sure I had the right version for my version of python. I got it right on the second try.

Couple of ways to run it. I found the easiest way was to run the IDLE Python GUI from the Windows start menu, do he menu option File->Open and find bard.py, then do the menu option Run->Run Module.
Caracas
Posts: 89
Joined: Thu Jan 20, 2011 9:16 am
Location: Belgium

Post by Caracas »

Yeah, that's what I did, but I get the message that the pygame module can't be loaded
Desmet Irkm
Posts: 35
Joined: Fri Nov 11, 2011 2:50 pm
Location: .de
Contact:

Post by Desmet Irkm »

Maven wrote: So how far do you intend to take this project?

Is there a place on GitHub to discuss specifics of the project? I didn't see a forum of any type, but then I didn't create an account over there, either.

I probably won't be contributing any coding, at least for the forseeable future, but I would love to help figure out more specifics of how the game works on PC. I have been working on more of the game mechanics, and plan to post more of my findings on this forum. If it is easy enough, I could cross-post in the GitHub area as well.
@Maven:

How far I want to go with this: I really don't know, I guess how far it takes me, but maybe a fully playable clone, why not? Currently the coding is just fun for me; the more there is that works, the more I want to put into. It's goes mostly like this: ok, this works, then its not much to also make that work, then that it would be nice to have that,... and then it's again 2 o'clock in the night, and I get tired to work the next day.

I just put in Sinister street, and with that it would be easy to also include the statues and the gates. Next thing will probably be the text window, instead of putting stuff on the console, so interactivity will become better. Then the dungeons: it's really not difficult and I have the decoder for the level files and for the graphics, so its maybe one night of coding...

As for a forum: I think there is no such thing on github. There is something for issue/bug management and also a project wiki, that could be used. Otherwise, I would just use this forum for discussion. Maybe if this thing grows a bit and more get interested, the board admin can make a separate topic branch?

If you can help with the game logic, that would be great. There's so much to do and investigate. Just a few things that come to mind:
* special encounters (e.g. with magic mouths, npcs, statues, etc.), what happens exactly, under which conditions (need special character? need special item? must be equipped? ...)
* combat: how do monsters choose attacks, who gets initiative, with what frequency do random encounters happen, ...
* What are the exact effects of each spells (numerically, not just e.g. "medium duration")
* when and how fast does the game clock run, night and day (closing hours of board and shop, which monsters appear when, ...), how fast is spell point regeneration in the city and on regeneration points
* spinners, smoke, portal, traps, with numerical values, statistics
* character development: number of attacks, thac0, ac adjustments,...
Many of those thing one somehow "knows", but not detailed enough to really code it. And figuring all of that out in enough detail takes time...

Then there is still info missing on some of the binary files: thanks to the infos from this board I could decode the basic level information (walls, doors and hidden doors). But there's lots of information missing: e.g. texture file to use, special encounter/programs, messages, teleports, ... I guess its probably somewhere here but I didn't find it yet.

Maybe we could put that into the rst files in the docs directory on the github project (rst is reStructuredText, which is more or less simple ascii text with some markup interpretation). This would be then much easier than searching for the information in the forum posts.

Concerning the coding: That's alright.I guess at the moment it's also probably best, if I do the that alone, because it the code is growing pretty fast, and I refactor quite often, so that coordination would be a bit difficult. Maybe, that can change later, when the code base becomes stable and e.g. things like game events/encounters become easily
scriptable.
Desmet Irkm
Posts: 35
Joined: Fri Nov 11, 2011 2:50 pm
Location: .de
Contact:

Post by Desmet Irkm »

@caracas:

It's probably pygame for a different python version (maybe 2.5 and not 2.7). I just fired up my windows in virtualbox and downloaded

* http://www.python.org/ftp/python/2.7.2/python-2.7.2.msi
* http://pygame.org/ftp/pygame-1.9.2a0.win32-py2.7.msi

and everything ran fine there. Just to check I tried it also with pygame-1.9.1.win32-py2.5.msi, which directly exited and printed some like "cannot load pygame" on the console (like you said).
User avatar
ZeroZero
Posts: 286
Joined: Tue Mar 10, 2009 9:10 pm
Location: Germany

Post by ZeroZero »

Most of the logic of BT1 is explained for the CBM64 version in that thread.

I can provide disassemblies for all dungeon events that are loaded from
disk on the C64 (it were small machine code snippets loaded into mem).
If interested, just pm me your email addy.

Most other info on maps is provided there too.

The rooster file formats are explained there too.

There also is loads of logic info in this forum.
Maven
Posts: 138
Joined: Sat Apr 16, 2011 9:39 pm

Post by Maven »

Desmet Irkm wrote: * combat: how do monsters choose attacks, who gets initiative, with what frequency do random encounters happen, ...
Which brings up an interesting question.

In messing with my Bard-Skelly strategy, I became interested in how the combat mechanics work. Specifically, when you are opposing 66 Skeletons, which one do you attack? The same one every time until it dies? A different one each round? What about weapons of mass destruction? I couldn't seem to get the numbers to make any coherent sense.

So I broke out my handy dandy memory monitor, and watched the HP array in memory to see how things went down. Interesting results, and a definite BUG. Remember my question about why if you hit the Samurai twice in the same round, it always dies no matter how little damage you do? It's a bug in the targeting algorithm. It does other things as well, but isn't disruptive enough to raise a red flag normally.

So the question would be, do you replicate the bug in your version, or do you fix it and do it the way you think the designer MEANT it to work?
Desmet Irkm
Posts: 35
Joined: Fri Nov 11, 2011 2:50 pm
Location: .de
Contact:

Post by Desmet Irkm »

Good question! Basically, I would say: make it configurable, maybe have some "bard.conf" file with a section [compatibility] and put a key there like, 'reproduce_samuarai_bug=true/false', so that you can have the original behaviour if you want to. However, sometimes it is more difficult to reproduce a bug, than to implement the "correct" behaviour.

You can compare it with the 3d rotation in the city, which is in my view also buggy, or at least flawed. You don't rotate around some fixed point, but rather round the outer edges of the square (having the center of the square in front of you) - which is already a bit weird and feels more like dancing than rotating - but then, when you have a building in front of you, you suddenly switch to the other side so that the center of the square is in your back. It wasn't to complicated to implement, but a more sensible behaviour would have been easier.

In the case of the combat, I think I would first go for the more sensible behaviour, keep the original bug in the back of my head and maybe, if I really feel like it, put it in later. This especially since implementing buggy behaviour deliberately usually involves lots of 'if's and is more difficult to get 'right'.
User avatar
ZeroZero
Posts: 286
Joined: Tue Mar 10, 2009 9:10 pm
Location: Germany

Post by ZeroZero »

In the Apple II and C64 versions the 3d view is right, but afaik in the
DOS version it is awful
Desmet Irkm
Posts: 35
Joined: Fri Nov 11, 2011 2:50 pm
Location: .de
Contact:

Post by Desmet Irkm »

ZeroZero wrote:In the Apple II and C64 versions the 3d view is right, but afaik in the DOS version it is awful
Hmm, never wanted to, but it seems I really have to take a look at the C64 version...
It''s sometimes strange how they first get it right and then mess things up when porting it to another system...
Desmet Irkm
Posts: 35
Joined: Fri Nov 11, 2011 2:50 pm
Location: .de
Contact:

Post by Desmet Irkm »

I've uploaded a new version. Visible things that have changed

* Messages are in the message pane instead of the console, with automatic text breaking and smooth scrolling (see Credits opposite the Guild)
* the Teleport on Sinister works now
* City gates, iron gates (impassable), Statues (vanish for one move when attacked) have been implemented
* Added Castle inside and outside, removed some gfx glitches in the city

Plus a lot of stuff going on internally, but which cannot be seen yet. Instead of putting the link here, I will edit first post, so that no obsolete versions are lying around.
Maven
Posts: 138
Joined: Sat Apr 16, 2011 9:39 pm

Post by Maven »

I'm wondering why include the Huffman files? I think it might be easier and more flexible to just decompress the files and use them in plain format.
User avatar
ZeroZero
Posts: 286
Joined: Tue Mar 10, 2009 9:10 pm
Location: Germany

Post by ZeroZero »

Indeed... only reason could be to keep people from editing the maps, but why do that anyway?
Post Reply