<aside> ⚠️ Warning: Before beginning this tutorial, you should have already read through and completed the tutorial for creating a basic weapon. This page will build on the previous weapon and concepts from that tutorial, making it essential to understand the previous page!

</aside>

Continuing from the previous page with weapons, we created a weapon that scattered explosive, stunning shots. Let’s continue to build upon that weapon to show off some more things that can be done with weapons using the systems in Mega Man 8-Bit Deathmatch.

The Alternate Fire


As mentioned in that previous tutorial, not only is there a Fire state, but there’s also an Altfire state. Let’s start our weapon ventures by adding an alternate fire to Spark Scatter. This alternate fire will fire a spread of three shots with a fancy weapon sprite animation.

Let’s begin by adding the TEXTURES definitions that will be needed to facilitate that fancy weapon sprite animation. We’ll add the following definitions to the TEXTURES file in our weapon file.

sprite SKS0A0, 128, 92 {Offset -212, -114  Patch HBU1A0, 0, 0 {Translation "192:192=4:4", "198:198=229:229"}}
sprite SKS0B0, 128, 92 {Offset -236, -134  Patch HBU1B0, 0, 0 {Translation "192:192=4:4", "198:198=229:229"}}
sprite SKS0C0, 128, 92 {Offset -232, -134  Patch HBU1C0, 0, 0 {Translation "192:192=4:4", "198:198=229:229"}}
sprite SKS0D0, 124, 96 {Offset -220, -122  Patch HBU1D0, 0, 0 {Translation "192:192=4:4", "198:198=229:229"}}
sprite SKS0E0, 124, 96 {Offset -200, -106  Patch HBU1E0, 0, 0 {Translation "192:192=4:4", "198:198=229:229"}}
sprite SKS0F0, 124, 96 {Offset -192, -98  Patch HBU1F0, 0, 0 {Translation "192:192=4:4", "198:198=229:229"}}

These offsets and animations are the same that Drill Bomb uses, so we’ll be involving some heavy kick back with our alternate fire. The actual DECORATE that we’ll be adding now is below.

Altfire:
	SKST B 0 A_JumpIfNoAmmo("NoAmmo")
	SKST B 0 A_PlaySoundEx("weapons/mm7/thunderboltfire", "Weapon")
	SKST B 0 A_PlaySoundEx("weapons/mm3/sparkshockfire", "SoundSlot6")
	SKST B 0 A_FireCustomMissile("SparkScatterLob",-10,0,8,0)
	SKST B 0 A_FireCustomMissile("SparkScatterLob",0,0,8,0)
	SKST B 0 A_FireCustomMissile("SparkScatterLob",10,1,8,0)
	SKS0 ABCDEF 2
	SKST B 6
	SKST B 0 A_Refire
	goto Ready+1

Note how only one of those A_FireCustomMissile calls are using the argument which tells the weapon that it should take its ammo. If all three had a 1 for the second argument, then this alternate fire would take triple the ammo. That sort of behavior may be desirable, but we shouldn’t do it that way. What we should actually do is add some new weapon properties.

-WEAPON.ALT_USES_BOTH
Weapon.AmmoUse2 6
Weapon.AmmoType2 "SparkScatterAmmo"

To go in order, this says to remove the flag which determines alternate fires taking both primary and alternate fire ammo, that alternate fire should use 6 ammo, and that the ammo which alternate fire uses should be "SparkScatterAmmo". Using this method allows some more fine-tuning of the ammo take values. In our instance, rather than tripling the ammo usage, we’ve only doubled it.

The Alternate Ammo


What if we wanted that alternate fire to use its own pool of ammo, however? Well, considering that we have access to a set of properties for the secondary ammo type, let’s just use those! First we’ll need to define a new ammo actor for the secondary ammo.

actor SparkSpreadAmmo : Ammo
{
	inventory.amount 1
	inventory.maxamount 28
	+INVENTORY.IGNORESKILL
}

Now let’s change our properties to use it and also change them to specify how much of this ammo the user should receive on weapon pickup.

-WEAPON.ALT_USES_BOTH
Weapon.AmmoUse2 7
Weapon.AmmoGive2 28
Weapon.AmmoType2 "SparkSpreadAmmo"

Last but certainly not least, just like we had to define an actor so that our primary ammo bar would show up, let’s do the same so that our secondary ammo bar will show up. The game will be searching for an actor named [YourWeapon]_SecondBar, or in our case, SparkScatterWep_SecondBar, so let’s go ahead and define that.