In addition to these, take a look at the ZDoom forums project thread for some more development news.
Adding a new BDLite weapon - Revolver
Over on the ZDoom forum, TheEternalStruggler had a request for a pistol weapon, so I'll show how to add one on top of BDLite by creating a project on top! You could equally just go in and add all this to the PK3 as it is, but this guide will demonstrate how you can build on top of BDLite by defining any extras you need and then merging the projects together. You could also get the player to load the separate PK3s one after the other or provide a batch file to do it, but I prefer to hand the player one unified PK3 for a project.
For this miniature project example, I'll use the revolver sprites from Project Brutality, because this weapon has all the states I need (crucially, the reloading sprites).
We start off by laying out our PK3 folder - I usually create a folder per project, then a "pk3" folder under that which will contain what we want to be packaged into the PK3. The project root directory is then free to fill up with works in progress, graphic source files and miscellaneous other garbage. Using a folder structure like this for a PK3 that just contains a weapon would normally be a bit of an overkill, but it makes things consistent with how the weapon files are laid out in BDLite so that when the files are combined everything is in the right place. In this example, the folder that will contain our pk3 contents is "extension-example-pk3" - a copy of this is available in the PK3 Tools download above.
The sprites can all be dumped into the sprites/weapons/revolver folder - we don't need to change any of them. Then we create our parent DECORATE lump, which will go in the root project folder and will just refer to the pistol's dedicated file. To avoid conflicts with files from other projects when they're merged together, I name the file extension after the project - ZDoom doesn't care about the extension and will pick it up as a DECORATE lump regardless.
Now, to actually program the thing, let's look at Project Brutality's DECORATE definition for this pistol. Oh, bloody hell - let's not, actually, because it's fourteen hundred lines. I don't want to diminish the work that people have put in to Project Brutality, though - one reason that BDLite weapons are so much more manageable is that they take out a lot of features that were in the original mod and its descendants, reducing the combinatorial explosion of different states and inventory items to keep track of when you have the options to dual wield with different firing modes and special actions.
So let's instead do this by starting again and building up from the base BDLiteWeapon class intead. As listed at the top of the base class, we'll need to provide our Spawn, Ready, ReadyLoop, Deselect and Fire states.
In this example so far, the pistol doesn't require reloading - we take ammunition directly from the RifleAmmo stock. We could define our own unique ammunition for it if we wanted, but for simplicity we'll imagine you can just about physically cram the same bullets from the rifle into this thing. For testing, you can run gzdoom with both the PK3 and the folder for our project together:
(video)
To add a reloading feature, we need to define a new subclass of Ammo that will represent the number of bullets currently loaded into the revolver. We'll call this "RevolverAmmoLoaded", and will take from this instead of RifleAmmo directly when we fire the weapon - if we find that we have no RevolverAmmoLoaded left, we'll start a reload, which will first check the RifleAmmo stock and transfer bullets from there to RevolverAmmoLoaded if it can.
For more about how the code for these weapons are laid out, check the Structure of BDLite Weapons tutorial.
Once you're happy with how the weapon works, check the Building a project with BDLite tutorial to put it all together - you can either re-zip the BDLite PK3 together with your files, or use the provided build-bdlite-extension tool to automate it.