Creating Game Bosses(SOLVED)

Good evening everyone.
Here’s a news - I got stuck again, creating the last part of my game - in game bosses. I just spent the entire week thinking over it, and trying to develop a solid logic, and day after day, I continued to fail :frowning_face: So, finally I thought why not approach the community?
So, how do we actually code the game bosses,?
Thanks in advance…

I’m not sure what you’re asking here. Are you asking for help with the actual coding, or do you want some help with the whole concept, that is, how to approach their creation from the gameplay persepctive?

In either case more details would be helpful.

2 Likes

What kind of game are you creating? Can you give an example of the type of boss behaviour you want in your game? Perhaps show an example or two from games with the kind of boss you want to create.

Something like nuclear throne, or enter the gungeon.

Again, something like nuclear throne, or enter the gungeon.

Actually, when I look at them, sometimes, I envy the minute details that they have, how every attack is perfectly timed, and well executed, and want to have a similar experience too but I never happen to grasp the logic. Well @Klear, I don’t know which of the above two mentioned category it satisfies, but I’m sure you are getting ready what I am trying to say…

The nuclear throne wiki has most of the details you need to recreate those bosses’ behavior. I suspect they are incredibly simple and what you see as “perfectly timed…well executed” attacks is just a matter of a lot of playtesting and tweaking a few values, not some fancy AI that can predict the perfect timing. This is my guess for how Big Bandit works:

Big Bandit

Movement - Just like bandits, he has an alternating timer running. He stands still for a little bit, then walks for a little bit (in a random direction away from the player if the player is close, otherwise in a random direction towards the player).

Attacks - Another timer, attack whenever it ends. (If he’s like the bandits, he only shoots when he’s not walking. )

  • Charge - If the player is close or not in line-of-sight, charge straight towards the player.
  • Shoot - Fire a barrage of a certain number of bullets. Aim straight towards the player when the barrage starts. Bullets have a fair amount of random spread. (inaccuracy)

For Big Dog, again, read the wiki article, they tell you exactly what phases he goes through. (likewise for the other Nuclear Throne bosses) It’s a lot simpler than you think.

3 Likes

You could give Finite State Machines a try:
https://en.wikipedia.org/wiki/Finite-state_machine

It took me about a week for it to sink in but when it did it made Boss logic pretty easy.

You basically set up states your Boss could be in, such as walking, stopped or hit, and state changes that are allowed. For example you can only stop if you’re walking or be hit if your not already recovering.

Then in your update function you do things like (Psuedo code warning):

if boss_pos.x >= left_limit and self.fsm.current == 'walking' then
    move_boss()
end

if boss_pos.x == left_limit and self.fsm.current == 'walking' then
    self.fsm:stop()
end

if boss_pos.x == left_limit and self.fsm.current == 'standing' then
    self.fsm:turn()
end

When setting up the fsm you add callbacks to each state, then whenever the fsm state changes the fsm calls a callback function to handle the action (such as turn callback would flip the sprite then change the fsm to walking) etc.

You can get really intricate but it keeps the logic structured which is what I struggled with. But it’s quite hard to grasp!

Here’s the lua one I’ve been using which includes some examples: https://github.com/kyleconroy/lua-state-machine

1 Like

@approbo.games Looks like I have tried to make something similar all the week long. But as you said, finite machines are really hard to understand, and much, much harder to code. I will try to learn that, but still, my wish was to create my own.

BTW @ross.grams I have developed logic for various boss abilities like radial fire, charge, fire_weapon etc, etc. But the problem I face is to get the current state’s state, and find when to transition to the next state…

Moreover, I found this in unity’s tutorials, Can anyone help me implement something similar in lua.
BTW: a remark(or maybe a game developers quote)
Making bosses is sometimes harder than killing them…

Oyster and its global state is pretty useful and easy. I’m using it and in update function I check for a state change like this:

if state.get() ~= self.state then self.state = state.get()  
   if self.state == "IDLE" then ...
   elseif self.state == "ATTACK" then ...
   end
end

And apply what an object has to do, when the state changed. Then I can change anywhere in the code the state and all interested objects will be notified about it.
I don’t think that checking only one condition in update and if it is, then doing something, is too hard for engine, though you can create one notifier script when you would at first register all interested objects as subscribers and then at the state change send msg to them and they will handle it in their way.
FSMs are all about states and transitions between them at specified conditions. So you can always check at first for a current state and then for proper conditions and then create a transition to the next state when something happens :wink:

Finally, I made them, and as @ross.grams said, ,it was much easier than I thought, I was just fancying things a lot. It now has a custom staye manager, and works perfectly. So, now the only thing left, is to make a pathfinder. I am not yet sure how to do it, but I will have to :cry:

2 Likes