Stabyourself.net
When I released Mari0, a lot of people have suggested adding enemies from SMB2J (the japanese sequel to SMB) or SMB3. And for that reason I’m trying to add enough enemy behavior components to allow at least most of them to be recreated easily with the enemy customization.
So let’s go and add fireball spitting Piranha plants to our mappack.
The basic behavior of the fire Piranha is the same as the normal Piranha, so we can just use its base and then change some of the attributes:
base=plant
{
}
This basically creates a 1:1 copy of the existing plant enemy.
You can find the attributes of the plant enemy over here. Notice how it says ‘“quadcount”: 2’, which tells the game that the included graphic is composed of 2 different sprites, an open- and a closed mouth one for the Piranha. Each enemy can have one png image with the same name as the json settings file which is used for all the graphics.
We could override the graphic of our plant with a fancier looking SMB3-alike one, but I’m lazy so let’s just keep the graphic the same by not supplying a “fireplant.png”. Instead, let’s see what we do have to change.
{
"pistonextendtime": 4,
"spawnsenemy": "fireplantfire",
"spawnenemydelays": [2, 1],
"spawnenemytowardsplayer": true,
"spawnenemyspeed": 5,
"spawnonlyonextended": true
}
First, we make the plant stay outside the pipe a little longer so it can fire off a few shots before disappearing again. Then, we set up the “spawnsenemy” parameter with another enemy we’re going to make shortly. The delay is a table of values from which a random one is picked for each shot, something I’ve discovered is the easiest to modify.
For the initial speed of the spawned enemy, we have the option of a set or random value for both X and Y, or make it fire towards the player with a preset speed, something we use here. Also we have an option to make piston-based enemies only spawn enemies while extended, something I totally didn’t add only for this blogpost.
So if we run that, we see that everything runs fine! Just kidding, it crashes because it tries to create an enemy that doesn’t exist. So let’s add that fireplantfire enemy.

The above graphic is the four frames used for Mario’s fireball, and we’re just going to use that for the Piranha fire because I’m lazy. You can find the whole fireplantfire.json here, but this is the important stuff:
{
"quadcount": 4,
"animationtype": "frames",
"animationspeed": 0.1,
"animationstart": 1,
"animationframes": 4,
"movement": "none",
"kills": true,
"width": 0.5,
"height": 0.5,
"gravity": 0,
}
We’re telling the game that this enemy’s graphic (fireplantfire.png) has 4 frames and that they should be cycled through with 0.1 seconds for each frame. The fireball itself has no movement pattern so it will just keep moving where it was sent to. It kills on contact (there’s also separate attributes for “killsonsides”, “killsontop” and “killsonbottom”) and it’s half a block (8 pixels) big. Lastly, it has no gravity so it doesn’t fall down.

So now that we have everything that we need, let’s try it out!

Everything’s working as expected. To make the Piranha plant face Mario in case we had replaced its graphic, we’d have to set “facesplayer” to true.
I hope this gives some insight into the enemy creation for mappack authors and will be enough to satisfy all the creative minds out there.