Posted April 10, 2024 by PestoRavioli
In today's update, I want to talk briefly about displaying the enemy names in battle. I had been using the advanced dialog plugin. That provides an option for "background text" that I was using. I'd check the enemy number and type and display the corresponding enemy name when the battleUI scene was called. It worked fine, except I had text overflowing from the dialog and menu boxes. I couldn't figure out what was going on. I stumbled upon a github post stating that you're limited to 52 characters of text in memory at a time. I started playing around with the text displayed and realized that this was my issue. The background text values counted towards that limit.
Around the same time, but before I found that post, I posted on reddit and the gb studio discord about this. It was suggested that I display sprites for the enemy names. So, that's what I ended up doing. It took some work, but I got it. Or so I thought. I quickly realized that only 5 letters were showing up in any enemy name (I set up 8 actors to display sprites for the name). I noticed this because I named my pikaclone as 'chonky' and it, much to my happiness, displayed it as honky.
I wasted a good 3-4 hours changing things around, simplifying and streamlining scripts, etc but nothing would work. At this point I was pretty frustrated so I took to Discord. A super helpful person named gearfo pointed out that there's a limit of "10 hardware sprites" and a single hardware sprite is 8x16. My original letter sprites were 16x16 sprites and thus each letter counted as two. I was able to fit the letters in to 8x16 images and thus they are the same size, but they fit in the limitation of 10 hardware sprites now.
While I was doing this, I decided to add an additional script. I don't recall if I mentioned it, but the scene I have my battle ui on (called battleUI) takes for-ev-er to do anything on. I'm not sure why exactly, but it does. Probably something to do with how the battle engine is coded and called from it. Anyhow, it's super frustrating touching that scene. It is where I housed the enemy name logic and sprite logic. Well, no longer! I created a script that I can now edit with all of that information that is called from the battleUI scene(specifically, the init section of one of the actors i set up with a letter sprite). in the script, I tell it which letter sprite to display along with what sprite to display. It has made the process much much less painful.
Anyhow, here's my honky!
EDIT:
Editing the post with a small update. I may or may not have mentioned plans for this in the battle system. So, the character sprite is supposed to be based off our current dog -- a Great Pyrenees. This breed is super smart, but incredibly stubborn. They often hear you and understand the command, but will frequently ignore what you say until they're good and ready. They also looooooove to give you the side eye. With that in mind, I created a 'stubbornness' stat. It starts at 100 and as the player levels up, it gradually goes down. My plan is to basically have a sliding scale of your battle orders being ignored until their stubborn stat gets low enough for them to obey all commands. I have no idea yet exactly how this will impact battles as I basically have placeholder enemy stats in there for now. It may or may not make the final cut, but I've implemented that functionality today.