Behind the scenes of enemy trash talk system in my custom game engine!

Yesterday, I made a post about how I created a dialog engine from scratch. However, I didn't get into how the trash talk system works, which is what this post is about!
You can check out yesterdays post: https://ldjam.com/events/ludum-dare/46/a-samurai-friend-of-mine/behind-the-scenes-of-my-own-game-engine-made-in-72-hours
The trash talk system is also managed by the dialogManager class that manages all the dialog in the game. However, the actual content of the trash talk is dependent on the scene. I will get into how I managed scenes, or "contexts" as they are called in my DIY game engine, on another post. We can briefly describe them as the entity that is aware of what is going on in the level.
All the content of the trash talk that is going to be displayed on that level is kept in it's context object as an std::vector.

This "trash talk stack" gets filled during the initialization of the context. So if I wanted to add a new trash talk line to any level I can just go to it's .cpp file and .push_back a new line.

Okay great! So how do I decide which enemy gets which line? It's all random. Anything pushed into the trash talk stack is randomly distributed amongst enemies that are alive and in the scene. Well, actually not that random. Every enemy gets to display a single line for 3 seconds and then the next enemy displays the next trash talk line for the next 3 seconds. So it's actually sequential. However, because the number of enemies and the number of unique lines don't match, it all seems random. At least untill you play the same level again.

It's pretty simple so far. But I added one more thing which seemed like a cool idea to me.
These lines already have the ability to change based on the level, for example they can trash talk you about how your chances of beating the "Big O" is so slim before you actually beat him. And then when you actually beat the boss they can tell you how he had a really nice family and how he was a great individual who liked to give back.
I also wanted them to react to what happens during the fight. This piece of code makes it possible for the enemies to react when you hit them during the fight.

One question you might still have in mind is, how does DM->addPopUp() work. It's also pretty simple. It just pushes the text into another stack. DM is the dialog manager. The dialog manager has it's own popup vector. However, it stands for what is being said instead of what can be said. Meaning if something is in the popup vector of the dialog manager, it is also being displayed on the screen. Popups automatically get deleted after a while so that the trash talk text disappears after a few seconds. This is how it's done.

That's about all. Well, actually there is much more to explain before all this comes together but since I don't want to bore people to death this is it for today's post.

By the way, if you have a good idea for a trash talk line that can be used in the game, comment below and I might actually add it into the game!
Also, try the game out to see how it all comes together at the end:
https://ldjam.com/events/ludum-dare/46/a-samurai-friend-of-mine
Source: ldjam.com archive