![]() |
| Summoner's Rift - League of Legends |
While it was touched on during the previous weeks (as a Core Mechanic), it was never actually fully implemented and left as a String based system that didn't really affect game-play (it was like a game of its own).
Blocks of Code were commented as "Insert Minion Spawn here" were never actually finished and the entire Wave System was left quite raw. So obviously the first thing that was attempted was to hook up exactly the way the blocks of code were commented -- put minion spawn here etc. etc.
But unfortunately... that didn't exactly work...
This was because Julian's Minion Spawning Scripts happened on event ticks - meaning that every frame that the game runs, the game checks if the number of a minion spawned equalled its max wave - if not summon another one.
I had my "raw" Wave coding under a Custom Event that was called once instead of every frame. This Custom Event would've summoned X Minions were X is the Wave Length rather than spawning it one by one as in Julian's code.
It also so happens that due to the way Custom Event works in Unreal, I also could not connect it to the Event Tick Node. This meant that I had to completely redo the current Wave System to accommodate.
That had a fairly easy solve which was to imitate Julian's code and move the Wave Checker into the Event Tick - so every frame of the game, the game checks if every monster has been killed, if so - increment the wave and reset the variables.
But there the second problem arose... How to count the Dead Enemies.
The first way was of course, a series of simple steps
- Set an Integer called Enemies Killed
- In the Enemy AI, make it so when an enemy is killed, increase the integer
- If the Integer matches, start next wave
But... coding never is so nice. To obtain the when an enemy is killed, you would have to cast to the Level Blueprints (an almost infamous problem at this point). With Unreal being quite strict on not allowing you to cast to the Level Blueprint (preferring you to use a much more painful Event Dispatchers which are complicated and frankly never work...), we had to forego this method.
The alternative was to put the Enemies Killed Integer in the Enemy AI Script and then collect it (calling it) at every tick in the Level Blueprints. This was met with several issues again...
- Flawed Logic - since every enemy is its own being, it doesn't share its variable. So every individual enemy will have 0 enemies killed, and when they die, it increases to 1. That doesn't mean that every enemy has their count increased... just that individual monster.
- Casting to Ironshell AI -- Casting is used to obtain a variable from another script (in this case one of the Minion's AI). Unfortunately... Due to the way it spawns as a Pawn, there was no Object we could find to link with it and we could never call it.
The Solution
It actually came to me while playing League of Legends. Every player had CS or "Creep Score" which indicates the amount of monsters killed in that game. Since I knew for sure that casting to the Player is possible (and the go-to method for all coding in Unreal), I ended up creating an Enemies Killed variable in the PLAYER'S script.
This acted as a "Creep Score" of sorts and every time the Number of Enemies Spawned equalled the Enemies Dead -- Start next wave, reset all the variables.
While definitely NOT the hardest Code I had to do this semester, it was one that required a bit of thinking to figure out how to piece it together. As quite an important part of the game - a ton of play-testing to make sure it worked correctly was done. Minions had to spawn correctly, Wave had to increment, there had to be a Delay between the Waves... It all had to come together.
Fortunately. It did.

















