Monolith Dev Blog 5 – Locked and Loaded
The focus of this past week has been combat!
Also, player’s are given a random color, which is synced across multiplayer, just a fun little feature that had no other place in this blog.
Locking On
Players can now lock on to mobs. This adds a completely new feature that was not previously used, the mouse! To lock on to a specific mob, the player would just click on the mob, and a circle is drawn around it. Also there is a button to lock onto the closest mob, right now bound to the ‘e’ key.
When the player is locked onto a mob and loses sight of the mob, the player is no longer locked onto.
What does locking on do you may wonder, well it does some very useful things, which will be covered in the next two sections of new features!
Status
At the top of the screen, there is now a status bar (when there is something to display)
When hovering your mouse over a mob or a player (including yourself) the status bar will appear with the mob/player’s name, remaining health, and the tile they are currently on.

Homing Shots
Another very nice new feature that is necessary for the combat system is homing shots. When a player is locked onto a mob and fires a projectile, the projectile will try to correct it path to fire more towards the mob. It will not correct it’s path too much, so the player still has to shoot in the correct direction for the spell to hit it’s target.
Now a mob does not have to completely line up diagonally, horizontally, or vertically for a shot to hit. This makes the combat feel a lot better, less annoying, and has the potential to allow the gameplay to feel faster than having to carefully line up a shot every time. Plus, the correcting amount of projectiles can be easily changed so if I ever want to change the feel of the combat I can easily adjust the projectile homing!
Revenge of the Mobs
Better run, better hide, because now the mobs won’t just sit around waiting to be killed anymore. They are taking back the level, one player at a time!
Mobs can now fire projectiles! The spells they can fire are assigned when they are created and each spell it casts is randomly chosen from the spells it was given. Right now, mobs can only shoot in 8 directions. In the future, the plan is that mobs using A* pathfinding will have homing projectiles.
The Move Toward mob AI also got a bit smarter! Mobs using that AI now move to get a shot on the player rather than blindly move toward the player. If a player is outside it’s maximum range, it will try to move toward the player and try to get a shot on the player.
The way it tries to get a shot is actually simple thanks to some math! Since the mob can only fire in 8 directions, it will try to find a diagonal, horizontal, or vertical position relative to it’s target. It does this by finding the distance from the player, and if the x distance is closer to the y distance than 0, it moves toward a diagonal shot, otherwise it tries to line up a horizontal or vertical shot. The reason it compares the x and y distance is because if the x and y distances are equal, that means that it is diagonal to it’s target.
And the best part of this new AI is that it almost just as efficient as the before, but seemingly much smarter! And it barely took any additional code, in fact here is an image of the entire Move Towards mob AI pathfinding

And that wraps up the changes, which may not be a ton in terms of a big change since last week, but a lot has been added that will be very useful for the rest of the games development, such as being able to use the mouse in-game.