top of page
Search

Wombat! Uh, Combat!

Writer: Mark Montenieri
Mark Montenieri
Dec 23, 2022
3 min read

Since my last post in October, I’ve been working steadily on the next features on my list of things to do. The first being a Leveling and Experience system. When a player completes a “talk to x” quest, they now receive experience toward leveling up. This one was tough because it required a good bit of database interaction, to ensure that the player’s progress got recorded in real-time, as well as repopulating that data if the player left the game and returned later. Since the quest system is already rather large and intricate, ensuring all the I’s were dotted and t’s crossed took longer than expected, but it appears to be bug-free so far.


There are so many things that, as a player, you don’t think of when questing or utilizing some feature of a game. For example, if the player receives more experience than needed to level up, you have to check to see if there are enough points to level up again (and again), or just partially fill their xp bar. The scenarios get complicated quickly and must all be accounted for. This is just one of many examples that a game developer faces when creating a new feature or system, and this one is nothing more than a talking quest!


The next bit I tackled is PVE combat. First, the NPC (Non-Player Character – i.e. Computer enemies) must attack the player automatically when in range and then the player can choose to run or fight. For the NPC to attack the player, it needed a “blueprint” of what to do and when to do it, so I used the Behavior Tree system built into Unreal Engine. I knew a little about it but not enough to be proficient, so I spent a good week and a half following some YouTube tutorials to learn not only how to do it but how to do it mostly in C++. Eventually, the pieces came together, and I gained a better understanding of how to make this work. The NPC now dutifully chases the player when in range, runs back when they get too far from their home base or when the player creates too much distance between them and the enemy NPC.


Getting the player to attack the NPC was more difficult, believe it or not. I struggled for a time since the NPC is controlled by the server and any actions it took were authoritative and then passed down to the players. For player to NPC combat, it dealt with attack timers and the need for Server RPC’s (asking the server to do something on your behalf). I know that the server is authoritative, not the client and everything happens on the server before getting replicated to clients, I just wasn’t sure how to ask the server to do something from the client when inside a timer delegated function. Yeah, it was confusing to me, too. That took me a good 2 weeks to figure out but now the player and enemy can beat each other into oblivion, yay!


If you understood any of that, cool. If not, don’t worry, just know that I accomplished player vs. NPC combat and nothing has caught fire…yet.

Lastly, I had an interesting inventory “bug” while I was working on combat where I couldn’t pick up anything, it would just crash the server. After some investigation, I found that the inventory table in the database had thousands of repeated entries for each inventory slot. Weird. I made a small change to the ASP web server code to delete any existing entries before posting the updated data. I will likely revisit this at some point to do an update instead of a delete/insert (single operation vs. 2 operations) for better speed.


That’s it for this riveting episode of “I don’t really understand what he’s doing but if he’s having fun then I’m happy for him.”

 
 
 

Recent Posts

See All
It's been awhile...

Between work, class, life and whatnot I've paused development on the MMO template project. I'm not giving up on it, just the opposite...

 
 
 
Refactor!

Wow, what a mess! As I continue on this journey to create an MMO template that others will be able to use as inspiration to create their...

 
 
 

Comments


  • facebook

©2022 by Mark Montenieri. Proudly created with Wix.com

bottom of page